@wallarm-org/design-system 4.9.0 → 4.10.0-rc-feat-parser.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.
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +2 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +84 -71
- package/dist/components/DropdownMenu/DropdownMenuItemDescription.js +1 -1
- package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/useFilterInputAutocomplete.js +1 -1
- package/dist/components/Rules/PointSelector/KeyboardShortcutsDialog.d.ts +14 -0
- package/dist/components/Rules/PointSelector/KeyboardShortcutsDialog.js +209 -0
- package/dist/components/Rules/PointSelector/MatchStep.d.ts +15 -0
- package/dist/components/Rules/PointSelector/MatchStep.js +186 -0
- package/dist/components/Rules/PointSelector/MenuFooterHints.d.ts +16 -0
- package/dist/components/Rules/PointSelector/MenuFooterHints.js +177 -0
- package/dist/components/Rules/PointSelector/PointPreview.d.ts +10 -0
- package/dist/components/Rules/PointSelector/PointPreview.js +88 -0
- package/dist/components/Rules/PointSelector/PointSelector.d.ts +17 -0
- package/dist/components/Rules/PointSelector/PointSelector.js +937 -0
- package/dist/components/Rules/PointSelector/PointSelectorEmptyState.d.ts +12 -0
- package/dist/components/Rules/PointSelector/PointSelectorEmptyState.js +173 -0
- package/dist/components/Rules/PointSelector/PointSelectorError.d.ts +31 -0
- package/dist/components/Rules/PointSelector/PointSelectorError.js +275 -0
- package/dist/components/Rules/PointSelector/PointSelectorInput.d.ts +20 -0
- package/dist/components/Rules/PointSelector/PointSelectorInput.js +130 -0
- package/dist/components/Rules/PointSelector/PointSelectorMenu.d.ts +31 -0
- package/dist/components/Rules/PointSelector/PointSelectorMenu.js +317 -0
- package/dist/components/Rules/PointSelector/PointSelectorSkeleton.d.ts +8 -0
- package/dist/components/Rules/PointSelector/PointSelectorSkeleton.js +73 -0
- package/dist/components/Rules/PointSelector/SampleRequest.d.ts +14 -0
- package/dist/components/Rules/PointSelector/SampleRequest.js +116 -0
- package/dist/components/Rules/PointSelector/StepMenu.d.ts +40 -0
- package/dist/components/Rules/PointSelector/StepMenu.js +210 -0
- package/dist/components/Rules/PointSelector/VersionWarning.d.ts +26 -0
- package/dist/components/Rules/PointSelector/VersionWarning.js +231 -0
- package/dist/components/Rules/PointSelector/WhereBar.d.ts +48 -0
- package/dist/components/Rules/PointSelector/WhereBar.js +263 -0
- package/dist/components/Rules/PointSelector/classes.d.ts +28 -0
- package/dist/components/Rules/PointSelector/classes.js +22 -0
- package/dist/components/Rules/PointSelector/index.d.ts +20 -0
- package/dist/components/Rules/PointSelector/index.js +18 -0
- package/dist/components/Rules/PointSelector/liftLayer.d.ts +8 -0
- package/dist/components/Rules/PointSelector/liftLayer.js +4 -0
- package/dist/components/Rules/PointSelector/sampleValue.d.ts +6 -0
- package/dist/components/Rules/PointSelector/sampleValue.js +51 -0
- package/dist/components/Rules/PointSelector/sdkBridge.d.ts +508 -0
- package/dist/components/Rules/PointSelector/sdkBridge.js +339 -0
- package/dist/components/Rules/PointSelector/types.d.ts +304 -0
- package/dist/components/Rules/PointSelector/types.js +0 -0
- package/dist/components/Rules/PointSelector/usePointSelector.d.ts +161 -0
- package/dist/components/Rules/PointSelector/usePointSelector.js +1088 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionEditor.d.ts +28 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionEditor.js +208 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionFields.d.ts +23 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionFields.js +950 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTargetPicker.d.ts +21 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTargetPicker.js +110 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTypeSelect.d.ts +20 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTypeSelect.js +31 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/AttackTypeField.d.ts +23 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/AttackTypeField.js +131 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/classes.d.ts +17 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/classes.js +14 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/index.d.ts +6 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/index.js +6 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/AddConditionMenu.d.ts +24 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/AddConditionMenu.js +245 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/AttackCondition.d.ts +15 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/AttackCondition.js +691 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionCard.d.ts +19 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionCard.js +72 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionTree.d.ts +27 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionTree.js +407 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/FieldCondition.d.ts +14 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/FieldCondition.js +269 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/GroupCondition.d.ts +25 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/GroupCondition.js +99 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/SampleCondition.d.ts +14 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/SampleCondition.js +118 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/SignalCondition.d.ts +14 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/SignalCondition.js +446 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/TagCondition.d.ts +14 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/TagCondition.js +266 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/classes.d.ts +35 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/classes.js +57 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/index.d.ts +15 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/index.js +10 -0
- package/dist/components/Rules/RuleBuilder/RuleBuilder.d.ts +67 -0
- package/dist/components/Rules/RuleBuilder/RuleBuilder.js +366 -0
- package/dist/components/Rules/RuleBuilder/Summary/ActionSummary.d.ts +32 -0
- package/dist/components/Rules/RuleBuilder/Summary/ActionSummary.js +420 -0
- package/dist/components/Rules/RuleBuilder/Summary/ConditionSummary.d.ts +27 -0
- package/dist/components/Rules/RuleBuilder/Summary/ConditionSummary.js +446 -0
- package/dist/components/Rules/RuleBuilder/Summary/index.d.ts +7 -0
- package/dist/components/Rules/RuleBuilder/Summary/index.js +2 -0
- package/dist/components/Rules/RuleBuilder/classes.d.ts +19 -0
- package/dist/components/Rules/RuleBuilder/classes.js +18 -0
- package/dist/components/Rules/RuleBuilder/index.d.ts +55 -0
- package/dist/components/Rules/RuleBuilder/index.js +11 -0
- package/dist/components/Rules/RuleBuilder/models/actionModel.d.ts +31 -0
- package/dist/components/Rules/RuleBuilder/models/actionModel.js +276 -0
- package/dist/components/Rules/RuleBuilder/models/conditionModel.d.ts +95 -0
- package/dist/components/Rules/RuleBuilder/models/conditionModel.js +418 -0
- package/dist/components/Rules/RuleBuilder/models/index.d.ts +3 -0
- package/dist/components/Rules/RuleBuilder/models/index.js +3 -0
- package/dist/components/Rules/RuleBuilder/models/validation.d.ts +176 -0
- package/dist/components/Rules/RuleBuilder/models/validation.js +242 -0
- package/dist/components/Rules/RuleBuilder/shared/ChoiceSelect.d.ts +27 -0
- package/dist/components/Rules/RuleBuilder/shared/ChoiceSelect.js +92 -0
- package/dist/components/Rules/RuleBuilder/shared/index.d.ts +1 -0
- package/dist/components/Rules/RuleBuilder/shared/index.js +1 -0
- package/dist/components/Rules/RuleBuilder/types.d.ts +384 -0
- package/dist/components/Rules/RuleBuilder/types.js +0 -0
- package/dist/components/Rules/RuleBuilder/utils/constants.d.ts +65 -0
- package/dist/components/Rules/RuleBuilder/utils/constants.js +356 -0
- package/dist/components/Rules/RuleBuilder/utils/extractBindings.d.ts +48 -0
- package/dist/components/Rules/RuleBuilder/utils/extractBindings.js +42 -0
- package/dist/components/Rules/RuleBuilder/utils/helpers.d.ts +92 -0
- package/dist/components/Rules/RuleBuilder/utils/helpers.js +54 -0
- package/dist/components/Rules/RuleBuilder/utils/index.d.ts +2 -0
- package/dist/components/Rules/RuleBuilder/utils/index.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/metadata/components.json +100 -2
- package/dist/metadata/guidelines.json +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { checkPoint } from "../../PointSelector/sdkBridge.js";
|
|
2
|
+
import { ACTION_KIND_CHOICES, TARGET_REQUIREMENT } from "../utils/constants.js";
|
|
3
|
+
import { extractBindings } from "../utils/extractBindings.js";
|
|
4
|
+
const GO_DURATION = /^(\d+(\.\d+)?(ns|us|µs|ms|s|m|h))+$/;
|
|
5
|
+
const QUANTITY = /^(\d+(\.\d+)?|\.\d+)(k|M|G|T|Ki|Mi|Gi|Ti)?$/;
|
|
6
|
+
function isValidDuration(value) {
|
|
7
|
+
return GO_DURATION.test(value.trim());
|
|
8
|
+
}
|
|
9
|
+
function isValidQuantity(value) {
|
|
10
|
+
return QUANTITY.test(value.trim());
|
|
11
|
+
}
|
|
12
|
+
function isValidInteger(value) {
|
|
13
|
+
const trimmed = value.trim();
|
|
14
|
+
return '' !== trimmed && Number.isInteger(Number(trimmed));
|
|
15
|
+
}
|
|
16
|
+
function ruleMetaProblems(ruleId) {
|
|
17
|
+
const problems = [];
|
|
18
|
+
if (!ruleId || !ruleId.trim()) problems.push('Rule ID is required');
|
|
19
|
+
return problems;
|
|
20
|
+
}
|
|
21
|
+
function validateActionTarget(draft) {
|
|
22
|
+
const problems = [];
|
|
23
|
+
if ('raw' === draft.kind) return problems;
|
|
24
|
+
const kind = draft.kind;
|
|
25
|
+
const targetType = TARGET_REQUIREMENT[kind];
|
|
26
|
+
const hasPointPattern = !draft.target.whole && draft.target.segments.length > 0;
|
|
27
|
+
const isFlow = draft.target.whole;
|
|
28
|
+
const actionLabel = ACTION_KIND_CHOICES.find((c)=>c.value === kind)?.label ?? kind;
|
|
29
|
+
switch(targetType){
|
|
30
|
+
case 'point':
|
|
31
|
+
if (isFlow) problems.push(`The "${actionLabel}" action needs a specific point, not the whole request.`);
|
|
32
|
+
else if (!hasPointPattern) problems.push('Say where the action applies.');
|
|
33
|
+
break;
|
|
34
|
+
case 'flow':
|
|
35
|
+
if (hasPointPattern) problems.push(`The "${actionLabel}" action applies to the whole request, not a specific point.`);
|
|
36
|
+
break;
|
|
37
|
+
case 'either':
|
|
38
|
+
if (!isFlow && !hasPointPattern) problems.push('Say where the action applies.');
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
return problems;
|
|
44
|
+
}
|
|
45
|
+
function validateActionPriority(draft) {
|
|
46
|
+
const problems = [];
|
|
47
|
+
if ('raw' === draft.kind) return problems;
|
|
48
|
+
const kind = draft.kind;
|
|
49
|
+
const priority = draft.priority?.trim() ?? '';
|
|
50
|
+
if ('' === priority) return problems;
|
|
51
|
+
const PRIORITY_ALLOWED = [
|
|
52
|
+
'processing_time_limit',
|
|
53
|
+
'processing_space_limit',
|
|
54
|
+
'entry_limits',
|
|
55
|
+
'disable_parsers',
|
|
56
|
+
'allow_parsers',
|
|
57
|
+
'force_parser'
|
|
58
|
+
];
|
|
59
|
+
const PRIORITY_FORBIDDEN = [
|
|
60
|
+
'add_attack',
|
|
61
|
+
'add_tag',
|
|
62
|
+
'suppress_attack',
|
|
63
|
+
'mark_attack',
|
|
64
|
+
'combine',
|
|
65
|
+
'disable_rule'
|
|
66
|
+
];
|
|
67
|
+
if (PRIORITY_FORBIDDEN.includes(kind)) {
|
|
68
|
+
problems.push(`Priority is not allowed for ${kind} actions.`);
|
|
69
|
+
return problems;
|
|
70
|
+
}
|
|
71
|
+
if (!PRIORITY_ALLOWED.includes(kind)) {
|
|
72
|
+
problems.push(`Priority support for ${kind} is unknown.`);
|
|
73
|
+
return problems;
|
|
74
|
+
}
|
|
75
|
+
if (!isValidInteger(priority)) {
|
|
76
|
+
problems.push('Priority must be a whole number.');
|
|
77
|
+
return problems;
|
|
78
|
+
}
|
|
79
|
+
const priorityNum = Number(priority);
|
|
80
|
+
const MIN_PRIORITY = -2147483648;
|
|
81
|
+
const MAX_PRIORITY = 2147483647;
|
|
82
|
+
if (priorityNum < MIN_PRIORITY || priorityNum > MAX_PRIORITY) problems.push(`Priority must be between ${MIN_PRIORITY} and ${MAX_PRIORITY}.`);
|
|
83
|
+
return problems;
|
|
84
|
+
}
|
|
85
|
+
function actionProblems(draft) {
|
|
86
|
+
const problems = [];
|
|
87
|
+
if ('raw' === draft.kind) return problems;
|
|
88
|
+
const kind = draft.kind;
|
|
89
|
+
problems.push(...validateActionTarget(draft));
|
|
90
|
+
switch(kind){
|
|
91
|
+
case 'add_attack':
|
|
92
|
+
if (!draft.attackType?.trim()) problems.push('Choose the attack type.');
|
|
93
|
+
break;
|
|
94
|
+
case 'add_tag':
|
|
95
|
+
if (!draft.tagKey?.trim()) problems.push('Give the tag a key.');
|
|
96
|
+
break;
|
|
97
|
+
case 'suppress_attack':
|
|
98
|
+
break;
|
|
99
|
+
case 'mark_attack':
|
|
100
|
+
{
|
|
101
|
+
const hasExperimental = void 0 !== draft.experimental;
|
|
102
|
+
const hasKnown = draft.known && Object.keys(draft.known).length > 0;
|
|
103
|
+
const hasKnownFalse = draft.knownFalse && (Array.isArray(draft.knownFalse) ? draft.knownFalse.length > 0 : '' !== draft.knownFalse.trim());
|
|
104
|
+
if (!hasExperimental && !hasKnown && !hasKnownFalse) problems.push('Mark the attack as experimental, known, or known false (at least one required).');
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case 'combine':
|
|
108
|
+
break;
|
|
109
|
+
case 'processing_time_limit':
|
|
110
|
+
{
|
|
111
|
+
const limit = draft.limit?.trim() ?? '';
|
|
112
|
+
if (limit) {
|
|
113
|
+
if (!isValidDuration(limit)) problems.push('Write the time limit with a unit, for example 5ms or 1.5s.');
|
|
114
|
+
} else problems.push('Set the time limit.');
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case 'processing_space_limit':
|
|
118
|
+
{
|
|
119
|
+
const limit = draft.limit?.trim() ?? '';
|
|
120
|
+
if (limit) {
|
|
121
|
+
if (!isValidQuantity(limit)) problems.push('Write the memory limit as a size, for example 512Ki or 2Mi.');
|
|
122
|
+
} else problems.push('Set the memory limit.');
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case 'entry_limits':
|
|
126
|
+
{
|
|
127
|
+
const soft = draft.softLimit?.trim() ?? '';
|
|
128
|
+
const hard = draft.hardLimit?.trim() ?? '';
|
|
129
|
+
if (!soft && !hard) problems.push('Set a soft limit, a hard limit, or both.');
|
|
130
|
+
if (soft && !isValidQuantity(soft)) problems.push('Write the soft limit as a size, for example 1Ki.');
|
|
131
|
+
if (hard && !isValidQuantity(hard)) problems.push('Write the hard limit as a size, for example 64Ki.');
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
case 'disable_parsers':
|
|
135
|
+
{
|
|
136
|
+
const parsers = draft.parsers;
|
|
137
|
+
if (!parsers || Array.isArray(parsers) && 0 === parsers.length) problems.push('Choose at least one parser to disable, or use "all".');
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case 'allow_parsers':
|
|
141
|
+
{
|
|
142
|
+
const parsers = draft.parsers;
|
|
143
|
+
if (null == parsers) problems.push('Specify which parsers to allow (use "all", a list, or leave empty for none).');
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case 'force_parser':
|
|
147
|
+
{
|
|
148
|
+
const parser = draft.parser?.trim() ?? '';
|
|
149
|
+
if (!parser) problems.push('Choose which parser to force.');
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case 'disable_rule':
|
|
153
|
+
{
|
|
154
|
+
const ruleIds = draft.ruleIds ?? [];
|
|
155
|
+
if (0 === ruleIds.length) problems.push('Specify at least one rule ID to disable.');
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
default:
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
problems.push(...validateActionPriority(draft));
|
|
162
|
+
return problems;
|
|
163
|
+
}
|
|
164
|
+
function isActionValid(draft) {
|
|
165
|
+
return 0 === actionProblems(draft).length;
|
|
166
|
+
}
|
|
167
|
+
function isSignalCheck(checkType) {
|
|
168
|
+
return 'attack_present' === checkType || 'attack_absent' === checkType || 'tag_present' === checkType || 'tag_absent' === checkType || 'signal_present' === checkType || 'signal_absent' === checkType || 'sample' === checkType;
|
|
169
|
+
}
|
|
170
|
+
function walkConditionTree(node, callback) {
|
|
171
|
+
if ('group' === node.kind) for (const child of node.children)walkConditionTree(child, callback);
|
|
172
|
+
else callback(node);
|
|
173
|
+
}
|
|
174
|
+
const validators = {
|
|
175
|
+
duration: (value)=>{
|
|
176
|
+
if (!value.trim()) return 'Duration is required';
|
|
177
|
+
if (!isValidDuration(value)) return 'Invalid duration format (use: 10ms, 1s, etc.)';
|
|
178
|
+
return null;
|
|
179
|
+
},
|
|
180
|
+
quantity: (value)=>{
|
|
181
|
+
if (!value.trim()) return 'Quantity is required';
|
|
182
|
+
if (!isValidQuantity(value)) return 'Invalid quantity format (use: 512, 1Ki, 2Mi, etc.)';
|
|
183
|
+
return null;
|
|
184
|
+
},
|
|
185
|
+
integer: (value)=>{
|
|
186
|
+
if (!value.trim()) return 'Number is required';
|
|
187
|
+
if (!isValidInteger(value)) return 'Must be a whole number';
|
|
188
|
+
return null;
|
|
189
|
+
},
|
|
190
|
+
required: (value)=>{
|
|
191
|
+
if (!value.trim()) return 'This field is required';
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
function validateBindingRefs(draft, condition, proton = null) {
|
|
196
|
+
const problems = [];
|
|
197
|
+
if ('raw' === draft.kind) return problems;
|
|
198
|
+
const bindings = extractBindings(condition);
|
|
199
|
+
const attackBindings = bindings.filter((b)=>'attack' === b.type).map((b)=>b.id);
|
|
200
|
+
const pointBindings = bindings.filter((b)=>'point' === b.type).map((b)=>b.id);
|
|
201
|
+
if (draft.attackRef) if (attackBindings.includes(draft.attackRef)) walkConditionTree(condition, (check)=>{
|
|
202
|
+
'attack' === check.kind && (check.bindAttack, draft.attackRef);
|
|
203
|
+
});
|
|
204
|
+
else problems.push(`Attack reference "${draft.attackRef}" does not match any bind_attack in conditions.`);
|
|
205
|
+
if (draft.targetRef) if (pointBindings.includes(draft.targetRef)) walkConditionTree(condition, (check)=>{
|
|
206
|
+
if (('field' === check.kind || 'signal' === check.kind) && check.bindPoint === draft.targetRef) {
|
|
207
|
+
let checkType;
|
|
208
|
+
let point;
|
|
209
|
+
let context;
|
|
210
|
+
if ('field' === check.kind) {
|
|
211
|
+
checkType = check.value.condition || '';
|
|
212
|
+
point = check.value.canonical || '';
|
|
213
|
+
context = check.context;
|
|
214
|
+
} else {
|
|
215
|
+
checkType = check.absent ? 'signal_absent' : 'signal_present';
|
|
216
|
+
point = check.point || '';
|
|
217
|
+
context = void 0;
|
|
218
|
+
}
|
|
219
|
+
if (isSignalCheck(checkType)) problems.push(`bind_point "${draft.targetRef}" cannot reference signal check ${checkType}`);
|
|
220
|
+
if (proton && point && context && 'field' === check.kind) {
|
|
221
|
+
const result = checkPoint(proton, point, {
|
|
222
|
+
context
|
|
223
|
+
});
|
|
224
|
+
if (result.canonical && !result.exact) problems.push(`bind_point "${draft.targetRef}" requires exact point, but ${point} contains wildcards`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
else problems.push(`Target reference "${draft.targetRef}" does not match any bind_point in conditions.`);
|
|
229
|
+
if (draft.targetRole && !draft.targetRef) problems.push('Target role requires a target reference.');
|
|
230
|
+
return problems;
|
|
231
|
+
}
|
|
232
|
+
function validateBindingUniqueness(condition) {
|
|
233
|
+
const problems = [];
|
|
234
|
+
const bindings = extractBindings(condition);
|
|
235
|
+
const seen = new Set();
|
|
236
|
+
for (const binding of bindings){
|
|
237
|
+
if (seen.has(binding.id)) problems.push(`Binding name "${binding.id}" is used more than once. Each binding must be unique.`);
|
|
238
|
+
seen.add(binding.id);
|
|
239
|
+
}
|
|
240
|
+
return problems;
|
|
241
|
+
}
|
|
242
|
+
export { actionProblems, isActionValid, isValidDuration, isValidInteger, isValidQuantity, ruleMetaProblems, validateActionPriority, validateActionTarget, validateBindingRefs, validateBindingUniqueness, validators };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChoiceSelect
|
|
3
|
+
*
|
|
4
|
+
* Reusable Select component for RuleBuilder choice lists.
|
|
5
|
+
* Wraps design system Select with consistent patterns.
|
|
6
|
+
*/
|
|
7
|
+
import { type FC } from 'react';
|
|
8
|
+
import type { Choice } from '../types.js';
|
|
9
|
+
export interface ChoiceSelectProps {
|
|
10
|
+
/** Accessible name */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Current selected value */
|
|
13
|
+
value: string;
|
|
14
|
+
/** Available choices */
|
|
15
|
+
choices: Choice[];
|
|
16
|
+
/** Placeholder text when no value selected */
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
/** Called when selection changes */
|
|
19
|
+
onChange: (value: string) => void;
|
|
20
|
+
/** Test ID for the button */
|
|
21
|
+
testId?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Single-select dropdown for RuleBuilder choice lists.
|
|
25
|
+
* Used for action types, operators, signal types, etc.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ChoiceSelect: FC<ChoiceSelectProps>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Select, SelectButton, SelectContent, SelectOption, SelectOptionIndicator, SelectOptionText, SelectPositioner, createListCollection } from "../../../Select/index.js";
|
|
4
|
+
const ChoiceSelect = (t0)=>{
|
|
5
|
+
const $ = c(20);
|
|
6
|
+
const { label, value, choices, placeholder, onChange, testId } = t0;
|
|
7
|
+
let t1;
|
|
8
|
+
if ($[0] !== choices) {
|
|
9
|
+
t1 = createListCollection({
|
|
10
|
+
items: choices
|
|
11
|
+
});
|
|
12
|
+
$[0] = choices;
|
|
13
|
+
$[1] = t1;
|
|
14
|
+
} else t1 = $[1];
|
|
15
|
+
const collection = t1;
|
|
16
|
+
let t2;
|
|
17
|
+
if ($[2] !== value) {
|
|
18
|
+
t2 = value ? [
|
|
19
|
+
value
|
|
20
|
+
] : [];
|
|
21
|
+
$[2] = value;
|
|
22
|
+
$[3] = t2;
|
|
23
|
+
} else t2 = $[3];
|
|
24
|
+
const selected = t2;
|
|
25
|
+
let t3;
|
|
26
|
+
if ($[4] !== onChange) {
|
|
27
|
+
t3 = (details)=>onChange(details.value[0] ?? "");
|
|
28
|
+
$[4] = onChange;
|
|
29
|
+
$[5] = t3;
|
|
30
|
+
} else t3 = $[5];
|
|
31
|
+
const t4 = placeholder ?? label;
|
|
32
|
+
let t5;
|
|
33
|
+
if ($[6] !== label || $[7] !== t4 || $[8] !== testId) {
|
|
34
|
+
t5 = /*#__PURE__*/ jsx(SelectButton, {
|
|
35
|
+
"aria-label": label,
|
|
36
|
+
placeholder: t4,
|
|
37
|
+
"data-testid": testId
|
|
38
|
+
});
|
|
39
|
+
$[6] = label;
|
|
40
|
+
$[7] = t4;
|
|
41
|
+
$[8] = testId;
|
|
42
|
+
$[9] = t5;
|
|
43
|
+
} else t5 = $[9];
|
|
44
|
+
let t6;
|
|
45
|
+
if ($[10] !== collection.items) {
|
|
46
|
+
t6 = collection.items.map(_temp);
|
|
47
|
+
$[10] = collection.items;
|
|
48
|
+
$[11] = t6;
|
|
49
|
+
} else t6 = $[11];
|
|
50
|
+
let t7;
|
|
51
|
+
if ($[12] !== t6) {
|
|
52
|
+
t7 = /*#__PURE__*/ jsx(SelectPositioner, {
|
|
53
|
+
children: /*#__PURE__*/ jsx(SelectContent, {
|
|
54
|
+
children: t6
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
$[12] = t6;
|
|
58
|
+
$[13] = t7;
|
|
59
|
+
} else t7 = $[13];
|
|
60
|
+
let t8;
|
|
61
|
+
if ($[14] !== collection || $[15] !== selected || $[16] !== t3 || $[17] !== t5 || $[18] !== t7) {
|
|
62
|
+
t8 = /*#__PURE__*/ jsxs(Select, {
|
|
63
|
+
collection: collection,
|
|
64
|
+
value: selected,
|
|
65
|
+
onValueChange: t3,
|
|
66
|
+
children: [
|
|
67
|
+
t5,
|
|
68
|
+
t7
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
$[14] = collection;
|
|
72
|
+
$[15] = selected;
|
|
73
|
+
$[16] = t3;
|
|
74
|
+
$[17] = t5;
|
|
75
|
+
$[18] = t7;
|
|
76
|
+
$[19] = t8;
|
|
77
|
+
} else t8 = $[19];
|
|
78
|
+
return t8;
|
|
79
|
+
};
|
|
80
|
+
ChoiceSelect.displayName = "ChoiceSelect";
|
|
81
|
+
function _temp(item) {
|
|
82
|
+
return /*#__PURE__*/ jsxs(SelectOption, {
|
|
83
|
+
item: item,
|
|
84
|
+
children: [
|
|
85
|
+
/*#__PURE__*/ jsx(SelectOptionText, {
|
|
86
|
+
children: item.label
|
|
87
|
+
}),
|
|
88
|
+
/*#__PURE__*/ jsx(SelectOptionIndicator, {})
|
|
89
|
+
]
|
|
90
|
+
}, item.value);
|
|
91
|
+
}
|
|
92
|
+
export { ChoiceSelect };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ChoiceSelect, type ChoiceSelectProps } from './ChoiceSelect.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ChoiceSelect } from "./ChoiceSelect.js";
|