@flowerforce/flower-react 3.1.1 → 3.1.2-beta.1
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/README.md +11 -1
- package/dist/index.cjs.js +761 -1036
- package/dist/index.esm.js +762 -1037
- package/dist/src/components/Flower.d.ts +7 -1
- package/dist/src/components/types/DefaultNode.d.ts +17 -0
- package/dist/src/components/types/FlowerComponent.d.ts +2 -0
- package/dist/src/components/types/FlowerField.d.ts +78 -0
- package/dist/src/components/types/FlowerFlow.d.ts +10 -0
- package/dist/src/components/types/FlowerHooks.d.ts +25 -2
- package/dist/src/components/types/FlowerNavigate.d.ts +14 -0
- package/dist/src/components/types/FlowerNode.d.ts +10 -0
- package/dist/src/components/types/FlowerRoute.d.ts +17 -0
- package/dist/src/components/types/FlowerRule.d.ts +23 -0
- package/dist/src/components/types/FlowerServer.d.ts +2 -0
- package/dist/src/components/types/FlowerValue.d.ts +22 -0
- package/dist/src/components/useFlower.d.ts +18 -0
- package/dist/src/components/useFlowerForm.d.ts +17 -0
- package/package.json +2 -2
    
        package/dist/index.cjs.js
    CHANGED
    
    | @@ -9,43 +9,40 @@ var reselect = require('reselect'); | |
| 9 9 | 
             
            var reactRedux = require('react-redux');
         | 
| 10 10 | 
             
            var debounce = require('lodash/debounce');
         | 
| 11 11 |  | 
| 12 | 
            -
            const _context =  | 
| 12 | 
            +
            const _context = React.createContext({});
         | 
| 13 13 | 
             
            const context = _context;
         | 
| 14 14 | 
             
            const Provider = _context.Provider;
         | 
| 15 15 | 
             
            const Consumer = _context.Consumer;
         | 
| 16 16 |  | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 17 | 
            +
            // eslint-disable-next-line import/prefer-default-export
         | 
| 18 | 
            +
            const convertElements = (nodes) => {
         | 
| 19 | 
            +
                const res = flowerCore.CoreUtils.generateNodesForFlowerJson(nodes);
         | 
| 20 | 
            +
                return res;
         | 
| 20 21 | 
             
            };
         | 
| 21 22 |  | 
| 22 23 | 
             
            const flowerReducer = toolkit.createSlice({
         | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 24 | 
            +
                name: 'flower',
         | 
| 25 | 
            +
                initialState: {},
         | 
| 26 | 
            +
                reducers: flowerCore.FlowerCoreReducers
         | 
| 26 27 | 
             
            });
         | 
| 27 | 
            -
            const {
         | 
| 28 | 
            -
              actions
         | 
| 29 | 
            -
            } = flowerReducer;
         | 
| 28 | 
            +
            const { actions } = flowerReducer;
         | 
| 30 29 | 
             
            const reducerFlower = {
         | 
| 31 | 
            -
             | 
| 30 | 
            +
                flower: flowerReducer.reducer
         | 
| 32 31 | 
             
            };
         | 
| 33 32 |  | 
| 34 | 
            -
            const {
         | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
            const {
         | 
| 38 | 
            -
              selectGlobal
         | 
| 39 | 
            -
            } = flowerCore.Selectors;
         | 
| 40 | 
            -
            const selectFlower = name => reselect.createSelector(selectGlobal, flowerCore.Selectors.selectFlower(name));
         | 
| 33 | 
            +
            const { getAllData: mapData } = flowerCore.FlowerStateUtils;
         | 
| 34 | 
            +
            const { selectGlobal } = flowerCore.Selectors;
         | 
| 35 | 
            +
            const selectFlower = (name) => reselect.createSelector(selectGlobal, flowerCore.Selectors.selectFlower(name));
         | 
| 41 36 | 
             
            const selectFlowerFormNode = (name, id) => reselect.createSelector(selectFlower(name), flowerCore.Selectors.selectFlowerFormNode(id));
         | 
| 42 | 
            -
            const selectFlowerHistory = name => reselect.createSelector(selectFlower(name), flowerCore.Selectors.selectFlowerHistory);
         | 
| 43 | 
            -
            const makeSelectNodesIds = name => reselect.createSelector(selectFlower(name), flowerCore.Selectors.makeSelectNodesIds);
         | 
| 44 | 
            -
            const makeSelectStartNodeId = name => reselect.createSelector(selectFlower(name), flowerCore.Selectors.makeSelectStartNodeId);
         | 
| 45 | 
            -
            const makeSelectCurrentNodeId = name => reselect.createSelector(selectFlower(name), makeSelectStartNodeId(name), flowerCore.Selectors.makeSelectCurrentNodeId);
         | 
| 46 | 
            -
            const makeSelectPrevNodeRetain = name => reselect.createSelector(makeSelectNodesIds(name), selectFlowerHistory(name), makeSelectCurrentNodeId(name), flowerCore.Selectors.makeSelectPrevNodeRetain);
         | 
| 47 | 
            -
            const makeSelectCurrentNodeDisabled = name => reselect.createSelector(makeSelectNodesIds(name), makeSelectCurrentNodeId(name), flowerCore.Selectors.makeSelectCurrentNodeDisabled);
         | 
| 48 | 
            -
             | 
| 37 | 
            +
            const selectFlowerHistory = (name) => reselect.createSelector(selectFlower(name), flowerCore.Selectors.selectFlowerHistory);
         | 
| 38 | 
            +
            const makeSelectNodesIds = (name) => reselect.createSelector(selectFlower(name), flowerCore.Selectors.makeSelectNodesIds);
         | 
| 39 | 
            +
            const makeSelectStartNodeId = (name) => reselect.createSelector(selectFlower(name), flowerCore.Selectors.makeSelectStartNodeId);
         | 
| 40 | 
            +
            const makeSelectCurrentNodeId = (name) => reselect.createSelector(selectFlower(name), makeSelectStartNodeId(name), flowerCore.Selectors.makeSelectCurrentNodeId);
         | 
| 41 | 
            +
            const makeSelectPrevNodeRetain = (name) => reselect.createSelector(makeSelectNodesIds(name), selectFlowerHistory(name), makeSelectCurrentNodeId(name), flowerCore.Selectors.makeSelectPrevNodeRetain);
         | 
| 42 | 
            +
            const makeSelectCurrentNodeDisabled = (name) => reselect.createSelector(makeSelectNodesIds(name), makeSelectCurrentNodeId(name), flowerCore.Selectors.makeSelectCurrentNodeDisabled);
         | 
| 43 | 
            +
            // dati nel flow selezionato
         | 
| 44 | 
            +
            const getDataByFlow = (name) => reselect.createSelector(selectFlower(name), flowerCore.Selectors.getDataByFlow);
         | 
| 45 | 
            +
            // selettore per recuperare i dati di un flow specifico e id specifico
         | 
| 49 46 | 
             
            const getDataFromState = (name, id) => reselect.createSelector(getDataByFlow(name), flowerCore.Selectors.getDataFromState(id));
         | 
| 50 47 | 
             
            const makeSelectNodeErrors = (name, currentNodeId) => reselect.createSelector(selectFlowerFormNode(name, currentNodeId), flowerCore.Selectors.makeSelectNodeErrors);
         | 
| 51 48 | 
             
            const makeSelectNodeFormTouched = (name, currentNodeId) => reselect.createSelector(selectFlowerFormNode(name, currentNodeId), flowerCore.Selectors.makeSelectNodeFormTouched);
         | 
| @@ -53,1101 +50,829 @@ const getAllData = reselect.createSelector(selectGlobal, mapData); | |
| 53 50 | 
             
            const makeSelectFieldError = (name, id, validate) => reselect.createSelector(getAllData, flowerCore.Selectors.makeSelectFieldError(name, id, validate));
         | 
| 54 51 | 
             
            const selectorRulesDisabled = (id, rules, keys, flowName, value, currentNode) => reselect.createSelector(getAllData, makeSelectNodeErrors(flowName, currentNode), flowerCore.Selectors.selectorRulesDisabled(id, rules, keys, flowName, value));
         | 
| 55 52 |  | 
| 56 | 
            -
             | 
| 53 | 
            +
            //TODO check reduxContext type due to remove all any types
         | 
| 54 | 
            +
            const reduxContext = React.createContext(null);
         | 
| 57 55 | 
             
            const useDispatch = reactRedux.createDispatchHook(reduxContext);
         | 
| 58 56 | 
             
            const useSelector = reactRedux.createSelectorHook(reduxContext);
         | 
| 59 57 | 
             
            const useStore = reactRedux.createStoreHook(reduxContext);
         | 
| 60 | 
            -
            const store = ({
         | 
| 61 | 
            -
             | 
| 62 | 
            -
            } | 
| 63 | 
            -
              reducer: reducerFlower,
         | 
| 64 | 
            -
              devTools: enableDevtool ? {
         | 
| 65 | 
            -
                name: 'flower'
         | 
| 66 | 
            -
              } : false
         | 
| 58 | 
            +
            const store = ({ enableDevtool }) => toolkit.configureStore({
         | 
| 59 | 
            +
                reducer: reducerFlower,
         | 
| 60 | 
            +
                devTools: enableDevtool ? { name: 'flower' } : false
         | 
| 67 61 | 
             
            });
         | 
| 68 62 | 
             
            class FlowerProvider extends React.PureComponent {
         | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
                 | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
                 | 
| 77 | 
            -
                  children
         | 
| 78 | 
            -
                } = this.props;
         | 
| 79 | 
            -
                return /*#__PURE__*/React.createElement(reactRedux.Provider, {
         | 
| 80 | 
            -
                  context: reduxContext,
         | 
| 81 | 
            -
                  store: this.store
         | 
| 82 | 
            -
                }, children);
         | 
| 83 | 
            -
              }
         | 
| 63 | 
            +
                constructor(props) {
         | 
| 64 | 
            +
                    super(props);
         | 
| 65 | 
            +
                    this.store = store({ enableDevtool: props.enableReduxDevtool });
         | 
| 66 | 
            +
                }
         | 
| 67 | 
            +
                render() {
         | 
| 68 | 
            +
                    const { children } = this.props;
         | 
| 69 | 
            +
                    return (React.createElement(reactRedux.Provider, { context: reduxContext, store: this.store }, children));
         | 
| 70 | 
            +
                }
         | 
| 84 71 | 
             
            }
         | 
| 85 72 |  | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
             | 
| 106 | 
            -
                 | 
| 107 | 
            -
             | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 73 | 
            +
            /* eslint-disable no-undef */
         | 
| 74 | 
            +
            /* eslint-disable no-underscore-dangle */
         | 
| 75 | 
            +
            /**
         | 
| 76 | 
            +
             * FlowerClient
         | 
| 77 | 
            +
             */
         | 
| 78 | 
            +
            const FlowerClient = ({ children, name, destroyOnUnmount = true, startId = null, initialData = {}, initialState = {} }) => {
         | 
| 79 | 
            +
                const flowName = name;
         | 
| 80 | 
            +
                const dispatch = useDispatch();
         | 
| 81 | 
            +
                const one = React.useRef(false);
         | 
| 82 | 
            +
                const [wsDevtools, setWsDevtools] = React.useState(flowerCore.devtoolState && _get(flowerCore.devtoolState, '__FLOWER_DEVTOOLS_INITIALIZED__', false));
         | 
| 83 | 
            +
                // TODO rivedere il giro, potremmo fare le trasformazioni in CoreUtils.generateNodesForFlowerJson
         | 
| 84 | 
            +
                // eslint-disable-next-line react-hooks/exhaustive-deps, max-len
         | 
| 85 | 
            +
                const nodes = React.useMemo(() => convertElements(React.Children.toArray(children)), [children]);
         | 
| 86 | 
            +
                const nodeById = React.useMemo(() => _keyBy(React.Children.toArray(children), 'props.id'), [children]);
         | 
| 87 | 
            +
                const isInitialized = useSelector(makeSelectStartNodeId(name));
         | 
| 88 | 
            +
                const history = useSelector(selectFlowerHistory(name));
         | 
| 89 | 
            +
                const current = useSelector(makeSelectCurrentNodeId(flowName));
         | 
| 90 | 
            +
                const isDisabled = useSelector(makeSelectCurrentNodeDisabled(flowName));
         | 
| 91 | 
            +
                const prevFlowerNodeId = useSelector(makeSelectPrevNodeRetain(flowName));
         | 
| 92 | 
            +
                const store = useStore();
         | 
| 93 | 
            +
                React.useEffect(() => {
         | 
| 94 | 
            +
                    if (nodes.length > 0 && one.current === false) {
         | 
| 95 | 
            +
                        one.current = true;
         | 
| 96 | 
            +
                        dispatch(actions.initNodes({
         | 
| 97 | 
            +
                            name: flowName,
         | 
| 98 | 
            +
                            // @ts-expect-error FIX ME
         | 
| 99 | 
            +
                            nodes,
         | 
| 100 | 
            +
                            startId: startId ?? '',
         | 
| 101 | 
            +
                            persist: destroyOnUnmount === false,
         | 
| 102 | 
            +
                            initialData,
         | 
| 103 | 
            +
                            initialState
         | 
| 104 | 
            +
                        }));
         | 
| 105 | 
            +
                    }
         | 
| 106 | 
            +
                }, [
         | 
| 107 | 
            +
                    dispatch,
         | 
| 108 | 
            +
                    flowName,
         | 
| 110 109 | 
             
                    nodes,
         | 
| 111 | 
            -
                    startId | 
| 112 | 
            -
                     | 
| 113 | 
            -
                     | 
| 114 | 
            -
             | 
| 115 | 
            -
                 | 
| 116 | 
            -
             | 
| 117 | 
            -
             | 
| 118 | 
            -
             | 
| 119 | 
            -
             | 
| 120 | 
            -
             | 
| 121 | 
            -
             | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 127 | 
            -
             | 
| 128 | 
            -
             | 
| 129 | 
            -
             | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 132 | 
            -
             | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 135 | 
            -
             | 
| 136 | 
            -
                     | 
| 137 | 
            -
             | 
| 138 | 
            -
                      value: msg.data
         | 
| 139 | 
            -
                    }));
         | 
| 140 | 
            -
                  }
         | 
| 141 | 
            -
                };
         | 
| 142 | 
            -
                if (global.window && _get(global.window, '__FLOWER_DEVTOOLS__')) {
         | 
| 143 | 
            -
                  flowerCore.Emitter.on('flower-devtool-to-client', eventCb);
         | 
| 144 | 
            -
                }
         | 
