@uipath/apollo-wind 2.93.0 → 2.94.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.
Files changed (132) 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/command.cjs +1 -1
  27. package/dist/components/ui/command.js +1 -1
  28. package/dist/components/ui/conditions-editor/condition-row.cjs +458 -0
  29. package/dist/components/ui/conditions-editor/condition-row.d.ts +23 -0
  30. package/dist/components/ui/conditions-editor/condition-row.js +421 -0
  31. package/dist/components/ui/conditions-editor/conditions-editor.cjs +363 -0
  32. package/dist/components/ui/conditions-editor/conditions-editor.d.ts +67 -0
  33. package/dist/components/ui/conditions-editor/conditions-editor.js +329 -0
  34. package/dist/components/ui/conditions-editor/context.cjs +45 -0
  35. package/dist/components/ui/conditions-editor/context.d.ts +54 -0
  36. package/dist/components/ui/conditions-editor/context.js +8 -0
  37. package/dist/components/ui/conditions-editor/index.cjs +55 -0
  38. package/dist/components/ui/conditions-editor/index.d.ts +6 -0
  39. package/dist/components/ui/conditions-editor/index.js +6 -0
  40. package/dist/components/ui/conditions-editor/model.cjs +126 -0
  41. package/dist/components/ui/conditions-editor/model.d.ts +39 -0
  42. package/dist/components/ui/conditions-editor/model.js +71 -0
  43. package/dist/components/ui/conditions-editor/status.cjs +198 -0
  44. package/dist/components/ui/conditions-editor/status.d.ts +44 -0
  45. package/dist/components/ui/conditions-editor/status.js +131 -0
  46. package/dist/components/ui/conditions-editor/strings.cjs +86 -0
  47. package/dist/components/ui/conditions-editor/strings.d.ts +62 -0
  48. package/dist/components/ui/conditions-editor/strings.js +52 -0
  49. package/dist/components/ui/conditions-editor/vocabulary.cjs +163 -0
  50. package/dist/components/ui/conditions-editor/vocabulary.d.ts +51 -0
  51. package/dist/components/ui/conditions-editor/vocabulary.js +129 -0
  52. package/dist/components/ui/context-menu.cjs +1 -1
  53. package/dist/components/ui/context-menu.js +1 -1
  54. package/dist/components/ui/dropdown-menu.cjs +1 -1
  55. package/dist/components/ui/dropdown-menu.js +1 -1
  56. package/dist/components/ui/field-actions/index.cjs +9 -2
  57. package/dist/components/ui/field-actions/index.d.ts +1 -0
  58. package/dist/components/ui/field-actions/index.js +2 -1
  59. package/dist/components/ui/field-actions/insert-variable-action.cjs +3 -1
  60. package/dist/components/ui/field-actions/insert-variable-action.d.ts +4 -1
  61. package/dist/components/ui/field-actions/insert-variable-action.js +3 -1
  62. package/dist/components/ui/field-actions/rules-action.cjs +244 -0
  63. package/dist/components/ui/field-actions/rules-action.d.ts +42 -0
  64. package/dist/components/ui/field-actions/rules-action.js +207 -0
  65. package/dist/components/ui/index.cjs +285 -246
  66. package/dist/components/ui/index.d.ts +3 -0
  67. package/dist/components/ui/index.js +3 -0
  68. package/dist/components/ui/quick-form-field/components/field-header.cjs +137 -167
  69. package/dist/components/ui/quick-form-field/components/field-header.d.ts +1 -1
  70. package/dist/components/ui/quick-form-field/components/field-header.js +138 -168
  71. package/dist/components/ui/quick-form-field/components/header-actions.cjs +187 -0
  72. package/dist/components/ui/quick-form-field/components/header-actions.d.ts +59 -0
  73. package/dist/components/ui/quick-form-field/components/header-actions.js +138 -0
  74. package/dist/components/ui/quick-form-field/components/header-context.cjs +59 -0
  75. package/dist/components/ui/quick-form-field/components/header-context.d.ts +33 -0
  76. package/dist/components/ui/quick-form-field/components/header-context.js +16 -0
  77. package/dist/components/ui/quick-form-field/index.cjs +18 -4
  78. package/dist/components/ui/quick-form-field/index.d.ts +2 -0
  79. package/dist/components/ui/quick-form-field/index.js +3 -1
  80. package/dist/components/ui/quick-form-field/quick-form-field.cjs +1 -1
  81. package/dist/components/ui/quick-form-field/quick-form-field.d.ts +6 -6
  82. package/dist/components/ui/quick-form-field/quick-form-field.js +1 -1
  83. package/dist/components/ui/quick-form-field/types.d.ts +42 -11
  84. package/dist/components/ui/row-groups/add-row-button.cjs +54 -0
  85. package/dist/components/ui/row-groups/add-row-button.d.ts +10 -0
  86. package/dist/components/ui/row-groups/add-row-button.js +20 -0
  87. package/dist/components/ui/row-groups/after-press.cjs +73 -0
  88. package/dist/components/ui/row-groups/after-press.d.ts +7 -0
  89. package/dist/components/ui/row-groups/after-press.js +36 -0
  90. package/dist/components/ui/row-groups/collapsible-row-group.cjs +83 -0
  91. package/dist/components/ui/row-groups/collapsible-row-group.d.ts +13 -0
  92. package/dist/components/ui/row-groups/collapsible-row-group.js +49 -0
  93. package/dist/components/ui/row-groups/empty-rows.cjs +42 -0
  94. package/dist/components/ui/row-groups/empty-rows.d.ts +7 -0
  95. package/dist/components/ui/row-groups/empty-rows.js +8 -0
  96. package/dist/components/ui/row-groups/group-mode-toggle.cjs +80 -0
  97. package/dist/components/ui/row-groups/group-mode-toggle.d.ts +26 -0
  98. package/dist/components/ui/row-groups/group-mode-toggle.js +40 -0
  99. package/dist/components/ui/row-groups/index.cjs +62 -0
  100. package/dist/components/ui/row-groups/index.d.ts +6 -0
  101. package/dist/components/ui/row-groups/index.js +7 -0
  102. package/dist/components/ui/row-groups/row-delete-button.cjs +54 -0
  103. package/dist/components/ui/row-groups/row-delete-button.d.ts +18 -0
  104. package/dist/components/ui/row-groups/row-delete-button.js +20 -0
  105. package/dist/components/ui/row-groups/use-row-focus.cjs +82 -0
  106. package/dist/components/ui/row-groups/use-row-focus.d.ts +17 -0
  107. package/dist/components/ui/row-groups/use-row-focus.js +48 -0
  108. package/dist/components/ui/rules-editor/context.cjs +45 -0
  109. package/dist/components/ui/rules-editor/context.d.ts +52 -0
  110. package/dist/components/ui/rules-editor/context.js +8 -0
  111. package/dist/components/ui/rules-editor/index.cjs +56 -0
  112. package/dist/components/ui/rules-editor/index.d.ts +4 -0
  113. package/dist/components/ui/rules-editor/index.js +4 -0
  114. package/dist/components/ui/rules-editor/model.cjs +205 -0
  115. package/dist/components/ui/rules-editor/model.d.ts +128 -0
  116. package/dist/components/ui/rules-editor/model.js +144 -0
  117. package/dist/components/ui/rules-editor/rule-card.cjs +470 -0
  118. package/dist/components/ui/rules-editor/rule-card.d.ts +14 -0
  119. package/dist/components/ui/rules-editor/rule-card.js +436 -0
  120. package/dist/components/ui/rules-editor/rules-editor.cjs +160 -0
  121. package/dist/components/ui/rules-editor/rules-editor.d.ts +66 -0
  122. package/dist/components/ui/rules-editor/rules-editor.js +126 -0
  123. package/dist/components/ui/rules-editor/strings.cjs +68 -0
  124. package/dist/components/ui/rules-editor/strings.d.ts +56 -0
  125. package/dist/components/ui/rules-editor/strings.js +34 -0
  126. package/dist/components/ui/select.cjs +1 -1
  127. package/dist/components/ui/select.js +1 -1
  128. package/dist/index.cjs +129 -8
  129. package/dist/index.d.ts +17 -4
  130. package/dist/index.js +10 -3
  131. package/dist/styles.css +97 -24
  132. package/package.json +2 -2
