Comparing version 2.2.0-beta.5 to 2.2.0-beta.6
@@ -1,2 +0,2 @@ | ||
import { Logic, LogicWrapper, Props, LogicInput, BuiltLogicAdditions } from '../types'; | ||
export declare function getBuiltLogic(inputs: LogicInput[], props: Props, wrapper: LogicWrapper, autoConnectInListener?: boolean): Logic & BuiltLogicAdditions; | ||
import { LogicWrapper, Props, LogicInput, BuiltLogic } from '../types'; | ||
export declare function getBuiltLogic(inputs: LogicInput[], props: Props, wrapper: LogicWrapper, autoConnectInListener?: boolean): BuiltLogic; |
import { Logic, LogicInput, LogicWrapper, LogicWrapperAdditions } from '../types'; | ||
export declare function proxyFieldToLogic(wrapper: LogicWrapper, key: keyof Logic): void; | ||
export declare function proxyFields(wrapper: LogicWrapper): void; | ||
export declare function kea<LogicType extends Logic = Logic>(input: LogicInput<LogicType>): LogicType & LogicWrapperAdditions; | ||
export declare function connect<LogicType extends Logic = Logic>(input: LogicInput['connect']): LogicType & LogicWrapperAdditions; | ||
export declare function kea<LogicType extends Logic = Logic>(input: LogicInput<LogicType>): LogicType & LogicWrapperAdditions<LogicType>; | ||
export declare function connect<LogicType extends Logic = Logic>(input: LogicInput['connect']): LogicType & LogicWrapperAdditions<LogicType>; |
@@ -5,9 +5,12 @@ import { Reducer, Store, Action as ReduxAction } from 'redux'; | ||
export declare type Selector = (state?: any, props?: any) => any; | ||
export declare type PathCreator = (key?: string) => string[]; | ||
export declare type Props = Record<string, any>; | ||
export declare type RequiredPathCreator<T = string> = (key: T) => PathType; | ||
export declare type PathCreator<T = string> = (key?: T) => PathType; | ||
export declare type PathType = (string | number | boolean)[]; | ||
export declare type Props = Record<string, unknown>; | ||
export interface Logic { | ||
key: any; | ||
path: string[]; | ||
pathString: string; | ||
props: Props; | ||
actionCreators: any; | ||
actionKeys: Record<string, string>; | ||
actionTypes: Record<string, string>; | ||
actions: any; | ||
cache: Record<string, any>; | ||
@@ -18,7 +21,6 @@ connections: { | ||
constants: Record<string, string>; | ||
actionCreators: any; | ||
actionKeys: Record<string, string>; | ||
actionTypes: Record<string, string>; | ||
actions: any; | ||
defaults: Record<string, any>; | ||
path: PathType; | ||
pathString: string; | ||
props: Props; | ||
reducers: any; | ||
@@ -30,3 +32,2 @@ reducerOptions: Record<string, any>; | ||
values: Record<string, any>; | ||
propTypes: unknown; | ||
events: { | ||
@@ -45,10 +46,10 @@ beforeMount?: () => void; | ||
} | ||
export interface LogicWrapperAdditions { | ||
export interface LogicWrapperAdditions<LogicType extends Logic> { | ||
_isKea: boolean; | ||
_isKeaWithKey: boolean; | ||
inputs: LogicInput[]; | ||
(params: AnyComponent): FunctionComponent; | ||
(params: Props | undefined): BuiltLogic; | ||
(component: AnyComponent): FunctionComponent; | ||
(props: LogicType['props'] | undefined): BuiltLogic; | ||
wrap: (Component: AnyComponent) => KeaComponent; | ||
build: (props?: Props, autoConnectInListener?: boolean) => BuiltLogic; | ||
build: (props?: LogicType['props'], autoConnectInListener?: boolean) => BuiltLogic; | ||
mount: (callback?: any) => () => void; | ||
@@ -58,3 +59,3 @@ extend: (extendedInput: LogicInput) => LogicWrapper; | ||
export declare type BuiltLogic = Logic & BuiltLogicAdditions; | ||
export declare type LogicWrapper = Logic & LogicWrapperAdditions; | ||
export declare type LogicWrapper = Logic & LogicWrapperAdditions<Logic>; | ||
declare type ActionDefinitions<LogicType extends Logic> = Record<string, any | (() => any)> | LogicType['actionCreators']; | ||
@@ -93,4 +94,4 @@ declare type ReducerActions<LogicType extends Logic, ReducerType> = { | ||
extend?: LogicInput[]; | ||
key?: (props: Props) => string; | ||
path?: PathCreator | string[]; | ||
key?: (props: LogicType['props']) => any; | ||
path?: (LogicType['key'] extends undefined ? PathCreator<LogicType['key']> : RequiredPathCreator<LogicType['key']>) | PathType; | ||
connect?: any; | ||
@@ -132,3 +133,3 @@ constants?: () => string[] | string[]; | ||
defaults: Values; | ||
path: string[]; | ||
path: PathType; | ||
pathString: string; | ||
@@ -220,3 +221,3 @@ reducerOptions: Record<string, unknown>; | ||
input: { | ||
inlinePathCreators: Map<LogicInput, PathCreator>; | ||
inlinePathCreators: Map<LogicInput, PathCreator<any>>; | ||
inlinePathCounter: number; | ||
@@ -223,0 +224,0 @@ defaults: Record<string, any> | undefined; |
{ | ||
"name": "kea", | ||
"version": "2.2.0-beta.5", | ||
"version": "2.2.0-beta.6", | ||
"description": "Smart front-end architecture", | ||
@@ -5,0 +5,0 @@ "author": "Marius Andra", |
@@ -8,3 +8,3 @@ import { runPlugins } from '../plugins' | ||
import { Logic, LogicWrapper, Props, LogicInput, BuiltLogicAdditions } from '../types' | ||
import { Logic, LogicWrapper, Props, LogicInput, BuiltLogicAdditions, BuiltLogic } from '../types' | ||
@@ -129,3 +129,8 @@ // Converts `input` into `logic` by running all build steps in succession | ||
export function getBuiltLogic(inputs: LogicInput[], props: Props, wrapper: LogicWrapper, autoConnectInListener = true) { | ||
export function getBuiltLogic( | ||
inputs: LogicInput[], | ||
props: Props, | ||
wrapper: LogicWrapper, | ||
autoConnectInListener = true, | ||
): BuiltLogic { | ||
const input = inputs[0] | ||
@@ -132,0 +137,0 @@ const key = props && input.key ? input.key(props) : undefined |
@@ -129,4 +129,6 @@ import { getContext } from '../context' | ||
export function kea<LogicType extends Logic = Logic>(input: LogicInput<LogicType>): LogicType & LogicWrapperAdditions { | ||
const wrapper: LogicType & LogicWrapperAdditions = (function ( | ||
export function kea<LogicType extends Logic = Logic>( | ||
input: LogicInput<LogicType>, | ||
): LogicType & LogicWrapperAdditions<LogicType> { | ||
const wrapper: LogicType & LogicWrapperAdditions<LogicType> = (function ( | ||
args: undefined | AnyComponent, | ||
@@ -138,3 +140,3 @@ ): (LogicType & BuiltLogicAdditions) | KeaComponent { | ||
return wrapper.wrap(args) | ||
} as any) as LogicType & LogicWrapperAdditions | ||
} as any) as LogicType & LogicWrapperAdditions<LogicType> | ||
@@ -166,4 +168,4 @@ wrapper._isKea = true | ||
input: LogicInput['connect'], | ||
): LogicType & LogicWrapperAdditions { | ||
): LogicType & LogicWrapperAdditions<LogicType> { | ||
return kea({ connect: input }) | ||
} |
@@ -7,4 +7,6 @@ import { Reducer, Store, Action as ReduxAction } from 'redux' | ||
export type Selector = (state?: any, props?: any) => any | ||
export type PathCreator = (key?: string) => string[] | ||
export type Props = Record<string, any> // nb! used in kea and react | ||
export type RequiredPathCreator<T = string> = (key: T) => PathType | ||
export type PathCreator<T = string> = (key?: T) => PathType | ||
export type PathType = (string | number | boolean)[] | ||
export type Props = Record<string, unknown> // nb! used in kea and react | ||
@@ -14,8 +16,2 @@ // logic base class | ||
key: any | ||
path: string[] | ||
pathString: string | ||
props: Props | ||
cache: Record<string, any> | ||
connections: { [pathString: string]: BuiltLogic } | ||
constants: Record<string, string> | ||
actionCreators: any | ||
@@ -25,3 +21,9 @@ actionKeys: Record<string, string> | ||
actions: any | ||
cache: Record<string, any> | ||
connections: { [pathString: string]: BuiltLogic } | ||
constants: Record<string, string> | ||
defaults: Record<string, any> | ||
path: PathType | ||
pathString: string | ||
props: Props | ||
reducers: any | ||
@@ -33,3 +35,2 @@ reducerOptions: Record<string, any> | ||
values: Record<string, any> | ||
propTypes: unknown | ||
events: { | ||
@@ -51,10 +52,10 @@ beforeMount?: () => void | ||
export interface LogicWrapperAdditions { | ||
export interface LogicWrapperAdditions<LogicType extends Logic> { | ||
_isKea: boolean | ||
_isKeaWithKey: boolean | ||
inputs: LogicInput[] | ||
(params: AnyComponent): FunctionComponent | ||
(params: Props | undefined): BuiltLogic | ||
(component: AnyComponent): FunctionComponent | ||
(props: LogicType['props'] | undefined): BuiltLogic | ||
wrap: (Component: AnyComponent) => KeaComponent | ||
build: (props?: Props, autoConnectInListener?: boolean) => BuiltLogic | ||
build: (props?: LogicType['props'], autoConnectInListener?: boolean) => BuiltLogic | ||
mount: (callback?: any) => () => void | ||
@@ -65,3 +66,3 @@ extend: (extendedInput: LogicInput) => LogicWrapper | ||
export type BuiltLogic = Logic & BuiltLogicAdditions | ||
export type LogicWrapper = Logic & LogicWrapperAdditions | ||
export type LogicWrapper = Logic & LogicWrapperAdditions<Logic> | ||
@@ -169,4 +170,6 @@ // input helpers (using the generated logic type as input) | ||
extend?: LogicInput[] | ||
key?: (props: Props) => string | ||
path?: PathCreator | string[] | ||
key?: (props: LogicType['props']) => any | ||
path?: | ||
| (LogicType['key'] extends undefined ? PathCreator<LogicType['key']> : RequiredPathCreator<LogicType['key']>) | ||
| PathType | ||
@@ -226,3 +229,3 @@ connect?: any | ||
defaults: Values | ||
path: string[] | ||
path: PathType | ||
pathString: string | ||
@@ -324,3 +327,3 @@ reducerOptions: Record<string, unknown> | ||
input: { | ||
inlinePathCreators: Map<LogicInput, PathCreator> | ||
inlinePathCreators: Map<LogicInput, PathCreator<any>> | ||
inlinePathCounter: number | ||
@@ -327,0 +330,0 @@ defaults: Record<string, any> | undefined |
464956
13784