@molecule/app-rule-builder-solid 0.0.0-stage → 0.0.1-stage
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/LICENSE +202 -0
- package/README.md +10 -2
- package/dist/RuleBuilder.d.ts +28 -0
- package/dist/RuleBuilder.d.ts.map +1 -0
- package/dist/RuleBuilder.jsx +248 -0
- package/dist/RuleBuilder.jsx.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/operators.d.ts +61 -0
- package/dist/operators.d.ts.map +1 -0
- package/dist/operators.js +98 -0
- package/dist/operators.js.map +1 -0
- package/dist/types.d.ts +138 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/utilities.d.ts +67 -0
- package/dist/utilities.d.ts.map +1 -0
- package/dist/utilities.js +108 -0
- package/dist/utilities.js.map +1 -0
- package/package.json +67 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @molecule/app-rule-builder-solid
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Visual condition / rule builder — nested AND / OR groups of field-operator-value leaves, used for feature-flag targeting, automation triggers, segmentation, and IoT scenarios
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install @molecule/app-rule-builder-solid
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Part of the [Molecule](https://www.molecule.dev) package fleet. This page carries the manifest summary; the full generated documentation ships with the package's first committed version.
|
|
10
|
+
|
|
11
|
+
License: Apache-2.0
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<RuleBuilder>` — visual condition / rule builder.
|
|
3
|
+
*
|
|
4
|
+
* Renders a recursive AND / OR group tree with field → operator → value
|
|
5
|
+
* leaves. Used by feature-flag-manager (target-audience rules),
|
|
6
|
+
* ai-workflow-automator (trigger conditions), email-marketing
|
|
7
|
+
* (segment definitions), iot-device-manager (automation rules), and
|
|
8
|
+
* smart-home-dashboard (scene triggers).
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { type Component } from 'solid-js';
|
|
13
|
+
import type { RuleBuilderProps } from './types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Visual rule / predicate builder. The rendered tree is a recursive
|
|
16
|
+
* `RuleGroup` of `RuleLeaf` predicates joined by `AND` or `OR`. The
|
|
17
|
+
* component is fully controlled — every interaction emits a new root
|
|
18
|
+
* rule via `onChange`.
|
|
19
|
+
*
|
|
20
|
+
* This is the Solid counterpart of `@molecule/app-rule-builder-react`'s
|
|
21
|
+
* `RuleBuilder`: the same props (React names), the same ClassMap tokens, and
|
|
22
|
+
* the same DOM for the same input.
|
|
23
|
+
*
|
|
24
|
+
* @param props - Component props (see {@link RuleBuilderProps}).
|
|
25
|
+
* @returns The rendered rule builder.
|
|
26
|
+
*/
|
|
27
|
+
export declare const RuleBuilder: Component<RuleBuilderProps>;
|
|
28
|
+
//# sourceMappingURL=RuleBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuleBuilder.d.ts","sourceRoot":"","sources":["../src/RuleBuilder.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,UAAU,CAAA;AAQpD,OAAO,KAAK,EAEV,gBAAgB,EAMjB,MAAM,YAAY,CAAA;AAyXnB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,gBAAgB,CA4BnD,CAAA"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<RuleBuilder>` — visual condition / rule builder.
|
|
3
|
+
*
|
|
4
|
+
* Renders a recursive AND / OR group tree with field → operator → value
|
|
5
|
+
* leaves. Used by feature-flag-manager (target-audience rules),
|
|
6
|
+
* ai-workflow-automator (trigger conditions), email-marketing
|
|
7
|
+
* (segment definitions), iot-device-manager (automation rules), and
|
|
8
|
+
* smart-home-dashboard (scene triggers).
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { For, Show } from 'solid-js';
|
|
13
|
+
import { useTranslation } from '@molecule/app-solid';
|
|
14
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
15
|
+
import { Button, Input, Select } from '@molecule/app-ui-solid';
|
|
16
|
+
import { operatorById, operatorsFor } from './operators.js';
|
|
17
|
+
import { appendToGroup, emptyGroup, emptyLeaf, removeById, replaceById, toggleGroupOp, } from './utilities.js';
|
|
18
|
+
/**
|
|
19
|
+
* Converts a React-style style object (camelCase keys) into the kebab-case
|
|
20
|
+
* object Solid's style runtime applies through `setProperty`, so the rendered
|
|
21
|
+
* inline style matches React's byte for byte.
|
|
22
|
+
*
|
|
23
|
+
* @param style - The ClassMap spacing record (`cm.sp(...)`).
|
|
24
|
+
* @returns The kebab-case style record.
|
|
25
|
+
*/
|
|
26
|
+
const styleProps = (style) => Object.fromEntries(Object.entries(style).map(([key, value]) => [
|
|
27
|
+
key.startsWith('--') ? key : key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`),
|
|
28
|
+
value,
|
|
29
|
+
]));
|
|
30
|
+
/**
|
|
31
|
+
* Reads the string a native input event carries.
|
|
32
|
+
*
|
|
33
|
+
* @param event - The native input event.
|
|
34
|
+
* @returns The input's current value.
|
|
35
|
+
*/
|
|
36
|
+
const inputValue = (event) => event.target.value;
|
|
37
|
+
/**
|
|
38
|
+
* Render one group: the `AND` / `OR` toggle row, the children, and the
|
|
39
|
+
* "Add condition" / "Add group" buttons.
|
|
40
|
+
*
|
|
41
|
+
* @param props - Group renderer props.
|
|
42
|
+
* @returns The rendered group.
|
|
43
|
+
*/
|
|
44
|
+
const Group = (props) => {
|
|
45
|
+
const cm = getClassMap();
|
|
46
|
+
const { t } = useTranslation();
|
|
47
|
+
const toggle = () => {
|
|
48
|
+
props.onReplace(toggleGroupOp(props.group, props.group.id));
|
|
49
|
+
};
|
|
50
|
+
const addCondition = () => {
|
|
51
|
+
props.onReplace(appendToGroup(props.group, props.group.id, emptyLeaf()));
|
|
52
|
+
};
|
|
53
|
+
const addGroup = () => {
|
|
54
|
+
props.onReplace(appendToGroup(props.group, props.group.id, emptyGroup()));
|
|
55
|
+
};
|
|
56
|
+
const removeChild = (childId) => {
|
|
57
|
+
props.onReplace(removeById(props.group, childId));
|
|
58
|
+
};
|
|
59
|
+
const replaceChild = (childId, next) => {
|
|
60
|
+
props.onReplace(replaceById(props.group, childId, next));
|
|
61
|
+
};
|
|
62
|
+
const opLabel = () => props.group.op === 'AND'
|
|
63
|
+
? t('ruleBuilder.op.and', {}, { defaultValue: 'AND' })
|
|
64
|
+
: t('ruleBuilder.op.or', {}, { defaultValue: 'OR' });
|
|
65
|
+
return (<div class={cm.cn(cm.flex({ direction: 'col', gap: 'xs' }), cm.borderAll, cm.surface)} style={styleProps(cm.sp({ p: 3 }))} data-mol-id={`rule-builder-group-${props.group.id}`} data-group-op={props.group.op}>
|
|
66
|
+
<div class={cm.flex({ align: 'center', gap: 'xs' })}>
|
|
67
|
+
<Button variant="outline" size="sm" onClick={toggle} aria-label={t('ruleBuilder.aria.toggleOp', {}, { defaultValue: 'Toggle AND / OR' })} data-mol-id={`rule-builder-group-${props.group.id}-toggle`}>
|
|
68
|
+
{opLabel()}
|
|
69
|
+
</Button>
|
|
70
|
+
<span class={cm.cn(cm.textSize('xs'), cm.textMuted)}>
|
|
71
|
+
{props.group.op === 'AND'
|
|
72
|
+
? t('ruleBuilder.help.allMustMatch', {}, { defaultValue: 'All conditions must match' })
|
|
73
|
+
: t('ruleBuilder.help.anyMustMatch', {}, { defaultValue: 'Any condition may match' })}
|
|
74
|
+
</span>
|
|
75
|
+
<Show when={!props.isRoot}>
|
|
76
|
+
<Button variant="ghost" size="sm" onClick={props.onRemove} aria-label={t('ruleBuilder.aria.removeGroup', {}, { defaultValue: 'Remove group' })} data-mol-id={`rule-builder-group-${props.group.id}-remove`}>
|
|
77
|
+
{t('ruleBuilder.action.removeGroup', {}, { defaultValue: 'Remove group' })}
|
|
78
|
+
</Button>
|
|
79
|
+
</Show>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<div class={cm.flex({ direction: 'col', gap: 'xs' })} style={styleProps(cm.sp({ p: 2 }))}>
|
|
83
|
+
<For each={props.group.children}>
|
|
84
|
+
{(child) => (<Show when={child.kind === 'group'} fallback={<Leaf leaf={child} schema={props.schema} onReplace={(next) => replaceChild(child.id, next)} onRemove={() => removeChild(child.id)}/>}>
|
|
85
|
+
<Group group={child} schema={props.schema} onReplace={(next) => replaceChild(child.id, next)} onRemove={() => removeChild(child.id)}/>
|
|
86
|
+
</Show>)}
|
|
87
|
+
</For>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div class={cm.flex({ align: 'center', gap: 'xs' })}>
|
|
91
|
+
<Button variant="outline" size="sm" onClick={addCondition} data-mol-id={`rule-builder-group-${props.group.id}-add-condition`}>
|
|
92
|
+
{t('ruleBuilder.action.addCondition', {}, { defaultValue: '+ Add condition' })}
|
|
93
|
+
</Button>
|
|
94
|
+
<Button variant="ghost" size="sm" onClick={addGroup} data-mol-id={`rule-builder-group-${props.group.id}-add-group`}>
|
|
95
|
+
{t('ruleBuilder.action.addGroup', {}, { defaultValue: '+ Add group' })}
|
|
96
|
+
</Button>
|
|
97
|
+
</div>
|
|
98
|
+
</div>);
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Render the value-side input(s) for a leaf, picking between
|
|
102
|
+
* text / number / date / select / boolean editors based on the field's
|
|
103
|
+
* `type` and the operator's `arity`.
|
|
104
|
+
*
|
|
105
|
+
* @param props - Value-editor props.
|
|
106
|
+
* @returns The rendered value editor.
|
|
107
|
+
*/
|
|
108
|
+
const ValueEditor = (props) => {
|
|
109
|
+
const cm = getClassMap();
|
|
110
|
+
const { t } = useTranslation();
|
|
111
|
+
/** The `[from, to]` tuple, falling back to empty values. */
|
|
112
|
+
const tuple = () => {
|
|
113
|
+
const value = props.value;
|
|
114
|
+
if (Array.isArray(value) && value.length === 2)
|
|
115
|
+
return value;
|
|
116
|
+
return props.field.type === 'number' ? [0, 0] : ['', ''];
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* The input type the field renders.
|
|
120
|
+
*
|
|
121
|
+
* @returns The native input type.
|
|
122
|
+
*/
|
|
123
|
+
const inputType = () => props.field.type === 'date' ? 'date' : props.field.type === 'number' ? 'number' : 'text';
|
|
124
|
+
const setFrom = (v) => {
|
|
125
|
+
const current = tuple();
|
|
126
|
+
props.onChange((props.field.type === 'number'
|
|
127
|
+
? [Number(v), current[1]]
|
|
128
|
+
: [v, current[1]]));
|
|
129
|
+
};
|
|
130
|
+
const setTo = (v) => {
|
|
131
|
+
const current = tuple();
|
|
132
|
+
props.onChange((props.field.type === 'number'
|
|
133
|
+
? [current[0], Number(v)]
|
|
134
|
+
: [current[0], v]));
|
|
135
|
+
};
|
|
136
|
+
return (<>
|
|
137
|
+
<Show when={props.arity === 'between'}>
|
|
138
|
+
<span class={cm.flex({ align: 'center', gap: 'xs' })}>
|
|
139
|
+
<Input type={inputType()} value={String(tuple()[0] ?? '')} onChange={(event) => setFrom(inputValue(event))} aria-label={t('ruleBuilder.aria.valueFrom', {}, { defaultValue: 'From' })}/>
|
|
140
|
+
<span>{t('ruleBuilder.between.separator', {}, { defaultValue: '–' })}</span>
|
|
141
|
+
<Input type={inputType()} value={String(tuple()[1] ?? '')} onChange={(event) => setTo(inputValue(event))} aria-label={t('ruleBuilder.aria.valueTo', {}, { defaultValue: 'To' })}/>
|
|
142
|
+
</span>
|
|
143
|
+
</Show>
|
|
144
|
+
<Show when={props.arity !== 'between' && props.field.type === 'select'}>
|
|
145
|
+
<Select value={typeof props.value === 'string' ? props.value : ''} onValueChange={(v) => props.onChange(v)} options={props.field.options ?? []} aria-label={t('ruleBuilder.aria.value', {}, { defaultValue: 'Value' })}/>
|
|
146
|
+
</Show>
|
|
147
|
+
<Show when={props.arity !== 'between' && props.field.type === 'boolean'}>
|
|
148
|
+
<Select value={props.value === true ? 'true' : props.value === false ? 'false' : ''} onValueChange={(v) => props.onChange(v === 'true')} options={[
|
|
149
|
+
{ value: 'true', label: t('ruleBuilder.boolean.true', {}, { defaultValue: 'true' }) },
|
|
150
|
+
{
|
|
151
|
+
value: 'false',
|
|
152
|
+
label: t('ruleBuilder.boolean.false', {}, { defaultValue: 'false' }),
|
|
153
|
+
},
|
|
154
|
+
]} aria-label={t('ruleBuilder.aria.value', {}, { defaultValue: 'Value' })}/>
|
|
155
|
+
</Show>
|
|
156
|
+
<Show when={props.arity !== 'between' &&
|
|
157
|
+
props.field.type !== 'select' &&
|
|
158
|
+
props.field.type !== 'boolean'}>
|
|
159
|
+
<Input type={inputType()} value={props.value === undefined ? '' : String(props.value)} onChange={(event) => {
|
|
160
|
+
const raw = inputValue(event);
|
|
161
|
+
props.onChange(props.field.type === 'number' ? Number(raw) : raw);
|
|
162
|
+
}} placeholder={props.field.placeholder} aria-label={t('ruleBuilder.aria.value', {}, { defaultValue: 'Value' })}/>
|
|
163
|
+
</Show>
|
|
164
|
+
</>);
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Render a single field → operator → value row.
|
|
168
|
+
*
|
|
169
|
+
* @param props - Leaf renderer props.
|
|
170
|
+
* @returns The rendered leaf.
|
|
171
|
+
*/
|
|
172
|
+
const Leaf = (props) => {
|
|
173
|
+
const cm = getClassMap();
|
|
174
|
+
const { t } = useTranslation();
|
|
175
|
+
const field = () => props.schema.fields.find((f) => f.name === props.leaf.field);
|
|
176
|
+
const ops = () => {
|
|
177
|
+
const f = field();
|
|
178
|
+
return f ? operatorsFor(f) : [];
|
|
179
|
+
};
|
|
180
|
+
const op = () => {
|
|
181
|
+
const f = field();
|
|
182
|
+
return f ? operatorById(f, props.leaf.op) : undefined;
|
|
183
|
+
};
|
|
184
|
+
const arity = () => op()?.arity ?? 'binary';
|
|
185
|
+
const setField = (name) => {
|
|
186
|
+
const f = props.schema.fields.find((x) => x.name === name);
|
|
187
|
+
const firstOp = f ? operatorsFor(f)[0] : undefined;
|
|
188
|
+
props.onReplace({
|
|
189
|
+
...props.leaf,
|
|
190
|
+
field: name,
|
|
191
|
+
op: firstOp?.id ?? '',
|
|
192
|
+
value: undefined,
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
const setOp = (opId) => {
|
|
196
|
+
props.onReplace({ ...props.leaf, op: opId, value: undefined });
|
|
197
|
+
};
|
|
198
|
+
const setValue = (value) => {
|
|
199
|
+
props.onReplace({ ...props.leaf, value });
|
|
200
|
+
};
|
|
201
|
+
const fieldOptions = () => [
|
|
202
|
+
{ value: '', label: t('ruleBuilder.field.placeholder', {}, { defaultValue: 'Select field…' }) },
|
|
203
|
+
...props.schema.fields.map((f) => ({ value: f.name, label: f.label })),
|
|
204
|
+
];
|
|
205
|
+
return (<div class={cm.flex({ align: 'center', gap: 'xs', wrap: 'wrap' })} data-mol-id={`rule-builder-leaf-${props.leaf.id}`}>
|
|
206
|
+
<Select value={props.leaf.field} onValueChange={setField} options={fieldOptions()} aria-label={t('ruleBuilder.aria.field', {}, { defaultValue: 'Field' })}/>
|
|
207
|
+
<Show when={field()}>
|
|
208
|
+
<Select value={props.leaf.op} onValueChange={setOp} options={ops().map((o) => ({ value: o.id, label: o.label }))} aria-label={t('ruleBuilder.aria.operator', {}, { defaultValue: 'Operator' })}/>
|
|
209
|
+
</Show>
|
|
210
|
+
<Show when={field() && op() && arity() !== 'unary'}>
|
|
211
|
+
<ValueEditor field={field()} arity={arity()} value={props.leaf.value} onChange={setValue}/>
|
|
212
|
+
</Show>
|
|
213
|
+
<Button variant="ghost" size="sm" onClick={props.onRemove} aria-label={t('ruleBuilder.aria.removeCondition', {}, {
|
|
214
|
+
defaultValue: 'Remove condition',
|
|
215
|
+
})} data-mol-id={`rule-builder-leaf-${props.leaf.id}-remove`}>
|
|
216
|
+
{t('ruleBuilder.action.removeCondition', {}, { defaultValue: 'Remove' })}
|
|
217
|
+
</Button>
|
|
218
|
+
</div>);
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Visual rule / predicate builder. The rendered tree is a recursive
|
|
222
|
+
* `RuleGroup` of `RuleLeaf` predicates joined by `AND` or `OR`. The
|
|
223
|
+
* component is fully controlled — every interaction emits a new root
|
|
224
|
+
* rule via `onChange`.
|
|
225
|
+
*
|
|
226
|
+
* This is the Solid counterpart of `@molecule/app-rule-builder-react`'s
|
|
227
|
+
* `RuleBuilder`: the same props (React names), the same ClassMap tokens, and
|
|
228
|
+
* the same DOM for the same input.
|
|
229
|
+
*
|
|
230
|
+
* @param props - Component props (see {@link RuleBuilderProps}).
|
|
231
|
+
* @returns The rendered rule builder.
|
|
232
|
+
*/
|
|
233
|
+
export const RuleBuilder = (props) => {
|
|
234
|
+
const cm = getClassMap();
|
|
235
|
+
/**
|
|
236
|
+
* The root group React renders: the given tree itself when it is a
|
|
237
|
+
* group, otherwise an implicit AND group wrapping the bare leaf.
|
|
238
|
+
*
|
|
239
|
+
* @returns The root group.
|
|
240
|
+
*/
|
|
241
|
+
const rootGroup = () => props.rules.kind === 'group'
|
|
242
|
+
? props.rules
|
|
243
|
+
: { kind: 'group', id: 'root', op: 'AND', children: [props.rules] };
|
|
244
|
+
return (<div class={cm.cn(cm.flex({ direction: 'col', gap: 'sm' }), props.className)} data-mol-id="rule-builder">
|
|
245
|
+
<Group group={rootGroup()} schema={props.schema} isRoot onReplace={(next) => props.onChange(next)} onRemove={() => props.onChange(emptyGroup())}/>
|
|
246
|
+
</div>);
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=RuleBuilder.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuleBuilder.jsx","sourceRoot":"","sources":["../src/RuleBuilder.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAU3D,OAAO,EACL,aAAa,EACb,UAAU,EACV,SAAS,EACT,UAAU,EACV,WAAW,EACX,aAAa,GACd,MAAM,gBAAgB,CAAA;AAEvB;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,CAAC,KAA6B,EAA0B,EAAE,CAC3E,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;IAC1C,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;IAChF,KAAK;CACN,CAAC,CACH,CAAA;AAEH;;;;;GAKG;AACH,MAAM,UAAU,GAAG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AE,KAAK,CAAC,SAAS,CAAC,CAAC,CACxE,WAAW,CAAC,cAAc,CAE1B;MAAA,CAAC,KAAK,CACJ,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC,CACnB,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CACrB,MAAM,CACN,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAC1C,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,EAEjD;IAAA,EAAE,GAAG,CAAC,CACP,CAAA;AACH,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual condition / rule builder for Solid.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - `<RuleBuilder>` — controlled tree editor for AND / OR groups of
|
|
6
|
+
* field-operator-value leaves.
|
|
7
|
+
* - `RuleSchema`, `RuleField`, `RuleOperator`, `Rule`, `RuleGroup`,
|
|
8
|
+
* `RuleLeaf`, `RuleLeafValue`, `RuleGroupOp`, `RuleFieldType` types.
|
|
9
|
+
* - `defaultOperators`, `operatorsFor`, `operatorById`, `OP` operator
|
|
10
|
+
* catalog helpers.
|
|
11
|
+
* - `emptyGroup`, `emptyLeaf`, `replaceById`, `removeById`,
|
|
12
|
+
* `appendToGroup`, `toggleGroupOp`, `makeId` pure tree utilities.
|
|
13
|
+
*
|
|
14
|
+
* Used by feature-flag-manager (audience targeting),
|
|
15
|
+
* ai-workflow-automator (trigger conditions), email-marketing
|
|
16
|
+
* (segments), iot-device-manager + smart-home-dashboard (scenes /
|
|
17
|
+
* automations).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { createSignal } from 'solid-js'
|
|
22
|
+
*
|
|
23
|
+
* import {
|
|
24
|
+
* RuleBuilder,
|
|
25
|
+
* emptyGroup,
|
|
26
|
+
* type Rule,
|
|
27
|
+
* type RuleSchema,
|
|
28
|
+
* } from '@molecule/app-rule-builder-solid'
|
|
29
|
+
*
|
|
30
|
+
* const schema: RuleSchema = {
|
|
31
|
+
* fields: [
|
|
32
|
+
* { name: 'country', label: 'Country', type: 'select', options: [{ value: 'US', label: 'United States' }] },
|
|
33
|
+
* { name: 'plan', label: 'Plan', type: 'text' },
|
|
34
|
+
* { name: 'spend', label: 'Spend', type: 'number' },
|
|
35
|
+
* ],
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* function Demo() {
|
|
39
|
+
* const [rules, setRules] = createSignal<Rule>(emptyGroup('AND'))
|
|
40
|
+
* return <RuleBuilder schema={schema} rules={rules()} onChange={setRules} />
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* - `<RuleBuilder>` throws unless rendered inside a Solid app whose
|
|
46
|
+
* `MoleculeProvider` supplies an i18n provider (bonded `@molecule/app-i18n`
|
|
47
|
+
* is the fallback) with a bonded ClassMap (`setClassMap()`).
|
|
48
|
+
* - Output is a plain JSON-serializable `Rule` tree — this package only
|
|
49
|
+
* renders and edits it. Evaluation (matching rows/users against the tree)
|
|
50
|
+
* is the app's job, typically server-side.
|
|
51
|
+
* - Fully controlled: keep the tree in a signal and pass it back via `rules`;
|
|
52
|
+
* start with `emptyGroup('AND')`.
|
|
53
|
+
* - Translations: registered companion bond `@molecule/app-locales-rule-builder`.
|
|
54
|
+
*
|
|
55
|
+
* @module
|
|
56
|
+
*/
|
|
57
|
+
export * from './operators.js';
|
|
58
|
+
export * from './RuleBuilder.jsx';
|
|
59
|
+
export * from './types.js';
|
|
60
|
+
export * from './utilities.js';
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual condition / rule builder for Solid.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - `<RuleBuilder>` — controlled tree editor for AND / OR groups of
|
|
6
|
+
* field-operator-value leaves.
|
|
7
|
+
* - `RuleSchema`, `RuleField`, `RuleOperator`, `Rule`, `RuleGroup`,
|
|
8
|
+
* `RuleLeaf`, `RuleLeafValue`, `RuleGroupOp`, `RuleFieldType` types.
|
|
9
|
+
* - `defaultOperators`, `operatorsFor`, `operatorById`, `OP` operator
|
|
10
|
+
* catalog helpers.
|
|
11
|
+
* - `emptyGroup`, `emptyLeaf`, `replaceById`, `removeById`,
|
|
12
|
+
* `appendToGroup`, `toggleGroupOp`, `makeId` pure tree utilities.
|
|
13
|
+
*
|
|
14
|
+
* Used by feature-flag-manager (audience targeting),
|
|
15
|
+
* ai-workflow-automator (trigger conditions), email-marketing
|
|
16
|
+
* (segments), iot-device-manager + smart-home-dashboard (scenes /
|
|
17
|
+
* automations).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { createSignal } from 'solid-js'
|
|
22
|
+
*
|
|
23
|
+
* import {
|
|
24
|
+
* RuleBuilder,
|
|
25
|
+
* emptyGroup,
|
|
26
|
+
* type Rule,
|
|
27
|
+
* type RuleSchema,
|
|
28
|
+
* } from '@molecule/app-rule-builder-solid'
|
|
29
|
+
*
|
|
30
|
+
* const schema: RuleSchema = {
|
|
31
|
+
* fields: [
|
|
32
|
+
* { name: 'country', label: 'Country', type: 'select', options: [{ value: 'US', label: 'United States' }] },
|
|
33
|
+
* { name: 'plan', label: 'Plan', type: 'text' },
|
|
34
|
+
* { name: 'spend', label: 'Spend', type: 'number' },
|
|
35
|
+
* ],
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* function Demo() {
|
|
39
|
+
* const [rules, setRules] = createSignal<Rule>(emptyGroup('AND'))
|
|
40
|
+
* return <RuleBuilder schema={schema} rules={rules()} onChange={setRules} />
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* - `<RuleBuilder>` throws unless rendered inside a Solid app whose
|
|
46
|
+
* `MoleculeProvider` supplies an i18n provider (bonded `@molecule/app-i18n`
|
|
47
|
+
* is the fallback) with a bonded ClassMap (`setClassMap()`).
|
|
48
|
+
* - Output is a plain JSON-serializable `Rule` tree — this package only
|
|
49
|
+
* renders and edits it. Evaluation (matching rows/users against the tree)
|
|
50
|
+
* is the app's job, typically server-side.
|
|
51
|
+
* - Fully controlled: keep the tree in a signal and pass it back via `rules`;
|
|
52
|
+
* start with `emptyGroup('AND')`.
|
|
53
|
+
* - Translations: registered companion bond `@molecule/app-locales-rule-builder`.
|
|
54
|
+
*
|
|
55
|
+
* @module
|
|
56
|
+
*/
|
|
57
|
+
export * from './operators.js';
|
|
58
|
+
export * from './RuleBuilder.jsx';
|
|
59
|
+
export * from './types.js';
|
|
60
|
+
export * from './utilities.js';
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default operator catalogs per field type, plus a small helper that
|
|
3
|
+
* picks the catalog for a given field (preferring the field's own
|
|
4
|
+
* `operators` override when provided).
|
|
5
|
+
*
|
|
6
|
+
* All operator labels here use English fallbacks via `t(key, ..., {
|
|
7
|
+
* defaultValue })` at the call site — this module is consumed by
|
|
8
|
+
* `RuleBuilder.tsx`, which translates labels through the
|
|
9
|
+
* `@molecule/app-solid` i18n primitives before passing them to the
|
|
10
|
+
* dropdown.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import type { RuleField, RuleFieldType, RuleOperator } from './types.js';
|
|
15
|
+
/** Operator id constants — exported so consumers can inspect leaves. */
|
|
16
|
+
export declare const OP: {
|
|
17
|
+
readonly Equals: "eq";
|
|
18
|
+
readonly NotEquals: "neq";
|
|
19
|
+
readonly Contains: "contains";
|
|
20
|
+
readonly NotContains: "notContains";
|
|
21
|
+
readonly StartsWith: "startsWith";
|
|
22
|
+
readonly EndsWith: "endsWith";
|
|
23
|
+
readonly GreaterThan: "gt";
|
|
24
|
+
readonly GreaterThanOrEqual: "gte";
|
|
25
|
+
readonly LessThan: "lt";
|
|
26
|
+
readonly LessThanOrEqual: "lte";
|
|
27
|
+
readonly Between: "between";
|
|
28
|
+
readonly Before: "before";
|
|
29
|
+
readonly After: "after";
|
|
30
|
+
readonly IsTrue: "isTrue";
|
|
31
|
+
readonly IsFalse: "isFalse";
|
|
32
|
+
readonly IsEmpty: "isEmpty";
|
|
33
|
+
readonly IsNotEmpty: "isNotEmpty";
|
|
34
|
+
readonly In: "in";
|
|
35
|
+
readonly NotIn: "notIn";
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Untranslated operator descriptors per field type.
|
|
39
|
+
*
|
|
40
|
+
* `RuleBuilder` translates each `label` at render time; the strings
|
|
41
|
+
* here are English fallbacks only, never shown directly.
|
|
42
|
+
*/
|
|
43
|
+
export declare const defaultOperators: Record<RuleFieldType, RuleOperator[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve the operator catalog for `field`. Returns the field's own
|
|
46
|
+
* `operators` override when provided, otherwise the built-in catalog
|
|
47
|
+
* for the field's `type`.
|
|
48
|
+
*
|
|
49
|
+
* @param field - Field descriptor from the schema.
|
|
50
|
+
* @returns Operator catalog applicable to this field.
|
|
51
|
+
*/
|
|
52
|
+
export declare function operatorsFor(field: RuleField): RuleOperator[];
|
|
53
|
+
/**
|
|
54
|
+
* Look up a single operator descriptor by id within `field`'s catalog.
|
|
55
|
+
*
|
|
56
|
+
* @param field - Field descriptor.
|
|
57
|
+
* @param opId - Operator id to look up.
|
|
58
|
+
* @returns The operator descriptor, or `undefined` if `opId` isn't in the catalog.
|
|
59
|
+
*/
|
|
60
|
+
export declare function operatorById(field: RuleField, opId: string): RuleOperator | undefined;
|
|
61
|
+
//# sourceMappingURL=operators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../src/operators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAExE,wEAAwE;AACxE,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;CAoBL,CAAA;AAEV;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,aAAa,EAAE,YAAY,EAAE,CAkClE,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,EAAE,CAE7D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAErF"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default operator catalogs per field type, plus a small helper that
|
|
3
|
+
* picks the catalog for a given field (preferring the field's own
|
|
4
|
+
* `operators` override when provided).
|
|
5
|
+
*
|
|
6
|
+
* All operator labels here use English fallbacks via `t(key, ..., {
|
|
7
|
+
* defaultValue })` at the call site — this module is consumed by
|
|
8
|
+
* `RuleBuilder.tsx`, which translates labels through the
|
|
9
|
+
* `@molecule/app-solid` i18n primitives before passing them to the
|
|
10
|
+
* dropdown.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/** Operator id constants — exported so consumers can inspect leaves. */
|
|
15
|
+
export const OP = {
|
|
16
|
+
Equals: 'eq',
|
|
17
|
+
NotEquals: 'neq',
|
|
18
|
+
Contains: 'contains',
|
|
19
|
+
NotContains: 'notContains',
|
|
20
|
+
StartsWith: 'startsWith',
|
|
21
|
+
EndsWith: 'endsWith',
|
|
22
|
+
GreaterThan: 'gt',
|
|
23
|
+
GreaterThanOrEqual: 'gte',
|
|
24
|
+
LessThan: 'lt',
|
|
25
|
+
LessThanOrEqual: 'lte',
|
|
26
|
+
Between: 'between',
|
|
27
|
+
Before: 'before',
|
|
28
|
+
After: 'after',
|
|
29
|
+
IsTrue: 'isTrue',
|
|
30
|
+
IsFalse: 'isFalse',
|
|
31
|
+
IsEmpty: 'isEmpty',
|
|
32
|
+
IsNotEmpty: 'isNotEmpty',
|
|
33
|
+
In: 'in',
|
|
34
|
+
NotIn: 'notIn',
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Untranslated operator descriptors per field type.
|
|
38
|
+
*
|
|
39
|
+
* `RuleBuilder` translates each `label` at render time; the strings
|
|
40
|
+
* here are English fallbacks only, never shown directly.
|
|
41
|
+
*/
|
|
42
|
+
export const defaultOperators = {
|
|
43
|
+
text: [
|
|
44
|
+
{ id: OP.Equals, label: 'equals' },
|
|
45
|
+
{ id: OP.NotEquals, label: 'does not equal' },
|
|
46
|
+
{ id: OP.Contains, label: 'contains' },
|
|
47
|
+
{ id: OP.NotContains, label: 'does not contain' },
|
|
48
|
+
{ id: OP.StartsWith, label: 'starts with' },
|
|
49
|
+
{ id: OP.EndsWith, label: 'ends with' },
|
|
50
|
+
{ id: OP.IsEmpty, label: 'is empty', arity: 'unary' },
|
|
51
|
+
{ id: OP.IsNotEmpty, label: 'is not empty', arity: 'unary' },
|
|
52
|
+
],
|
|
53
|
+
number: [
|
|
54
|
+
{ id: OP.Equals, label: '=' },
|
|
55
|
+
{ id: OP.NotEquals, label: '≠' },
|
|
56
|
+
{ id: OP.GreaterThan, label: '>' },
|
|
57
|
+
{ id: OP.GreaterThanOrEqual, label: '≥' },
|
|
58
|
+
{ id: OP.LessThan, label: '<' },
|
|
59
|
+
{ id: OP.LessThanOrEqual, label: '≤' },
|
|
60
|
+
{ id: OP.Between, label: 'between', arity: 'between' },
|
|
61
|
+
],
|
|
62
|
+
date: [
|
|
63
|
+
{ id: OP.Equals, label: 'on' },
|
|
64
|
+
{ id: OP.Before, label: 'before' },
|
|
65
|
+
{ id: OP.After, label: 'after' },
|
|
66
|
+
{ id: OP.Between, label: 'between', arity: 'between' },
|
|
67
|
+
],
|
|
68
|
+
select: [
|
|
69
|
+
{ id: OP.Equals, label: 'is' },
|
|
70
|
+
{ id: OP.NotEquals, label: 'is not' },
|
|
71
|
+
],
|
|
72
|
+
boolean: [
|
|
73
|
+
{ id: OP.IsTrue, label: 'is true', arity: 'unary' },
|
|
74
|
+
{ id: OP.IsFalse, label: 'is false', arity: 'unary' },
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Resolve the operator catalog for `field`. Returns the field's own
|
|
79
|
+
* `operators` override when provided, otherwise the built-in catalog
|
|
80
|
+
* for the field's `type`.
|
|
81
|
+
*
|
|
82
|
+
* @param field - Field descriptor from the schema.
|
|
83
|
+
* @returns Operator catalog applicable to this field.
|
|
84
|
+
*/
|
|
85
|
+
export function operatorsFor(field) {
|
|
86
|
+
return field.operators ?? defaultOperators[field.type] ?? [];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Look up a single operator descriptor by id within `field`'s catalog.
|
|
90
|
+
*
|
|
91
|
+
* @param field - Field descriptor.
|
|
92
|
+
* @param opId - Operator id to look up.
|
|
93
|
+
* @returns The operator descriptor, or `undefined` if `opId` isn't in the catalog.
|
|
94
|
+
*/
|
|
95
|
+
export function operatorById(field, opId) {
|
|
96
|
+
return operatorsFor(field).find((o) => o.id === opId);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=operators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.js","sourceRoot":"","sources":["../src/operators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,wEAAwE;AACxE,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,IAAI;IACjB,kBAAkB,EAAE,KAAK;IACzB,QAAQ,EAAE,IAAI;IACd,eAAe,EAAE,KAAK;IACtB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,EAAE,EAAE,IAAI;IACR,KAAK,EAAE,OAAO;CACN,CAAA;AAEV;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA0C;IACrE,IAAI,EAAE;QACJ,EAAE,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE;QAClC,EAAE,EAAE,EAAE,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE;QAC7C,EAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,E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AAE,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;KACvD;IACD,MAAM,EAAE;QACN,EAAE,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE;QAC9B,EAAE,EAAE,EAAE,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;KACtC;IACD,OAAO,EAAE;QACP,EAAE,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE;QACnD,EAAE,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE;KACtD;CACF,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAgB;IAC3C,OAAO,KAAK,CAAC,SAAS,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;AAC9D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAgB,EAAE,IAAY;IACzD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAA;AACvD,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule-builder types — schema, operators, and recursive rule trees.
|
|
3
|
+
*
|
|
4
|
+
* The rule tree is a discriminated union: a `RuleGroup` contains an
|
|
5
|
+
* `op` (`AND` or `OR`) plus a list of children (themselves groups or
|
|
6
|
+
* leaves), and a `RuleLeaf` is a `{ field, op, value }` triple.
|
|
7
|
+
*
|
|
8
|
+
* The schema declares the available `fields`, each typed (text, number,
|
|
9
|
+
* date, select) so the builder can render the right value editor and
|
|
10
|
+
* filter the operator dropdown to operators that make sense for that
|
|
11
|
+
* type.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Logical join operator at a group level.
|
|
17
|
+
*/
|
|
18
|
+
export type RuleGroupOp = 'AND' | 'OR';
|
|
19
|
+
/**
|
|
20
|
+
* Built-in field types supported by the default operator catalog and
|
|
21
|
+
* value editors. Consumers can supply custom operator lists per field
|
|
22
|
+
* if these don't fit.
|
|
23
|
+
*/
|
|
24
|
+
export type RuleFieldType = 'text' | 'number' | 'date' | 'select' | 'boolean';
|
|
25
|
+
/**
|
|
26
|
+
* Operator descriptor — `id` is what's stored on the leaf, `label` is
|
|
27
|
+
* what's shown in the operator dropdown.
|
|
28
|
+
*
|
|
29
|
+
* `arity` controls how many value inputs are rendered:
|
|
30
|
+
* - `'unary'` — no value input (e.g. `is empty`, `exists`)
|
|
31
|
+
* - `'binary'` — one value input (default)
|
|
32
|
+
* - `'between'` — two value inputs (rendered as `from`/`to`)
|
|
33
|
+
*/
|
|
34
|
+
export interface RuleOperator {
|
|
35
|
+
/** Operator id stored on the leaf. */
|
|
36
|
+
id: string;
|
|
37
|
+
/** Translated, human-readable label. */
|
|
38
|
+
label: string;
|
|
39
|
+
/** Number of value inputs to render. Default `'binary'`. */
|
|
40
|
+
arity?: 'unary' | 'binary' | 'between';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Field descriptor in the schema — the rule builder uses it to render
|
|
44
|
+
* the field dropdown, infer the value editor, and (when no explicit
|
|
45
|
+
* `operators` list is given) pick a default operator catalog by `type`.
|
|
46
|
+
*/
|
|
47
|
+
export interface RuleField {
|
|
48
|
+
/** Stable field identifier stored on the leaf. */
|
|
49
|
+
name: string;
|
|
50
|
+
/** Translated, human-readable label shown in the field dropdown. */
|
|
51
|
+
label: string;
|
|
52
|
+
/** Built-in type used to pick the value editor + default operators. */
|
|
53
|
+
type: RuleFieldType;
|
|
54
|
+
/**
|
|
55
|
+
* Operators valid for this field. Optional — when omitted, the
|
|
56
|
+
* builder uses the default catalog for `type` from `defaultOperators`.
|
|
57
|
+
*/
|
|
58
|
+
operators?: RuleOperator[];
|
|
59
|
+
/**
|
|
60
|
+
* For `type: 'select'` — the option list rendered as a `<Select>`.
|
|
61
|
+
* Ignored for other types.
|
|
62
|
+
*/
|
|
63
|
+
options?: Array<{
|
|
64
|
+
value: string;
|
|
65
|
+
label: string;
|
|
66
|
+
}>;
|
|
67
|
+
/** Optional placeholder for text/number/date inputs. */
|
|
68
|
+
placeholder?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Schema given to `<RuleBuilder>`. Currently only `fields` — kept as an
|
|
72
|
+
* object so future schema-level config (max depth, group limit, etc.)
|
|
73
|
+
* can be added without breaking the API.
|
|
74
|
+
*/
|
|
75
|
+
export interface RuleSchema {
|
|
76
|
+
/** Available fields, in the order they appear in the field dropdown. */
|
|
77
|
+
fields: RuleField[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Leaf rule — a single `field op value` predicate.
|
|
81
|
+
*
|
|
82
|
+
* `value` is opaque to the builder for `text` / `number` / `select` /
|
|
83
|
+
* `boolean` (it stores whatever the input produced — string for text /
|
|
84
|
+
* select / date, number for number, boolean for boolean). For `between`
|
|
85
|
+
* arity operators it's stored as a `[from, to]` two-element tuple.
|
|
86
|
+
*/
|
|
87
|
+
export interface RuleLeaf {
|
|
88
|
+
/** Discriminator. */
|
|
89
|
+
kind: 'leaf';
|
|
90
|
+
/** Stable id (uuid-ish) — used for element identity + delete identity. */
|
|
91
|
+
id: string;
|
|
92
|
+
/** Field name from the schema. Empty string when unset. */
|
|
93
|
+
field: string;
|
|
94
|
+
/** Operator id from the field's operator catalog. Empty when unset. */
|
|
95
|
+
op: string;
|
|
96
|
+
/**
|
|
97
|
+
* Current value. `undefined` when unset. Encoding depends on the
|
|
98
|
+
* operator's `arity`:
|
|
99
|
+
* - `'unary'` — value is ignored.
|
|
100
|
+
* - `'binary'` — string | number | boolean.
|
|
101
|
+
* - `'between'` — `[from, to]` tuple.
|
|
102
|
+
*/
|
|
103
|
+
value?: RuleLeafValue;
|
|
104
|
+
}
|
|
105
|
+
/** Possible leaf value encodings. See `RuleLeaf.value`. */
|
|
106
|
+
export type RuleLeafValue = string | number | boolean | [string, string] | [number, number];
|
|
107
|
+
/**
|
|
108
|
+
* Group rule — a logical conjunction (AND) or disjunction (OR) of
|
|
109
|
+
* children. Children may themselves be groups, allowing arbitrary
|
|
110
|
+
* nesting like `(A AND (B OR C) AND D)`.
|
|
111
|
+
*/
|
|
112
|
+
export interface RuleGroup {
|
|
113
|
+
/** Discriminator. */
|
|
114
|
+
kind: 'group';
|
|
115
|
+
/** Stable id. */
|
|
116
|
+
id: string;
|
|
117
|
+
/** Logical operator joining the children. */
|
|
118
|
+
op: RuleGroupOp;
|
|
119
|
+
/** Child rules — groups or leaves, in display order. */
|
|
120
|
+
children: Rule[];
|
|
121
|
+
}
|
|
122
|
+
/** Either a group or a leaf. */
|
|
123
|
+
export type Rule = RuleGroup | RuleLeaf;
|
|
124
|
+
/** Public component props. */
|
|
125
|
+
export interface RuleBuilderProps {
|
|
126
|
+
/** Field catalog the user picks from. */
|
|
127
|
+
schema: RuleSchema;
|
|
128
|
+
/** Current rule tree (controlled). */
|
|
129
|
+
rules: Rule;
|
|
130
|
+
/**
|
|
131
|
+
* Called whenever the user mutates the tree — receives the full new
|
|
132
|
+
* root rule. Output is a deterministic JSON-serializable structure.
|
|
133
|
+
*/
|
|
134
|
+
onChange: (next: Rule) => void;
|
|
135
|
+
/** Optional extra root-level class. */
|
|
136
|
+
className?: string;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,I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,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE3F;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,qBAAqB;IACrB,IAAI,EAAE,OAAO,CAAA;IACb,iBAAiB;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,6CAA6C;IAC7C,EAAE,EAAE,WAAW,CAAA;IACf,wDAAwD;IACxD,QAAQ,EAAE,IAAI,EAAE,CAAA;CACjB;AAED,gCAAgC;AAChC,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAA;AAEvC,8BAA8B;AAC9B,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,MAAM,EAAE,UAAU,CAAA;IAClB,sCAAsC;IACtC,KAAK,EAAE,IAAI,CAAA;IACX;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAC9B,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule-builder types — schema, operators, and recursive rule trees.
|
|
3
|
+
*
|
|
4
|
+
* The rule tree is a discriminated union: a `RuleGroup` contains an
|
|
5
|
+
* `op` (`AND` or `OR`) plus a list of children (themselves groups or
|
|
6
|
+
* leaves), and a `RuleLeaf` is a `{ field, op, value }` triple.
|
|
7
|
+
*
|
|
8
|
+
* The schema declares the available `fields`, each typed (text, number,
|
|
9
|
+
* date, select) so the builder can render the right value editor and
|
|
10
|
+
* filter the operator dropdown to operators that make sense for that
|
|
11
|
+
* type.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure rule-tree utilities — id generation + immutable update helpers.
|
|
3
|
+
*
|
|
4
|
+
* Kept free of any UI framework so they're trivial to unit-test and to
|
|
5
|
+
* reuse from non-UI consumers (e.g. server-side validation, CLI tooling).
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { Rule, RuleGroup, RuleGroupOp, RuleLeaf } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Generate a short non-cryptographic id. Sufficient for rendered element
|
|
12
|
+
* identity and in-memory rule identity within a single editing session.
|
|
13
|
+
*
|
|
14
|
+
* @returns A short random id.
|
|
15
|
+
*/
|
|
16
|
+
export declare function makeId(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Build a fresh empty leaf — used when the user clicks "Add condition".
|
|
19
|
+
*
|
|
20
|
+
* @returns A new leaf with all fields blank and a fresh id.
|
|
21
|
+
*/
|
|
22
|
+
export declare function emptyLeaf(): RuleLeaf;
|
|
23
|
+
/**
|
|
24
|
+
* Build a fresh empty group — used when the user clicks "Add group".
|
|
25
|
+
*
|
|
26
|
+
* @param op - Initial group operator, defaults to `'AND'`.
|
|
27
|
+
* @returns A new group with one empty leaf already inside.
|
|
28
|
+
*/
|
|
29
|
+
export declare function emptyGroup(op?: RuleGroupOp): RuleGroup;
|
|
30
|
+
/**
|
|
31
|
+
* Replace `target` (matched by id) anywhere in the tree with `replacement`.
|
|
32
|
+
*
|
|
33
|
+
* @param tree - Root of the rule tree.
|
|
34
|
+
* @param targetId - Id of the rule to replace.
|
|
35
|
+
* @param replacement - Replacement rule (same id is not required).
|
|
36
|
+
* @returns New tree with the replacement applied.
|
|
37
|
+
*/
|
|
38
|
+
export declare function replaceById(tree: Rule, targetId: string, replacement: Rule): Rule;
|
|
39
|
+
/**
|
|
40
|
+
* Remove the rule with id `targetId` from the tree. The root itself
|
|
41
|
+
* cannot be removed — when `targetId` matches the root, the tree is
|
|
42
|
+
* returned unchanged.
|
|
43
|
+
*
|
|
44
|
+
* @param tree - Root of the rule tree.
|
|
45
|
+
* @param targetId - Id of the rule to remove.
|
|
46
|
+
* @returns New tree with the rule removed (or the original tree if no match).
|
|
47
|
+
*/
|
|
48
|
+
export declare function removeById(tree: Rule, targetId: string): Rule;
|
|
49
|
+
/**
|
|
50
|
+
* Append `child` to the children of the group identified by `groupId`.
|
|
51
|
+
* If the id doesn't match any group, returns the tree unchanged.
|
|
52
|
+
*
|
|
53
|
+
* @param tree - Root of the rule tree.
|
|
54
|
+
* @param groupId - Id of the group to append to.
|
|
55
|
+
* @param child - Rule to append.
|
|
56
|
+
* @returns New tree with the child appended.
|
|
57
|
+
*/
|
|
58
|
+
export declare function appendToGroup(tree: Rule, groupId: string, child: Rule): Rule;
|
|
59
|
+
/**
|
|
60
|
+
* Toggle a group's `op` between `'AND'` and `'OR'`.
|
|
61
|
+
*
|
|
62
|
+
* @param tree - Root of the rule tree.
|
|
63
|
+
* @param groupId - Id of the group to toggle.
|
|
64
|
+
* @returns New tree with the group's op flipped (or the original tree if no match).
|
|
65
|
+
*/
|
|
66
|
+
export declare function toggleGroupOp(tree: Rule, groupId: string): Rule;
|
|
67
|
+
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAExE;;;;;GAKG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,QAAQ,CAEpC;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,GAAE,WAAmB,GAAG,SAAS,CAE7D;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,GAAG,IAAI,CAOjF;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAM7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAS5E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAS/D"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure rule-tree utilities — id generation + immutable update helpers.
|
|
3
|
+
*
|
|
4
|
+
* Kept free of any UI framework so they're trivial to unit-test and to
|
|
5
|
+
* reuse from non-UI consumers (e.g. server-side validation, CLI tooling).
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Generate a short non-cryptographic id. Sufficient for rendered element
|
|
11
|
+
* identity and in-memory rule identity within a single editing session.
|
|
12
|
+
*
|
|
13
|
+
* @returns A short random id.
|
|
14
|
+
*/
|
|
15
|
+
export function makeId() {
|
|
16
|
+
return Math.random().toString(36).slice(2, 10);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build a fresh empty leaf — used when the user clicks "Add condition".
|
|
20
|
+
*
|
|
21
|
+
* @returns A new leaf with all fields blank and a fresh id.
|
|
22
|
+
*/
|
|
23
|
+
export function emptyLeaf() {
|
|
24
|
+
return { kind: 'leaf', id: makeId(), field: '', op: '' };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build a fresh empty group — used when the user clicks "Add group".
|
|
28
|
+
*
|
|
29
|
+
* @param op - Initial group operator, defaults to `'AND'`.
|
|
30
|
+
* @returns A new group with one empty leaf already inside.
|
|
31
|
+
*/
|
|
32
|
+
export function emptyGroup(op = 'AND') {
|
|
33
|
+
return { kind: 'group', id: makeId(), op, children: [emptyLeaf()] };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Replace `target` (matched by id) anywhere in the tree with `replacement`.
|
|
37
|
+
*
|
|
38
|
+
* @param tree - Root of the rule tree.
|
|
39
|
+
* @param targetId - Id of the rule to replace.
|
|
40
|
+
* @param replacement - Replacement rule (same id is not required).
|
|
41
|
+
* @returns New tree with the replacement applied.
|
|
42
|
+
*/
|
|
43
|
+
export function replaceById(tree, targetId, replacement) {
|
|
44
|
+
if (tree.id === targetId)
|
|
45
|
+
return replacement;
|
|
46
|
+
if (tree.kind === 'leaf')
|
|
47
|
+
return tree;
|
|
48
|
+
return {
|
|
49
|
+
...tree,
|
|
50
|
+
children: tree.children.map((c) => replaceById(c, targetId, replacement)),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Remove the rule with id `targetId` from the tree. The root itself
|
|
55
|
+
* cannot be removed — when `targetId` matches the root, the tree is
|
|
56
|
+
* returned unchanged.
|
|
57
|
+
*
|
|
58
|
+
* @param tree - Root of the rule tree.
|
|
59
|
+
* @param targetId - Id of the rule to remove.
|
|
60
|
+
* @returns New tree with the rule removed (or the original tree if no match).
|
|
61
|
+
*/
|
|
62
|
+
export function removeById(tree, targetId) {
|
|
63
|
+
if (tree.kind === 'leaf')
|
|
64
|
+
return tree;
|
|
65
|
+
return {
|
|
66
|
+
...tree,
|
|
67
|
+
children: tree.children.filter((c) => c.id !== targetId).map((c) => removeById(c, targetId)),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Append `child` to the children of the group identified by `groupId`.
|
|
72
|
+
* If the id doesn't match any group, returns the tree unchanged.
|
|
73
|
+
*
|
|
74
|
+
* @param tree - Root of the rule tree.
|
|
75
|
+
* @param groupId - Id of the group to append to.
|
|
76
|
+
* @param child - Rule to append.
|
|
77
|
+
* @returns New tree with the child appended.
|
|
78
|
+
*/
|
|
79
|
+
export function appendToGroup(tree, groupId, child) {
|
|
80
|
+
if (tree.kind === 'leaf')
|
|
81
|
+
return tree;
|
|
82
|
+
if (tree.id === groupId) {
|
|
83
|
+
return { ...tree, children: [...tree.children, child] };
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
...tree,
|
|
87
|
+
children: tree.children.map((c) => appendToGroup(c, groupId, child)),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Toggle a group's `op` between `'AND'` and `'OR'`.
|
|
92
|
+
*
|
|
93
|
+
* @param tree - Root of the rule tree.
|
|
94
|
+
* @param groupId - Id of the group to toggle.
|
|
95
|
+
* @returns New tree with the group's op flipped (or the original tree if no match).
|
|
96
|
+
*/
|
|
97
|
+
export function toggleGroupOp(tree, groupId) {
|
|
98
|
+
if (tree.kind === 'leaf')
|
|
99
|
+
return tree;
|
|
100
|
+
if (tree.id === groupId) {
|
|
101
|
+
return { ...tree, op: tree.op === 'AND' ? 'OR' : 'AND' };
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
...tree,
|
|
105
|
+
children: tree.children.map((c) => toggleGroupOp(c, groupId)),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;;GAKG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAA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IAAI,IAAI,CAAC,EAAE,KAAK,OAAO,EAAE,CAAC;QACxB,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAA;IACzD,CAAC;IACD,OAAO;QACL,GAAG,IAAI;QACP,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;KACrE,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAU,EAAE,OAAe;IACvD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,IAAI,CAAA;IACrC,IAAI,IAAI,CAAC,EAAE,KAAK,OAAO,EAAE,CAAC;QACxB,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;IAC1D,CAAC;IACD,OAAO;QACL,GAAG,IAAI;QACP,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;KAC9D,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-rule-builder-solid",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1-stage",
|
|
4
|
+
"description": "Visual condition / rule builder — nested AND / OR groups of field-operator-value leaves, used for feature-flag targeting, automation triggers, segmentation, and IoT scenarios",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/app-rule-builder-solid",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"dev": "tsc --watch",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"molecule",
|
|
27
|
+
"rule",
|
|
28
|
+
"builder",
|
|
29
|
+
"predicate",
|
|
30
|
+
"condition",
|
|
31
|
+
"feature-flag",
|
|
32
|
+
"automation",
|
|
33
|
+
"solid"
|
|
34
|
+
],
|
|
35
|
+
"author": "Molecule Dev, Inc. (https://molecule.dev)",
|
|
36
|
+
"license": "Apache-2.0",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
40
|
+
"directory": "packages/app/features/rule-builder-solid"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=20"
|
|
44
|
+
},
|
|
45
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@molecule/app-solid": "^3.5.0",
|
|
51
|
+
"@molecule/app-ui": "^1.5.0",
|
|
52
|
+
"@molecule/app-ui-solid": "^1.1.0",
|
|
53
|
+
"solid-js": "^1.8.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@molecule/app-framework-conformance": "0.0.0",
|
|
57
|
+
"@molecule/app-i18n": "1.2.2",
|
|
58
|
+
"@molecule/app-icons": "1.0.4",
|
|
59
|
+
"@molecule/app-solid": "3.7.2",
|
|
60
|
+
"@molecule/app-ui": "1.4.0",
|
|
61
|
+
"@molecule/app-ui-solid": "1.1.5",
|
|
62
|
+
"@types/node": "26.6.5",
|
|
63
|
+
"jsdom": "30.1.3",
|
|
64
|
+
"solid-js": "1.9.17",
|
|
65
|
+
"typescript": "6.0.3",
|
|
66
|
+
"vite-plugin-solid": "2.11.15",
|
|
67
|
+
"vitest": "4.1.12"
|
|
68
|
+
}
|
|
69
|
+
}
|