@azx-pbc/axiom-form-builder 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +231 -2
- package/dist/bridge/index.d.ts +12 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +10 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/bridge/inspector-commands.d.ts +55 -0
- package/dist/bridge/inspector-commands.d.ts.map +1 -0
- package/dist/bridge/inspector-commands.js +532 -0
- package/dist/bridge/inspector-commands.js.map +1 -0
- package/dist/bridge/rule-context.d.ts +57 -0
- package/dist/bridge/rule-context.d.ts.map +1 -0
- package/dist/bridge/rule-context.js +302 -0
- package/dist/bridge/rule-context.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/inspector.d.ts +125 -0
- package/dist/inspector.d.ts.map +1 -0
- package/dist/inspector.js +2 -0
- package/dist/inspector.js.map +1 -0
- package/dist/reference/ReferencePicker.d.ts +59 -0
- package/dist/reference/ReferencePicker.d.ts.map +1 -0
- package/dist/reference/ReferencePicker.js +145 -0
- package/dist/reference/ReferencePicker.js.map +1 -0
- package/dist/reference/index.d.ts +13 -0
- package/dist/reference/index.d.ts.map +1 -0
- package/dist/reference/index.js +11 -0
- package/dist/reference/index.js.map +1 -0
- package/dist/reference/token.d.ts +44 -0
- package/dist/reference/token.d.ts.map +1 -0
- package/dist/reference/token.js +141 -0
- package/dist/reference/token.js.map +1 -0
- package/dist/reference/types.d.ts +49 -0
- package/dist/reference/types.d.ts.map +1 -0
- package/dist/reference/types.js +2 -0
- package/dist/reference/types.js.map +1 -0
- package/dist/rules/ConditionEditor.d.ts +38 -0
- package/dist/rules/ConditionEditor.d.ts.map +1 -0
- package/dist/rules/ConditionEditor.js +79 -0
- package/dist/rules/ConditionEditor.js.map +1 -0
- package/dist/rules/RuleBuilder.d.ts +76 -0
- package/dist/rules/RuleBuilder.d.ts.map +1 -0
- package/dist/rules/RuleBuilder.js +336 -0
- package/dist/rules/RuleBuilder.js.map +1 -0
- package/dist/rules/RuleList.d.ts +45 -0
- package/dist/rules/RuleList.d.ts.map +1 -0
- package/dist/rules/RuleList.js +62 -0
- package/dist/rules/RuleList.js.map +1 -0
- package/dist/rules/RuleMessageEditor.d.ts +38 -0
- package/dist/rules/RuleMessageEditor.d.ts.map +1 -0
- package/dist/rules/RuleMessageEditor.js +38 -0
- package/dist/rules/RuleMessageEditor.js.map +1 -0
- package/dist/rules/ValidationEditor.d.ts +60 -0
- package/dist/rules/ValidationEditor.d.ts.map +1 -0
- package/dist/rules/ValidationEditor.js +299 -0
- package/dist/rules/ValidationEditor.js.map +1 -0
- package/dist/rules/condition.d.ts +12 -0
- package/dist/rules/condition.d.ts.map +1 -0
- package/dist/rules/condition.js +46 -0
- package/dist/rules/condition.js.map +1 -0
- package/dist/rules/expression.d.ts +57 -0
- package/dist/rules/expression.d.ts.map +1 -0
- package/dist/rules/expression.js +286 -0
- package/dist/rules/expression.js.map +1 -0
- package/dist/rules/index.d.ts +28 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +19 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/messages.d.ts +64 -0
- package/dist/rules/messages.d.ts.map +1 -0
- package/dist/rules/messages.js +114 -0
- package/dist/rules/messages.js.map +1 -0
- package/dist/rules/operators.d.ts +25 -0
- package/dist/rules/operators.d.ts.map +1 -0
- package/dist/rules/operators.js +128 -0
- package/dist/rules/operators.js.map +1 -0
- package/dist/rules/sentence.d.ts +151 -0
- package/dist/rules/sentence.d.ts.map +1 -0
- package/dist/rules/sentence.js +527 -0
- package/dist/rules/sentence.js.map +1 -0
- package/dist/rules/templates.d.ts +163 -0
- package/dist/rules/templates.d.ts.map +1 -0
- package/dist/rules/templates.js +560 -0
- package/dist/rules/templates.js.map +1 -0
- package/dist/rules/types.d.ts +209 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/types.js +2 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/rules/validation-editor-api.d.ts +12 -0
- package/dist/rules/validation-editor-api.d.ts.map +1 -0
- package/dist/rules/validation-editor-api.js +12 -0
- package/dist/rules/validation-editor-api.js.map +1 -0
- package/dist/rules/validation.d.ts +27 -0
- package/dist/rules/validation.d.ts.map +1 -0
- package/dist/rules/validation.js +184 -0
- package/dist/rules/validation.js.map +1 -0
- package/dist/styles.css +900 -0
- package/package.json +65 -3
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import { ReferencePicker } from '../reference/ReferencePicker.js';
|
|
4
|
+
import { compileSource } from './expression.js';
|
|
5
|
+
import { operandFieldCompatible, operatorsForField, validationOperatorDefinition, } from './operators.js';
|
|
6
|
+
import { validationExpression, withValidationField, withValidationOperator } from './validation.js';
|
|
7
|
+
const DEFAULT_LABELS = {
|
|
8
|
+
field: 'Question',
|
|
9
|
+
operator: 'Is',
|
|
10
|
+
operandMode: 'Compare with',
|
|
11
|
+
valueMode: 'A value',
|
|
12
|
+
fieldMode: 'Another field',
|
|
13
|
+
listMode: 'A list of values',
|
|
14
|
+
tableMode: 'A table',
|
|
15
|
+
value: 'Value',
|
|
16
|
+
chooseField: 'Choose the question to compare with',
|
|
17
|
+
chooseListField: 'Choose a list question',
|
|
18
|
+
chooseTable: 'Choose a table',
|
|
19
|
+
addValue: 'Add another value',
|
|
20
|
+
removeValue: (index) => `Remove value ${String(index + 1)}`,
|
|
21
|
+
lower: 'From',
|
|
22
|
+
upper: 'To',
|
|
23
|
+
pattern: 'Pattern',
|
|
24
|
+
patternPlaceholder: 'A[0-9]{3}',
|
|
25
|
+
advanced: 'Advanced',
|
|
26
|
+
expression: 'Condition',
|
|
27
|
+
expressionValid: 'Looks right.',
|
|
28
|
+
expressionInvalid: 'Not finished yet.',
|
|
29
|
+
noFields: 'Choose a question to begin.',
|
|
30
|
+
noneNeeded: 'This operator needs no value.',
|
|
31
|
+
emptyList: 'Add at least one value.',
|
|
32
|
+
chooseValue: 'Choose…',
|
|
33
|
+
yes: 'Yes',
|
|
34
|
+
no: 'No',
|
|
35
|
+
placeholder: placeholderFor,
|
|
36
|
+
problem: defaultProblem,
|
|
37
|
+
operators: {},
|
|
38
|
+
};
|
|
39
|
+
function defaultProblem(problem) {
|
|
40
|
+
switch (problem.code) {
|
|
41
|
+
case 'missing-field':
|
|
42
|
+
return 'That question is no longer in the form.';
|
|
43
|
+
case 'missing-table':
|
|
44
|
+
return 'That table is no longer in the form.';
|
|
45
|
+
case 'missing-operand':
|
|
46
|
+
return 'Choose a value to compare with.';
|
|
47
|
+
case 'empty-list':
|
|
48
|
+
return 'Add at least one value to the list.';
|
|
49
|
+
case 'invalid-literal':
|
|
50
|
+
return problem.detail;
|
|
51
|
+
case 'unsupported-primitive':
|
|
52
|
+
return 'This answer cannot be typed here.';
|
|
53
|
+
case 'unprintable':
|
|
54
|
+
return `This condition cannot be shown: ${problem.detail}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function operatorLabel(labels, operator) {
|
|
58
|
+
return labels.operators[operator] ?? validationOperatorDefinition(operator).label;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* One field's validation, with an operand editor shaped by the operator.
|
|
62
|
+
*
|
|
63
|
+
* The draft is controlled: every edit calls `onChange` with a complete next draft, and the
|
|
64
|
+
* operator/field combination is kept valid by falling back to an operator the field supports.
|
|
65
|
+
* The expression preview is the printer's canonical source and, when the draft is complete, the
|
|
66
|
+
* compiler's verdict on it. `ReferencePicker` is how an author names another field by its label
|
|
67
|
+
* rather than typing `f_total_area_sqm`.
|
|
68
|
+
*/
|
|
69
|
+
export function ValidationEditor(props) {
|
|
70
|
+
const labels = { ...DEFAULT_LABELS, ...props.labels };
|
|
71
|
+
const reactId = useId();
|
|
72
|
+
const baseId = props.id ?? `axb-validation-${reactId}`;
|
|
73
|
+
const field = props.context.fields.find((candidate) => candidate.fieldId === props.value.fieldId);
|
|
74
|
+
const build = validationExpression(props.value, props.context);
|
|
75
|
+
const check = build.ok ? compileSource(build.source, props.context) : undefined;
|
|
76
|
+
return (_jsxs("div", { className: ['axb-validation', props.className].filter(Boolean).join(' '), children: [_jsxs("div", { className: "axb-validation__row", children: [_jsxs("label", { className: "axb-field", htmlFor: `${baseId}-field`, children: [_jsx("span", { className: "axb-field__label", children: labels.field }), _jsx(GroupedFieldSelect, { id: `${baseId}-field`, fields: props.context.fields, value: props.value.fieldId, disabled: props.disabled === true, labels: labels, onChange: (fieldId) => {
|
|
77
|
+
const next = props.context.fields.find((candidate) => candidate.fieldId === fieldId);
|
|
78
|
+
if (next === undefined)
|
|
79
|
+
return;
|
|
80
|
+
props.onChange(withValidationField(props.value, next));
|
|
81
|
+
} })] }), _jsxs("label", { className: "axb-field", htmlFor: `${baseId}-operator`, children: [_jsx("span", { className: "axb-field__label", children: labels.operator }), _jsx("select", { id: `${baseId}-operator`, className: "axb-select", value: props.value.operator, disabled: props.disabled === true || field === undefined, onChange: (event) => {
|
|
82
|
+
const operator = event.currentTarget.value;
|
|
83
|
+
props.onChange(withValidationOperator(props.value, operator));
|
|
84
|
+
}, children: operatorsFor(field, props.value.operator).map((operator) => (_jsx("option", { value: operator, children: operatorLabel(labels, operator) }, operator))) })] })] }), _jsx("div", { className: "axb-validation__operand", children: _jsx(OperandEditor, { value: props.value, context: props.context, labels: labels, explicitLabels: props.labels, referencePickerLabels: props.referencePickerLabels, disabled: props.disabled === true, baseId: baseId, onChange: props.onChange }) }), props.showExpression === false ? null : (_jsxs("div", { className: "axb-expression", children: [build.ok ? (_jsxs("details", { className: "axb-advanced", children: [_jsx("summary", { children: labels.advanced }), _jsx("span", { className: "axb-expression__label", children: labels.expression }), ' ', _jsx("code", { className: "axb-expression__code", children: build.source })] })) : (_jsx("span", { className: "axb-problem", children: labels.problem(build.problem) })), _jsx("p", { className: build.ok && check?.ok === true ? 'axb-expression__ok' : 'axb-problem', role: "status", "aria-live": "polite", children: build.ok && check?.ok === true ? labels.expressionValid : labels.expressionInvalid }), build.ok && check !== undefined && !check.ok ? (_jsx("ul", { className: "axb-problems", "aria-label": labels.expressionInvalid, children: check.diagnostics.map((diagnostic) => (_jsxs("li", { className: "axb-problem", children: [_jsx("code", { children: diagnostic.code }), " ", diagnostic.detail] }, `${diagnostic.code}-${String(diagnostic.offset)}`))) })) : null] }))] }));
|
|
85
|
+
}
|
|
86
|
+
function operatorsFor(field, current) {
|
|
87
|
+
if (field === undefined)
|
|
88
|
+
return [current];
|
|
89
|
+
const available = operatorsForField(field);
|
|
90
|
+
return available.includes(current) ? available : [current, ...available];
|
|
91
|
+
}
|
|
92
|
+
function OperandEditor(props) {
|
|
93
|
+
const draft = props.value;
|
|
94
|
+
const field = props.context.fields.find((candidate) => candidate.fieldId === draft.fieldId);
|
|
95
|
+
switch (draft.operator) {
|
|
96
|
+
case 'is_empty':
|
|
97
|
+
case 'is_not_empty':
|
|
98
|
+
return _jsx("p", { className: "axb-hint", children: props.labels.noneNeeded });
|
|
99
|
+
case 'equals':
|
|
100
|
+
case 'not_equals':
|
|
101
|
+
case 'greater_than':
|
|
102
|
+
case 'less_than':
|
|
103
|
+
case 'greater_or_equal':
|
|
104
|
+
case 'less_or_equal':
|
|
105
|
+
case 'contains':
|
|
106
|
+
case 'starts_with':
|
|
107
|
+
case 'ends_with':
|
|
108
|
+
return (_jsxs("div", { className: "axb-operand", children: [_jsx(ModeSelect, { id: `${props.baseId}-mode`, value: draft.operand.kind, labels: props.labels, modes: ['value', 'field'], disabled: props.disabled, onChange: (mode) => {
|
|
109
|
+
if (mode !== 'value' && mode !== 'field')
|
|
110
|
+
return;
|
|
111
|
+
props.onChange(setOperand(draft, operandForMode(mode, draft.operand, draft.operator, field, props.context.fields)));
|
|
112
|
+
} }), _jsx(SingleOperand, { operand: draft.operand, field: field, operator: draft.operator, context: props.context, labels: props.labels, explicitChooseFieldLabel: props.explicitLabels?.chooseField, referencePickerLabels: props.referencePickerLabels, disabled: props.disabled, onChange: (operand) => props.onChange(setOperand(draft, operand)) })] }));
|
|
113
|
+
case 'one_of':
|
|
114
|
+
case 'not_one_of':
|
|
115
|
+
return (_jsx(ListOperandEditor, { operand: draft.operand, field: field, operator: draft.operator, context: props.context, labels: props.labels, explicitChooseListFieldLabel: props.explicitLabels?.chooseListField, referencePickerLabels: props.referencePickerLabels, disabled: props.disabled, baseId: props.baseId, onChange: (operand) => props.onChange(setListOperand(draft, operand)) }));
|
|
116
|
+
case 'between':
|
|
117
|
+
return (_jsxs("div", { className: "axb-between", children: [_jsxs("div", { className: "axb-operand", children: [_jsx(ModeSelect, { id: `${props.baseId}-lower-mode`, value: draft.lower.kind, labels: props.labels, modes: ['value', 'field'], disabled: props.disabled, onChange: (mode) => {
|
|
118
|
+
if (mode !== 'value' && mode !== 'field')
|
|
119
|
+
return;
|
|
120
|
+
props.onChange({
|
|
121
|
+
...draft,
|
|
122
|
+
lower: operandForMode(mode, draft.lower, 'between', field, props.context.fields),
|
|
123
|
+
});
|
|
124
|
+
} }), _jsx(SingleOperand, { operand: draft.lower, field: field, operator: draft.operator, context: props.context, labels: { ...props.labels, value: props.labels.lower }, explicitChooseFieldLabel: props.explicitLabels?.chooseField, referencePickerLabels: props.referencePickerLabels, disabled: props.disabled, onChange: (lower) => props.onChange({ ...draft, lower }) })] }), _jsxs("div", { className: "axb-operand", children: [_jsx(ModeSelect, { id: `${props.baseId}-upper-mode`, value: draft.upper.kind, labels: props.labels, modes: ['value', 'field'], disabled: props.disabled, onChange: (mode) => {
|
|
125
|
+
if (mode !== 'value' && mode !== 'field')
|
|
126
|
+
return;
|
|
127
|
+
props.onChange({
|
|
128
|
+
...draft,
|
|
129
|
+
upper: operandForMode(mode, draft.upper, 'between', field, props.context.fields),
|
|
130
|
+
});
|
|
131
|
+
} }), _jsx(SingleOperand, { operand: draft.upper, field: field, operator: draft.operator, context: props.context, labels: { ...props.labels, value: props.labels.upper }, explicitChooseFieldLabel: props.explicitLabels?.chooseField, referencePickerLabels: props.referencePickerLabels, disabled: props.disabled, onChange: (upper) => props.onChange({ ...draft, upper }) })] })] }));
|
|
132
|
+
case 'matches_pattern':
|
|
133
|
+
return (_jsxs("label", { className: "axb-field", children: [_jsx("span", { className: "axb-field__label", children: props.labels.pattern }), _jsx("input", { className: "axb-input axb-input--mono", type: "text", value: draft.pattern, disabled: props.disabled, placeholder: props.labels.patternPlaceholder, onChange: (event) => props.onChange({ ...draft, pattern: event.currentTarget.value }) })] }));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function ModeSelect(props) {
|
|
137
|
+
const label = (mode) => {
|
|
138
|
+
switch (mode) {
|
|
139
|
+
case 'value':
|
|
140
|
+
return props.labels.valueMode;
|
|
141
|
+
case 'field':
|
|
142
|
+
return props.labels.fieldMode;
|
|
143
|
+
case 'list':
|
|
144
|
+
return props.labels.listMode;
|
|
145
|
+
case 'table':
|
|
146
|
+
return props.labels.tableMode;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
return (_jsxs("label", { className: "axb-field axb-field--inline", htmlFor: props.id, children: [_jsx("span", { className: "axb-field__label", children: props.labels.operandMode }), _jsx("select", { id: props.id, className: "axb-select", value: props.value, disabled: props.disabled, onChange: (event) => {
|
|
150
|
+
const mode = event.currentTarget.value;
|
|
151
|
+
if (mode === 'value' || mode === 'field' || mode === 'list' || mode === 'table') {
|
|
152
|
+
props.onChange(mode);
|
|
153
|
+
}
|
|
154
|
+
}, children: props.modes.map((mode) => (_jsx("option", { value: mode, children: label(mode) }, mode))) })] }));
|
|
155
|
+
}
|
|
156
|
+
function SingleOperand(props) {
|
|
157
|
+
const operand = props.operand;
|
|
158
|
+
if (operand.kind === 'field') {
|
|
159
|
+
const chosen = props.context.fields.find((field) => field.fieldId === operand.fieldId);
|
|
160
|
+
const pickerLabels = {
|
|
161
|
+
...props.referencePickerLabels,
|
|
162
|
+
label: props.explicitChooseFieldLabel ??
|
|
163
|
+
props.referencePickerLabels?.label ??
|
|
164
|
+
props.labels.chooseField,
|
|
165
|
+
};
|
|
166
|
+
return (_jsxs("div", { className: "axb-operand__field", children: [chosen === undefined ? null : (_jsx("p", { className: "axb-operand__chosen", children: _jsx("span", { children: chosen.label }) })), _jsx(ReferencePicker, { fields: fieldsForOperand(props.operator, props.field, props.context.fields), tokenFields: props.context.fields, disabled: props.disabled, labels: pickerLabels, onPick: (reference) => props.onChange({ kind: 'field', fieldId: reference.fieldId }) })] }));
|
|
167
|
+
}
|
|
168
|
+
return (_jsx(ValueTextInput, { field: props.field, value: operand.text, disabled: props.disabled, label: props.labels.value, labels: props.labels, onChange: (text) => props.onChange({ kind: 'value', text }) }));
|
|
169
|
+
}
|
|
170
|
+
function ValueTextInput(props) {
|
|
171
|
+
const primitive = props.field?.primitive ?? 'string';
|
|
172
|
+
if (primitive === 'boolean') {
|
|
173
|
+
return (_jsxs("label", { className: "axb-field", children: [_jsx("span", { className: "axb-field__label", children: props.label }), _jsxs("select", { className: "axb-select", value: props.value, disabled: props.disabled, onChange: (event) => props.onChange(event.currentTarget.value), children: [_jsx("option", { value: "", children: props.labels.chooseValue }), _jsx("option", { value: "true", children: props.labels.yes }), _jsx("option", { value: "false", children: props.labels.no })] })] }));
|
|
174
|
+
}
|
|
175
|
+
const inputMode = primitive === 'integer' || primitive === 'decimal' || primitive === 'money'
|
|
176
|
+
? 'decimal'
|
|
177
|
+
: undefined;
|
|
178
|
+
return (_jsxs("label", { className: "axb-field", children: [_jsx("span", { className: "axb-field__label", children: props.label }), _jsx("input", { className: "axb-input", type: primitive === 'date' ? 'date' : 'text', inputMode: inputMode, value: props.value, disabled: props.disabled, placeholder: props.labels.placeholder(primitive), onChange: (event) => props.onChange(event.currentTarget.value) })] }));
|
|
179
|
+
}
|
|
180
|
+
function placeholderFor(primitive) {
|
|
181
|
+
switch (primitive) {
|
|
182
|
+
case 'integer':
|
|
183
|
+
return '42';
|
|
184
|
+
case 'decimal':
|
|
185
|
+
return '12.5';
|
|
186
|
+
case 'money':
|
|
187
|
+
return '10.50';
|
|
188
|
+
case 'date':
|
|
189
|
+
return '2026-01-31';
|
|
190
|
+
case 'instant':
|
|
191
|
+
return '2026-01-31T09:00:00.000Z';
|
|
192
|
+
default:
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function ListOperandEditor(props) {
|
|
197
|
+
const hasFieldCandidate = fieldsForOperand(props.operator, props.field, props.context.fields).length > 0;
|
|
198
|
+
const setTables = (props.context.tables ?? []).filter((table) => table.kind === 'set');
|
|
199
|
+
const modes = ['list'];
|
|
200
|
+
if (hasFieldCandidate)
|
|
201
|
+
modes.push('field');
|
|
202
|
+
if (setTables.length > 0)
|
|
203
|
+
modes.push('table');
|
|
204
|
+
return (_jsxs("div", { className: "axb-list-operand", children: [_jsx(ModeSelect, { id: `${props.baseId}-list-mode`, value: props.operand.kind, labels: props.labels, modes: modes, disabled: props.disabled, onChange: (mode) => {
|
|
205
|
+
if (mode === 'list')
|
|
206
|
+
props.onChange({ kind: 'list', items: [] });
|
|
207
|
+
if (mode === 'field') {
|
|
208
|
+
props.onChange({
|
|
209
|
+
kind: 'field',
|
|
210
|
+
fieldId: fieldsForOperand(props.operator, props.field, props.context.fields)[0]?.fieldId ??
|
|
211
|
+
'',
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
if (mode === 'table') {
|
|
215
|
+
props.onChange({ kind: 'table', tableId: setTables[0]?.tableId ?? '' });
|
|
216
|
+
}
|
|
217
|
+
} }), props.operand.kind === 'list' ? (props.field === undefined ? null : (_jsxs("div", { className: "axb-list-editor", children: [props.operand.items.map((item, index) => (_jsxs("div", { className: "axb-list-editor__row", children: [_jsx(ValueTextInput, { field: props.field, value: item, disabled: props.disabled, label: `${props.labels.value} ${String(index + 1)}`, labels: props.labels, onChange: (text) => {
|
|
218
|
+
const items = props.operand.kind === 'list' ? [...props.operand.items] : [];
|
|
219
|
+
items[index] = text;
|
|
220
|
+
props.onChange({ kind: 'list', items });
|
|
221
|
+
} }), _jsx("button", { type: "button", className: "axb-button axb-button--quiet", disabled: props.disabled, "aria-label": props.labels.removeValue(index), onClick: () => {
|
|
222
|
+
const items = props.operand.kind === 'list' ? [...props.operand.items] : [];
|
|
223
|
+
props.onChange({
|
|
224
|
+
kind: 'list',
|
|
225
|
+
items: items.filter((_, position) => position !== index),
|
|
226
|
+
});
|
|
227
|
+
}, children: "\u00D7" })] }, String(index)))), _jsx("button", { type: "button", className: "axb-button", disabled: props.disabled, onClick: () => {
|
|
228
|
+
const items = props.operand.kind === 'list' ? [...props.operand.items] : [];
|
|
229
|
+
props.onChange({ kind: 'list', items: [...items, ''] });
|
|
230
|
+
}, children: props.labels.addValue }), props.operand.items.length === 0 ? (_jsx("p", { className: "axb-hint", children: props.labels.emptyList })) : null] }))) : null, props.operand.kind === 'field' ? (_jsx(ReferencePicker, { fields: fieldsForOperand(props.operator, props.field, props.context.fields), tokenFields: props.context.fields, disabled: props.disabled, labels: {
|
|
231
|
+
...props.referencePickerLabels,
|
|
232
|
+
label: props.explicitChooseListFieldLabel ??
|
|
233
|
+
props.referencePickerLabels?.label ??
|
|
234
|
+
props.labels.chooseListField,
|
|
235
|
+
}, onPick: (reference) => props.onChange({ kind: 'field', fieldId: reference.fieldId }) })) : null, props.operand.kind === 'table' ? (_jsxs("label", { className: "axb-field", children: [_jsx("span", { className: "axb-field__label", children: props.labels.chooseTable }), _jsx("select", { className: "axb-select", value: props.operand.tableId, disabled: props.disabled, onChange: (event) => props.onChange({ kind: 'table', tableId: event.currentTarget.value }), children: setTables.map((table) => (_jsx("option", { value: table.tableId, children: table.label }, table.tableId))) })] })) : null] }));
|
|
236
|
+
}
|
|
237
|
+
function fieldsForOperand(operator, field, fields) {
|
|
238
|
+
const primitive = field?.primitive;
|
|
239
|
+
if (primitive === undefined)
|
|
240
|
+
return [];
|
|
241
|
+
return fields.filter((candidate) => operandFieldCompatible(operator, primitive, candidate));
|
|
242
|
+
}
|
|
243
|
+
function firstCompatibleField(operator, field, fields) {
|
|
244
|
+
return fieldsForOperand(operator, field, fields)[0];
|
|
245
|
+
}
|
|
246
|
+
function operandForMode(mode, current, operator, field, fields) {
|
|
247
|
+
if (mode === 'field') {
|
|
248
|
+
return {
|
|
249
|
+
kind: 'field',
|
|
250
|
+
fieldId: firstCompatibleField(operator, field, fields)?.fieldId ?? '',
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
return { kind: 'value', text: current.kind === 'value' ? current.text : '' };
|
|
254
|
+
}
|
|
255
|
+
function setOperand(draft, operand) {
|
|
256
|
+
switch (draft.operator) {
|
|
257
|
+
case 'equals':
|
|
258
|
+
case 'not_equals':
|
|
259
|
+
case 'greater_than':
|
|
260
|
+
case 'less_than':
|
|
261
|
+
case 'greater_or_equal':
|
|
262
|
+
case 'less_or_equal':
|
|
263
|
+
case 'contains':
|
|
264
|
+
case 'starts_with':
|
|
265
|
+
case 'ends_with':
|
|
266
|
+
return { ...draft, operand };
|
|
267
|
+
default:
|
|
268
|
+
return draft;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function setListOperand(draft, operand) {
|
|
272
|
+
if (draft.operator === 'one_of' || draft.operator === 'not_one_of') {
|
|
273
|
+
return { ...draft, operand };
|
|
274
|
+
}
|
|
275
|
+
return draft;
|
|
276
|
+
}
|
|
277
|
+
/** A grouped field selector for the subject field, which needs no search at normal form sizes. */
|
|
278
|
+
function GroupedFieldSelect(props) {
|
|
279
|
+
if (props.fields.length === 0) {
|
|
280
|
+
return _jsx("span", { className: "axb-hint", children: props.labels.noFields });
|
|
281
|
+
}
|
|
282
|
+
const groups = new Map();
|
|
283
|
+
for (const field of props.fields) {
|
|
284
|
+
const key = `${field.pageLabel ?? ''}\u0000${field.sectionLabel ?? ''}`;
|
|
285
|
+
const group = groups.get(key);
|
|
286
|
+
if (group === undefined)
|
|
287
|
+
groups.set(key, [field]);
|
|
288
|
+
else
|
|
289
|
+
group.push(field);
|
|
290
|
+
}
|
|
291
|
+
return (_jsxs("select", { id: props.id, className: "axb-select", value: props.value, disabled: props.disabled, onChange: (event) => props.onChange(event.currentTarget.value), children: [_jsx("option", { value: "", children: props.labels.chooseValue }), [...groups].map(([key, fields]) => {
|
|
292
|
+
const [first] = fields;
|
|
293
|
+
const page = first?.pageLabel;
|
|
294
|
+
const section = first?.sectionLabel;
|
|
295
|
+
const label = section ?? page ?? '';
|
|
296
|
+
return (_jsx("optgroup", { label: label, children: fields.map((field) => (_jsx("option", { value: field.fieldId, children: field.label }, field.fieldId))) }, key));
|
|
297
|
+
})] }));
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=ValidationEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationEditor.js","sourceRoot":"","sources":["../../src/rules/ValidationEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,4BAA4B,GAC7B,MAAM,gBAAgB,CAAC;AAUxB,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAoCpG,MAAM,cAAc,GAA2B;IAC7C,KAAK,EAAE,UAAU;IACjB,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,cAAc;IAC3B,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,eAAe;IAC1B,QAAQ,EAAE,kBAAkB;IAC5B,SAAS,EAAE,SAAS;IACpB,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,qCAAqC;IAClD,eAAe,EAAE,wBAAwB;IACzC,WAAW,EAAE,gBAAgB;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BACE,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,aAE9D,iBAAQ,KAAK,EAAC,EAAE,YAAE,KAAK,CAAC,MAAM,CAAC,WAAW,GAAU,EACnD,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE;gBACjC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;gBACvB,MAAM,IAAI,GAAG,KAAK,EAAE,SAAS,CAAC;gBAC9B,MAAM,OAAO,GAAG,KAAK,EAAE,YAAY,CAAC;gBACpC,MAAM,KAAK,GAAG,OAAO,IAAI,IAAI,IAAI,EAAE,CAAC;gBACpC,OAAO,CACL,mBAAoB,KAAK,EAAE,KAAK,YAC7B,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,iBAA4B,KAAK,EAAE,KAAK,CAAC,OAAO,YAC7C,KAAK,CAAC,KAAK,IADD,KAAK,CAAC,OAAO,CAEjB,CACV,CAAC,IALW,GAAG,CAMP,CACZ,CAAC;YACJ,CAAC,CAAC,IACK,CACV,CAAC;AACJ,CAAC","sourcesContent":["import { useId } from 'react';\nimport type { ReactElement } from 'react';\nimport { ReferencePicker } from '../reference/ReferencePicker.js';\nimport type { ReferencePickerLabels } from '../reference/ReferencePicker.js';\nimport { compileSource } from './expression.js';\nimport {\n operandFieldCompatible,\n operatorsForField,\n validationOperatorDefinition,\n} from './operators.js';\nimport type {\n ExpressionProblem,\n ListOperand,\n RuleContext,\n RuleField,\n ValidationDraft,\n ValidationOperator,\n ValueOperand,\n} from './types.js';\nimport { validationExpression, withValidationField, withValidationOperator } from './validation.js';\n\n/** The overridable chrome a validation editor uses; no document text lives here. */\nexport interface ValidationEditorLabels {\n readonly field: string;\n readonly operator: string;\n readonly operandMode: string;\n readonly valueMode: string;\n readonly fieldMode: string;\n readonly listMode: string;\n readonly tableMode: string;\n readonly value: string;\n readonly chooseField: string;\n readonly chooseListField: string;\n readonly chooseTable: string;\n readonly addValue: string;\n readonly removeValue: (index: number) => string;\n readonly lower: string;\n readonly upper: string;\n readonly pattern: string;\n readonly patternPlaceholder: string;\n readonly advanced: string;\n readonly expression: string;\n readonly expressionValid: string;\n readonly expressionInvalid: string;\n readonly noFields: string;\n readonly noneNeeded: string;\n readonly emptyList: string;\n readonly chooseValue: string;\n readonly yes: string;\n readonly no: string;\n readonly placeholder: (primitive: RuleField['primitive']) => string | undefined;\n readonly problem: (problem: ExpressionProblem) => string;\n readonly operators: Readonly<Partial<Record<ValidationOperator, string>>>;\n}\n\nconst DEFAULT_LABELS: ValidationEditorLabels = {\n field: 'Question',\n operator: 'Is',\n operandMode: 'Compare with',\n valueMode: 'A value',\n fieldMode: 'Another field',\n listMode: 'A list of values',\n tableMode: 'A table',\n value: 'Value',\n chooseField: 'Choose the question to compare with',\n chooseListField: 'Choose a list question',\n chooseTable: 'Choose a table',\n addValue: 'Add another value',\n removeValue: (index: number) => `Remove value ${String(index + 1)}`,\n lower: 'From',\n upper: 'To',\n pattern: 'Pattern',\n patternPlaceholder: 'A[0-9]{3}',\n advanced: 'Advanced',\n expression: 'Condition',\n expressionValid: 'Looks right.',\n expressionInvalid: 'Not finished yet.',\n noFields: 'Choose a question to begin.',\n noneNeeded: 'This operator needs no value.',\n emptyList: 'Add at least one value.',\n chooseValue: 'Choose…',\n yes: 'Yes',\n no: 'No',\n placeholder: placeholderFor,\n problem: defaultProblem,\n operators: {},\n};\n\n/** One editor's props: a draft in, a changed draft out, and the context it is checked against. */\nexport interface ValidationEditorProps {\n readonly value: ValidationDraft;\n readonly context: RuleContext;\n readonly onChange: (draft: ValidationDraft) => void;\n readonly labels?: Partial<ValidationEditorLabels> | undefined;\n readonly referencePickerLabels?: Partial<ReferencePickerLabels> | undefined;\n readonly disabled?: boolean | undefined;\n readonly id?: string | undefined;\n readonly className?: string | undefined;\n /** Hide the expression preview inside a condition tree, where the parent shows one. */\n readonly showExpression?: boolean | undefined;\n}\n\nfunction defaultProblem(problem: ExpressionProblem): string {\n switch (problem.code) {\n case 'missing-field':\n return 'That question is no longer in the form.';\n case 'missing-table':\n return 'That table is no longer in the form.';\n case 'missing-operand':\n return 'Choose a value to compare with.';\n case 'empty-list':\n return 'Add at least one value to the list.';\n case 'invalid-literal':\n return problem.detail;\n case 'unsupported-primitive':\n return 'This answer cannot be typed here.';\n case 'unprintable':\n return `This condition cannot be shown: ${problem.detail}`;\n }\n}\n\nfunction operatorLabel(labels: ValidationEditorLabels, operator: ValidationOperator): string {\n return labels.operators[operator] ?? validationOperatorDefinition(operator).label;\n}\n\n/**\n * One field's validation, with an operand editor shaped by the operator.\n *\n * The draft is controlled: every edit calls `onChange` with a complete next draft, and the\n * operator/field combination is kept valid by falling back to an operator the field supports.\n * The expression preview is the printer's canonical source and, when the draft is complete, the\n * compiler's verdict on it. `ReferencePicker` is how an author names another field by its label\n * rather than typing `f_total_area_sqm`.\n */\nexport function ValidationEditor(props: ValidationEditorProps): ReactElement {\n const labels: ValidationEditorLabels = { ...DEFAULT_LABELS, ...props.labels };\n const reactId = useId();\n const baseId = props.id ?? `axb-validation-${reactId}`;\n const field = props.context.fields.find((candidate) => candidate.fieldId === props.value.fieldId);\n const build = validationExpression(props.value, props.context);\n const check = build.ok ? compileSource(build.source, props.context) : undefined;\n\n return (\n <div className={['axb-validation', props.className].filter(Boolean).join(' ')}>\n <div className=\"axb-validation__row\">\n <label className=\"axb-field\" htmlFor={`${baseId}-field`}>\n <span className=\"axb-field__label\">{labels.field}</span>\n <GroupedFieldSelect\n id={`${baseId}-field`}\n fields={props.context.fields}\n value={props.value.fieldId}\n disabled={props.disabled === true}\n labels={labels}\n onChange={(fieldId) => {\n const next = props.context.fields.find((candidate) => candidate.fieldId === fieldId);\n if (next === undefined) return;\n props.onChange(withValidationField(props.value, next));\n }}\n />\n </label>\n <label className=\"axb-field\" htmlFor={`${baseId}-operator`}>\n <span className=\"axb-field__label\">{labels.operator}</span>\n <select\n id={`${baseId}-operator`}\n className=\"axb-select\"\n value={props.value.operator}\n disabled={props.disabled === true || field === undefined}\n onChange={(event) => {\n const operator = event.currentTarget.value as ValidationOperator;\n props.onChange(withValidationOperator(props.value, operator));\n }}\n >\n {operatorsFor(field, props.value.operator).map((operator) => (\n <option key={operator} value={operator}>\n {operatorLabel(labels, operator)}\n </option>\n ))}\n </select>\n </label>\n </div>\n <div className=\"axb-validation__operand\">\n <OperandEditor\n value={props.value}\n context={props.context}\n labels={labels}\n explicitLabels={props.labels}\n referencePickerLabels={props.referencePickerLabels}\n disabled={props.disabled === true}\n baseId={baseId}\n onChange={props.onChange}\n />\n </div>\n {props.showExpression === false ? null : (\n <div className=\"axb-expression\">\n {build.ok ? (\n <details className=\"axb-advanced\">\n <summary>{labels.advanced}</summary>\n <span className=\"axb-expression__label\">{labels.expression}</span>{' '}\n <code className=\"axb-expression__code\">{build.source}</code>\n </details>\n ) : (\n <span className=\"axb-problem\">{labels.problem(build.problem)}</span>\n )}\n {/*\n The region announces the verdict only. The expression above and the diagnostic list\n below are rewritten per keystroke; putting them inside the polite region would make a\n screen reader read the whole block again for every character typed.\n */}\n <p\n className={build.ok && check?.ok === true ? 'axb-expression__ok' : 'axb-problem'}\n role=\"status\"\n aria-live=\"polite\"\n >\n {build.ok && check?.ok === true ? labels.expressionValid : labels.expressionInvalid}\n </p>\n {build.ok && check !== undefined && !check.ok ? (\n <ul className=\"axb-problems\" aria-label={labels.expressionInvalid}>\n {check.diagnostics.map((diagnostic) => (\n <li key={`${diagnostic.code}-${String(diagnostic.offset)}`} className=\"axb-problem\">\n <code>{diagnostic.code}</code> {diagnostic.detail}\n </li>\n ))}\n </ul>\n ) : null}\n </div>\n )}\n </div>\n );\n}\n\nfunction operatorsFor(\n field: RuleField | undefined,\n current: ValidationOperator,\n): readonly ValidationOperator[] {\n if (field === undefined) return [current];\n const available = operatorsForField(field);\n return available.includes(current) ? available : [current, ...available];\n}\n\ninterface OperandEditorProps {\n readonly value: ValidationDraft;\n readonly context: RuleContext;\n readonly labels: ValidationEditorLabels;\n readonly explicitLabels: Partial<ValidationEditorLabels> | undefined;\n readonly referencePickerLabels: Partial<ReferencePickerLabels> | undefined;\n readonly disabled: boolean;\n readonly baseId: string;\n readonly onChange: (draft: ValidationDraft) => void;\n}\n\nfunction OperandEditor(props: OperandEditorProps): ReactElement {\n const draft = props.value;\n const field = props.context.fields.find((candidate) => candidate.fieldId === draft.fieldId);\n switch (draft.operator) {\n case 'is_empty':\n case 'is_not_empty':\n return <p className=\"axb-hint\">{props.labels.noneNeeded}</p>;\n case 'equals':\n case 'not_equals':\n case 'greater_than':\n case 'less_than':\n case 'greater_or_equal':\n case 'less_or_equal':\n case 'contains':\n case 'starts_with':\n case 'ends_with':\n return (\n <div className=\"axb-operand\">\n <ModeSelect\n id={`${props.baseId}-mode`}\n value={draft.operand.kind}\n labels={props.labels}\n modes={['value', 'field']}\n disabled={props.disabled}\n onChange={(mode) => {\n if (mode !== 'value' && mode !== 'field') return;\n props.onChange(\n setOperand(\n draft,\n operandForMode(mode, draft.operand, draft.operator, field, props.context.fields),\n ),\n );\n }}\n />\n <SingleOperand\n operand={draft.operand}\n field={field}\n operator={draft.operator}\n context={props.context}\n labels={props.labels}\n explicitChooseFieldLabel={props.explicitLabels?.chooseField}\n referencePickerLabels={props.referencePickerLabels}\n disabled={props.disabled}\n onChange={(operand) => props.onChange(setOperand(draft, operand))}\n />\n </div>\n );\n case 'one_of':\n case 'not_one_of':\n return (\n <ListOperandEditor\n operand={draft.operand}\n field={field}\n operator={draft.operator}\n context={props.context}\n labels={props.labels}\n explicitChooseListFieldLabel={props.explicitLabels?.chooseListField}\n referencePickerLabels={props.referencePickerLabels}\n disabled={props.disabled}\n baseId={props.baseId}\n onChange={(operand) => props.onChange(setListOperand(draft, operand))}\n />\n );\n case 'between':\n return (\n <div className=\"axb-between\">\n <div className=\"axb-operand\">\n <ModeSelect\n id={`${props.baseId}-lower-mode`}\n value={draft.lower.kind}\n labels={props.labels}\n modes={['value', 'field']}\n disabled={props.disabled}\n onChange={(mode) => {\n if (mode !== 'value' && mode !== 'field') return;\n props.onChange({\n ...draft,\n lower: operandForMode(mode, draft.lower, 'between', field, props.context.fields),\n });\n }}\n />\n <SingleOperand\n operand={draft.lower}\n field={field}\n operator={draft.operator}\n context={props.context}\n labels={{ ...props.labels, value: props.labels.lower }}\n explicitChooseFieldLabel={props.explicitLabels?.chooseField}\n referencePickerLabels={props.referencePickerLabels}\n disabled={props.disabled}\n onChange={(lower) => props.onChange({ ...draft, lower })}\n />\n </div>\n <div className=\"axb-operand\">\n <ModeSelect\n id={`${props.baseId}-upper-mode`}\n value={draft.upper.kind}\n labels={props.labels}\n modes={['value', 'field']}\n disabled={props.disabled}\n onChange={(mode) => {\n if (mode !== 'value' && mode !== 'field') return;\n props.onChange({\n ...draft,\n upper: operandForMode(mode, draft.upper, 'between', field, props.context.fields),\n });\n }}\n />\n <SingleOperand\n operand={draft.upper}\n field={field}\n operator={draft.operator}\n context={props.context}\n labels={{ ...props.labels, value: props.labels.upper }}\n explicitChooseFieldLabel={props.explicitLabels?.chooseField}\n referencePickerLabels={props.referencePickerLabels}\n disabled={props.disabled}\n onChange={(upper) => props.onChange({ ...draft, upper })}\n />\n </div>\n </div>\n );\n case 'matches_pattern':\n return (\n <label className=\"axb-field\">\n <span className=\"axb-field__label\">{props.labels.pattern}</span>\n <input\n className=\"axb-input axb-input--mono\"\n type=\"text\"\n value={draft.pattern}\n disabled={props.disabled}\n placeholder={props.labels.patternPlaceholder}\n onChange={(event) => props.onChange({ ...draft, pattern: event.currentTarget.value })}\n />\n </label>\n );\n }\n}\n\nfunction ModeSelect(props: {\n readonly id: string;\n readonly value: string;\n readonly labels: ValidationEditorLabels;\n readonly modes: readonly ('value' | 'field' | 'list' | 'table')[];\n readonly disabled: boolean;\n readonly onChange: (mode: 'value' | 'field' | 'list' | 'table') => void;\n}): ReactElement {\n const label = (mode: 'value' | 'field' | 'list' | 'table'): string => {\n switch (mode) {\n case 'value':\n return props.labels.valueMode;\n case 'field':\n return props.labels.fieldMode;\n case 'list':\n return props.labels.listMode;\n case 'table':\n return props.labels.tableMode;\n }\n };\n return (\n <label className=\"axb-field axb-field--inline\" htmlFor={props.id}>\n <span className=\"axb-field__label\">{props.labels.operandMode}</span>\n <select\n id={props.id}\n className=\"axb-select\"\n value={props.value}\n disabled={props.disabled}\n onChange={(event) => {\n const mode = event.currentTarget.value;\n if (mode === 'value' || mode === 'field' || mode === 'list' || mode === 'table') {\n props.onChange(mode);\n }\n }}\n >\n {props.modes.map((mode) => (\n <option key={mode} value={mode}>\n {label(mode)}\n </option>\n ))}\n </select>\n </label>\n );\n}\n\nfunction SingleOperand(props: {\n readonly operand: ValueOperand;\n readonly field: RuleField | undefined;\n readonly operator: ValidationOperator;\n readonly context: RuleContext;\n readonly labels: ValidationEditorLabels;\n readonly explicitChooseFieldLabel: string | undefined;\n readonly referencePickerLabels: Partial<ReferencePickerLabels> | undefined;\n readonly disabled: boolean;\n readonly onChange: (operand: ValueOperand) => void;\n}): ReactElement {\n const operand = props.operand;\n if (operand.kind === 'field') {\n const chosen = props.context.fields.find((field) => field.fieldId === operand.fieldId);\n const pickerLabels: Partial<ReferencePickerLabels> = {\n ...props.referencePickerLabels,\n label:\n props.explicitChooseFieldLabel ??\n props.referencePickerLabels?.label ??\n props.labels.chooseField,\n };\n return (\n <div className=\"axb-operand__field\">\n {chosen === undefined ? null : (\n <p className=\"axb-operand__chosen\">\n <span>{chosen.label}</span>\n </p>\n )}\n <ReferencePicker\n fields={fieldsForOperand(props.operator, props.field, props.context.fields)}\n tokenFields={props.context.fields}\n disabled={props.disabled}\n labels={pickerLabels}\n onPick={(reference) => props.onChange({ kind: 'field', fieldId: reference.fieldId })}\n />\n </div>\n );\n }\n return (\n <ValueTextInput\n field={props.field}\n value={operand.text}\n disabled={props.disabled}\n label={props.labels.value}\n labels={props.labels}\n onChange={(text) => props.onChange({ kind: 'value', text })}\n />\n );\n}\n\nfunction ValueTextInput(props: {\n readonly field: RuleField | undefined;\n readonly value: string;\n readonly disabled: boolean;\n readonly label: string;\n readonly labels: ValidationEditorLabels;\n readonly onChange: (text: string) => void;\n}): ReactElement {\n const primitive = props.field?.primitive ?? 'string';\n if (primitive === 'boolean') {\n return (\n <label className=\"axb-field\">\n <span className=\"axb-field__label\">{props.label}</span>\n <select\n className=\"axb-select\"\n value={props.value}\n disabled={props.disabled}\n onChange={(event) => props.onChange(event.currentTarget.value)}\n >\n <option value=\"\">{props.labels.chooseValue}</option>\n <option value=\"true\">{props.labels.yes}</option>\n <option value=\"false\">{props.labels.no}</option>\n </select>\n </label>\n );\n }\n const inputMode: 'decimal' | undefined =\n primitive === 'integer' || primitive === 'decimal' || primitive === 'money'\n ? 'decimal'\n : undefined;\n return (\n <label className=\"axb-field\">\n <span className=\"axb-field__label\">{props.label}</span>\n <input\n className=\"axb-input\"\n type={primitive === 'date' ? 'date' : 'text'}\n inputMode={inputMode}\n value={props.value}\n disabled={props.disabled}\n placeholder={props.labels.placeholder(primitive)}\n onChange={(event) => props.onChange(event.currentTarget.value)}\n />\n </label>\n );\n}\n\nfunction placeholderFor(primitive: RuleField['primitive']): string | undefined {\n switch (primitive) {\n case 'integer':\n return '42';\n case 'decimal':\n return '12.5';\n case 'money':\n return '10.50';\n case 'date':\n return '2026-01-31';\n case 'instant':\n return '2026-01-31T09:00:00.000Z';\n default:\n return undefined;\n }\n}\n\nfunction ListOperandEditor(props: {\n readonly operand: ListOperand;\n readonly field: RuleField | undefined;\n readonly operator: 'one_of' | 'not_one_of';\n readonly context: RuleContext;\n readonly labels: ValidationEditorLabels;\n readonly explicitChooseListFieldLabel: string | undefined;\n readonly referencePickerLabels: Partial<ReferencePickerLabels> | undefined;\n readonly disabled: boolean;\n readonly baseId: string;\n readonly onChange: (operand: ListOperand) => void;\n}): ReactElement {\n const hasFieldCandidate =\n fieldsForOperand(props.operator, props.field, props.context.fields).length > 0;\n const setTables = (props.context.tables ?? []).filter((table) => table.kind === 'set');\n const modes: ('list' | 'field' | 'table')[] = ['list'];\n if (hasFieldCandidate) modes.push('field');\n if (setTables.length > 0) modes.push('table');\n return (\n <div className=\"axb-list-operand\">\n <ModeSelect\n id={`${props.baseId}-list-mode`}\n value={props.operand.kind}\n labels={props.labels}\n modes={modes}\n disabled={props.disabled}\n onChange={(mode) => {\n if (mode === 'list') props.onChange({ kind: 'list', items: [] });\n if (mode === 'field') {\n props.onChange({\n kind: 'field',\n fieldId:\n fieldsForOperand(props.operator, props.field, props.context.fields)[0]?.fieldId ??\n '',\n });\n }\n if (mode === 'table') {\n props.onChange({ kind: 'table', tableId: setTables[0]?.tableId ?? '' });\n }\n }}\n />\n {props.operand.kind === 'list' ? (\n props.field === undefined ? null : (\n <div className=\"axb-list-editor\">\n {props.operand.items.map((item, index) => (\n <div key={String(index)} className=\"axb-list-editor__row\">\n <ValueTextInput\n field={props.field}\n value={item}\n disabled={props.disabled}\n label={`${props.labels.value} ${String(index + 1)}`}\n labels={props.labels}\n onChange={(text) => {\n const items = props.operand.kind === 'list' ? [...props.operand.items] : [];\n items[index] = text;\n props.onChange({ kind: 'list', items });\n }}\n />\n <button\n type=\"button\"\n className=\"axb-button axb-button--quiet\"\n disabled={props.disabled}\n aria-label={props.labels.removeValue(index)}\n onClick={() => {\n const items = props.operand.kind === 'list' ? [...props.operand.items] : [];\n props.onChange({\n kind: 'list',\n items: items.filter((_, position) => position !== index),\n });\n }}\n >\n ×\n </button>\n </div>\n ))}\n <button\n type=\"button\"\n className=\"axb-button\"\n disabled={props.disabled}\n onClick={() => {\n const items = props.operand.kind === 'list' ? [...props.operand.items] : [];\n props.onChange({ kind: 'list', items: [...items, ''] });\n }}\n >\n {props.labels.addValue}\n </button>\n {props.operand.items.length === 0 ? (\n <p className=\"axb-hint\">{props.labels.emptyList}</p>\n ) : null}\n </div>\n )\n ) : null}\n {props.operand.kind === 'field' ? (\n <ReferencePicker\n fields={fieldsForOperand(props.operator, props.field, props.context.fields)}\n tokenFields={props.context.fields}\n disabled={props.disabled}\n labels={{\n ...props.referencePickerLabels,\n label:\n props.explicitChooseListFieldLabel ??\n props.referencePickerLabels?.label ??\n props.labels.chooseListField,\n }}\n onPick={(reference) => props.onChange({ kind: 'field', fieldId: reference.fieldId })}\n />\n ) : null}\n {props.operand.kind === 'table' ? (\n <label className=\"axb-field\">\n <span className=\"axb-field__label\">{props.labels.chooseTable}</span>\n <select\n className=\"axb-select\"\n value={props.operand.tableId}\n disabled={props.disabled}\n onChange={(event) =>\n props.onChange({ kind: 'table', tableId: event.currentTarget.value })\n }\n >\n {setTables.map((table) => (\n <option key={table.tableId} value={table.tableId}>\n {table.label}\n </option>\n ))}\n </select>\n </label>\n ) : null}\n </div>\n );\n}\n\nfunction fieldsForOperand(\n operator: ValidationOperator,\n field: RuleField | undefined,\n fields: readonly RuleField[],\n): readonly RuleField[] {\n const primitive = field?.primitive;\n if (primitive === undefined) return [];\n return fields.filter((candidate) => operandFieldCompatible(operator, primitive, candidate));\n}\n\nfunction firstCompatibleField(\n operator: ValidationOperator,\n field: RuleField | undefined,\n fields: readonly RuleField[],\n): RuleField | undefined {\n return fieldsForOperand(operator, field, fields)[0];\n}\n\nfunction operandForMode(\n mode: 'value' | 'field',\n current: ValueOperand,\n operator: ValidationOperator,\n field: RuleField | undefined,\n fields: readonly RuleField[],\n): ValueOperand {\n if (mode === 'field') {\n return {\n kind: 'field',\n fieldId: firstCompatibleField(operator, field, fields)?.fieldId ?? '',\n };\n }\n return { kind: 'value', text: current.kind === 'value' ? current.text : '' };\n}\n\nfunction setOperand(draft: ValidationDraft, operand: ValueOperand): ValidationDraft {\n switch (draft.operator) {\n case 'equals':\n case 'not_equals':\n case 'greater_than':\n case 'less_than':\n case 'greater_or_equal':\n case 'less_or_equal':\n case 'contains':\n case 'starts_with':\n case 'ends_with':\n return { ...draft, operand };\n default:\n return draft;\n }\n}\n\nfunction setListOperand(draft: ValidationDraft, operand: ListOperand): ValidationDraft {\n if (draft.operator === 'one_of' || draft.operator === 'not_one_of') {\n return { ...draft, operand };\n }\n return draft;\n}\n\n/** A grouped field selector for the subject field, which needs no search at normal form sizes. */\nfunction GroupedFieldSelect(props: {\n readonly id: string;\n readonly fields: readonly RuleField[];\n readonly value: string;\n readonly disabled: boolean;\n readonly labels: ValidationEditorLabels;\n readonly onChange: (fieldId: string) => void;\n}): ReactElement {\n if (props.fields.length === 0) {\n return <span className=\"axb-hint\">{props.labels.noFields}</span>;\n }\n const groups = new Map<string, RuleField[]>();\n for (const field of props.fields) {\n const key = `${field.pageLabel ?? ''}\\u0000${field.sectionLabel ?? ''}`;\n const group = groups.get(key);\n if (group === undefined) groups.set(key, [field]);\n else group.push(field);\n }\n return (\n <select\n id={props.id}\n className=\"axb-select\"\n value={props.value}\n disabled={props.disabled}\n onChange={(event) => props.onChange(event.currentTarget.value)}\n >\n <option value=\"\">{props.labels.chooseValue}</option>\n {[...groups].map(([key, fields]) => {\n const [first] = fields;\n const page = first?.pageLabel;\n const section = first?.sectionLabel;\n const label = section ?? page ?? '';\n return (\n <optgroup key={key} label={label}>\n {fields.map((field) => (\n <option key={field.fieldId} value={field.fieldId}>\n {field.label}\n </option>\n ))}\n </optgroup>\n );\n })}\n </select>\n );\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ConditionDraft, ExpressionBuild, RuleContext } from './types.js';
|
|
2
|
+
/** A first predicate over the context's first field, so a new condition is never empty. */
|
|
3
|
+
export declare function defaultConditionDraft(context: RuleContext): ConditionDraft;
|
|
4
|
+
/**
|
|
5
|
+
* Builds the Expr v1 tree one condition means.
|
|
6
|
+
*
|
|
7
|
+
* `and` and `or` carry exactly the two operands the editor shows; `not` wraps one. The tree keeps
|
|
8
|
+
* the author's nesting — nothing is flattened and no `not` is pushed through a connective — so the
|
|
9
|
+
* source under the sentence is the expression that will be stored.
|
|
10
|
+
*/
|
|
11
|
+
export declare function conditionExpression(draft: ConditionDraft, context: RuleContext): ExpressionBuild;
|
|
12
|
+
//# sourceMappingURL=condition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.d.ts","sourceRoot":"","sources":["../../src/rules/condition.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG/E,2FAA2F;AAC3F,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAS1E;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,GAAG,eAAe,CAqBhG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { printNode } from './expression.js';
|
|
2
|
+
import { defaultOperatorFor } from './operators.js';
|
|
3
|
+
import { defaultValidationDraft, validationExpression } from './validation.js';
|
|
4
|
+
/** A first predicate over the context's first field, so a new condition is never empty. */
|
|
5
|
+
export function defaultConditionDraft(context) {
|
|
6
|
+
const field = context.fields[0];
|
|
7
|
+
if (field === undefined) {
|
|
8
|
+
return { kind: 'predicate', predicate: defaultValidationDraft('') };
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
kind: 'predicate',
|
|
12
|
+
predicate: defaultValidationDraft(field.fieldId, defaultOperatorFor(field)),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Builds the Expr v1 tree one condition means.
|
|
17
|
+
*
|
|
18
|
+
* `and` and `or` carry exactly the two operands the editor shows; `not` wraps one. The tree keeps
|
|
19
|
+
* the author's nesting — nothing is flattened and no `not` is pushed through a connective — so the
|
|
20
|
+
* source under the sentence is the expression that will be stored.
|
|
21
|
+
*/
|
|
22
|
+
export function conditionExpression(draft, context) {
|
|
23
|
+
switch (draft.kind) {
|
|
24
|
+
case 'predicate':
|
|
25
|
+
return validationExpression(draft.predicate, context);
|
|
26
|
+
case 'not': {
|
|
27
|
+
const operand = conditionExpression(draft.operand, context);
|
|
28
|
+
if (!operand.ok)
|
|
29
|
+
return operand;
|
|
30
|
+
const node = { kind: 'not', args: [operand.node] };
|
|
31
|
+
return printNode(node);
|
|
32
|
+
}
|
|
33
|
+
case 'and':
|
|
34
|
+
case 'or': {
|
|
35
|
+
const args = [];
|
|
36
|
+
for (const child of draft.operands) {
|
|
37
|
+
const built = conditionExpression(child, context);
|
|
38
|
+
if (!built.ok)
|
|
39
|
+
return built;
|
|
40
|
+
args.push(built.node);
|
|
41
|
+
}
|
|
42
|
+
return printNode({ kind: draft.kind, args });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=condition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../src/rules/condition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE/E,2FAA2F;AAC3F,MAAM,UAAU,qBAAqB,CAAC,OAAoB;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,sBAAsB,CAAC,EAAE,CAAC,EAAE,CAAC;IACtE,CAAC;IACD,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,sBAAsB,CAAC,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC;KAC5E,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAqB,EAAE,OAAoB;IAC7E,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,WAAW;YACd,OAAO,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,KAAK,KAAK,EAAE,CAAC;YACX,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC5D,IAAI,CAAC,OAAO,CAAC,EAAE;gBAAE,OAAO,OAAO,CAAC;YAChC,MAAM,IAAI,GAAY,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5D,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QACD,KAAK,KAAK,CAAC;QACX,KAAK,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,GAAe,EAAE,CAAC;YAC5B,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACnC,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;gBAClD,IAAI,CAAC,KAAK,CAAC,EAAE;oBAAE,OAAO,KAAK,CAAC;gBAC5B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;YACD,OAAO,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { ExprNode, NotNode } from '@azx-pbc/axiom-runtime';\nimport { printNode } from './expression.js';\nimport { defaultOperatorFor } from './operators.js';\nimport type { ConditionDraft, ExpressionBuild, RuleContext } from './types.js';\nimport { defaultValidationDraft, validationExpression } from './validation.js';\n\n/** A first predicate over the context's first field, so a new condition is never empty. */\nexport function defaultConditionDraft(context: RuleContext): ConditionDraft {\n const field = context.fields[0];\n if (field === undefined) {\n return { kind: 'predicate', predicate: defaultValidationDraft('') };\n }\n return {\n kind: 'predicate',\n predicate: defaultValidationDraft(field.fieldId, defaultOperatorFor(field)),\n };\n}\n\n/**\n * Builds the Expr v1 tree one condition means.\n *\n * `and` and `or` carry exactly the two operands the editor shows; `not` wraps one. The tree keeps\n * the author's nesting — nothing is flattened and no `not` is pushed through a connective — so the\n * source under the sentence is the expression that will be stored.\n */\nexport function conditionExpression(draft: ConditionDraft, context: RuleContext): ExpressionBuild {\n switch (draft.kind) {\n case 'predicate':\n return validationExpression(draft.predicate, context);\n case 'not': {\n const operand = conditionExpression(draft.operand, context);\n if (!operand.ok) return operand;\n const node: NotNode = { kind: 'not', args: [operand.node] };\n return printNode(node);\n }\n case 'and':\n case 'or': {\n const args: ExprNode[] = [];\n for (const child of draft.operands) {\n const built = conditionExpression(child, context);\n if (!built.ok) return built;\n args.push(built.node);\n }\n return printNode({ kind: draft.kind, args });\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ParseExprResult } from '@azx-pbc/axiom-compiler';
|
|
2
|
+
import type { ExprNode, LiteralNode } from '@azx-pbc/axiom-runtime';
|
|
3
|
+
import type { CompileCheck, ExpressionBuild, ExpressionProblem, RuleContext, RuleField, RuleTable, ValueOperand } from './types.js';
|
|
4
|
+
/** The field a draft names, or `undefined`. */
|
|
5
|
+
export declare function fieldById(fields: readonly RuleField[], fieldId: string): RuleField | undefined;
|
|
6
|
+
/** The table a draft names, or `undefined`. */
|
|
7
|
+
export declare function tableById(tables: readonly RuleTable[], tableId: string): RuleTable | undefined;
|
|
8
|
+
/** The path one field is read by, honouring a repeater's binder (`r.f_qty`). */
|
|
9
|
+
export declare function fieldPath(fieldId: string, context: RuleContext): ExprNode;
|
|
10
|
+
/** A bare table identifier: a dataset built-in's first operand, never a read. */
|
|
11
|
+
export declare function tablePath(tableId: string): ExprNode;
|
|
12
|
+
/** A literal node of the domain the field declares. */
|
|
13
|
+
export type LiteralBuild = {
|
|
14
|
+
readonly ok: true;
|
|
15
|
+
readonly node: LiteralNode;
|
|
16
|
+
} | {
|
|
17
|
+
readonly ok: false;
|
|
18
|
+
readonly problem: ExpressionProblem;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Parses one authored operand against the field it is compared with.
|
|
22
|
+
*
|
|
23
|
+
* The domain is the field's, not a guess from the text: `"1.5"` typed against a decimal field is
|
|
24
|
+
* the decimal 1.5, and the same text against a text field is the string. A value outside the
|
|
25
|
+
* domain is reported here rather than handed to the compiler, so the editor can point at the
|
|
26
|
+
* operand the author typed.
|
|
27
|
+
*/
|
|
28
|
+
export declare function literalFor(field: RuleField, text: string): LiteralBuild;
|
|
29
|
+
/** One operand's node: a typed literal or the declared path of another field. */
|
|
30
|
+
export declare function operandNode(operand: ValueOperand, field: RuleField, context: RuleContext): ExpressionBuild;
|
|
31
|
+
/** Prints one node through the compiler's printer, the only Expr v1 source authority. */
|
|
32
|
+
export declare function printNode(node: ExprNode): ExpressionBuild;
|
|
33
|
+
/** The literal `true`, the expression of a rule with no condition. */
|
|
34
|
+
export declare function literalTrue(): LiteralNode;
|
|
35
|
+
/** Parses one source into a node, or reports the parse diagnostic the author can fix. */
|
|
36
|
+
export declare function parseNode(source: string): {
|
|
37
|
+
readonly ok: true;
|
|
38
|
+
readonly node: ExprNode;
|
|
39
|
+
readonly source: string;
|
|
40
|
+
} | {
|
|
41
|
+
readonly ok: false;
|
|
42
|
+
readonly problem: ExpressionProblem;
|
|
43
|
+
};
|
|
44
|
+
/** Parses a rule's stored source, for a reader that displays rather than edits it. */
|
|
45
|
+
export declare function parseSource(source: string): ParseExprResult;
|
|
46
|
+
/** The canonical source of one node, or `undefined` when it has no source form. */
|
|
47
|
+
export declare function sourceOf(node: ExprNode): string | undefined;
|
|
48
|
+
/** Compiles one source against the context's declarations. */
|
|
49
|
+
export declare function compileSource(source: string, context: RuleContext): CompileCheck;
|
|
50
|
+
/**
|
|
51
|
+
* The context with a row binder, for a condition over a repeating table's rows.
|
|
52
|
+
*
|
|
53
|
+
* The fields become the table's columns and every path is prefixed with the binder, so the same
|
|
54
|
+
* validation editor that reads `f_qty` at record level reads `r.f_qty` inside a comprehension.
|
|
55
|
+
*/
|
|
56
|
+
export declare function rowContext(table: RuleField, tables: readonly RuleTable[] | undefined): RuleContext;
|
|
57
|
+
//# sourceMappingURL=expression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../src/rules/expression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqB,eAAe,EAAe,MAAM,yBAAyB,CAAC;AAQ/F,OAAO,KAAK,EAKV,QAAQ,EAER,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,SAAS,EACT,YAAY,EACb,MAAM,YAAY,CAAC;AAIpB,+CAA+C;AAC/C,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE9F;AAED,+CAA+C;AAC/C,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE9F;AAED,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,QAAQ,CAGzE;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAEnD;AAED,uDAAuD;AACvD,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IA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