@flowerforce/flower-react 3.1.2-beta.3 → 3.1.2-beta.5

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 CHANGED
@@ -834,7 +834,7 @@ Devtool({
834
834
 
835
835
  ```jsx
836
836
  Devtool({
837
- remote: 'passKey',
837
+ sessionId: 'RANDOM SESSION ID',
838
838
  sourceMap: require('./.flower.sourcemap.json')
839
839
  })
840
840
  ```
package/dist/index.cjs.js CHANGED
@@ -8,6 +8,7 @@ var toolkit = require('@reduxjs/toolkit');
8
8
  var reselect = require('reselect');
9
9
  var reactRedux = require('react-redux');
10
10
  var debounce = require('lodash/debounce');
11
+ var isEqual = require('lodash/isEqual');
11
12
 
12
13
  const _context = React.createContext({});
13
14
  const context = _context;
@@ -45,9 +46,14 @@ const getDataByFlow = (name) => reselect.createSelector(selectFlower(name), flow
45
46
  // selettore per recuperare i dati di un flow specifico e id specifico
46
47
  const getDataFromState = (name, id) => reselect.createSelector(getDataByFlow(name), flowerCore.Selectors.getDataFromState(id));
47
48
  const makeSelectNodeErrors = (name, currentNodeId) => reselect.createSelector(selectFlowerFormNode(name, currentNodeId), flowerCore.Selectors.makeSelectNodeErrors);
49
+ const makeSelectNodeFieldTouched = (name, currentNodeId, fieldId) => reselect.createSelector(selectFlowerFormNode(name, currentNodeId), flowerCore.Selectors.makeSelectNodeFormFieldTouched(fieldId));
50
+ const makeSelectNodeFieldDirty = (name, currentNodeId, fieldId) => reselect.createSelector(selectFlowerFormNode(name, currentNodeId), flowerCore.Selectors.makeSelectNodeFormFieldDirty(fieldId));
48
51
  const makeSelectNodeFormTouched = (name, currentNodeId) => reselect.createSelector(selectFlowerFormNode(name, currentNodeId), flowerCore.Selectors.makeSelectNodeFormTouched);
49
52
  const getAllData = reselect.createSelector(selectGlobal, mapData);
50
- const makeSelectFieldError = (name, id, validate) => reselect.createSelector(getAllData, flowerCore.Selectors.makeSelectFieldError(name, id, validate));
53
+ const selectFlowerFormCurrentNode = (name) => reselect.createSelector(selectFlower(name), makeSelectCurrentNodeId(name), (data, current) => {
54
+ return _get(data, ['form', current]);
55
+ });
56
+ const makeSelectFieldError = (name, id, validate) => reselect.createSelector(getAllData, selectFlowerFormCurrentNode(name), flowerCore.Selectors.makeSelectFieldError(name, id, validate));
51
57
  const selectorRulesDisabled = (id, rules, keys, flowName, value, currentNode) => reselect.createSelector(getAllData, makeSelectNodeErrors(flowName, currentNode), flowerCore.Selectors.selectorRulesDisabled(id, rules, keys, flowName, value));
52
58
 
53
59
  //TODO check reduxContext type due to remove all any types
@@ -251,11 +257,14 @@ const FlowerClient = ({ children, name, destroyOnUnmount = true, startId = null,
251
257
  initialData,
252
258
  currentNode: current
253
259
  }), [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;
260
+ const prevContextValues = React.useMemo(() => ({
261
+ flowName,
262
+ initialData,
263
+ currentNode: prevFlowerNodeId
264
+ }), [flowName, initialData, prevFlowerNodeId]);
265
+ return isInitialized ? (React.createElement(React.Fragment, null,
266
+ prevFlowerNodeId !== current && typeof prevFlowerNodeId === 'string' && (React.createElement(Provider, { value: prevContextValues }, nodeById[prevFlowerNodeId])),
267
+ React.createElement(Provider, { value: contextValues }, !isDisabled && nodeById[current]))) : null;
259
268
  };
260
269
  const component$c = React.memo(FlowerClient);
261
270
 
@@ -399,27 +408,55 @@ function isIntrinsicElement$1(x) {
399
408
  //TODO make types for wrapper function props
400
409
  function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDebounce = 0, asyncValidate, asyncInitialError, asyncWaitingError, destroyValue, onBlur = (val) => null, hidden, onUpdate, defaultValue, ...props }) {
401
410
  const dispatch = useDispatch();
402
- const [touched, setTouched] = React.useState();
403
- const [customErrors, setCustomErrors] = React.useState(asyncValidate && [asyncInitialError]);
411
+ const [customAsyncErrors, setCustomAsyncErrors] = React.useState(asyncValidate && [asyncInitialError]);
404
412
  const [isValidating, setIsValidating] = React.useState(undefined);
405
413
  const { flowNameFromPath = flowName, path } = React.useMemo(() => flowerCore.CoreUtils.getPath(id), [id]);
406
414
  const value = useSelector(getDataFromState(flowNameFromPath, path));
407
415
  const errors = useSelector(makeSelectFieldError(flowName, id, validate), flowerCore.CoreUtils.allEqual);
416
+ const dirty = useSelector(makeSelectNodeFieldDirty(flowName, currentNode, id));
417
+ const touched = useSelector(makeSelectNodeFieldTouched(flowName, currentNode, id));
408
418
  const refValue = React.useRef();
409
- const one = React.useRef();
419
+ const touchedForm = useSelector(makeSelectNodeFormTouched(flowName, currentNode));
420
+ const allErrors = React.useMemo(() => [...errors, ...(customAsyncErrors || []).filter(Boolean)], [errors, customAsyncErrors]);
421
+ const setTouched = React.useCallback((touched) => {
422
+ dispatch({
423
+ type: 'flower/formFieldTouch',
424
+ payload: {
425
+ name: flowName,
426
+ id,
427
+ currentNode,
428
+ touched
429
+ }
430
+ });
431
+ }, [dispatch, flowName, currentNode, id]);
410
432
  const validateFn = React.useCallback(async (value) => {
411
433
  if (asyncWaitingError) {
412
- setCustomErrors([asyncWaitingError]);
434
+ setCustomAsyncErrors([asyncWaitingError]);
413
435
  }
414
436
  setIsValidating(true);
415
437
  const state = flowerCore.FlowerStateUtils.getAllData(store);
416
438
  const res = await asyncValidate(value, state, errors);
417
439
  setIsValidating(false);
418
- setCustomErrors(res);
440
+ setCustomAsyncErrors(res);
419
441
  }, [asyncWaitingError, errors]);
420
442
  const debouncedValidation = React.useCallback(debounce(validateFn, asyncDebounce), [
421
443
  validateFn
422
444
  ]);
445
+ const onChange = React.useCallback((val) => {
446
+ dispatch({
447
+ type: `flower/addDataByPath`,
448
+ payload: {
449
+ flowName: flowNameFromPath,
450
+ id,
451
+ value: val,
452
+ dirty: defaultValue ? !isEqual(val, defaultValue) : true
453
+ }
454
+ });
455
+ }, [flowNameFromPath, id, onBlur, dispatch]);
456
+ const onBlurInternal = React.useCallback((e) => {
457
+ setTouched(true);
458
+ onBlur && onBlur(e);
459
+ }, [onBlur, setTouched]);
423
460
  React.useEffect(() => {
424
461
  if (asyncValidate) {
425
462
  if (refValue.current === value)
@@ -427,36 +464,20 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
427
464
  refValue.current = value;
428
465
  const hasValue = !flowerCore.MatchRules.utils.isEmpty(value);
429
466
  if (!hasValue) {
430
- setCustomErrors([asyncInitialError]);
467
+ setCustomAsyncErrors([asyncInitialError]);
431
468
  setIsValidating(false);
432
469
  return;
433
470
  }
434
471
  setTouched(true);
435
472
  debouncedValidation(value);
436
473
  }
437
- }, [asyncValidate, asyncInitialError, value, debouncedValidation]);
438
- const touchedForm = useSelector(makeSelectNodeFormTouched(flowName, currentNode));
439
- const allErrors = React.useMemo(() => [...errors, ...(customErrors || []).filter(Boolean)], [errors, customErrors]);
474
+ }, [asyncValidate, asyncInitialError, value, debouncedValidation, setTouched]);
440
475
  React.useEffect(() => {
441
476
  if (onUpdate) {
442
477
  onUpdate(value);
443
478
  }
444
479
  }, [value, onUpdate]);
445
- const onChange = React.useCallback((val) => {
446
- dispatch({
447
- type: `flower/addDataByPath`,
448
- payload: {
449
- flowName: flowNameFromPath,
450
- id: path,
451
- value: val
452
- }
453
- });
454
- }, [flowNameFromPath, path, onBlur, dispatch]);
455
- const onBlurInternal = React.useCallback((e) => {
456
- setTouched(true);
457
- onBlur && onBlur(e);
458
- }, [onBlur]);
459
- React.useLayoutEffect(() => {
480
+ React.useEffect(() => {
460
481
  dispatch({
461
482
  type: 'flower/formAddErrors',
462
483
  payload: {
@@ -466,7 +487,7 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
466
487
  errors: allErrors
467
488
  }
468
489
  });
469
- }, [id, flowName, allErrors, currentNode]);
490
+ }, [id, flowName, allErrors, currentNode, touched]);
470
491
  React.useEffect(() => {
471
492
  dispatch({
472
493
  type: 'flower/setFormIsValidating',
@@ -477,7 +498,7 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
477
498
  }
478
499
  });
479
500
  }, [flowName, currentNode, isValidating]);
