@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.
Files changed (124) hide show
  1. package/dist/components/forms/field-renderer.cjs +1 -1
  2. package/dist/components/forms/field-renderer.js +1 -1
  3. package/dist/components/forms/field-rules-strings.cjs +40 -0
  4. package/dist/components/forms/field-rules-strings.d.ts +17 -0
  5. package/dist/components/forms/field-rules-strings.js +6 -0
  6. package/dist/components/forms/field-rules.cjs +526 -0
  7. package/dist/components/forms/field-rules.d.ts +97 -0
  8. package/dist/components/forms/field-rules.js +468 -0
  9. package/dist/components/forms/form-designer.cjs +208 -592
  10. package/dist/components/forms/form-designer.js +210 -594
  11. package/dist/components/forms/form-schema.d.ts +5 -0
  12. package/dist/components/forms/index.cjs +43 -3
  13. package/dist/components/forms/index.d.ts +4 -0
  14. package/dist/components/forms/index.js +5 -1
  15. package/dist/components/forms/metadata-form.cjs +1 -1
  16. package/dist/components/forms/metadata-form.js +1 -1
  17. package/dist/components/forms/rules-engine-dialect.cjs +644 -0
  18. package/dist/components/forms/rules-engine-dialect.d.ts +90 -0
  19. package/dist/components/forms/rules-engine-dialect.js +537 -0
  20. package/dist/components/forms/rules-engine.cjs +99 -10
  21. package/dist/components/forms/rules-engine.d.ts +5 -0
  22. package/dist/components/forms/rules-engine.js +99 -10
  23. package/dist/components/forms/use-field-rules.cjs +122 -0
  24. package/dist/components/forms/use-field-rules.d.ts +31 -0
  25. package/dist/components/forms/use-field-rules.js +88 -0
  26. package/dist/components/ui/conditions-editor/condition-row.cjs +458 -0
  27. package/dist/components/ui/conditions-editor/condition-row.d.ts +23 -0
  28. package/dist/components/ui/conditions-editor/condition-row.js +421 -0
  29. package/dist/components/ui/conditions-editor/conditions-editor.cjs +363 -0
  30. package/dist/components/ui/conditions-editor/conditions-editor.d.ts +67 -0
  31. package/dist/components/ui/conditions-editor/conditions-editor.js +329 -0
  32. package/dist/components/ui/conditions-editor/context.cjs +45 -0
  33. package/dist/components/ui/conditions-editor/context.d.ts +54 -0
  34. package/dist/components/ui/conditions-editor/context.js +8 -0
  35. package/dist/components/ui/conditions-editor/index.cjs +55 -0
  36. package/dist/components/ui/conditions-editor/index.d.ts +6 -0
  37. package/dist/components/ui/conditions-editor/index.js +6 -0
  38. package/dist/components/ui/conditions-editor/model.cjs +126 -0
  39. package/dist/components/ui/conditions-editor/model.d.ts +39 -0
  40. package/dist/components/ui/conditions-editor/model.js +71 -0
  41. package/dist/components/ui/conditions-editor/status.cjs +198 -0
  42. package/dist/components/ui/conditions-editor/status.d.ts +44 -0
  43. package/dist/components/ui/conditions-editor/status.js +131 -0
  44. package/dist/components/ui/conditions-editor/strings.cjs +86 -0
  45. package/dist/components/ui/conditions-editor/strings.d.ts +62 -0
  46. package/dist/components/ui/conditions-editor/strings.js +52 -0
  47. package/dist/components/ui/conditions-editor/vocabulary.cjs +163 -0
  48. package/dist/components/ui/conditions-editor/vocabulary.d.ts +51 -0
  49. package/dist/components/ui/conditions-editor/vocabulary.js +129 -0
  50. package/dist/components/ui/field-actions/index.cjs +9 -2
  51. package/dist/components/ui/field-actions/index.d.ts +1 -0
  52. package/dist/components/ui/field-actions/index.js +2 -1
  53. package/dist/components/ui/field-actions/insert-variable-action.cjs +3 -1
  54. package/dist/components/ui/field-actions/insert-variable-action.d.ts +4 -1
  55. package/dist/components/ui/field-actions/insert-variable-action.js +3 -1
  56. package/dist/components/ui/field-actions/rules-action.cjs +244 -0
  57. package/dist/components/ui/field-actions/rules-action.d.ts +42 -0
  58. package/dist/components/ui/field-actions/rules-action.js +207 -0
  59. package/dist/components/ui/index.cjs +273 -234
  60. package/dist/components/ui/index.d.ts +3 -0
  61. package/dist/components/ui/index.js +3 -0
  62. package/dist/components/ui/quick-form-field/components/field-header.cjs +137 -167
  63. package/dist/components/ui/quick-form-field/components/field-header.d.ts +1 -1
  64. package/dist/components/ui/quick-form-field/components/field-header.js +138 -168
  65. package/dist/components/ui/quick-form-field/components/header-actions.cjs +187 -0
  66. package/dist/components/ui/quick-form-field/components/header-actions.d.ts +59 -0
  67. package/dist/components/ui/quick-form-field/components/header-actions.js +138 -0
  68. package/dist/components/ui/quick-form-field/components/header-context.cjs +59 -0
  69. package/dist/components/ui/quick-form-field/components/header-context.d.ts +33 -0
  70. package/dist/components/ui/quick-form-field/components/header-context.js +16 -0
  71. package/dist/components/ui/quick-form-field/index.cjs +18 -4
  72. package/dist/components/ui/quick-form-field/index.d.ts +2 -0
  73. package/dist/components/ui/quick-form-field/index.js +3 -1
  74. package/dist/components/ui/quick-form-field/quick-form-field.cjs +1 -1
  75. package/dist/components/ui/quick-form-field/quick-form-field.d.ts +6 -6
  76. package/dist/components/ui/quick-form-field/quick-form-field.js +1 -1
  77. package/dist/components/ui/quick-form-field/types.d.ts +42 -11
  78. package/dist/components/ui/row-groups/add-row-button.cjs +54 -0
  79. package/dist/components/ui/row-groups/add-row-button.d.ts +10 -0
  80. package/dist/components/ui/row-groups/add-row-button.js +20 -0
  81. package/dist/components/ui/row-groups/after-press.cjs +73 -0
  82. package/dist/components/ui/row-groups/after-press.d.ts +7 -0
  83. package/dist/components/ui/row-groups/after-press.js +36 -0
  84. package/dist/components/ui/row-groups/collapsible-row-group.cjs +83 -0
  85. package/dist/components/ui/row-groups/collapsible-row-group.d.ts +13 -0
  86. package/dist/components/ui/row-groups/collapsible-row-group.js +49 -0
  87. package/dist/components/ui/row-groups/empty-rows.cjs +42 -0
  88. package/dist/components/ui/row-groups/empty-rows.d.ts +7 -0
  89. package/dist/components/ui/row-groups/empty-rows.js +8 -0
  90. package/dist/components/ui/row-groups/group-mode-toggle.cjs +80 -0
  91. package/dist/components/ui/row-groups/group-mode-toggle.d.ts +26 -0
  92. package/dist/components/ui/row-groups/group-mode-toggle.js +40 -0
  93. package/dist/components/ui/row-groups/index.cjs +62 -0
  94. package/dist/components/ui/row-groups/index.d.ts +6 -0
  95. package/dist/components/ui/row-groups/index.js +7 -0
  96. package/dist/components/ui/row-groups/row-delete-button.cjs +54 -0
  97. package/dist/components/ui/row-groups/row-delete-button.d.ts +18 -0
  98. package/dist/components/ui/row-groups/row-delete-button.js +20 -0
  99. package/dist/components/ui/row-groups/use-row-focus.cjs +82 -0
  100. package/dist/components/ui/row-groups/use-row-focus.d.ts +17 -0
  101. package/dist/components/ui/row-groups/use-row-focus.js +48 -0
  102. package/dist/components/ui/rules-editor/context.cjs +45 -0
  103. package/dist/components/ui/rules-editor/context.d.ts +52 -0
  104. package/dist/components/ui/rules-editor/context.js +8 -0
  105. package/dist/components/ui/rules-editor/index.cjs +56 -0
  106. package/dist/components/ui/rules-editor/index.d.ts +4 -0
  107. package/dist/components/ui/rules-editor/index.js +4 -0
  108. package/dist/components/ui/rules-editor/model.cjs +205 -0
  109. package/dist/components/ui/rules-editor/model.d.ts +128 -0
  110. package/dist/components/ui/rules-editor/model.js +144 -0
  111. package/dist/components/ui/rules-editor/rule-card.cjs +470 -0
  112. package/dist/components/ui/rules-editor/rule-card.d.ts +14 -0
  113. package/dist/components/ui/rules-editor/rule-card.js +436 -0
  114. package/dist/components/ui/rules-editor/rules-editor.cjs +160 -0
  115. package/dist/components/ui/rules-editor/rules-editor.d.ts +66 -0
  116. package/dist/components/ui/rules-editor/rules-editor.js +126 -0
  117. package/dist/components/ui/rules-editor/strings.cjs +68 -0
  118. package/dist/components/ui/rules-editor/strings.d.ts +56 -0
  119. package/dist/components/ui/rules-editor/strings.js +34 -0
  120. package/dist/index.cjs +129 -8
  121. package/dist/index.d.ts +17 -4
  122. package/dist/index.js +10 -3
  123. package/dist/styles.css +97 -24
  124. package/package.json +2 -2
