@uipath/apollo-wind 2.59.0 → 2.60.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.
- package/README.md +13 -0
- package/dist/components/ui/accordion.cjs +1 -0
- package/dist/components/ui/accordion.js +1 -0
- package/dist/components/ui/datetime-picker.cjs +19 -3
- package/dist/components/ui/datetime-picker.d.ts +2 -0
- package/dist/components/ui/datetime-picker.js +19 -3
- package/dist/components/ui/dialog.cjs +1 -0
- package/dist/components/ui/dialog.js +1 -0
- package/dist/components/ui/drawer.cjs +1 -1
- package/dist/components/ui/drawer.js +1 -1
- package/dist/components/ui/field-actions/insert-variable-action.cjs +1 -1
- package/dist/components/ui/field-actions/insert-variable-action.d.ts +5 -2
- package/dist/components/ui/field-actions/insert-variable-action.js +1 -1
- package/dist/components/ui/field-addons/field-menu.cjs +2 -2
- package/dist/components/ui/field-addons/field-menu.d.ts +4 -2
- package/dist/components/ui/field-addons/field-menu.js +2 -2
- package/dist/components/ui/index.cjs +97 -86
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/components/ui/lockable-value-field/index.cjs +5 -5
- package/dist/components/ui/lockable-value-field/index.d.ts +18 -3
- package/dist/components/ui/lockable-value-field/index.js +2 -2
- package/dist/components/ui/quick-form-field/components/field-header.cjs +265 -0
- package/dist/components/ui/quick-form-field/components/field-header.d.ts +23 -0
- package/dist/components/ui/quick-form-field/components/field-header.js +231 -0
- package/dist/components/ui/{lockable-value-field → quick-form-field}/components/lock-toggle-button.cjs +3 -3
- package/dist/components/ui/{lockable-value-field → quick-form-field}/components/lock-toggle-button.d.ts +4 -1
- package/dist/components/ui/{lockable-value-field → quick-form-field}/components/lock-toggle-button.js +3 -3
- package/dist/components/ui/quick-form-field/index.cjs +46 -0
- package/dist/components/ui/quick-form-field/index.d.ts +3 -0
- package/dist/components/ui/quick-form-field/index.js +3 -0
- package/dist/components/ui/{lockable-value-field/lockable-value-field.cjs → quick-form-field/quick-form-field.cjs} +190 -119
- package/dist/components/ui/quick-form-field/quick-form-field.d.ts +26 -0
- package/dist/components/ui/{lockable-value-field/lockable-value-field.js → quick-form-field/quick-form-field.js} +194 -123
- package/dist/components/ui/{lockable-value-field → quick-form-field}/types.cjs +70 -0
- package/dist/components/ui/quick-form-field/types.d.ts +245 -0
- package/dist/components/ui/quick-form-field/types.js +137 -0
- package/dist/components/ui/{lockable-value-field → quick-form-field}/utils.cjs +21 -3
- package/dist/components/ui/{lockable-value-field → quick-form-field}/utils.d.ts +8 -3
- package/dist/components/ui/{lockable-value-field → quick-form-field}/utils.js +19 -4
- package/dist/components/ui/sheet.cjs +2 -2
- package/dist/components/ui/sheet.js +2 -2
- package/dist/index.cjs +9 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -2
- package/dist/styles.css +53 -0
- package/dist/tailwind.css +72 -0
- package/package.json +1 -1
- package/dist/components/ui/lockable-value-field/components/field-header.cjs +0 -242
- package/dist/components/ui/lockable-value-field/components/field-header.d.ts +0 -19
- package/dist/components/ui/lockable-value-field/components/field-header.js +0 -208
- package/dist/components/ui/lockable-value-field/lockable-value-field.d.ts +0 -14
- package/dist/components/ui/lockable-value-field/types.d.ts +0 -109
- package/dist/components/ui/lockable-value-field/types.js +0 -70
|
@@ -24,13 +24,13 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
27
|
+
QuickFormField: ()=>QuickFormField
|
|
28
28
|
});
|
|
29
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
30
|
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
31
31
|
const external_react_namespaceObject = require("react");
|
|
32
32
|
const external_calendar_cjs_namespaceObject = require("../calendar.cjs");
|
|
33
|
-
const
|
|
33
|
+
const external_datetime_picker_cjs_namespaceObject = require("../datetime-picker.cjs");
|
|
34
34
|
const external_file_upload_cjs_namespaceObject = require("../file-upload.cjs");
|
|
35
35
|
const external_input_group_cjs_namespaceObject = require("../input-group.cjs");
|
|
36
36
|
const external_multi_select_cjs_namespaceObject = require("../multi-select.cjs");
|
|
@@ -43,59 +43,113 @@ const field_header_cjs_namespaceObject = require("./components/field-header.cjs"
|
|
|
43
43
|
const lock_toggle_button_cjs_namespaceObject = require("./components/lock-toggle-button.cjs");
|
|
44
44
|
const external_types_cjs_namespaceObject = require("./types.cjs");
|
|
45
45
|
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
asChild: true,
|
|
54
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupButton, {
|
|
55
|
-
icon: true,
|
|
56
|
-
size: "3xs",
|
|
57
|
-
"aria-label": "More value actions",
|
|
58
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.MoreHorizontal, {})
|
|
59
|
-
})
|
|
60
|
-
}),
|
|
61
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuContent, {
|
|
62
|
-
align: "end",
|
|
63
|
-
className: "w-40",
|
|
64
|
-
children: [
|
|
65
|
-
onClear && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuItem, {
|
|
66
|
-
className: "text-error focus:text-error",
|
|
67
|
-
onClick: onClear,
|
|
68
|
-
children: [
|
|
69
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Trash2, {}),
|
|
70
|
-
"Clear value"
|
|
71
|
-
]
|
|
72
|
-
}),
|
|
73
|
-
onRefresh && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuItem, {
|
|
74
|
-
onClick: onRefresh,
|
|
75
|
-
children: [
|
|
76
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.RefreshCw, {}),
|
|
77
|
-
"Force refresh"
|
|
78
|
-
]
|
|
79
|
-
})
|
|
80
|
-
]
|
|
81
|
-
})
|
|
82
|
-
]
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
function LockableValueField({ value = '', onValueChange, onValueBlur, locked = true, onLockedChange, showLock = true, leadingAddon, trailingAddon, more, mode = 'fixed', onModeChange, renderExpressionEditor, fieldType = 'string', onFieldTypeChange, required, onRequiredChange, label, error, errorId, belowValue, fileUploadAriaLabel, headerActions, compact, showFieldActions = true, showAiAssist = true, options = external_utils_cjs_namespaceObject.DEFAULT_SELECT_OPTIONS, onGenerateWithAi, variables = [], id, className }) {
|
|
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
|
+
const strings = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
48
|
+
...external_types_cjs_namespaceObject.DEFAULT_QUICK_FORM_FIELD_STRINGS,
|
|
49
|
+
...stringOverrides
|
|
50
|
+
}), [
|
|
51
|
+
stringOverrides
|
|
52
|
+
]);
|
|
86
53
|
const generatedId = (0, external_react_namespaceObject.useId)().replace(/:/g, '');
|
|
54
|
+
const valueInputRef = (0, external_react_namespaceObject.useRef)(null);
|
|
55
|
+
const committedRef = (0, external_react_namespaceObject.useRef)(value);
|
|
56
|
+
const caretRef = (0, external_react_namespaceObject.useRef)(null);
|
|
87
57
|
const [datePopoverOpen, setDatePopoverOpen] = (0, external_react_namespaceObject.useState)(false);
|
|
88
58
|
const [selectOpen, setSelectOpen] = (0, external_react_namespaceObject.useState)(false);
|
|
89
59
|
const fieldId = id ?? generatedId;
|
|
90
60
|
const validationId = errorId ?? `${fieldId}-error`;
|
|
91
61
|
const typeMeta = external_types_cjs_namespaceObject.FIELD_TYPE_META[fieldType];
|
|
92
|
-
const effectiveMode = typeMeta.supportsExpression ? mode : '
|
|
62
|
+
const effectiveMode = 'expression' !== mode || typeMeta.supportsExpression ? mode : 'literal';
|
|
93
63
|
const editableOnValueChange = locked ? void 0 : onValueChange;
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
|
|
64
|
+
const typeLabel = strings.typeLabels[fieldType] ?? typeMeta.label;
|
|
65
|
+
const fieldLabel = 'expression' === effectiveMode ? strings.expressionFieldLabel(typeLabel) : strings.valueFieldLabel(typeLabel);
|
|
66
|
+
const valuePlaceholder = placeholder ?? fieldLabel;
|
|
67
|
+
const menuActions = [
|
|
68
|
+
...more?.onClear && !locked ? [
|
|
69
|
+
{
|
|
70
|
+
id: 'clear',
|
|
71
|
+
label: strings.clearValue,
|
|
72
|
+
icon: external_lucide_react_namespaceObject.Trash2,
|
|
73
|
+
onSelect: more.onClear
|
|
74
|
+
}
|
|
75
|
+
] : [],
|
|
76
|
+
...more?.onRefresh ? [
|
|
77
|
+
{
|
|
78
|
+
id: 'refresh',
|
|
79
|
+
label: strings.forceRefresh,
|
|
80
|
+
icon: external_lucide_react_namespaceObject.RefreshCw,
|
|
81
|
+
onSelect: more.onRefresh
|
|
82
|
+
}
|
|
83
|
+
] : []
|
|
84
|
+
];
|
|
85
|
+
const offersModes = typeMeta.supportsExpression && !!onModeChange;
|
|
86
|
+
const showsMenu = typeMeta.supportsExpression || menuActions.length > 0;
|
|
87
|
+
const builtInMenu = showsMenu ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(field_menu_cjs_namespaceObject.FieldMenu, {
|
|
88
|
+
mode: effectiveMode,
|
|
89
|
+
onSelect: (next)=>onModeChange?.(next),
|
|
90
|
+
modesDisabled: !offersModes && menuActions.length > 0,
|
|
91
|
+
disabled: !offersModes && 0 === menuActions.length,
|
|
92
|
+
actions: menuActions,
|
|
93
|
+
triggerLabel: strings.valueModeAriaLabel,
|
|
94
|
+
literalDescription: strings.literalDescriptions[fieldType] ?? typeMeta.fixedDescription,
|
|
95
|
+
strings: {
|
|
96
|
+
literalTitle: strings.literalLabels[fieldType] ?? typeMeta.fixedLabel,
|
|
97
|
+
expressionTitle: strings.expressionLabel,
|
|
98
|
+
expressionDescription: strings.expressionDescription,
|
|
99
|
+
fieldActions: strings.moreActionsAriaLabel
|
|
100
|
+
}
|
|
101
|
+
}) : null;
|
|
102
|
+
const modeControl = renderModeControl?.(mode, {
|
|
103
|
+
id: fieldId,
|
|
104
|
+
value,
|
|
105
|
+
onValueChange: editableOnValueChange,
|
|
106
|
+
onBlur: onValueBlur,
|
|
107
|
+
readOnly: !editableOnValueChange,
|
|
108
|
+
placeholder: valuePlaceholder,
|
|
109
|
+
fieldType,
|
|
110
|
+
'aria-invalid': error ? true : void 0,
|
|
111
|
+
'aria-describedby': error ? validationId : void 0,
|
|
112
|
+
'aria-errormessage': error ? validationId : void 0,
|
|
113
|
+
'data-slot': 'input-group-control'
|
|
114
|
+
}) ?? null;
|
|
115
|
+
const modeOnMount = (0, external_react_namespaceObject.useRef)(mode);
|
|
116
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
117
|
+
if (modeOnMount.current === mode) return;
|
|
118
|
+
modeOnMount.current = mode;
|
|
119
|
+
valueInputRef.current?.focus();
|
|
120
|
+
}, [
|
|
121
|
+
mode
|
|
122
|
+
]);
|
|
123
|
+
const handleValueKeyDown = (e)=>{
|
|
124
|
+
if ('Enter' === e.key) {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
e.currentTarget.blur();
|
|
127
|
+
}
|
|
128
|
+
if ('Escape' === e.key) {
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
onValueChange?.(committedRef.current);
|
|
131
|
+
e.currentTarget.blur();
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const insertVariableAtCaret = (insertText)=>{
|
|
135
|
+
const input = valueInputRef.current;
|
|
136
|
+
const caret = caretRef.current;
|
|
137
|
+
if (!input || !caret) return void onValueChange?.(value ? `${value} ${insertText}` : insertText);
|
|
138
|
+
const start = Math.min(caret.start, value.length);
|
|
139
|
+
const end = Math.min(Math.max(caret.end, start), value.length);
|
|
140
|
+
const next = value.slice(0, start) + insertText + value.slice(end);
|
|
141
|
+
onValueChange?.(next);
|
|
142
|
+
const next_caret = start + insertText.length;
|
|
143
|
+
caretRef.current = {
|
|
144
|
+
start: next_caret,
|
|
145
|
+
end: next_caret
|
|
146
|
+
};
|
|
147
|
+
requestAnimationFrame(()=>{
|
|
148
|
+
input.focus();
|
|
149
|
+
input.setSelectionRange(next_caret, next_caret);
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
const lockedDisplayValue = (0, external_utils_cjs_namespaceObject.getLockedDisplayValue)(fieldType, value, options, strings);
|
|
99
153
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
100
154
|
className: (0, index_cjs_namespaceObject.cn)('@container group flex flex-col gap-1.5 [&>[data-slot=form-field-error]]:mt-0', className),
|
|
101
155
|
children: [
|
|
@@ -105,36 +159,41 @@ function LockableValueField({ value = '', onValueChange, onValueBlur, locked = t
|
|
|
105
159
|
fieldLabel: fieldLabel,
|
|
106
160
|
required: required,
|
|
107
161
|
fieldType: fieldType,
|
|
162
|
+
fieldTypes: fieldTypes,
|
|
108
163
|
onFieldTypeChange: onFieldTypeChange,
|
|
109
164
|
onRequiredChange: onRequiredChange,
|
|
110
165
|
compact: compact,
|
|
111
166
|
showFieldActions: showFieldActions,
|
|
112
|
-
showAiAssist: showAiAssist,
|
|
113
|
-
value: value,
|
|
114
167
|
onValueChange: editableOnValueChange,
|
|
115
168
|
variables: variables,
|
|
116
169
|
onGenerateWithAi: onGenerateWithAi,
|
|
117
|
-
|
|
170
|
+
onInsertVariable: (variable)=>onInsertVariable ? onInsertVariable(variable, {
|
|
171
|
+
value,
|
|
172
|
+
caret: caretRef.current
|
|
173
|
+
}) : insertVariableAtCaret(variable.value),
|
|
174
|
+
headerActions: headerActions,
|
|
175
|
+
strings: strings
|
|
118
176
|
}),
|
|
119
177
|
typeMeta.supportsExpression ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_input_group_cjs_namespaceObject.InputGroup, {
|
|
120
178
|
error: error,
|
|
121
179
|
errorId: validationId,
|
|
122
|
-
|
|
180
|
+
layout: 'file' !== fieldType || locked || 'literal' !== effectiveMode ? 'row' : 'grow',
|
|
123
181
|
children: [
|
|
124
182
|
(showLock || void 0 !== leadingAddon) && null !== leadingAddon && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
125
183
|
align: "inline-start",
|
|
126
184
|
children: void 0 !== leadingAddon ? leadingAddon : showLock && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(lock_toggle_button_cjs_namespaceObject.LockToggleButton, {
|
|
127
185
|
locked: locked,
|
|
128
|
-
onLockedChange: onLockedChange
|
|
186
|
+
onLockedChange: onLockedChange,
|
|
187
|
+
strings: strings
|
|
129
188
|
})
|
|
130
189
|
}),
|
|
131
|
-
'expression' === effectiveMode ? renderExpressionEditor ? renderExpressionEditor({
|
|
190
|
+
modeControl ?? ('expression' === effectiveMode ? renderExpressionEditor ? renderExpressionEditor({
|
|
132
191
|
id: fieldId,
|
|
133
192
|
value,
|
|
134
193
|
onValueChange: editableOnValueChange,
|
|
135
194
|
onBlur: onValueBlur,
|
|
136
195
|
readOnly: !editableOnValueChange,
|
|
137
|
-
placeholder:
|
|
196
|
+
placeholder: valuePlaceholder,
|
|
138
197
|
fieldType,
|
|
139
198
|
'aria-invalid': error ? true : void 0,
|
|
140
199
|
'aria-describedby': error ? validationId : void 0,
|
|
@@ -142,17 +201,39 @@ function LockableValueField({ value = '', onValueChange, onValueBlur, locked = t
|
|
|
142
201
|
'data-slot': 'input-group-control'
|
|
143
202
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
144
203
|
id: fieldId,
|
|
204
|
+
ref: valueInputRef,
|
|
145
205
|
readOnly: !editableOnValueChange,
|
|
146
206
|
value: value,
|
|
147
207
|
onChange: (e)=>editableOnValueChange?.(e.target.value),
|
|
148
|
-
|
|
149
|
-
|
|
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,
|
|
150
231
|
className: "font-mono"
|
|
151
232
|
}) : locked ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
152
233
|
id: fieldId,
|
|
153
234
|
readOnly: true,
|
|
154
235
|
value: lockedDisplayValue,
|
|
155
|
-
placeholder:
|
|
236
|
+
placeholder: valuePlaceholder,
|
|
156
237
|
onBlur: onValueBlur
|
|
157
238
|
}) : 'boolean' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
158
239
|
className: "flex h-full flex-1 items-center px-3",
|
|
@@ -186,7 +267,7 @@ function LockableValueField({ value = '', onValueChange, onValueBlur, locked = t
|
|
|
186
267
|
className: "flex h-full flex-1 items-center text-left text-sm text-foreground outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
187
268
|
children: value ? (0, external_utils_cjs_namespaceObject.formatDateValue)(value) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
188
269
|
className: "text-muted-foreground",
|
|
189
|
-
children:
|
|
270
|
+
children: strings.pickDate
|
|
190
271
|
})
|
|
191
272
|
})
|
|
192
273
|
}),
|
|
@@ -201,6 +282,15 @@ function LockableValueField({ value = '', onValueChange, onValueBlur, locked = t
|
|
|
201
282
|
})
|
|
202
283
|
})
|
|
203
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
|
|
204
294
|
}) : 'file' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_file_upload_cjs_namespaceObject.FileUpload, {
|
|
205
295
|
id: fieldId,
|
|
206
296
|
ariaLabel: fileUploadAriaLabel ?? ('string' == typeof label ? label : fieldLabel),
|
|
@@ -213,76 +303,60 @@ function LockableValueField({ value = '', onValueChange, onValueBlur, locked = t
|
|
|
213
303
|
"aria-errormessage": error ? validationId : void 0
|
|
214
304
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
215
305
|
id: fieldId,
|
|
216
|
-
|
|
306
|
+
ref: valueInputRef,
|
|
307
|
+
type: 'integer' === fieldType || 'double' === fieldType ? 'number' : 'text',
|
|
308
|
+
step: 'double' === fieldType ? 'any' : void 0,
|
|
217
309
|
readOnly: !onValueChange,
|
|
218
310
|
value: value,
|
|
219
311
|
onChange: (e)=>onValueChange?.(e.target.value),
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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, {
|
|
224
337
|
align: "inline-end",
|
|
225
338
|
className: "cursor-default",
|
|
226
|
-
children: void 0 !== trailingAddon ? trailingAddon :
|
|
227
|
-
children: [
|
|
228
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenu, {
|
|
229
|
-
children: [
|
|
230
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuTrigger, {
|
|
231
|
-
asChild: true,
|
|
232
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupButton, {
|
|
233
|
-
icon: true,
|
|
234
|
-
size: "3xs",
|
|
235
|
-
disabled: !onModeChange,
|
|
236
|
-
"aria-label": "Choose value type",
|
|
237
|
-
children: 'expression' === effectiveMode ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Code2, {}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Type, {})
|
|
238
|
-
})
|
|
239
|
-
}),
|
|
240
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuContent, {
|
|
241
|
-
align: "end",
|
|
242
|
-
className: "w-56",
|
|
243
|
-
children: [
|
|
244
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(field_menu_cjs_namespaceObject.ValueModeMenuItem, {
|
|
245
|
-
icon: external_lucide_react_namespaceObject.Type,
|
|
246
|
-
label: typeMeta.fixedLabel,
|
|
247
|
-
description: typeMeta.fixedDescription,
|
|
248
|
-
active: 'fixed' === effectiveMode,
|
|
249
|
-
onClick: ()=>onModeChange?.('fixed')
|
|
250
|
-
}),
|
|
251
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(field_menu_cjs_namespaceObject.ValueModeMenuItem, {
|
|
252
|
-
icon: external_lucide_react_namespaceObject.Code2,
|
|
253
|
-
label: "Expression",
|
|
254
|
-
description: "Use a JS expression",
|
|
255
|
-
active: 'expression' === effectiveMode,
|
|
256
|
-
onClick: ()=>onModeChange?.('expression')
|
|
257
|
-
})
|
|
258
|
-
]
|
|
259
|
-
})
|
|
260
|
-
]
|
|
261
|
-
}),
|
|
262
|
-
hasMoreActions && more && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MoreActionsMenu, {
|
|
263
|
-
more: more,
|
|
264
|
-
locked: locked
|
|
265
|
-
})
|
|
266
|
-
]
|
|
267
|
-
})
|
|
339
|
+
children: void 0 !== trailingAddon ? trailingAddon : builtInMenu
|
|
268
340
|
})
|
|
269
341
|
]
|
|
270
342
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_input_group_cjs_namespaceObject.InputGroup, {
|
|
271
343
|
error: error,
|
|
272
344
|
errorId: validationId,
|
|
345
|
+
layout: 'multi-select' !== fieldType || locked ? 'row' : 'grow',
|
|
273
346
|
children: [
|
|
274
347
|
(showLock || void 0 !== leadingAddon) && null !== leadingAddon && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
275
348
|
align: "inline-start",
|
|
276
349
|
children: void 0 !== leadingAddon ? leadingAddon : showLock && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(lock_toggle_button_cjs_namespaceObject.LockToggleButton, {
|
|
277
350
|
locked: locked,
|
|
278
|
-
onLockedChange: onLockedChange
|
|
351
|
+
onLockedChange: onLockedChange,
|
|
352
|
+
strings: strings
|
|
279
353
|
})
|
|
280
354
|
}),
|
|
281
|
-
locked ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
355
|
+
modeControl ?? (locked ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
282
356
|
id: fieldId,
|
|
283
357
|
readOnly: true,
|
|
284
358
|
value: lockedDisplayValue,
|
|
285
|
-
placeholder:
|
|
359
|
+
placeholder: valuePlaceholder,
|
|
286
360
|
className: "min-w-0",
|
|
287
361
|
onBlur: onValueBlur
|
|
288
362
|
}) : 'single-select' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
|
|
@@ -298,7 +372,7 @@ function LockableValueField({ value = '', onValueChange, onValueBlur, locked = t
|
|
|
298
372
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
|
|
299
373
|
id: fieldId,
|
|
300
374
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {
|
|
301
|
-
placeholder:
|
|
375
|
+
placeholder: strings.selectOption
|
|
302
376
|
})
|
|
303
377
|
}),
|
|
304
378
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
|
|
@@ -313,17 +387,14 @@ function LockableValueField({ value = '', onValueChange, onValueBlur, locked = t
|
|
|
313
387
|
options: options,
|
|
314
388
|
selected: (0, external_utils_cjs_namespaceObject.parseListValue)(value),
|
|
315
389
|
onChange: (selected)=>onValueChange?.(JSON.stringify(selected)),
|
|
316
|
-
placeholder:
|
|
390
|
+
placeholder: strings.selectOptions,
|
|
317
391
|
disabled: !onValueChange,
|
|
318
392
|
onBlur: onValueBlur
|
|
319
|
-
}) : null,
|
|
320
|
-
|
|
393
|
+
}) : null),
|
|
394
|
+
null !== trailingAddon && (void 0 !== trailingAddon || builtInMenu) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
321
395
|
align: "inline-end",
|
|
322
396
|
className: "cursor-default",
|
|
323
|
-
children:
|
|
324
|
-
more: more,
|
|
325
|
-
locked: locked
|
|
326
|
-
})
|
|
397
|
+
children: void 0 !== trailingAddon ? trailingAddon : builtInMenu
|
|
327
398
|
})
|
|
328
399
|
]
|
|
329
400
|
}),
|
|
@@ -331,9 +402,9 @@ function LockableValueField({ value = '', onValueChange, onValueBlur, locked = t
|
|
|
331
402
|
]
|
|
332
403
|
});
|
|
333
404
|
}
|
|
334
|
-
exports.
|
|
405
|
+
exports.QuickFormField = __webpack_exports__.QuickFormField;
|
|
335
406
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
336
|
-
"
|
|
407
|
+
"QuickFormField"
|
|
337
408
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
338
409
|
Object.defineProperty(exports, '__esModule', {
|
|
339
410
|
value: true
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { QuickFormFieldProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A Quick Form is assembled by end users, like a form builder. QuickFormField is
|
|
4
|
+
* the control for an individual field within it, and carries its own
|
|
5
|
+
* configuration controls: a lock that makes it read-only, a data-type switch
|
|
6
|
+
* that swaps the control, a Required toggle, and a value-mode switch across
|
|
7
|
+
* `literal`, `expression`, `variable` and `prompt`.
|
|
8
|
+
*
|
|
9
|
+
* Only use it within a quick form builder. For standard forms, compose the
|
|
10
|
+
* form-field anatomy (`FormField`, `FormFieldLabel`, `InputGroup`, …) or
|
|
11
|
+
* describe them to `MetadataForm`.
|
|
12
|
+
*
|
|
13
|
+
* - Literal and expression have built-in controls; `renderModeControl`
|
|
14
|
+
* supplies the control for any mode, and `variable` / `prompt` need it.
|
|
15
|
+
* - `fieldTypes` chooses which types the picker offers.
|
|
16
|
+
* - Insert variable renders `variables` as supplied and splices at the caret;
|
|
17
|
+
* `onInsertVariable` takes over what inserting means.
|
|
18
|
+
* - Enter commits through `onValueBlur`, Escape restores the value as of focus.
|
|
19
|
+
* - Every user-visible string can be overridden through `strings`.
|
|
20
|
+
*
|
|
21
|
+
* The expression mode is styled as code but not highlighted or evaluated.
|
|
22
|
+
* Select options default to a small demo set unless `options` is provided. The
|
|
23
|
+
* AI-assist button renders only with `onGenerateWithAi`, and file uploads
|
|
24
|
+
* aren't persisted anywhere.
|
|
25
|
+
*/
|
|
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;
|