480
- React.useLayoutEffect(() => {
501
+ React.useEffect(() => {
481
502
  // destroy
482
503
  return () => {
483
504
  if (destroyValue) {
@@ -495,35 +516,37 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
495
516
  }
496
517
  });
497
518
  };
498
- }, [destroyValue]);
519
+ }, [destroyValue, id, flowNameFromPath, path, currentNode]);
499
520
  React.useEffect(() => {
500
- if (defaultValue && !one.current) {
501
- one.current = true;
521
+ if (defaultValue && !dirty && !isEqual(value, defaultValue)) {
502
522
  onChange(defaultValue);
503
523
  }
504
- }, [defaultValue, onChange]);
505
- const isTouched = touched || touchedForm;
524
+ }, [defaultValue, value, dirty, onChange]);
506
525
  const newProps = React.useMemo(() => ({
507
526
  ...props,
508
527
  id,
509
528
  value,
510
- errors: isTouched && allErrors,
511
- hasError: isTouched && !!allErrors.length,
529
+ errors: allErrors,
530
+ hasError: !!allErrors.length,
512
531
  onChange,
513
532
  onBlur: onBlurInternal,
514
- isTouched,
533
+ touched,
534
+ dirty,
515
535
  hidden,
516
- isValidating
536
+ isValidating,
537
+ touchedForm
517
538
  }), [
518
539
  props,
519
540
  id,
520
541
  value,
521
542
  allErrors,
522
- isTouched,
543
+ touched,
544
+ dirty,
523
545
  onChange,
524
546
  onBlurInternal,
525
547
  hidden,
526
- isValidating
548
+ isValidating,
549
+ touchedForm
527
550
  ]);
