@flowerforce/flower-core 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 +8 -9
- package/dist/index.esm.js +8 -9
- package/dist/src/FlowerCoreStateUtils.d.ts +2 -1
- package/dist/src/interfaces/ReducerInterface.d.ts +1 -15
- package/dist/src/interfaces/SelectorsInterface.d.ts +3 -2
- package/dist/src/interfaces/Store.d.ts +2 -1
- package/dist/src/interfaces/UtilsInterface.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
@@ -440,7 +440,8 @@ const createFormData = (form) => {
|
|
440
440
|
const validationErrors = form && form.errors;
|
441
441
|
const allErrors = Object.values(validationErrors || {});
|
442
442
|
return {
|
443
|
-
|
443
|
+
isSubmitted: form?.isSubmitted || false,
|
444
|
+
isDirty: form?.isDirty || false,
|
444
445
|
errors: form?.errors,
|
445
446
|
customErrors: form?.customErrors,
|
446
447
|
isValidating: form?.isValidating,
|
@@ -483,7 +484,7 @@ const FlowerCoreReducers = {
|
|
483
484
|
typeof payload === 'string' ? payload : payload.flowName,
|
484
485
|
'form',
|
485
486
|
typeof payload === 'string' ? payload : payload.currentNode,
|
486
|
-
'
|
487
|
+
'isSubmitted'
|
487
488
|
], true);
|
488
489
|
return state;
|
489
490
|
},
|
@@ -631,9 +632,6 @@ const FlowerCoreReducers = {
|
|
631
632
|
formFieldTouch: (state, { payload }) => {
|
632
633
|
_set(state, [payload.name, 'form', payload.currentNode, 'touches', payload.id], payload.touched);
|
633
634
|
},
|
634
|
-
formFieldDirty: (state, { payload }) => {
|
635
|
-
_set(state, [payload.name, 'form', payload.currentNode, 'dirty', payload.id], payload.dirty);
|
636
|
-
},
|
637
635
|
addData: (state, { payload }) => {
|
638
636
|
const prevData = _get(state, [payload.flowName, 'data']);
|
639
637
|
_set(state, [payload.flowName, 'data'], { ...prevData, ...payload.value });
|
@@ -643,8 +641,9 @@ const FlowerCoreReducers = {
|
|
643
641
|
const currentNode = FlowerStateUtils.makeSelectCurrentNodeId(payload.flowName)(state);
|
644
642
|
if (payload.id && payload.id.length) {
|
645
643
|
_set(state, [payload.flowName, 'data', ...newpath], payload.value);
|
646
|
-
if (payload
|
644
|
+
if (payload && payload.dirty) {
|
647
645
|
_set(state, [payload.flowName, 'form', currentNode, 'dirty', payload.id], payload.dirty);
|
646
|
+
_set(state, [payload.flowName, 'form', currentNode, 'isDirty'], true);
|
648
647
|
}
|
649
648
|
}
|
650
649
|
},
|
@@ -666,8 +665,8 @@ const FlowerCoreReducers = {
|
|
666
665
|
_unset(state, [flowNameFromPath, 'data', ...path]);
|
667
666
|
});
|
668
667
|
_unset(state, [payload.flowName, 'form', payload.id, 'touches']);
|
669
|
-
_unset(state, [payload.flowName, 'form', payload.id, '
|
670
|
-
_unset(state, [payload.flowName, 'form', payload.id, '
|
668
|
+
_unset(state, [payload.flowName, 'form', payload.id, 'isDirty']);
|
669
|
+
_unset(state, [payload.flowName, 'form', payload.id, 'isSubmitted']);
|
671
670
|
},
|
672
671
|
node: (state, { payload }) => {
|
673
672
|
const { name, history } = payload;
|
@@ -777,7 +776,7 @@ const FlowerCoreStateSelectors = {
|
|
777
776
|
makeSelectStartNodeId: (flower) => _get(flower, ['startId']),
|
778
777
|
getDataByFlow: (flower) => _get(flower, ['data']) ?? {},
|
779
778
|
getDataFromState: (id) => (data) => (id === '*' ? data : _get(data, id)),
|
780
|
-
|
779
|
+
makeSelectNodeFormSubmitted: (form) => form && form.isSubmitted,
|
781
780
|
makeSelectNodeFormFieldTouched: (id) => (form) => form && form.touches && form.touches[id],
|
782
781
|
makeSelectNodeFormFieldDirty: (id) => (form) => form && form.dirty && form.dirty[id],
|
783
782
|
makeSelectCurrentNodeId: (flower, startNodeId) => _get(flower, ['current']) || startNodeId,
|
package/dist/index.esm.js
CHANGED
@@ -438,7 +438,8 @@ const createFormData = (form) => {
|
|
438
438
|
const validationErrors = form && form.errors;
|
439
439
|
const allErrors = Object.values(validationErrors || {});
|
440
440
|
return {
|
441
|
-
|
441
|
+
isSubmitted: form?.isSubmitted || false,
|
442
|
+
isDirty: form?.isDirty || false,
|
442
443
|
errors: form?.errors,
|
443
444
|
customErrors: form?.customErrors,
|
444
445
|
isValidating: form?.isValidating,
|
@@ -481,7 +482,7 @@ const FlowerCoreReducers = {
|
|
481
482
|
typeof payload === 'string' ? payload : payload.flowName,
|
482
483
|
'form',
|
483
484
|
typeof payload === 'string' ? payload : payload.currentNode,
|
484
|
-
'
|
485
|
+
'isSubmitted'
|
485
486
|
], true);
|
486
487
|
return state;
|
487
488
|
},
|
@@ -629,9 +630,6 @@ const FlowerCoreReducers = {
|
|
629
630
|
formFieldTouch: (state, { payload }) => {
|
630
631
|
_set(state, [payload.name, 'form', payload.currentNode, 'touches', payload.id], payload.touched);
|
631
632
|
},
|
632
|
-
formFieldDirty: (state, { payload }) => {
|
633
|
-
_set(state, [payload.name, 'form', payload.currentNode, 'dirty', payload.id], payload.dirty);
|
634
|
-
},
|
635
633
|
addData: (state, { payload }) => {
|
636
634
|
const prevData = _get(state, [payload.flowName, 'data']);
|
637
635
|
_set(state, [payload.flowName, 'data'], { ...prevData, ...payload.value });
|
@@ -641,8 +639,9 @@ const FlowerCoreReducers = {
|
|
641
639
|
const currentNode = FlowerStateUtils.makeSelectCurrentNodeId(payload.flowName)(state);
|
642
640
|
if (payload.id && payload.id.length) {
|
643
641
|
_set(state, [payload.flowName, 'data', ...newpath], payload.value);
|
644
|
-
if (payload
|
642
|
+
if (payload && payload.dirty) {
|
645
643
|
_set(state, [payload.flowName, 'form', currentNode, 'dirty', payload.id], payload.dirty);
|
644
|
+
_set(state, [payload.flowName, 'form', currentNode, 'isDirty'], true);
|
646
645
|
}
|
647
646
|
}
|
648
647
|
},
|
@@ -664,8 +663,8 @@ const FlowerCoreReducers = {
|
|
664
663
|
_unset(state, [flowNameFromPath, 'data', ...path]);
|
665
664
|
});
|
666
665
|
_unset(state, [payload.flowName, 'form', payload.id, 'touches']);
|
667
|
-
_unset(state, [payload.flowName, 'form', payload.id, '
|
668
|
-
_unset(state, [payload.flowName, 'form', payload.id, '
|
666
|
+
_unset(state, [payload.flowName, 'form', payload.id, 'isDirty']);
|
667
|
+
_unset(state, [payload.flowName, 'form', payload.id, 'isSubmitted']);
|
669
668
|
},
|
670
669
|
node: (state, { payload }) => {
|
671
670
|
const { name, history } = payload;
|
@@ -775,7 +774,7 @@ const FlowerCoreStateSelectors = {
|
|
775
774
|
makeSelectStartNodeId: (flower) => _get(flower, ['startId']),
|
776
775
|
getDataByFlow: (flower) => _get(flower, ['data']) ?? {},
|
777
776
|
getDataFromState: (id) => (data) => (id === '*' ? data : _get(data, id)),
|
778
|
-
|
777
|
+
makeSelectNodeFormSubmitted: (form) => form && form.isSubmitted,
|
779
778
|
makeSelectNodeFormFieldTouched: (id) => (form) => form && form.touches && form.touches[id],
|
780
779
|
makeSelectNodeFormFieldDirty: (id) => (form) => form && form.dirty && form.dirty[id],
|
781
780
|
makeSelectCurrentNodeId: (flower, startNodeId) => _get(flower, ['current']) || startNodeId,
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { CoreStateUtils } from './interfaces/UtilsInterface';
|
2
2
|
export declare const FlowerStateUtils: CoreStateUtils;
|
3
3
|
export declare const createFormData: (form: Record<string, any>) => {
|
4
|
-
|
4
|
+
isSubmitted: any;
|
5
|
+
isDirty: any;
|
5
6
|
errors: any;
|
6
7
|
customErrors: any;
|
7
8
|
isValidating: any;
|
@@ -5,7 +5,7 @@ export type ActionWithPayload<T> = {
|
|
5
5
|
payload: T;
|
6
6
|
};
|
7
7
|
type ReducerFunctionSign<T extends object, R> = (state: Record<string, Flower<T>>, action: ActionWithPayload<R>) => Record<string, Flower<T>> | void;
|
8
|
-
export type ActionsTypes = 'historyAdd' | 'historyPrevToNode' | 'setFormTouched' | 'forceAddHistory' | 'historyPop' | 'restoreHistory' | 'replaceNode' | 'initializeFromNode' | 'forceResetHistory' | 'destroy' | 'initNodes' | 'setCurrentNode' | 'formAddErrors' | 'formRemoveErrors' | 'addData' | 'addDataByPath' | 'replaceData' | 'unsetData' | 'setFormIsValidating' | 'resetForm' | 'formFieldTouch' | '
|
8
|
+
export type ActionsTypes = 'historyAdd' | 'historyPrevToNode' | 'setFormTouched' | 'forceAddHistory' | 'historyPop' | 'restoreHistory' | 'replaceNode' | 'initializeFromNode' | 'forceResetHistory' | 'destroy' | 'initNodes' | 'setCurrentNode' | 'formAddErrors' | 'formRemoveErrors' | 'addData' | 'addDataByPath' | 'replaceData' | 'unsetData' | 'setFormIsValidating' | 'resetForm' | 'formFieldTouch' | 'node' | 'prevToNode' | 'next' | 'prev' | 'reset';
|
9
9
|
/**
|
10
10
|
* These functions are Redux reducers used in a Flux architecture for managing state transitions and updates in a Flower application.
|
11
11
|
*/
|
@@ -192,20 +192,6 @@ export type ReducersFunctions<T extends Record<string, any> = Record<string, Flo
|
|
192
192
|
[x: string]: string[];
|
193
193
|
} | string[];
|
194
194
|
}>;
|
195
|
-
/**
|
196
|
-
* @param state
|
197
|
-
* @param action
|
198
|
-
*
|
199
|
-
* Set touch form single field
|
200
|
-
*
|
201
|
-
* @returns state
|
202
|
-
*/
|
203
|
-
formFieldDirty: ReducerFunctionSign<T, {
|
204
|
-
name: string;
|
205
|
-
currentNode: string;
|
206
|
-
id: string;
|
207
|
-
dirty?: boolean;
|
208
|
-
}>;
|
209
195
|
/**
|
210
196
|
* @param state
|
211
197
|
* @param action
|
@@ -65,7 +65,8 @@ export interface ISelectors {
|
|
65
65
|
* @returns
|
66
66
|
*/
|
67
67
|
makeSelectNodeErrors<T extends Record<string, any>>(form: Form<T> | undefined): {
|
68
|
-
|
68
|
+
isSubmitted: boolean;
|
69
|
+
isDirty: boolean;
|
69
70
|
errors: any;
|
70
71
|
customErrors: any;
|
71
72
|
isValid: boolean;
|
@@ -95,7 +96,7 @@ export interface ISelectors {
|
|
95
96
|
* @param form
|
96
97
|
* @returns
|
97
98
|
*/
|
98
|
-
|
99
|
+
makeSelectNodeFormSubmitted<T extends Record<string, any>>(form: Form<T>): boolean | undefined;
|
99
100
|
/**
|
100
101
|
* @param name
|
101
102
|
* @param id
|
@@ -41,7 +41,8 @@ export interface CoreStateUtils {
|
|
41
41
|
* It retrieves the form node using selectFlowerFormNode, then extracts information about touched state, errors, validation status, and validity.
|
42
42
|
*/
|
43
43
|
makeSelectNodeErrors<T extends object>(name: string, currentNodeId: string): (state: T) => {
|
44
|
-
|
44
|
+
isSubmitted: boolean;
|
45
|
+
isDirty: boolean;
|
45
46
|
errors: any;
|
46
47
|
customErrors: any;
|
47
48
|
isValid: boolean;
|