@flowerforce/flower-react 3.1.2-beta.6 → 3.1.2-beta.8

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/dist/index.cjs.js CHANGED
@@ -48,7 +48,7 @@ const getDataFromState = (name, id) => reselect.createSelector(getDataByFlow(nam
48
48
  const makeSelectNodeErrors = (name, currentNodeId) => reselect.createSelector(selectFlowerFormNode(name, currentNodeId), flowerCore.Selectors.makeSelectNodeErrors);
49
49
  const makeSelectNodeFieldTouched = (name, currentNodeId, fieldId) => reselect.createSelector(selectFlowerFormNode(name, currentNodeId), flowerCore.Selectors.makeSelectNodeFormFieldTouched(fieldId));
50
50
  const makeSelectNodeFieldDirty = (name, currentNodeId, fieldId) => reselect.createSelector(selectFlowerFormNode(name, currentNodeId), flowerCore.Selectors.makeSelectNodeFormFieldDirty(fieldId));
51
- const makeSelectNodeFormTouched = (name, currentNodeId) => reselect.createSelector(selectFlowerFormNode(name, currentNodeId), flowerCore.Selectors.makeSelectNodeFormTouched);
51
+ const makeSelectNodeFormSubmitted = (name, currentNodeId) => reselect.createSelector(selectFlowerFormNode(name, currentNodeId), flowerCore.Selectors.makeSelectNodeFormSubmitted);
52
52
  const getAllData = reselect.createSelector(selectGlobal, mapData);
53
53
  const selectFlowerFormCurrentNode = (name) => reselect.createSelector(selectFlower(name), makeSelectCurrentNodeId(name), (data, current) => {
54
54
  return _get(data, ['form', current]);
@@ -416,7 +416,7 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
416
416
  const dirty = useSelector(makeSelectNodeFieldDirty(flowName, currentNode, id));
417
417
  const touched = useSelector(makeSelectNodeFieldTouched(flowName, currentNode, id));
418
418
  const refValue = React.useRef();
419
- const touchedForm = useSelector(makeSelectNodeFormTouched(flowName, currentNode));
419
+ const isSubmitted = useSelector(makeSelectNodeFormSubmitted(flowName, currentNode));
420
420
  const allErrors = React.useMemo(() => [...errors, ...(customAsyncErrors || []).filter(Boolean)], [errors, customAsyncErrors]);
421
421
  const setTouched = React.useCallback((touched) => {
422
422
  dispatch({
@@ -534,7 +534,7 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
534
534
  dirty,
535
535
  hidden,
536
536
  isValidating,
537
- touchedForm
537
+ isSubmitted
538
538
  }), [
539
539
  props,
540
540
  id,
@@ -546,7 +546,7 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
546
546
  onBlurInternal,
547
547
  hidden,
548
548
  isValidating,
549
- touchedForm
549
+ isSubmitted
550
550
  ]);
551
551
  if (typeof Component === 'function') {
552
552
  return Component(newProps);
@@ -838,15 +838,18 @@ const component = React.memo(FlowerComponent);
838
838
  *
839
839
  * It exposes details regarding the form's state and a set of methods for reading and writing within it:
840
840
  *
841
- * - getData
842
- *
843
- * - setData
844
- *
845
- * - unSetData
846
- *
847
- * - replaceData
848
- *
849
- * - unTouched
841
+ * - isSubmitted,
842
+ * - isDirty,
843
+ * - errors,
844
+ * - customErrors,
845
+ * - isValid,
846
+ * - isValidating,
847
+ * - getData,
848
+ * - setData,
849
+ * - unsetData,
850
+ * - replaceData,
851
+ * - reset,
852
+ * - setCustomErrors
850
853
  *
851
854
  * @param {string} flowName - first optional parameter
852
855
  *
@@ -859,7 +862,7 @@ const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
859
862
  const store = useStore();
860
863
  const flowName = customFlowName || name || flowNameDefault || '';
861
864
  const currentNode = useSelector(makeSelectCurrentNodeId(flowName));
862
- const { errors, customErrors, isValid, touched, isValidating } = useSelector(makeSelectNodeErrors(flowName, currentNode));
865
+ const { errors, customErrors, isValid, isSubmitted, isDirty, isValidating } = useSelector(makeSelectNodeErrors(flowName, currentNode));
863
866
  const getData = React.useCallback((path) => {
864
867
  const { flowNameFromPath = flowName, path: newpath } = flowerCore.CoreUtils.getPath(path);
865
868
  return _get(store.getState(), [
@@ -869,19 +872,23 @@ const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
869
872
  ...newpath
870
873
  ]);
871
874
  }, [store, flowName]);
875
+ const setDataField = React.useCallback((id, val) => {
876
+ const { flowNameFromPath = flowName } = flowerCore.CoreUtils.getPath(id);
877
+ dispatch(actions.addDataByPath({
878
+ flowName: flowNameFromPath,
879
+ id,
880
+ value: val,
881
+ dirty: true
882
+ }));
883
+ return;
884
+ }, [flowName, dispatch]);
872
885
  const setData = React.useCallback((val, id) => {
873
886
  if (id) {
874
- const { flowNameFromPath = flowName } = flowerCore.CoreUtils.getPath(id);
875
- dispatch(actions.addDataByPath({
876
- flowName: flowNameFromPath,
877
- id,
878
- value: val,
879
- dirty: true
880
- }));
887
+ setDataField(id, val);
881
888
  return;
882
889
  }
883
890
  dispatch(actions.addData({ flowName, value: val }));
884
- }, [flowName, dispatch]);
891
+ }, [flowName, setDataField, dispatch]);
885
892
  const unsetData = React.useCallback((path) => {
886
893
  const { flowNameFromPath = flowName, path: newpath } = flowerCore.CoreUtils.getPath(path);
887
894
  dispatch(actions.unsetData({ flowName: flowNameFromPath, id: newpath }));
@@ -904,13 +911,15 @@ const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
904
911
  });
905
912
  }, [flowName, currentNode, dispatch]);
906
913
  return {
907
- touched,
914
+ isSubmitted,
915
+ isDirty,
908
916
  errors,
909
917
  customErrors,
910
918
  isValid,
911
919
  isValidating,
912
920
  getData,
913
921
  setData,
922
+ setDataField,
914
923
  unsetData,
915
924
  replaceData,
916
925
  reset,
package/dist/index.esm.js CHANGED
@@ -46,7 +46,7 @@ const getDataFromState = (name, id) => createSelector(getDataByFlow(name), Selec
46
46
  const makeSelectNodeErrors = (name, currentNodeId) => createSelector(selectFlowerFormNode(name, currentNodeId), Selectors.makeSelectNodeErrors);
47
47
  const makeSelectNodeFieldTouched = (name, currentNodeId, fieldId) => createSelector(selectFlowerFormNode(name, currentNodeId), Selectors.makeSelectNodeFormFieldTouched(fieldId));
48
48
  const makeSelectNodeFieldDirty = (name, currentNodeId, fieldId) => createSelector(selectFlowerFormNode(name, currentNodeId), Selectors.makeSelectNodeFormFieldDirty(fieldId));
49
- const makeSelectNodeFormTouched = (name, currentNodeId) => createSelector(selectFlowerFormNode(name, currentNodeId), Selectors.makeSelectNodeFormTouched);
49
+ const makeSelectNodeFormSubmitted = (name, currentNodeId) => createSelector(selectFlowerFormNode(name, currentNodeId), Selectors.makeSelectNodeFormSubmitted);
50
50
  const getAllData = createSelector(selectGlobal, mapData);
51
51
  const selectFlowerFormCurrentNode = (name) => createSelector(selectFlower(name), makeSelectCurrentNodeId(name), (data, current) => {
52
52
  return _get(data, ['form', current]);
@@ -414,7 +414,7 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
414
414
  const dirty = useSelector(makeSelectNodeFieldDirty(flowName, currentNode, id));
415
415
  const touched = useSelector(makeSelectNodeFieldTouched(flowName, currentNode, id));
416
416
  const refValue = useRef();
417
- const touchedForm = useSelector(makeSelectNodeFormTouched(flowName, currentNode));
417
+ const isSubmitted = useSelector(makeSelectNodeFormSubmitted(flowName, currentNode));
418
418
  const allErrors = useMemo(() => [...errors, ...(customAsyncErrors || []).filter(Boolean)], [errors, customAsyncErrors]);
419
419
  const setTouched = useCallback((touched) => {
420
420
  dispatch({
@@ -532,7 +532,7 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
532
532
  dirty,
533
533
  hidden,
534
534
  isValidating,
535
- touchedForm
535
+ isSubmitted
536
536
  }), [
537
537
  props,
538
538
  id,
@@ -544,7 +544,7 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
544
544
  onBlurInternal,
545
545
  hidden,
546
546
  isValidating,
547
- touchedForm
547
+ isSubmitted
548
548
  ]);
549
549
  if (typeof Component === 'function') {
550
550
  return Component(newProps);
@@ -836,15 +836,18 @@ const component = memo(FlowerComponent);
836
836
  *
837
837
  * It exposes details regarding the form's state and a set of methods for reading and writing within it:
838
838
  *
839
- * - getData
840
- *
841
- * - setData
842
- *
843
- * - unSetData
844
- *
845
- * - replaceData
846
- *
847
- * - unTouched
839
+ * - isSubmitted,
840
+ * - isDirty,
841
+ * - errors,
842
+ * - customErrors,
843
+ * - isValid,
844
+ * - isValidating,
845
+ * - getData,
846
+ * - setData,
847
+ * - unsetData,
848
+ * - replaceData,
849
+ * - reset,
850
+ * - setCustomErrors
848
851
  *
849
852
  * @param {string} flowName - first optional parameter
850
853
  *
@@ -857,7 +860,7 @@ const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
857
860
  const store = useStore();
858
861
  const flowName = customFlowName || name || flowNameDefault || '';
859
862
  const currentNode = useSelector(makeSelectCurrentNodeId(flowName));
860
- const { errors, customErrors, isValid, touched, isValidating } = useSelector(makeSelectNodeErrors(flowName, currentNode));
863
+ const { errors, customErrors, isValid, isSubmitted, isDirty, isValidating } = useSelector(makeSelectNodeErrors(flowName, currentNode));
861
864
  const getData = useCallback((path) => {
862
865
  const { flowNameFromPath = flowName, path: newpath } = CoreUtils.getPath(path);
863
866
  return _get(store.getState(), [
@@ -867,19 +870,23 @@ const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
867
870
  ...newpath
868
871
  ]);
869
872
  }, [store, flowName]);
873
+ const setDataField = useCallback((id, val) => {
874
+ const { flowNameFromPath = flowName } = CoreUtils.getPath(id);
875
+ dispatch(actions.addDataByPath({
876
+ flowName: flowNameFromPath,
877
+ id,
878
+ value: val,
879
+ dirty: true
880
+ }));
881
+ return;
882
+ }, [flowName, dispatch]);
870
883
  const setData = useCallback((val, id) => {
871
884
  if (id) {
872
- const { flowNameFromPath = flowName } = CoreUtils.getPath(id);
873
- dispatch(actions.addDataByPath({
874
- flowName: flowNameFromPath,
875
- id,
876
- value: val,
877
- dirty: true
878
- }));
885
+ setDataField(id, val);
879
886
  return;
880
887
  }
881
888
  dispatch(actions.addData({ flowName, value: val }));
882
- }, [flowName, dispatch]);
889
+ }, [flowName, setDataField, dispatch]);
883
890
  const unsetData = useCallback((path) => {
884
891
  const { flowNameFromPath = flowName, path: newpath } = CoreUtils.getPath(path);
885
892
  dispatch(actions.unsetData({ flowName: flowNameFromPath, id: newpath }));
@@ -902,13 +909,15 @@ const useFlowerForm = ({ flowName: customFlowName, name } = {}) => {
902
909
  });
903
910
  }, [flowName, currentNode, dispatch]);
904
911
  return {
905
- touched,
912
+ isSubmitted,
913
+ isDirty,
906
914
  errors,
907
915
  customErrors,
908
916
  isValid,
909
917
  isValidating,
910
918
  getData,
911
919
  setData,
920
+ setDataField,
912
921
  unsetData,
913
922
  replaceData,
914
923
  reset,
@@ -31,11 +31,11 @@ export type FlowerFieldProps<T extends Record<string, any> = Record<string, any>
31
31
  onChange: (props: any) => void;
32
32
  /** The function executed to test all the validation rules*/
33
33
  onBlur: () => void;
34
- /** This parameter will notify you whether the form field has been touched */
35
- touchedForm: boolean;
34
+ /** This value is set to true when the form has been submitted at least once or a next invoked */
35
+ isSubmitted: boolean;
36
36
  /** This parameter will notify you whether the form field has been touched */
37
37
  touched: boolean;
38
- /** This parameter will notify you whether the form field has been touched */
38
+ /** This parameter will notify you if the form field is filled in at least once */
39
39
  dirty: boolean;
40
40
  /** true when some of the display rules are not satisfied, and you have passed true to the "alwaysDisplay" FlowerField's prop*/
41
41
  hidden: boolean;
@@ -3,8 +3,10 @@ export type UseFlowerProps = {
3
3
  [x in 'name' | 'flowName']?: string;
4
4
  };
5
5
  export type UseFlowerForm = (options?: UseFlowerProps) => {
6
- /** This value is set to true when the form has been touched at least once. */
7
- touched: boolean;
6
+ /** This value is set to true when the form has been submitted at least once or a next invoked. */
7
+ isSubmitted: boolean;
8
+ /** This value is set to true when at least once field is dirted. */
9
+ isDirty: boolean;
8
10
  /** An object containing all the form errors */
9
11
  errors: Record<string, any>;
10
12
  /** An object containing all the form custom errors */
@@ -21,6 +23,12 @@ export type UseFlowerForm = (options?: UseFlowerProps) => {
21
23
  value: any,
22
24
  /** Specify the target path to set the value*/
23
25
  path?: string) => void;
26
+ /** Use this function to set value in the flow's field data. */
27
+ setDataField: (
28
+ /** Specify the target path to set the value*/
29
+ path: string,
30
+ /** The value that you want to set */
31
+ value: any) => void;
24
32
  /** Use this function to unset values in the flow's data. */
25
33
  unsetData: (
26
34
  /** Specify the target path to the value tha you want to unset*/
@@ -3,15 +3,18 @@ import { UseFlowerForm } from './types/FlowerHooks';
3
3
  *
4
4
  * It exposes details regarding the form's state and a set of methods for reading and writing within it:
5
5
  *
6
- * - getData
7
- *
8
- * - setData
9
- *
10
- * - unSetData
11
- *
12
- * - replaceData
13
- *
14
- * - unTouched
6
+ * - isSubmitted,
7
+ * - isDirty,
8
+ * - errors,
9
+ * - customErrors,
10
+ * - isValid,
11
+ * - isValidating,
12
+ * - getData,
13
+ * - setData,
14
+ * - unsetData,
15
+ * - replaceData,
16
+ * - reset,
17
+ * - setCustomErrors
15
18
  *
16
19
  * @param {string} flowName - first optional parameter
17
20
  *
@@ -928,7 +928,8 @@ declare const makeSelectNodeErrors: (name: string, currentNodeId: string) => ((s
928
928
  [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
929
929
  };
930
930
  }) => {
931
- touched: boolean;
931
+ isSubmitted: boolean;
932
+ isDirty: boolean;
932
933
  errors: any;
933
934
  customErrors: any;
934
935
  isValid: boolean;
@@ -939,14 +940,16 @@ declare const makeSelectNodeErrors: (name: string, currentNodeId: string) => ((s
939
940
  resetResultsCount: () => void;
940
941
  } & {
941
942
  resultFunc: (resultFuncArgs_0: import("@flowerforce/flower-core").Form<Record<string, any>>) => {
942
- touched: boolean;
943
+ isSubmitted: boolean;
944
+ isDirty: boolean;
943
945
  errors: any;
944
946
  customErrors: any;
945
947
  isValid: boolean;
946
948
  isValidating?: boolean | undefined;
947
949
  };
948
950
  memoizedResultFunc: ((resultFuncArgs_0: import("@flowerforce/flower-core").Form<Record<string, any>>) => {
949
- touched: boolean;
951
+ isSubmitted: boolean;
952
+ isDirty: boolean;
950
953
  errors: any;
951
954
  customErrors: any;
952
955
  isValid: boolean;
@@ -957,7 +960,8 @@ declare const makeSelectNodeErrors: (name: string, currentNodeId: string) => ((s
957
960
  resetResultsCount: () => void;
958
961
  };
959
962
  lastResult: () => {
960
- touched: boolean;
963
+ isSubmitted: boolean;
964
+ isDirty: boolean;
961
965
  errors: any;
962
966
  customErrors: any;
963
967
  isValid: boolean;
@@ -1196,7 +1200,7 @@ declare const makeSelectNodeFieldDirty: (name: string, currentNodeId: string, fi
1196
1200
  argsMemoize: typeof import("reselect").weakMapMemoize;
1197
1201
  memoize: typeof import("reselect").weakMapMemoize;
1198
1202
  };
1199
- declare const makeSelectNodeFormTouched: (name: string, currentNodeId: string) => ((state: {
1203
+ declare const makeSelectNodeFormSubmitted: (name: string, currentNodeId: string) => ((state: {
1200
1204
  flower: {
1201
1205
  [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1202
1206
  };
@@ -1557,14 +1561,16 @@ export declare const selectorRulesDisabled: (id: string, rules: RulesObject<any>
1557
1561
  resetResultsCount: () => void;
1558
1562
  } & {
1559
1563
  resultFunc: (resultFuncArgs_0: Record<string, any> | undefined, resultFuncArgs_1: {
1560
- touched: boolean;
1564
+ isSubmitted: boolean;
1565
+ isDirty: boolean;
1561
1566
  errors: any;
1562
1567
  customErrors: any;
1563
1568
  isValid: boolean;
1564
1569
  isValidating?: boolean | undefined;
1565
1570
  }) => boolean;
1566
1571
  memoizedResultFunc: ((resultFuncArgs_0: Record<string, any> | undefined, resultFuncArgs_1: {
1567
- touched: boolean;
1572
+ isSubmitted: boolean;
1573
+ isDirty: boolean;
1568
1574
  errors: any;
1569
1575
  customErrors: any;
1570
1576
  isValid: boolean;
@@ -1614,7 +1620,8 @@ export declare const selectorRulesDisabled: (id: string, rules: RulesObject<any>
1614
1620
  [x: string]: import("@flowerforce/flower-core").Flower<Record<string, any>>;
1615
1621
  };
1616
1622
  }) => {
1617
- touched: boolean;
1623
+ isSubmitted: boolean;
1624
+ isDirty: boolean;
1618
1625
  errors: any;
1619
1626
  customErrors: any;
1620
1627
  isValid: boolean;
@@ -1625,14 +1632,16 @@ export declare const selectorRulesDisabled: (id: string, rules: RulesObject<any>
1625
1632
  resetResultsCount: () => void;
1626
1633
  } & {
1627
1634
  resultFunc: (resultFuncArgs_0: import("@flowerforce/flower-core").Form<Record<string, any>>) => {
1628
- touched: boolean;
1635
+ isSubmitted: boolean;
1636
+ isDirty: boolean;
1629
1637
  errors: any;
1630
1638
  customErrors: any;
1631
1639
  isValid: boolean;
1632
1640
  isValidating?: boolean | undefined;
1633
1641
  };
1634
1642
  memoizedResultFunc: ((resultFuncArgs_0: import("@flowerforce/flower-core").Form<Record<string, any>>) => {
1635
- touched: boolean;
1643
+ isSubmitted: boolean;
1644
+ isDirty: boolean;
1636
1645
  errors: any;
1637
1646
  customErrors: any;
1638
1647
  isValid: boolean;
@@ -1643,7 +1652,8 @@ export declare const selectorRulesDisabled: (id: string, rules: RulesObject<any>
1643
1652
  resetResultsCount: () => void;
1644
1653
  };
1645
1654
  lastResult: () => {
1646
- touched: boolean;
1655
+ isSubmitted: boolean;
1656
+ isDirty: boolean;
1647
1657
  errors: any;
1648
1658
  customErrors: any;
1649
1659
  isValid: boolean;
@@ -1724,4 +1734,4 @@ export declare const selectorRulesDisabled: (id: string, rules: RulesObject<any>
1724
1734
  argsMemoize: typeof import("reselect").weakMapMemoize;
1725
1735
  memoize: typeof import("reselect").weakMapMemoize;
1726
1736
  };
1727
- export { selectFlowerHistory, makeSelectNodesIds, makeSelectCurrentNodeId, makeSelectStartNodeId, makeSelectCurrentNodeDisabled, getAllData, getDataByFlow, getDataFromState, makeSelectNodeErrors, makeSelectNodeFieldTouched, makeSelectNodeFieldDirty, makeSelectFieldError, makeSelectNodeFormTouched, makeSelectPrevNodeRetain };
1737
+ export { selectFlowerHistory, makeSelectNodesIds, makeSelectCurrentNodeId, makeSelectStartNodeId, makeSelectCurrentNodeDisabled, getAllData, getDataByFlow, getDataFromState, makeSelectNodeErrors, makeSelectNodeFieldTouched, makeSelectNodeFieldDirty, makeSelectFieldError, makeSelectNodeFormSubmitted, makeSelectPrevNodeRetain };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowerforce/flower-react",
3
- "version": "3.1.2-beta.6",
3
+ "version": "3.1.2-beta.8",
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.6",
37
+ "@flowerforce/flower-core": "3.1.2-beta.8",
38
38
  "@reduxjs/toolkit": "^2.2.4",
39
39
  "lodash": "^4.17.21",
40
40
  "react-redux": "^9.1.2",