| 145 | 
            -
                return () => {
         | 
| 146 | 
            -
                  if (global.window && _get(global.window, '__FLOWER_DEVTOOLS__')) {
         | 
| 147 | 
            -
                    flowerCore.Emitter.off('flower-devtool-to-client', eventCb);
         | 
| 148 | 
            -
                  }
         | 
| 149 | 
            -
                };
         | 
| 150 | 
            -
              }, [dispatch, flowName]);
         | 
| 151 | 
            -
              React.useEffect(() => () => {
         | 
| 152 | 
            -
                if (_destroyOnUnmount && one.current === true) {
         | 
| 153 | 
            -
                  one.current = false;
         | 
| 154 | 
            -
                  dispatch(actions.destroy({
         | 
| 155 | 
            -
                    name: flowName
         | 
| 156 | 
            -
                  }));
         | 
| 157 | 
            -
                }
         | 
| 158 | 
            -
              }, [dispatch, flowName, _destroyOnUnmount]);
         | 
| 159 | 
            -
              React.useEffect(() => {
         | 
| 160 | 
            -
                if (isInitialized && wsDevtools && global.window && _get(global.window, '__FLOWER_DEVTOOLS__')) {
         | 
| 161 | 
            -
                  flowerCore.Emitter.emit('flower-devtool-from-client', {
         | 
| 162 | 
            -
                    source: 'flower-client',
         | 
| 163 | 
            -
                    action: 'FLOWER_CLIENT_INIT',
         | 
| 164 | 
            -
                    name: flowName,
         | 
| 165 | 
            -
                    time: new Date(),
         | 
| 166 | 
            -
                    nodeId: isInitialized,
         | 
| 167 | 
            -
                    getState: store.getState
         | 
| 168 | 
            -
                  });
         | 
| 169 | 
            -
                }
         | 
| 170 | 
            -
              }, [dispatch, flowName, wsDevtools, isInitialized, store]);
         | 
| 171 | 
            -
              React.useEffect(() => {
         | 
| 172 | 
            -
                if (isInitialized && wsDevtools && global.window && _get(global.window, '__FLOWER_DEVTOOLS__')) {
         | 
| 173 | 
            -
                  flowerCore.Emitter.emit('flower-devtool-from-client', {
         | 
| 174 | 
            -
                    source: 'flower-client',
         | 
| 175 | 
            -
                    action: 'SET_HISTORY',
         | 
| 176 | 
            -
                    name: flowName,
         | 
| 177 | 
            -
                    history
         | 
| 178 | 
            -
                  });
         | 
| 179 | 
            -
                }
         | 
| 180 | 
            -
              }, [dispatch, flowName, history, wsDevtools, isInitialized]);
         | 
| 181 | 
            -
              React.useEffect(() => {
         | 
| 182 | 
            -
                if (!current) return;
         | 
| 183 | 
            -
                if (!isInitialized) return;
         | 
| 184 | 
            -
                if (isInitialized && wsDevtools && global.window && _get(global.window, '__FLOWER_DEVTOOLS__')) {
         | 
| 185 | 
            -
                  flowerCore.Emitter.emit('flower-devtool-from-client', {
         | 
| 186 | 
            -
                    source: 'flower-client',
         | 
| 187 | 
            -
                    action: 'SET_CURRENT',
         | 
| 188 | 
            -
                    name: flowName,
         | 
| 189 | 
            -
                    current
         | 
| 190 | 
            -
                  });
         | 
| 191 | 
            -
                }
         | 
| 192 | 
            -
              }, [flowName, current, wsDevtools, isInitialized]);
         | 
| 193 | 
            -
              React.useEffect(() => {
         | 
| 194 | 
            -
                if (!current) return;
         | 
| 195 | 
            -
                if (!isInitialized) return;
         | 
| 196 | 
            -
                if (isDisabled) {
         | 
| 197 | 
            -
                  dispatch({
         | 
| 198 | 
            -
                    type: 'flower/next',
         | 
| 199 | 
            -
                    payload: {
         | 
| 200 | 
            -
                      flowName,
         | 
| 201 | 
            -
                      disabled: true
         | 
| 110 | 
            +
                    startId,
         | 
| 111 | 
            +
                    initialData,
         | 
| 112 | 
            +
                    destroyOnUnmount,
         | 
| 113 | 
            +
                    initialState
         | 
| 114 | 
            +
                ]);
         | 
| 115 | 
            +
                React.useEffect(() => {
         | 
| 116 | 
            +
                    /* istanbul ignore next */
         | 
| 117 | 
            +
                    const eventCb = (msg) => {
         | 
| 118 | 
            +
                        if (msg.source !== 'flower-devtool')
         | 
| 119 | 
            +
                            return;
         | 
| 120 | 
            +
                        if (msg.action === 'FLOWER_EXTENSION_INIT' ||
         | 
| 121 | 
            +
                            msg.action === 'FLOWER_DEVTOOL_WEB_INIT') {
         | 
| 122 | 
            +
                            setWsDevtools(true);
         | 
| 123 | 
            +
                        }
         | 
| 124 | 
            +
                        if (msg.action === 'SELECTED_NODE' && msg.name === flowName) {
         | 
| 125 | 
            +
                            dispatch(actions.setCurrentNode({ name: msg.name, node: msg.id }));
         | 
| 126 | 
            +
                        }
         | 
| 127 | 
            +
                        if (msg.action === 'REPLACE_DATA' && msg.name === flowName) {
         | 
| 128 | 
            +
                            dispatch(actions.replaceData({ flowName: msg.name, value: msg.data }));
         | 
| 129 | 
            +
                        }
         | 
| 130 | 
            +
                        if (msg.action === 'ADD_DATA' && msg.name === flowName) {
         | 
| 131 | 
            +
                            dispatch(actions.addData({ flowName: msg.name, value: msg.data }));
         | 
| 132 | 
            +
                        }
         | 
| 133 | 
            +
                    };
         | 
| 134 | 
            +
                    /* istanbul ignore next */
         | 
| 135 | 
            +
                    if (flowerCore.devtoolState && _get(flowerCore.devtoolState, '__FLOWER_DEVTOOLS__')) {
         | 
| 136 | 
            +
                        flowerCore.Emitter.on('flower-devtool-to-client', eventCb);
         | 
| 202 137 | 
             
                    }
         | 
| 203 | 
            -
             | 
| 204 | 
            -
             | 
| 205 | 
            -
             | 
| 206 | 
            -
             | 
| 207 | 
            -
                      action: 'FLOWER_NAVIGATE',
         | 
| 208 | 
            -
                      nodeId: current,
         | 
| 209 | 
            -
                      name: flowName,
         | 
| 210 | 
            -
                      time: new Date(),
         | 
| 211 | 
            -
                      params: {
         | 
| 212 | 
            -
                        action: 'next',
         | 
| 213 | 
            -
                        payload: {
         | 
| 214 | 
            -
                          flowName,
         | 
| 215 | 
            -
                          disabled: true
         | 
| 138 | 
            +
                    return () => {
         | 
| 139 | 
            +
                        /* istanbul ignore next */
         | 
| 140 | 
            +
                        if (flowerCore.devtoolState && _get(flowerCore.devtoolState, '__FLOWER_DEVTOOLS__')) {
         | 
| 141 | 
            +
                            flowerCore.Emitter.off('flower-devtool-to-client', eventCb);
         | 
| 216 142 | 
             
                        }
         | 
| 217 | 
            -
             | 
| 218 | 
            -
             | 
| 219 | 
            -
             | 
| 220 | 
            -
             | 
| 221 | 
            -
             | 
| 222 | 
            -
             | 
| 223 | 
            -
             | 
| 224 | 
            -
             | 
| 225 | 
            -
             | 
| 226 | 
            -
             | 
| 227 | 
            -
                     | 
| 228 | 
            -
                     | 
| 229 | 
            -
             | 
| 230 | 
            -
             | 
| 231 | 
            -
             | 
| 232 | 
            -
             | 
| 233 | 
            -
             | 
| 234 | 
            -
             | 
| 235 | 
            -
             | 
| 236 | 
            -
             | 
| 237 | 
            -
             | 
| 238 | 
            -
             | 
| 239 | 
            -
             | 
| 240 | 
            -
             | 
| 143 | 
            +
                    };
         | 
| 144 | 
            +
                }, [dispatch, flowName]);
         | 
| 145 | 
            +
                React.useEffect(() => () => {
         | 
| 146 | 
            +
                    // unmount function
         | 
| 147 | 
            +
                    if (destroyOnUnmount && one.current === true) {
         | 
| 148 | 
            +
                        one.current = false;
         | 
| 149 | 
            +
                        dispatch(actions.destroy({ name: flowName }));
         | 
| 150 | 
            +
                    }
         | 
| 151 | 
            +
                }, [dispatch, flowName, destroyOnUnmount]);
         | 
| 152 | 
            +
                React.useEffect(() => {
         | 
| 153 | 
            +
                    /* istanbul ignore next */
         | 
| 154 | 
            +
                    if (isInitialized &&
         | 
| 155 | 
            +
                        wsDevtools &&
         | 
| 156 | 
            +
                        flowerCore.devtoolState &&
         | 
| 157 | 
            +
                        _get(flowerCore.devtoolState, '__FLOWER_DEVTOOLS__')) {
         | 
| 158 | 
            +
                        flowerCore.Emitter.emit('flower-devtool-from-client', {
         | 
| 159 | 
            +
                            source: 'flower-client',
         | 
| 160 | 
            +
                            action: 'FLOWER_CLIENT_INIT',
         | 
| 161 | 
            +
                            name: flowName,
         | 
| 162 | 
            +
                            time: new Date(),
         | 
| 163 | 
            +
                            nodeId: isInitialized,
         | 
| 164 | 
            +
                            getState: store.getState
         | 
| 165 | 
            +
                        });
         | 
| 166 | 
            +
                    }
         | 
| 167 | 
            +
                }, [dispatch, flowName, wsDevtools, isInitialized, store]);
         | 
| 168 | 
            +
                React.useEffect(() => {
         | 
| 169 | 
            +
                    /* istanbul ignore next */
         | 
| 170 | 
            +
                    if (isInitialized &&
         | 
| 171 | 
            +
                        wsDevtools &&
         | 
| 172 | 
            +
                        flowerCore.devtoolState &&
         | 
| 173 | 
            +
                        _get(flowerCore.devtoolState, '__FLOWER_DEVTOOLS__')) {
         | 
| 174 | 
            +
                        flowerCore.Emitter.emit('flower-devtool-from-client', {
         | 
| 175 | 
            +
                            source: 'flower-client',
         | 
| 176 | 
            +
                            action: 'SET_HISTORY',
         | 
| 177 | 
            +
                            name: flowName,
         | 
| 178 | 
            +
                            history
         | 
| 179 | 
            +
                        });
         | 
| 180 | 
            +
                    }
         | 
| 181 | 
            +
                }, [dispatch, flowName, history, wsDevtools, isInitialized]);
         | 
| 182 | 
            +
                React.useEffect(() => {
         | 
| 183 | 
            +
                    if (!current)
         | 
| 184 | 
            +
                        return;
         | 
| 185 | 
            +
                    /* istanbul ignore next */
         | 
| 186 | 
            +
                    if (!isInitialized)
         | 
| 187 | 
            +
                        return;
         | 
| 188 | 
            +
                    /* istanbul ignore next */
         | 
| 189 | 
            +
                    if (isInitialized &&
         | 
| 190 | 
            +
                        wsDevtools &&
         | 
| 191 | 
            +
                        flowerCore.devtoolState &&
         | 
| 192 | 
            +
                        _get(flowerCore.devtoolState, '__FLOWER_DEVTOOLS__')) {
         | 
| 193 | 
            +
                        flowerCore.Emitter.emit('flower-devtool-from-client', {
         | 
| 194 | 
            +
                            source: 'flower-client',
         | 
| 195 | 
            +
                            action: 'SET_CURRENT',
         | 
| 196 | 
            +
                            name: flowName,
         | 
| 197 | 
            +
                            current
         | 
| 198 | 
            +
                        });
         | 
| 199 | 
            +
                    }
         | 
| 200 | 
            +
                }, [flowName, current, wsDevtools, isInitialized]);
         | 
| 201 | 
            +
                React.useEffect(() => {
         | 
| 202 | 
            +
                    if (!current)
         | 
| 203 | 
            +
                        return;
         | 
| 204 | 
            +
                    /* istanbul ignore next */
         | 
| 205 | 
            +
                    if (!isInitialized)
         | 
| 206 | 
            +
                        return;
         | 
| 207 | 
            +
                    if (isDisabled) {
         | 
| 208 | 
            +
                        dispatch({ type: 'flower/next', payload: { flowName, disabled: true } });
         | 
| 209 | 
            +
                        // eslint-disable-next-line no-underscore-dangle, no-undef
         | 
| 210 | 
            +
                        /* istanbul ignore next */
         | 
| 211 | 
            +
                        if (wsDevtools &&
         | 
| 212 | 
            +
                            flowerCore.devtoolState &&
         | 
| 213 | 
            +
                            _get(flowerCore.devtoolState, '__FLOWER_DEVTOOLS__')) {
         | 
| 214 | 
            +
                            flowerCore.Emitter.emit('flower-devtool-from-client', {
         | 
| 215 | 
            +
                                source: 'flower-client',
         | 
| 216 | 
            +
                                action: 'FLOWER_NAVIGATE',
         | 
| 217 | 
            +
                                nodeId: current,
         | 
| 218 | 
            +
                                name: flowName,
         | 
| 219 | 
            +
                                time: new Date(),
         | 
| 220 | 
            +
                                params: { action: 'next', payload: { flowName, disabled: true } }
         | 
| 221 | 
            +
                            });
         | 
| 222 | 
            +
                        }
         | 
| 223 | 
            +
                        return;
         | 
| 224 | 
            +
                    }
         | 
| 225 | 
            +
                    // eslint-disable-next-line no-underscore-dangle, no-undef
         | 
| 226 | 
            +
                    /* istanbul ignore next */
         | 
| 227 | 
            +
                    if (wsDevtools &&
         | 
| 228 | 
            +
                        flowerCore.devtoolState &&
         | 
| 229 | 
            +
                        _get(flowerCore.devtoolState, '__FLOWER_DEVTOOLS__')) {
         | 
| 230 | 
            +
                        if (isInitialized === current)
         | 
| 231 | 
            +
                            return; // salto il primo evento
         | 
| 232 | 
            +
                        flowerCore.Emitter.emit('flower-devtool-from-client', {
         | 
| 233 | 
            +
                            source: 'flower-client',
         | 
| 234 | 
            +
                            action: 'SET_SELECTED',
         | 
| 235 | 
            +
                            nodeId: current,
         | 
| 236 | 
            +
                            name: flowName,
         | 
| 237 | 
            +
                            time: new Date()
         | 
| 238 | 
            +
                        });
         | 
| 239 | 
            +
                    }
         | 
| 240 | 
            +
                }, [
         | 
| 241 | 
            +
                    dispatch,
         | 
| 242 | 
            +
                    flowName,
         | 
| 243 | 
            +
                    current,
         | 
| 244 | 
            +
                    isDisabled,
         | 
| 245 | 
            +
                    store,
         | 
| 246 | 
            +
                    wsDevtools,
         | 
| 247 | 
            +
                    isInitialized
         | 
| 248 | 
            +
                ]);
         | 
| 249 | 
            +
                const contextValues = React.useMemo(() => ({
         | 
| 250 | 
            +
                    flowName,
         | 
| 251 | 
            +
                    initialData,
         | 
| 252 | 
            +
                    currentNode: current
         | 
| 253 | 
            +
                }), [flowName, initialData, current]);
         | 
| 254 | 
            +
                return isInitialized ? (React.createElement(Provider, { value: contextValues },
         | 
| 255 | 
            +
                    prevFlowerNodeId !== current &&
         | 
| 256 | 
            +
                        typeof prevFlowerNodeId === 'string' &&
         | 
| 257 | 
            +
                        nodeById[prevFlowerNodeId],
         | 
| 258 | 
            +
                    !isDisabled && nodeById[current])) : null;
         | 
| 241 259 | 
             
            };
         | 
| 242 | 
            -
            const component$c =  | 
| 260 | 
            +
            const component$c = React.memo(FlowerClient);
         | 
| 243 261 |  | 
| 244 | 
            -
            const FlowerNode = ({
         | 
| 245 | 
            -
             | 
| 246 | 
            -
             | 
| 247 | 
            -
             | 
| 248 | 
            -
             | 
| 249 | 
            -
             | 
| 250 | 
            -
                onEnter  | 
| 251 | 
            -
                return  | 
| 252 | 
            -
                  onExit == null || onExit();
         | 
| 253 | 
            -
                };
         | 
| 254 | 
            -
              }, [onEnter, onExit]);
         | 
| 255 | 
            -
              return children;
         | 
| 262 | 
            +
            const FlowerNode = ({ children, onEnter, onExit }) => {
         | 
| 263 | 
            +
                React.useEffect(() => {
         | 
| 264 | 
            +
                    onEnter?.();
         | 
| 265 | 
            +
                    return () => {
         | 
| 266 | 
            +
                        onExit?.();
         | 
| 267 | 
            +
                    };
         | 
| 268 | 
            +
                }, [onEnter, onExit]);
         | 
| 269 | 
            +
                return children;
         | 
| 256 270 | 
             
            };
         | 
| 257 | 
            -
            const component$b =  | 
| 271 | 
            +
            const component$b = React.memo(FlowerNode);
         | 
| 258 272 | 
             
            component$b.displayName = 'FlowerNode';
         | 
| 259 273 |  | 
| 260 | 
            -
            const FlowAction = ({
         | 
| 261 | 
            -
             | 
| 262 | 
            -
             | 
| 263 | 
            -
             | 
| 264 | 
            -
             | 
| 265 | 
            -
             | 
| 266 | 
            -
                onEnter  | 
| 267 | 
            -
                return  | 
| 268 | 
            -
                  onExit == null || onExit();
         | 
| 269 | 
            -
                };
         | 
| 270 | 
            -
              }, [onEnter, onExit]);
         | 
| 271 | 
            -
              return children;
         | 
| 274 | 
            +
            const FlowAction = ({ children, onEnter, onExit }) => {
         | 
| 275 | 
            +
                React.useEffect(() => {
         | 
| 276 | 
            +
                    onEnter?.();
         | 
| 277 | 
            +
                    return () => {
         | 
| 278 | 
            +
                        onExit?.();
         | 
| 279 | 
            +
                    };
         | 
| 280 | 
            +
                }, [onEnter, onExit]);
         | 
| 281 | 
            +
                return children;
         | 
| 272 282 | 
             
            };
         | 
| 273 | 
            -
            const component$a =  | 
| 283 | 
            +
            const component$a = React.memo(FlowAction);
         | 
| 274 284 | 
             
            component$a.displayName = 'FlowerAction';
         | 
| 275 285 |  | 
| 276 | 
            -
            const FlowerServer = ({
         | 
| 277 | 
            -
             | 
| 278 | 
            -
            }) => {
         | 
| 279 | 
            -
              return children;
         | 
| 286 | 
            +
            const FlowerServer = ({ children }) => {
         | 
| 287 | 
            +
                return children;
         | 
| 280 288 | 
             
            };
         | 
| 281 | 
            -
            const component$9 =  | 
| 289 | 
            +
            const component$9 = React.memo(FlowerServer);
         | 
| 282 290 | 
             
            component$9.displayName = 'FlowerServer';
         | 
| 283 291 |  | 
| 284 | 
            -
            const FlowerFlow = ({
         | 
| 285 | 
            -
             | 
| 286 | 
            -
             | 
| 287 | 
            -
             | 
| 288 | 
            -
             | 
| 289 | 
            -
             | 
| 290 | 
            -
                onEnter  | 
| 291 | 
            -
                return  | 
| 292 | 
            -
                  onExit == null || onExit();
         | 
| 293 | 
            -
                };
         | 
| 294 | 
            -
              }, [onEnter, onExit]);
         | 
| 295 | 
            -
              return children;
         | 
| 292 | 
            +
            const FlowerFlow = ({ children, onEnter, onExit }) => {
         | 
| 293 | 
            +
                React.useEffect(() => {
         | 
| 294 | 
            +
                    onEnter?.();
         | 
| 295 | 
            +
                    return () => {
         | 
| 296 | 
            +
                        onExit?.();
         | 
| 297 | 
            +
                    };
         | 
| 298 | 
            +
                }, [onEnter, onExit]);
         | 
| 299 | 
            +
                return children;
         | 
| 296 300 | 
             
            };
         | 
| 297 | 
            -
            const component$8 =  | 
| 301 | 
            +
            const component$8 = React.memo(FlowerFlow);
         | 
| 298 302 | 
             
            component$8.displayName = 'FlowerFlow';
         | 
| 299 303 |  | 
| 300 304 | 
             
            function FlowerStart() {
         | 
| 301 | 
            -
             | 
| 302 | 
            -
             | 
| 303 | 
            -
             | 
| 304 | 
            -
                flowName | 
| 305 | 
            -
                 | 
| 306 | 
            -
             | 
| 307 | 
            -
             | 
| 308 | 
            -
             | 
| 309 | 
            -
             | 
| 310 | 
            -
             | 
| 311 | 
            -
             | 
| 312 | 
            -
             | 
| 313 | 
            -
             | 
| 314 | 
            -
             | 
| 315 | 
            -
             | 
| 316 | 
            -
             | 
| 305 | 
            +
                const dispatch = useDispatch();
         | 
| 306 | 
            +
                const one = React.useRef(false);
         | 
| 307 | 
            +
                const { flowName, autostart = true, currentNode } = React.useContext(context);
         | 
| 308 | 
            +
                const startNodeId = useSelector(makeSelectStartNodeId(flowName ?? ''));
         | 
| 309 | 
            +
                React.useEffect(() => {
         | 
| 310 | 
            +
                    if (startNodeId === currentNode && autostart && one.current === false) {
         | 
| 311 | 
            +
                        one.current = true;
         | 
| 312 | 
            +
                        dispatch({ type: 'flower/next', payload: { flowName, isStart: true } });
         | 
| 313 | 
            +
                        // if (global.window
         | 
| 314 | 
            +
                        //   // eslint-disable-next-line no-underscore-dangle, no-undef
         | 
| 315 | 
            +
                        //   && global.window.__FLOWER_DEVTOOLS__ && global.window.__FLOWER_DEVTOOLS__AUTO) {
         | 
| 316 | 
            +
                        //   Emitter.emit('flower-devtool-from-client', {
         | 
| 317 | 
            +
                        //     source: 'flower-client',
         | 
| 318 | 
            +
                        //     action: 'START_FLOWER',
         | 
| 319 | 
            +
                        //     name: flowName,
         | 
| 320 | 
            +
                        //   });
         | 
| 321 | 
            +
                        // }
         | 
| 317 322 | 
             
                    }
         | 
| 318 | 
            -
             | 
| 319 | 
            -
                 | 
| 320 | 
            -
              }, [dispatch, autostart, startNodeId, currentNode, flowName]);
         | 
| 321 | 
            -
              return null;
         | 
| 323 | 
            +
                }, [dispatch, autostart, startNodeId, currentNode, flowName]);
         | 
| 324 | 
            +
                return null;
         | 
| 322 325 | 
             
            }
         | 
| 323 | 
            -
            const component$7 =  | 
| 326 | 
            +
            const component$7 = React.memo(FlowerStart);
         | 
| 324 327 | 
             
            component$7.displayName = 'FlowerStart';
         | 
| 325 328 |  | 
| 326 | 
            -
            const FlowerRoute = ({
         | 
| 327 | 
            -
             | 
| 328 | 
            -
             | 
| 329 | 
            -
             | 
| 330 | 
            -
             | 
| 331 | 
            -
             | 
| 332 | 
            -
             | 
| 333 | 
            -
             | 
| 334 | 
            -
             | 
| 335 | 
            -
                 | 
| 336 | 
            -
             | 
| 337 | 
            -
             | 
| 338 | 
            -
             | 
| 339 | 
            -
             | 
| 340 | 
            -
                  onExit == null || onExit();
         | 
| 341 | 
            -
                };
         | 
| 342 | 
            -
              }, [onEnter, onExit]);
         | 