@@ -0,0 +1,144 @@
1
+ import { DEFAULT_CONDITION_OPERATORS, createCondition, createConditionGroup, isConditionComplete } from "../conditions-editor/index.js";
2
+ import { defaultValueModes, resolveCondition } from "../conditions-editor/status.js";
3
+ function newId(prefix) {
4
+ return `${prefix}-${crypto.randomUUID()}`;
5
+ }
6
+ function createRule(init) {
7
+ const id = init.id ?? newId('rule');
8
+ return void 0 !== init.expression ? {
9
+ id,
10
+ outcome: init.outcome,
11
+ mode: 'expression',
12
+ expression: init.expression
13
+ } : {
14
+ id,
15
+ outcome: init.outcome,
16
+ mode: 'conditions',
17
+ conditions: init.conditions ?? createConditionGroup('all', [
18
+ createCondition()
19
+ ])
20
+ };
21
+ }
22
+ function withMode(rule, next) {
23
+ const rest = Object.fromEntries(Object.entries(rule).filter(([key])=>'conditions' !== key && 'expression' !== key && 'preservedSource' !== key));
24
+ return {
25
+ ...rest,
26
+ ...next
27
+ };
28
+ }
29
+ function conditionsOf(node) {
30
+ return 'condition' === node.kind ? [
31
+ node
32
+ ] : node.children.flatMap(conditionsOf);
33
+ }
34
+ function isBlank(rule) {
35
+ if ('preserved' === rule.mode) return false;
36
+ return 'expression' === rule.mode ? '' === rule.expression.trim() : conditionsOf(rule.conditions).every((c)=>!c.field && !c.value && (c.values?.length ?? 0) === 0);
37
+ }
38
+ function isUnconditionalRule(rule) {
39
+ return 'conditions' === rule.mode && 0 === rule.conditions.children.length;
40
+ }
41
+ function groupComplete(group, vocabulary, nested) {
42
+ if (nested && 0 === group.children.length) return false;
43
+ return group.children.every((child)=>'condition' === child.kind ? isConditionComplete(child, vocabulary) : groupComplete(child, vocabulary, true));
44
+ }
45
+ function isRuleComplete(rule, vocabulary) {
46
+ if (!vocabulary.outcomes.some((option)=>option.value === rule.outcome)) return false;
47
+ if ('preserved' === rule.mode) return true;
48
+ if ('expression' === rule.mode) return '' !== rule.expression.trim();
49
+ return groupComplete(rule.conditions, {
50
+ fields: vocabulary.fields,
51
+ operators: vocabulary.operators ?? DEFAULT_CONDITION_OPERATORS,
52
+ valueModes: vocabulary.valueModes ?? defaultValueModes(vocabulary.variables)
53
+ }, false);
54
+ }
55
+ function missingFields(names, fields) {
56
+ return names.filter((name)=>!fields.some((field)=>name === field.value || name.startsWith(`${field.value}.`)));
57
+ }
58
+ function unknownFields(expression, fields, dialect) {
59
+ return missingFields(dialect?.fieldsOf?.(expression) ?? [], fields);
60
+ }
61
+ function unknownValueFields(c, vocabulary, dialect) {
62
+ const value = c.value?.trim();
63
+ if (!value || 'expression' !== resolveCondition(c, vocabulary).mode) return [];
64
+ return unknownFields(value, vocabulary.fields, dialect);
65
+ }
66
+ function findRuleIssues(rules, vocabulary, dialect) {
67
+ const resolved = {
68
+ fields: vocabulary.fields,
69
+ operators: vocabulary.operators ?? DEFAULT_CONDITION_OPERATORS,
70
+ valueModes: vocabulary.valueModes ?? defaultValueModes(vocabulary.variables)
71
+ };
72
+ const issues = [];
73
+ for (const rule of rules){
74
+ const ruleId = rule.id;
75
+ if (!vocabulary.outcomes.some((option)=>option.value === rule.outcome)) issues.push({
76
+ ruleId,
77
+ kind: 'outcome'
78
+ });
79
+ if (dialect?.repair?.(rule)) issues.push({
80
+ ruleId,
81
+ kind: 'repair'
82
+ });
83
+ if ('preserved' === rule.mode) {
84
+ if (missingFields(rule.fieldKeys ?? [], resolved.fields).length > 0) issues.push({
85
+ ruleId,
86
+ kind: 'unknownField'
87
+ });
88
+ continue;
89
+ }
90
+ if ('expression' === rule.mode) {
91
+ if ('' === rule.expression.trim()) {
92
+ issues.push({
93
+ ruleId,
94
+ kind: 'incomplete'
95
+ });
96
+ continue;
97
+ }
98
+ if (unknownFields(rule.expression, resolved.fields, dialect).length > 0) issues.push({
99
+ ruleId,
100
+ kind: 'unknownField'
101
+ });
102
+ if (dialect?.checkExpression?.(rule, resolved) === 'invalid') issues.push({
103
+ ruleId,
104
+ kind: 'expression'
105
+ });
106
+ continue;
107
+ }
108
+ const visit = (group, nested)=>{
109
+ if (nested && 0 === group.children.length) issues.push({
110
+ ruleId,
111
+ nodeId: group.id,
112
+ kind: 'incomplete'
113
+ });
114
+ for (const child of group.children)if ('group' === child.kind) visit(child, true);
115
+ else if (child.field && !resolved.fields.some((field)=>field.value === child.field)) issues.push({
116
+ ruleId,
117
+ nodeId: child.id,
118
+ kind: 'unknownField'
119
+ });
120
+ else if (isConditionComplete(child, resolved)) {
121
+ if (unknownValueFields(child, resolved, dialect).length > 0) issues.push({
122
+ ruleId,
123
+ nodeId: child.id,
124
+ kind: 'unknownField'
125
+ });
126
+ } else issues.push({
127
+ ruleId,
128
+ nodeId: child.id,
129
+ kind: 'incomplete'
130
+ });
131
+ };
132
+ visit(rule.conditions, false);
133
+ }
134
+ return issues;
135
+ }
136
+ function issueIds(issues) {
137
+ return issues.flatMap((issue)=>[
138
+ issue.ruleId,
139
+ ...issue.nodeId ? [
140
+ issue.nodeId
141
+ ] : []
142
+ ]);
143
+ }
144
+ export { createRule, findRuleIssues, isBlank, isRuleComplete, isUnconditionalRule, issueIds, missingFields, unknownFields, unknownValueFields, withMode };
@@ -0,0 +1,470 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ RuleCard: ()=>rule_card_RuleCard
28
+ });
29
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
+ const external_lucide_react_namespaceObject = require("lucide-react");
31
+ const external_react_namespaceObject = require("react");
32
+ const external_alert_dialog_cjs_namespaceObject = require("../alert-dialog.cjs");
33
+ const external_button_cjs_namespaceObject = require("../button.cjs");
34
+ const index_cjs_namespaceObject = require("../conditions-editor/index.cjs");
35
+ const external_dropdown_menu_cjs_namespaceObject = require("../dropdown-menu.cjs");
36
+ const field_menu_cjs_namespaceObject = require("../field-addons/field-menu.cjs");
37
+ const external_form_field_cjs_namespaceObject = require("../form-field.cjs");
38
+ const external_row_groups_index_cjs_namespaceObject = require("../row-groups/index.cjs");
39
+ const after_press_cjs_namespaceObject = require("../row-groups/after-press.cjs");
40
+ const external_select_cjs_namespaceObject = require("../select.cjs");
41
+ const external_textarea_cjs_namespaceObject = require("../textarea.cjs");
42
+ const external_context_cjs_namespaceObject = require("./context.cjs");
43
+ const external_model_cjs_namespaceObject = require("./model.cjs");
44
+ function switched(rule, dialect, vocabulary) {
45
+ if ('conditions' === rule.mode) {
46
+ const expression = dialect?.toExpression?.(rule.conditions, vocabulary) ?? ((0, external_model_cjs_namespaceObject.isBlank)(rule) ? '' : void 0);
47
+ return void 0 === expression ? void 0 : (0, external_model_cjs_namespaceObject.withMode)(rule, {
48
+ mode: 'expression',
49
+ expression
50
+ });
51
+ }
52
+ if ('preserved' === rule.mode) return;
53
+ if ((0, external_model_cjs_namespaceObject.isBlank)(rule)) return (0, external_model_cjs_namespaceObject.withMode)(rule, {
54
+ mode: 'conditions',
55
+ conditions: oneCondition()
56
+ });
57
+ const conditions = dialect?.fromExpression?.(rule.expression, vocabulary);
58
+ return conditions && (0, external_model_cjs_namespaceObject.withMode)(rule, {
59
+ mode: 'conditions',
60
+ conditions
61
+ });
62
+ }
63
+ const oneCondition = ()=>(0, index_cjs_namespaceObject.createConditionGroup)('all', [
64
+ (0, index_cjs_namespaceObject.createCondition)()
65
+ ]);
66
+ const FOCUSABLE = 'button:not(:disabled), input:not(:disabled), textarea:not(:disabled)';
67
+ function BuiltInExpressionEditor({ id, value, onChange, onBlur, labelledBy, invalid, errorId, disabled, placeholder }) {
68
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_textarea_cjs_namespaceObject.Textarea, {
69
+ id: id,
70
+ value: value,
71
+ onChange: (event)=>onChange(event.target.value),
72
+ onBlur: onBlur,
73
+ placeholder: placeholder,
74
+ disabled: disabled,
75
+ minRows: 2,
76
+ maxRows: 8,
77
+ spellCheck: false,
78
+ autoCapitalize: "off",
79
+ autoCorrect: "off",
80
+ className: "font-mono text-xs",
81
+ "aria-labelledby": labelledBy,
82
+ "aria-invalid": invalid || void 0,
83
+ "aria-describedby": errorId,
84
+ "aria-errormessage": errorId
85
+ });
86
+ }
87
+ const rule_card_RuleCard = /*#__PURE__*/ external_react_namespaceObject.memo(function({ rule, index, position, onDelete }) {
88
+ const editor = (0, external_context_cjs_namespaceObject.useRulesEditor)();
89
+ const { strings: text, disabled, updateRule } = editor;
90
+ const [touched, setTouched] = external_react_namespaceObject.useState(()=>editor.defaultTouched?.includes(rule.id) ?? false);
91
+ const [confirm, setConfirm] = external_react_namespaceObject.useState({
92
+ open: false,
93
+ target: 'expression'
94
+ });
95
+ const baseId = external_react_namespaceObject.useId();
96
+ const ids = {
97
+ name: `${baseId}-name`,
98
+ outcome: `${baseId}-outcome`,
99
+ expression: `${baseId}-expression`,
100
+ expressionLabel: `${baseId}-expression-label`,
101
+ outcomeError: `${baseId}-outcome-error`,
102
+ repair: `${baseId}-repair`,
103
+ expressionError: `${baseId}-expression-error`,
104
+ preserved: `${baseId}-preserved`,
105
+ preservedLabel: `${baseId}-preserved-label`,
106
+ preservedNote: `${baseId}-preserved-note`,
107
+ preservedError: `${baseId}-preserved-error`
108
+ };
109
+ const ruleName = text.ruleName(index);
110
+ const conditionsName = text.ruleConditions(ruleName);
111
+ const modeRef = external_react_namespaceObject.useRef(null);
112
+ const bodyRef = external_react_namespaceObject.useRef(null);
113
+ const restoreFocus = ()=>{
114
+ if (modeRef.current?.isConnected) modeRef.current.focus();
115
+ else bodyRef.current?.querySelector(FOCUSABLE)?.focus();
116
+ };
117
+ const apply = (next)=>{
118
+ setTouched(false);
119
+ updateRule(next);
120
+ };
121
+ const switchMode = (mode)=>{
122
+ if (mode === rule.mode) return;
123
+ const next = switched(rule, editor.dialect, editor.vocabulary);
124
+ if (next) apply(next);
125
+ else setConfirm({
126
+ open: true,
127
+ target: mode
128
+ });
129
+ };
130
+ const confirmSwitch = ()=>{
131
+ if (disabled) return;
132
+ apply('expression' === confirm.target ? (0, external_model_cjs_namespaceObject.withMode)(rule, {
133
+ mode: 'expression',
134
+ expression: ''
135
+ }) : (0, external_model_cjs_namespaceObject.withMode)(rule, {
136
+ mode: 'conditions',
137
+ conditions: oneCondition()
138
+ }));
139
+ };
140
+ const problem = 'expression' === rule.mode && '' !== rule.expression.trim() ? editor.dialect?.checkExpression?.(rule, editor.vocabulary) : void 0;
141
+ const missing = 'expression' === rule.mode && '' !== rule.expression.trim() ? (0, external_model_cjs_namespaceObject.unknownFields)(rule.expression, editor.vocabulary.fields, editor.dialect) : [];
142
+ const [openedText] = external_react_namespaceObject.useState(()=>'expression' === rule.mode ? rule.expression : void 0);
143
+ const unchanged = 'expression' === rule.mode && rule.expression === openedText;
144
+ const repair = editor.dialect?.repair?.(rule);
145
+ const repaired = external_react_namespaceObject.useRef(false);
146
+ const repairRule = ()=>{
147
+ if (!repair) return;
148
+ repaired.current = true;
149
+ updateRule(repair.rule);
150
+ };
151
+ external_react_namespaceObject.useEffect(()=>{
152
+ if (!repaired.current || repair) return;
153
+ repaired.current = false;
154
+ restoreFocus();
155
+ });
156
+ const { vocabulary, dialect } = editor;
157
+ const valueWarning = external_react_namespaceObject.useCallback((c)=>{
158
+ const missing = (0, external_model_cjs_namespaceObject.unknownValueFields)(c, vocabulary, dialect);
159
+ return missing.length > 0 ? text.errorExpressionUnknownFields(missing) : void 0;
160
+ }, [
161
+ vocabulary,
162
+ dialect,
163
+ text
164
+ ]);
165
+ const outcomeKnown = editor.outcomes.some((option)=>option.value === rule.outcome);
166
+ const outcomeError = outcomeKnown ? void 0 : text.errorOutcome;
167
+ const showModeToggle = editor.allowExpressions || 'conditions' !== rule.mode;
168
+ const modes = {
169
+ conditions: {
170
+ icon: external_lucide_react_namespaceObject.Form,
171
+ title: text.modeConditions,
172
+ description: text.modeConditionsDescription
173
+ },
174
+ expression: {
175
+ icon: external_lucide_react_namespaceObject.SquareFunction,
176
+ title: text.modeExpression,
177
+ description: text.modeExpressionDescription
178
+ },
179
+ preserved: {
180
+ icon: external_lucide_react_namespaceObject.Braces,
181
+ title: text.modePreserved,
182
+ description: text.preservedNote
183
+ }
184
+ };
185
+ const ModeIcon = modes[rule.mode].icon;
186
+ let body;
187
+ if ('conditions' === rule.mode) body = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ConditionsEditor, {
188
+ label: conditionsName,
189
+ value: rule.conditions,
190
+ onChange: (conditions)=>updateRule({
191
+ ...rule,
192
+ conditions
193
+ }),
194
+ fields: editor.vocabulary.fields,
195
+ operators: editor.vocabulary.operators,
196
+ valueModes: editor.vocabulary.valueModes,
197
+ variables: editor.variables,
198
+ renderValue: editor.renderValue,
199
+ maxDepth: 0,
200
+ showMatchMode: editor.showMatchMode,
201
+ container: "plain",
202
+ forceErrors: editor.forceErrors,
203
+ defaultTouched: editor.defaultTouched,
204
+ disabled: disabled,
205
+ strings: editor.conditionsStrings,
206
+ valueModeStrings: editor.valueModeStrings,
207
+ multiSelectStrings: editor.multiSelectStrings,
208
+ valueWarning: valueWarning
209
+ });
210
+ else if ('preserved' === rule.mode) {
211
+ const missingKeys = (0, external_model_cjs_namespaceObject.missingFields)(rule.fieldKeys ?? [], editor.vocabulary.fields);
212
+ const describedBy = [
213
+ ...missingKeys.length > 0 ? [
214
+ ids.preservedError
215
+ ] : [],
216
+ ...repair ? [] : [
217
+ ids.preservedNote
218
+ ]
219
+ ].join(' ');
220
+ body = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_form_field_cjs_namespaceObject.FormField, {
221
+ children: [
222
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldLabel, {
223
+ id: ids.preservedLabel,
224
+ htmlFor: ids.preserved,
225
+ children: text.modePreserved
226
+ }),
227
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_textarea_cjs_namespaceObject.Textarea, {
228
+ id: ids.preserved,
229
+ value: rule.preservedSource,
230
+ readOnly: true,
231
+ minRows: 2,
232
+ maxRows: 8,
233
+ spellCheck: false,
234
+ className: "font-mono text-xs",
235
+ "aria-labelledby": `${ids.name} ${ids.preservedLabel}`,
236
+ "aria-describedby": describedBy || void 0
237
+ }),
238
+ missingKeys.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
239
+ id: ids.preservedError,
240
+ children: text.errorExpressionUnknownFields(missingKeys)
241
+ }),
242
+ !repair && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldDescription, {
243
+ id: ids.preservedNote,
244
+ children: text.preservedNote
245
+ })
246
+ ]
247
+ });
248
+ } else {
249
+ const shown = editor.forceErrors || touched;
250
+ const error = shown && '' === rule.expression.trim() ? text.errorExpression : 'invalid' === problem && (shown || unchanged) ? text.errorExpressionInvalid : missing.length > 0 && (shown || unchanged) ? text.errorExpressionUnknownFields(missing) : void 0;
251
+ const props = {
252
+ rule,
253
+ id: ids.expression,
254
+ value: rule.expression,
255
+ onChange: (expression)=>updateRule({
256
+ ...rule,
257
+ expression
258
+ }),
259
+ onBlur: ()=>(0, after_press_cjs_namespaceObject.afterPress)(()=>setTouched(true)),
260
+ labelledBy: `${ids.name} ${ids.expressionLabel}`,
261
+ invalid: Boolean(error),
262
+ errorId: error ? ids.expressionError : void 0,
263
+ disabled,
264
+ placeholder: text.expressionPlaceholder || void 0
265
+ };
266
+ const custom = editor.renderExpressionEditor?.(props);
267
+ body = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_form_field_cjs_namespaceObject.FormField, {
268
+ children: [
269
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldLabel, {
270
+ id: ids.expressionLabel,
271
+ htmlFor: ids.expression,
272
+ children: text.expressionLabel
273
+ }),
274
+ void 0 === custom ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(BuiltInExpressionEditor, {
275
+ ...props
276
+ }) : custom,
277
+ error && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
278
+ id: ids.expressionError,
279
+ children: error
280
+ })
281
+ ]
282
+ });
283
+ }
284
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("fieldset", {
285
+ "data-row": "",
286
+ "aria-label": ruleName,
287
+ className: "m-0 flex min-w-0 flex-col gap-3 rounded-lg border border-solid border-border bg-card p-3",
288
+ children: [
289
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
290
+ id: ids.name,
291
+ className: "sr-only",
292
+ children: ruleName
293
+ }),
294
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
295
+ className: "flex flex-col",
296
+ children: [
297
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
298
+ className: "flex flex-wrap items-center gap-2",
299
+ children: [
300
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
301
+ className: "flex items-center gap-2",
302
+ children: [
303
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
304
+ id: ids.outcome,
305
+ className: "sr-only",
306
+ children: text.outcomeLabel
307
+ }),
308
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
309
+ value: outcomeKnown ? rule.outcome : '',
310
+ disabled: disabled,
311
+ onValueChange: (outcome)=>updateRule({
312
+ ...rule,
313
+ outcome
314
+ }),
315
+ children: [
316
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
317
+ "data-row-first": "",
318
+ className: "w-auto shrink-0",
319
+ "aria-labelledby": `${ids.name} ${ids.outcome}`,
320
+ "aria-invalid": outcomeError ? true : void 0,
321
+ "aria-describedby": outcomeError ? ids.outcomeError : void 0,
322
+ "aria-errormessage": outcomeError ? ids.outcomeError : void 0,
323
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {
324
+ placeholder: text.outcomePlaceholder
325
+ })
326
+ }),
327
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
328
+ children: editor.outcomes.map((option)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
329
+ value: option.value,
330
+ children: option.label
331
+ }, option.value))
332
+ })
333
+ ]
334
+ }),
335
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
336
+ className: "flex h-9 shrink-0 items-center text-xs text-muted-foreground future:h-10",
337
+ children: (0, external_model_cjs_namespaceObject.isUnconditionalRule)(rule) ? text.always : text.when
338
+ })
339
+ ]
340
+ }),
341
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
342
+ className: "ml-auto flex h-9 items-center gap-2 future:h-10",
343
+ children: [
344
+ showModeToggle && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenu, {
345
+ children: [
346
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuTrigger, {
347
+ asChild: true,
348
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
349
+ ref: modeRef,
350
+ type: "button",
351
+ variant: "ghost",
352
+ size: "xs",
353
+ icon: true,
354
+ disabled: disabled,
355
+ "aria-label": text.ruleMode(ruleName, modes[rule.mode].title),
356
+ title: text.ruleMode(ruleName, modes[rule.mode].title),
357
+ className: "px-1.5 text-muted-foreground hover:text-foreground",
358
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModeIcon, {})
359
+ })
360
+ }),
361
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuContent, {
362
+ align: "end",
363
+ className: "w-56",
364
+ onCloseAutoFocus: (event)=>{
365
+ if (modeRef.current?.isConnected) return;
366
+ event.preventDefault();
367
+ restoreFocus();
368
+ },
369
+ children: [
370
+ 'conditions',
371
+ 'expression'
372
+ ].map((mode)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(field_menu_cjs_namespaceObject.ValueModeMenuItem, {
373
+ icon: modes[mode].icon,
374
+ label: modes[mode].title,
375
+ description: modes[mode].description,
376
+ active: rule.mode === mode,
377
+ onClick: ()=>switchMode(mode)
378
+ }, mode))
379
+ })
380
+ ]
381
+ }),
382
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_row_groups_index_cjs_namespaceObject.RowDeleteButton, {
383
+ label: text.removeRule(index),
384
+ disabled: disabled,
385
+ onClick: ()=>onDelete(rule.id, position)
386
+ })
387
+ ]
388
+ })
389
+ ]
390
+ }),
391
+ outcomeError && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
392
+ id: ids.outcomeError,
393
+ children: outcomeError
394
+ })
395
+ ]
396
+ }),
397
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
398
+ ref: bodyRef,
399
+ className: "flex min-w-0 flex-col gap-3",
400
+ children: body
401
+ }),
402
+ repair && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
403
+ className: "flex flex-wrap items-center gap-x-2",
404
+ children: [
405
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
406
+ id: ids.repair,
407
+ children: text.ruleNeedsRepair(repair.reason)
408
+ }),
409
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
410
+ type: "button",
411
+ variant: "link",
412
+ size: "xs",
413
+ className: "h-auto px-0",
414
+ disabled: disabled,
415
+ "aria-describedby": ids.repair,
416
+ onClick: repairRule,
417
+ children: text.repairAction
418
+ })
419
+ ]
420
+ }),
421
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_dialog_cjs_namespaceObject.AlertDialog, {
422
+ open: confirm.open,
423
+ onOpenChange: (open)=>setConfirm((current)=>({
424
+ ...current,
425
+ open
426
+ })),
427
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_alert_dialog_cjs_namespaceObject.AlertDialogContent, {
428
+ onCloseAutoFocus: (event)=>{
429
+ event.preventDefault();
430
+ restoreFocus();
431
+ },
432
+ children: [
433
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_alert_dialog_cjs_namespaceObject.AlertDialogHeader, {
434
+ children: [
435
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_dialog_cjs_namespaceObject.AlertDialogTitle, {
436
+ children: 'expression' === confirm.target ? text.switchToExpressionTitle : text.switchToConditionsTitle
437
+ }),
438
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_dialog_cjs_namespaceObject.AlertDialogDescription, {
439
+ children: 'preserved' === rule.mode ? text.switchFromPreservedDescription : 'expression' === confirm.target ? text.switchToExpressionDescription : text.switchToConditionsDescription
440
+ })
441
+ ]
442
+ }),
443
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_alert_dialog_cjs_namespaceObject.AlertDialogFooter, {
444
+ children: [
445
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_dialog_cjs_namespaceObject.AlertDialogCancel, {
446
+ children: text.cancel
447
+ }),
448
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_dialog_cjs_namespaceObject.AlertDialogAction, {
449
+ className: (0, external_button_cjs_namespaceObject.buttonVariants)({
450
+ variant: 'destructive'
451
+ }),
452
+ disabled: disabled,
453
+ onClick: confirmSwitch,
454
+ children: text.switchConfirm
455
+ })
456
+ ]
457
+ })
458
+ ]
459
+ })
460
+ })
461
+ ]
462
+ });
463
+ });
464
+ exports.RuleCard = __webpack_exports__.RuleCard;
465
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
466
+ "RuleCard"
467
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
468
+ Object.defineProperty(exports, '__esModule', {
469
+ value: true
470
+ });
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ import { type Rule } from './model';
3
+ /**
4
+ * One rule: its outcome, then the conditions or the expression that decide when it applies.
5
+ * Memoised, so typing in one rule leaves the others alone.
6
+ */
7
+ export declare const RuleCard: React.NamedExoticComponent<{
8
+ rule: Rule;
9
+ /** 1-based, for names. */
10
+ index: number;
11
+ /** 0-based, for focus after a delete. */
12
+ position: number;
13
+ onDelete: (id: string, position: number) => void;
14
+ }>;