@flowerforce/flower-core 3.3.1-beta.2 → 4.0.1-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.
Files changed (35) hide show
  1. package/dist/index.cjs.js +238 -266
  2. package/dist/index.esm.js +228 -265
  3. package/dist/src/constants/index.d.ts +5 -0
  4. package/dist/src/event-emitter/index.d.ts +1 -0
  5. package/dist/src/index.d.ts +6 -8
  6. package/dist/src/interfaces/CoreInterface.d.ts +23 -17
  7. package/dist/src/interfaces/ReducerInterface.d.ts +109 -109
  8. package/dist/src/{rules-matcher/interface.d.ts → interfaces/RulesMatcherInterface.d.ts} +1 -1
  9. package/dist/src/interfaces/SelectorsInterface.d.ts +34 -25
  10. package/dist/src/interfaces/Store.d.ts +2 -10
  11. package/dist/src/interfaces/UtilsInterface.d.ts +1 -1
  12. package/dist/src/interfaces/index.d.ts +3 -0
  13. package/dist/src/rules-matcher/RulesMatcher.d.ts +2 -0
  14. package/dist/src/rules-matcher/index.d.ts +2 -0
  15. package/dist/src/rules-matcher/utils.d.ts +2 -3
  16. package/dist/src/state-manager/index.d.ts +2 -0
  17. package/dist/src/state-manager/state-functions/FlowerCoreMergedReducers.d.ts +2 -0
  18. package/dist/src/state-manager/state-functions/FlowerCoreStateFunctions.d.ts +5 -0
  19. package/dist/src/state-manager/state-functions/FlowerDataStateFunctions.d.ts +2 -0
  20. package/dist/src/state-manager/state-functions/index.d.ts +4 -0
  21. package/dist/src/state-manager/state-selectors/FlowerCoreStateSelectors.d.ts +2 -0
  22. package/dist/src/state-manager/state-selectors/FlowerDataStateSelectors.d.ts +2 -0
  23. package/dist/src/state-manager/state-selectors/FlowerSelectorsMerged.d.ts +2 -0
  24. package/dist/src/state-manager/state-selectors/index.d.ts +4 -0
  25. package/dist/src/{FlowerCoreStateUtils.d.ts → utils/FlowerCoreStateUtils.d.ts} +2 -2
  26. package/dist/src/{CoreUtils.d.ts → utils/FlowerCoreUtils.d.ts} +1 -2
  27. package/dist/src/utils/FlowerDataCoreUtils.d.ts +2 -0
  28. package/dist/src/utils/FlowerFlowUtils.d.ts +3 -0
  29. package/dist/src/utils/index.d.ts +4 -0
  30. package/package.json +1 -1
  31. package/dist/src/FlowerCoreStateFunctions.d.ts +0 -5
  32. package/dist/src/FlowerCoreStateSelectors.d.ts +0 -2
  33. package/dist/src/RulesMatcher.d.ts +0 -5
  34. package/dist/src/devtoolState.d.ts +0 -2
  35. /package/dist/src/{Emitter.d.ts → event-emitter/Emitter.d.ts} +0 -0
@@ -0,0 +1,5 @@
1
+ export declare enum REDUCER_NAME {
2
+ FLOWER_FLOW = "FlowerFlow",
3
+ FLOWER_DATA = "FlowerData"
4
+ }
5
+ export declare const devtoolState: {};
@@ -0,0 +1 @@
1
+ export * from './Emitter';
@@ -1,8 +1,6 @@
1
- export { Emitter } from './Emitter';
2
- export { FlowerCoreReducers } from './FlowerCoreStateFunctions';
3
- export { FlowerStateUtils } from './FlowerCoreStateUtils';
4
- export { FlowerCoreStateSelectors as Selectors } from './FlowerCoreStateSelectors';
5
- export { CoreUtils } from './CoreUtils';
6
- export { MatchRules } from './RulesMatcher';
7
- export { devtoolState } from './devtoolState';
8
- export * from './interfaces';
1
+ export * from './event-emitter';
2
+ export * from './constants';
3
+ export * from './utils';
4
+ export * from './rules-matcher';
5
+ export * from './state-manager';
6
+ export type * from './interfaces';
@@ -47,6 +47,8 @@ export declare enum RulesModes {
47
47
  $or = "$or"
48
48
  }
