@uipath/apollo-wind 2.92.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 (130) 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/data-table.cjs +493 -104
  51. package/dist/components/ui/data-table.d.ts +88 -5
  52. package/dist/components/ui/data-table.js +491 -105
  53. package/dist/components/ui/editable-cell.cjs +91 -27
  54. package/dist/components/ui/editable-cell.d.ts +14 -1
  55. package/dist/components/ui/editable-cell.js +91 -27
  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 +282 -243
  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/index.cjs +132 -8
  127. package/dist/index.d.ts +19 -6
  128. package/dist/index.js +11 -4
  129. package/dist/styles.css +119 -24
  130. package/package.json +2 -2
@@ -39,44 +39,102 @@ const external_calendar_cjs_namespaceObject = require("./calendar.cjs");
39
39
  const external_locale_provider_cjs_namespaceObject = require("./locale-provider.cjs");
40
40
  const external_popover_cjs_namespaceObject = require("./popover.cjs");
41
41
  const external_select_cjs_namespaceObject = require("./select.cjs");
42
- function EditableCell({ cell, onUpdate }) {
42
+ function isEmptyValue(value) {
43
+ return null == value || '' === value;
44
+ }
45
+ function toValidDate(value) {
46
+ if (isEmptyValue(value)) return;
47
+ const dateOnly = 'string' == typeof value ? /^(\d{4})-(\d{2})-(\d{2})$/.exec(value) : null;
48
+ const date = dateOnly ? new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3])) : value instanceof Date ? value : new Date(value);
49
+ return Number.isNaN(date.getTime()) ? void 0 : date;
50
+ }
51
+ function EditableCell({ cell, onUpdate, editLabel, toggleLabel }) {
43
52
  const initialValue = cell.getValue();
44
53
  const meta = cell.column.columnDef.meta;
45
54
  const type = meta?.type ?? 'text';
55
+ const dateLocale = (0, external_locale_provider_cjs_namespaceObject.useDateLocale)();
46
56
  const [isEditing, setIsEditing] = external_react_namespaceObject.useState(false);
47
57
  const [value, setValue] = external_react_namespaceObject.useState(initialValue);
58
+ const [numberDraft, setNumberDraft] = external_react_namespaceObject.useState('');
48
59
  const inputRef = external_react_namespaceObject.useRef(null);
60
+ const displayRef = external_react_namespaceObject.useRef(null);
61
+ const restoreFocusRef = external_react_namespaceObject.useRef(false);
62
+ const finishedRef = external_react_namespaceObject.useRef(false);
49
63
  external_react_namespaceObject.useEffect(()=>{
50
64
  setValue(initialValue);
51
65
  }, [
52
66
  initialValue
53
67
  ]);
54
68
  external_react_namespaceObject.useEffect(()=>{
55
- if (isEditing && inputRef.current) {
56
- inputRef.current.focus();
57
- inputRef.current.select();
69
+ if (isEditing) {
70
+ if (inputRef.current) {
71
+ inputRef.current.focus();
72
+ inputRef.current.select();
73
+ }
74
+ } else if (restoreFocusRef.current) {
75
+ restoreFocusRef.current = false;
76
+ displayRef.current?.focus();
58
77
  }
59
78
  }, [
60
79
  isEditing
61
80
  ]);
62
- const handleSave = external_react_namespaceObject.useCallback(()=>{
63
- if (value !== initialValue) onUpdate(value);
81
+ const startEditing = external_react_namespaceObject.useCallback(()=>{
82
+ finishedRef.current = false;
83
+ if ('number' === type) setNumberDraft(isEmptyValue(value) ? '' : String(value));
84
+ setIsEditing(true);
85
+ }, [
86
+ type,
87
+ value
88
+ ]);
89
+ const finishEditing = external_react_namespaceObject.useCallback((restoreFocus)=>{
90
+ finishedRef.current = true;
91
+ restoreFocusRef.current = restoreFocus;
64
92
  setIsEditing(false);
93
+ }, []);
94
+ const handleSave = external_react_namespaceObject.useCallback((restoreFocus)=>{
95
+ if (finishedRef.current) return;
96
+ if ('number' === type) {
97
+ const trimmed = numberDraft.trim();
98
+ if ('' === trimmed) {
99
+ if (meta?.nullable && !isEmptyValue(initialValue)) {
100
+ setValue(null);
101
+ onUpdate(null);
102
+ }
103
+ } else {
104
+ let next = Number(trimmed);
105
+ if (Number.isFinite(next)) {
106
+ if (meta?.min !== void 0) next = Math.max(meta.min, next);
107
+ if (meta?.max !== void 0) next = Math.min(meta.max, next);
108
+ if (next !== initialValue) {
109
+ setValue(next);
110
+ onUpdate(next);
111
+ }
112
+ }
113
+ }
114
+ } else if (value !== initialValue) onUpdate(value);
115
+ finishEditing(restoreFocus);
65
116
  }, [
117
+ type,
118
+ numberDraft,
119
+ meta?.nullable,
120
+ meta?.min,
121
+ meta?.max,
66
122
  value,
67
123
  initialValue,
68
- onUpdate
124
+ onUpdate,
125
+ finishEditing
69
126
  ]);
70
127
  const handleCancel = external_react_namespaceObject.useCallback(()=>{
71
128
  setValue(initialValue);
72
- setIsEditing(false);
129
+ finishEditing(true);
73
130
  }, [
74
- initialValue
131
+ initialValue,
132
+ finishEditing
75
133
  ]);
76
134
  const handleKeyDown = external_react_namespaceObject.useCallback((e)=>{
77
135
  if ('Enter' === e.key) {
78
136
  e.preventDefault();
79
- handleSave();
137
+ handleSave(true);
80
138
  } else if ('Escape' === e.key) {
81
139
  e.preventDefault();
82
140
  handleCancel();
@@ -94,18 +152,19 @@ function EditableCell({ cell, onUpdate }) {
94
152
  setValue(checked);
95
153
  onUpdate(checked);
96
154
  },
97
- "aria-label": "Toggle"
155
+ "aria-label": toggleLabel ?? 'Toggle'
98
156
  })
99
157
  });
100
158
  const cellContent = isEditing ? renderEditMode() : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
159
+ ref: displayRef,
101
160
  type: "button",
102
161
  "data-slot": "editable-cell",
103
162
  className: (0, index_cjs_namespaceObject.cn)('min-h-[32px] px-2 py-1.5 -mx-2 rounded cursor-pointer w-full text-left', 'hover:bg-muted/50 transition-colors', 'flex items-center bg-transparent border-0'),
104
- onClick: ()=>setIsEditing(true),
105
- "aria-label": `Edit ${cell.column.id}`,
163
+ onClick: startEditing,
164
+ "aria-label": editLabel ?? `Edit ${cell.column.id}`,
106
165
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
107
- className: (0, index_cjs_namespaceObject.cn)('truncate', !value && 'text-muted-foreground'),
108
- children: formatDisplayValue(value, type, meta?.options)
166
+ className: (0, index_cjs_namespaceObject.cn)('truncate', isEmptyValue(value) && 'text-muted-foreground'),
167
+ children: formatDisplayValue(value, type, meta?.options, dateLocale)
109
168
  })
110
169
  });
