@uipath/apollo-wind 2.70.0 → 2.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/forms/field-control.cjs +3 -2
- package/dist/components/forms/field-control.js +3 -2
- package/dist/components/forms/validation-converter.cjs +14 -5
- package/dist/components/forms/validation-converter.js +14 -5
- package/dist/components/ui/chat-hero.cjs +244 -0
- package/dist/components/ui/chat-hero.d.ts +51 -0
- package/dist/components/ui/chat-hero.js +189 -0
- package/dist/components/ui/date-picker.cjs +6 -5
- package/dist/components/ui/date-picker.js +7 -6
- package/dist/components/ui/datetime-picker.cjs +7 -10
- package/dist/components/ui/datetime-picker.js +8 -11
- package/dist/components/ui/index.cjs +252 -230
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/index.js +2 -0
- package/dist/components/ui/prompt-suggestions.cjs +133 -0
- package/dist/components/ui/prompt-suggestions.d.ts +52 -0
- package/dist/components/ui/prompt-suggestions.js +90 -0
- package/dist/components/ui/quick-form-field/components/field-header.cjs +9 -4
- package/dist/components/ui/quick-form-field/components/field-header.d.ts +4 -1
- package/dist/components/ui/quick-form-field/components/field-header.js +9 -4
- package/dist/components/ui/quick-form-field/components/lock-toggle-button.cjs +2 -2
- package/dist/components/ui/quick-form-field/components/lock-toggle-button.d.ts +5 -4
- package/dist/components/ui/quick-form-field/components/lock-toggle-button.js +2 -2
- package/dist/components/ui/quick-form-field/index.d.ts +1 -1
- package/dist/components/ui/quick-form-field/quick-form-field.cjs +158 -222
- package/dist/components/ui/quick-form-field/quick-form-field.d.ts +6 -4
- package/dist/components/ui/quick-form-field/quick-form-field.js +159 -223
- package/dist/components/ui/quick-form-field/types.cjs +2 -2
- package/dist/components/ui/quick-form-field/types.d.ts +39 -32
- package/dist/components/ui/quick-form-field/types.js +2 -2
- package/dist/components/ui/quick-form-field/utils.cjs +5 -59
- package/dist/components/ui/quick-form-field/utils.d.ts +2 -24
- package/dist/components/ui/quick-form-field/utils.js +3 -48
- package/dist/index.cjs +40 -2
- package/dist/index.d.ts +5 -1
- package/dist/index.js +3 -1
- package/dist/lib/date-value.cjs +46 -0
- package/dist/lib/date-value.d.ts +8 -0
- package/dist/lib/date-value.js +12 -0
- package/dist/styles.css +82 -43
- package/dist/tailwind.utilities.css +15 -0
- package/package.json +1 -1
- package/dist/components/custom/chat-first-experience.cjs +0 -87
- package/dist/components/custom/chat-first-experience.d.ts +0 -24
- package/dist/components/custom/chat-first-experience.js +0 -53
- package/dist/components/custom/chat-prompt-suggestions.cjs +0 -49
- package/dist/components/custom/chat-prompt-suggestions.d.ts +0 -18
- package/dist/components/custom/chat-prompt-suggestions.js +0 -15
|
@@ -38,12 +38,13 @@ const external_popover_cjs_namespaceObject = require("../popover.cjs");
|
|
|
38
38
|
const external_select_cjs_namespaceObject = require("../select.cjs");
|
|
39
39
|
const external_switch_cjs_namespaceObject = require("../switch.cjs");
|
|
40
40
|
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
41
|
+
const date_value_cjs_namespaceObject = require("../../../lib/date-value.cjs");
|
|
41
42
|
const field_menu_cjs_namespaceObject = require("../field-addons/field-menu.cjs");
|
|
42
43
|
const field_header_cjs_namespaceObject = require("./components/field-header.cjs");
|
|
43
44
|
const lock_toggle_button_cjs_namespaceObject = require("./components/lock-toggle-button.cjs");
|
|
44
45
|
const external_types_cjs_namespaceObject = require("./types.cjs");
|
|
45
46
|
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
46
|
-
function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true, onLockedChange, showLock = true, leadingAddon, trailingAddon, more, mode = 'literal', onModeChange, renderExpressionEditor, renderModeControl, fieldType = 'string', fieldTypes, onFieldTypeChange, required, onRequiredChange, label, strings: stringOverrides, placeholder, error, errorId, belowValue, fileUploadAriaLabel, headerActions, compact, showFieldActions = true, options = external_utils_cjs_namespaceObject.DEFAULT_SELECT_OPTIONS, onGenerateWithAi, onInsertVariable, variables = [], id, className }) {
|
|
47
|
+
function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true, onLockedChange, showLock = true, disabled = false, leadingAddon, trailingAddon, more, mode = 'literal', onModeChange, renderExpressionEditor, renderModeControl, fieldType = 'string', fieldTypes, onFieldTypeChange, required, onRequiredChange, label, strings: stringOverrides, placeholder, error, errorId, belowValue, fileUploadAriaLabel, headerActions, compact, showFieldActions = true, options = external_utils_cjs_namespaceObject.DEFAULT_SELECT_OPTIONS, onGenerateWithAi, onInsertVariable, variables = [], id, className }) {
|
|
47
48
|
const strings = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
48
49
|
...external_types_cjs_namespaceObject.DEFAULT_QUICK_FORM_FIELD_STRINGS,
|
|
49
50
|
...stringOverrides
|
|
@@ -59,13 +60,12 @@ function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true,
|
|
|
59
60
|
const fieldId = id ?? generatedId;
|
|
60
61
|
const validationId = errorId ?? `${fieldId}-error`;
|
|
61
62
|
const typeMeta = external_types_cjs_namespaceObject.FIELD_TYPE_META[fieldType];
|
|
62
|
-
const
|
|
63
|
-
const editableOnValueChange = locked ? void 0 : onValueChange;
|
|
63
|
+
const editableOnValueChange = disabled ? void 0 : onValueChange;
|
|
64
64
|
const typeLabel = strings.typeLabels[fieldType] ?? typeMeta.label;
|
|
65
|
-
const fieldLabel = 'expression' ===
|
|
65
|
+
const fieldLabel = 'expression' === mode ? strings.expressionFieldLabel(typeLabel) : strings.valueFieldLabel(typeLabel);
|
|
66
66
|
const valuePlaceholder = placeholder ?? fieldLabel;
|
|
67
67
|
const menuActions = [
|
|
68
|
-
...more?.onClear
|
|
68
|
+
...more?.onClear ? [
|
|
69
69
|
{
|
|
70
70
|
id: 'clear',
|
|
71
71
|
label: strings.clearValue,
|
|
@@ -82,13 +82,11 @@ function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true,
|
|
|
82
82
|
}
|
|
83
83
|
] : []
|
|
84
84
|
];
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const builtInMenu = showsMenu ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(field_menu_cjs_namespaceObject.FieldMenu, {
|
|
88
|
-
mode: effectiveMode,
|
|
85
|
+
const builtInMenu = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(field_menu_cjs_namespaceObject.FieldMenu, {
|
|
86
|
+
mode: mode,
|
|
89
87
|
onSelect: (next)=>onModeChange?.(next),
|
|
90
|
-
modesDisabled: !
|
|
91
|
-
disabled: !
|
|
88
|
+
modesDisabled: !onModeChange && menuActions.length > 0,
|
|
89
|
+
disabled: disabled || !onModeChange && 0 === menuActions.length,
|
|
92
90
|
actions: menuActions,
|
|
93
91
|
triggerLabel: strings.valueModeAriaLabel,
|
|
94
92
|
literalDescription: strings.literalDescriptions[fieldType] ?? typeMeta.fixedDescription,
|
|
@@ -98,20 +96,22 @@ function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true,
|
|
|
98
96
|
expressionDescription: strings.expressionDescription,
|
|
99
97
|
fieldActions: strings.moreActionsAriaLabel
|
|
100
98
|
}
|
|
101
|
-
})
|
|
102
|
-
const
|
|
99
|
+
});
|
|
100
|
+
const controlProps = {
|
|
103
101
|
id: fieldId,
|
|
104
102
|
value,
|
|
105
103
|
onValueChange: editableOnValueChange,
|
|
106
104
|
onBlur: onValueBlur,
|
|
107
105
|
readOnly: !editableOnValueChange,
|
|
106
|
+
disabled,
|
|
108
107
|
placeholder: valuePlaceholder,
|
|
109
108
|
fieldType,
|
|
110
109
|
'aria-invalid': error ? true : void 0,
|
|
111
110
|
'aria-describedby': error ? validationId : void 0,
|
|
112
111
|
'aria-errormessage': error ? validationId : void 0,
|
|
113
112
|
'data-slot': 'input-group-control'
|
|
114
|
-
}
|
|
113
|
+
};
|
|
114
|
+
const modeControl = renderModeControl?.(mode, controlProps) ?? null;
|
|
115
115
|
const modeOnMount = (0, external_react_namespaceObject.useRef)(mode);
|
|
116
116
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
117
117
|
if (modeOnMount.current === mode) return;
|
|
@@ -127,7 +127,7 @@ function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true,
|
|
|
127
127
|
}
|
|
128
128
|
if ('Escape' === e.key) {
|
|
129
129
|
e.preventDefault();
|
|
130
|
-
|
|
130
|
+
editableOnValueChange?.(committedRef.current);
|
|
131
131
|
e.currentTarget.blur();
|
|
132
132
|
}
|
|
133
133
|
};
|
|
@@ -149,7 +149,139 @@ function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true,
|
|
|
149
149
|
input.setSelectionRange(next_caret, next_caret);
|
|
150
150
|
});
|
|
151
151
|
};
|
|
152
|
-
const
|
|
152
|
+
const textInputProps = {
|
|
153
|
+
id: fieldId,
|
|
154
|
+
ref: valueInputRef,
|
|
155
|
+
readOnly: !editableOnValueChange,
|
|
156
|
+
disabled,
|
|
157
|
+
value,
|
|
158
|
+
onChange: (e)=>editableOnValueChange?.(e.target.value),
|
|
159
|
+
onFocus: (e)=>{
|
|
160
|
+
committedRef.current = value;
|
|
161
|
+
caretRef.current = {
|
|
162
|
+
start: e.currentTarget.selectionStart ?? value.length,
|
|
163
|
+
end: e.currentTarget.selectionEnd ?? value.length
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
onSelect: (e)=>{
|
|
167
|
+
const el = e.currentTarget;
|
|
168
|
+
caretRef.current = {
|
|
169
|
+
start: el.selectionStart ?? 0,
|
|
170
|
+
end: el.selectionEnd ?? el.selectionStart ?? 0
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
onKeyDown: handleValueKeyDown,
|
|
174
|
+
onBlur: (e)=>{
|
|
175
|
+
caretRef.current = {
|
|
176
|
+
start: e.currentTarget.selectionStart ?? value.length,
|
|
177
|
+
end: e.currentTarget.selectionEnd ?? value.length
|
|
178
|
+
};
|
|
179
|
+
onValueBlur?.();
|
|
180
|
+
},
|
|
181
|
+
placeholder: valuePlaceholder
|
|
182
|
+
};
|
|
183
|
+
const literalControl = 'boolean' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
184
|
+
className: "flex h-full flex-1 items-center px-3",
|
|
185
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_switch_cjs_namespaceObject.Switch, {
|
|
186
|
+
id: fieldId,
|
|
187
|
+
"aria-invalid": controlProps['aria-invalid'],
|
|
188
|
+
"aria-describedby": controlProps['aria-describedby'],
|
|
189
|
+
"aria-errormessage": controlProps['aria-errormessage'],
|
|
190
|
+
checked: 'true' === value,
|
|
191
|
+
onCheckedChange: (checked)=>editableOnValueChange?.(String(checked)),
|
|
192
|
+
onBlur: onValueBlur,
|
|
193
|
+
disabled: !editableOnValueChange
|
|
194
|
+
})
|
|
195
|
+
}) : 'date' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
196
|
+
open: datePopoverOpen,
|
|
197
|
+
onOpenChange: (open)=>{
|
|
198
|
+
setDatePopoverOpen(open);
|
|
199
|
+
if (!open) onValueBlur?.();
|
|
200
|
+
},
|
|
201
|
+
children: [
|
|
202
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
203
|
+
asChild: true,
|
|
204
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
205
|
+
type: "button",
|
|
206
|
+
id: fieldId,
|
|
207
|
+
"data-slot": "input-group-control",
|
|
208
|
+
"aria-invalid": controlProps['aria-invalid'],
|
|
209
|
+
"aria-describedby": controlProps['aria-describedby'],
|
|
210
|
+
"aria-errormessage": controlProps['aria-errormessage'],
|
|
211
|
+
disabled: !editableOnValueChange,
|
|
212
|
+
className: "flex h-full flex-1 items-center text-left text-sm text-foreground outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
213
|
+
children: value ? (0, external_utils_cjs_namespaceObject.formatDateValue)(value) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
214
|
+
className: "text-muted-foreground",
|
|
215
|
+
children: strings.pickDate
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
}),
|
|
219
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent, {
|
|
220
|
+
align: "start",
|
|
221
|
+
className: "w-auto p-0",
|
|
222
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_calendar_cjs_namespaceObject.Calendar, {
|
|
223
|
+
mode: "single",
|
|
224
|
+
selected: (0, date_value_cjs_namespaceObject.toDateValue)(value),
|
|
225
|
+
onSelect: (date)=>editableOnValueChange?.(date ? (0, external_utils_cjs_namespaceObject.toDateOnlyString)(date) : ''),
|
|
226
|
+
initialFocus: true
|
|
227
|
+
})
|
|
228
|
+
})
|
|
229
|
+
]
|
|
230
|
+
}) : 'datetime' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_datetime_picker_cjs_namespaceObject.DateTimePicker, {
|
|
231
|
+
id: fieldId,
|
|
232
|
+
value: (0, date_value_cjs_namespaceObject.toDateValue)(value),
|
|
233
|
+
onValueChange: (date)=>editableOnValueChange?.(date ? date.toISOString() : ''),
|
|
234
|
+
onOpenChange: (open)=>{
|
|
235
|
+
if (!open) onValueBlur?.();
|
|
236
|
+
},
|
|
237
|
+
disabled: !editableOnValueChange,
|
|
238
|
+
placeholder: valuePlaceholder
|
|
239
|
+
}) : 'file' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_file_upload_cjs_namespaceObject.FileUpload, {
|
|
240
|
+
id: fieldId,
|
|
241
|
+
ariaLabel: fileUploadAriaLabel ?? ('string' == typeof label ? label : fieldLabel),
|
|
242
|
+
className: "flex-1",
|
|
243
|
+
onFilesChange: (files)=>editableOnValueChange?.(files.map((f)=>f.name).join(', ')),
|
|
244
|
+
disabled: !editableOnValueChange,
|
|
245
|
+
onBlur: onValueBlur,
|
|
246
|
+
"aria-invalid": controlProps['aria-invalid'],
|
|
247
|
+
"aria-describedby": controlProps['aria-describedby'],
|
|
248
|
+
"aria-errormessage": controlProps['aria-errormessage']
|
|
249
|
+
}) : 'single-select' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
|
|
250
|
+
open: selectOpen,
|
|
251
|
+
onOpenChange: (open)=>{
|
|
252
|
+
setSelectOpen(open);
|
|
253
|
+
if (!open && selectOpen) onValueBlur?.();
|
|
254
|
+
},
|
|
255
|
+
value: value || void 0,
|
|
256
|
+
onValueChange: editableOnValueChange,
|
|
257
|
+
disabled: !editableOnValueChange,
|
|
258
|
+
children: [
|
|
259
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
|
|
260
|
+
id: fieldId,
|
|
261
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {
|
|
262
|
+
placeholder: strings.selectOption
|
|
263
|
+
})
|
|
264
|
+
}),
|
|
265
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
|
|
266
|
+
children: options.map((option)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
|
|
267
|
+
value: option.value,
|
|
268
|
+
children: option.label
|
|
269
|
+
}, option.value))
|
|
270
|
+
})
|
|
271
|
+
]
|
|
272
|
+
}) : 'multi-select' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_multi_select_cjs_namespaceObject.MultiSelect, {
|
|
273
|
+
id: fieldId,
|
|
274
|
+
options: options,
|
|
275
|
+
selected: (0, external_utils_cjs_namespaceObject.parseListValue)(value),
|
|
276
|
+
onChange: (selected)=>editableOnValueChange?.(JSON.stringify(selected)),
|
|
277
|
+
placeholder: strings.selectOptions,
|
|
278
|
+
disabled: !editableOnValueChange,
|
|
279
|
+
onBlur: onValueBlur
|
|
280
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
281
|
+
...textInputProps,
|
|
282
|
+
type: 'integer' === fieldType || 'double' === fieldType ? 'number' : 'text',
|
|
283
|
+
step: 'double' === fieldType ? 'any' : void 0
|
|
284
|
+
});
|
|
153
285
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
154
286
|
className: (0, index_cjs_namespaceObject.cn)('@container group flex flex-col gap-1.5 [&>[data-slot=form-field-error]]:mt-0', className),
|
|
155
287
|
children: [
|
|
@@ -163,6 +295,8 @@ function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true,
|
|
|
163
295
|
onFieldTypeChange: onFieldTypeChange,
|
|
164
296
|
onRequiredChange: onRequiredChange,
|
|
165
297
|
compact: compact,
|
|
298
|
+
disabled: disabled,
|
|
299
|
+
isExpression: 'expression' === mode,
|
|
166
300
|
showFieldActions: showFieldActions,
|
|
167
301
|
onValueChange: editableOnValueChange,
|
|
168
302
|
variables: variables,
|
|
@@ -174,224 +308,26 @@ function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true,
|
|
|
174
308
|
headerActions: headerActions,
|
|
175
309
|
strings: strings
|
|
176
310
|
}),
|
|
177
|
-
|
|
311
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_input_group_cjs_namespaceObject.InputGroup, {
|
|
178
312
|
error: error,
|
|
179
313
|
errorId: validationId,
|
|
180
|
-
|
|
314
|
+
disabled: disabled,
|
|
315
|
+
layout: 'literal' === mode && ('file' === fieldType || 'multi-select' === fieldType) ? 'grow' : 'row',
|
|
181
316
|
children: [
|
|
182
317
|
(showLock || void 0 !== leadingAddon) && null !== leadingAddon && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
183
318
|
align: "inline-start",
|
|
184
319
|
children: void 0 !== leadingAddon ? leadingAddon : showLock && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(lock_toggle_button_cjs_namespaceObject.LockToggleButton, {
|
|
185
320
|
locked: locked,
|
|
186
321
|
onLockedChange: onLockedChange,
|
|
322
|
+
disabled: disabled,
|
|
187
323
|
strings: strings
|
|
188
324
|
})
|
|
189
325
|
}),
|
|
190
|
-
modeControl ?? ('expression' ===
|
|
191
|
-
|
|
192
|
-
value,
|
|
193
|
-
onValueChange: editableOnValueChange,
|
|
194
|
-
onBlur: onValueBlur,
|
|
195
|
-
readOnly: !editableOnValueChange,
|
|
196
|
-
placeholder: valuePlaceholder,
|
|
197
|
-
fieldType,
|
|
198
|
-
'aria-invalid': error ? true : void 0,
|
|
199
|
-
'aria-describedby': error ? validationId : void 0,
|
|
200
|
-
'aria-errormessage': error ? validationId : void 0,
|
|
201
|
-
'data-slot': 'input-group-control'
|
|
202
|
-
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
203
|
-
id: fieldId,
|
|
204
|
-
ref: valueInputRef,
|
|
205
|
-
readOnly: !editableOnValueChange,
|
|
206
|
-
value: value,
|
|
207
|
-
onChange: (e)=>editableOnValueChange?.(e.target.value),
|
|
208
|
-
onFocus: (e)=>{
|
|
209
|
-
committedRef.current = value;
|
|
210
|
-
caretRef.current = {
|
|
211
|
-
start: e.currentTarget.selectionStart ?? value.length,
|
|
212
|
-
end: e.currentTarget.selectionEnd ?? value.length
|
|
213
|
-
};
|
|
214
|
-
},
|
|
215
|
-
onSelect: (e)=>{
|
|
216
|
-
const el = e.currentTarget;
|
|
217
|
-
caretRef.current = {
|
|
218
|
-
start: el.selectionStart ?? 0,
|
|
219
|
-
end: el.selectionEnd ?? el.selectionStart ?? 0
|
|
220
|
-
};
|
|
221
|
-
},
|
|
222
|
-
onKeyDown: handleValueKeyDown,
|
|
223
|
-
onBlur: (e)=>{
|
|
224
|
-
caretRef.current = {
|
|
225
|
-
start: e.currentTarget.selectionStart ?? value.length,
|
|
226
|
-
end: e.currentTarget.selectionEnd ?? value.length
|
|
227
|
-
};
|
|
228
|
-
onValueBlur?.();
|
|
229
|
-
},
|
|
230
|
-
placeholder: valuePlaceholder,
|
|
326
|
+
modeControl ?? ('expression' === mode ? renderExpressionEditor ? renderExpressionEditor(controlProps) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
327
|
+
...textInputProps,
|
|
231
328
|
className: "font-mono"
|
|
232
|
-
}) :
|
|
233
|
-
|
|
234
|
-
readOnly: true,
|
|
235
|
-
value: lockedDisplayValue,
|
|
236
|
-
placeholder: valuePlaceholder,
|
|
237
|
-
onBlur: onValueBlur
|
|
238
|
-
}) : 'boolean' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
239
|
-
className: "flex h-full flex-1 items-center px-3",
|
|
240
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_switch_cjs_namespaceObject.Switch, {
|
|
241
|
-
id: fieldId,
|
|
242
|
-
"aria-invalid": error ? true : void 0,
|
|
243
|
-
"aria-describedby": error ? validationId : void 0,
|
|
244
|
-
"aria-errormessage": error ? validationId : void 0,
|
|
245
|
-
checked: 'true' === value,
|
|
246
|
-
onCheckedChange: (checked)=>onValueChange?.(String(checked)),
|
|
247
|
-
onBlur: onValueBlur,
|
|
248
|
-
disabled: !onValueChange
|
|
249
|
-
})
|
|
250
|
-
}) : 'date' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
251
|
-
open: datePopoverOpen,
|
|
252
|
-
onOpenChange: (open)=>{
|
|
253
|
-
setDatePopoverOpen(open);
|
|
254
|
-
if (!open) onValueBlur?.();
|
|
255
|
-
},
|
|
256
|
-
children: [
|
|
257
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
258
|
-
asChild: true,
|
|
259
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
260
|
-
type: "button",
|
|
261
|
-
id: fieldId,
|
|
262
|
-
"data-slot": "input-group-control",
|
|
263
|
-
"aria-invalid": error ? true : void 0,
|
|
264
|
-
"aria-describedby": error ? validationId : void 0,
|
|
265
|
-
"aria-errormessage": error ? validationId : void 0,
|
|
266
|
-
disabled: !onValueChange,
|
|
267
|
-
className: "flex h-full flex-1 items-center text-left text-sm text-foreground outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
268
|
-
children: value ? (0, external_utils_cjs_namespaceObject.formatDateValue)(value) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
269
|
-
className: "text-muted-foreground",
|
|
270
|
-
children: strings.pickDate
|
|
271
|
-
})
|
|
272
|
-
})
|
|
273
|
-
}),
|
|
274
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent, {
|
|
275
|
-
align: "start",
|
|
276
|
-
className: "w-auto p-0",
|
|
277
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_calendar_cjs_namespaceObject.Calendar, {
|
|
278
|
-
mode: "single",
|
|
279
|
-
selected: (0, external_utils_cjs_namespaceObject.parseDateValue)(value),
|
|
280
|
-
onSelect: (date)=>onValueChange?.(date ? (0, external_utils_cjs_namespaceObject.toDateOnlyString)(date) : ''),
|
|
281
|
-
initialFocus: true
|
|
282
|
-
})
|
|
283
|
-
})
|
|
284
|
-
]
|
|
285
|
-
}) : 'datetime' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_datetime_picker_cjs_namespaceObject.DateTimePicker, {
|
|
286
|
-
id: fieldId,
|
|
287
|
-
value: (0, external_utils_cjs_namespaceObject.parseDateValue)(value),
|
|
288
|
-
onValueChange: (date)=>onValueChange?.(date ? date.toISOString() : ''),
|
|
289
|
-
onOpenChange: (open)=>{
|
|
290
|
-
if (!open) onValueBlur?.();
|
|
291
|
-
},
|
|
292
|
-
disabled: !onValueChange,
|
|
293
|
-
placeholder: valuePlaceholder
|
|
294
|
-
}) : 'file' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_file_upload_cjs_namespaceObject.FileUpload, {
|
|
295
|
-
id: fieldId,
|
|
296
|
-
ariaLabel: fileUploadAriaLabel ?? ('string' == typeof label ? label : fieldLabel),
|
|
297
|
-
className: "flex-1",
|
|
298
|
-
onFilesChange: (files)=>onValueChange?.(files.map((f)=>f.name).join(', ')),
|
|
299
|
-
disabled: !onValueChange,
|
|
300
|
-
onBlur: onValueBlur,
|
|
301
|
-
"aria-invalid": error ? true : void 0,
|
|
302
|
-
"aria-describedby": error ? validationId : void 0,
|
|
303
|
-
"aria-errormessage": error ? validationId : void 0
|
|
304
|
-
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
305
|
-
id: fieldId,
|
|
306
|
-
ref: valueInputRef,
|
|
307
|
-
type: 'integer' === fieldType || 'double' === fieldType ? 'number' : 'text',
|
|
308
|
-
step: 'double' === fieldType ? 'any' : void 0,
|
|
309
|
-
readOnly: !onValueChange,
|
|
310
|
-
value: value,
|
|
311
|
-
onChange: (e)=>onValueChange?.(e.target.value),
|
|
312
|
-
onFocus: (e)=>{
|
|
313
|
-
committedRef.current = value;
|
|
314
|
-
caretRef.current = {
|
|
315
|
-
start: e.currentTarget.selectionStart ?? value.length,
|
|
316
|
-
end: e.currentTarget.selectionEnd ?? value.length
|
|
317
|
-
};
|
|
318
|
-
},
|
|
319
|
-
onSelect: (e)=>{
|
|
320
|
-
const el = e.currentTarget;
|
|
321
|
-
caretRef.current = {
|
|
322
|
-
start: el.selectionStart ?? 0,
|
|
323
|
-
end: el.selectionEnd ?? el.selectionStart ?? 0
|
|
324
|
-
};
|
|
325
|
-
},
|
|
326
|
-
onKeyDown: handleValueKeyDown,
|
|
327
|
-
onBlur: (e)=>{
|
|
328
|
-
caretRef.current = {
|
|
329
|
-
start: e.currentTarget.selectionStart ?? value.length,
|
|
330
|
-
end: e.currentTarget.selectionEnd ?? value.length
|
|
331
|
-
};
|
|
332
|
-
onValueBlur?.();
|
|
333
|
-
},
|
|
334
|
-
placeholder: valuePlaceholder
|
|
335
|
-
})),
|
|
336
|
-
null !== trailingAddon && (void 0 !== trailingAddon || builtInMenu) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
337
|
-
align: "inline-end",
|
|
338
|
-
className: "cursor-default",
|
|
339
|
-
children: void 0 !== trailingAddon ? trailingAddon : builtInMenu
|
|
340
|
-
})
|
|
341
|
-
]
|
|
342
|
-
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_input_group_cjs_namespaceObject.InputGroup, {
|
|
343
|
-
error: error,
|
|
344
|
-
errorId: validationId,
|
|
345
|
-
layout: 'multi-select' !== fieldType || locked ? 'row' : 'grow',
|
|
346
|
-
children: [
|
|
347
|
-
(showLock || void 0 !== leadingAddon) && null !== leadingAddon && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
348
|
-
align: "inline-start",
|
|
349
|
-
children: void 0 !== leadingAddon ? leadingAddon : showLock && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(lock_toggle_button_cjs_namespaceObject.LockToggleButton, {
|
|
350
|
-
locked: locked,
|
|
351
|
-
onLockedChange: onLockedChange,
|
|
352
|
-
strings: strings
|
|
353
|
-
})
|
|
354
|
-
}),
|
|
355
|
-
modeControl ?? (locked ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
356
|
-
id: fieldId,
|
|
357
|
-
readOnly: true,
|
|
358
|
-
value: lockedDisplayValue,
|
|
359
|
-
placeholder: valuePlaceholder,
|
|
360
|
-
className: "min-w-0",
|
|
361
|
-
onBlur: onValueBlur
|
|
362
|
-
}) : 'single-select' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
|
|
363
|
-
open: selectOpen,
|
|
364
|
-
onOpenChange: (open)=>{
|
|
365
|
-
setSelectOpen(open);
|
|
366
|
-
if (!open && selectOpen) onValueBlur?.();
|
|
367
|
-
},
|
|
368
|
-
value: value || void 0,
|
|
369
|
-
onValueChange: onValueChange,
|
|
370
|
-
disabled: !onValueChange,
|
|
371
|
-
children: [
|
|
372
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
|
|
373
|
-
id: fieldId,
|
|
374
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {
|
|
375
|
-
placeholder: strings.selectOption
|
|
376
|
-
})
|
|
377
|
-
}),
|
|
378
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
|
|
379
|
-
children: options.map((option)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
|
|
380
|
-
value: option.value,
|
|
381
|
-
children: option.label
|
|
382
|
-
}, option.value))
|
|
383
|
-
})
|
|
384
|
-
]
|
|
385
|
-
}) : 'multi-select' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_multi_select_cjs_namespaceObject.MultiSelect, {
|
|
386
|
-
id: fieldId,
|
|
387
|
-
options: options,
|
|
388
|
-
selected: (0, external_utils_cjs_namespaceObject.parseListValue)(value),
|
|
389
|
-
onChange: (selected)=>onValueChange?.(JSON.stringify(selected)),
|
|
390
|
-
placeholder: strings.selectOptions,
|
|
391
|
-
disabled: !onValueChange,
|
|
392
|
-
onBlur: onValueBlur
|
|
393
|
-
}) : null),
|
|
394
|
-
null !== trailingAddon && (void 0 !== trailingAddon || builtInMenu) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
329
|
+
}) : literalControl),
|
|
330
|
+
null !== trailingAddon && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
395
331
|
align: "inline-end",
|
|
396
332
|
className: "cursor-default",
|
|
397
333
|
children: void 0 !== trailingAddon ? trailingAddon : builtInMenu
|
|
@@ -2,9 +2,9 @@ import type { QuickFormFieldProps } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* A Quick Form is assembled by end users, like a form builder. QuickFormField is
|
|
4
4
|
* the control for an individual field within it, and carries its own
|
|
5
|
-
* configuration controls: a lock that
|
|
6
|
-
* that swaps the control, a Required toggle, and
|
|
7
|
-
* `literal`, `expression`, `variable` and `prompt`.
|
|
5
|
+
* configuration controls: a lock that marks it read-only for the person filling
|
|
6
|
+
* in the form, a data-type switch that swaps the control, a Required toggle, and
|
|
7
|
+
* a value-mode switch across `literal`, `expression`, `variable` and `prompt`.
|
|
8
8
|
*
|
|
9
9
|
* Only use it within a quick form builder. For standard forms, compose the
|
|
10
10
|
* form-field anatomy (`FormField`, `FormFieldLabel`, `InputGroup`, …) or
|
|
@@ -12,6 +12,8 @@ import type { QuickFormFieldProps } from './types';
|
|
|
12
12
|
*
|
|
13
13
|
* - Literal and expression have built-in controls; `renderModeControl`
|
|
14
14
|
* supplies the control for any mode, and `variable` / `prompt` need it.
|
|
15
|
+
* - `locked` is configuration the author sets, so the value stays editable;
|
|
16
|
+
* `disabled` is what stops the author editing the field.
|
|
15
17
|
* - `fieldTypes` chooses which types the picker offers.
|
|
16
18
|
* - Insert variable renders `variables` as supplied and splices at the caret;
|
|
17
19
|
* `onInsertVariable` takes over what inserting means.
|
|
@@ -23,4 +25,4 @@ import type { QuickFormFieldProps } from './types';
|
|
|
23
25
|
* AI-assist button renders only with `onGenerateWithAi`, and file uploads
|
|
24
26
|
* aren't persisted anywhere.
|
|
25
27
|
*/
|
|
26
|
-
export declare function QuickFormField({ value, onValueChange, onValueBlur, locked, onLockedChange, showLock, leadingAddon, trailingAddon, more, mode, onModeChange, renderExpressionEditor, renderModeControl, fieldType, fieldTypes, onFieldTypeChange, required, onRequiredChange, label, strings: stringOverrides, placeholder, error, errorId, belowValue, fileUploadAriaLabel, headerActions, compact, showFieldActions, options, onGenerateWithAi, onInsertVariable, variables, id, className, }: QuickFormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare function QuickFormField({ value, onValueChange, onValueBlur, locked, onLockedChange, showLock, disabled, leadingAddon, trailingAddon, more, mode, onModeChange, renderExpressionEditor, renderModeControl, fieldType, fieldTypes, onFieldTypeChange, required, onRequiredChange, label, strings: stringOverrides, placeholder, error, errorId, belowValue, fileUploadAriaLabel, headerActions, compact, showFieldActions, options, onGenerateWithAi, onInsertVariable, variables, id, className, }: QuickFormFieldProps): import("react/jsx-runtime").JSX.Element;
|