@form-flow/core 2.0.2 → 2.0.4
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 +52 -1
- package/dist/models/operator-registry.d.ts +15 -1
- package/dist/models/operator-registry.d.ts.map +1 -1
- package/dist/models/operator-registry.js +41 -1
- package/dist/models/operator-registry.js.map +1 -1
- package/dist/models/operators.d.ts +4 -0
- package/dist/models/operators.d.ts.map +1 -1
- package/dist/models/operators.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,8 @@ pnpm add @form-flow/core
|
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
## Breaking Changes v2.0.0 20/03/2026
|
|
38
39
|
|
|
39
40
|
### `FieldControlType` is now generic
|
|
40
41
|
|
|
@@ -92,6 +93,56 @@ If you were importing `FORM_FLOW_OPERATORS_MAP` from `@form-flow/core`, this is
|
|
|
92
93
|
|
|
93
94
|
---
|
|
94
95
|
|
|
96
|
+
## 🆕 Patch Updates v2.x
|
|
97
|
+
|
|
98
|
+
### `v2.0.1`
|
|
99
|
+
|
|
100
|
+
- Improved type safety for `FormFlowOperatorRegistry.get()` and `FormFlowOperatorRegistry.getAll()`
|
|
101
|
+
- Better generic inference when working with custom field control types
|
|
102
|
+
|
|
103
|
+
### `v2.0.2`
|
|
104
|
+
|
|
105
|
+
- Added `disallowedTypes` to `RuleOperatorMeta`
|
|
106
|
+
- You can now keep an operator broadly available with `allowedTypes` and explicitly exclude specific control types
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
const operators = FormFlowOperatorRegistry.getAll<"switch">();
|
|
110
|
+
|
|
111
|
+
operators.truthy = {
|
|
112
|
+
label: "Is truthy",
|
|
113
|
+
allowedTypes: "all",
|
|
114
|
+
disallowedTypes: ["switch"]
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `v2.0.3`
|
|
119
|
+
|
|
120
|
+
- Patch release for the `2.0.2` operator filtering improvements
|
|
121
|
+
- No additional public API changes compared to `v2.0.2`
|
|
122
|
+
|
|
123
|
+
### Next patch in current branch
|
|
124
|
+
|
|
125
|
+
Based on the most recent commits after `v2.0.3`, the next `2.x` patch will also include:
|
|
126
|
+
|
|
127
|
+
- `FormFlowOperatorRegistry.patch()` to partially override existing operators without redefining the full object
|
|
128
|
+
- `FormFlowOperatorRegistry.excludeFieldTypes()` to exclude one or more field types from multiple operators in a single call
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
import { FormFlowOperatorRegistry } from "@form-flow/core";
|
|
132
|
+
|
|
133
|
+
FormFlowOperatorRegistry.patch({
|
|
134
|
+
eq: { hideFromPicker: true },
|
|
135
|
+
neq: { hideFromPicker: true }
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
FormFlowOperatorRegistry.excludeFieldTypes(
|
|
139
|
+
["switch"],
|
|
140
|
+
["isTrue", "isFalse", "truthy"]
|
|
141
|
+
);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
95
146
|
## 📖 Quick Start
|
|
96
147
|
|
|
97
148
|
### Basic Example
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FieldControlType } from "./field-definition";
|
|
2
|
+
import { RuleOperatorKey, RuleOperatorMeta, RuleOperatorPatches, RuleOperatorsMap } from "./operators";
|
|
2
3
|
export declare const OperatorRegistry: {
|
|
3
4
|
/**
|
|
4
5
|
* Get the definition of a specific operator by key.
|
|
@@ -17,5 +18,18 @@ export declare const OperatorRegistry: {
|
|
|
17
18
|
* Reset the registry to the original default operator map.
|
|
18
19
|
*/
|
|
19
20
|
reset: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Use this for override existing operators even partially.
|
|
23
|
+
* @example OperatorRegistry.patch({
|
|
24
|
+
eq: { hideFromPicker: true },
|
|
25
|
+
neq: { hideFromPicker: true },
|
|
26
|
+
});
|
|
27
|
+
*/
|
|
28
|
+
patch: <TCustom extends string = never>(overrides: RuleOperatorPatches<TCustom>) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Helper for easily exclude a `fieldType` from multiple operators
|
|
31
|
+
* @example OperatorRegistry.excludeFieldTypes(["switch"], ["isTrue", "isFalse", "truthy"]);
|
|
32
|
+
*/
|
|
33
|
+
excludeFieldTypes: <TCustom extends string = never>(fieldTypes: FieldControlType<TCustom>[], operators: RuleOperatorKey[]) => void;
|
|
20
34
|
};
|
|
21
35
|
//# sourceMappingURL=operator-registry.d.ts.map
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"operator-registry.d.ts","sourceRoot":"","sources":["../../src/models/operator-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAA2B,eAAe,EAAE,gBAAgB,EAAyB,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKvJ,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;;IAIH;;;;;;OAMG;YACK,OAAO,SAAS,MAAM,qBAAqB,mBAAmB,CAAC,OAAO,CAAC;IAsB/E;;;OAGG;wBACiB,OAAO,SAAS,MAAM,sBAC1B,gBAAgB,CAAC,OAAO,CAAC,EAAE,aAC5B,eAAe,EAAE;CAoBnC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OperatorRegistry = void 0;
|
|
4
|
-
// operator-registry.ts
|
|
5
4
|
const operators_1 = require("./operators");
|
|
6
5
|
// Mutable copy of the original operator map
|
|
7
6
|
let registry = { ...operators_1.FORM_FLOW_OPERATORS_MAP };
|
|
@@ -27,5 +26,46 @@ exports.OperatorRegistry = {
|
|
|
27
26
|
reset: () => {
|
|
28
27
|
registry = { ...operators_1.FORM_FLOW_OPERATORS_MAP };
|
|
29
28
|
},
|
|
29
|
+
/**
|
|
30
|
+
* Use this for override existing operators even partially.
|
|
31
|
+
* @example OperatorRegistry.patch({
|
|
32
|
+
eq: { hideFromPicker: true },
|
|
33
|
+
neq: { hideFromPicker: true },
|
|
34
|
+
});
|
|
35
|
+
*/
|
|
36
|
+
patch: (overrides) => {
|
|
37
|
+
const next = { ...registry };
|
|
38
|
+
for (const [key, patch] of Object.entries(overrides)) {
|
|
39
|
+
const current = next[key];
|
|
40
|
+
if (!current) {
|
|
41
|
+
throw new Error(`Cannot patch unknown operator "${key}". Use register() instead.`);
|
|
42
|
+
}
|
|
43
|
+
next[key] = {
|
|
44
|
+
...current,
|
|
45
|
+
...patch,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
registry = next;
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Helper for easily exclude a `fieldType` from multiple operators
|
|
52
|
+
* @example OperatorRegistry.excludeFieldTypes(["switch"], ["isTrue", "isFalse", "truthy"]);
|
|
53
|
+
*/
|
|
54
|
+
excludeFieldTypes: (fieldTypes, operators) => {
|
|
55
|
+
const next = { ...registry };
|
|
56
|
+
for (const key of operators) {
|
|
57
|
+
const current = next[key];
|
|
58
|
+
if (!current)
|
|
59
|
+
continue;
|
|
60
|
+
next[key] = {
|
|
61
|
+
...current,
|
|
62
|
+
disallowedTypes: [
|
|
63
|
+
...(current.disallowedTypes ?? []),
|
|
64
|
+
...fieldTypes,
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
registry = next;
|
|
69
|
+
},
|
|
30
70
|
};
|
|
31
71
|
//# sourceMappingURL=operator-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator-registry.js","sourceRoot":"","sources":["../../src/models/operator-registry.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"operator-registry.js","sourceRoot":"","sources":["../../src/models/operator-registry.ts"],"names":[],"mappings":";;;AAEA,2CAAuJ;AAEvJ,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;IACD;;;;;;OAMG;IACH,KAAK,EAAE,CAAiC,SAAuC,EAAE,EAAE;QAC/E,MAAM,IAAI,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;QAE7B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAGhD,EAAE,CAAC;YACF,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YAE1B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,MAAM,IAAI,KAAK,CAAC,kCAAkC,GAAG,4BAA4B,CAAC,CAAC;YACvF,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,GAAG;gBACR,GAAG,OAAO;gBACV,GAAG,KAAK;aACX,CAAC;QACN,CAAC;QAED,QAAQ,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,iBAAiB,EAAE,CACf,UAAuC,EACvC,SAA4B,EAC9B,EAAE;QACA,MAAM,IAAI,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;QAE7B,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YAC1B,IAAI,CAAC,OAAO;gBAAE,SAAS;YAEvB,IAAI,CAAC,GAAG,CAAC,GAAG;gBACR,GAAG,OAAO;gBACV,eAAe,EAAE;oBACb,GAAG,CAAC,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;oBAClC,GAAG,UAAU;iBAChB;aACJ,CAAC;QACN,CAAC;QAED,QAAQ,GAAG,IAAI,CAAC;IACpB,CAAC;CAEJ,CAAC"}
|
|
@@ -29,11 +29,15 @@ export interface RuleOperatorMeta<TCustom extends string = never> {
|
|
|
29
29
|
label: string;
|
|
30
30
|
/** Which field types this operator is allowed for. */
|
|
31
31
|
allowedTypes?: FieldControlType<TCustom>[] | "all";
|
|
32
|
+
/** Exclude field types by using this operator */
|
|
33
|
+
disallowedTypes?: FieldControlType<TCustom>[];
|
|
32
34
|
/** The type of value this operator requires. */
|
|
33
35
|
valueType?: RuleOperatorValueType;
|
|
34
36
|
/** If true, the operator will be hidden from the UI picker. */
|
|
35
37
|
hideFromPicker?: boolean;
|
|
36
38
|
}
|
|
39
|
+
export type RuleOperatorMetaPatch<TCustom extends string = never> = Partial<RuleOperatorMeta<TCustom>>;
|
|
40
|
+
export type RuleOperatorPatches<TCustom extends string = never> = Partial<Record<RuleOperatorKey, RuleOperatorMetaPatch<TCustom>>>;
|
|
37
41
|
export type RuleOperatorsMap<TCustom extends string = never> = Partial<Record<RuleOperatorKey, RuleOperatorMeta<TCustom>>>;
|
|
38
42
|
/**
|
|
39
43
|
* Default operator map shipped with `@form-flow/core`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../../src/models/operators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD;;GAEG;AACH,KAAK,gBAAgB,GAAG,MAAM,OAAO,WAAW,CAAC,KAAK,CAAC;AAEvD;;GAEG;AACH,KAAK,mBAAmB,GAAG,KAAK,CAAC;AAEjC;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAC7B,MAAM,GACN,QAAQ,GACR,MAAM,GACN,OAAO,GACP,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,OAAO,SAAS,MAAM,GAAG,KAAK;IAC9D,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IAEd,sDAAsD;IACtD,YAAY,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC;IAEnD,gDAAgD;IAChD,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAElC,+DAA+D;IAC/D,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,MAAM,gBAAgB,CAAC,OAAO,SAAS,MAAM,GAAG,KAAK,IACzD,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,gBAoBrC,CAAC"}
|
|
1
|
+
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../../src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,CAAC,CAAC,CAAC,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,gBAoBrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operators.js","sourceRoot":"","sources":["../../src/models/operators.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"operators.js","sourceRoot":"","sources":["../../src/models/operators.ts"],"names":[],"mappings":";;;AA6DA;;;GAGG;AACU,QAAA,uBAAuB,GAAqB;IACvD,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE;IACjE,GAAG,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE;IACxE,EAAE,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE;IACpF,GAAG,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE;IACjG,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE;IACjF,GAAG,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE;IAC9F,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE;IAC9D,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE;IACzF,OAAO,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