528
551
  if (typeof Component === 'function') {
529
552
  return Component(newProps);
@@ -823,9 +846,11 @@ const component = React.memo(FlowerComponent);
823
846
  *
824
847
  * - replaceData
825
848
  *
849
+ * - unTouched
850
+ *
826
851
  * @param {string} flowName - first optional parameter
827
852
  *
828
- * @param {string} name - optional parameter, if flowName exist, name is not used
853
+ * @param {string} name - alias optional parameter, if flowName exist, name is not used
829
854
  *
830
855
  */
831
856
  const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
@@ -834,7 +859,7 @@ const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
834
859
  const store = useStore();
835
860
  const flowName = customFlowName || name || flowNameDefault || '';
836
861
  const currentNode = useSelector(makeSelectCurrentNodeId(flowName));
837
- const { errors, isValid, touched, isValidating } = useSelector(makeSelectNodeErrors(flowName, currentNode));
862
+ const { errors, customErrors, isValid, touched, isValidating } = useSelector(makeSelectNodeErrors(flowName, currentNode));
838
863
  const getData = React.useCallback((path) => {
839
864
  const { flowNameFromPath = flowName, path: newpath } = flowerCore.CoreUtils.getPath(path);
840
865
  return _get(store.getState(), [
@@ -844,13 +869,14 @@ const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
844
869
  ...newpath
845
870
  ]);
846
871
  }, [store, flowName]);
847
- const setData = React.useCallback((val, path) => {
848
- if (path) {
849
- const { flowNameFromPath = flowName, path: newpath } = flowerCore.CoreUtils.getPath(path);
872
+ const setData = React.useCallback((val, id) => {
873
+ if (id) {
874
+ const { flowNameFromPath = flowName } = flowerCore.CoreUtils.getPath(id);
850
875
  dispatch(actions.addDataByPath({
851
876
  flowName: flowNameFromPath,
852
- id: Array.isArray(newpath) ? newpath : [newpath],
853
- value: val
877
+ id,
878
+ value: val,
879
+ dirty: true
854
880
  }));
855
881
  return;
856
882
  }
@@ -863,15 +889,32 @@ const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
863
889
  const replaceData = React.useCallback((val) => {
864
890
  dispatch(actions.replaceData({ flowName, value: val }));
865
891
  }, [flowName, dispatch]);
892
+ const reset = React.useCallback((nodeId) => {
893
+ dispatch(actions.resetForm({ flowName, id: nodeId || currentNode }));
894
+ }, [flowName, currentNode, dispatch]);
895
+ const setCustomErrors = React.useCallback((field, errors, nodeId) => {
896
+ dispatch({
897
+ type: 'flower/formAddCustomErrors',
898
+ payload: {
899
+ name: flowName,
900
+ id: field,
901
+ currentNode: nodeId || currentNode,
902
+ errors
903
+ }
904
+ });
905
+ }, [flowName, currentNode, dispatch]);
866
906
  return {
867
907
  touched,
868
908
  errors,
909
+ customErrors,
869
910
  isValid,
870
911
  isValidating,
871
912
  getData,
872
913
  setData,
873
914
  unsetData,
874
- replaceData
915
+ replaceData,
916
+ reset,
917
+ setCustomErrors
875
918
  };
876
919
  };
877
920
 
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import React, { createContext, PureComponent, memo, useRef, useState, useMemo, Children, useEffect, useContext, useCallback, useLayoutEffect } from 'react';
1
+ import React, { createContext, PureComponent, memo, useRef, useState, useMemo, Children, useEffect, useContext, useCallback } from 'react';
2
2
  import _keyBy from 'lodash/keyBy';
3
3
  import { CoreUtils, FlowerCoreReducers, FlowerStateUtils, Selectors, devtoolState, Emitter, MatchRules } from '@flowerforce/flower-core';
4
4
  import _get from 'lodash/get';
@@ -6,6 +6,7 @@ import { createSlice, configureStore } from '@reduxjs/toolkit';
6
6
  import { createSelector } from 'reselect';
7
7
  import { createDispatchHook, createSelectorHook, createStoreHook, Provider as Provider$1 } from 'react-redux';
8
8
  import debounce from 'lodash/debounce';
9
+ import isEqual from 'lodash/isEqual';
9
10
 
10
11
  const _context = createContext({});
11
12
  const context = _context;
@@ -43,9 +44,14 @@ const getDataByFlow = (name) => createSelector(selectFlower(name), Selectors.get
43
44
  // selettore per recuperare i dati di un flow specifico e id specifico
44
45
  const getDataFromState = (name, id) => createSelector(getDataByFlow(name), Selectors.getDataFromState(id));
45
46
  const makeSelectNodeErrors = (name, currentNodeId) => createSelector(selectFlowerFormNode(name, currentNodeId), Selectors.makeSelectNodeErrors);
47
+ const makeSelectNodeFieldTouched = (name, currentNodeId, fieldId) => createSelector(selectFlowerFormNode(name, currentNodeId), Selectors.makeSelectNodeFormFieldTouched(fieldId));
48
+ const makeSelectNodeFieldDirty = (name, currentNodeId, fieldId) => createSelector(selectFlowerFormNode(name, currentNodeId), Selectors.makeSelectNodeFormFieldDirty(fieldId));
46
49
  const makeSelectNodeFormTouched = (name, currentNodeId) => createSelector(selectFlowerFormNode(name, currentNodeId), Selectors.makeSelectNodeFormTouched);
47
50
  const getAllData = createSelector(selectGlobal, mapData);
48
- const makeSelectFieldError = (name, id, validate) => createSelector(getAllData, Selectors.makeSelectFieldError(name, id, validate));
51
+ const selectFlowerFormCurrentNode = (name) => createSelector(selectFlower(name), makeSelectCurrentNodeId(name), (data, current) => {
52
+ return _get(data, ['form', current]);
53
+ });
54
+ const makeSelectFieldError = (name, id, validate) => createSelector(getAllData, selectFlowerFormCurrentNode(name), Selectors.makeSelectFieldError(name, id, validate));
49
55
  const selectorRulesDisabled = (id, rules, keys, flowName, value, currentNode) => createSelector(getAllData, makeSelectNodeErrors(flowName, currentNode), Selectors.selectorRulesDisabled(id, rules, keys, flowName, value));
50
56
 
51
57
  //TODO check reduxContext type due to remove all any types
@@ -249,11 +255,14 @@ const FlowerClient = ({ children, name, destroyOnUnmount = true, startId = null,
249
255
  initialData,
250
256
  currentNode: current
251
257
  }), [flowName, initialData, current]);
252
- return isInitialized ? (React.createElement(Provider, { value: contextValues },
253
- prevFlowerNodeId !== current &&
254
- typeof prevFlowerNodeId === 'string' &&
255
- nodeById[prevFlowerNodeId],
256
- !isDisabled && nodeById[current])) : null;
258
+ const prevContextValues = useMemo(() => ({
259
+ flowName,
260
+ initialData,
261
+ currentNode: prevFlowerNodeId
262
+ }), [flowName, initialData, prevFlowerNodeId]);
263
+ return isInitialized ? (React.createElement(React.Fragment, null,
264
+ prevFlowerNodeId !== current && typeof prevFlowerNodeId === 'string' && (React.createElement(Provider, { value: prevContextValues }, nodeById[prevFlowerNodeId])),
265
+ React.createElement(Provider, { value: contextValues }, !isDisabled && nodeById[current]))) : null;
257
266
  };
258
267
  const component$c = memo(FlowerClient);
259
268
 
@@ -397,27 +406,55 @@ function isIntrinsicElement$1(x) {
397
406
  //TODO make types for wrapper function props
398
407
  function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDebounce = 0, asyncValidate, asyncInitialError, asyncWaitingError, destroyValue, onBlur = (val) => null, hidden, onUpdate, defaultValue, ...props }) {
399
408
  const dispatch = useDispatch();
400
- const [touched, setTouched] = useState();
401
- const [customErrors, setCustomErrors] = useState(asyncValidate && [asyncInitialError]);
409
+ const [customAsyncErrors, setCustomAsyncErrors] = useState(asyncValidate && [asyncInitialError]);
402
410
  const [isValidating, setIsValidating] = useState(undefined);
403
411
  const { flowNameFromPath = flowName, path } = useMemo(() => CoreUtils.getPath(id), [id]);
404
412
  const value = useSelector(getDataFromState(flowNameFromPath, path));
405
413
  const errors = useSelector(makeSelectFieldError(flowName, id, validate), CoreUtils.allEqual);
414
+ const dirty = useSelector(makeSelectNodeFieldDirty(flowName, currentNode, id));
415
+ const touched = useSelector(makeSelectNodeFieldTouched(flowName, currentNode, id));
406
416
  const refValue = useRef();
407
- const one = useRef();
417
+ const touchedForm = useSelector(makeSelectNodeFormTouched(flowName, currentNode));
418
+ const allErrors = useMemo(() => [...errors, ...(customAsyncErrors || []).filter(Boolean)], [errors, customAsyncErrors]);
419
+ const setTouched = useCallback((touched) => {
420
+ dispatch({
421
+ type: 'flower/formFieldTouch',
422
+ payload: {
423
+ name: flowName,
424
+ id,
425
+ currentNode,
426
+ touched
427
+ }
428
+ });
429
+ }, [dispatch, flowName, currentNode, id]);
408
430
  const validateFn = useCallback(async (value) => {
409
431
  if (asyncWaitingError) {
410
- setCustomErrors([asyncWaitingError]);
432
+ setCustomAsyncErrors([asyncWaitingError]);
411
433
  }
412
434
  setIsValidating(true);
413
435
  const state = FlowerStateUtils.getAllData(store);
414
436
  const res = await asyncValidate(value, state, errors);
415
437
  setIsValidating(false);
416
- setCustomErrors(res);
438
+ setCustomAsyncErrors(res);
417
439
  }, [asyncWaitingError, errors]);
418
440
  const debouncedValidation = useCallback(debounce(validateFn, asyncDebounce), [
419
441
  validateFn
420
442
  ]);
443
+ const onChange = useCallback((val) => {
444
+ dispatch({
445
+ type: `flower/addDataByPath`,
446
+ payload: {
447
+ flowName: flowNameFromPath,
448
+ id,
449
+ value: val,
450
+ dirty: defaultValue ? !isEqual(val, defaultValue) : true
451
+ }
452
+ });
453
+ }, [flowNameFromPath, id, onBlur, dispatch]);
454
+ const onBlurInternal = useCallback((e) => {
455
+ setTouched(true);
456
+ onBlur && onBlur(e);
457
+ }, [onBlur, setTouched]);
421
458
  useEffect(() => {
422
459
  if (asyncValidate) {
423
460
  if (refValue.current === value)
@@ -425,36 +462,20 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
425
462
  refValue.current = value;
426
463
  const hasValue = !MatchRules.utils.isEmpty(value);
427
464
  if (!hasValue) {
428
- setCustomErrors([asyncInitialError]);
465
+ setCustomAsyncErrors([asyncInitialError]);
429
466
  setIsValidating(false);
430
467
  return;
431
468
  }
432
469
  setTouched(true);
433
470
  debouncedValidation(value);
434
471
  }
435
- }, [asyncValidate, asyncInitialError, value, debouncedValidation]);
436
- const touchedForm = useSelector(makeSelectNodeFormTouched(flowName, currentNode));
437
- const allErrors = useMemo(() => [...errors, ...(customErrors || []).filter(Boolean)], [errors, customErrors]);
472
+ }, [asyncValidate, asyncInitialError, value, debouncedValidation, setTouched]);
438
473
  useEffect(() => {
439
474
  if (onUpdate) {
440
475
  onUpdate(value);
441
476
  }
442
477
  }, [value, onUpdate]);
443
- const onChange = useCallback((val) => {
444
- dispatch({
445
- type: `flower/addDataByPath`,
446
- payload: {
447
- flowName: flowNameFromPath,
448
- id: path,
449
- value: val
450
- }
451
- });
452
- }, [flowNameFromPath, path, onBlur, dispatch]);
453
- const onBlurInternal = useCallback((e) => {
454
- setTouched(true);
455
- onBlur && onBlur(e);
456
- }, [onBlur]);
457
- useLayoutEffect(() => {
478
+ useEffect(() => {
458
479
  dispatch({
459
480
  type: 'flower/formAddErrors',
460
481
  payload: {
@@ -464,7 +485,7 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
464
485
  errors: allErrors
465
486
  }
466
487
  });
467
- }, [id, flowName, allErrors, currentNode]);
488
+ }, [id, flowName, allErrors, currentNode, touched]);
468
489
  useEffect(() => {
469
490
  dispatch({
470
491
  type: 'flower/setFormIsValidating',
@@ -475,7 +496,7 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
475
496
  }
476
497
  });
477
498
  }, [flowName, currentNode, isValidating]);
478
- useLayoutEffect(() => {
499
+ useEffect(() => {
479
500
  // destroy
480
501
  return () => {
481
502
  if (destroyValue) {
@@ -493,35 +514,37 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
493
514
  }
494
515
  });
495
516
  };
496
- }, [destroyValue]);
517
+ }, [destroyValue, id, flowNameFromPath, path, currentNode]);
497
518
  useEffect(() => {
498
- if (defaultValue && !one.current) {
499
- one.current = true;
519
+ if (defaultValue && !dirty && !isEqual(value, defaultValue)) {
500
520
  onChange(defaultValue);
501
521
  }
502
- }, [defaultValue, onChange]);
503
- const isTouched = touched || touchedForm;
522
+ }, [defaultValue, value, dirty, onChange]);
504
523
  const newProps = useMemo(() => ({
505
524
  ...props,
506
525
  id,
507
526
  value,
508
- errors: isTouched && allErrors,
509
- hasError: isTouched && !!allErrors.length,
527
+ errors: allErrors,
528
+ hasError: !!allErrors.length,
510
529
  onChange,
511
530
  onBlur: onBlurInternal,
512
- isTouched,
531
+ touched,
532
+ dirty,
513
533
  hidden,
514
- isValidating
534
+ isValidating,
535
+ touchedForm
515
536
  }), [
516
537
  props,
517
538
  id,
518
539
  value,
519
540
  allErrors,
520
- isTouched,
541
+ touched,
542
+ dirty,
521
543
  onChange,
522
544
  onBlurInternal,
523
545
  hidden,
524
- isValidating
546
+ isValidating,
547
+ touchedForm
525
548
  ]);