111
170
  return cellContent;
@@ -117,11 +176,11 @@ function EditableCell({ cell, onUpdate }) {
117
176
  onValueChange: (newValue)=>{
118
177
  setValue(newValue);
119
178
  onUpdate(newValue);
120
- setIsEditing(false);
179
+ finishEditing(true);
121
180
  },
122
181
  open: true,
123
182
  onOpenChange: (open)=>{
124
- if (!open) setIsEditing(false);
183
+ if (!open) finishEditing(true);
125
184
  },
126
185
  children: [
127
186
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
@@ -140,21 +199,21 @@ function EditableCell({ cell, onUpdate }) {
140
199
  });
141
200
  case 'date':
142
201
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(DatePickerCell, {
143
- value: value instanceof Date ? value : value ? new Date(value) : void 0,
202
+ value: toValidDate(value),
144
203
  onValueChange: (date)=>{
145
204
  setValue(date);
146
205
  onUpdate(date);
147
206
  },
148
- onClose: ()=>setIsEditing(false),
207
+ onClose: ()=>finishEditing(true),
149
208
  placeholder: meta?.placeholder ?? 'Pick date'
150
209
  });
151
210
  case 'number':
152
211
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_cjs_namespaceObject.Input, {
153
212
  ref: inputRef,
154
213
  type: "number",
155
- value: value,
156
- onChange: (e)=>setValue(e.target.valueAsNumber),
157
- onBlur: handleSave,
214
+ value: numberDraft,
215
+ onChange: (e)=>setNumberDraft(e.target.value),
216
+ onBlur: ()=>handleSave(false),
158
217
  onKeyDown: handleKeyDown,
159
218
  min: meta?.min,
160
219
  max: meta?.max,
@@ -167,7 +226,7 @@ function EditableCell({ cell, onUpdate }) {
167
226
  type: "text",
168
227
  value: String(value ?? ''),
169
228
  onChange: (e)=>setValue(e.target.value),
170
- onBlur: handleSave,
229
+ onBlur: ()=>handleSave(false),
171
230
  onKeyDown: handleKeyDown,
172
231
  placeholder: meta?.placeholder,
173
232
  className: "h-8 -mx-2 w-full"
@@ -175,8 +234,8 @@ function EditableCell({ cell, onUpdate }) {
175
234
  }
176
235
  }
177
236
  }
178
- function formatDisplayValue(value, type, options) {
179
- if (null == value || '' === value) return '—';
237
+ function formatDisplayValue(value, type, options, locale) {
238
+ if (isEmptyValue(value)) return '—';
180
239
  switch(type){
181
240
  case 'select':
182
241
  {
@@ -184,8 +243,12 @@ function formatDisplayValue(value, type, options) {
184
243
  return option?.label ?? String(value);
185
244
  }
186
245
  case 'date':
187
- if (value instanceof Date) return (0, external_date_fns_namespaceObject.format)(value, 'PP');
188
- return (0, external_date_fns_namespaceObject.format)(new Date(value), 'PP');
246
+ {
247
+ const date = toValidDate(value);
248
+ return date ? (0, external_date_fns_namespaceObject.format)(date, 'PP', {
249
+ locale
250
+ }) : String(value);
251
+ }
189
252
  case 'checkbox':
190
253
  return value ? 'Yes' : 'No';
191
254
  default:
@@ -233,6 +296,7 @@ function DatePickerCell({ value, onValueChange, onClose, placeholder }) {
233
296
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_calendar_cjs_namespaceObject.Calendar, {
234
297
  mode: "single",
235
298
  selected: value,
299
+ defaultMonth: value,
236
300
  onSelect: (date)=>{
237
301
  onValueChange(date);
238
302
  setOpen(false);
@@ -8,14 +8,27 @@ export interface EditableCellMeta {
8
8
  type?: EditableCellType;
9
9
  options?: SelectOption[];
10
10
  placeholder?: string;
11
+ /** Lower bound of a `number` cell. An out-of-range entry is clamped on commit. */
11
12
  min?: number;
13
+ /** Upper bound of a `number` cell. An out-of-range entry is clamped on commit. */
12
14
  max?: number;
15
+ /**
16
+ * Lets a `number` cell be emptied, which commits `null`. Without it, clearing the
17
+ * field and committing leaves the previous value in place.
18
+ */
19
+ nullable?: boolean;
20
+ /** Human-readable column name, used in accessible names and the DataTable column menu. */
21
+ label?: string;
13
22
  }
14
23
  interface EditableCellProps<TData, TValue> {
15
24
  cell: CellContext<TData, TValue>;
16
25
  onUpdate: (value: TValue) => void;
26
+ /** Accessible name of the button that starts editing. Default: `Edit <column id>`. */
27
+ editLabel?: string;
28
+ /** Accessible name of a `checkbox` cell. Default: `Toggle`. */
29
+ toggleLabel?: string;
17
30
  }
18
- export declare function EditableCell<TData, TValue>({ cell, onUpdate }: EditableCellProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
31
+ export declare function EditableCell<TData, TValue>({ cell, onUpdate, editLabel, toggleLabel, }: EditableCellProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
19
32
  export declare function createEditableColumn<TData>(accessorKey: keyof TData & string, header: string, meta?: EditableCellMeta): {
20
33
  accessorKey: keyof TData & string;
21
34
  header: string;
@@ -10,44 +10,102 @@ import { Calendar } from "./calendar.js";
10
10
  import { useDateLocale } from "./locale-provider.js";
11
11
  import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
12
12
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
13
- function EditableCell({ cell, onUpdate }) {
13
+ function isEmptyValue(value) {
14
+ return null == value || '' === value;
15
+ }
16
+ function toValidDate(value) {
17
+ if (isEmptyValue(value)) return;
18
+ const dateOnly = 'string' == typeof value ? /^(\d{4})-(\d{2})-(\d{2})$/.exec(value) : null;
19
+ const date = dateOnly ? new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3])) : value instanceof Date ? value : new Date(value);
20
+ return Number.isNaN(date.getTime()) ? void 0 : date;
21
+ }
22
+ function EditableCell({ cell, onUpdate, editLabel, toggleLabel }) {
14
23
  const initialValue = cell.getValue();
15
24
  const meta = cell.column.columnDef.meta;
16
25
  const type = meta?.type ?? 'text';
26
+ const dateLocale = useDateLocale();
17
27
  const [isEditing, setIsEditing] = useState(false);
18
28
  const [value, setValue] = useState(initialValue);
29
+ const [numberDraft, setNumberDraft] = useState('');
19
30
  const inputRef = useRef(null);
31
+ const displayRef = useRef(null);
32
+ const restoreFocusRef = useRef(false);
33
+ const finishedRef = useRef(false);
20
34
  useEffect(()=>{
21
35
  setValue(initialValue);
22
36
  }, [
23
37
  initialValue
24
38
  ]);
25
39
  useEffect(()=>{
26
- if (isEditing && inputRef.current) {
27
- inputRef.current.focus();
28
- inputRef.current.select();
40
+ if (isEditing) {
41
+ if (inputRef.current) {
42
+ inputRef.current.focus();
43
+ inputRef.current.select();
44
+ }
45
+ } else if (restoreFocusRef.current) {
46
+ restoreFocusRef.current = false;
47
+ displayRef.current?.focus();
29
48
  }
30
49
  }, [
31
50
  isEditing
32
51
  ]);
33
- const handleSave = useCallback(()=>{
34
- if (value !== initialValue) onUpdate(value);
52
+ const startEditing = useCallback(()=>{
53
+ finishedRef.current = false;
54
+ if ('number' === type) setNumberDraft(isEmptyValue(value) ? '' : String(value));
55
+ setIsEditing(true);
56
+ }, [
57
+ type,
58
+ value
59
+ ]);
60
+ const finishEditing = useCallback((restoreFocus)=>{
61
+ finishedRef.current = true;
62
+ restoreFocusRef.current = restoreFocus;
35
63
  setIsEditing(false);
64
+ }, []);
65
+ const handleSave = useCallback((restoreFocus)=>{
66
+ if (finishedRef.current) return;
67
+ if ('number' === type) {
68
+ const trimmed = numberDraft.trim();
69
+ if ('' === trimmed) {
70
+ if (meta?.nullable && !isEmptyValue(initialValue)) {
71
+ setValue(null);
72
+ onUpdate(null);
73
+ }
74
+ } else {
75
+ let next = Number(trimmed);
76
+ if (Number.isFinite(next)) {
77
+ if (meta?.min !== void 0) next = Math.max(meta.min, next);
78
+ if (meta?.max !== void 0) next = Math.min(meta.max, next);
79
+ if (next !== initialValue) {
80
+ setValue(next);
81
+ onUpdate(next);
82
+ }
83
+ }
84
+ }
85
+ } else if (value !== initialValue) onUpdate(value);
86
+ finishEditing(restoreFocus);
36
87
  }, [
88
+ type,
89
+ numberDraft,
90
+ meta?.nullable,
91
+ meta?.min,
92
+ meta?.max,
37
93
  value,
38
94
  initialValue,
39
- onUpdate
95
+ onUpdate,
96
+ finishEditing
40
97
  ]);
41
98
  const handleCancel = useCallback(()=>{
42
99
  setValue(initialValue);
43
- setIsEditing(false);
100
+ finishEditing(true);
44
101
  }, [
45
- initialValue
102
+ initialValue,
103
+ finishEditing
46
104
  ]);
47
105
  const handleKeyDown = useCallback((e)=>{
48
106
  if ('Enter' === e.key) {
49
107
  e.preventDefault();
50
- handleSave();
108
+ handleSave(true);
51
109
  } else if ('Escape' === e.key) {
52
110
  e.preventDefault();
53
111
  handleCancel();
@@ -65,18 +123,19 @@ function EditableCell({ cell, onUpdate }) {
65
123
  setValue(checked);
66
124
  onUpdate(checked);
67
125
  },
68
- "aria-label": "Toggle"
126
+ "aria-label": toggleLabel ?? 'Toggle'
69
127
  })
70
128
  });
71
129
  const cellContent = isEditing ? renderEditMode() : /*#__PURE__*/ jsx("button", {
130
+ ref: displayRef,
72
131
  type: "button",
73
132
  "data-slot": "editable-cell",
74
133
  className: cn('min-h-[32px] px-2 py-1.5 -mx-2 rounded cursor-pointer w-full text-left', 'hover:bg-muted/50 transition-colors', 'flex items-center bg-transparent border-0'),
75
- onClick: ()=>setIsEditing(true),
76
- "aria-label": `Edit ${cell.column.id}`,
134
+ onClick: startEditing,
135
+ "aria-label": editLabel ?? `Edit ${cell.column.id}`,
77
136
  children: /*#__PURE__*/ jsx("span", {
78
- className: cn('truncate', !value && 'text-muted-foreground'),
79
- children: formatDisplayValue(value, type, meta?.options)
137
+ className: cn('truncate', isEmptyValue(value) && 'text-muted-foreground'),
138
+ children: formatDisplayValue(value, type, meta?.options, dateLocale)
80
139
  })
81
140
  });
82
141
  return cellContent;
@@ -88,11 +147,11 @@ function EditableCell({ cell, onUpdate }) {
88
147
  onValueChange: (newValue)=>{
89
148
  setValue(newValue);
90
149
  onUpdate(newValue);
91
- setIsEditing(false);
150
+ finishEditing(true);
92
151
  },
93
152
  open: true,
94
153
  onOpenChange: (open)=>{
95
- if (!open) setIsEditing(false);
154
+ if (!open) finishEditing(true);
96
155
  },
97
156
  children: [
98
157
  /*#__PURE__*/ jsx(SelectTrigger, {
@@ -111,21 +170,21 @@ function EditableCell({ cell, onUpdate }) {
111
170
  });
112
171
  case 'date':
113
172
  return /*#__PURE__*/ jsx(DatePickerCell, {
114
- value: value instanceof Date ? value : value ? new Date(value) : void 0,
173
+ value: toValidDate(value),
115
174
  onValueChange: (date)=>{
116
175
  setValue(date);
117
176
  onUpdate(date);
118
177
  },
119
- onClose: ()=>setIsEditing(false),
178
+ onClose: ()=>finishEditing(true),
120
179
  placeholder: meta?.placeholder ?? 'Pick date'
121
180
  });
122
181
  case 'number':
123
182
  return /*#__PURE__*/ jsx(Input, {
124
183
  ref: inputRef,
125
184
  type: "number",
126
- value: value,
127
- onChange: (e)=>setValue(e.target.valueAsNumber),
128
- onBlur: handleSave,
185
+ value: numberDraft,
186
+ onChange: (e)=>setNumberDraft(e.target.value),
187
+ onBlur: ()=>handleSave(false),
129
188
  onKeyDown: handleKeyDown,
130
189
  min: meta?.min,
131
190
  max: meta?.max,
@@ -138,7 +197,7 @@ function EditableCell({ cell, onUpdate }) {
138
197
  type: "text",
139
198
  value: String(value ?? ''),
140
199
  onChange: (e)=>setValue(e.target.value),
141
- onBlur: handleSave,
200
+ onBlur: ()=>handleSave(false),
142
201
  onKeyDown: handleKeyDown,
143
202
  placeholder: meta?.placeholder,
144
203
  className: "h-8 -mx-2 w-full"
@@ -146,8 +205,8 @@ function EditableCell({ cell, onUpdate }) {
146
205
  }
147
206
  }
148
207
  }
149
- function formatDisplayValue(value, type, options) {
150
- if (null == value || '' === value) return '—';
208
+ function formatDisplayValue(value, type, options, locale) {
209
+ if (isEmptyValue(value)) return '—';
151
210
  switch(type){
152
211
  case 'select':
153
212
  {
@@ -155,8 +214,12 @@ function formatDisplayValue(value, type, options) {
155
214
  return option?.label ?? String(value);
156
215
  }
157
216
  case 'date':
158
- if (value instanceof Date) return format(value, 'PP');
159
- return format(new Date(value), 'PP');
217
+ {
218
+ const date = toValidDate(value);
219
+ return date ? format(date, 'PP', {
220
+ locale
221
+ }) : String(value);
222
+ }
160
223
  case 'checkbox':
161
224
  return value ? 'Yes' : 'No';
162
225
  default:
@@ -204,6 +267,7 @@ function DatePickerCell({ value, onValueChange, onClose, placeholder }) {
204
267
  children: /*#__PURE__*/ jsx(Calendar, {
205
268
  mode: "single",
206
269
  selected: value,
270
+ defaultMonth: value,
207
271
  onSelect: (date)=>{
208
272
  onValueChange(date);
209
273
  setOpen(false);
@@ -25,21 +25,28 @@ var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  AiAssistAction: ()=>external_ai_assist_action_cjs_namespaceObject.AiAssistAction,
28
+ InsertVariableAction: ()=>external_insert_variable_action_cjs_namespaceObject.InsertVariableAction,
29
+ RulesAction: ()=>external_rules_action_cjs_namespaceObject.RulesAction,
28
30
  DEFAULT_AI_ASSIST_ACTION_STRINGS: ()=>external_ai_assist_action_cjs_namespaceObject.DEFAULT_AI_ASSIST_ACTION_STRINGS,
29
31
  DEFAULT_INSERT_VARIABLE_ACTION_STRINGS: ()=>external_insert_variable_action_cjs_namespaceObject.DEFAULT_INSERT_VARIABLE_ACTION_STRINGS,
30
- InsertVariableAction: ()=>external_insert_variable_action_cjs_namespaceObject.InsertVariableAction
32
+ DEFAULT_RULES_ACTION_STRINGS: ()=>external_rules_action_cjs_namespaceObject.DEFAULT_RULES_ACTION_STRINGS
31
33
  });
32
34
  const external_ai_assist_action_cjs_namespaceObject = require("./ai-assist-action.cjs");
33
35
  const external_insert_variable_action_cjs_namespaceObject = require("./insert-variable-action.cjs");
36
+ const external_rules_action_cjs_namespaceObject = require("./rules-action.cjs");
34
37
  exports.AiAssistAction = __webpack_exports__.AiAssistAction;
35
38
  exports.DEFAULT_AI_ASSIST_ACTION_STRINGS = __webpack_exports__.DEFAULT_AI_ASSIST_ACTION_STRINGS;
36
39
  exports.DEFAULT_INSERT_VARIABLE_ACTION_STRINGS = __webpack_exports__.DEFAULT_INSERT_VARIABLE_ACTION_STRINGS;
40
+ exports.DEFAULT_RULES_ACTION_STRINGS = __webpack_exports__.DEFAULT_RULES_ACTION_STRINGS;
37
41
  exports.InsertVariableAction = __webpack_exports__.InsertVariableAction;
42
+ exports.RulesAction = __webpack_exports__.RulesAction;
38
43
  for(var __rspack_i in __webpack_exports__)if (-1 === [
39
44
  "AiAssistAction",
40
45
  "DEFAULT_AI_ASSIST_ACTION_STRINGS",
41
46
  "DEFAULT_INSERT_VARIABLE_ACTION_STRINGS",
42
- "InsertVariableAction"
47
+ "DEFAULT_RULES_ACTION_STRINGS",
48
+ "InsertVariableAction",
49
+ "RulesAction"
43
50
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
44
51
  Object.defineProperty(exports, '__esModule', {
45
52
  value: true
@@ -1,2 +1,3 @@
1
1
  export { AiAssistAction, type AiAssistActionProps, type AiAssistActionStrings, type AiAssistContentProps, DEFAULT_AI_ASSIST_ACTION_STRINGS, } from './ai-assist-action';
2
2
  export { DEFAULT_INSERT_VARIABLE_ACTION_STRINGS, InsertVariableAction, type InsertVariableActionProps, type InsertVariableActionStrings, } from './insert-variable-action';
3
+ export { DEFAULT_RULES_ACTION_STRINGS, RulesAction, type RulesActionProps, type RulesActionStrings, } from './rules-action';
@@ -1,3 +1,4 @@
1
1
  import { AiAssistAction, DEFAULT_AI_ASSIST_ACTION_STRINGS } from "./ai-assist-action.js";
2
2
  import { DEFAULT_INSERT_VARIABLE_ACTION_STRINGS, InsertVariableAction } from "./insert-variable-action.js";
3
- export { AiAssistAction, DEFAULT_AI_ASSIST_ACTION_STRINGS, DEFAULT_INSERT_VARIABLE_ACTION_STRINGS, InsertVariableAction };
3
+ import { DEFAULT_RULES_ACTION_STRINGS, RulesAction } from "./rules-action.js";
4
+ export { AiAssistAction, DEFAULT_AI_ASSIST_ACTION_STRINGS, DEFAULT_INSERT_VARIABLE_ACTION_STRINGS, DEFAULT_RULES_ACTION_STRINGS, InsertVariableAction, RulesAction };
@@ -31,6 +31,7 @@ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
31
31
  const external_lucide_react_namespaceObject = require("lucide-react");
32
32
  const external_react_namespaceObject = require("react");
33
33
  const external_button_cjs_namespaceObject = require("../button.cjs");
34
+ const header_context_cjs_namespaceObject = require("../quick-form-field/components/header-context.cjs");
34
35
  const index_cjs_namespaceObject = require("../variable-picker/index.cjs");
35
36
  const external_lib_index_cjs_namespaceObject = require("../../../lib/index.cjs");
36
37
  const external_collapse_cjs_namespaceObject = require("./collapse.cjs");
@@ -52,7 +53,8 @@ function InsertVariableAction({ variables = NO_VARIABLES, renderPicker, onInsert
52
53
  const lazy = 'function' == typeof variables;
53
54
  const inert = disabled || !onInsert || !renderPicker && !lazy && 0 === variables.length;
54
55
  const [openedItems, setOpenedItems] = (0, external_react_namespaceObject.useState)([]);
55
- const collapsedTextClass = (0, external_lib_index_cjs_namespaceObject.cn)(external_collapse_cjs_namespaceObject.COLLAPSED_HIDDEN, compact && '!hidden');
56
+ const header = (0, header_context_cjs_namespaceObject.useQuickFormFieldHeader)();
57
+ const collapsedTextClass = (0, external_lib_index_cjs_namespaceObject.cn)(external_collapse_cjs_namespaceObject.COLLAPSED_HIDDEN, (compact ?? header?.compact) && '!hidden');
56
58
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.VariablePicker, {
57
59
  disabled: inert,
58
60
  items: lazy ? openedItems : variables,
@@ -22,7 +22,10 @@ interface InsertVariableActionBaseProps {
22
22
  */
23
23
  onInsert?: (value: string, item: VariablePickerItem) => void;
24
24
  disabled?: boolean;
25
- /** Icon only. Below a 260px `@container` the action also collapses to its icon by itself. */
25
+ /**
26
+ * Icon only, or with its text even in a `compact` QuickFormField. In a field's header it defaults
27
+ * to the field's `compact`. Below a 260px `@container` it collapses to its icon either way.
28
+ */
26
29
  compact?: boolean;
27
30
  /** Overrides for any subset of the English strings. */
28
31
  strings?: Partial<InsertVariableActionStrings>;
@@ -2,6 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Braces, ChevronDown } from "lucide-react";
3
3
  import { useState } from "react";
4
4
  import { Button } from "../button.js";
5
+ import { useQuickFormFieldHeader } from "../quick-form-field/components/header-context.js";
5
6
  import { VariablePicker } from "../variable-picker/index.js";
6
7
  import { cn } from "../../../lib/index.js";
7
8
  import { COLLAPSED_HIDDEN, FIELD_ACTION_CLASS } from "./collapse.js";
@@ -23,7 +24,8 @@ function InsertVariableAction({ variables = NO_VARIABLES, renderPicker, onInsert
23
24
  const lazy = 'function' == typeof variables;
24
25
  const inert = disabled || !onInsert || !renderPicker && !lazy && 0 === variables.length;
25
26
  const [openedItems, setOpenedItems] = useState([]);
26
- const collapsedTextClass = cn(COLLAPSED_HIDDEN, compact && '!hidden');
27
+ const header = useQuickFormFieldHeader();
28
+ const collapsedTextClass = cn(COLLAPSED_HIDDEN, (compact ?? header?.compact) && '!hidden');
27
29
  return /*#__PURE__*/ jsx(VariablePicker, {
28
30
  disabled: inert,
29
31
  items: lazy ? openedItems : variables,