@form-flow/core 2.0.0 → 2.0.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 (2) hide show
  1. package/README.md +76 -7
  2. package/package.json +1 -1
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 BaseFieldDefinition<T = any> = {
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: string;
305
+ type: FieldControlType<TCustom>;
237
306
  label: string;
238
307
  };
239
308
 
240
309
  // Field with conditional rules
241
- type FieldDefinition<T = any> = BaseFieldDefinition<T> & {
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<T = any> = BaseFieldDefinition<T>;
317
+ type RuleContextFieldDefinition<TCustom extends string = never> = BaseFieldDefinition<TCustom>;
249
318
 
250
- type FormFlowDefinition<T = any> = {
319
+ type FormFlowDefinition<TCustom extends string = never> = {
251
320
  formId: string;
252
- fields: FieldDefinition<T>[];
253
- ruleContextFields?: RuleContextFieldDefinition<T>[];
321
+ fields: FieldDefinition<TCustom>[];
322
+ ruleContextFields?: RuleContextFieldDefinition<TCustom>[];
254
323
  };
255
324
 
256
325
  // Atomic rule
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@form-flow/core",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "TypeScript engine for conditional UI states (visible, required, disabled, readonly) on form fields",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",