@uipath/apollo-wind 2.93.0 → 2.94.0
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/forms/field-renderer.cjs +1 -1
- package/dist/components/forms/field-renderer.js +1 -1
- package/dist/components/forms/field-rules-strings.cjs +40 -0
- package/dist/components/forms/field-rules-strings.d.ts +17 -0
- package/dist/components/forms/field-rules-strings.js +6 -0
- package/dist/components/forms/field-rules.cjs +526 -0
- package/dist/components/forms/field-rules.d.ts +97 -0
- package/dist/components/forms/field-rules.js +468 -0
- package/dist/components/forms/form-designer.cjs +208 -592
- package/dist/components/forms/form-designer.js +210 -594
- package/dist/components/forms/form-schema.d.ts +5 -0
- package/dist/components/forms/index.cjs +43 -3
- package/dist/components/forms/index.d.ts +4 -0
- package/dist/components/forms/index.js +5 -1
- package/dist/components/forms/metadata-form.cjs +1 -1
- package/dist/components/forms/metadata-form.js +1 -1
- package/dist/components/forms/rules-engine-dialect.cjs +644 -0
- package/dist/components/forms/rules-engine-dialect.d.ts +90 -0
- package/dist/components/forms/rules-engine-dialect.js +537 -0
- package/dist/components/forms/rules-engine.cjs +99 -10
- package/dist/components/forms/rules-engine.d.ts +5 -0
- package/dist/components/forms/rules-engine.js +99 -10
- package/dist/components/forms/use-field-rules.cjs +122 -0
- package/dist/components/forms/use-field-rules.d.ts +31 -0
- package/dist/components/forms/use-field-rules.js +88 -0
- package/dist/components/ui/conditions-editor/condition-row.cjs +458 -0
- package/dist/components/ui/conditions-editor/condition-row.d.ts +23 -0
- package/dist/components/ui/conditions-editor/condition-row.js +421 -0
- package/dist/components/ui/conditions-editor/conditions-editor.cjs +363 -0
- package/dist/components/ui/conditions-editor/conditions-editor.d.ts +67 -0
- package/dist/components/ui/conditions-editor/conditions-editor.js +329 -0
- package/dist/components/ui/conditions-editor/context.cjs +45 -0
- package/dist/components/ui/conditions-editor/context.d.ts +54 -0
- package/dist/components/ui/conditions-editor/context.js +8 -0
- package/dist/components/ui/conditions-editor/index.cjs +55 -0
- package/dist/components/ui/conditions-editor/index.d.ts +6 -0
- package/dist/components/ui/conditions-editor/index.js +6 -0
- package/dist/components/ui/conditions-editor/model.cjs +126 -0
- package/dist/components/ui/conditions-editor/model.d.ts +39 -0
- package/dist/components/ui/conditions-editor/model.js +71 -0
- package/dist/components/ui/conditions-editor/status.cjs +198 -0
- package/dist/components/ui/conditions-editor/status.d.ts +44 -0
- package/dist/components/ui/conditions-editor/status.js +131 -0
- package/dist/components/ui/conditions-editor/strings.cjs +86 -0
- package/dist/components/ui/conditions-editor/strings.d.ts +62 -0
- package/dist/components/ui/conditions-editor/strings.js +52 -0
- package/dist/components/ui/conditions-editor/vocabulary.cjs +163 -0
- package/dist/components/ui/conditions-editor/vocabulary.d.ts +51 -0
- package/dist/components/ui/conditions-editor/vocabulary.js +129 -0
- package/dist/components/ui/field-actions/index.cjs +9 -2
- package/dist/components/ui/field-actions/index.d.ts +1 -0
- package/dist/components/ui/field-actions/index.js +2 -1
- package/dist/components/ui/field-actions/insert-variable-action.cjs +3 -1
- package/dist/components/ui/field-actions/insert-variable-action.d.ts +4 -1
- package/dist/components/ui/field-actions/insert-variable-action.js +3 -1
- package/dist/components/ui/field-actions/rules-action.cjs +244 -0
- package/dist/components/ui/field-actions/rules-action.d.ts +42 -0
- package/dist/components/ui/field-actions/rules-action.js +207 -0
- package/dist/components/ui/index.cjs +273 -234
- package/dist/components/ui/index.d.ts +3 -0
- package/dist/components/ui/index.js +3 -0
- package/dist/components/ui/quick-form-field/components/field-header.cjs +137 -167
- package/dist/components/ui/quick-form-field/components/field-header.d.ts +1 -1
- package/dist/components/ui/quick-form-field/components/field-header.js +138 -168
- package/dist/components/ui/quick-form-field/components/header-actions.cjs +187 -0
- package/dist/components/ui/quick-form-field/components/header-actions.d.ts +59 -0
- package/dist/components/ui/quick-form-field/components/header-actions.js +138 -0
- package/dist/components/ui/quick-form-field/components/header-context.cjs +59 -0
- package/dist/components/ui/quick-form-field/components/header-context.d.ts +33 -0
- package/dist/components/ui/quick-form-field/components/header-context.js +16 -0
- package/dist/components/ui/quick-form-field/index.cjs +18 -4
- package/dist/components/ui/quick-form-field/index.d.ts +2 -0
- package/dist/components/ui/quick-form-field/index.js +3 -1
- package/dist/components/ui/quick-form-field/quick-form-field.cjs +1 -1
- package/dist/components/ui/quick-form-field/quick-form-field.d.ts +6 -6
- package/dist/components/ui/quick-form-field/quick-form-field.js +1 -1
- package/dist/components/ui/quick-form-field/types.d.ts +42 -11
- package/dist/components/ui/row-groups/add-row-button.cjs +54 -0
- package/dist/components/ui/row-groups/add-row-button.d.ts +10 -0
- package/dist/components/ui/row-groups/add-row-button.js +20 -0
- package/dist/components/ui/row-groups/after-press.cjs +73 -0
- package/dist/components/ui/row-groups/after-press.d.ts +7 -0
- package/dist/components/ui/row-groups/after-press.js +36 -0
- package/dist/components/ui/row-groups/collapsible-row-group.cjs +83 -0
- package/dist/components/ui/row-groups/collapsible-row-group.d.ts +13 -0
- package/dist/components/ui/row-groups/collapsible-row-group.js +49 -0
- package/dist/components/ui/row-groups/empty-rows.cjs +42 -0
- package/dist/components/ui/row-groups/empty-rows.d.ts +7 -0
- package/dist/components/ui/row-groups/empty-rows.js +8 -0
- package/dist/components/ui/row-groups/group-mode-toggle.cjs +80 -0
- package/dist/components/ui/row-groups/group-mode-toggle.d.ts +26 -0
- package/dist/components/ui/row-groups/group-mode-toggle.js +40 -0
- package/dist/components/ui/row-groups/index.cjs +62 -0
- package/dist/components/ui/row-groups/index.d.ts +6 -0
- package/dist/components/ui/row-groups/index.js +7 -0
- package/dist/components/ui/row-groups/row-delete-button.cjs +54 -0
- package/dist/components/ui/row-groups/row-delete-button.d.ts +18 -0
- package/dist/components/ui/row-groups/row-delete-button.js +20 -0
- package/dist/components/ui/row-groups/use-row-focus.cjs +82 -0
- package/dist/components/ui/row-groups/use-row-focus.d.ts +17 -0
- package/dist/components/ui/row-groups/use-row-focus.js +48 -0
- package/dist/components/ui/rules-editor/context.cjs +45 -0
- package/dist/components/ui/rules-editor/context.d.ts +52 -0
- package/dist/components/ui/rules-editor/context.js +8 -0
- package/dist/components/ui/rules-editor/index.cjs +56 -0
- package/dist/components/ui/rules-editor/index.d.ts +4 -0
- package/dist/components/ui/rules-editor/index.js +4 -0
- package/dist/components/ui/rules-editor/model.cjs +205 -0
- package/dist/components/ui/rules-editor/model.d.ts +128 -0
- package/dist/components/ui/rules-editor/model.js +144 -0
- package/dist/components/ui/rules-editor/rule-card.cjs +470 -0
- package/dist/components/ui/rules-editor/rule-card.d.ts +14 -0
- package/dist/components/ui/rules-editor/rule-card.js +436 -0
- package/dist/components/ui/rules-editor/rules-editor.cjs +160 -0
- package/dist/components/ui/rules-editor/rules-editor.d.ts +66 -0
- package/dist/components/ui/rules-editor/rules-editor.js +126 -0
- package/dist/components/ui/rules-editor/strings.cjs +68 -0
- package/dist/components/ui/rules-editor/strings.d.ts +56 -0
- package/dist/components/ui/rules-editor/strings.js +34 -0
- package/dist/index.cjs +129 -8
- package/dist/index.d.ts +17 -4
- package/dist/index.js +10 -3
- package/dist/styles.css +97 -24
- package/package.json +2 -2
|
@@ -33,17 +33,22 @@ const accordion_cjs_namespaceObject = require("../ui/accordion.cjs");
|
|
|
33
33
|
const button_cjs_namespaceObject = require("../ui/button.cjs");
|
|
34
34
|
const card_cjs_namespaceObject = require("../ui/card.cjs");
|
|
35
35
|
const checkbox_cjs_namespaceObject = require("../ui/checkbox.cjs");
|
|
36
|
+
const index_cjs_namespaceObject = require("../ui/conditions-editor/index.cjs");
|
|
36
37
|
const input_cjs_namespaceObject = require("../ui/input.cjs");
|
|
37
38
|
const label_cjs_namespaceObject = require("../ui/label.cjs");
|
|
38
39
|
const grid_cjs_namespaceObject = require("../ui/layout/grid.cjs");
|
|
40
|
+
const rules_editor_index_cjs_namespaceObject = require("../ui/rules-editor/index.cjs");
|
|
39
41
|
const select_cjs_namespaceObject = require("../ui/select.cjs");
|
|
40
42
|
const separator_cjs_namespaceObject = require("../ui/separator.cjs");
|
|
41
43
|
const switch_cjs_namespaceObject = require("../ui/switch.cjs");
|
|
42
44
|
const tabs_cjs_namespaceObject = require("../ui/tabs.cjs");
|
|
43
45
|
const textarea_cjs_namespaceObject = require("../ui/textarea.cjs");
|
|
44
46
|
const external_field_actions_cjs_namespaceObject = require("./field-actions.cjs");
|
|
47
|
+
const external_field_rules_cjs_namespaceObject = require("./field-rules.cjs");
|
|
45
48
|
const external_metadata_form_cjs_namespaceObject = require("./metadata-form.cjs");
|
|
49
|
+
const external_rules_engine_dialect_cjs_namespaceObject = require("./rules-engine-dialect.cjs");
|
|
46
50
|
const external_schema_serializer_cjs_namespaceObject = require("./schema-serializer.cjs");
|
|
51
|
+
const external_use_field_rules_cjs_namespaceObject = require("./use-field-rules.cjs");
|
|
47
52
|
const FIELD_TYPE_METADATA = [
|
|
48
53
|
{
|
|
49
54
|
value: 'text',
|
|
@@ -999,20 +1004,11 @@ function FieldConfigForm({ field, onUpdate, allFields, existingFieldNames }) {
|
|
|
999
1004
|
}),
|
|
1000
1005
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.AccordionContent, {
|
|
1001
1006
|
className: "pt-2",
|
|
1002
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
1003
|
-
|
|
1004
|
-
onChange: (rules)=>onUpdate({
|
|
1005
|
-
rules
|
|
1006
|
-
}),
|
|
1007
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FieldRulesEditor, {
|
|
1008
|
+
field: field,
|
|
1007
1009
|
allFields: allFields,
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
validation: {
|
|
1011
|
-
...field.validation,
|
|
1012
|
-
requiredMessage: message
|
|
1013
|
-
}
|
|
1014
|
-
})
|
|
1015
|
-
})
|
|
1010
|
+
onUpdate: onUpdate
|
|
1011
|
+
}, field.id)
|
|
1016
1012
|
})
|
|
1017
1013
|
]
|
|
1018
1014
|
})
|
|
@@ -1047,6 +1043,11 @@ function FormDesigner() {
|
|
|
1047
1043
|
]);
|
|
1048
1044
|
const [previewDisabled, setPreviewDisabled] = (0, external_react_namespaceObject.useState)(false);
|
|
1049
1045
|
const allFields = sections.flatMap((s)=>s.fields);
|
|
1046
|
+
const ruleOptions = useRuleOptions(allFields);
|
|
1047
|
+
const lastNames = (0, external_react_namespaceObject.useRef)(new Map());
|
|
1048
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
1049
|
+
for (const field of allFields)if (field.name) lastNames.current.set(field.id, field.name);
|
|
1050
|
+
});
|
|
1050
1051
|
const selectedSection = sections.find((s)=>s.id === selectedSectionId);
|
|
1051
1052
|
const selectedField = allFields.find((f)=>f.id === selectedFieldId);
|
|
1052
1053
|
const generatedSchema = {
|
|
@@ -1176,12 +1177,21 @@ function FormDesigner() {
|
|
|
1176
1177
|
}
|
|
1177
1178
|
}
|
|
1178
1179
|
}
|
|
1180
|
+
const previousName = prevAllFields.find((f)=>f.id === fieldId)?.name || lastNames.current.get(fieldId);
|
|
1181
|
+
const renamed = finalUpdates.name && previousName && finalUpdates.name !== previousName ? {
|
|
1182
|
+
from: previousName,
|
|
1183
|
+
to: finalUpdates.name
|
|
1184
|
+
} : void 0;
|
|
1185
|
+
const follow = (f)=>renamed && f.rules ? {
|
|
1186
|
+
...f,
|
|
1187
|
+
rules: (0, external_field_rules_cjs_namespaceObject.renameFieldInRules)(f.rules, renamed.from, renamed.to)
|
|
1188
|
+
} : f;
|
|
1179
1189
|
return prevSections.map((s)=>({
|
|
1180
1190
|
...s,
|
|
1181
|
-
fields: s.fields.map((f)=>f.id === fieldId ? {
|
|
1191
|
+
fields: s.fields.map((f)=>follow(f.id === fieldId ? {
|
|
1182
1192
|
...f,
|
|
1183
1193
|
...finalUpdates
|
|
1184
|
-
} : f)
|
|
1194
|
+
} : f))
|
|
1185
1195
|
}));
|
|
1186
1196
|
});
|
|
1187
1197
|
};
|
|
@@ -1377,6 +1387,11 @@ function FormDesigner() {
|
|
|
1377
1387
|
}),
|
|
1378
1388
|
field.rules?.some((r)=>r.effects.required) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.RequiredIndicator, {
|
|
1379
1389
|
className: "ml-0 text-[10px]"
|
|
1390
|
+
}),
|
|
1391
|
+
rulesNeedAttention(field.rules, ruleOptions) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.AlertTriangle, {
|
|
1392
|
+
role: "img",
|
|
1393
|
+
"aria-label": "Rules need attention",
|
|
1394
|
+
className: "h-3 w-3 shrink-0 text-destructive"
|
|
1380
1395
|
})
|
|
1381
1396
|
]
|
|
1382
1397
|
}),
|
|
@@ -1889,286 +1904,188 @@ function DataSourceEditor({ dataSource, onChange }) {
|
|
|
1889
1904
|
]
|
|
1890
1905
|
});
|
|
1891
1906
|
}
|
|
1892
|
-
const
|
|
1893
|
-
{
|
|
1894
|
-
value: 'is',
|
|
1895
|
-
label: 'equals',
|
|
1896
|
-
description: 'Field value equals'
|
|
1897
|
-
},
|
|
1907
|
+
const DESIGNER_OUTCOMES = [
|
|
1898
1908
|
{
|
|
1899
|
-
value: '
|
|
1900
|
-
label: '
|
|
1901
|
-
|
|
1909
|
+
value: 'show',
|
|
1910
|
+
label: 'Show',
|
|
1911
|
+
effects: {
|
|
1912
|
+
visible: true
|
|
1913
|
+
}
|
|
1902
1914
|
},
|
|
1903
1915
|
{
|
|
1904
|
-
value: '
|
|
1905
|
-
label: '
|
|
1906
|
-
|
|
1916
|
+
value: 'hide',
|
|
1917
|
+
label: 'Hide',
|
|
1918
|
+
effects: {
|
|
1919
|
+
visible: false
|
|
1920
|
+
}
|
|
1907
1921
|
},
|
|
1908
1922
|
{
|
|
1909
|
-
value: '
|
|
1910
|
-
label: '
|
|
1911
|
-
|
|
1923
|
+
value: 'require',
|
|
1924
|
+
label: 'Require',
|
|
1925
|
+
effects: {
|
|
1926
|
+
required: true
|
|
1927
|
+
}
|
|
1912
1928
|
},
|
|
1913
1929
|
{
|
|
1914
|
-
value: '
|
|
1915
|
-
label: '
|
|
1916
|
-
|
|
1930
|
+
value: 'disable',
|
|
1931
|
+
label: 'Disable',
|
|
1932
|
+
effects: {
|
|
1933
|
+
disabled: true
|
|
1934
|
+
}
|
|
1917
1935
|
}
|
|
1918
1936
|
];
|
|
1919
|
-
const
|
|
1937
|
+
const ALWAYS_REQUIRED_ID = 'always-required';
|
|
1938
|
+
const BOOLEAN_OPTIONS = [
|
|
1920
1939
|
{
|
|
1921
|
-
value: '
|
|
1922
|
-
label: '
|
|
1923
|
-
description: 'Show this field when conditions are met',
|
|
1924
|
-
Icon: external_lucide_react_namespaceObject.Eye,
|
|
1925
|
-
color: 'text-success bg-success-background border-success/30'
|
|
1940
|
+
value: 'true',
|
|
1941
|
+
label: 'Yes'
|
|
1926
1942
|
},
|
|
1927
1943
|
{
|
|
1928
|
-
value: '
|
|
1929
|
-
label: '
|
|
1930
|
-
description: 'Hide this field when conditions are met',
|
|
1931
|
-
Icon: external_lucide_react_namespaceObject.EyeOff,
|
|
1932
|
-
color: 'text-warning bg-warning-background border-warning/30'
|
|
1933
|
-
},
|
|
1934
|
-
{
|
|
1935
|
-
value: 'require',
|
|
1936
|
-
label: 'Make required',
|
|
1937
|
-
description: 'Require this field when conditions are met',
|
|
1938
|
-
Icon: external_lucide_react_namespaceObject.Asterisk,
|
|
1939
|
-
color: 'text-error bg-error-background border-error/30'
|
|
1940
|
-
},
|
|
1941
|
-
{
|
|
1942
|
-
value: 'disable',
|
|
1943
|
-
label: 'Disable field',
|
|
1944
|
-
description: 'Disable this field when conditions are met',
|
|
1945
|
-
Icon: external_lucide_react_namespaceObject.Ban,
|
|
1946
|
-
color: 'text-muted-foreground bg-muted border-border'
|
|
1944
|
+
value: 'false',
|
|
1945
|
+
label: 'No'
|
|
1947
1946
|
}
|
|
1948
1947
|
];
|
|
1949
|
-
function
|
|
1950
|
-
const
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
const [conditions, setConditions] = (0, external_react_namespaceObject.useState)([
|
|
1954
|
-
{
|
|
1955
|
-
field: '',
|
|
1956
|
-
operator: 'is',
|
|
1957
|
-
value: ''
|
|
1958
|
-
}
|
|
1959
|
-
]);
|
|
1960
|
-
const [conditionOperator, setConditionOperator] = (0, external_react_namespaceObject.useState)('AND');
|
|
1961
|
-
const isAlwaysRequired = rules.some((r)=>true === r.effects.required && 0 === r.conditions.length);
|
|
1962
|
-
const resetBuilder = ()=>{
|
|
1963
|
-
setSelectedEffect('show');
|
|
1964
|
-
setConditions([
|
|
1965
|
-
{
|
|
1966
|
-
field: '',
|
|
1967
|
-
operator: 'is',
|
|
1968
|
-
value: ''
|
|
1969
|
-
}
|
|
1970
|
-
]);
|
|
1971
|
-
setConditionOperator('AND');
|
|
1972
|
-
setIsAddingRule(false);
|
|
1973
|
-
setEditingRuleIndex(null);
|
|
1974
|
-
};
|
|
1975
|
-
const addCondition = ()=>{
|
|
1976
|
-
setConditions([
|
|
1977
|
-
...conditions,
|
|
1978
|
-
{
|
|
1979
|
-
field: '',
|
|
1980
|
-
operator: 'is',
|
|
1981
|
-
value: ''
|
|
1982
|
-
}
|
|
1983
|
-
]);
|
|
1984
|
-
};
|
|
1985
|
-
const updateCondition = (index, updates)=>{
|
|
1986
|
-
const newConditions = [
|
|
1987
|
-
...conditions
|
|
1988
|
-
];
|
|
1989
|
-
newConditions[index] = {
|
|
1990
|
-
...newConditions[index],
|
|
1991
|
-
...updates
|
|
1992
|
-
};
|
|
1993
|
-
setConditions(newConditions);
|
|
1994
|
-
};
|
|
1995
|
-
const removeCondition = (index)=>{
|
|
1996
|
-
if (conditions.length > 1) setConditions(conditions.filter((_, i)=>i !== index));
|
|
1948
|
+
function ruleFieldFor(field) {
|
|
1949
|
+
const base = {
|
|
1950
|
+
value: field.name,
|
|
1951
|
+
label: field.label || field.name
|
|
1997
1952
|
};
|
|
1998
|
-
const
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
if ('true' === val.toLowerCase()) return true;
|
|
2008
|
-
if ('false' === val.toLowerCase()) return false;
|
|
2009
|
-
}
|
|
2010
|
-
if (isNumericField) {
|
|
2011
|
-
const num = Number(val);
|
|
2012
|
-
if (!isNaN(num)) return num;
|
|
2013
|
-
}
|
|
2014
|
-
if ('true' === val.toLowerCase()) return true;
|
|
2015
|
-
if ('false' === val.toLowerCase()) return false;
|
|
2016
|
-
return val;
|
|
2017
|
-
};
|
|
2018
|
-
switch(cond.operator){
|
|
2019
|
-
case 'is':
|
|
2020
|
-
condition.is = parseValue(cond.value);
|
|
2021
|
-
break;
|
|
2022
|
-
case 'isNot':
|
|
2023
|
-
condition.isNot = parseValue(cond.value);
|
|
2024
|
-
break;
|
|
2025
|
-
case 'in':
|
|
2026
|
-
condition.in = cond.value.split(',').map((v)=>parseValue(v.trim()));
|
|
2027
|
-
break;
|
|
2028
|
-
case 'notIn':
|
|
2029
|
-
condition.notIn = cond.value.split(',').map((v)=>parseValue(v.trim()));
|
|
2030
|
-
break;
|
|
2031
|
-
case 'matches':
|
|
2032
|
-
condition.matches = cond.value;
|
|
2033
|
-
break;
|
|
2034
|
-
}
|
|
2035
|
-
return condition;
|
|
1953
|
+
const enumOf = (options)=>options.map((option)=>({
|
|
1954
|
+
value: String(option.value),
|
|
1955
|
+
label: option.label
|
|
1956
|
+
}));
|
|
1957
|
+
const boolean = {
|
|
1958
|
+
...base,
|
|
1959
|
+
type: 'enum',
|
|
1960
|
+
valueType: 'boolean',
|
|
1961
|
+
options: BOOLEAN_OPTIONS
|
|
2036
1962
|
};
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
id: `rule-${Date.now()}`,
|
|
2042
|
-
conditions: validConditions.map(buildCondition),
|
|
2043
|
-
operator: conditionOperator,
|
|
2044
|
-
effects: {}
|
|
2045
|
-
};
|
|
2046
|
-
switch(selectedEffect){
|
|
2047
|
-
case 'show':
|
|
2048
|
-
newRule.effects.visible = true;
|
|
2049
|
-
break;
|
|
2050
|
-
case 'hide':
|
|
2051
|
-
newRule.effects.visible = false;
|
|
2052
|
-
break;
|
|
2053
|
-
case 'require':
|
|
2054
|
-
newRule.effects.required = true;
|
|
2055
|
-
break;
|
|
2056
|
-
case 'disable':
|
|
2057
|
-
newRule.effects.disabled = true;
|
|
2058
|
-
break;
|
|
2059
|
-
}
|
|
2060
|
-
if (null !== editingRuleIndex) {
|
|
2061
|
-
const newRules = [
|
|
2062
|
-
...rules
|
|
2063
|
-
];
|
|
2064
|
-
newRules[editingRuleIndex] = newRule;
|
|
2065
|
-
onChange(newRules);
|
|
2066
|
-
} else onChange([
|
|
2067
|
-
...rules,
|
|
2068
|
-
newRule
|
|
2069
|
-
]);
|
|
2070
|
-
resetBuilder();
|
|
2071
|
-
};
|
|
2072
|
-
const editRule = (index)=>{
|
|
2073
|
-
const rule = rules[index];
|
|
2074
|
-
if (!rule) return;
|
|
2075
|
-
let effect = 'show';
|
|
2076
|
-
if (true === rule.effects.visible) effect = 'show';
|
|
2077
|
-
else if (false === rule.effects.visible) effect = 'hide';
|
|
2078
|
-
else if (true === rule.effects.required) effect = 'require';
|
|
2079
|
-
else if (true === rule.effects.disabled) effect = 'disable';
|
|
2080
|
-
setSelectedEffect(effect);
|
|
2081
|
-
setConditionOperator(rule.operator || 'AND');
|
|
2082
|
-
const editableConditions = rule.conditions.map((cond)=>{
|
|
2083
|
-
let operator = 'is';
|
|
2084
|
-
let value = '';
|
|
2085
|
-
if (void 0 !== cond.is) {
|
|
2086
|
-
operator = 'is';
|
|
2087
|
-
value = String(cond.is);
|
|
2088
|
-
} else if (void 0 !== cond.isNot) {
|
|
2089
|
-
operator = 'isNot';
|
|
2090
|
-
value = String(cond.isNot);
|
|
2091
|
-
} else if (void 0 !== cond.in) {
|
|
2092
|
-
operator = 'in';
|
|
2093
|
-
value = cond.in.map(String).join(', ');
|
|
2094
|
-
} else if (void 0 !== cond.notIn) {
|
|
2095
|
-
operator = 'notIn';
|
|
2096
|
-
value = cond.notIn.map(String).join(', ');
|
|
2097
|
-
} else if (void 0 !== cond.matches) {
|
|
2098
|
-
operator = 'matches';
|
|
2099
|
-
value = cond.matches;
|
|
2100
|
-
}
|
|
1963
|
+
switch(field.type){
|
|
1964
|
+
case 'text':
|
|
1965
|
+
case 'email':
|
|
1966
|
+
case 'textarea':
|
|
2101
1967
|
return {
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
value
|
|
1968
|
+
...base,
|
|
1969
|
+
type: 'string'
|
|
2105
1970
|
};
|
|
2106
|
-
|
|
2107
|
-
|
|
1971
|
+
case 'number':
|
|
1972
|
+
case 'slider':
|
|
1973
|
+
return {
|
|
1974
|
+
...base,
|
|
1975
|
+
type: 'number'
|
|
1976
|
+
};
|
|
1977
|
+
case 'date':
|
|
1978
|
+
case 'datetime':
|
|
1979
|
+
return {
|
|
1980
|
+
...base,
|
|
1981
|
+
type: 'date'
|
|
1982
|
+
};
|
|
1983
|
+
case 'select':
|
|
1984
|
+
case 'radio':
|
|
1985
|
+
return {
|
|
1986
|
+
...base,
|
|
1987
|
+
type: 'enum',
|
|
1988
|
+
options: enumOf(field.options ?? [])
|
|
1989
|
+
};
|
|
1990
|
+
case 'checkbox':
|
|
1991
|
+
case 'switch':
|
|
1992
|
+
case 'boolean':
|
|
1993
|
+
return boolean;
|
|
1994
|
+
case 'custom':
|
|
2108
1995
|
{
|
|
2109
|
-
field
|
|
2110
|
-
|
|
2111
|
-
|
|
1996
|
+
const { valueType } = field;
|
|
1997
|
+
if ('string' === valueType) return {
|
|
1998
|
+
...base,
|
|
1999
|
+
type: 'string'
|
|
2000
|
+
};
|
|
2001
|
+
if ('number' === valueType) return {
|
|
2002
|
+
...base,
|
|
2003
|
+
type: 'number'
|
|
2004
|
+
};
|
|
2005
|
+
if ('boolean' === valueType) return boolean;
|
|
2006
|
+
return {
|
|
2007
|
+
...base,
|
|
2008
|
+
type: 'other'
|
|
2009
|
+
};
|
|
2112
2010
|
}
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2011
|
+
default:
|
|
2012
|
+
return {
|
|
2013
|
+
...base,
|
|
2014
|
+
type: 'other'
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
function useRuleOptions(allFields) {
|
|
2019
|
+
const fields = allFields.flatMap((field)=>field.name ? ruleFieldFor(field) : []);
|
|
2020
|
+
const key = JSON.stringify(fields);
|
|
2021
|
+
return (0, external_react_namespaceObject.useMemo)(()=>({
|
|
2022
|
+
outcomes: DESIGNER_OUTCOMES,
|
|
2023
|
+
fields
|
|
2024
|
+
}), [
|
|
2025
|
+
key
|
|
2026
|
+
]);
|
|
2027
|
+
}
|
|
2028
|
+
const attention = new WeakMap();
|
|
2029
|
+
function rulesNeedAttention(rules, options) {
|
|
2030
|
+
if (!rules?.length) return false;
|
|
2031
|
+
let byRules = attention.get(options);
|
|
2032
|
+
if (!byRules) {
|
|
2033
|
+
byRules = new WeakMap();
|
|
2034
|
+
attention.set(options, byRules);
|
|
2035
|
+
}
|
|
2036
|
+
const known = byRules.get(rules);
|
|
2037
|
+
if (void 0 !== known) return known;
|
|
2038
|
+
const vocabulary = {
|
|
2039
|
+
...options,
|
|
2040
|
+
...external_rules_engine_dialect_cjs_namespaceObject.rulesEngineVocabulary
|
|
2123
2041
|
};
|
|
2124
|
-
const
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2042
|
+
const flagged = (0, rules_editor_index_cjs_namespaceObject.findRuleIssues)((0, external_field_rules_cjs_namespaceObject.fromFieldRules)(rules, options), vocabulary, external_rules_engine_dialect_cjs_namespaceObject.rulesEngineDialect).length > 0;
|
|
2043
|
+
byRules.set(rules, flagged);
|
|
2044
|
+
return flagged;
|
|
2045
|
+
}
|
|
2046
|
+
const form_designer_isAlwaysRequired = (rule)=>'require' === rule.outcome && (0, rules_editor_index_cjs_namespaceObject.isUnconditionalRule)(rule);
|
|
2047
|
+
function FieldRulesEditor({ field, allFields, onUpdate }) {
|
|
2048
|
+
const options = useRuleOptions(allFields);
|
|
2049
|
+
const requiredMessage = field.validation?.requiredMessage;
|
|
2050
|
+
const editor = (0, external_use_field_rules_cjs_namespaceObject.useFieldRules)({
|
|
2051
|
+
rules: field.rules
|
|
2052
|
+
}, ({ rules })=>{
|
|
2053
|
+
const stillRequired = rules.some((rule)=>true === rule.effects.required && 0 === rule.conditions.length);
|
|
2054
|
+
onUpdate({
|
|
2055
|
+
rules,
|
|
2056
|
+
...stillRequired || !requiredMessage ? {} : {
|
|
2057
|
+
validation: {
|
|
2058
|
+
...field.validation,
|
|
2059
|
+
requiredMessage: void 0
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2137
2062
|
});
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
const
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
label: 'Unknown',
|
|
2160
|
-
color: 'text-muted-foreground bg-muted'
|
|
2161
|
-
};
|
|
2162
|
-
};
|
|
2163
|
-
const getFieldOptions = (fieldName)=>{
|
|
2164
|
-
const field = allFields.find((f)=>f.name === fieldName);
|
|
2165
|
-
return field?.options || [];
|
|
2166
|
-
};
|
|
2063
|
+
}, options);
|
|
2064
|
+
const alwaysRequired = editor.value.find(form_designer_isAlwaysRequired);
|
|
2065
|
+
const rules = alwaysRequired ? editor.value.filter((rule)=>rule !== alwaysRequired) : editor.value;
|
|
2066
|
+
const changeRules = (next)=>editor.onChange(alwaysRequired ? [
|
|
2067
|
+
...next,
|
|
2068
|
+
alwaysRequired
|
|
2069
|
+
] : next);
|
|
2070
|
+
const setAlwaysRequired = (on)=>editor.onChange(on ? [
|
|
2071
|
+
...editor.value,
|
|
2072
|
+
(0, rules_editor_index_cjs_namespaceObject.createRule)({
|
|
2073
|
+
id: ALWAYS_REQUIRED_ID,
|
|
2074
|
+
outcome: 'require',
|
|
2075
|
+
conditions: (0, index_cjs_namespaceObject.createConditionGroup)()
|
|
2076
|
+
})
|
|
2077
|
+
] : [
|
|
2078
|
+
...rules
|
|
2079
|
+
]);
|
|
2080
|
+
const editorKey = options.fields.map((option)=>option.value).join('\n');
|
|
2081
|
+
const touched = (0, external_react_namespaceObject.useMemo)(()=>(0, rules_editor_index_cjs_namespaceObject.issueIds)(editor.issues), [
|
|
2082
|
+
editorKey
|
|
2083
|
+
]);
|
|
2167
2084
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2168
2085
|
className: "space-y-4",
|
|
2169
2086
|
children: [
|
|
2170
2087
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2171
|
-
className: "space-y-3
|
|
2088
|
+
className: "space-y-3 rounded-lg border bg-muted/30 p-3",
|
|
2172
2089
|
children: [
|
|
2173
2090
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2174
2091
|
className: "flex items-center justify-between",
|
|
@@ -2182,6 +2099,7 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
|
|
|
2182
2099
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2183
2100
|
children: [
|
|
2184
2101
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
|
|
2102
|
+
htmlFor: `always-required-${field.id}`,
|
|
2185
2103
|
className: "cursor-pointer font-medium",
|
|
2186
2104
|
children: "Always required"
|
|
2187
2105
|
}),
|
|
@@ -2194,31 +2112,13 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
|
|
|
2194
2112
|
]
|
|
2195
2113
|
}),
|
|
2196
2114
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(checkbox_cjs_namespaceObject.Checkbox, {
|
|
2197
|
-
|
|
2198
|
-
checked:
|
|
2199
|
-
onCheckedChange: (checked)=>
|
|
2200
|
-
if (checked) {
|
|
2201
|
-
const requiredRule = {
|
|
2202
|
-
id: 'always-required',
|
|
2203
|
-
conditions: [],
|
|
2204
|
-
operator: 'AND',
|
|
2205
|
-
effects: {
|
|
2206
|
-
required: true
|
|
2207
|
-
}
|
|
2208
|
-
};
|
|
2209
|
-
onChange([
|
|
2210
|
-
...rules.filter((r)=>!(r.effects.required && 0 === r.conditions.length)),
|
|
2211
|
-
requiredRule
|
|
2212
|
-
]);
|
|
2213
|
-
} else {
|
|
2214
|
-
onChange(rules.filter((r)=>!(r.effects.required && 0 === r.conditions.length)));
|
|
2215
|
-
onRequiredMessageChange(void 0);
|
|
2216
|
-
}
|
|
2217
|
-
}
|
|
2115
|
+
id: `always-required-${field.id}`,
|
|
2116
|
+
checked: !!alwaysRequired,
|
|
2117
|
+
onCheckedChange: (checked)=>setAlwaysRequired(true === checked)
|
|
2218
2118
|
})
|
|
2219
2119
|
]
|
|
2220
2120
|
}),
|
|
2221
|
-
|
|
2121
|
+
alwaysRequired && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2222
2122
|
className: "space-y-1.5 pl-8",
|
|
2223
2123
|
children: [
|
|
2224
2124
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
|
|
@@ -2230,313 +2130,29 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
|
|
|
2230
2130
|
id: "required-message",
|
|
2231
2131
|
placeholder: "This field is required",
|
|
2232
2132
|
value: requiredMessage || '',
|
|
2233
|
-
onChange: (e)=>
|
|
2133
|
+
onChange: (e)=>onUpdate({
|
|
2134
|
+
validation: {
|
|
2135
|
+
...field.validation,
|
|
2136
|
+
requiredMessage: e.target.value || void 0
|
|
2137
|
+
}
|
|
2138
|
+
}),
|
|
2234
2139
|
className: "h-8 text-sm"
|
|
2235
2140
|
})
|
|
2236
2141
|
]
|
|
2237
2142
|
})
|
|
2238
2143
|
]
|
|
2239
2144
|
}),
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
const effect = getEffectDescription(rule);
|
|
2252
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
2253
|
-
className: "group border rounded-lg p-3 hover:border-primary/50 transition-colors",
|
|
2254
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2255
|
-
className: "flex items-start justify-between gap-2",
|
|
2256
|
-
children: [
|
|
2257
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2258
|
-
className: "flex-1 min-w-0",
|
|
2259
|
-
children: [
|
|
2260
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2261
|
-
className: "flex items-center gap-2 mb-1",
|
|
2262
|
-
children: [
|
|
2263
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
2264
|
-
className: `text-xs font-medium px-2 py-0.5 rounded ${effect.color}`,
|
|
2265
|
-
children: effect.label
|
|
2266
|
-
}),
|
|
2267
|
-
rule.conditions.length > 1 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
2268
|
-
className: "text-xs text-muted-foreground",
|
|
2269
|
-
children: [
|
|
2270
|
-
"(",
|
|
2271
|
-
rule.operator,
|
|
2272
|
-
")"
|
|
2273
|
-
]
|
|
2274
|
-
})
|
|
2275
|
-
]
|
|
2276
|
-
}),
|
|
2277
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
2278
|
-
className: "text-sm text-muted-foreground truncate",
|
|
2279
|
-
children: describeRule(rule)
|
|
2280
|
-
})
|
|
2281
|
-
]
|
|
2282
|
-
}),
|
|
2283
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2284
|
-
className: "flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",
|
|
2285
|
-
children: [
|
|
2286
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
2287
|
-
variant: "ghost",
|
|
2288
|
-
size: "sm",
|
|
2289
|
-
className: "h-7 w-7 p-0",
|
|
2290
|
-
onClick: ()=>editRule(index),
|
|
2291
|
-
"aria-label": "Edit rule",
|
|
2292
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Settings, {
|
|
2293
|
-
className: "h-3.5 w-3.5"
|
|
2294
|
-
})
|
|
2295
|
-
}),
|
|
2296
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
2297
|
-
variant: "ghost",
|
|
2298
|
-
size: "2xs",
|
|
2299
|
-
icon: true,
|
|
2300
|
-
className: "text-destructive hover:text-destructive",
|
|
2301
|
-
onClick: ()=>deleteRule(index),
|
|
2302
|
-
"aria-label": "Delete rule",
|
|
2303
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Trash2, {
|
|
2304
|
-
className: "h-3.5 w-3.5"
|
|
2305
|
-
})
|
|
2306
|
-
})
|
|
2307
|
-
]
|
|
2308
|
-
})
|
|
2309
|
-
]
|
|
2310
|
-
})
|
|
2311
|
-
}, index);
|
|
2312
|
-
})
|
|
2313
|
-
]
|
|
2314
|
-
}),
|
|
2315
|
-
isAddingRule ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2316
|
-
className: "border rounded-lg p-4 space-y-4 bg-muted/20",
|
|
2317
|
-
children: [
|
|
2318
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2319
|
-
className: "flex items-center justify-between",
|
|
2320
|
-
children: [
|
|
2321
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
|
|
2322
|
-
className: "font-medium",
|
|
2323
|
-
children: null !== editingRuleIndex ? 'Edit rule' : 'New rule'
|
|
2324
|
-
}),
|
|
2325
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
2326
|
-
variant: "ghost",
|
|
2327
|
-
size: "sm",
|
|
2328
|
-
onClick: resetBuilder,
|
|
2329
|
-
children: "Cancel"
|
|
2330
|
-
})
|
|
2331
|
-
]
|
|
2332
|
-
}),
|
|
2333
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2334
|
-
className: "space-y-2",
|
|
2335
|
-
children: [
|
|
2336
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
|
|
2337
|
-
className: "text-xs text-muted-foreground",
|
|
2338
|
-
children: "When conditions are met:"
|
|
2339
|
-
}),
|
|
2340
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
2341
|
-
className: "grid grid-cols-2 gap-2",
|
|
2342
|
-
children: RULE_EFFECTS.map((effect)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("button", {
|
|
2343
|
-
type: "button",
|
|
2344
|
-
className: `flex items-center gap-2 p-2 rounded-lg border text-left text-sm transition-all ${selectedEffect === effect.value ? effect.color + ' border-current' : 'hover:bg-muted'}`,
|
|
2345
|
-
onClick: ()=>setSelectedEffect(effect.value),
|
|
2346
|
-
children: [
|
|
2347
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(effect.Icon, {
|
|
2348
|
-
className: "h-4 w-4"
|
|
2349
|
-
}),
|
|
2350
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
2351
|
-
className: "font-medium",
|
|
2352
|
-
children: effect.label
|
|
2353
|
-
})
|
|
2354
|
-
]
|
|
2355
|
-
}, effect.value))
|
|
2356
|
-
})
|
|
2357
|
-
]
|
|
2358
|
-
}),
|
|
2359
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2360
|
-
className: "space-y-3",
|
|
2361
|
-
children: [
|
|
2362
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2363
|
-
className: "flex items-center justify-between",
|
|
2364
|
-
children: [
|
|
2365
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
|
|
2366
|
-
className: "text-xs text-muted-foreground",
|
|
2367
|
-
children: "Conditions:"
|
|
2368
|
-
}),
|
|
2369
|
-
conditions.length > 1 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.Select, {
|
|
2370
|
-
value: conditionOperator,
|
|
2371
|
-
onValueChange: (v)=>setConditionOperator(v),
|
|
2372
|
-
children: [
|
|
2373
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectTrigger, {
|
|
2374
|
-
"aria-label": "Condition match mode",
|
|
2375
|
-
className: "w-24 h-7 text-xs",
|
|
2376
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectValue, {})
|
|
2377
|
-
}),
|
|
2378
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.SelectContent, {
|
|
2379
|
-
children: [
|
|
2380
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
|
|
2381
|
-
value: "AND",
|
|
2382
|
-
children: "Match ALL"
|
|
2383
|
-
}),
|
|
2384
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
|
|
2385
|
-
value: "OR",
|
|
2386
|
-
children: "Match ANY"
|
|
2387
|
-
})
|
|
2388
|
-
]
|
|
2389
|
-
})
|
|
2390
|
-
]
|
|
2391
|
-
})
|
|
2392
|
-
]
|
|
2393
|
-
}),
|
|
2394
|
-
conditions.map((cond, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2395
|
-
className: "space-y-2",
|
|
2396
|
-
children: [
|
|
2397
|
-
index > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2398
|
-
className: "flex items-center gap-2 text-xs text-muted-foreground",
|
|
2399
|
-
children: [
|
|
2400
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(separator_cjs_namespaceObject.Separator, {
|
|
2401
|
-
className: "flex-1"
|
|
2402
|
-
}),
|
|
2403
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
2404
|
-
children: conditionOperator
|
|
2405
|
-
}),
|
|
2406
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(separator_cjs_namespaceObject.Separator, {
|
|
2407
|
-
className: "flex-1"
|
|
2408
|
-
})
|
|
2409
|
-
]
|
|
2410
|
-
}),
|
|
2411
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2412
|
-
className: "flex gap-2 items-start",
|
|
2413
|
-
children: [
|
|
2414
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2415
|
-
className: "flex-1 space-y-2",
|
|
2416
|
-
children: [
|
|
2417
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.Select, {
|
|
2418
|
-
value: cond.field,
|
|
2419
|
-
onValueChange: (v)=>updateCondition(index, {
|
|
2420
|
-
field: v
|
|
2421
|
-
}),
|
|
2422
|
-
children: [
|
|
2423
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectTrigger, {
|
|
2424
|
-
"aria-label": "Condition field",
|
|
2425
|
-
className: "h-8 text-sm",
|
|
2426
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectValue, {
|
|
2427
|
-
placeholder: "Select field..."
|
|
2428
|
-
})
|
|
2429
|
-
}),
|
|
2430
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectContent, {
|
|
2431
|
-
children: allFields.map((field)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
|
|
2432
|
-
value: field.name,
|
|
2433
|
-
children: field.label
|
|
2434
|
-
}, field.id))
|
|
2435
|
-
})
|
|
2436
|
-
]
|
|
2437
|
-
}),
|
|
2438
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
2439
|
-
className: "flex gap-2",
|
|
2440
|
-
children: [
|
|
2441
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.Select, {
|
|
2442
|
-
value: cond.operator,
|
|
2443
|
-
onValueChange: (v)=>updateCondition(index, {
|
|
2444
|
-
operator: v
|
|
2445
|
-
}),
|
|
2446
|
-
children: [
|
|
2447
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectTrigger, {
|
|
2448
|
-
"aria-label": "Condition operator",
|
|
2449
|
-
className: "w-32 h-8 text-sm",
|
|
2450
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectValue, {})
|
|
2451
|
-
}),
|
|
2452
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectContent, {
|
|
2453
|
-
children: CONDITION_OPERATORS.map((op)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
|
|
2454
|
-
value: op.value,
|
|
2455
|
-
children: op.label
|
|
2456
|
-
}, op.value))
|
|
2457
|
-
})
|
|
2458
|
-
]
|
|
2459
|
-
}),
|
|
2460
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
2461
|
-
className: "flex-1",
|
|
2462
|
-
children: cond.field && getFieldOptions(cond.field).length > 0 && ('is' === cond.operator || 'isNot' === cond.operator) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.Select, {
|
|
2463
|
-
value: cond.value,
|
|
2464
|
-
onValueChange: (v)=>updateCondition(index, {
|
|
2465
|
-
value: v
|
|
2466
|
-
}),
|
|
2467
|
-
children: [
|
|
2468
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectTrigger, {
|
|
2469
|
-
"aria-label": "Condition value",
|
|
2470
|
-
className: "h-8 text-sm",
|
|
2471
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectValue, {
|
|
2472
|
-
placeholder: "Select value..."
|
|
2473
|
-
})
|
|
2474
|
-
}),
|
|
2475
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectContent, {
|
|
2476
|
-
children: getFieldOptions(cond.field).map((opt)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
|
|
2477
|
-
value: String(opt.value),
|
|
2478
|
-
children: opt.label
|
|
2479
|
-
}, String(opt.value)))
|
|
2480
|
-
})
|
|
2481
|
-
]
|
|
2482
|
-
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
|
|
2483
|
-
className: "h-8 text-sm",
|
|
2484
|
-
placeholder: 'in' === cond.operator || 'notIn' === cond.operator ? 'value1, value2, ...' : 'matches' === cond.operator ? 'regex pattern' : 'value',
|
|
2485
|
-
value: cond.value,
|
|
2486
|
-
onChange: (e)=>updateCondition(index, {
|
|
2487
|
-
value: e.target.value
|
|
2488
|
-
})
|
|
2489
|
-
})
|
|
2490
|
-
})
|
|
2491
|
-
]
|
|
2492
|
-
})
|
|
2493
|
-
]
|
|
2494
|
-
}),
|
|
2495
|
-
conditions.length > 1 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
2496
|
-
variant: "ghost",
|
|
2497
|
-
size: "sm",
|
|
2498
|
-
className: "h-8 w-8 p-0 text-muted-foreground",
|
|
2499
|
-
onClick: ()=>removeCondition(index),
|
|
2500
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Trash2, {
|
|
2501
|
-
className: "h-3.5 w-3.5"
|
|
2502
|
-
})
|
|
2503
|
-
})
|
|
2504
|
-
]
|
|
2505
|
-
})
|
|
2506
|
-
]
|
|
2507
|
-
}, index)),
|
|
2508
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(button_cjs_namespaceObject.Button, {
|
|
2509
|
-
variant: "outline",
|
|
2510
|
-
size: "sm",
|
|
2511
|
-
className: "w-full",
|
|
2512
|
-
onClick: addCondition,
|
|
2513
|
-
children: [
|
|
2514
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Plus, {
|
|
2515
|
-
className: "h-3 w-3 mr-2"
|
|
2516
|
-
}),
|
|
2517
|
-
"Add condition"
|
|
2518
|
-
]
|
|
2519
|
-
})
|
|
2520
|
-
]
|
|
2521
|
-
}),
|
|
2522
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
2523
|
-
className: "w-full",
|
|
2524
|
-
onClick: saveRule,
|
|
2525
|
-
disabled: !conditions.some((c)=>c.field),
|
|
2526
|
-
children: null !== editingRuleIndex ? 'Update rule' : 'Add rule'
|
|
2527
|
-
})
|
|
2528
|
-
]
|
|
2529
|
-
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(button_cjs_namespaceObject.Button, {
|
|
2530
|
-
variant: "outline",
|
|
2531
|
-
className: "w-full",
|
|
2532
|
-
onClick: ()=>setIsAddingRule(true),
|
|
2533
|
-
children: [
|
|
2534
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Plus, {
|
|
2535
|
-
className: "h-4 w-4 mr-2"
|
|
2536
|
-
}),
|
|
2537
|
-
"Add conditional rule"
|
|
2538
|
-
]
|
|
2539
|
-
})
|
|
2145
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(rules_editor_index_cjs_namespaceObject.RulesEditor, {
|
|
2146
|
+
label: "Field rules",
|
|
2147
|
+
value: rules,
|
|
2148
|
+
onChange: changeRules,
|
|
2149
|
+
outcomes: DESIGNER_OUTCOMES,
|
|
2150
|
+
fields: options.fields,
|
|
2151
|
+
operators: external_rules_engine_dialect_cjs_namespaceObject.rulesEngineVocabulary.operators,
|
|
2152
|
+
valueModes: external_rules_engine_dialect_cjs_namespaceObject.rulesEngineVocabulary.valueModes,
|
|
2153
|
+
dialect: external_rules_engine_dialect_cjs_namespaceObject.rulesEngineDialect,
|
|
2154
|
+
defaultTouched: touched
|
|
2155
|
+
}, editorKey)
|
|
2540
2156
|
]
|
|
2541
2157
|
});
|
|
2542
2158
|
}
|