49
49
  type RulesValuesType<T> = {
50
+ '$data.isValid'?: boolean;
51
+ /** @deprecated use $data.isValid instead */
50
52
  '$form.isValid'?: boolean;
51
53
  } & T;
52
54
  type RulesOperatorsInArray<T> = Partial<{
@@ -74,7 +76,7 @@ export type RulesObject<T> = RulesValuesType<T> | {
74
76
  export type CleanPath = (name: string, char?: string) => string;
75
77
  export type GetPath = (idValue?: string) => {
76
78
  path: string | string[];
77
- flowNameFromPath?: string;
79
+ rootName?: string;
78
80
  };
79
81
  export type AllEqual = (...args: Array<number | string | boolean>[]) => boolean;
80
82
  export type FindValidRule<T = Rules<RulesObject<any>>> = (nextRules: {
@@ -112,7 +114,7 @@ export type MapKeysDeepLodash = (obj: Record<string, any>, cb: (...args: any) =>
112
114
  export type GenerateRulesName = (nextRules: RulesWithName[]) => {
113
115
  [X: string]: string;
114
116
  };
115
- export interface CoreUtilitiesFunctions {
117
+ export interface FlowUtilitiesFunctions {
116
118
  /**
117
119
  *
118
120
  * Generates rule names from a set of rules.
@@ -181,21 +183,6 @@ export interface CoreUtilitiesFunctions {
181
183
  * @returns
182
184
  */
183
185
  generateNodesForFlowerJson: GenerateNodesForFlowerJson;
184
- /**
185
- * Removes specified characters from the beginning of a string (default char -> '^').
186
- * @param name
187
- * @param char
188
- *
189
- * @returns
190
- */
191
- cleanPath: CleanPath;
192
- /**
193
- * Creates a valid path from idValue
194
- * @param idValue
195
- *
196
- * @returns
197
- */
198
- getPath: GetPath;
199
186
  /**
200
187
  * Checks if two arrays are equal in length and have the same elements.
201
188
  * @param arr
@@ -214,4 +201,23 @@ export interface CoreUtilitiesFunctions {
214
201
  */
215
202
  findValidRule: FindValidRule;
216
203
  }
204
+ export interface DataUtilitiesFunctions {
205
+ /**
206
+ * Removes specified characters from the beginning of a string (default char -> '^').
207
+ * @param name
208
+ * @param char
209
+ *
210
+ * @returns
211
+ */
212
+ cleanPath: CleanPath;
213
+ /**
214
+ * Creates a valid path from idValue
215
+ * @param idValue
216
+ *
217
+ * @returns
218
+ */
219
+ getPath: GetPath;
220
+ }
221
+ export interface CoreUtilitiesFunctions extends DataUtilitiesFunctions, FlowUtilitiesFunctions {
222
+ }
217
223
  export {};
@@ -5,11 +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' | 'formFieldFocus' | 'node' | 'prevToNode' | 'next' | 'prev' | 'reset';
9
- /**
10
- * These functions are Redux reducers used in a Flux architecture for managing state transitions and updates in a Flower application.
11
- */
12
- export type ReducersFunctions<T extends Record<string, any> = Record<string, Flower<Record<string, any>>>> = {
8
+ export type CoreReducersFunctions<T extends Record<string, any> = Record<string, Flower<Record<string, any>>>> = {
13
9
  /**
14
10
  * @param state
15
11
  * @param action
@@ -34,18 +30,6 @@ export type ReducersFunctions<T extends Record<string, any> = Record<string, Flo
34
30
  name: string;
35
31
  node: string;
36
32
  } | string>;
37
- /**
38
- * @param state
39
- * @param action
40
- *
41
- * Sets the "touched" state of a form node in a flow.
42
- *
43
- * @returns state
44
- */
45
- setFormTouched: ReducerFunctionSign<T, {
46
- flowName: string;
47
- currentNode: string;
48
- } | string>;
49
33
  /**
50
34
  * @param state
51
35
  * @param action
@@ -143,7 +127,6 @@ export type ReducersFunctions<T extends Record<string, any> = Record<string, Flo
143
127
  startId: string;
144
128
  persist: boolean;
145
129
  nodes: Node[];
146
- initialData: any;
147
130
  initialState: {
148
131
  startId?: string;
149
132
  current?: string;
@@ -166,229 +149,247 @@ export type ReducersFunctions<T extends Record<string, any> = Record<string, Flo
166
149
  * @param state
167
150
  * @param action
168
151
  *
169
- * Adds errors to a form node in a flow.
152
+ * Handles node transitions in a flow, updating history and form states accordingly.
170
153
  *
171
154
  * @returns state
172
155
  */
173
- formAddCustomErrors: ReducerFunctionSign<T, {
156
+ node: ReducerFunctionSign<T, {
174
157
  name: string;
175
- currentNode: string;
176
- id: string;
177
- errors: string[];
158
+ flowName?: string;
159
+ nodeId?: string;
160
+ node?: string;
161
+ history: string[];
178
162
  }>;
179
163
  /**
180
164
  * @param state
181
165
  * @param action
182
166
  *
183
- * Adds errors to a form node in a flow.
167
+ * Navigates to a specific node in the history of a flow.
184
168
  *
185
169
  * @returns state
186
170
  */
187
- formAddErrors: ReducerFunctionSign<T, {
188
- name: string;
189
- currentNode: string;
190
- id: string;
191
- errors: {
192
- [x: string]: string[];
193
- } | string[];
171
+ prevToNode: ReducerFunctionSign<T, {
172
+ name?: string;
173
+ flowName?: string;
174
+ node: string;
194
175
  }>;
195
176
  /**
196
177
  * @param state
197
178
  * @param action
198
179
  *
199
- * Set dirty form single field
180
+ * Moves to the next node in a flow based on validation rules and current state.
200
181
  *
201
182
  * @returns state
202
183
  */
203
- formFieldDirty: ReducerFunctionSign<T, {
204
- name: string;
205
- currentNode: string;
206
- id: string;
207
- dirty?: boolean;
184
+ next: ReducerFunctionSign<T, {
185
+ name?: string;
186
+ flowName?: string;
187
+ route?: string;
188
+ data?: Record<string, any>;
189
+ dataIn?: Record<string, any>;
190
+ isStart?: boolean;
208
191
  }>;
209
192
  /**
210
193
  * @param state
211
194
  * @param action
212
195
  *
213
- * Set touch form single field
196
+ * Moves to the previous node in a flow.
214
197
  *
215
198
  * @returns state
216
199
  */
217
- formFieldTouch: ReducerFunctionSign<T, {
218
- name: string;
219
- currentNode: string;
220
- id: string;
221
- touched?: boolean;
200
+ prev: ReducerFunctionSign<T, {
201
+ name?: string;
202
+ flowName?: string;
222
203
  }>;
223
204
  /**
224
205
  * @param state
225
206
  * @param action
226
207
  *
227
- * Set touch form single field
208
+ * Return back to the first node and resets history.
228
209
  *
229
210
  * @returns state
230
211
  */
231
- formFieldFocus: ReducerFunctionSign<T, {
232
- name: string;
233
- currentNode: string;
234
- id: string;
235
- focused?: boolean;
212
+ restart: ReducerFunctionSign<T, {
213
+ name?: string;
214
+ flowName?: string;
236
215
  }>;
237
216
  /**
238
217
  * @param state
239
218
  * @param action
240
219
  *
241
- * Removes errors from a form node in a flow.
220
+ * Returns back to the first node, resets history and clean all previous data from flow.
242
221
  *
243
222
  * @returns state
244
223
  */
245
- formRemoveErrors: ReducerFunctionSign<T, {
246
- name: string;
247
- currentNode: string;
224
+ reset: ReducerFunctionSign<T, {
225
+ name?: string;
226
+ flowName?: string;
227
+ }
228
+ /**
229
+ * @param state
230
+ * @param action
231
+ *
232
+ * Reset form.
233
+ *
234
+ * @returns state
235
+ */
236
+ >;
237
+ };
238
+ type DataReducerFunctionSign<T extends object, R = object> = (state: Record<string, T>, action: ActionWithPayload<{
239
+ rootName: string;
240
+ } & R>) => Record<string, T> | void;
241
+ export type DataReducersFunctions<T extends Record<string, any> = Record<string, Record<string, any>>> = {
242
+ /**
243
+ * @param state
244
+ * @param action
245
+ *
246
+ * Sets the "touched" state of a form node in a flow.
247
+ *
248
+ * @returns state
249
+ */
250
+ setFormSubmitted: DataReducerFunctionSign<T>;
251
+ /**
252
+ * @param state
253
+ * @param action
254
+ *
255
+ * Adds errors to a form node in a flow.
256
+ *
257
+ * @returns state
258
+ */
259
+ addCustomDataErrors: DataReducerFunctionSign<T, {
248
260
  id: string;
261
+ errors: string[];
249
262
  }>;
250
263
  /**
251
264
  * @param state
252
265
  * @param action
253
266
  *
254
- * Adds data to a flow.
267
+ * Adds errors to a form node in a flow.
255
268
  *
256
269
  * @returns state
257
270
  */
258
- addData: ReducerFunctionSign<T, {
259
- flowName: string;
260
- value: T;
271
+ addDataErrors: DataReducerFunctionSign<T, {
272
+ id: string;
273
+ errors: {
274
+ [x: string]: string[];
275
+ } | string[];
261
276
  }>;
262
277
  /**
263
278
  * @param state
264
279
  * @param action
265
280
  *
266
- * Adds data to a flow at a specific path.
281
+ * Set dirty form single field
267
282
  *
268
283
  * @returns state
269
284
  */
270
- addDataByPath: ReducerFunctionSign<T, {
285
+ fieldDirty: DataReducerFunctionSign<T, {
271
286
  id: string;
272
- flowName: string;
273
- value: T | string;
274
287
  dirty?: boolean;
275
288
  }>;
276
289
  /**
277
290
  * @param state
278
291
  * @param action
279
292
  *
280
- * Replaces the data of a flow with new data.
293
+ * Set touch form single field
281
294
  *
282
295
  * @returns state
283
296
  */
284
- replaceData: ReducerFunctionSign<T, {
285
- flowName: string;
286
- value: T;
297
+ fieldTouch: DataReducerFunctionSign<T, {
298
+ id: string;
299
+ touched?: boolean;
287
300
  }>;
288
301
  /**
289
302
  * @param state
290
303
  * @param action
291
304
  *
292
- * Unsets data from a flow at a specific path.
305
+ * Set touch form single field
293
306
  *
294
307
  * @returns state
295
308
  */
296
- unsetData: ReducerFunctionSign<T, {
297
- id: string[] | string;
298
- flowName: string;
309
+ fieldFocus: DataReducerFunctionSign<T, {
310
+ id: string;
311
+ focused?: boolean;
299
312
  }>;
300
313
  /**
301
314
  * @param state
302
315
  * @param action
303
316
  *
304
- * Sets the "isValidating" state of a form node in a flow.
317
+ * Removes errors from a form node in a flow.
305
318
  *
306
319
  * @returns state
307
320
  */
308
- setFormIsValidating: ReducerFunctionSign<T, {
309
- name: string;
310
- currentNode: string;
311
- isValidating?: boolean;
321
+ removeDataErrors: DataReducerFunctionSign<T, {
322
+ id: string;
312
323
  }>;
313
324
  /**
314
325
  * @param state
315
326
  * @param action
316
327
  *
317
- * Handles node transitions in a flow, updating history and form states accordingly.
328
+ * Adds data to a flow.
318
329
  *
319
330
  * @returns state
320
331
  */
321
- node: ReducerFunctionSign<T, {
322
- name: string;
323
- flowName?: string;
324
- nodeId?: string;
325
- node?: string;
326
- history: string[];
332
+ addData: DataReducerFunctionSign<T, {
333
+ value: T;
327
334
  }>;
328
335
  /**
329
336
  * @param state
330
337
  * @param action
331
338
  *
332
- * Navigates to a specific node in the history of a flow.
339
+ * Adds data to a flow at a specific path.
333
340
  *
334
341
  * @returns state
335
342
  */
336
- prevToNode: ReducerFunctionSign<T, {
337
- name?: string;
338
- flowName?: string;
339
- node: string;
343
+ addDataByPath: DataReducerFunctionSign<T, {
344
+ id: string;
345
+ value: T | string;
346
+ dirty?: boolean;
340
347
  }>;
341
348
  /**
342
349
  * @param state
343
350
  * @param action
344
351
  *
345
- * Moves to the next node in a flow based on validation rules and current state.
352
+ * Replaces the data of a flow with new data.
346
353
  *
347
354
  * @returns state
348
355
  */
349
- next: ReducerFunctionSign<T, {
350
- name?: string;
351
- flowName?: string;
352
- data: T;
353
- route?: string;
356
+ replaceData: DataReducerFunctionSign<T, {
357
+ value: T;
354
358
  }>;
355
359
  /**
356
360
  * @param state
357
361
  * @param action
358
362
  *
359
- * Moves to the previous node in a flow.
363
+ * Unsets data from a flow at a specific path.
360
364
  *
361
365
  * @returns state
362
366
  */
363
- prev: ReducerFunctionSign<T, {
364
- name?: string;
365
- flowName?: string;
367
+ unsetData: DataReducerFunctionSign<T, {
368
+ id: string[] | string;
366
369
  }>;
367
370
  /**
368
371
  * @param state
369
372
  * @param action
370
373
  *
371
- * Return back to the first node and resets history.
374
+ * Sets the "isValidating" state of a form node in a flow.
372
375
  *
373
376
  * @returns state
374
377
  */
375
- restart: ReducerFunctionSign<T, {
376
- name?: string;
377
- flowName?: string;
378
+ setIsDataValidating: DataReducerFunctionSign<T, {
379
+ isValidating?: boolean;
378
380
  }>;
379
381
  /**
380
382
  * @param state
381
383
  * @param action
382
384
  *
383
- * Returns back to the first node, resets history and clean all previous data from flow.
385
+ * Reset form.
384
386
  *
385
387
  * @returns state
386
388
  */
387
- reset: ReducerFunctionSign<T, {
388
- name?: string;
389
- flowName?: string;
389
+ resetData: DataReducerFunctionSign<T, {
390
+ rootName: string;
390
391
  initialData?: Record<string, any>;
391
- }
392
+ }>;
392
393
  /**
393
394
  * @param state
394
395
  * @param action
@@ -397,10 +398,9 @@ export type ReducersFunctions<T extends Record<string, any> = Record<string, Flo
397
398
  *
398
399
  * @returns state
399
400
  */
400
- >;
401
- resetForm: ReducerFunctionSign<T, {
402
- id: string;
403
- flowName: string;
401
+ initData: DataReducerFunctionSign<T, {
402
+ rootName: string;
403
+ initialData: Record<string, any>;
404
404
  }>;
405
405
  };
406
406
  export {};
@@ -1,4 +1,4 @@
1
- import { RulesObject } from '../interfaces/CoreInterface';
1
+ import { RulesObject } from './CoreInterface';
2
2
  export type CheckTypeOf = (v: any) => boolean;
3
3
  export type CheckOperationObj = {
4
4
  op: keyof Operators;
@@ -1,12 +1,13 @@
1
+ import { REDUCER_NAME } from '../constants';
1
2
  import { RulesObject } from './CoreInterface';
2
- import { Flower, Form, INode } from './Store';
3
- export interface ISelectors {
3
+ import { Flower, Data, INode } from './Store';
4
+ export interface IFlowerSelectors {
4
5
  /**
5
6
  * @param state
6
7
  * @returns
7
8
  */
8
9
  selectGlobal<T extends Record<string, any>>(state: {
9
- flower: {
10
+ [REDUCER_NAME.FLOWER_FLOW]: {
10
11
  [x: string]: Flower<T>;
11
12
  };
12
13
  }): {
@@ -19,11 +20,6 @@ export interface ISelectors {
19
20
  selectFlower<T extends Record<string, any>>(name: string): (state: {
20
21
  [x: string]: Flower<T>;
21
22
  }) => Flower<T>;
22
- /**
23
- * @param id
24
- * @returns
25
- */
26
- selectFlowerFormNode<T extends Record<string, any>>(id: string): (state: Flower<T>) => Form<T>;
27
23
  /**
28
24
  * @param flower
29
25
  * @returns
@@ -60,11 +56,29 @@ export interface ISelectors {
60
56
  makeSelectCurrentNodeDisabled<T extends Record<string, any>>(nodes: {
61
57
  [x: string]: Partial<INode>;
62
58
  }, current: Flower<T>['current']): boolean;
59
+ }
60
+ export interface IDataSelectors {
61
+ /**
62
+ * @param state
63
+ * @returns
64
+ */
65
+ selectGlobalReducerByName(name: string): (state: Record<string, Record<string, unknown>>) => Record<string, unknown>;
66
+ /**
67
+ * @param state
68
+ * @returns
69
+ */
70
+ selectGlobalData<T extends Record<string, any>>(state: {
71
+ [REDUCER_NAME.FLOWER_DATA]: {
72
+ [x: string]: Data<T>;
73
+ };
74
+ }): {
75
+ [x: string]: Data<T>;
76
+ };
63
77
  /**
64
- * @param form
78
+ * @param data
65
79
  * @returns
66
80
  */
67
- makeSelectNodeErrors<T extends Record<string, any>>(form: Form<T> | undefined): {
81
+ makeSelectNodeErrors<T extends Record<string, any>>(data: Data<T> | undefined): {
68
82
  isSubmitted: boolean;
69
83
  isDirty: boolean;
70
84
  hasFocus: string | undefined;
@@ -74,35 +88,30 @@ export interface ISelectors {
74
88
  isValidating?: boolean;
75
89
  };
76
90
  /**
77
- * @param form
91
+ * @param data
78
92
  * @returns
79
93
  */
80
- makeSelectNodeFormFieldTouched<T extends Record<string, any>>(id: string): (form: Form<T> | undefined) => boolean | undefined;
94
+ makeSelectNodeDataFieldTouched<T extends Record<string, any>>(id: string): (data: Data<T> | undefined) => boolean | undefined;
81
95
  /**
82
- * @param form
96
+ * @param data
83
97
  * @returns
84
98
  */
85
- makeSelectNodeFormFieldFocused<T extends Record<string, any>>(id: string): (form: Form<T> | undefined) => string | undefined;
99
+ makeSelectNodeDataFieldFocused<T extends Record<string, any>>(id: string): (data: Data<T> | undefined) => string | undefined;
86
100
  /**
87
- * @param form
88
- * @returns
89
- */
90
- makeSelectNodeFormFieldDirty<T extends Record<string, any>>(id: string): (form: Form<T> | undefined) => boolean | undefined;
91
- /**
92
- * @param flower
101
+ * @param data
93
102
  * @returns
94
103
  */
95
- getDataByFlow<T extends Record<string, any>>(flower: Flower<T>): T;
104
+ makeSelectNodeDataFieldDirty<T extends Record<string, any>>(id: string): (data: Data<T> | undefined) => boolean | undefined;
96
105
  /**
97
106
  * @param id
98
107
  * @returns
99
108
  */
100
109
  getDataFromState<T extends Record<string, any>>(id: string | string[]): (data: T) => Partial<T>;
101
110
  /**
102
- * @param form
111
+ * @param data
103
112
  * @returns
104
113
  */
105
- makeSelectNodeFormSubmitted<T extends Record<string, any>>(form: Form<T>): boolean | undefined;
114
+ makeSelectNodeDataSubmitted<T extends Record<string, any>>(data: Data<T>): boolean | undefined;
106
115
  /**
107
116
  * @param name
108
117
  * @param id
@@ -112,7 +121,7 @@ export interface ISelectors {
112
121
  makeSelectFieldError<T extends Record<string, any>>(name: string, id: string, validate: {
113
122
  rules?: RulesObject<any>;
114
123
  message?: string;
115
- }[] | null): (data: T | undefined, form: Form<T>) => Array<string>;
124
+ }[] | null): (globalData: T | undefined, data: Data<T>) => Array<string>;
116
125
  /**
117
126
  * @param id
118
127
  * @param rules
@@ -121,5 +130,5 @@ export interface ISelectors {
121
130
  * @param value
122
131
  * @returns
123
132
  */
124
- selectorRulesDisabled<T extends Record<string, any>>(id: string, rules: any, keys: string[] | null, flowName: string, value: any): (data: T | undefined, form: Form<T>) => boolean;
133
+ selectorRulesDisabled<T extends Record<string, any>>(id: string, rules: any, keys: string[] | null, flowName: string, value: any): (globalData: T | undefined, data: Data<T>) => boolean;
125
134
  }
@@ -1,9 +1,4 @@
1
1
  import { RulesByNodeId } from './CoreInterface';
2
- export interface StoreRoot<T extends Record<string, any>> {
3
- flower: {
4
- [x: string]: Flower<T>;
5
- };
6
- }
7
2
  export interface Flower<T extends Record<string, any>> {
8
3
  persist: boolean;
9
4
  startId: string;
@@ -15,10 +10,6 @@ export interface Flower<T extends Record<string, any>> {
15
10
  nextRules: {
16
11
  [x: string]: RulesByNodeId<T>[];
17
12
  };
18
- data: T;
19
- form: {
20
- [x: string]: Form<T>;
21
- };
22
13
  }
23
14
  export interface INode {
24
15
  nodeId: string;
@@ -26,7 +17,7 @@ export interface INode {
26
17
  retain?: boolean;
27
18
  disabled?: boolean;
28
19
  }
29
- export type Form<T> = {
20
+ export type Data<T extends Record<string, unknown>> = {
30
21
  isSubmitted?: boolean;
31
22
  isDirty?: boolean;
32
23
  hasFocus?: string;
@@ -43,4 +34,5 @@ export type Form<T> = {
43
34
  touches?: {
44
35
  [K in keyof T]: boolean;
45
36
  };
37
+ data?: T;
46
38
  };
@@ -14,7 +14,7 @@ export interface CoreStateUtils {
14
14
  * Selects the form node with a specific ID from a given flow.
15
15
  * It returns a selector function that accepts the state as an argument and retrieves the form node
16
16
  */
17
- selectFlowerFormNode<T extends object>(name: string, id: string): (state: T) => Record<string, any>;
17
+ selectFlowerDataNode<T extends object>(name: string): (state: T) => Record<string, any>;
18
18
  /**
19
19
  *
20
20
  * @param name
@@ -1,5 +1,8 @@
1
1
  export * from './CoreInterface';
2
+ export * from './EmitterInterface';
3
+ export * from './FlatInterface';
2
4
  export * from './ReducerInterface';
5
+ export * from './RulesMatcherInterface';
3
6
  export * from './SelectorsInterface';
4
7
  export * from './Store';
5
8
  export * from './UtilsInterface';
@@ -0,0 +1,2 @@
1
+ import { FunctionRule } from '../interfaces';
2
+ export declare const rulesMatcher: (rules?: Record<string, any> | Record<string, any>[] | FunctionRule, dataValue?: Record<string, any>, apply?: boolean, options?: Record<string, any>) => boolean[];
@@ -0,0 +1,2 @@
1
+ export { rulesMatcher } from './RulesMatcher';
2
+ export { rulesMatcherUtils } from './utils';