@form-flow/core 2.0.0 → 2.0.2
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
|
@@ -34,6 +34,64 @@ pnpm add @form-flow/core
|
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
37
|
+
## Breaking Changes v2.0.0
|
|
38
|
+
|
|
39
|
+
### `FieldControlType` is now generic
|
|
40
|
+
|
|
41
|
+
`FieldControlType` no longer represents only the built-in control types. It now accepts custom control types through a generic parameter.
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
type FieldControlType<TCustom extends string = never> =
|
|
45
|
+
BuiltInFieldControlType | Exclude<TCustom, BuiltInFieldControlType>;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This means:
|
|
49
|
+
|
|
50
|
+
- use `BuiltInFieldControlType` when you need the built-in union only
|
|
51
|
+
- use `FieldControlType<"myCustomType" | "anotherType">` for built-in + custom types
|
|
52
|
+
- stop using `CustomFieldControlType` in new code; it is still exported only as a deprecated compatibility alias
|
|
53
|
+
|
|
54
|
+
Migration examples:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
// Before
|
|
58
|
+
type BuiltInOnly = FieldControlType;
|
|
59
|
+
type AllControls = CustomFieldControlType<"rating" | "currency">;
|
|
60
|
+
|
|
61
|
+
// After
|
|
62
|
+
type BuiltInOnly = BuiltInFieldControlType;
|
|
63
|
+
type AllControls = FieldControlType<"rating" | "currency">;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Custom field definition example:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
type AppFieldTypes = "switch" | "slider" | "radio";
|
|
70
|
+
|
|
71
|
+
const fields: FieldDefinition<AppFieldTypes>[] = [
|
|
72
|
+
|
|
73
|
+
];
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
If your code relied on `FieldControlType` being built-in only, this is a breaking change and you should migrate those usages to `BuiltInFieldControlType`.
|
|
77
|
+
|
|
78
|
+
### `FORM_FLOW_OPERATORS_MAP` is no longer publicly exported
|
|
79
|
+
|
|
80
|
+
The package root no longer exposes `FORM_FLOW_OPERATORS_MAP` as part of the public API.
|
|
81
|
+
|
|
82
|
+
Use `FormFlowOperatorRegistry` instead:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { FormFlowOperatorRegistry } from "@form-flow/core";
|
|
86
|
+
|
|
87
|
+
const operators = FormFlowOperatorRegistry.getAll();
|
|
88
|
+
const eqOperator = FormFlowOperatorRegistry.get("eq");
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
If you were importing `FORM_FLOW_OPERATORS_MAP` from `@form-flow/core`, this is a breaking change and you should migrate those usages to `FormFlowOperatorRegistry`.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
37
95
|
## 📖 Quick Start
|
|
38
96
|
|
|
39
97
|
### Basic Example
|
|
@@ -231,26 +289,37 @@ console.log(availableRules); // ["disabledIf", "readonlyIf"]
|
|
|
231
289
|
### Type Definitions
|
|
232
290
|
|
|
233
291
|
```ts
|
|
234
|
-
type
|
|
292
|
+
type BuiltInFieldControlType =
|
|
293
|
+
| "text"
|
|
294
|
+
| "number"
|
|
295
|
+
| "date"
|
|
296
|
+
| "singleSelect"
|
|
297
|
+
| "multipleSelect"
|
|
298
|
+
| "checkbox";
|
|
299
|
+
|
|
300
|
+
type FieldControlType<TCustom extends string = never> =
|
|
301
|
+
BuiltInFieldControlType | Exclude<TCustom, BuiltInFieldControlType>;
|
|
302
|
+
|
|
303
|
+
type BaseFieldDefinition<TCustom extends string = never> = {
|
|
235
304
|
id: string;
|
|
236
|
-
type:
|
|
305
|
+
type: FieldControlType<TCustom>;
|
|
237
306
|
label: string;
|
|
238
307
|
};
|
|
239
308
|
|
|
240
309
|
// Field with conditional rules
|
|
241
|
-
type FieldDefinition<
|
|
310
|
+
type FieldDefinition<TCustom extends string = never> = BaseFieldDefinition<TCustom> & {
|
|
242
311
|
visibleIf?: FieldRuleGroupDefinition;
|
|
243
312
|
requiredIf?: FieldRuleGroupDefinition;
|
|
244
313
|
disabledIf?: FieldRuleGroupDefinition;
|
|
245
314
|
readonlyIf?: FieldRuleGroupDefinition;
|
|
246
315
|
};
|
|
247
316
|
|
|
248
|
-
type RuleContextFieldDefinition<
|
|
317
|
+
type RuleContextFieldDefinition<TCustom extends string = never> = BaseFieldDefinition<TCustom>;
|
|
249
318
|
|
|
250
|
-
type FormFlowDefinition<
|
|
319
|
+
type FormFlowDefinition<TCustom extends string = never> = {
|
|
251
320
|
formId: string;
|
|
252
|
-
fields: FieldDefinition<
|
|
253
|
-
ruleContextFields?: RuleContextFieldDefinition<
|
|
321
|
+
fields: FieldDefinition<TCustom>[];
|
|
322
|
+
ruleContextFields?: RuleContextFieldDefinition<TCustom>[];
|
|
254
323
|
};
|
|
255
324
|
|
|
256
325
|
// Atomic rule
|
|
@@ -3,16 +3,16 @@ export declare const OperatorRegistry: {
|
|
|
3
3
|
/**
|
|
4
4
|
* Get the definition of a specific operator by key.
|
|
5
5
|
*/
|
|
6
|
-
get: (key: RuleOperatorKey) => RuleOperatorMeta | undefined;
|
|
6
|
+
get: <TCustom extends string = never>(key: RuleOperatorKey) => RuleOperatorMeta<TCustom> | undefined;
|
|
7
7
|
/**
|
|
8
8
|
* Get all operator definitions (e.g., for building UI pickers).
|
|
9
9
|
*/
|
|
10
|
-
getAll: () => RuleOperatorsMap
|
|
10
|
+
getAll: <TCustom extends string = never>() => RuleOperatorsMap<TCustom>;
|
|
11
11
|
/**
|
|
12
12
|
* Register one or more operator overrides or additions.
|
|
13
13
|
* Existing operators with the same key will be replaced.
|
|
14
14
|
*/
|
|
15
|
-
register: (overrides: RuleOperatorsMap) => void;
|
|
15
|
+
register: <TCustom extends string = never>(overrides: RuleOperatorsMap<TCustom>) => void;
|
|
16
16
|
/**
|
|
17
17
|
* Reset the registry to the original default operator map.
|
|
18
18
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator-registry.d.ts","sourceRoot":"","sources":["../../src/models/operator-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK3G,eAAO,MAAM,gBAAgB;IACzB;;OAEG;
|
|
1
|
+
{"version":3,"file":"operator-registry.d.ts","sourceRoot":"","sources":["../../src/models/operator-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK3G,eAAO,MAAM,gBAAgB;IACzB;;OAEG;UACG,OAAO,SAAS,MAAM,eAAe,eAAe,KAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,SAAS;IAElG;;OAEG;aACM,OAAO,SAAS,MAAM,eAAa,gBAAgB,CAAC,OAAO,CAAC;IAErE;;;OAGG;eACQ,OAAO,SAAS,MAAM,qBAAqB,gBAAgB,CAAC,OAAO,CAAC;IAI/E;;OAEG;;CAIN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator-registry.js","sourceRoot":"","sources":["../../src/models/operator-registry.ts"],"names":[],"mappings":";;;AAAA,uBAAuB;AACvB,2CAA2G;AAE3G,4CAA4C;AAC5C,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"file":"operator-registry.js","sourceRoot":"","sources":["../../src/models/operator-registry.ts"],"names":[],"mappings":";;;AAAA,uBAAuB;AACvB,2CAA2G;AAE3G,4CAA4C;AAC5C,IAAI,QAAQ,GAA6B,EAAE,GAAG,mCAAuB,EAAE,CAAC;AAE3D,QAAA,gBAAgB,GAAG;IAC5B;;OAEG;IACH,GAAG,EAAE,CAAiC,GAAoB,EAAyC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAA8B;IAEhJ;;OAEG;IACH,MAAM,EAAE,GAA8D,EAAE,CAAC,QAAqC;IAE9G;;;OAGG;IACH,QAAQ,EAAE,CAAiC,SAAoC,EAAE,EAAE;QAC/E,QAAQ,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,KAAK,EAAE,GAAG,EAAE;QACR,QAAQ,GAAG,EAAE,GAAG,mCAAuB,EAAE,CAAC;IAC9C,CAAC;CACJ,CAAC"}
|
package/package.json
CHANGED