@flowerforce/flower-react 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/LICENSE +15 -0
- package/README.md +771 -0
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.default.js +1 -0
- package/dist/index.cjs.js +1134 -0
- package/dist/index.cjs.mjs +2 -0
- package/dist/index.esm.d.ts +1 -0
- package/dist/index.esm.js +1113 -0
- package/dist/src/components/Flower.d.ts +9 -0
- package/dist/src/components/FlowerAction.d.ts +4 -0
- package/dist/src/components/FlowerComponent.d.ts +4 -0
- package/dist/src/components/FlowerField.d.ts +4 -0
- package/dist/src/components/FlowerFlow.d.ts +4 -0
- package/dist/src/components/FlowerNavigate/WrapperComponent.d.ts +4 -0
- package/dist/src/components/FlowerNavigate/index.d.ts +4 -0
- package/dist/src/components/FlowerNavigate/useFlowerNavigate.d.ts +7 -0
- package/dist/src/components/FlowerNode.d.ts +4 -0
- package/dist/src/components/FlowerRoute.d.ts +4 -0
- package/dist/src/components/FlowerRule.d.ts +4 -0
- package/dist/src/components/FlowerServer.d.ts +4 -0
- package/dist/src/components/FlowerStart.d.ts +4 -0
- package/dist/src/components/FlowerValue.d.ts +4 -0
- package/dist/src/components/types/DefaultNode.d.ts +8 -0
- package/dist/src/components/types/FlowerComponent.d.ts +4 -0
- package/dist/src/components/types/FlowerField.d.ts +30 -0
- package/dist/src/components/types/FlowerFlow.d.ts +4 -0
- package/dist/src/components/types/FlowerHooks.d.ts +26 -0
- package/dist/src/components/types/FlowerNavigate.d.ts +37 -0
- package/dist/src/components/types/FlowerNode.d.ts +4 -0
- package/dist/src/components/types/FlowerProvider.d.ts +13 -0
- package/dist/src/components/types/FlowerRoute.d.ts +8 -0
- package/dist/src/components/types/FlowerRule.d.ts +12 -0
- package/dist/src/components/types/FlowerServer.d.ts +7 -0
- package/dist/src/components/types/FlowerValue.d.ts +11 -0
- package/dist/src/components/useFlower.d.ts +3 -0
- package/dist/src/components/useFlowerForm.d.ts +3 -0
- package/dist/src/context.d.ts +9 -0
- package/dist/src/index.d.ts +20 -0
- package/dist/src/provider.d.ts +19 -0
- package/dist/src/reducer.d.ts +7 -0
- package/dist/src/selectors.d.ts +1377 -0
- package/dist/src/utils.d.ts +10 -0
- package/package.json +49 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
2
|
+
type FlowerClientProps = PropsWithChildren & {
|
3
|
+
name: string;
|
4
|
+
destroyOnUnmount?: boolean;
|
5
|
+
startId?: string | null;
|
6
|
+
initialData?: any;
|
7
|
+
};
|
8
|
+
declare const component: React.MemoExoticComponent<({ children, name, destroyOnUnmount, startId, initialData }: FlowerClientProps) => React.JSX.Element | null>;
|
9
|
+
export default component;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { FlowerFieldProps } from './types/FlowerField';
|
3
|
+
declare const component: React.MemoExoticComponent<({ id, validate, asyncValidate, asyncDebounce, asyncInitialError, asyncWaitingError, rules, alwaysDisplay, value, children, defaultValue, destroyValue, flowName, onUpdate }: FlowerFieldProps<any>) => React.JSX.Element | (string | number | Iterable<React.ReactNode> | React.JSX.Element)[] | null | undefined>;
|
4
|
+
export default component;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { FlowerNavigateProps } from '../types/FlowerNavigate';
|
3
|
+
declare const component: React.MemoExoticComponent<({ children, flowName: forceFlowName, action, route, node, rules, alwaysDisplay, }: FlowerNavigateProps) => React.JSX.Element | (string | number | Iterable<React.ReactNode> | React.JSX.Element)[] | null | undefined>;
|
4
|
+
export default component;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { FlowerNavigateProps } from '../types/FlowerNavigate';
|
2
|
+
type UseFlowerNavigateProps = Pick<FlowerNavigateProps, 'flowName' | 'node' | 'route' | 'action'>;
|
3
|
+
export declare const useFlowerNavigate: ({ flowName, action, route, node }: UseFlowerNavigateProps) => {
|
4
|
+
onNavigate: () => void;
|
5
|
+
flowName: string | undefined;
|
6
|
+
};
|
7
|
+
export {};
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { FlowerRuleProps } from './types/FlowerRule';
|
3
|
+
declare const component: React.MemoExoticComponent<({ children, rules, value, alwaysDisplay, flowName, id, onUpdate }: FlowerRuleProps) => string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | (string | number | Iterable<React.ReactNode> | React.JSX.Element)[] | null | undefined>;
|
4
|
+
export default component;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { FlowerValueProps } from './types/FlowerValue';
|
3
|
+
declare const component: React.MemoExoticComponent<({ id, rules, alwaysDisplay, value, children, spreadValue, flowName, onUpdate, }: FlowerValueProps) => React.JSX.Element | (string | number | React.JSX.Element | Iterable<React.ReactNode>)[] | null | undefined>;
|
4
|
+
export default component;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { RulesObject } from '@flowerforce/flower-core';
|
2
|
+
export type FlowerFieldProps<T extends Record<string, any>> = {
|
3
|
+
id?: string;
|
4
|
+
children: React.ReactNode | ((props: {
|
5
|
+
id: string;
|
6
|
+
value: any;
|
7
|
+
errors: undefined | string[];
|
8
|
+
hasError: undefined | boolean;
|
9
|
+
onChange: (props: any) => void;
|
10
|
+
onBlur: () => void;
|
11
|
+
isTouched: boolean;
|
12
|
+
hidden: boolean;
|
13
|
+
isValidating: boolean | undefined;
|
14
|
+
}) => React.ReactNode | React.ReactElement | undefined);
|
15
|
+
validate?: Record<string, any>[] | string[];
|
16
|
+
asyncValidate?: (value: any, data?: Record<string, any>, errors?: undefined | string[]) => string[] | undefined | Promise<string[]> | {
|
17
|
+
message: string;
|
18
|
+
}[] | boolean | Promise<boolean>;
|
19
|
+
asyncDebounce?: number;
|
20
|
+
asyncInitialError?: string;
|
21
|
+
asyncWaitingError?: string;
|
22
|
+
rules?: RulesObject<T>;
|
23
|
+
flowName?: string;
|
24
|
+
defaultValue?: unknown;
|
25
|
+
destroyValue?: boolean;
|
26
|
+
value?: any;
|
27
|
+
alwaysDisplay?: boolean;
|
28
|
+
onUpdate?: (value: any) => void;
|
29
|
+
onBlur?: (e: any) => void;
|
30
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { Route, RouteNode, RoutePrev, RouteReset } from './FlowerNavigate';
|
2
|
+
export type UseFlowerProps = {
|
3
|
+
[x in 'name' | 'flowName']?: string;
|
4
|
+
};
|
5
|
+
export type UseFlowerForm = (options?: UseFlowerProps) => {
|
6
|
+
touched: boolean;
|
7
|
+
errors: Record<string, any>;
|
8
|
+
isValid: boolean;
|
9
|
+
isValidating: boolean | undefined;
|
10
|
+
getData: (path?: string) => any;
|
11
|
+
setData: (value: any, path?: string) => void;
|
12
|
+
unsetData: (path: string) => void;
|
13
|
+
replaceData: (value: any) => void;
|
14
|
+
};
|
15
|
+
type useFlowerActions = {
|
16
|
+
next: (payload?: Route) => void;
|
17
|
+
back: (payload?: RoutePrev) => void;
|
18
|
+
reset: (payload?: RouteReset) => void;
|
19
|
+
jump: (payload: RouteNode) => void;
|
20
|
+
};
|
21
|
+
export type UseFlower = (options?: UseFlowerProps) => useFlowerActions & {
|
22
|
+
flowName?: string;
|
23
|
+
nodeId: string;
|
24
|
+
};
|
25
|
+
export type NavigateFunctionParams = string | Record<string, any>;
|
26
|
+
export {};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { RulesObject } from '@flowerforce/flower-core';
|
2
|
+
export type Route = string | Record<string, any>;
|
3
|
+
export type RouteNode = string | {
|
4
|
+
node: string;
|
5
|
+
flowName?: string;
|
6
|
+
history?: string[];
|
7
|
+
};
|
8
|
+
export type RouteReset = string | {
|
9
|
+
node: string;
|
10
|
+
flowName?: string;
|
11
|
+
};
|
12
|
+
export type RoutePrev = string | {
|
13
|
+
node: string;
|
14
|
+
flowName?: string;
|
15
|
+
};
|
16
|
+
export type FlowerNavigateProps = {
|
17
|
+
flowName?: string | undefined;
|
18
|
+
children: React.ReactNode | ((props: Record<string, any>) => React.ReactNode | React.ReactElement | undefined);
|
19
|
+
rules?: RulesObject<Record<string, any>> | Record<string, RulesObject<any>>;
|
20
|
+
alwaysDisplay?: boolean;
|
21
|
+
} & ({
|
22
|
+
action?: 'next';
|
23
|
+
node?: undefined;
|
24
|
+
route?: Route;
|
25
|
+
} | {
|
26
|
+
action?: 'back';
|
27
|
+
node?: RoutePrev;
|
28
|
+
route?: undefined;
|
29
|
+
} | {
|
30
|
+
action?: 'reset';
|
31
|
+
node?: RouteReset;
|
32
|
+
route?: undefined;
|
33
|
+
} | {
|
34
|
+
action?: 'jump';
|
35
|
+
node?: RouteNode;
|
36
|
+
route?: undefined;
|
37
|
+
});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { ThunkMiddleware, Tuple, configureStore } from '@reduxjs/toolkit';
|
2
|
+
import { Flower } from '@flowerforce/flower-core';
|
3
|
+
import { UnknownAction } from 'redux';
|
4
|
+
export interface FlowerProviderInterface {
|
5
|
+
render(): JSX.Element;
|
6
|
+
}
|
7
|
+
export type FlowerProviderProps = ReturnType<typeof configureStore<{
|
8
|
+
flower: Record<string, Flower<any>>;
|
9
|
+
}, UnknownAction, Tuple<[
|
10
|
+
ThunkMiddleware<{
|
11
|
+
flower: Record<string, Flower<any>>;
|
12
|
+
}, UnknownAction>
|
13
|
+
]>>>;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { RulesObject } from '@flowerforce/flower-core';
|
2
|
+
export type FlowerRuleProps = {
|
3
|
+
id?: string;
|
4
|
+
value?: any;
|
5
|
+
rules?: RulesObject<any>;
|
6
|
+
flowName?: string;
|
7
|
+
alwaysDisplay?: boolean;
|
8
|
+
onUpdate?: (hidden: boolean) => void;
|
9
|
+
children?: React.ReactNode | ((props: {
|
10
|
+
hidden?: boolean;
|
11
|
+
}) => React.ReactNode | React.ReactElement | undefined);
|
12
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { RulesObject } from '@flowerforce/flower-core';
|
2
|
+
export type FlowerValueProps = {
|
3
|
+
id?: string;
|
4
|
+
value?: any;
|
5
|
+
rules?: RulesObject<any>;
|
6
|
+
children: React.ReactNode | ((props: Record<string, any>) => React.ReactNode | React.ReactElement | undefined);
|
7
|
+
spreadValue?: boolean;
|
8
|
+
flowName?: string;
|
9
|
+
alwaysDisplay?: boolean;
|
10
|
+
onUpdate?: (value: any) => void;
|
11
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
export type FlowerContext = {
|
3
|
+
flowName?: string | undefined;
|
4
|
+
currentNode?: string | undefined;
|
5
|
+
autostart?: boolean | undefined;
|
6
|
+
};
|
7
|
+
export declare const context: React.Context<FlowerContext>;
|
8
|
+
export declare const Provider: React.Provider<FlowerContext>;
|
9
|
+
export declare const Consumer: React.Consumer<FlowerContext>;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
export { Consumer as FlowerContextConsumer } from './context';
|
2
|
+
export { Provider as FlowerContextProvider } from './context';
|
3
|
+
export { context as FlowerContext } from './context';
|
4
|
+
export { default as Flower } from './components/Flower';
|
5
|
+
export { default as FlowerNode } from './components/FlowerNode';
|
6
|
+
export { default as FlowerAction } from './components/FlowerAction';
|
7
|
+
export { default as FlowerServer } from './components/FlowerServer';
|
8
|
+
export { default as FlowerFlow } from './components/FlowerFlow';
|
9
|
+
export { default as FlowerStart } from './components/FlowerStart';
|
10
|
+
export { default as FlowerRoute } from './components/FlowerRoute';
|
11
|
+
export { default as FlowerRule } from './components/FlowerRule';
|
12
|
+
export { default as FlowerField } from './components/FlowerField';
|
13
|
+
export { default as FlowerValue } from './components/FlowerValue';
|
14
|
+
export { default as FlowerNavigate } from './components/FlowerNavigate';
|
15
|
+
export { default as FlowerComponent } from './components/FlowerComponent';
|
16
|
+
export { default as useFlower } from './components/useFlower';
|
17
|
+
export { default as useFlowerForm } from './components/useFlowerForm';
|
18
|
+
export { default as FlowerProvider } from './provider';
|
19
|
+
export { getDataByFlow } from './selectors';
|
20
|
+
export { useSelector } from './provider';
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React, { PropsWithChildren, Component } from 'react';
|
2
|
+
import { Action } from '@reduxjs/toolkit';
|
3
|
+
import { FlowerProviderProps } from './components/types/FlowerProvider';
|
4
|
+
export declare const useDispatch: import("react-redux").UseDispatch<import("redux").Dispatch<Action>>;
|
5
|
+
export declare const useSelector: import("react-redux").UseSelector<unknown>;
|
6
|
+
export declare const useStore: import("react-redux").UseStore<import("redux").Store<any, Action, {}>>;
|
7
|
+
export declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
8
|
+
flower: Record<string, import("packages/flower-core/dist/src").Flower<Record<string, any>>>;
|
9
|
+
}, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
|
10
|
+
dispatch: import("redux-thunk").ThunkDispatch<{
|
11
|
+
flower: Record<string, import("packages/flower-core/dist/src").Flower<Record<string, any>>>;
|
12
|
+
}, undefined, import("redux").UnknownAction>;
|
13
|
+
}>, import("redux").StoreEnhancer]>>;
|
14
|
+
declare class FlowerProvider extends Component<PropsWithChildren, FlowerProviderProps> {
|
15
|
+
private store;
|
16
|
+
constructor(props: PropsWithChildren);
|
17
|
+
render(): React.JSX.Element;
|
18
|
+
}
|
19
|
+
export default FlowerProvider;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { Flower } from '@flowerforce/flower-core';
|
2
|
+
declare const flowerReducer: import("@reduxjs/toolkit").Slice<Record<string, Flower<Record<string, any>>>, import("@flowerforce/flower-core").ReducersFunctions, "flower", "flower", import("@reduxjs/toolkit").SliceSelectors<Record<string, Flower<Record<string, any>>>>>;
|
3
|
+
export declare const actions: import("@reduxjs/toolkit").CaseReducerActions<import("@flowerforce/flower-core").ReducersFunctions, "flower">;
|
4
|
+
export declare const reducerFlower: {
|
5
|
+
flower: import("redux").Reducer<Record<string, Flower<Record<string, any>>>>;
|
6
|
+
};
|
7
|
+
export default flowerReducer;
|