| 343 | 
            -
              React.useEffect(() => {
         | 
| 344 | 
            -
                if (_autostart && one.current === false) {
         | 
| 345 | 
            -
                  one.current = true;
         | 
| 346 | 
            -
                  dispatch({
         | 
| 347 | 
            -
                    type: 'flower/next',
         | 
| 348 | 
            -
                    payload: {
         | 
| 349 | 
            -
                      flowName
         | 
| 329 | 
            +
            const FlowerRoute = ({ autostart = true, children, onEnter, onExit }) => {
         | 
| 330 | 
            +
                const dispatch = useDispatch();
         | 
| 331 | 
            +
                const one = React.useRef(false);
         | 
| 332 | 
            +
                const { flowName } = React.useContext(context);
         | 
| 333 | 
            +
                React.useEffect(() => {
         | 
| 334 | 
            +
                    onEnter?.();
         | 
| 335 | 
            +
                    return () => {
         | 
| 336 | 
            +
                        onExit?.();
         | 
| 337 | 
            +
                    };
         | 
| 338 | 
            +
                }, [onEnter, onExit]);
         | 
| 339 | 
            +
                React.useEffect(() => {
         | 
| 340 | 
            +
                    if (autostart && one.current === false) {
         | 
| 341 | 
            +
                        one.current = true;
         | 
| 342 | 
            +
                        dispatch({ type: 'flower/next', payload: { flowName } });
         | 
| 350 343 | 
             
                    }
         | 
| 351 | 
            -
             | 
| 352 | 
            -
                 | 
| 353 | 
            -
              }, [dispatch, flowName, _autostart]);
         | 
| 354 | 
            -
              return children;
         | 
| 344 | 
            +
                }, [dispatch, flowName, autostart]);
         | 
| 345 | 
            +
                return children;
         | 
| 355 346 | 
             
            };
         | 
| 356 | 
            -
            const component$6 =  | 
| 347 | 
            +
            const component$6 = React.memo(FlowerRoute);
         | 
| 357 348 | 
             
            component$6.displayName = 'FlowerRoute';
         | 
| 358 349 |  | 
| 359 | 
            -
             | 
| 360 | 
            -
             | 
| 361 | 
            -
                 | 
| 362 | 
            -
             | 
| 363 | 
            -
             | 
| 364 | 
            -
                 | 
| 365 | 
            -
             | 
| 366 | 
            -
             | 
| 367 | 
            -
            }
         | 
| 368 | 
            -
             | 
| 369 | 
            -
             | 
| 370 | 
            -
             | 
| 371 | 
            -
             | 
| 372 | 
            -
             | 
| 373 | 
            -
             | 
| 374 | 
            -
             | 
| 375 | 
            -
             | 
| 376 | 
            -
            }
         | 
| 377 | 
            -
             | 
| 378 | 
            -
            const FlowerRule = ({
         | 
| 379 | 
            -
              children,
         | 
| 380 | 
            -
              rules,
         | 
| 381 | 
            -
              value,
         | 
| 382 | 
            -
              alwaysDisplay,
         | 
| 383 | 
            -
              flowName,
         | 
| 384 | 
            -
              id,
         | 
| 385 | 
            -
              onUpdate
         | 
| 386 | 
            -
            }) => {
         | 
| 387 | 
            -
              const {
         | 
| 388 | 
            -
                flowName: flowNameContext,
         | 
| 389 | 
            -
                currentNode
         | 
| 390 | 
            -
              } = React.useContext(context);
         | 
| 391 | 
            -
              const name = flowName || flowNameContext;
         | 
| 392 | 
            -
              const keys = flowerCore.MatchRules.utils.getKeys(rules, {
         | 
| 393 | 
            -
                prefix: name
         | 
| 394 | 
            -
              });
         | 
| 395 | 
            -
              const hidden = useSelector(selectorRulesDisabled(id != null ? id : '', rules, keys != null ? keys : [], name != null ? name : '', value, currentNode != null ? currentNode : ''));
         | 
| 396 | 
            -
              React.useEffect(() => {
         | 
| 397 | 
            -
                if (onUpdate) {
         | 
| 398 | 
            -
                  onUpdate(hidden);
         | 
| 350 | 
            +
            const FlowerRule = ({ children, rules, value, alwaysDisplay, flowName, id, onUpdate }) => {
         | 
| 351 | 
            +
                const { flowName: flowNameContext, currentNode } = React.useContext(context);
         | 
| 352 | 
            +
                const name = flowName || flowNameContext;
         | 
| 353 | 
            +
                const keys = flowerCore.MatchRules.utils.getKeys(rules, { prefix: name });
         | 
| 354 | 
            +
                const hidden = useSelector(selectorRulesDisabled(id ?? '', rules, keys ?? [], name ?? '', value, currentNode ?? ''));
         | 
| 355 | 
            +
                React.useEffect(() => {
         | 
| 356 | 
            +
                    if (onUpdate) {
         | 
| 357 | 
            +
                        onUpdate(hidden);
         | 
| 358 | 
            +
                    }
         | 
| 359 | 
            +
                }, [hidden, onUpdate]);
         | 
| 360 | 
            +
                if (typeof children === 'function') {
         | 
| 361 | 
            +
                    if (alwaysDisplay && hidden) {
         | 
| 362 | 
            +
                        return children({ hidden });
         | 
| 363 | 
            +
                    }
         | 
| 364 | 
            +
                    if (hidden) {
         | 
| 365 | 
            +
                        return undefined;
         | 
| 366 | 
            +
                    }
         | 
| 367 | 
            +
                    return children({});
         | 
| 399 368 | 
             
                }
         | 
| 400 | 
            -
              }, [hidden, onUpdate]);
         | 
| 401 | 
            -
              if (typeof children === 'function') {
         | 
| 402 369 | 
             
                if (alwaysDisplay && hidden) {
         | 
| 403 | 
            -
             | 
| 404 | 
            -
             | 
| 405 | 
            -
             | 
| 406 | 
            -
             | 
| 407 | 
            -
             | 
| 408 | 
            -
             | 
| 409 | 
            -
             | 
| 410 | 
            -
             | 
| 411 | 
            -
             | 
| 412 | 
            -
              if (alwaysDisplay && hidden) {
         | 
| 413 | 
            -
                return React.Children.map(children, (child, i) => {
         | 
| 414 | 
            -
                  if ( /*#__PURE__*/React.isValidElement(child)) {
         | 
| 415 | 
            -
                    const {
         | 
| 416 | 
            -
                      props,
         | 
| 417 | 
            -
                      type
         | 
| 418 | 
            -
                    } = child;
         | 
| 419 | 
            -
                    const Component = type;
         | 
| 420 | 
            -
                    return Component && /*#__PURE__*/React.createElement(Component, _extends({
         | 
| 421 | 
            -
                      key: i,
         | 
| 422 | 
            -
                      hidden: true
         | 
| 423 | 
            -
                    }, props));
         | 
| 424 | 
            -
                  }
         | 
| 425 | 
            -
                  return child;
         | 
| 426 | 
            -
                });
         | 
| 427 | 
            -
              }
         | 
| 428 | 
            -
              return hidden ? undefined : React.Children.map(children, (child, i) => {
         | 
| 429 | 
            -
                if ( /*#__PURE__*/React.isValidElement(child)) {
         | 
| 430 | 
            -
                  const {
         | 
| 431 | 
            -
                    props,
         | 
| 432 | 
            -
                    type
         | 
| 433 | 
            -
                  } = child;
         | 
| 434 | 
            -
                  const Component = type;
         | 
| 435 | 
            -
                  return Component && /*#__PURE__*/React.createElement(Component, _extends({
         | 
| 436 | 
            -
                    key: i
         | 
| 437 | 
            -
                  }, props));
         | 
| 370 | 
            +
                    return React.Children.map(children, (child, i) => {
         | 
| 371 | 
            +
                        if (React.isValidElement(child)) {
         | 
| 372 | 
            +
                            const { props, type } = child;
         | 
| 373 | 
            +
                            const Component = type;
         | 
| 374 | 
            +
                            // eslint-disable-next-line react/jsx-props-no-spreading
         | 
| 375 | 
            +
                            return Component && React.createElement(Component, { key: i, hidden: true, ...props });
         | 
| 376 | 
            +
                        }
         | 
| 377 | 
            +
                        return child;
         | 
| 378 | 
            +
                    });
         | 
| 438 379 | 
             
                }
         | 
| 439 | 
            -
                return  | 
| 440 | 
            -
             | 
| 380 | 
            +
                return hidden
         | 
| 381 | 
            +
                    ? undefined
         | 
| 382 | 
            +
                    : React.Children.map(children, (child, i) => {
         | 
| 383 | 
            +
                        if (React.isValidElement(child)) {
         | 
| 384 | 
            +
                            const { props, type } = child;
         | 
| 385 | 
            +
                            const Component = type;
         | 
| 386 | 
            +
                            // eslint-disable-next-line react/jsx-props-no-spreading
         | 
| 387 | 
            +
                            return Component && React.createElement(Component, { key: i, ...props });
         | 
| 388 | 
            +
                        }
         | 
| 389 | 
            +
                        return child;
         | 
| 390 | 
            +
                    });
         | 
| 441 391 | 
             
            };
         | 
| 442 | 
            -
            const component$5 =  | 
| 392 | 
            +
            const component$5 = React.memo(FlowerRule);
         | 
| 443 393 | 
             
            component$5.displayName = 'FlowerRule';
         | 
| 444 394 |  | 
| 445 | 
            -
             | 
| 395 | 
            +
            /* eslint-disable */
         | 
| 446 396 | 
             
            function isIntrinsicElement$1(x) {
         | 
| 447 | 
            -
             | 
| 397 | 
            +
                return typeof x === 'string';
         | 
| 448 398 | 
             
            }
         | 
| 449 | 
            -
            function  | 
| 450 | 
            -
             | 
| 451 | 
            -
             | 
| 452 | 
            -
             | 
| 453 | 
            -
             | 
| 454 | 
            -
             | 
| 455 | 
            -
             | 
| 456 | 
            -
             | 
| 457 | 
            -
             | 
| 458 | 
            -
             | 
| 459 | 
            -
             | 
| 460 | 
            -
             | 
| 461 | 
            -
             | 
| 462 | 
            -
             | 
| 463 | 
            -
             | 
| 464 | 
            -
             | 
| 465 | 
            -
             | 
| 466 | 
            -
             | 
| 467 | 
            -
              const dispatch = useDispatch();
         | 
| 468 | 
            -
              const [touched, setTouched] = React.useState();
         | 
| 469 | 
            -
              const [customErrors, setCustomErrors] = React.useState(asyncValidate && [asyncInitialError]);
         | 
| 470 | 
            -
              const [isValidating, setIsValidating] = React.useState(undefined);
         | 
| 471 | 
            -
              const {
         | 
| 472 | 
            -
                flowNameFromPath = flowName,
         | 
| 473 | 
            -
                path
         | 
| 474 | 
            -
              } = React.useMemo(() => flowerCore.CoreUtils.getPath(id), [id]);
         | 
| 475 | 
            -
              const value = useSelector(getDataFromState(flowNameFromPath, path));
         | 
| 476 | 
            -
              const errors = useSelector(makeSelectFieldError(flowName, id, validate), flowerCore.CoreUtils.allEqual);
         | 
| 477 | 
            -
              const refValue = React.useRef();
         | 
| 478 | 
            -
              const one = React.useRef();
         | 
| 479 | 
            -
              const validateFn = React.useCallback(async value => {
         | 
| 480 | 
            -
                if (asyncWaitingError) {
         | 
| 481 | 
            -
                  setCustomErrors([asyncWaitingError]);
         | 
| 482 | 
            -
                }
         | 
| 483 | 
            -
                setIsValidating(true);
         | 
| 484 | 
            -
                const state = flowerCore.FlowerStateUtils.getAllData(store);
         | 
| 485 | 
            -
                const res = await asyncValidate(value, state, errors);
         | 
| 486 | 
            -
                setIsValidating(false);
         | 
| 487 | 
            -
                setCustomErrors(res);
         | 
| 488 | 
            -
              }, [asyncWaitingError, errors]);
         | 
| 489 | 
            -
              const debouncedValidation = React.useCallback(debounce(validateFn, asyncDebounce), [validateFn]);
         | 
| 490 | 
            -
              React.useEffect(() => {
         | 
| 491 | 
            -
                if (asyncValidate) {
         | 
| 492 | 
            -
                  if (refValue.current === value) return;
         | 
| 493 | 
            -
                  refValue.current = value;
         | 
| 494 | 
            -
                  const hasValue = !flowerCore.MatchRules.utils.isEmpty(value);
         | 
| 495 | 
            -
                  if (!hasValue) {
         | 
| 496 | 
            -
                    setCustomErrors([asyncInitialError]);
         | 
| 399 | 
            +
            //TODO make types for wrapper function props
         | 
| 400 | 
            +
            function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDebounce = 0, asyncValidate, asyncInitialError, asyncWaitingError, destroyValue, onBlur = (val) => null, hidden, onUpdate, defaultValue, ...props }) {
         | 
| 401 | 
            +
                const dispatch = useDispatch();
         | 
| 402 | 
            +
                const [touched, setTouched] = React.useState();
         | 
| 403 | 
            +
                const [customErrors, setCustomErrors] = React.useState(asyncValidate && [asyncInitialError]);
         | 
| 404 | 
            +
                const [isValidating, setIsValidating] = React.useState(undefined);
         | 
| 405 | 
            +
                const { flowNameFromPath = flowName, path } = React.useMemo(() => flowerCore.CoreUtils.getPath(id), [id]);
         | 
| 406 | 
            +
                const value = useSelector(getDataFromState(flowNameFromPath, path));
         | 
| 407 | 
            +
                const errors = useSelector(makeSelectFieldError(flowName, id, validate), flowerCore.CoreUtils.allEqual);
         | 
| 408 | 
            +
                const refValue = React.useRef();
         | 
| 409 | 
            +
                const one = React.useRef();
         | 
| 410 | 
            +
                const validateFn = React.useCallback(async (value) => {
         | 
| 411 | 
            +
                    if (asyncWaitingError) {
         | 
| 412 | 
            +
                        setCustomErrors([asyncWaitingError]);
         | 
| 413 | 
            +
                    }
         | 
| 414 | 
            +
                    setIsValidating(true);
         | 
| 415 | 
            +
                    const state = flowerCore.FlowerStateUtils.getAllData(store);
         | 
| 416 | 
            +
                    const res = await asyncValidate(value, state, errors);
         | 
| 497 417 | 
             
                    setIsValidating(false);
         | 
| 498 | 
            -
                     | 
| 499 | 
            -
             | 
| 500 | 
            -
             | 
| 501 | 
            -
             | 
| 502 | 
            -
                 | 
| 503 | 
            -
             | 
| 504 | 
            -
             | 
| 505 | 
            -
             | 
| 506 | 
            -
             | 
| 507 | 
            -
             | 
| 508 | 
            -
             | 
| 509 | 
            -
             | 
| 510 | 
            -
             | 
| 511 | 
            -
             | 
| 512 | 
            -
             | 
| 513 | 
            -
             | 
| 514 | 
            -
             | 
| 515 | 
            -
             | 
| 516 | 
            -
                     | 
| 517 | 
            -
             | 
| 518 | 
            -
             | 
| 519 | 
            -
                 | 
| 520 | 
            -
             | 
| 521 | 
            -
             | 
| 522 | 
            -
             | 
| 523 | 
            -
             | 
| 524 | 
            -
             | 
| 525 | 
            -
             | 
| 526 | 
            -
                dispatch({
         | 
| 527 | 
            -
                  type: 'flower/formAddErrors',
         | 
| 528 | 
            -
                  payload: {
         | 
| 529 | 
            -
                    name: flowName,
         | 
| 530 | 
            -
                    id,
         | 
| 531 | 
            -
                    currentNode,
         | 
| 532 | 
            -
                    errors: allErrors
         | 
| 533 | 
            -
                  }
         | 
| 534 | 
            -
                });
         | 
| 535 | 
            -
              }, [id, flowName, allErrors, currentNode]);
         | 
| 536 | 
            -
              React.useEffect(() => {
         | 
| 537 | 
            -
                dispatch({
         | 
| 538 | 
            -
                  type: 'flower/setFormIsValidating',
         | 
| 539 | 
            -
                  payload: {
         | 
| 540 | 
            -
                    name: flowName,
         | 
| 541 | 
            -
                    currentNode,
         | 
| 542 | 
            -
                    isValidating
         | 
| 543 | 
            -
                  }
         | 
| 544 | 
            -
                });
         | 
| 545 | 
            -
              }, [flowName, currentNode, isValidating]);
         | 
| 546 | 
            -
              React.useLayoutEffect(() => {
         | 
| 547 | 
            -
                return () => {
         | 
| 548 | 
            -
                  if (destroyValue) {
         | 
| 418 | 
            +
                    setCustomErrors(res);
         | 
| 419 | 
            +
                }, [asyncWaitingError, errors]);
         | 
| 420 | 
            +
                const debouncedValidation = React.useCallback(debounce(validateFn, asyncDebounce), [
         | 
| 421 | 
            +
                    validateFn
         | 
| 422 | 
            +
                ]);
         | 
| 423 | 
            +
                React.useEffect(() => {
         | 
| 424 | 
            +
                    if (asyncValidate) {
         | 
| 425 | 
            +
                        if (refValue.current === value)
         | 
| 426 | 
            +
                            return;
         | 
| 427 | 
            +
                        refValue.current = value;
         | 
| 428 | 
            +
                        const hasValue = !flowerCore.MatchRules.utils.isEmpty(value);
         | 
| 429 | 
            +
                        if (!hasValue) {
         | 
| 430 | 
            +
                            setCustomErrors([asyncInitialError]);
         | 
| 431 | 
            +
                            setIsValidating(false);
         | 
| 432 | 
            +
                            return;
         | 
| 433 | 
            +
                        }
         | 
| 434 | 
            +
                        setTouched(true);
         | 
| 435 | 
            +
                        debouncedValidation(value);
         | 
| 436 | 
            +
                    }
         | 
| 437 | 
            +
                }, [asyncValidate, asyncInitialError, value, debouncedValidation]);
         | 
| 438 | 
            +
                const touchedForm = useSelector(makeSelectNodeFormTouched(flowName, currentNode));
         | 
| 439 | 
            +
                const allErrors = React.useMemo(() => [...errors, ...(customErrors || []).filter(Boolean)], [errors, customErrors]);
         | 
| 440 | 
            +
                React.useEffect(() => {
         | 
| 441 | 
            +
                    if (onUpdate) {
         | 
| 442 | 
            +
                        onUpdate(value);
         | 
| 443 | 
            +
                    }
         | 
| 444 | 
            +
                }, [value, onUpdate]);
         | 
| 445 | 
            +
                const onChange = React.useCallback((val) => {
         | 
| 549 446 | 
             
                    dispatch({
         | 
| 550 | 
            -
             | 
| 551 | 
            -
             | 
| 552 | 
            -
             | 
| 553 | 
            -
             | 
| 554 | 
            -
             | 
| 447 | 
            +
                        type: `flower/addDataByPath`,
         | 
| 448 | 
            +
                        payload: {
         | 
| 449 | 
            +
                            flowName: flowNameFromPath,
         | 
| 450 | 
            +
                            id: path,
         | 
| 451 | 
            +
                            value: val
         | 
| 452 | 
            +
                        }
         | 
| 555 453 | 
             
                    });
         | 
| 556 | 
            -
             | 
| 557 | 
            -
             | 
| 558 | 
            -
                     | 
| 559 | 
            -
                     | 
| 560 | 
            -
             | 
| 561 | 
            -
             | 
| 562 | 
            -
             | 
| 454 | 
            +
                }, [flowNameFromPath, path, onBlur, dispatch]);
         | 
| 455 | 
            +
                const onBlurInternal = React.useCallback((e) => {
         | 
| 456 | 
            +
                    setTouched(true);
         | 
| 457 | 
            +
                    onBlur && onBlur(e);
         | 
| 458 | 
            +
                }, [onBlur]);
         | 
| 459 | 
            +
                React.useLayoutEffect(() => {
         | 
| 460 | 
            +
                    dispatch({
         | 
| 461 | 
            +
                        type: 'flower/formAddErrors',
         | 
| 462 | 
            +
                        payload: {
         | 
| 463 | 
            +
                            name: flowName,
         | 
| 464 | 
            +
                            id,
         | 
| 465 | 
            +
                            currentNode,
         | 
| 466 | 
            +
                            errors: allErrors
         | 
| 467 | 
            +
                        }
         | 
| 468 | 
            +
                    });
         | 
| 469 | 
            +
                }, [id, flowName, allErrors, currentNode]);
         | 
| 470 | 
            +
                React.useEffect(() => {
         | 
| 471 | 
            +
                    dispatch({
         | 
| 472 | 
            +
                        type: 'flower/setFormIsValidating',
         | 
| 473 | 
            +
                        payload: {
         | 
| 474 | 
            +
                            name: flowName,
         | 
| 475 | 
            +
                            currentNode,
         | 
| 476 | 
            +
                            isValidating
         | 
| 477 | 
            +
                        }
         | 
| 478 | 
            +
                    });
         | 
| 479 | 
            +
                }, [flowName, currentNode, isValidating]);
         | 
| 480 | 
            +
                React.useLayoutEffect(() => {
         | 
| 481 | 
            +
                    // destroy
         | 
| 482 | 
            +
                    return () => {
         | 
| 483 | 
            +
                        if (destroyValue) {
         | 
| 484 | 
            +
                            dispatch({
         | 
| 485 | 
            +
                                type: `flower/unsetData`,
         | 
| 486 | 
            +
                                payload: { flowName: flowNameFromPath, id: path }
         | 
| 487 | 
            +
                            });
         | 
| 488 | 
            +
                        }
         | 
| 489 | 
            +
                        dispatch({
         | 
| 490 | 
            +
                            type: 'flower/formRemoveErrors',
         | 
| 491 | 
            +
                            payload: {
         | 
| 492 | 
            +
                                name: flowName,
         | 
| 493 | 
            +
                                id,
         | 
| 494 | 
            +
                                currentNode
         | 
| 495 | 
            +
                            }
         | 
| 496 | 
            +
                        });
         | 
| 497 | 
            +
                    };
         | 
| 498 | 
            +
                }, [destroyValue]);
         | 
| 499 | 
            +
                React.useEffect(() => {
         | 
| 500 | 
            +
                    if (defaultValue && !one.current) {
         | 
| 501 | 
            +
                        one.current = true;
         | 
| 502 | 
            +
                        onChange(defaultValue);
         | 
| 563 503 | 
             
                    }
         | 
| 564 | 
            -
             | 
| 565 | 
            -
                 | 
| 566 | 
            -
             | 
| 567 | 
            -
             | 
| 568 | 
            -
             | 
| 569 | 
            -
             | 
| 570 | 
            -
             | 
| 504 | 
            +
                }, [defaultValue, onChange]);
         | 
| 505 | 
            +
                const isTouched = touched || touchedForm;
         | 
| 506 | 
            +
                const newProps = React.useMemo(() => ({
         | 
| 507 | 
            +
                    ...props,
         | 
| 508 | 
            +
                    id,
         | 
| 509 | 
            +
                    value,
         | 
| 510 | 
            +
                    errors: isTouched && allErrors,
         | 
| 511 | 
            +
                    hasError: isTouched && !!allErrors.length,
         | 
| 512 | 
            +
                    onChange,
         | 
| 513 | 
            +
                    onBlur: onBlurInternal,
         | 
| 514 | 
            +
                    isTouched,
         | 
| 515 | 
            +
                    hidden,
         | 
| 516 | 
            +
                    isValidating
         | 
| 517 | 
            +
                }), [
         | 
| 518 | 
            +
                    props,
         | 
| 519 | 
            +
                    id,
         | 
| 520 | 
            +
                    value,
         | 
| 521 | 
            +
                    allErrors,
         | 
| 522 | 
            +
                    isTouched,
         | 
| 523 | 
            +
                    onChange,
         | 
| 524 | 
            +
                    onBlurInternal,
         | 
| 525 | 
            +
                    hidden,
         | 
| 526 | 
            +
                    isValidating
         | 
| 527 | 
            +
                ]);
         | 
| 528 | 
            +
                if (typeof Component === 'function') {
         | 
| 529 | 
            +
                    return Component(newProps);
         | 
| 530 | 
            +
                }
         | 
| 531 | 
            +
                // TODO si arriva in questa condizione quando si passa un componente primitivo es. div
         | 
| 532 | 
            +
                // in questo caso non posso props custom di flower
         | 
| 533 | 
            +
                if (isIntrinsicElement$1(Component)) {
         | 
| 534 | 
            +
                    return React.createElement(Component, { id: id, ...props });
         | 
| 571 535 | 
             
                }
         | 
| 572 | 
            -
             | 
| 573 | 
            -
              const isTouched = touched || touchedForm;
         | 
| 574 | 
            -
              const newProps = React.useMemo(() => _extends({}, props, {
         | 
| 575 | 
            -
                id,
         | 
| 576 | 
            -
                value,
         | 
| 577 | 
            -
                errors: isTouched && allErrors,
         | 
| 578 | 
            -
                hasError: isTouched && !!allErrors.length,
         | 
| 579 | 
            -
                onChange,
         | 
| 580 | 
            -
                onBlur: onBlurInternal,
         | 
| 581 | 
            -
                isTouched,
         | 
| 582 | 
            -
                hidden,
         | 
| 583 | 
            -
                isValidating
         | 
| 584 | 
            -
              }), [props, id, value, allErrors, isTouched, onChange, onBlurInternal, hidden, isValidating]);
         | 
| 585 | 
            -
              if (typeof Component === 'function') {
         | 
| 586 | 
            -
                return Component(newProps);
         | 
| 587 | 
            -
              }
         | 
| 588 | 
            -
              if (isIntrinsicElement$1(Component)) {
         | 
| 589 | 
            -
                return /*#__PURE__*/React.createElement(Component, _extends({
         | 
| 590 | 
            -
                  id: id
         | 
| 591 | 
            -
                }, props));
         | 
| 592 | 
            -
              }
         | 
| 593 | 
            -
              return Component && /*#__PURE__*/React.createElement(Component, _extends({}, newProps));
         | 
| 536 | 
            +
                return Component && React.createElement(Component, { ...newProps });
         | 
| 594 537 | 
             
            }
         | 
| 595 | 
            -
            const FlowerField = ({
         | 
| 596 | 
            -
             | 
| 597 | 
            -
             | 
| 598 | 
            -
             | 
| 599 | 
            -
             | 
| 600 | 
            -
              asyncInitialError,
         | 
| 601 | 
            -
              asyncWaitingError,
         | 
| 602 | 
            -
              rules,
         | 
| 603 | 
            -
              alwaysDisplay,
         | 
| 604 | 
            -
              value,
         | 
| 605 | 
            -
              children,
         | 
| 606 | 
            -
              defaultValue,
         | 
| 607 | 
            -
              destroyValue,
         | 
| 608 | 
            -
              flowName,
         | 
| 609 | 
            -
              onUpdate
         | 
| 610 | 
            -
            }) => {
         | 
| 611 | 
            -
              const {
         | 
| 612 | 
            -
                flowName: flowNameContext,
         | 
| 613 | 
            -
                currentNode
         | 
| 614 | 
            -
              } = React.useContext(context);
         | 
| 615 | 
            -
              const name = flowName || flowNameContext;
         | 
| 616 | 
            -
              if (typeof children === 'function') {
         | 
| 617 | 
            -
                return /*#__PURE__*/React.createElement(component$5, {
         | 
| 618 | 
            -
                  alwaysDisplay: alwaysDisplay,
         | 
| 619 | 
            -
                  rules: rules,
         | 
| 620 | 
            -
                  value: value,
         | 
| 621 | 
            -
                  flowName: name,
         | 
| 622 | 
            -
                  id: id
         | 
| 623 | 
            -
                }, ({
         | 
| 624 | 
            -
                  hidden
         | 
| 625 | 
            -
                }) => ( /*#__PURE__*/React.createElement(Wrapper$1, {
         | 
| 626 | 
            -
                  hidden: hidden,
         | 
| 627 | 
            -
                  id: id,
         | 
| 628 | 
            -
                  Component: children,
         | 
| 629 | 
            -
                  flowName: name,
         | 
| 630 | 
            -
                  currentNode: currentNode,
         | 
| 631 | 
            -
                  validate: validate,
         | 
| 632 | 
            -
                  asyncValidate: asyncValidate,
         | 
| 633 | 
            -
                  asyncDebounce: asyncDebounce,
         | 
| 634 | 
            -
                  asyncInitialError: asyncInitialError,
         | 
| 635 | 
            -
                  asyncWaitingError: asyncWaitingError,
         | 
| 636 | 
            -
                  destroyValue: destroyValue,
         | 
| 637 | 
            -
                  onUpdate: onUpdate,
         | 
| 638 | 
            -
                  defaultValue: defaultValue
         | 
| 639 | 
            -
                })));
         | 
| 640 | 
            -
              }
         | 
| 641 | 
            -
              return React.Children.map(children, (child, i) => {
         | 
| 642 | 
            -
                if (! /*#__PURE__*/React.isValidElement(child)) {
         | 
| 643 | 
            -
                  return child;
         | 
| 538 | 
            +
            const FlowerField = ({ id, validate, asyncValidate, asyncDebounce, asyncInitialError, asyncWaitingError, rules, alwaysDisplay, value, children, defaultValue, destroyValue, flowName, onUpdate }) => {
         | 
| 539 | 
            +
                const { flowName: flowNameContext, currentNode } = React.useContext(context);
         | 
| 540 | 
            +
                const name = flowName || flowNameContext;
         | 
| 541 | 
            +
                if (typeof children === 'function') {
         | 
| 542 | 
            +
                    return (React.createElement(component$5, { alwaysDisplay: alwaysDisplay, rules: rules, value: value, flowName: name, id: id }, ({ hidden }) => (React.createElement(Wrapper$1, { hidden: hidden, id: id, Component: children, flowName: name, currentNode: currentNode, validate: validate, asyncValidate: asyncValidate, asyncDebounce: asyncDebounce, asyncInitialError: asyncInitialError, asyncWaitingError: asyncWaitingError, destroyValue: destroyValue, onUpdate: onUpdate, defaultValue: defaultValue }))));
         | 
| 644 543 | 
             
                }
         | 
| 645 | 
            -
                 | 
| 646 | 
            -
             | 
| 647 | 
            -
             | 
| 648 | 
            -
             | 
| 649 | 
            -
             | 
| 650 | 
            -
             | 
| 651 | 
            -
             | 
| 652 | 
            -
             | 
| 653 | 
            -
                  rules: rules,
         | 
| 654 | 
            -
                  value: value,
         | 
| 655 | 
            -
                  flowName: name
         | 
| 656 | 
            -
                }, ({
         | 
| 657 | 
            -
                  hidden
         | 
| 658 | 
            -
                }) => ( /*#__PURE__*/React.createElement(Wrapper$1, _extends({}, props, {
         | 
| 659 | 
            -
                  hidden: hidden,
         | 
| 660 | 
            -
                  id: id,
         | 
| 661 | 
            -
                  Component: Component,
         | 
| 662 | 
            -
                  flowName: name,
         | 
| 663 | 
            -
                  currentNode: currentNode,
         | 
| 664 | 
            -
                  validate: validate,
         | 
| 665 | 
            -
                  asyncValidate: asyncValidate,
         | 
| 666 | 
            -
                  asyncDebounce: asyncDebounce,
         | 
| 667 | 
            -
                  asyncInitialError: asyncInitialError,
         | 
| 668 | 
            -
                  asyncWaitingError: asyncWaitingError,
         | 
| 669 | 
            -
                  destroyValue: destroyValue,
         | 
| 670 | 
            -
                  onUpdate: onUpdate,
         | 
| 671 | 
            -
                  defaultValue: defaultValue
         | 
| 672 | 
            -
                }))));
         | 
| 673 | 
            -
              });
         | 
| 544 | 
            +
                return React.Children.map(children, (child, i) => {
         | 
| 545 | 
            +
                    if (!React.isValidElement(child)) {
         | 
| 546 | 
            +
                        return child;
         | 
| 547 | 
            +
                    }
         | 
| 548 | 
            +
                    const { type, props } = child;
         | 
| 549 | 
            +
                    const Component = type;
         | 
| 550 | 
            +
                    return (React.createElement(component$5, { key: i, alwaysDisplay: alwaysDisplay, rules: rules, value: value, flowName: name }, ({ hidden }) => (React.createElement(Wrapper$1, { ...props, hidden: hidden, id: id, Component: Component, flowName: name, currentNode: currentNode, validate: validate, asyncValidate: asyncValidate, asyncDebounce: asyncDebounce, asyncInitialError: asyncInitialError, asyncWaitingError: asyncWaitingError, destroyValue: destroyValue, onUpdate: onUpdate, defaultValue: defaultValue }))));
         | 
| 551 | 
            +
                });
         | 
| 674 552 | 
             
            };
         | 
| 675 | 
            -
            const component$4 =  | 
| 553 | 
            +
            const component$4 = React.memo(FlowerField);
         | 
| 676 554 | 
             
            component$4.displayName = 'FlowerField';
         | 
| 677 555 |  | 
| 678 | 
            -
             | 
| 679 | 
            -
             | 
| 680 | 
            -
            function Wrapper( | 
| 681 | 
            -
             | 
| 682 | 
            -
             | 
| 683 | 
            -
             | 
| 684 | 
            -
             | 
| 685 | 
            -
             | 
| 686 | 
            -
             | 
| 687 | 
            -
             | 
| 688 | 
            -
             | 
| 689 | 
            -
             | 
| 690 | 
            -
             | 
| 691 | 
            -
                 | 
| 692 | 
            -
                path
         | 
| 693 | 
            -
              } = React.useMemo(() => flowerCore.CoreUtils.getPath(id), [id]);
         | 
| 694 | 
            -
              const value = useSelector(getDataFromState(flowNameFromPath, path));
         | 
| 695 | 
            -
              const values = spreadValue && typeof value === 'object' && !Array.isArray(value) ? value : {
         | 
| 696 | 
            -
                value
         | 
| 697 | 
            -
              };
         | 
| 698 | 
            -
              React.useEffect(() => {
         | 
| 699 | 
            -
                if (onUpdate) {
         | 
| 700 | 
            -
                  onUpdate(value);
         | 
| 701 | 
            -
                }
         | 
| 702 | 
            -
              }, [onUpdate, value]);
         | 
| 703 | 
            -
              return /*#__PURE__*/React.createElement(Component, _extends({
         | 
| 704 | 
            -
                id: id
         | 
| 705 | 
            -
              }, props, {
         | 
| 706 | 
            -
                flowName: flowName,
         | 
| 707 | 
            -
                hidden: hidden
         | 
| 708 | 
            -
              }, values));
         | 
| 556 | 
            +
            /* eslint-disable */
         | 
| 557 | 
            +
            //TODO make types for wrapper function
         | 
| 558 | 
            +
            function Wrapper({ Component, id, flowName, spreadValue, hidden, onUpdate, ...props }) {
         | 
| 559 | 
            +
                const { flowNameFromPath = flowName, path } = React.useMemo(() => flowerCore.CoreUtils.getPath(id), [id]);
         | 
| 560 | 
            +
                const value = useSelector(getDataFromState(flowNameFromPath, path));
         | 
| 561 | 
            +
                const values = spreadValue && typeof value === 'object' && !Array.isArray(value)
         | 
| 562 | 
            +
                    ? value
         | 
| 563 | 
            +
                    : { value };
         | 
| 564 | 
            +
                React.useEffect(() => {
         | 
| 565 | 
            +
                    if (onUpdate) {
         | 
| 566 | 
            +
                        onUpdate(value);
         | 
| 567 | 
            +
                    }
         | 
| 568 | 
            +
                }, [onUpdate, value]);
         | 
| 569 | 
            +
                return (React.createElement(Component, { id: id, ...props, flowName: flowName, hidden: hidden, ...values }));
         | 
| 709 570 | 
             
            }
         | 
| 710 | 
            -
            const RenderRules$1 =  | 
| 711 | 
            -
             | 
| 712 | 
            -
                  id,
         | 
| 713 | 
            -
                  alwaysDisplay,
         | 
| 714 | 
            -
                  rules,
         | 
| 715 | 
            -
                  value,
         | 
| 716 | 
            -
                  Component,
         | 
| 717 | 
            -
                  spreadValue,
         | 
| 718 | 
            -
                  flowName,
         | 
| 719 | 
            -
                  onUpdate
         | 
| 720 | 
            -
                } = _ref2,
         | 
| 721 | 
            -
                props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
         | 
| 722 | 
            -
              return /*#__PURE__*/React.createElement(component$5, {
         | 
| 723 | 
            -
                alwaysDisplay: alwaysDisplay,
         | 
| 724 | 
            -
                rules: rules,
         | 
| 725 | 
            -
                value: value,
         | 
| 726 | 
            -
                flowName: flowName,
         | 
| 727 | 
            -
                id: id
         | 
| 728 | 
            -
              }, ({
         | 
| 729 | 
            -
                hidden
         | 
| 730 | 
            -
              }) => ( /*#__PURE__*/React.createElement(Wrapper, _extends({}, props, {
         | 
| 731 | 
            -
                hidden: hidden,
         | 
| 732 | 
            -
                id: id,
         | 
| 733 | 
            -
                Component: Component,
         | 
| 734 | 
            -
                spreadValue: spreadValue,
         | 
| 735 | 
            -
                flowName: flowName,
         | 
| 736 | 
            -
                onUpdate: onUpdate
         | 
| 737 | 
            -
              }))));
         | 
| 571 | 
            +
            const RenderRules$1 = ({ id, alwaysDisplay, rules, value, Component, spreadValue, flowName, onUpdate, ...props }) => {
         | 
| 572 | 
            +
                return (React.createElement(component$5, { alwaysDisplay: alwaysDisplay, rules: rules, value: value, flowName: flowName, id: id }, ({ hidden }) => (React.createElement(Wrapper, { ...props, hidden: hidden, id: id, Component: Component, spreadValue: spreadValue, flowName: flowName, onUpdate: onUpdate }))));
         | 
| 738 573 | 
             
            };
         | 
| 739 | 
            -
            const FlowerValue = ({
         | 
| 740 | 
            -
             | 
| 741 | 
            -
             | 
| 742 | 
            -
             | 
| 743 | 
            -
             | 
| 744 | 
            -
             | 
| 745 | 
            -
             | 
| 746 | 
            -
             | 
| 747 | 
            -
             | 
| 748 | 
            -
            } | 
| 749 | 
            -
             | 
| 750 | 
            -
             | 
| 751 | 
            -
             | 
| 752 | 
            -
              const name = flowName || flowNameContext;
         | 
| 753 | 
            -
              if (typeof children === 'function') {
         | 
| 754 | 
            -
                return /*#__PURE__*/React.createElement(RenderRules$1, {
         | 
| 755 | 
            -
                  id: _id,
         | 
| 756 | 
            -
                  alwaysDisplay: alwaysDisplay,
         | 
| 757 | 
            -
                  rules: rules,
         | 
| 758 | 
            -
                  value: value,
         | 
| 759 | 
            -
                  spreadValue: spreadValue,
         | 
| 760 | 
            -
                  Component: children,
         | 
| 761 | 
            -
                  flowName: name,
         | 
| 762 | 
            -
                  onUpdate: onUpdate
         | 
| 574 | 
            +
            const FlowerValue = ({ id = '*', rules, alwaysDisplay, value, children, spreadValue, flowName, onUpdate, }) => {
         | 
| 575 | 
            +
                const { flowName: flowNameContext } = React.useContext(context);
         | 
| 576 | 
            +
                const name = flowName || flowNameContext;
         | 
| 577 | 
            +
                if (typeof children === 'function') {
         | 
| 578 | 
            +
                    return (React.createElement(RenderRules$1, { id: id, alwaysDisplay: alwaysDisplay, rules: rules, value: value, spreadValue: spreadValue, Component: children, flowName: name, onUpdate: onUpdate }));
         | 
| 579 | 
            +
                }
         | 
| 580 | 
            +
                return React.Children.map(children, (child, i) => {
         | 
| 581 | 
            +
                    if (!React.isValidElement(child))
         | 
| 582 | 
            +
                        return child;
         | 
| 583 | 
            +
                    const { type, props } = child;
         | 
| 584 | 
            +
                    const Component = type;
         | 
| 585 | 
            +
                    // eslint-disable-next-line react/jsx-props-no-spreading
         | 
| 586 | 
            +
                    return (React.createElement(RenderRules$1, { key: i, id: id, alwaysDisplay: alwaysDisplay, rules: rules, value: value, spreadValue: spreadValue, flowName: name, Component: Component, ...props, onUpdate: onUpdate }));
         | 
| 763 587 | 
             
                });
         | 
| 764 | 
            -
              }
         | 
| 765 | 
            -
              return React.Children.map(children, (child, i) => {
         | 
| 766 | 
            -
                if (! /*#__PURE__*/React.isValidElement(child)) return child;
         | 
| 767 | 
            -
                const {
         | 
| 768 | 
            -
                  type,
         | 
| 769 | 
            -
                  props
         | 
| 770 | 
            -
                } = child;
         | 
| 771 | 
            -
                const Component = type;
         | 
| 772 | 
            -
                return /*#__PURE__*/React.createElement(RenderRules$1, _extends({
         | 
| 773 | 
            -
                  key: i,
         | 
| 774 | 
            -
                  id: _id,
         | 
| 775 | 
            -
                  alwaysDisplay: alwaysDisplay,
         | 
| 776 | 
            -
                  rules: rules,
         | 
| 777 | 
            -
                  value: value,
         | 
| 778 | 
            -
                  spreadValue: spreadValue,
         | 
| 779 | 
            -
                  flowName: name,
         | 
| 780 | 
            -
                  Component: Component
         | 
| 781 | 
            -
                }, props, {
         | 
| 782 | 
            -
                  onUpdate: onUpdate
         | 
| 783 | 
            -
                }));
         | 
| 784 | 
            -
              });
         | 
| 785 588 | 
             
            };
         | 
| 786 | 
            -
            const component$3 =  | 
| 589 | 
            +
            const component$3 = React.memo(FlowerValue);
         | 
| 787 590 | 
             
            component$3.displayName = 'FlowerValue';
         | 
| 788 591 |  | 
| 789 592 | 
             
            const ACTION_TYPES = {
         | 
| 790 | 
            -
             | 
| 791 | 
            -
             | 
| 792 | 
            -
             | 
| 793 | 
            -
             | 
| 794 | 
            -
             | 
| 593 | 
            +
                back: ['prev', 'prevToNode'],
         | 
| 594 | 
            +
                jump: ['node', 'node'],
         | 
| 595 | 
            +
                next: ['next', 'next'],
         | 
| 596 | 
            +
                restart: ['restart', 'restart'],
         | 
| 597 | 
            +
                reset: ['reset', 'initializeFromNode']
         | 
| 795 598 | 
             
            };
         | 
| 796 599 | 
             
            const PAYLAOAD_KEYS_NEEDED = {
         | 
| 797 | 
            -
             | 
| 798 | 
            -
             | 
| 799 | 
            -
             | 
| 800 | 
            -
             | 
| 801 | 
            -
             | 
| 600 | 
            +
                back: ['node'],
         | 
| 601 | 
            +
                jump: ['node', 'history'],
         | 
| 602 | 
            +
                next: ['node', 'route', 'data'],
         | 
| 603 | 
            +
                restart: ['node'],
         | 
| 604 | 
            +
                reset: ['node', 'initialData']
         | 
| 802 605 | 
             
            };
         | 
| 803 606 | 
             
            const makeActionPayload = (actions, keys) => (flowName, params) => {
         | 
| 804 | 
            -
             | 
| 805 | 
            -
                 | 
| 806 | 
            -
             | 
| 807 | 
            -
             | 
| 808 | 
            -
                 | 
| 809 | 
            -
             | 
| 810 | 
            -
             | 
| 811 | 
            -
             | 
| 812 | 
            -
             | 
| 813 | 
            -
                 | 
| 814 | 
            -
              };
         | 
| 607 | 
            +
                const rest = typeof params === 'string' ? { node: params } : params;
         | 
| 608 | 
            +
                const payload = {
         | 
| 609 | 
            +
                    flowName: params?.flowName || flowName,
         | 
| 610 | 
            +
                    ...Object.fromEntries(Object.entries(rest ?? {}).filter(([k]) => keys.includes(k)))
         | 
| 611 | 
            +
                };
         | 
| 612 | 
            +
                const type = !params || !payload.node ? actions[0] : actions[1];
         | 
| 613 | 
            +
                return {
         | 
| 614 | 
            +
                    type,
         | 
| 615 | 
            +
                    payload
         | 
| 616 | 
            +
                };
         | 
| 815 617 | 
             
            };
         | 
| 816 618 | 
             
            const makeActionPayloadOnPrev = makeActionPayload(ACTION_TYPES.back, PAYLAOAD_KEYS_NEEDED.back);
         | 
| 817 619 | 
             
            const makeActionPayloadOnReset = makeActionPayload(ACTION_TYPES.reset, PAYLAOAD_KEYS_NEEDED.reset);
         | 
| 818 620 | 
             
            const makeActionPayloadOnNode = makeActionPayload(ACTION_TYPES.jump, PAYLAOAD_KEYS_NEEDED.jump);
         | 
| 819 621 | 
             
            const makeActionPayloadOnNext = makeActionPayload(ACTION_TYPES.next, PAYLAOAD_KEYS_NEEDED.next);
         | 
| 820 622 | 
             
            const makeActionPayloadOnRestart = makeActionPayload(ACTION_TYPES.restart, PAYLAOAD_KEYS_NEEDED.restart);
         | 
| 821 | 
            -
             | 
| 822 | 
            -
             | 
| 823 | 
            -
             | 
| 824 | 
            -
             | 
| 825 | 
            -
             | 
| 826 | 
            -
             | 
| 827 | 
            -
             | 
| 828 | 
            -
             | 
| 829 | 
            -
             | 
| 830 | 
            -
             | 
| 831 | 
            -
             | 
| 832 | 
            -
             | 
| 833 | 
            -
             | 
| 834 | 
            -
             | 
| 835 | 
            -
             | 
| 836 | 
            -
             | 
| 623 | 
            +
            /** This hook allows you to read flow informations, such as the flowName and ID of the current node.
         | 
| 624 | 
            +
             *
         | 
| 625 | 
            +
             * It also exposes all the functions to navigate within the flow:
         | 
| 626 | 
            +
             *
         | 
| 627 | 
            +
             * - next
         | 
| 628 | 
            +
             *
         | 
| 629 | 
            +
             * - back
         | 
| 630 | 
            +
             *
         | 
| 631 | 
            +
             * - jump
         | 
| 632 | 
            +
             *
         | 
| 633 | 
            +
             * - reset
         | 
| 634 | 
            +
             *
         | 
| 635 | 
            +
             * - restart
         | 
| 636 | 
            +
             *
         | 
| 637 | 
            +
             * @param {string} flowName - first optional parameter
         | 
| 638 | 
            +
             *
         | 
| 639 | 
            +
             * @param {string} name - optional parameter, if flowName exist, name is not used
         | 
| 640 | 
            +
             */
         | 
| 641 | 
            +
            const useFlower = ({ flowName: customFlowName, name } = {}) => {
         | 
| 642 | 
            +
                const dispatch = useDispatch();
         | 
| 643 | 
            +
                const { flowName: flowNameDefault, initialData } = React.useContext(context);
         | 
| 644 | 
            +
                const flowName = customFlowName || name || flowNameDefault;
         | 
| 645 | 
            +
                const nodeId = useSelector(makeSelectCurrentNodeId(flowName ?? ''));
         | 
| 646 | 
            +
                const startId = useSelector(makeSelectStartNodeId(flowName ?? ''));
         | 
| 647 | 
            +
                const emitNavigateEvent = React.useCallback(
         | 
| 648 | 
            +
                //TODO check this function is needed
         | 
| 649 | 
            +
                (params) => {
         | 
| 650 | 
            +
                    /* istanbul ignore next */
         | 
| 651 | 
            +
                    // eslint-disable-next-line no-underscore-dangle, no-undef
         | 
| 652 | 
            +
                    if (_get(flowerCore.devtoolState, '__FLOWER_DEVTOOLS__')) {
         | 
| 653 | 
            +
                        flowerCore.Emitter.emit('flower-devtool-from-client', {
         | 
| 654 | 
            +
                            source: 'flower-client',
         | 
| 655 | 
            +
                            action: 'FLOWER_NAVIGATE',
         | 
| 656 | 
            +
                            nodeId,
         | 
| 657 | 
            +
                            name: flowName,
         | 
| 658 | 
            +
                            time: new Date(),
         | 
| 659 | 
            +
                            params
         | 
| 660 | 
            +
                        });
         | 
| 661 | 
            +
                    }
         | 
| 662 | 
            +
                }, [flowName, nodeId]);
         | 
| 663 | 
            +
                const next = React.useCallback((param) => {
         | 
| 664 | 
            +
                    const params = typeof param === 'string' ? { route: param } : { data: param };
         | 
| 665 | 
            +
                    const { type, payload } = makeActionPayloadOnNext(flowName, params);
         | 
| 666 | 
            +
                    dispatch({
         | 
| 667 | 
            +
                        type: `flower/${type}`,
         | 
| 668 | 
            +
                        payload
         | 
| 669 | 
            +
                    });
         | 
| 670 | 
            +
                    emitNavigateEvent({ type, payload });
         | 
| 671 | 
            +
                }, [dispatch, emitNavigateEvent, flowName]);
         | 
| 672 | 
            +
                const back = React.useCallback((param) => {
         | 
| 673 | 
            +
                    const { type, payload } = makeActionPayloadOnPrev(flowName, param);
         | 
| 674 | 
            +
                    dispatch({ type: `flower/${type}`, payload });
         | 
| 675 | 
            +
                    emitNavigateEvent({ type, payload });
         | 
| 676 | 
            +
                }, [dispatch, emitNavigateEvent, flowName]);
         | 
| 677 | 
            +
                const restart = React.useCallback((param) => {
         | 
| 678 | 
            +
                    const { type, payload } = makeActionPayloadOnRestart(flowName, param);
         | 
| 679 | 
            +
                    dispatch({ type: `flower/${type}`, payload });
         | 
| 680 | 
            +
                    emitNavigateEvent({ type, payload });
         | 
| 681 | 
            +
                }, [dispatch, emitNavigateEvent, flowName]);
         | 
| 682 | 
            +
                const reset = React.useCallback((param) => {
         | 
| 683 | 
            +
                    const { type, payload } = makeActionPayloadOnReset(flowName, typeof param === 'string'
         | 
| 684 | 
            +
                        ? { node: param, initialData }
         | 
| 685 | 
            +
                        : {
         | 
| 686 | 
            +
                            ...param,
         | 
| 687 | 
            +
                            initialData
         | 
| 688 | 
            +
                        });
         | 
| 689 | 
            +
                    dispatch({ type: `flower/${type}`, payload });
         | 
| 690 | 
            +
                    emitNavigateEvent({ type, payload });
         | 
| 691 | 
            +
                }, [dispatch, emitNavigateEvent, flowName, initialData]);
         | 
| 692 | 
            +
                const jump = React.useCallback((param) => {
         | 
| 693 | 
            +
                    const { type, payload } = makeActionPayloadOnNode(flowName, param);
         | 
| 694 | 
            +
                    dispatch({ type: `flower/${type}`, payload });
         | 
| 695 | 
            +
                    emitNavigateEvent({ type, payload });
         | 
| 696 | 
            +
                }, [dispatch, emitNavigateEvent, flowName]);
         | 
| 697 | 
            +
                return {
         | 
| 698 | 
            +
                    flowName,
         | 
| 837 699 | 
             
                    nodeId,
         | 
| 838 | 
            -
                     | 
| 839 | 
            -
                     | 
| 840 | 
            -
                     | 
| 841 | 
            -
             | 
| 842 | 
            -
             | 
| 843 | 
            -
             | 
| 844 | 
            -
              const next = React.useCallback(param => {
         | 
| 845 | 
            -
                const params = typeof param === 'string' ? {
         | 
| 846 | 
            -
                  route: param
         | 
| 847 | 
            -
                } : {
         | 
| 848 | 
            -
                  data: param
         | 
| 700 | 
            +
                    startId,
         | 
| 701 | 
            +
                    next,
         | 
| 702 | 
            +
                    jump,
         | 
| 703 | 
            +
                    back,
         | 
| 704 | 
            +
                    reset,
         | 
| 705 | 
            +
                    restart
         | 
| 849 706 | 
             
                };
         | 
| 850 | 
            -
                const {
         | 
| 851 | 
            -
                  type,
         | 
| 852 | 
            -
                  payload
         | 
| 853 | 
            -
                } = makeActionPayloadOnNext(flowName, params);
         | 
| 854 | 
            -
                dispatch({
         | 
| 855 | 
            -
                  type: `flower/${type}`,
         | 
| 856 | 
            -
                  payload
         | 
| 857 | 
            -
                });
         | 
| 858 | 
            -
                emitNavigateEvent({
         | 
| 859 | 
            -
                  type,
         | 
| 860 | 
            -
                  payload
         | 
| 861 | 
            -
                });
         | 
| 862 | 
            -
              }, [dispatch, emitNavigateEvent, flowName]);
         | 
| 863 | 
            -
              const back = React.useCallback(param => {
         | 
| 864 | 
            -
                const {
         | 
| 865 | 
            -
                  type,
         | 
| 866 | 
            -
                  payload
         | 
| 867 | 
            -
                } = makeActionPayloadOnPrev(flowName, param);
         | 
| 868 | 
            -
                dispatch({
         | 
| 869 | 
            -
                  type: `flower/${type}`,
         | 
| 870 | 
            -
                  payload
         | 
| 871 | 
            -
                });
         | 
| 872 | 
            -
                emitNavigateEvent({
         | 
| 873 | 
            -
                  type,
         | 
| 874 | 
            -
                  payload
         | 
| 875 | 
            -
                });
         | 
| 876 | 
            -
              }, [dispatch, emitNavigateEvent, flowName]);
         | 
| 877 | 
            -
              const restart = React.useCallback(param => {
         | 
| 878 | 
            -
                const {
         | 
| 879 | 
            -
                  type,
         | 
| 880 | 
            -
                  payload
         | 
| 881 | 
            -
                } = makeActionPayloadOnRestart(flowName, param);
         | 
| 882 | 
            -
                dispatch({
         | 
| 883 | 
            -
                  type: `flower/${type}`,
         | 
| 884 | 
            -
                  payload
         | 
| 885 | 
            -
                });
         | 
| 886 | 
            -
                emitNavigateEvent({
         | 
| 887 | 
            -
                  type,
         | 
| 888 | 
            -
                  payload
         | 
| 889 | 
            -
                });
         | 
| 890 | 
            -
              }, [dispatch, emitNavigateEvent, flowName]);
         | 
| 891 | 
            -
              const reset = React.useCallback(param => {
         | 
| 892 | 
            -
                const {
         | 
| 893 | 
            -
                  type,
         | 
| 894 | 
            -
                  payload
         | 
| 895 | 
            -
                } = makeActionPayloadOnReset(flowName, typeof param === 'string' ? {
         | 
| 896 | 
            -
                  node: param,
         | 
| 897 | 
            -
                  initialData
         | 
| 898 | 
            -
                } : _extends({}, param, {
         | 
| 899 | 
            -
                  initialData
         | 
| 900 | 
            -
                }));
         | 
| 901 | 
            -
                dispatch({
         | 
| 902 | 
            -
                  type: `flower/${type}`,
         | 
| 903 | 
            -
                  payload
         | 
| 904 | 
            -
                });
         | 
| 905 | 
            -
                emitNavigateEvent({
         | 
| 906 | 
            -
                  type,
         | 
| 907 | 
            -
                  payload
         | 
| 908 | 
            -
                });
         | 
| 909 | 
            -
              }, [dispatch, emitNavigateEvent, flowName, initialData]);
         | 
| 910 | 
            -
              const jump = React.useCallback(param => {
         | 
| 911 | 
            -
                const {
         | 
| 912 | 
            -
                  type,
         | 
| 913 | 
            -
                  payload
         | 
| 914 | 
            -
                } = makeActionPayloadOnNode(flowName, param);
         | 
| 915 | 
            -
                dispatch({
         | 
| 916 | 
            -
                  type: `flower/${type}`,
         | 
| 917 | 
            -
                  payload
         | 
| 918 | 
            -
                });
         | 
| 919 | 
            -
                emitNavigateEvent({
         | 
| 920 | 
            -
                  type,
         | 
| 921 | 
            -
                  payload
         | 
| 922 | 
            -
                });
         | 
| 923 | 
            -
              }, [dispatch, emitNavigateEvent, flowName]);
         | 
| 924 | 
            -
              return {
         | 
| 925 | 
            -
                flowName,
         | 
| 926 | 
            -
                nodeId,
         | 
| 927 | 
            -
                next,
         | 
| 928 | 
            -
                jump,
         | 
| 929 | 
            -
                back,
         | 
| 930 | 
            -
                reset,
         | 
| 931 | 
            -
                restart
         | 
| 932 | 
            -
              };
         | 
| 933 707 | 
             
            };
         | 
| 934 708 |  | 
| 935 | 
            -
             | 
| 936 | 
            -
             | 
| 937 | 
            -
             | 
| 938 | 
            -
             | 
| 939 | 
            -
             | 
| 940 | 
            -
             | 
| 941 | 
            -
             | 
| 942 | 
            -
             | 
| 943 | 
            -
             | 
| 944 | 
            -
             | 
| 945 | 
            -
             | 
| 946 | 
            -
             | 
| 947 | 
            -
             | 
| 948 | 
            -
             | 
| 949 | 
            -
             | 
| 950 | 
            -
             | 
| 951 | 
            -
             | 
| 952 | 
            -
             | 
| 953 | 
            -
             | 
| 954 | 
            -
             | 
| 955 | 
            -
             | 
| 956 | 
            -
             | 
| 957 | 
            -
             | 
| 958 | 
            -
             | 
| 959 | 
            -
             | 
| 960 | 
            -
             | 
| 961 | 
            -
             | 
| 962 | 
            -
             | 
| 963 | 
            -
             | 
| 964 | 
            -
             | 
| 965 | 
            -
             | 
| 966 | 
            -
             | 
| 967 | 
            -
             | 
| 968 | 
            -
             | 
| 969 | 
            -
             | 
| 970 | 
            -
             | 
| 971 | 
            -
             | 
| 972 | 
            -
             | 
| 973 | 
            -
             | 
| 974 | 
            -
             | 
| 975 | 
            -
             | 
| 976 | 
            -
             | 
| 977 | 
            -
             | 
| 978 | 
            -
             | 
| 979 | 
            -
             | 
| 709 | 
            +
            /* eslint-disable */
         | 
| 710 | 
            +
            // {
         | 
| 711 | 
            +
            //   flowName?: string | undefined;
         | 
| 712 | 
            +
            //   action?: 'next' | 'back' | 'reset' | 'jump';
         | 
| 713 | 
            +
            // } & (
         | 
| 714 | 
            +
            //   | {
         | 
| 715 | 
            +
            //       node?: undefined;
         | 
| 716 | 
            +
            //       route?: Route;
         | 
| 717 | 
            +
            //     }
         | 
| 718 | 
            +
            //   | {
         | 
| 719 | 
            +
            //       node?: RoutePrev;
         | 
| 720 | 
            +
            //       route?: undefined;
         | 
| 721 | 
            +
            //     }
         | 
| 722 | 
            +
            //   | {
         | 
| 723 | 
            +
            //       node?: RouteReset;
         | 
| 724 | 
            +
            //       route?: undefined;
         | 
| 725 | 
            +
            //     }
         | 
| 726 | 
            +
            //   | {
         | 
| 727 | 
            +
            //       node?: RouteNode;
         | 
| 728 | 
            +
            //       route?: undefined;
         | 
| 729 | 
            +
            //     }
         | 
| 730 | 
            +
            // );
         | 
| 731 | 
            +
            const useFlowerNavigate = ({ flowName, action, route, node }) => {
         | 
| 732 | 
            +
                const { flowName: flowNameContext } = React.useContext(context);
         | 
| 733 | 
            +
                const name = flowName || flowNameContext;
         | 
| 734 | 
            +
                const { next, jump, back, reset, restart } = useFlower({ flowName: name });
         | 
| 735 | 
            +
                const onNavigate = React.useCallback(() => {
         | 
| 736 | 
            +
                    switch (action) {
         | 
| 737 | 
            +
                        case 'next':
         | 
| 738 | 
            +
                            next(route);
         | 
| 739 | 
            +
                            return;
         | 
| 740 | 
            +
                        case 'jump':
         | 
| 741 | 
            +
                            jump(node);
         | 
| 742 | 
            +
                            return;
         | 
| 743 | 
            +
                        case 'back':
         | 
| 744 | 
            +
                            back(node);
         | 
| 745 | 
            +
                            return;
         | 
| 746 | 
            +
                        case 'reset':
         | 
| 747 | 
            +
                            reset(node);
         | 
| 748 | 
            +
                            return;
         | 
| 749 | 
            +
                        case 'restart':
         | 
| 750 | 
            +
                            restart(node);
         | 
| 751 | 
            +
                            return;
         | 
| 752 | 
            +
                        default:
         | 
| 753 | 
            +
                            next();
         | 
| 754 | 
            +
                            return;
         | 
| 755 | 
            +
                    }
         | 
| 756 | 
            +
                }, [next, jump, back, reset, restart, node, route]);
         | 
| 757 | 
            +
                return {
         | 
| 758 | 
            +
                    onNavigate,
         | 
| 759 | 
            +
                    flowName
         | 
| 760 | 
            +
                };
         | 
| 980 761 | 
             
            };
         | 
| 981 762 |  | 
| 982 | 
            -
             | 
| 763 | 
            +
            /* eslint-disable */
         | 
| 983 764 | 
             
            function isIntrinsicElement(x) {
         | 
| 984 | 
            -
             | 
| 765 | 
            +
                return typeof x === 'string';
         | 
| 985 766 | 
             
            }
         | 
| 986 | 
            -
             | 
| 987 | 
            -
             | 
| 988 | 
            -
             | 
| 989 | 
            -
             | 
| 990 | 
            -
             | 
| 991 | 
            -
             | 
| 992 | 
            -
                props | 
| 993 | 
            -
             | 
| 994 | 
            -
             | 
| 995 | 
            -
                 | 
| 996 | 
            -
             | 
| 997 | 
            -
             | 
| 998 | 
            -
                 | 
| 999 | 
            -
             | 
| 1000 | 
            -
             | 
| 1001 | 
            -
                 | 
| 1002 | 
            -
             | 
| 1003 | 
            -
                 | 
| 1004 | 
            -
             | 
| 1005 | 
            -
              return Component && /*#__PURE__*/React.createElement(Component, _extends({}, newProps));
         | 
| 767 | 
            +
            //TODO type FlowerNavigateWrapper props
         | 
| 768 | 
            +
            function FlowerNavigateWrapper({ hidden, Component, onNavigate, ...props }) {
         | 
| 769 | 
            +
                const newProps = React.useMemo(() => ({
         | 
| 770 | 
            +
                    ...props,
         | 
| 771 | 
            +
                    hidden,
         | 
| 772 | 
            +
                    onClick: onNavigate,
         | 
| 773 | 
            +
                }), [props, onNavigate]);
         | 
| 774 | 
            +
                if (typeof Component === 'function') {
         | 
| 775 | 
            +
                    return Component(newProps);
         | 
| 776 | 
            +
                }
         | 
| 777 | 
            +
                // TODO si arriva in questa condizione quando si passa un componente primitivo es. div
         | 
| 778 | 
            +
                // in questo caso non posso props custom di flower
         | 
| 779 | 
            +
                if (isIntrinsicElement(Component)) {
         | 
| 780 | 
            +
                    return React.createElement(Component, { ...props, onClick: onNavigate });
         | 
| 781 | 
            +
                }
         | 
| 782 | 
            +
                // TODO in questa condizione si arriva se nel progetto si utilizza Vite, in questo caso i componenti non sono Function ma Object,
         | 
| 783 | 
            +
                // oppure nel caso di un testo semplice come children di questo componente
         | 
| 784 | 
            +
                /* istanbul ignore next */
         | 
| 785 | 
            +
                return Component && React.createElement(Component, { ...newProps });
         | 
| 1006 786 | 
             
            }
         | 
| 1007 | 
            -
            const component$2 =  | 
| 787 | 
            +
            const component$2 = React.memo(FlowerNavigateWrapper);
         | 
| 1008 788 |  | 
| 1009 | 
            -
             | 
| 1010 | 
            -
             | 
| 1011 | 
            -
             | 
| 1012 | 
            -
             | 
| 1013 | 
            -
                  rules,
         | 
| 1014 | 
            -
                  Component,
         | 
| 1015 | 
            -
                  flowName,
         | 
| 1016 | 
            -
                  onNavigate
         | 
| 1017 | 
            -
                } = _ref,
         | 
| 1018 | 
            -
                props = _objectWithoutPropertiesLoose(_ref, _excluded);
         | 
| 1019 | 
            -
              return /*#__PURE__*/React.createElement(component$5, {
         | 
| 1020 | 
            -
                alwaysDisplay: alwaysDisplay,
         | 
| 1021 | 
            -
                rules: rules,
         | 
| 1022 | 
            -
                flowName: flowName
         | 
| 1023 | 
            -
              }, ({
         | 
| 1024 | 
            -
                hidden
         | 
| 1025 | 
            -
              }) => /*#__PURE__*/React.createElement(component$2, _extends({}, props, {
         | 
| 1026 | 
            -
                Component: Component,
         | 
| 1027 | 
            -
                hidden: hidden,
         | 
| 1028 | 
            -
                onNavigate: onNavigate
         | 
| 1029 | 
            -
              })));
         | 
| 789 | 
            +
            /* eslint-disable */
         | 
| 790 | 
            +
            //TODO type RenderRules props
         | 
| 791 | 
            +
            const RenderRules = ({ alwaysDisplay, rules, Component, flowName, onNavigate, ...props }) => {
         | 
| 792 | 
            +
                return (React.createElement(component$5, { alwaysDisplay: alwaysDisplay, rules: rules, flowName: flowName }, ({ hidden }) => React.createElement(component$2, { ...props, Component: Component, hidden: hidden, onNavigate: onNavigate })));
         | 
| 1030 793 | 
             
            };
         | 
| 1031 | 
            -
            const FlowerNavigate = ({
         | 
| 1032 | 
            -
             | 
| 1033 | 
            -
             | 
| 1034 | 
            -
             | 
| 1035 | 
            -
             | 
| 1036 | 
            -
             | 
| 1037 | 
            -
             | 
| 1038 | 
            -
             | 
| 1039 | 
            -
            } | 
| 1040 | 
            -
             | 
| 1041 | 
            -
             | 
| 1042 | 
            -
             | 
| 1043 | 
            -
              } = useFlowerNavigate({
         | 
| 1044 | 
            -
                flowName: forceFlowName,
         | 
| 1045 | 
            -
                action,
         | 
| 1046 | 
            -
                route,
         | 
| 1047 | 
            -
                node
         | 
| 1048 | 
            -
              });
         | 
| 1049 | 
            -
              if (typeof children === 'function') {
         | 
| 1050 | 
            -
                return /*#__PURE__*/React.createElement(RenderRules, {
         | 
| 1051 | 
            -
                  alwaysDisplay: alwaysDisplay,
         | 
| 1052 | 
            -
                  rules: rules,
         | 
| 1053 | 
            -
                  Component: children,
         | 
| 1054 | 
            -
                  flowName: flowName,
         | 
| 1055 | 
            -
                  onNavigate: onNavigate
         | 
| 794 | 
            +
            const FlowerNavigate = ({ children, flowName: forceFlowName, action, route, node, rules, alwaysDisplay, }) => {
         | 
| 795 | 
            +
                const { onNavigate, flowName } = useFlowerNavigate({ flowName: forceFlowName, action, route, node });
         | 
| 796 | 
            +
                if (typeof children === 'function') {
         | 
| 797 | 
            +
                    return React.createElement(RenderRules, { alwaysDisplay: alwaysDisplay, rules: rules, Component: children, flowName: flowName, onNavigate: onNavigate });
         | 
| 798 | 
            +
                }
         | 
| 799 | 
            +
                return React.Children.map(children, (child, i) => {
         | 
| 800 | 
            +
                    if (!React.isValidElement(child))
         | 
| 801 | 
            +
                        return child;
         | 
| 802 | 
            +
                    const { type, props } = child;
         | 
| 803 | 
            +
                    const Component = type;
         | 
| 804 | 
            +
                    // eslint-disable-next-line react/jsx-props-no-spreading
         | 
| 805 | 
            +
                    return React.createElement(RenderRules, { key: i, alwaysDisplay: alwaysDisplay, rules: rules, Component: Component, flowName: flowName, onNavigate: onNavigate, ...props });
         | 
| 1056 806 | 
             
                });
         | 
| 1057 | 
            -
              }
         | 
| 1058 | 
            -
              return React.Children.map(children, (child, i) => {
         | 
| 1059 | 
            -
                if (! /*#__PURE__*/React.isValidElement(child)) return child;
         | 
| 1060 | 
            -
                const {
         | 
| 1061 | 
            -
                  type,
         | 
| 1062 | 
            -
                  props
         | 
| 1063 | 
            -
                } = child;
         | 
| 1064 | 
            -
                const Component = type;
         | 
| 1065 | 
            -
                return /*#__PURE__*/React.createElement(RenderRules, _extends({
         | 
| 1066 | 
            -
                  key: i,
         | 
| 1067 | 
            -
                  alwaysDisplay: alwaysDisplay,
         | 
| 1068 | 
            -
                  rules: rules,
         | 
| 1069 | 
            -
                  Component: Component,
         | 
| 1070 | 
            -
                  flowName: flowName,
         | 
| 1071 | 
            -
                  onNavigate: onNavigate
         | 
| 1072 | 
            -
                }, props));
         | 
| 1073 | 
            -
              });
         | 
| 1074 807 | 
             
            };
         | 
| 1075 | 
            -
            const component$1 =  | 
| 808 | 
            +
            const component$1 = React.memo(FlowerNavigate);
         | 
| 1076 809 | 
             
            component$1.displayName = 'FlowerNavigate';
         | 
| 1077 810 |  | 
| 1078 | 
            -
            const FlowerComponent = ({
         | 
| 1079 | 
            -
             | 
| 1080 | 
            -
            }) => children;
         | 
| 1081 | 
            -
            const component = /*#__PURE__*/React.memo(FlowerComponent);
         | 
| 811 | 
            +
            const FlowerComponent = ({ children }) => children;
         | 
| 812 | 
            +
            const component = React.memo(FlowerComponent);
         | 
| 1082 813 |  | 
| 1083 | 
            -
             | 
| 1084 | 
            -
             | 
| 1085 | 
            -
             | 
| 1086 | 
            -
             | 
| 1087 | 
            -
             | 
| 1088 | 
            -
             | 
| 1089 | 
            -
             | 
| 1090 | 
            -
             | 
| 1091 | 
            -
             | 
| 1092 | 
            -
             | 
| 1093 | 
            -
             | 
| 1094 | 
            -
             | 
| 1095 | 
            -
             | 
| 1096 | 
            -
             | 
| 1097 | 
            -
             | 
| 1098 | 
            -
             | 
| 1099 | 
            -
             | 
| 1100 | 
            -
             | 
| 1101 | 
            -
                const {
         | 
| 1102 | 
            -
             | 
| 1103 | 
            -
             | 
| 1104 | 
            -
                 | 
| 1105 | 
            -
                 | 
| 1106 | 
            -
             | 
| 1107 | 
            -
             | 
| 1108 | 
            -
             | 
| 1109 | 
            -
             | 
| 1110 | 
            -
             | 
| 1111 | 
            -
             | 
| 1112 | 
            -
             | 
| 1113 | 
            -
             | 
| 1114 | 
            -
                     | 
| 1115 | 
            -
             | 
| 1116 | 
            -
             | 
| 1117 | 
            -
             | 
| 1118 | 
            -
             | 
| 1119 | 
            -
             | 
| 1120 | 
            -
             | 
| 1121 | 
            -
             | 
| 1122 | 
            -
             | 
| 1123 | 
            -
             | 
| 1124 | 
            -
             | 
| 1125 | 
            -
             | 
| 1126 | 
            -
             | 
| 1127 | 
            -
             | 
| 1128 | 
            -
             | 
| 1129 | 
            -
             | 
| 1130 | 
            -
             | 
| 1131 | 
            -
             | 
| 1132 | 
            -
             | 
| 1133 | 
            -
             | 
| 1134 | 
            -
             | 
| 1135 | 
            -
             | 
| 1136 | 
            -
             | 
| 1137 | 
            -
             | 
| 1138 | 
            -
             | 
| 1139 | 
            -
             | 
| 1140 | 
            -
             | 
| 1141 | 
            -
             | 
| 1142 | 
            -
             | 
| 1143 | 
            -
             | 
| 1144 | 
            -
                 | 
| 1145 | 
            -
                isValidating,
         | 
| 1146 | 
            -
                getData,
         | 
| 1147 | 
            -
                setData,
         | 
| 1148 | 
            -
                unsetData,
         | 
| 1149 | 
            -
                replaceData
         | 
| 1150 | 
            -
              };
         | 
| 814 | 
            +
            /**  This hook allows you to manage and retrieve information about Forms.
         | 
| 815 | 
            +
             *
         | 
| 816 | 
            +
             * It exposes details regarding the form's state and a set of methods for reading and writing within it:
         | 
| 817 | 
            +
             *
         | 
| 818 | 
            +
             * - getData
         | 
| 819 | 
            +
             *
         | 
| 820 | 
            +
             * - setData
         | 
| 821 | 
            +
             *
         | 
| 822 | 
            +
             * - unSetData
         | 
| 823 | 
            +
             *
         | 
| 824 | 
            +
             * - replaceData
         | 
| 825 | 
            +
             *
         | 
| 826 | 
            +
             * @param {string} flowName - first optional parameter
         | 
| 827 | 
            +
             *
         | 
| 828 | 
            +
             * @param {string} name - optional parameter, if flowName exist, name is not used
         | 
| 829 | 
            +
             *
         | 
| 830 | 
            +
             */
         | 
| 831 | 
            +
            const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
         | 
| 832 | 
            +
                const { flowName: flowNameDefault } = React.useContext(context);
         | 
| 833 | 
            +
                const dispatch = useDispatch();
         | 
| 834 | 
            +
                const store = useStore();
         | 
| 835 | 
            +
                const flowName = customFlowName || name || flowNameDefault || '';
         | 
| 836 | 
            +
                const currentNode = useSelector(makeSelectCurrentNodeId(flowName));
         | 
| 837 | 
            +
                const { errors, isValid, touched, isValidating } = useSelector(makeSelectNodeErrors(flowName, currentNode));
         | 
| 838 | 
            +
                const getData = React.useCallback((path) => {
         | 
| 839 | 
            +
                    const { flowNameFromPath = flowName, path: newpath } = flowerCore.CoreUtils.getPath(path);
         | 
| 840 | 
            +
                    return _get(store.getState(), [
         | 
| 841 | 
            +
                        'flower',
         | 
| 842 | 
            +
                        flowNameFromPath,
         | 
| 843 | 
            +
                        'data',
         | 
| 844 | 
            +
                        ...newpath
         | 
| 845 | 
            +
                    ]);
         | 
| 846 | 
            +
                }, [store, flowName]);
         | 
| 847 | 
            +
                const setData = React.useCallback((val, path) => {
         | 
| 848 | 
            +
                    if (path) {
         | 
| 849 | 
            +
                        const { flowNameFromPath = flowName, path: newpath } = flowerCore.CoreUtils.getPath(path);
         | 
| 850 | 
            +
                        dispatch(actions.addDataByPath({
         | 
| 851 | 
            +
                            flowName: flowNameFromPath,
         | 
| 852 | 
            +
                            id: Array.isArray(newpath) ? newpath : [newpath],
         | 
| 853 | 
            +
                            value: val
         | 
| 854 | 
            +
                        }));
         | 
| 855 | 
            +
                        return;
         | 
| 856 | 
            +
                    }
         | 
| 857 | 
            +
                    dispatch(actions.addData({ flowName, value: val }));
         | 
| 858 | 
            +
                }, [flowName, dispatch]);
         | 
| 859 | 
            +
                const unsetData = React.useCallback((path) => {
         | 
| 860 | 
            +
                    const { flowNameFromPath = flowName, path: newpath } = flowerCore.CoreUtils.getPath(path);
         | 
| 861 | 
            +
                    dispatch(actions.unsetData({ flowName: flowNameFromPath, id: newpath }));
         | 
| 862 | 
            +
                }, [flowName, dispatch]);
         | 
| 863 | 
            +
                const replaceData = React.useCallback((val) => {
         | 
| 864 | 
            +
                    dispatch(actions.replaceData({ flowName, value: val }));
         | 
| 865 | 
            +
                }, [flowName, dispatch]);
         | 
| 866 | 
            +
                return {
         | 
| 867 | 
            +
                    touched,
         | 
| 868 | 
            +
                    errors,
         | 
| 869 | 
            +
                    isValid,
         | 
| 870 | 
            +
                    isValidating,
         | 
| 871 | 
            +
                    getData,
         | 
| 872 | 
            +
                    setData,
         | 
| 873 | 
            +
                    unsetData,
         | 
| 874 | 
            +
                    replaceData
         | 
| 875 | 
            +
                };
         | 
| 1151 876 | 
             
            };
         | 
| 1152 877 |  | 
| 1153 878 | 
             
            exports.Flower = component$c;
         |