526
549
  if (typeof Component === 'function') {
527
550
  return Component(newProps);
@@ -821,9 +844,11 @@ const component = memo(FlowerComponent);
821
844
  *
822
845
  * - replaceData
823
846
  *
847
+ * - unTouched
848
+ *
824
849
  * @param {string} flowName - first optional parameter
825
850
  *
826
- * @param {string} name - optional parameter, if flowName exist, name is not used
851
+ * @param {string} name - alias optional parameter, if flowName exist, name is not used
827
852
  *
828
853
  */
829
854
  const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
@@ -832,7 +857,7 @@ const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
832
857
  const store = useStore();
833
858
  const flowName = customFlowName || name || flowNameDefault || '';
834
859
  const currentNode = useSelector(makeSelectCurrentNodeId(flowName));
835
- const { errors, isValid, touched, isValidating } = useSelector(makeSelectNodeErrors(flowName, currentNode));
860
+ const { errors, customErrors, isValid, touched, isValidating } = useSelector(makeSelectNodeErrors(flowName, currentNode));
836
861
  const getData = useCallback((path) => {
837
862
  const { flowNameFromPath = flowName, path: newpath } = CoreUtils.getPath(path);
838
863
  return _get(store.getState(), [
@@ -842,13 +867,14 @@ const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
842
867
  ...newpath
843
868
  ]);
844
869
  }, [store, flowName]);
845
- const setData = useCallback((val, path) => {
846
- if (path) {
847
- const { flowNameFromPath = flowName, path: newpath } = CoreUtils.getPath(path);
870
+ const setData = useCallback((val, id) => {
871
+ if (id) {
872
+ const { flowNameFromPath = flowName } = CoreUtils.getPath(id);
848
873
  dispatch(actions.addDataByPath({
849
874
  flowName: flowNameFromPath,
850
- id: Array.isArray(newpath) ? newpath : [newpath],
851
- value: val
875
+ id,
876
+ value: val,
877
+ dirty: true
852
878
  }));
853
879
  return;
854
880
  }
@@ -861,15 +887,32 @@ const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
861
887
  const replaceData = useCallback((val) => {
862
888
  dispatch(actions.replaceData({ flowName, value: val }));
863
889
  }, [flowName, dispatch]);
890
+ const reset = useCallback((nodeId) => {
891
+ dispatch(actions.resetForm({ flowName, id: nodeId || currentNode }));
892
+ }, [flowName, currentNode, dispatch]);
893
+ const setCustomErrors = useCallback((field, errors, nodeId) => {
894
+ dispatch({
895
+ type: 'flower/formAddCustomErrors',
896
+ payload: {
897
+ name: flowName,
898
+ id: field,
899
+ currentNode: nodeId || currentNode,
900
+ errors
901
+ }
902
+ });
903
+ }, [flowName, currentNode, dispatch]);
864
904
  return {
865
905
  touched,
866
906
  errors,
907
+ customErrors,
867
908
  isValid,
868
909
  isValidating,
869
910
  getData,
870
911
  setData,
871
912
  unsetData,
872
- replaceData
913
+ replaceData,
914
+ reset,
915
+ setCustomErrors
873
916
  };
874
917
  };
875
918
 
@@ -32,7 +32,11 @@ export type FlowerFieldProps<T extends Record<string, any> = Record<string, any>
32
32
  /** The function executed to test all the validation rules*/
33
33
  onBlur: () => void;
34
34
  /** This parameter will notify you whether the form field has been touched */
35
- isTouched: boolean;
35
+ touchedForm: boolean;
36
+ /** This parameter will notify you whether the form field has been touched */
37
+ touched: boolean;
38
+ /** This parameter will notify you whether the form field has been touched */
39
+ dirty: boolean;
36
40
  /** true when some of the display rules are not satisfied, and you have passed true to the "alwaysDisplay" FlowerField's prop*/
37
41
  hidden: boolean;
38
42
  /** true when you have an async validation in progress */
@@ -7,6 +7,8 @@ export type UseFlowerForm = (options?: UseFlowerProps) => {
7
7
  touched: boolean;
8
8
  /** An object containing all the form errors */
9
9
  errors: Record<string, any>;
10
+ /** An object containing all the form custom errors */
11
+ customErrors: Record<string, any>;
10
12
  /** This value is set to true when all the validation rules are satisfied and the form is valid*/
11
13
  isValid: boolean;
12
14
  /** This value is set to true during asynchronous validation.*/
@@ -25,6 +27,10 @@ export type UseFlowerForm = (options?: UseFlowerProps) => {
25
27
  path: string) => void;
26
28
  /** Use this function to replace a value in the flow's data. */
27
29
  replaceData: (value: any) => void;
30
+ /**Use this function to reset errors form and touched state */
31
+ reset: (nodeId?: string) => void;
32
+ /**this function to set a custom error on a specific field */
33
+ setCustomErrors: (field: string, errors: string[], nodeId?: string) => void;
28
34
  };
29
35
  type useFlowerActions = {
30
36
  /** Use this function to move to the next node inside the flow*/
@@ -11,9 +11,11 @@ import { UseFlowerForm } from './types/FlowerHooks';
11
11
  *
12
12
  * - replaceData
13
13
  *
14
+ * - unTouched
15
+ *
14
16
  * @param {string} flowName - first optional parameter
15
17
  *
16
- * @param {string} name - optional parameter, if flowName exist, name is not used
18
+ * @param {string} name - alias optional parameter, if flowName exist, name is not used
17
19
  *
18
20
  */
19
21
  declare const useFlowerForm: UseFlowerForm;
@@ -305,22 +305,22 @@ declare const makeSelectPrevNodeRetain: (name: string) => ((state: {
305
305
  flower: {
306
306
  [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
307
307
  };
308
- }) => string | boolean | undefined) & {
308
+ }) => string | undefined) & {
309
309
  clearCache: () => void;
310
310
  resultsCount: () => number;
311
311
  resetResultsCount: () => void;
312
312
  } & {
313
313
  resultFunc: (resultFuncArgs_0: {
314
314
  [x: string]: import("@flowerforce/flower-core").INode;
315
- }, resultFuncArgs_1: string[], resultFuncArgs_2: string) => string | boolean | undefined;
315
+ }, resultFuncArgs_1: string[], resultFuncArgs_2: string) => string | undefined;
316
316
  memoizedResultFunc: ((resultFuncArgs_0: {
317
317
  [x: string]: import("@flowerforce/flower-core").INode;
318
- }, resultFuncArgs_1: string[], resultFuncArgs_2: string) => string | boolean | undefined) & {
318
+ }, resultFuncArgs_1: string[], resultFuncArgs_2: string) => string | undefined) & {
319
319
  clearCache: () => void;
320
320
  resultsCount: () => number;
321
321
  resetResultsCount: () => void;
322
322
  };
323
- lastResult: () => string | boolean | undefined;
323
+ lastResult: () => string | undefined;
324
324
  dependencies: [((state: {
325
325
  flower: {
326
326
  [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
@@ -930,6 +930,7 @@ declare const makeSelectNodeErrors: (name: string, currentNodeId: string) => ((s
930
930
  }) => {
931
931
  touched: boolean;
932
932
  errors: any;
933
+ customErrors: any;
933
934
  isValid: boolean;
934
935
  isValidating?: boolean | undefined;
935
936
  }) & {
@@ -940,12 +941,14 @@ declare const makeSelectNodeErrors: (name: string, currentNodeId: string) => ((s
940
941
  resultFunc: (resultFuncArgs_0: import("@flowerforce/flower-core").Form<Record<string, any>>) => {
941
942
  touched: boolean;
942
943
  errors: any;
944
+ customErrors: any;
943
945
  isValid: boolean;
944
946
  isValidating?: boolean | undefined;
945
947
  };
946
948
  memoizedResultFunc: ((resultFuncArgs_0: import("@flowerforce/flower-core").Form<Record<string, any>>) => {
947
949
  touched: boolean;
948
950
  errors: any;
951
+ customErrors: any;
949
952
  isValid: boolean;
950
953
  isValidating?: boolean | undefined;
951
954
  }) & {
@@ -956,6 +959,7 @@ declare const makeSelectNodeErrors: (name: string, currentNodeId: string) => ((s
956
959
  lastResult: () => {
957
960
  touched: boolean;
958
961
  errors: any;
962
+ customErrors: any;
959
963
  isValid: boolean;
960
964
  isValidating?: boolean | undefined;
961
965
  };
@@ -1026,6 +1030,172 @@ declare const makeSelectNodeErrors: (name: string, currentNodeId: string) => ((s
1026
1030
  argsMemoize: typeof import("reselect").weakMapMemoize;
1027
1031
  memoize: typeof import("reselect").weakMapMemoize;
1028
1032
  };
1033
+ declare const makeSelectNodeFieldTouched: (name: string, currentNodeId: string, fieldId: string) => ((state: {
1034
+ flower: {
1035
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1036
+ };
1037
+ }) => boolean | undefined) & {
1038
+ clearCache: () => void;
1039
+ resultsCount: () => number;
1040
+ resetResultsCount: () => void;
1041
+ } & {
1042
+ resultFunc: (resultFuncArgs_0: import("@flowerforce/flower-core").Form<Record<string, any>>) => boolean | undefined;
1043
+ memoizedResultFunc: ((resultFuncArgs_0: import("@flowerforce/flower-core").Form<Record<string, any>>) => boolean | undefined) & {
1044
+ clearCache: () => void;
1045
+ resultsCount: () => number;
1046
+ resetResultsCount: () => void;
1047
+ };
1048
+ lastResult: () => boolean | undefined;
1049
+ dependencies: [((state: {
1050
+ flower: {
1051
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1052
+ };
1053
+ }) => import("@flowerforce/flower-core").Form<Record<string, any>>) & {
1054
+ clearCache: () => void;
1055
+ resultsCount: () => number;
1056
+ resetResultsCount: () => void;
1057
+ } & {
1058
+ resultFunc: (resultFuncArgs_0: import("@flowerforce/flower-core").Flower<Record<string, any>>) => import("@flowerforce/flower-core").Form<Record<string, any>>;
1059
+ memoizedResultFunc: ((resultFuncArgs_0: import("@flowerforce/flower-core").Flower<Record<string, any>>) => import("@flowerforce/flower-core").Form<Record<string, any>>) & {
1060
+ clearCache: () => void;
1061
+ resultsCount: () => number;
1062
+ resetResultsCount: () => void;
1063
+ };
1064
+ lastResult: () => import("@flowerforce/flower-core").Form<Record<string, any>>;
1065
+ dependencies: [((state: {
1066
+ flower: {
1067
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1068
+ };
1069
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>) & {
1070
+ clearCache: () => void;
1071
+ resultsCount: () => number;
1072
+ resetResultsCount: () => void;
1073
+ } & {
1074
+ resultFunc: (resultFuncArgs_0: {
1075
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1076
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>;
1077
+ memoizedResultFunc: ((resultFuncArgs_0: {
1078
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1079
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>) & {
1080
+ clearCache: () => void;
1081
+ resultsCount: () => number;
1082
+ resetResultsCount: () => void;
1083
+ };
1084
+ lastResult: () => import("@flowerforce/flower-core").Flower<Record<string, any>>;
1085
+ dependencies: [<T extends Record<string, any>>(state: {
1086
+ flower: {
1087
+ [x: string]: import("@flowerforce/flower-core").Flower<T>;
1088
+ };
1089
+ }) => {
1090
+ [x: string]: import("@flowerforce/flower-core").Flower<T>;
1091
+ }];
1092
+ recomputations: () => number;
1093
+ resetRecomputations: () => void;
1094
+ dependencyRecomputations: () => number;
1095
+ resetDependencyRecomputations: () => void;
1096
+ } & {
1097
+ argsMemoize: typeof import("reselect").weakMapMemoize;
1098
+ memoize: typeof import("reselect").weakMapMemoize;
1099
+ }];
1100
+ recomputations: () => number;
1101
+ resetRecomputations: () => void;
1102
+ dependencyRecomputations: () => number;
1103
+ resetDependencyRecomputations: () => void;
1104
+ } & {
1105
+ argsMemoize: typeof import("reselect").weakMapMemoize;
1106
+ memoize: typeof import("reselect").weakMapMemoize;
1107
+ }];
1108
+ recomputations: () => number;
1109
+ resetRecomputations: () => void;
1110
+ dependencyRecomputations: () => number;
1111
+ resetDependencyRecomputations: () => void;
1112
+ } & {
1113
+ argsMemoize: typeof import("reselect").weakMapMemoize;
1114
+ memoize: typeof import("reselect").weakMapMemoize;
1115
+ };
1116
+ declare const makeSelectNodeFieldDirty: (name: string, currentNodeId: string, fieldId: string) => ((state: {
1117
+ flower: {
1118
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1119
+ };
1120
+ }) => boolean | undefined) & {
1121
+ clearCache: () => void;
1122
+ resultsCount: () => number;
1123
+ resetResultsCount: () => void;
1124
+ } & {
1125
+ resultFunc: (resultFuncArgs_0: import("@flowerforce/flower-core").Form<Record<string, any>>) => boolean | undefined;
1126
+ memoizedResultFunc: ((resultFuncArgs_0: import("@flowerforce/flower-core").Form<Record<string, any>>) => boolean | undefined) & {
1127
+ clearCache: () => void;
1128
+ resultsCount: () => number;
1129
+ resetResultsCount: () => void;
1130
+ };
1131
+ lastResult: () => boolean | undefined;
1132
+ dependencies: [((state: {
1133
+ flower: {
1134
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1135
+ };
1136
+ }) => import("@flowerforce/flower-core").Form<Record<string, any>>) & {
1137
+ clearCache: () => void;
1138
+ resultsCount: () => number;
1139
+ resetResultsCount: () => void;
1140
+ } & {
1141
+ resultFunc: (resultFuncArgs_0: import("@flowerforce/flower-core").Flower<Record<string, any>>) => import("@flowerforce/flower-core").Form<Record<string, any>>;
1142
+ memoizedResultFunc: ((resultFuncArgs_0: import("@flowerforce/flower-core").Flower<Record<string, any>>) => import("@flowerforce/flower-core").Form<Record<string, any>>) & {
1143
+ clearCache: () => void;
1144
+ resultsCount: () => number;
1145
+ resetResultsCount: () => void;
1146
+ };
1147
+ lastResult: () => import("@flowerforce/flower-core").Form<Record<string, any>>;
1148
+ dependencies: [((state: {
1149
+ flower: {
1150
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1151
+ };
1152
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>) & {
1153
+ clearCache: () => void;
1154
+ resultsCount: () => number;
1155
+ resetResultsCount: () => void;
1156
+ } & {
1157
+ resultFunc: (resultFuncArgs_0: {
1158
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1159
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>;
1160
+ memoizedResultFunc: ((resultFuncArgs_0: {
1161
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1162
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>) & {
1163
+ clearCache: () => void;
1164
+ resultsCount: () => number;
1165
+ resetResultsCount: () => void;
1166
+ };
1167
+ lastResult: () => import("@flowerforce/flower-core").Flower<Record<string, any>>;
1168
+ dependencies: [<T extends Record<string, any>>(state: {
1169
+ flower: {
1170
+ [x: string]: import("@flowerforce/flower-core").Flower<T>;
1171
+ };
1172
+ }) => {
1173
+ [x: string]: import("@flowerforce/flower-core").Flower<T>;
1174
+ }];
1175
+ recomputations: () => number;
1176
+ resetRecomputations: () => void;
1177
+ dependencyRecomputations: () => number;
1178
+ resetDependencyRecomputations: () => void;
1179
+ } & {
1180
+ argsMemoize: typeof import("reselect").weakMapMemoize;
1181
+ memoize: typeof import("reselect").weakMapMemoize;
1182
+ }];
1183
+ recomputations: () => number;
1184
+ resetRecomputations: () => void;
1185
+ dependencyRecomputations: () => number;
1186
+ resetDependencyRecomputations: () => void;
1187
+ } & {
1188
+ argsMemoize: typeof import("reselect").weakMapMemoize;
1189
+ memoize: typeof import("reselect").weakMapMemoize;
1190
+ }];
1191
+ recomputations: () => number;
1192
+ resetRecomputations: () => void;
1193
+ dependencyRecomputations: () => number;
1194
+ resetDependencyRecomputations: () => void;
1195
+ } & {
1196
+ argsMemoize: typeof import("reselect").weakMapMemoize;
1197
+ memoize: typeof import("reselect").weakMapMemoize;
1198
+ };
1029
1199
  declare const makeSelectNodeFormTouched: (name: string, currentNodeId: string) => ((state: {
1030
1200
  flower: {
1031
1201
  [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
@@ -1153,8 +1323,8 @@ declare const makeSelectFieldError: (name: string, id: string, validate: any) =>
1153
1323
  resultsCount: () => number;
1154
1324
  resetResultsCount: () => void;
1155
1325
  } & {
1156
- resultFunc: (resultFuncArgs_0: Record<string, any> | undefined) => string[];
1157
- memoizedResultFunc: ((resultFuncArgs_0: Record<string, any> | undefined) => string[]) & {
1326
+ resultFunc: (resultFuncArgs_0: Record<string, any> | undefined, resultFuncArgs_1: import("@flowerforce/flower-core").Form<Record<string, any>>) => string[];
1327
+ memoizedResultFunc: ((resultFuncArgs_0: Record<string, any> | undefined, resultFuncArgs_1: import("@flowerforce/flower-core").Form<Record<string, any>>) => string[]) & {
1158
1328
  clearCache: () => void;
1159
1329
  resultsCount: () => number;
1160
1330
  resetResultsCount: () => void;
@@ -1194,6 +1364,180 @@ declare const makeSelectFieldError: (name: string, id: string, validate: any) =>
1194
1364
  } & {
1195
1365
  argsMemoize: typeof import("reselect").weakMapMemoize;
1196
1366
  memoize: typeof import("reselect").weakMapMemoize;
1367
+ }, ((state: {
1368
+ flower: {
1369
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1370
+ };
1371
+ }) => import("@flowerforce/flower-core").Form<Record<string, any>>) & {
1372
+ clearCache: () => void;
1373
+ resultsCount: () => number;
1374
+ resetResultsCount: () => void;
1375
+ } & {
1376
+ resultFunc: (resultFuncArgs_0: import("@flowerforce/flower-core").Flower<Record<string, any>>, resultFuncArgs_1: string) => import("@flowerforce/flower-core").Form<Record<string, any>>;
1377
+ memoizedResultFunc: ((resultFuncArgs_0: import("@flowerforce/flower-core").Flower<Record<string, any>>, resultFuncArgs_1: string) => import("@flowerforce/flower-core").Form<Record<string, any>>) & {
1378
+ clearCache: () => void;
1379
+ resultsCount: () => number;
1380
+ resetResultsCount: () => void;
1381
+ };
1382
+ lastResult: () => import("@flowerforce/flower-core").Form<Record<string, any>>;
1383
+ dependencies: [((state: {
1384
+ flower: {
1385
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1386
+ };
1387
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>) & {
1388
+ clearCache: () => void;
1389
+ resultsCount: () => number;
1390
+ resetResultsCount: () => void;
1391
+ } & {
1392
+ resultFunc: (resultFuncArgs_0: {
1393
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1394
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>;
1395
+ memoizedResultFunc: ((resultFuncArgs_0: {
1396
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1397
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>) & {
1398
+ clearCache: () => void;
1399
+ resultsCount: () => number;
1400
+ resetResultsCount: () => void;
1401
+ };
1402
+ lastResult: () => import("@flowerforce/flower-core").Flower<Record<string, any>>;
1403
+ dependencies: [<T extends Record<string, any>>(state: {
1404
+ flower: {
1405
+ [x: string]: import("@flowerforce/flower-core").Flower<T>;
1406
+ };
1407
+ }) => {
1408
+ [x: string]: import("@flowerforce/flower-core").Flower<T>;
1409
+ }];
1410
+ recomputations: () => number;
1411
+ resetRecomputations: () => void;
1412
+ dependencyRecomputations: () => number;
1413
+ resetDependencyRecomputations: () => void;
1414
+ } & {
1415
+ argsMemoize: typeof import("reselect").weakMapMemoize;
1416
+ memoize: typeof import("reselect").weakMapMemoize;
1417
+ }, ((state: {
1418
+ flower: {
1419
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1420
+ };
1421
+ }) => string) & {
1422
+ clearCache: () => void;
1423
+ resultsCount: () => number;
1424
+ resetResultsCount: () => void;
1425
+ } & {
1426
+ resultFunc: (resultFuncArgs_0: import("@flowerforce/flower-core").Flower<Record<string, any>>, resultFuncArgs_1: string) => string;
1427
+ memoizedResultFunc: ((resultFuncArgs_0: import("@flowerforce/flower-core").Flower<Record<string, any>>, resultFuncArgs_1: string) => string) & {
1428
+ clearCache: () => void;
1429
+ resultsCount: () => number;
1430
+ resetResultsCount: () => void;
1431
+ };
1432
+ lastResult: () => string;
1433
+ dependencies: [((state: {
1434
+ flower: {
1435
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1436
+ };
1437
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>) & {
1438
+ clearCache: () => void;
1439
+ resultsCount: () => number;
1440
+ resetResultsCount: () => void;
1441
+ } & {
1442
+ resultFunc: (resultFuncArgs_0: {
1443
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1444
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>;
1445
+ memoizedResultFunc: ((resultFuncArgs_0: {
1446
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1447
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>) & {
1448
+ clearCache: () => void;
1449
+ resultsCount: () => number;
1450
+ resetResultsCount: () => void;
1451
+ };
1452
+ lastResult: () => import("@flowerforce/flower-core").Flower<Record<string, any>>;
1453
+ dependencies: [<T extends Record<string, any>>(state: {
1454
+ flower: {
1455
+ [x: string]: import("@flowerforce/flower-core").Flower<T>;
1456
+ };
1457
+ }) => {
1458
+ [x: string]: import("@flowerforce/flower-core").Flower<T>;
1459
+ }];
1460
+ recomputations: () => number;
1461
+ resetRecomputations: () => void;
1462
+ dependencyRecomputations: () => number;
1463
+ resetDependencyRecomputations: () => void;
1464
+ } & {
1465
+ argsMemoize: typeof import("reselect").weakMapMemoize;
1466
+ memoize: typeof import("reselect").weakMapMemoize;
1467
+ }, ((state: {
1468
+ flower: {
1469
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1470
+ };
1471
+ }) => string) & {
1472
+ clearCache: () => void;
1473
+ resultsCount: () => number;
1474
+ resetResultsCount: () => void;
1475
+ } & {
1476
+ resultFunc: (resultFuncArgs_0: import("@flowerforce/flower-core").Flower<Record<string, any>>) => string;
1477
+ memoizedResultFunc: ((resultFuncArgs_0: import("@flowerforce/flower-core").Flower<Record<string, any>>) => string) & {
1478
+ clearCache: () => void;
1479
+ resultsCount: () => number;
1480
+ resetResultsCount: () => void;
1481
+ };
1482
+ lastResult: () => string;
1483
+ dependencies: [((state: {
1484
+ flower: {
1485
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1486
+ };
1487
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>) & {
1488
+ clearCache: () => void;
1489
+ resultsCount: () => number;
1490
+ resetResultsCount: () => void;
1491
+ } & {
1492
+ resultFunc: (resultFuncArgs_0: {
1493
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1494
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>;
1495
+ memoizedResultFunc: ((resultFuncArgs_0: {
1496
+ [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1497
+ }) => import("@flowerforce/flower-core").Flower<Record<string, any>>) & {
1498
+ clearCache: () => void;
1499
+ resultsCount: () => number;
1500
+ resetResultsCount: () => void;
1501
+ };
1502
+ lastResult: () => import("@flowerforce/flower-core").Flower<Record<string, any>>;
1503
+ dependencies: [<T extends Record<string, any>>(state: {
1504
+ flower: {
1505
+ [x: string]: import("@flowerforce/flower-core").Flower<T>;
1506
+ };
1507
+ }) => {
1508
+ [x: string]: import("@flowerforce/flower-core").Flower<T>;
1509
+ }];
1510
+ recomputations: () => number;
1511
+ resetRecomputations: () => void;
1512
+ dependencyRecomputations: () => number;
1513
+ resetDependencyRecomputations: () => void;
1514
+ } & {
1515
+ argsMemoize: typeof import("reselect").weakMapMemoize;
1516
+ memoize: typeof import("reselect").weakMapMemoize;
1517
+ }];
1518
+ recomputations: () => number;
1519
+ resetRecomputations: () => void;
1520
+ dependencyRecomputations: () => number;
1521
+ resetDependencyRecomputations: () => void;
1522
+ } & {
1523
+ argsMemoize: typeof import("reselect").weakMapMemoize;
1524
+ memoize: typeof import("reselect").weakMapMemoize;
1525
+ }];
1526
+ recomputations: () => number;
1527
+ resetRecomputations: () => void;
1528
+ dependencyRecomputations: () => number;
1529
+ resetDependencyRecomputations: () => void;
1530
+ } & {
1531
+ argsMemoize: typeof import("reselect").weakMapMemoize;
1532
+ memoize: typeof import("reselect").weakMapMemoize;
1533
+ }];
1534
+ recomputations: () => number;
1535
+ resetRecomputations: () => void;
1536
+ dependencyRecomputations: () => number;
1537
+ resetDependencyRecomputations: () => void;
1538
+ } & {
1539
+ argsMemoize: typeof import("reselect").weakMapMemoize;
1540
+ memoize: typeof import("reselect").weakMapMemoize;
1197
1541
  }];
1198
1542
  recomputations: () => number;
1199
1543
  resetRecomputations: () => void;
@@ -1215,12 +1559,14 @@ export declare const selectorRulesDisabled: (id: string, rules: RulesObject<any>
1215
1559
  resultFunc: (resultFuncArgs_0: Record<string, any> | undefined, resultFuncArgs_1: {
1216
1560
  touched: boolean;
1217
1561
  errors: any;
1562
+ customErrors: any;
1218
1563
  isValid: boolean;
1219
1564
  isValidating?: boolean | undefined;
1220
1565
  }) => boolean;
1221
1566
  memoizedResultFunc: ((resultFuncArgs_0: Record<string, any> | undefined, resultFuncArgs_1: {
1222
1567
  touched: boolean;
1223
1568
  errors: any;
1569
+ customErrors: any;
1224
1570
  isValid: boolean;
1225
1571
  isValidating?: boolean | undefined;
1226
1572
  }) => boolean) & {
@@ -1270,6 +1616,7 @@ export declare const selectorRulesDisabled: (id: string, rules: RulesObject<any>
1270
1616
  }) => {
1271
1617
  touched: boolean;
1272
1618
  errors: any;
1619
+ customErrors: any;
1273
1620
  isValid: boolean;
1274
1621
  isValidating?: boolean | undefined;
1275
1622
  }) & {
@@ -1280,12 +1627,14 @@ export declare const selectorRulesDisabled: (id: string, rules: RulesObject<any>
1280
1627
  resultFunc: (resultFuncArgs_0: import("@flowerforce/flower-core").Form<Record<string, any>>) => {
1281
1628
  touched: boolean;
1282
1629
  errors: any;
1630
+ customErrors: any;
1283
1631
  isValid: boolean;
1284
1632
  isValidating?: boolean | undefined;
1285
1633
  };
1286
1634
  memoizedResultFunc: ((resultFuncArgs_0: import("@flowerforce/flower-core").Form<Record<string, any>>) => {
1287
1635
  touched: boolean;
1288
1636
  errors: any;
1637
+ customErrors: any;
1289
1638
  isValid: boolean;
1290
1639
  isValidating?: boolean | undefined;
1291
1640
  }) & {
@@ -1296,6 +1645,7 @@ export declare const selectorRulesDisabled: (id: string, rules: RulesObject<any>
1296
1645
  lastResult: () => {
1297
1646
  touched: boolean;
1298
1647
  errors: any;
1648
+ customErrors: any;
1299
1649
  isValid: boolean;
1300
1650
  isValidating?: boolean | undefined;
1301
1651
  };
@@ -1374,4 +1724,4 @@ export declare const selectorRulesDisabled: (id: string, rules: RulesObject<any>
1374
1724
  argsMemoize: typeof import("reselect").weakMapMemoize;
1375
1725
  memoize: typeof import("reselect").weakMapMemoize;
1376
1726
  };
1377
- export { selectFlowerHistory, makeSelectNodesIds, makeSelectCurrentNodeId, makeSelectStartNodeId, makeSelectCurrentNodeDisabled, getAllData, getDataByFlow, getDataFromState, makeSelectNodeErrors, makeSelectFieldError, makeSelectNodeFormTouched, makeSelectPrevNodeRetain };
1727
+ export { selectFlowerHistory, makeSelectNodesIds, makeSelectCurrentNodeId, makeSelectStartNodeId, makeSelectCurrentNodeDisabled, getAllData, getDataByFlow, getDataFromState, makeSelectNodeErrors, makeSelectNodeFieldTouched, makeSelectNodeFieldDirty, makeSelectFieldError, makeSelectNodeFormTouched, makeSelectPrevNodeRetain };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowerforce/flower-react",
3
- "version": "3.1.2-beta.3",
3
+ "version": "3.1.2-beta.5",
4
4
  "description": "FlowerJS components, hooks and utils for React.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "typescript": "^5.4.5"
35
35
  },
36
36
  "dependencies": {
37
- "@flowerforce/flower-core": "3.1.2-beta.3",
37
+ "@flowerforce/flower-core": "3.1.2-beta.5",
38
38
  "@reduxjs/toolkit": "^2.2.4",
39
39
  "lodash": "^4.17.21",
40
40
  "react-redux": "^9.1.2",