@@ -0,0 +1,329 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { MoreVertical, Trash2 } from "lucide-react";
3
+ import { Fragment, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
4
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "../alert-dialog.js";
5
+ import { Button, buttonVariants } from "../button.js";
6
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../dropdown-menu.js";
7
+ import { FormFieldError } from "../form-field.js";
8
+ import { AddRowButton, CollapsibleRowGroup, EmptyRows, GroupModeToggle, useRowFocus } from "../row-groups/index.js";
9
+ import { usePressTracking } from "../row-groups/after-press.js";
10
+ import { cn } from "../../../lib/index.js";
11
+ import { ConditionRow, ConditionSeparator } from "./condition-row.js";
12
+ import { ConditionsEditorContext, useConditionsEditor } from "./context.js";
13
+ import { collectIds, countConditions, createCondition, createConditionGroup, numberConditions, numberGroups, removeNode, updateNode } from "./model.js";
14
+ import { defaultValueModes, describeGroup, hasShownProblems } from "./status.js";
15
+ import { DEFAULT_CONDITIONS_EDITOR_STRINGS } from "./strings.js";
16
+ import { DEFAULT_CONDITION_OPERATORS } from "./vocabulary.js";
17
+ function ConditionsEditor({ value, onChange, label, fields, operators = DEFAULT_CONDITION_OPERATORS, valueModes, variables, renderValue, valueWarning, maxDepth = 1, showMatchMode = true, container = 'card', defaultOpen, showSummary = false, forceErrors = false, defaultTouched, disabled = false, className, strings, valueModeStrings, multiSelectStrings }) {
18
+ usePressTracking();
19
+ const [touched, setTouched] = useState(()=>new Set(defaultTouched));
20
+ const markTouched = useCallback((id)=>setTouched((current)=>new Set(current).add(id)), []);
21
+ useEffect(()=>{
22
+ setTouched((current)=>{
23
+ const ids = collectIds(value);
24
+ const kept = [
25
+ ...current
26
+ ].filter((id)=>ids.has(id));
27
+ return kept.length === current.size ? current : new Set(kept);
28
+ });
29
+ }, [
30
+ value
31
+ ]);
32
+ const latest = useRef({
33
+ value,
34
+ onChange
35
+ });
36
+ latest.current = {
37
+ value,
38
+ onChange
39
+ };
40
+ const actions = useMemo(()=>{
41
+ const apply = (next)=>latest.current.onChange(next(latest.current.value));
42
+ return {
43
+ updateCondition: (id, patch)=>apply((root)=>updateNode(root, id, (node)=>({
44
+ ...node,
45
+ ...patch
46
+ }))),
47
+ setGroupMode: (id, mode)=>apply((root)=>updateNode(root, id, (node)=>({
48
+ ...node,
49
+ mode
50
+ }))),
51
+ addChild: (groupId, child)=>apply((root)=>updateNode(root, groupId, (node)=>({
52
+ ...node,
53
+ children: [
54
+ ...node.children,
55
+ child
56
+ ]
57
+ }))),
58
+ removeChild: (id)=>apply((root)=>removeNode(root, id))
59
+ };
60
+ }, []);
61
+ const text = useMemo(()=>({
62
+ ...DEFAULT_CONDITIONS_EDITOR_STRINGS,
63
+ ...strings
64
+ }), [
65
+ strings
66
+ ]);
67
+ const modes = valueModes ?? defaultValueModes(variables);
68
+ const editor = useMemo(()=>({
69
+ fields,
70
+ operators,
71
+ valueModes: modes,
72
+ variables,
73
+ renderValue,
74
+ valueWarning,
75
+ strings: text,
76
+ valueModeStrings,
77
+ multiSelectStrings,
78
+ disabled,
79
+ forceErrors,
80
+ touched,
81
+ markTouched,
82
+ ...actions
83
+ }), [
84
+ fields,
85
+ operators,
86
+ modes,
87
+ variables,
88
+ renderValue,
89
+ valueWarning,
90
+ text,
91
+ valueModeStrings,
92
+ multiSelectStrings,
93
+ disabled,
94
+ forceErrors,
95
+ touched,
96
+ markTouched,
97
+ actions
98
+ ]);
99
+ const matchModes = useMemo(()=>[
100
+ {
101
+ value: 'all',
102
+ label: text.matchAll
103
+ },
104
+ {
105
+ value: 'any',
106
+ label: text.matchAny
107
+ }
108
+ ], [
109
+ text
110
+ ]);
111
+ const summary = showSummary || 'collapsible' === container ? describeGroup(value, editor, text) : '';
112
+ const groupError = hasShownProblems(value, editor, (id)=>forceErrors || touched.has(id)) ? text.incomplete : void 0;
113
+ const groupErrorId = useId();
114
+ const body = /*#__PURE__*/ jsx(GroupBody, {
115
+ node: value,
116
+ depth: 0,
117
+ maxDepth: maxDepth,
118
+ showMatchMode: showMatchMode,
119
+ matchModes: matchModes,
120
+ groupLabel: label,
121
+ conditionNumbers: numberConditions(value),
122
+ groupNumbers: numberGroups(value),
123
+ describedBy: groupError && 'collapsible' !== container ? groupErrorId : void 0,
124
+ footer: showSummary && summary ? /*#__PURE__*/ jsxs("p", {
125
+ className: "rounded-md bg-muted/50 px-3 py-2 text-xs leading-5 text-muted-foreground",
126
+ children: [
127
+ /*#__PURE__*/ jsxs("span", {
128
+ className: "font-medium text-foreground",
129
+ children: [
130
+ text.summaryLabel,
131
+ " "
132
+ ]
133
+ }),
134
+ summary
135
+ ]
136
+ }) : null
137
+ });
138
+ return /*#__PURE__*/ jsx(ConditionsEditorContext.Provider, {
139
+ value: editor,
140
+ children: 'collapsible' === container ? /*#__PURE__*/ jsx("div", {
141
+ className: className,
142
+ children: /*#__PURE__*/ jsx(CollapsibleRowGroup, {
143
+ summary: text.count(countConditions(value)),
144
+ detail: summary,
145
+ error: groupError,
146
+ defaultOpen: defaultOpen,
147
+ children: body
148
+ })
149
+ }) : /*#__PURE__*/ jsxs("div", {
150
+ className: cn('flex min-w-0 flex-col', className),
151
+ children: [
152
+ /*#__PURE__*/ jsx("div", {
153
+ className: cn('card' === container && 'rounded-lg border border-border bg-card p-3', 'card' === container && groupError && 'border-error'),
154
+ children: body
155
+ }),
156
+ groupError && /*#__PURE__*/ jsx(FormFieldError, {
157
+ id: groupErrorId,
158
+ children: groupError
159
+ })
160
+ ]
161
+ })
162
+ });
163
+ }
164
+ function GroupBody({ node, depth, maxDepth, showMatchMode, matchModes, groupLabel, conditionNumbers, groupNumbers, describedBy, onDeleteGroup, footer }) {
165
+ const { strings, disabled, setGroupMode, addChild, removeChild } = useConditionsEditor();
166
+ const focus = useRowFocus();
167
+ const [confirmOpen, setConfirmOpen] = useState(false);
168
+ const actionsRef = useRef(null);
169
+ const nested = depth > 0;
170
+ const matchModeShown = nested || showMatchMode && node.children.length > 1;
171
+ const add = (child)=>{
172
+ focus.afterAdd();
173
+ addChild(node.id, child);
174
+ };
175
+ const { afterDelete } = focus;
176
+ const deleteChild = useCallback((id, position)=>{
177
+ afterDelete(position);
178
+ removeChild(id);
179
+ }, [
180
+ afterDelete,
181
+ removeChild
182
+ ]);
183
+ return /*#__PURE__*/ jsxs("fieldset", {
184
+ "aria-label": groupLabel,
185
+ "aria-describedby": describedBy,
186
+ "data-row": nested ? '' : void 0,
187
+ className: cn('m-0 flex min-w-0 flex-col gap-3 border-0 p-0', nested && 'border-l-2 border-solid border-border pl-3'),
188
+ children: [
189
+ matchModeShown && /*#__PURE__*/ jsxs("div", {
190
+ className: "flex items-center gap-2",
191
+ children: [
192
+ /*#__PURE__*/ jsx(GroupModeToggle, {
193
+ modes: matchModes,
194
+ value: node.mode,
195
+ disabled: disabled,
196
+ strings: {
197
+ label: strings.groupMatchMode(groupLabel)
198
+ },
199
+ onValueChange: (mode)=>setGroupMode(node.id, mode)
200
+ }),
201
+ nested && /*#__PURE__*/ jsxs(DropdownMenu, {
202
+ children: [
203
+ /*#__PURE__*/ jsx(DropdownMenuTrigger, {
204
+ asChild: true,
205
+ children: /*#__PURE__*/ jsx(Button, {
206
+ ref: actionsRef,
207
+ type: "button",
208
+ variant: "ghost",
209
+ size: "xs",
210
+ icon: true,
211
+ disabled: disabled,
212
+ "data-row-delete": "",
213
+ "aria-label": strings.groupActions(groupLabel),
214
+ className: "ml-auto text-muted-foreground hover:text-foreground",
215
+ children: /*#__PURE__*/ jsx(MoreVertical, {})
216
+ })
217
+ }),
218
+ /*#__PURE__*/ jsx(DropdownMenuContent, {
219
+ align: "end",
220
+ className: "w-44",
221
+ children: /*#__PURE__*/ jsxs(DropdownMenuItem, {
222
+ className: "text-error focus:text-error",
223
+ onSelect: ()=>{
224
+ if (node.children.length > 0) setConfirmOpen(true);
225
+ else onDeleteGroup?.();
226
+ },
227
+ children: [
228
+ /*#__PURE__*/ jsx(Trash2, {}),
229
+ " ",
230
+ strings.deleteGroup
231
+ ]
232
+ })
233
+ })
234
+ ]
235
+ })
236
+ ]
237
+ }),
238
+ /*#__PURE__*/ jsx("div", {
239
+ className: "@container",
240
+ children: /*#__PURE__*/ jsx("div", {
241
+ ref: focus.listRef,
242
+ className: "flex flex-col gap-2 @lg:gap-3",
243
+ children: 0 === node.children.length ? (nested ? strings.emptyGroup : strings.empty) && /*#__PURE__*/ jsx(EmptyRows, {
244
+ children: nested ? strings.emptyGroup : strings.empty
245
+ }) : node.children.map((child, position)=>'group' === child.kind ? /*#__PURE__*/ jsx(GroupBody, {
246
+ node: child,
247
+ depth: depth + 1,
248
+ maxDepth: maxDepth,
249
+ showMatchMode: showMatchMode,
250
+ matchModes: matchModes,
251
+ groupLabel: strings.groupName(groupNumbers.get(child.id) ?? position + 1),
252
+ conditionNumbers: conditionNumbers,
253
+ groupNumbers: groupNumbers,
254
+ onDeleteGroup: ()=>deleteChild(child.id, position)
255
+ }, child.id) : /*#__PURE__*/ jsxs(Fragment, {
256
+ children: [
257
+ node.children[position - 1]?.kind === 'condition' && /*#__PURE__*/ jsx(ConditionSeparator, {}),
258
+ /*#__PURE__*/ jsx(ConditionRow, {
259
+ index: conditionNumbers.get(child.id) ?? position + 1,
260
+ position: position,
261
+ condition: child,
262
+ onDelete: deleteChild
263
+ })
264
+ ]
265
+ }, child.id))
266
+ })
267
+ }),
268
+ /*#__PURE__*/ jsxs("div", {
269
+ className: "flex flex-wrap items-center gap-4",
270
+ children: [
271
+ /*#__PURE__*/ jsx(AddRowButton, {
272
+ ref: focus.addRef,
273
+ disabled: disabled,
274
+ onClick: ()=>add(createCondition()),
275
+ children: strings.addCondition
276
+ }),
277
+ depth < maxDepth && /*#__PURE__*/ jsx(AddRowButton, {
278
+ disabled: disabled,
279
+ onClick: ()=>add(createConditionGroup('all', [
280
+ createCondition()
281
+ ])),
282
+ children: strings.addGroup
283
+ })
284
+ ]
285
+ }),
286
+ footer,
287
+ nested && /*#__PURE__*/ jsx(AlertDialog, {
288
+ open: confirmOpen,
289
+ onOpenChange: setConfirmOpen,
290
+ children: /*#__PURE__*/ jsxs(AlertDialogContent, {
291
+ onCloseAutoFocus: (event)=>{
292
+ event.preventDefault();
293
+ if (actionsRef.current?.isConnected) actionsRef.current.focus();
294
+ },
295
+ children: [
296
+ /*#__PURE__*/ jsxs(AlertDialogHeader, {
297
+ children: [
298
+ /*#__PURE__*/ jsx(AlertDialogTitle, {
299
+ children: strings.deleteGroupTitle
300
+ }),
301
+ /*#__PURE__*/ jsx(AlertDialogDescription, {
302
+ children: strings.deleteGroupDescription(countConditions(node))
303
+ })
304
+ ]
305
+ }),
306
+ /*#__PURE__*/ jsxs(AlertDialogFooter, {
307
+ children: [
308
+ /*#__PURE__*/ jsx(AlertDialogCancel, {
309
+ children: strings.cancel
310
+ }),
311
+ /*#__PURE__*/ jsx(AlertDialogAction, {
312
+ className: buttonVariants({
313
+ variant: 'destructive'
314
+ }),
315
+ disabled: disabled,
316
+ onClick: ()=>{
317
+ if (!disabled) onDeleteGroup?.();
318
+ },
319
+ children: strings.deleteGroup
320
+ })
321
+ ]
322
+ })
323
+ ]
324
+ })
325
+ })
326
+ ]
327
+ });
328
+ }
329
+ export { ConditionsEditor };
@@ -0,0 +1,45 @@
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
+ ConditionsEditorContext: ()=>ConditionsEditorContext,
28
+ useConditionsEditor: ()=>useConditionsEditor
29
+ });
30
+ const external_react_namespaceObject = require("react");
31
+ const ConditionsEditorContext = external_react_namespaceObject.createContext(null);
32
+ function useConditionsEditor() {
33
+ const context = external_react_namespaceObject.useContext(ConditionsEditorContext);
34
+ if (!context) throw new Error('ConditionRow must be rendered inside ConditionsEditor.');
35
+ return context;
36
+ }
37
+ exports.ConditionsEditorContext = __webpack_exports__.ConditionsEditorContext;
38
+ exports.useConditionsEditor = __webpack_exports__.useConditionsEditor;
39
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
40
+ "ConditionsEditorContext",
41
+ "useConditionsEditor"
42
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
43
+ Object.defineProperty(exports, '__esModule', {
44
+ value: true
45
+ });
@@ -0,0 +1,54 @@
1
+ import * as React from 'react';
2
+ import type { ValueModeStrings } from '../field-addons';
3
+ import type { MultiSelectStrings } from '../multi-select';
4
+ import type { MatchMode } from '../row-groups';
5
+ import type { VariablePickerItem } from '../variable-picker';
6
+ import type { Condition, ConditionNode, ConditionValueMode } from './model';
7
+ import type { ConditionVocabulary } from './status';
8
+ import type { ConditionsEditorStrings } from './strings';
9
+ import type { ConditionField, ConditionOperator } from './vocabulary';
10
+ export interface ConditionValueRenderProps {
11
+ condition: Condition;
12
+ field?: ConditionField;
13
+ operator?: ConditionOperator;
14
+ mode: ConditionValueMode;
15
+ /** Ids of the row name and the visible Value label, for `aria-labelledby`. */
16
+ labelledBy: string;
17
+ invalid: boolean;
18
+ /** The row message's id, for `aria-errormessage`, while it shows. */
19
+ errorId?: string;
20
+ /** What describes the value, such as its hint and the row message, for `aria-describedby`. */
21
+ describedBy?: string;
22
+ disabled: boolean;
23
+ onChange: (patch: Pick<Condition, 'value' | 'values'>) => void;
24
+ }
25
+ /**
26
+ * Replaces a value's control, such as with the host's own expression editor. It renders inside the
27
+ * value's `InputGroup`, beside the mode menu, so return an input-group control. Return `undefined`
28
+ * to keep the built-in control; `null` renders no control.
29
+ *
30
+ * It is called during render, not mounted as a component, so it cannot call hooks itself. Return
31
+ * a component that does.
32
+ */
33
+ export type RenderConditionValue = (props: ConditionValueRenderProps) => React.ReactNode | undefined;
34
+ export type ConditionPatch = Partial<Omit<Condition, 'kind' | 'id'>>;
35
+ export interface ConditionsEditorContextValue extends ConditionVocabulary {
36
+ strings: ConditionsEditorStrings;
37
+ valueModeStrings?: Partial<ValueModeStrings>;
38
+ multiSelectStrings?: Partial<MultiSelectStrings>;
39
+ variables?: VariablePickerItem[];
40
+ renderValue?: RenderConditionValue;
41
+ valueWarning?: (condition: Condition) => string | undefined;
42
+ disabled: boolean;
43
+ forceErrors: boolean;
44
+ /** Rows focus has left. Their messages show from then on. */
45
+ touched: ReadonlySet<string>;
46
+ markTouched: (id: string) => void;
47
+ /** Stable across renders, so memoised rows only re-render when their own condition changes. */
48
+ updateCondition: (id: string, patch: ConditionPatch) => void;
49
+ setGroupMode: (id: string, mode: MatchMode) => void;
50
+ addChild: (groupId: string, child: ConditionNode) => void;
51
+ removeChild: (id: string) => void;
52
+ }
53
+ export declare const ConditionsEditorContext: React.Context<ConditionsEditorContextValue | null>;
54
+ export declare function useConditionsEditor(): ConditionsEditorContextValue;
@@ -0,0 +1,8 @@
1
+ import { createContext, useContext } from "react";
2
+ const ConditionsEditorContext = createContext(null);
3
+ function useConditionsEditor() {
4
+ const context = useContext(ConditionsEditorContext);
5
+ if (!context) throw new Error('ConditionRow must be rendered inside ConditionsEditor.');
6
+ return context;
7
+ }
8
+ export { ConditionsEditorContext, useConditionsEditor };
@@ -0,0 +1,55 @@
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
+ ConditionsEditor: ()=>external_conditions_editor_cjs_namespaceObject.ConditionsEditor,
28
+ DEFAULT_CONDITIONS_EDITOR_STRINGS: ()=>external_strings_cjs_namespaceObject.DEFAULT_CONDITIONS_EDITOR_STRINGS,
29
+ createCondition: ()=>external_model_cjs_namespaceObject.createCondition,
30
+ isConditionComplete: ()=>external_status_cjs_namespaceObject.isConditionComplete,
31
+ DEFAULT_CONDITION_OPERATORS: ()=>external_vocabulary_cjs_namespaceObject.DEFAULT_CONDITION_OPERATORS,
32
+ createConditionGroup: ()=>external_model_cjs_namespaceObject.createConditionGroup
33
+ });
34
+ const external_conditions_editor_cjs_namespaceObject = require("./conditions-editor.cjs");
35
+ const external_model_cjs_namespaceObject = require("./model.cjs");
36
+ const external_status_cjs_namespaceObject = require("./status.cjs");
37
+ const external_strings_cjs_namespaceObject = require("./strings.cjs");
38
+ const external_vocabulary_cjs_namespaceObject = require("./vocabulary.cjs");
39
+ exports.ConditionsEditor = __webpack_exports__.ConditionsEditor;
40
+ exports.DEFAULT_CONDITIONS_EDITOR_STRINGS = __webpack_exports__.DEFAULT_CONDITIONS_EDITOR_STRINGS;
41
+ exports.DEFAULT_CONDITION_OPERATORS = __webpack_exports__.DEFAULT_CONDITION_OPERATORS;
42
+ exports.createCondition = __webpack_exports__.createCondition;
43
+ exports.createConditionGroup = __webpack_exports__.createConditionGroup;
44
+ exports.isConditionComplete = __webpack_exports__.isConditionComplete;
45
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
46
+ "ConditionsEditor",
47
+ "DEFAULT_CONDITIONS_EDITOR_STRINGS",
48
+ "DEFAULT_CONDITION_OPERATORS",
49
+ "createCondition",
50
+ "createConditionGroup",
51
+ "isConditionComplete"
52
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
53
+ Object.defineProperty(exports, '__esModule', {
54
+ value: true
55
+ });
@@ -0,0 +1,6 @@
1
+ export { ConditionsEditor, type ConditionsEditorProps, } from './conditions-editor';
2
+ export type { ConditionValueRenderProps, RenderConditionValue } from './context';
3
+ export { type Condition, type ConditionGroup, type ConditionNode, type ConditionValueMode, createCondition, createConditionGroup, } from './model';
4
+ export { type ConditionVocabulary, isConditionComplete } from './status';
5
+ export { type ConditionsEditorStrings, DEFAULT_CONDITIONS_EDITOR_STRINGS } from './strings';
6
+ export { type ConditionField, type ConditionFieldOption, type ConditionFieldType, type ConditionOperator, type ConditionOperators, type ConditionValueContext, DEFAULT_CONDITION_OPERATORS, } from './vocabulary';
@@ -0,0 +1,6 @@
1
+ import { ConditionsEditor } from "./conditions-editor.js";
2
+ import { createCondition, createConditionGroup } from "./model.js";
3
+ import { isConditionComplete } from "./status.js";
4
+ import { DEFAULT_CONDITIONS_EDITOR_STRINGS } from "./strings.js";
5
+ import { DEFAULT_CONDITION_OPERATORS } from "./vocabulary.js";
6
+ export { ConditionsEditor, DEFAULT_CONDITIONS_EDITOR_STRINGS, DEFAULT_CONDITION_OPERATORS, createCondition, createConditionGroup, isConditionComplete };
@@ -0,0 +1,126 @@
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
+ collectIds: ()=>collectIds,
28
+ countConditions: ()=>countConditions,
29
+ createCondition: ()=>createCondition,
30
+ createConditionGroup: ()=>createConditionGroup,
31
+ numberConditions: ()=>numberConditions,
32
+ numberGroups: ()=>numberGroups,
33
+ removeNode: ()=>removeNode,
34
+ updateNode: ()=>updateNode
35
+ });
36
+ function newId(prefix) {
37
+ return `${prefix}-${crypto.randomUUID()}`;
38
+ }
39
+ function createCondition(init = {}) {
40
+ return {
41
+ kind: 'condition',
42
+ id: init.id ?? newId('condition'),
43
+ ...init
44
+ };
45
+ }
46
+ function createConditionGroup(mode = 'all', children = [], id = newId('group')) {
47
+ return {
48
+ kind: 'group',
49
+ id,
50
+ mode,
51
+ children
52
+ };
53
+ }
54
+ function updateNode(root, id, update) {
55
+ if (root.id === id) return update(root);
56
+ let changed = false;
57
+ const children = root.children.map((child)=>{
58
+ const next = child.id === id ? update(child) : 'group' === child.kind ? updateNode(child, id, update) : child;
59
+ if (next !== child) changed = true;
60
+ return next;
61
+ });
62
+ return changed ? {
63
+ ...root,
64
+ children
65
+ } : root;
66
+ }
67
+ function removeNode(root, id) {
68
+ let changed = false;
69
+ const children = [];
70
+ for (const child of root.children){
71
+ if (child.id === id) {
72
+ changed = true;
73
+ continue;
74
+ }
75
+ const next = 'group' === child.kind ? removeNode(child, id) : child;
76
+ if (next !== child) changed = true;
77
+ children.push(next);
78
+ }
79
+ return changed ? {
80
+ ...root,
81
+ children
82
+ } : root;
83
+ }
84
+ function countConditions(node) {
85
+ return node.children.reduce((total, child)=>total + ('condition' === child.kind ? 1 : countConditions(child)), 0);
86
+ }
87
+ function numberConditions(node, map = new Map()) {
88
+ for (const child of node.children)if ('condition' === child.kind) map.set(child.id, map.size + 1);
89
+ else numberConditions(child, map);
90
+ return map;
91
+ }
92
+ function numberGroups(node, map = new Map()) {
93
+ for (const child of node.children)if ('group' === child.kind) {
94
+ map.set(child.id, map.size + 1);
95
+ numberGroups(child, map);
96
+ }
97
+ return map;
98
+ }
99
+ function collectIds(node, ids = new Set()) {
100
+ for (const child of node.children){
101
+ ids.add(child.id);
102
+ if ('group' === child.kind) collectIds(child, ids);
103
+ }
104
+ return ids;
105
+ }
106
+ exports.collectIds = __webpack_exports__.collectIds;
107
+ exports.countConditions = __webpack_exports__.countConditions;
108
+ exports.createCondition = __webpack_exports__.createCondition;
109
+ exports.createConditionGroup = __webpack_exports__.createConditionGroup;
110
+ exports.numberConditions = __webpack_exports__.numberConditions;
111
+ exports.numberGroups = __webpack_exports__.numberGroups;
112
+ exports.removeNode = __webpack_exports__.removeNode;
113
+ exports.updateNode = __webpack_exports__.updateNode;
114
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
115
+ "collectIds",
116
+ "countConditions",
117
+ "createCondition",
118
+ "createConditionGroup",
119
+ "numberConditions",
120
+ "numberGroups",
121
+ "removeNode",
122
+ "updateNode"
123
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
124
+ Object.defineProperty(exports, '__esModule', {
125
+ value: true
126
+ });
@@ -0,0 +1,39 @@
1
+ import type { ValueMode } from '../field-addons';
2
+ import type { MatchMode } from '../row-groups';
3
+ /** The value modes a condition can offer. A prompt is not a comparable value. */
4
+ export type ConditionValueMode = Exclude<ValueMode, 'prompt'>;
5
+ /** One field / operator / value row. Every part is optional while the row is being filled in. */
6
+ export interface Condition {
7
+ kind: 'condition';
8
+ id: string;
9
+ /** The compared field's `value`. */
10
+ field?: string;
11
+ /** The operator's `value`. */
12
+ operator?: string;
13
+ /** Text, a number as typed, an ISO date, an option value, an expression, or a variable reference. */
14
+ value?: string;
15
+ /** The chosen option values, for an operator that takes several. */
16
+ values?: string[];
17
+ /** Omitted means Fixed value. */
18
+ valueMode?: ConditionValueMode;
19
+ }
20
+ export interface ConditionGroup {
21
+ kind: 'group';
22
+ id: string;
23
+ mode: MatchMode;
24
+ children: ConditionNode[];
25
+ }
26
+ export type ConditionNode = Condition | ConditionGroup;
27
+ export declare function createCondition(init?: Omit<Condition, 'kind' | 'id'> & {
28
+ id?: string;
29
+ }): Condition;
30
+ export declare function createConditionGroup(mode?: MatchMode, children?: ConditionNode[], id?: string): ConditionGroup;
31
+ /** Replaces the node with `id`. Groups off its path keep their identity, so memoised rows stay put. */
32
+ export declare function updateNode(root: ConditionGroup, id: string, update: (node: ConditionNode) => ConditionNode): ConditionGroup;
33
+ export declare function removeNode(root: ConditionGroup, id: string): ConditionGroup;
34
+ export declare function countConditions(node: ConditionGroup): number;
35
+ /** Each condition's 1-based position across the tree, in reading order, so names match the screen. */
36
+ export declare function numberConditions(node: ConditionGroup, map?: Map<string, number>): Map<string, number>;
37
+ /** Each nested group's 1-based position across the tree, in reading order, so their names differ. */
38
+ export declare function numberGroups(node: ConditionGroup, map?: Map<string, number>): Map<string, number>;
39
+ export declare function collectIds(node: ConditionGroup, ids?: Set<string>): Set<string>;