@uipath/apollo-wind 2.31.1 → 2.32.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/dist/components/custom/panel-flow.cjs +3 -3
- package/dist/components/custom/panel-flow.d.ts +2 -0
- package/dist/components/custom/panel-flow.js +3 -3
- package/dist/components/forms/field-renderer.cjs +4 -1
- package/dist/components/forms/field-renderer.js +4 -1
- package/dist/components/ui/file-upload.cjs +22 -16
- package/dist/components/ui/file-upload.d.ts +19 -1
- package/dist/components/ui/file-upload.js +22 -16
- package/dist/components/ui/index.cjs +24 -24
- package/dist/components/ui/lockable-value-field/components/field-header.cjs +327 -0
- package/dist/components/ui/lockable-value-field/components/field-header.d.ts +19 -0
- package/dist/components/ui/lockable-value-field/components/field-header.js +293 -0
- package/dist/components/ui/lockable-value-field/components/lock-toggle-button.cjs +67 -0
- package/dist/components/ui/lockable-value-field/components/lock-toggle-button.d.ts +9 -0
- package/dist/components/ui/lockable-value-field/components/lock-toggle-button.js +33 -0
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.cjs +63 -0
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.d.ts +9 -0
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.js +29 -0
- package/dist/components/ui/lockable-value-field/index.cjs +43 -0
- package/dist/components/ui/lockable-value-field/index.d.ts +3 -0
- package/dist/components/ui/lockable-value-field/index.js +3 -0
- package/dist/components/ui/lockable-value-field/lockable-value-field.cjs +264 -0
- package/dist/components/ui/lockable-value-field/lockable-value-field.d.ts +14 -0
- package/dist/components/ui/lockable-value-field/lockable-value-field.js +230 -0
- package/dist/components/ui/lockable-value-field/types.cjs +99 -0
- package/dist/components/ui/lockable-value-field/types.d.ts +78 -0
- package/dist/components/ui/lockable-value-field/types.js +62 -0
- package/dist/components/ui/lockable-value-field/utils.cjs +117 -0
- package/dist/components/ui/lockable-value-field/utils.d.ts +24 -0
- package/dist/components/ui/lockable-value-field/utils.js +68 -0
- package/dist/components/ui/multi-select.cjs +7 -3
- package/dist/components/ui/multi-select.d.ts +4 -0
- package/dist/components/ui/multi-select.js +7 -3
- package/dist/index.cjs +28 -18
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/styles.css +665 -0
- package/dist/tailwind.css +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
LockableValueField: ()=>LockableValueField
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
31
|
+
const external_react_namespaceObject = require("react");
|
|
32
|
+
const external_calendar_cjs_namespaceObject = require("../calendar.cjs");
|
|
33
|
+
const external_dropdown_menu_cjs_namespaceObject = require("../dropdown-menu.cjs");
|
|
34
|
+
const external_file_upload_cjs_namespaceObject = require("../file-upload.cjs");
|
|
35
|
+
const external_input_cjs_namespaceObject = require("../input.cjs");
|
|
36
|
+
const external_input_group_cjs_namespaceObject = require("../input-group.cjs");
|
|
37
|
+
const external_multi_select_cjs_namespaceObject = require("../multi-select.cjs");
|
|
38
|
+
const external_popover_cjs_namespaceObject = require("../popover.cjs");
|
|
39
|
+
const external_select_cjs_namespaceObject = require("../select.cjs");
|
|
40
|
+
const external_switch_cjs_namespaceObject = require("../switch.cjs");
|
|
41
|
+
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
42
|
+
const field_header_cjs_namespaceObject = require("./components/field-header.cjs");
|
|
43
|
+
const lock_toggle_button_cjs_namespaceObject = require("./components/lock-toggle-button.cjs");
|
|
44
|
+
const mode_menu_item_cjs_namespaceObject = require("./components/mode-menu-item.cjs");
|
|
45
|
+
const external_types_cjs_namespaceObject = require("./types.cjs");
|
|
46
|
+
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
47
|
+
function LockableValueField({ value = '', onValueChange, onValueBlur, locked = true, onLockedChange, mode = 'fixed', onModeChange, renderExpressionEditor, fieldType = 'string', onFieldTypeChange, required, onRequiredChange, label, fileUploadAriaLabel, headerActions, compact, controlsVisibility = 'visible', showFieldActions = true, options = external_utils_cjs_namespaceObject.DEFAULT_SELECT_OPTIONS, onGenerateWithAi, variables = [], id, className }) {
|
|
48
|
+
const generatedId = (0, external_react_namespaceObject.useId)();
|
|
49
|
+
const [datePopoverOpen, setDatePopoverOpen] = (0, external_react_namespaceObject.useState)(false);
|
|
50
|
+
const [selectOpen, setSelectOpen] = (0, external_react_namespaceObject.useState)(false);
|
|
51
|
+
const fieldId = id ?? generatedId;
|
|
52
|
+
const typeMeta = external_types_cjs_namespaceObject.FIELD_TYPE_META[fieldType];
|
|
53
|
+
const effectiveMode = typeMeta.supportsExpression ? mode : 'fixed';
|
|
54
|
+
const editableOnValueChange = locked ? void 0 : onValueChange;
|
|
55
|
+
const fieldTypeLabel = typeMeta.label.toLowerCase();
|
|
56
|
+
const expressionArticle = /^[aeiou]/.test(fieldTypeLabel) ? 'an' : 'a';
|
|
57
|
+
const fieldLabel = 'expression' === effectiveMode ? `Write ${expressionArticle} ${fieldTypeLabel} expression` : `${typeMeta.label} value`;
|
|
58
|
+
const lockedDisplayValue = (0, external_utils_cjs_namespaceObject.getLockedDisplayValue)(fieldType, value, options);
|
|
59
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
60
|
+
className: (0, index_cjs_namespaceObject.cn)('@container group flex flex-col gap-1.5', className),
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(field_header_cjs_namespaceObject.FieldHeader, {
|
|
63
|
+
label: label,
|
|
64
|
+
fieldId: fieldId,
|
|
65
|
+
fieldLabel: fieldLabel,
|
|
66
|
+
required: required,
|
|
67
|
+
fieldType: fieldType,
|
|
68
|
+
onFieldTypeChange: onFieldTypeChange,
|
|
69
|
+
onRequiredChange: onRequiredChange,
|
|
70
|
+
controlsVisibility: controlsVisibility,
|
|
71
|
+
compact: compact,
|
|
72
|
+
showFieldActions: showFieldActions,
|
|
73
|
+
value: value,
|
|
74
|
+
onValueChange: editableOnValueChange,
|
|
75
|
+
variables: variables,
|
|
76
|
+
onGenerateWithAi: onGenerateWithAi,
|
|
77
|
+
headerActions: headerActions
|
|
78
|
+
}),
|
|
79
|
+
typeMeta.supportsExpression ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_input_group_cjs_namespaceObject.InputGroup, {
|
|
80
|
+
children: [
|
|
81
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
82
|
+
align: "inline-start",
|
|
83
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(lock_toggle_button_cjs_namespaceObject.LockToggleButton, {
|
|
84
|
+
locked: locked,
|
|
85
|
+
onLockedChange: onLockedChange
|
|
86
|
+
})
|
|
87
|
+
}),
|
|
88
|
+
'expression' === effectiveMode ? renderExpressionEditor ? renderExpressionEditor({
|
|
89
|
+
id: fieldId,
|
|
90
|
+
value,
|
|
91
|
+
onValueChange: editableOnValueChange,
|
|
92
|
+
onBlur: onValueBlur,
|
|
93
|
+
readOnly: !editableOnValueChange,
|
|
94
|
+
placeholder: fieldLabel,
|
|
95
|
+
fieldType
|
|
96
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
97
|
+
id: fieldId,
|
|
98
|
+
readOnly: !editableOnValueChange,
|
|
99
|
+
value: value,
|
|
100
|
+
onChange: (e)=>editableOnValueChange?.(e.target.value),
|
|
101
|
+
onBlur: onValueBlur,
|
|
102
|
+
placeholder: fieldLabel,
|
|
103
|
+
className: "font-mono"
|
|
104
|
+
}) : locked ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
105
|
+
id: fieldId,
|
|
106
|
+
readOnly: true,
|
|
107
|
+
value: lockedDisplayValue,
|
|
108
|
+
placeholder: fieldLabel,
|
|
109
|
+
onBlur: onValueBlur
|
|
110
|
+
}) : 'boolean' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
111
|
+
className: "flex h-full flex-1 items-center px-3",
|
|
112
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_switch_cjs_namespaceObject.Switch, {
|
|
113
|
+
id: fieldId,
|
|
114
|
+
checked: 'true' === value,
|
|
115
|
+
onCheckedChange: (checked)=>onValueChange?.(String(checked)),
|
|
116
|
+
onBlur: onValueBlur,
|
|
117
|
+
disabled: !onValueChange
|
|
118
|
+
})
|
|
119
|
+
}) : 'date' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
120
|
+
open: datePopoverOpen,
|
|
121
|
+
onOpenChange: (open)=>{
|
|
122
|
+
setDatePopoverOpen(open);
|
|
123
|
+
if (!open) onValueBlur?.();
|
|
124
|
+
},
|
|
125
|
+
children: [
|
|
126
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
127
|
+
asChild: true,
|
|
128
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
129
|
+
type: "button",
|
|
130
|
+
id: fieldId,
|
|
131
|
+
"data-slot": "input-group-control",
|
|
132
|
+
disabled: !onValueChange,
|
|
133
|
+
className: "flex h-full flex-1 items-center text-left text-sm text-foreground outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
134
|
+
children: value ? (0, external_utils_cjs_namespaceObject.formatDateValue)(value) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
135
|
+
className: "text-muted-foreground",
|
|
136
|
+
children: "Pick a date"
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
}),
|
|
140
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent, {
|
|
141
|
+
align: "start",
|
|
142
|
+
className: "w-auto p-0",
|
|
143
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_calendar_cjs_namespaceObject.Calendar, {
|
|
144
|
+
mode: "single",
|
|
145
|
+
selected: (0, external_utils_cjs_namespaceObject.parseDateValue)(value),
|
|
146
|
+
onSelect: (date)=>onValueChange?.(date ? (0, external_utils_cjs_namespaceObject.toDateOnlyString)(date) : ''),
|
|
147
|
+
initialFocus: true
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
]
|
|
151
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupInput, {
|
|
152
|
+
id: fieldId,
|
|
153
|
+
type: 'integer' === fieldType ? 'number' : 'text',
|
|
154
|
+
readOnly: !onValueChange,
|
|
155
|
+
value: value,
|
|
156
|
+
onChange: (e)=>onValueChange?.(e.target.value),
|
|
157
|
+
onBlur: onValueBlur,
|
|
158
|
+
placeholder: fieldLabel
|
|
159
|
+
}),
|
|
160
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
161
|
+
align: "inline-end",
|
|
162
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenu, {
|
|
163
|
+
children: [
|
|
164
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuTrigger, {
|
|
165
|
+
asChild: true,
|
|
166
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupButton, {
|
|
167
|
+
icon: true,
|
|
168
|
+
size: "3xs",
|
|
169
|
+
disabled: !onModeChange,
|
|
170
|
+
"aria-label": "Choose value type",
|
|
171
|
+
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, {})
|
|
172
|
+
})
|
|
173
|
+
}),
|
|
174
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuContent, {
|
|
175
|
+
align: "end",
|
|
176
|
+
className: "w-56",
|
|
177
|
+
children: [
|
|
178
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(mode_menu_item_cjs_namespaceObject.ModeMenuItem, {
|
|
179
|
+
icon: external_lucide_react_namespaceObject.Type,
|
|
180
|
+
label: typeMeta.fixedLabel,
|
|
181
|
+
description: typeMeta.fixedDescription,
|
|
182
|
+
active: 'fixed' === effectiveMode,
|
|
183
|
+
onClick: ()=>onModeChange?.('fixed')
|
|
184
|
+
}),
|
|
185
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(mode_menu_item_cjs_namespaceObject.ModeMenuItem, {
|
|
186
|
+
icon: external_lucide_react_namespaceObject.Code2,
|
|
187
|
+
label: "Expression",
|
|
188
|
+
description: "Use a JS expression",
|
|
189
|
+
active: 'expression' === effectiveMode,
|
|
190
|
+
onClick: ()=>onModeChange?.('expression')
|
|
191
|
+
})
|
|
192
|
+
]
|
|
193
|
+
})
|
|
194
|
+
]
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
]
|
|
198
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
199
|
+
className: "flex items-center gap-2",
|
|
200
|
+
children: [
|
|
201
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(lock_toggle_button_cjs_namespaceObject.LockToggleButton, {
|
|
202
|
+
locked: locked,
|
|
203
|
+
onLockedChange: onLockedChange
|
|
204
|
+
}),
|
|
205
|
+
locked ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_cjs_namespaceObject.Input, {
|
|
206
|
+
id: fieldId,
|
|
207
|
+
readOnly: true,
|
|
208
|
+
value: lockedDisplayValue,
|
|
209
|
+
placeholder: fieldLabel,
|
|
210
|
+
className: "flex-1",
|
|
211
|
+
onBlur: onValueBlur
|
|
212
|
+
}) : 'single-select' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
|
|
213
|
+
open: selectOpen,
|
|
214
|
+
onOpenChange: (open)=>{
|
|
215
|
+
setSelectOpen(open);
|
|
216
|
+
if (!open && selectOpen) onValueBlur?.();
|
|
217
|
+
},
|
|
218
|
+
value: value || void 0,
|
|
219
|
+
onValueChange: onValueChange,
|
|
220
|
+
disabled: !onValueChange,
|
|
221
|
+
children: [
|
|
222
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
|
|
223
|
+
id: fieldId,
|
|
224
|
+
className: "flex-1",
|
|
225
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {
|
|
226
|
+
placeholder: "Select an option"
|
|
227
|
+
})
|
|
228
|
+
}),
|
|
229
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
|
|
230
|
+
children: options.map((option)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
|
|
231
|
+
value: option.value,
|
|
232
|
+
children: option.label
|
|
233
|
+
}, option.value))
|
|
234
|
+
})
|
|
235
|
+
]
|
|
236
|
+
}) : 'multi-select' === fieldType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_multi_select_cjs_namespaceObject.MultiSelect, {
|
|
237
|
+
id: fieldId,
|
|
238
|
+
className: "flex-1",
|
|
239
|
+
options: options,
|
|
240
|
+
selected: (0, external_utils_cjs_namespaceObject.parseListValue)(value),
|
|
241
|
+
onChange: (selected)=>onValueChange?.(JSON.stringify(selected)),
|
|
242
|
+
placeholder: "Select options...",
|
|
243
|
+
disabled: !onValueChange,
|
|
244
|
+
onBlur: onValueBlur
|
|
245
|
+
}) : 'file' === fieldType && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_file_upload_cjs_namespaceObject.FileUpload, {
|
|
246
|
+
id: fieldId,
|
|
247
|
+
ariaLabel: fileUploadAriaLabel ?? ('string' == typeof label ? label : fieldLabel),
|
|
248
|
+
className: "flex-1",
|
|
249
|
+
onFilesChange: (files)=>onValueChange?.(files.map((f)=>f.name).join(', ')),
|
|
250
|
+
disabled: !onValueChange,
|
|
251
|
+
onBlur: onValueBlur
|
|
252
|
+
})
|
|
253
|
+
]
|
|
254
|
+
})
|
|
255
|
+
]
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
exports.LockableValueField = __webpack_exports__.LockableValueField;
|
|
259
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
260
|
+
"LockableValueField"
|
|
261
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
262
|
+
Object.defineProperty(exports, '__esModule', {
|
|
263
|
+
value: true
|
|
264
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LockableValueFieldProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* LockableValueField — a field that can be locked to read-only, typed as one
|
|
4
|
+
* of several data types, and (for scalar types) switched between a literal
|
|
5
|
+
* value and a JS expression.
|
|
6
|
+
*
|
|
7
|
+
* The expression mode is styled as code (monospace) but does not carry real
|
|
8
|
+
* syntax highlighting or evaluation. Select/multiselect options default to a
|
|
9
|
+
* small demo set unless `options` is provided. The built-in AI-assist
|
|
10
|
+
* "Generate" button is a no-op unless `onGenerateWithAi` is provided; the
|
|
11
|
+
* Insert-variable menu is empty (and disabled) unless `variables` is
|
|
12
|
+
* provided; file uploads aren't persisted anywhere.
|
|
13
|
+
*/
|
|
14
|
+
export declare function LockableValueField({ value, onValueChange, onValueBlur, locked, onLockedChange, mode, onModeChange, renderExpressionEditor, fieldType, onFieldTypeChange, required, onRequiredChange, label, fileUploadAriaLabel, headerActions, compact, controlsVisibility, showFieldActions, options, onGenerateWithAi, variables, id, className, }: LockableValueFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Code2, Type } from "lucide-react";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { Calendar } from "../calendar.js";
|
|
5
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from "../dropdown-menu.js";
|
|
6
|
+
import { FileUpload } from "../file-upload.js";
|
|
7
|
+
import { Input } from "../input.js";
|
|
8
|
+
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "../input-group.js";
|
|
9
|
+
import { MultiSelect } from "../multi-select.js";
|
|
10
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../popover.js";
|
|
11
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../select.js";
|
|
12
|
+
import { Switch } from "../switch.js";
|
|
13
|
+
import { cn } from "../../../lib/index.js";
|
|
14
|
+
import { FieldHeader } from "./components/field-header.js";
|
|
15
|
+
import { LockToggleButton } from "./components/lock-toggle-button.js";
|
|
16
|
+
import { ModeMenuItem } from "./components/mode-menu-item.js";
|
|
17
|
+
import { FIELD_TYPE_META } from "./types.js";
|
|
18
|
+
import { DEFAULT_SELECT_OPTIONS, formatDateValue, getLockedDisplayValue, parseDateValue, parseListValue, toDateOnlyString } from "./utils.js";
|
|
19
|
+
function LockableValueField({ value = '', onValueChange, onValueBlur, locked = true, onLockedChange, mode = 'fixed', onModeChange, renderExpressionEditor, fieldType = 'string', onFieldTypeChange, required, onRequiredChange, label, fileUploadAriaLabel, headerActions, compact, controlsVisibility = 'visible', showFieldActions = true, options = DEFAULT_SELECT_OPTIONS, onGenerateWithAi, variables = [], id, className }) {
|
|
20
|
+
const generatedId = useId();
|
|
21
|
+
const [datePopoverOpen, setDatePopoverOpen] = useState(false);
|
|
22
|
+
const [selectOpen, setSelectOpen] = useState(false);
|
|
23
|
+
const fieldId = id ?? generatedId;
|
|
24
|
+
const typeMeta = FIELD_TYPE_META[fieldType];
|
|
25
|
+
const effectiveMode = typeMeta.supportsExpression ? mode : 'fixed';
|
|
26
|
+
const editableOnValueChange = locked ? void 0 : onValueChange;
|
|
27
|
+
const fieldTypeLabel = typeMeta.label.toLowerCase();
|
|
28
|
+
const expressionArticle = /^[aeiou]/.test(fieldTypeLabel) ? 'an' : 'a';
|
|
29
|
+
const fieldLabel = 'expression' === effectiveMode ? `Write ${expressionArticle} ${fieldTypeLabel} expression` : `${typeMeta.label} value`;
|
|
30
|
+
const lockedDisplayValue = getLockedDisplayValue(fieldType, value, options);
|
|
31
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
32
|
+
className: cn('@container group flex flex-col gap-1.5', className),
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ jsx(FieldHeader, {
|
|
35
|
+
label: label,
|
|
36
|
+
fieldId: fieldId,
|
|
37
|
+
fieldLabel: fieldLabel,
|
|
38
|
+
required: required,
|
|
39
|
+
fieldType: fieldType,
|
|
40
|
+
onFieldTypeChange: onFieldTypeChange,
|
|
41
|
+
onRequiredChange: onRequiredChange,
|
|
42
|
+
controlsVisibility: controlsVisibility,
|
|
43
|
+
compact: compact,
|
|
44
|
+
showFieldActions: showFieldActions,
|
|
45
|
+
value: value,
|
|
46
|
+
onValueChange: editableOnValueChange,
|
|
47
|
+
variables: variables,
|
|
48
|
+
onGenerateWithAi: onGenerateWithAi,
|
|
49
|
+
headerActions: headerActions
|
|
50
|
+
}),
|
|
51
|
+
typeMeta.supportsExpression ? /*#__PURE__*/ jsxs(InputGroup, {
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ jsx(InputGroupAddon, {
|
|
54
|
+
align: "inline-start",
|
|
55
|
+
children: /*#__PURE__*/ jsx(LockToggleButton, {
|
|
56
|
+
locked: locked,
|
|
57
|
+
onLockedChange: onLockedChange
|
|
58
|
+
})
|
|
59
|
+
}),
|
|
60
|
+
'expression' === effectiveMode ? renderExpressionEditor ? renderExpressionEditor({
|
|
61
|
+
id: fieldId,
|
|
62
|
+
value,
|
|
63
|
+
onValueChange: editableOnValueChange,
|
|
64
|
+
onBlur: onValueBlur,
|
|
65
|
+
readOnly: !editableOnValueChange,
|
|
66
|
+
placeholder: fieldLabel,
|
|
67
|
+
fieldType
|
|
68
|
+
}) : /*#__PURE__*/ jsx(InputGroupInput, {
|
|
69
|
+
id: fieldId,
|
|
70
|
+
readOnly: !editableOnValueChange,
|
|
71
|
+
value: value,
|
|
72
|
+
onChange: (e)=>editableOnValueChange?.(e.target.value),
|
|
73
|
+
onBlur: onValueBlur,
|
|
74
|
+
placeholder: fieldLabel,
|
|
75
|
+
className: "font-mono"
|
|
76
|
+
}) : locked ? /*#__PURE__*/ jsx(InputGroupInput, {
|
|
77
|
+
id: fieldId,
|
|
78
|
+
readOnly: true,
|
|
79
|
+
value: lockedDisplayValue,
|
|
80
|
+
placeholder: fieldLabel,
|
|
81
|
+
onBlur: onValueBlur
|
|
82
|
+
}) : 'boolean' === fieldType ? /*#__PURE__*/ jsx("div", {
|
|
83
|
+
className: "flex h-full flex-1 items-center px-3",
|
|
84
|
+
children: /*#__PURE__*/ jsx(Switch, {
|
|
85
|
+
id: fieldId,
|
|
86
|
+
checked: 'true' === value,
|
|
87
|
+
onCheckedChange: (checked)=>onValueChange?.(String(checked)),
|
|
88
|
+
onBlur: onValueBlur,
|
|
89
|
+
disabled: !onValueChange
|
|
90
|
+
})
|
|
91
|
+
}) : 'date' === fieldType ? /*#__PURE__*/ jsxs(Popover, {
|
|
92
|
+
open: datePopoverOpen,
|
|
93
|
+
onOpenChange: (open)=>{
|
|
94
|
+
setDatePopoverOpen(open);
|
|
95
|
+
if (!open) onValueBlur?.();
|
|
96
|
+
},
|
|
97
|
+
children: [
|
|
98
|
+
/*#__PURE__*/ jsx(PopoverTrigger, {
|
|
99
|
+
asChild: true,
|
|
100
|
+
children: /*#__PURE__*/ jsx("button", {
|
|
101
|
+
type: "button",
|
|
102
|
+
id: fieldId,
|
|
103
|
+
"data-slot": "input-group-control",
|
|
104
|
+
disabled: !onValueChange,
|
|
105
|
+
className: "flex h-full flex-1 items-center text-left text-sm text-foreground outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
106
|
+
children: value ? formatDateValue(value) : /*#__PURE__*/ jsx("span", {
|
|
107
|
+
className: "text-muted-foreground",
|
|
108
|
+
children: "Pick a date"
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ jsx(PopoverContent, {
|
|
113
|
+
align: "start",
|
|
114
|
+
className: "w-auto p-0",
|
|
115
|
+
children: /*#__PURE__*/ jsx(Calendar, {
|
|
116
|
+
mode: "single",
|
|
117
|
+
selected: parseDateValue(value),
|
|
118
|
+
onSelect: (date)=>onValueChange?.(date ? toDateOnlyString(date) : ''),
|
|
119
|
+
initialFocus: true
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
}) : /*#__PURE__*/ jsx(InputGroupInput, {
|
|
124
|
+
id: fieldId,
|
|
125
|
+
type: 'integer' === fieldType ? 'number' : 'text',
|
|
126
|
+
readOnly: !onValueChange,
|
|
127
|
+
value: value,
|
|
128
|
+
onChange: (e)=>onValueChange?.(e.target.value),
|
|
129
|
+
onBlur: onValueBlur,
|
|
130
|
+
placeholder: fieldLabel
|
|
131
|
+
}),
|
|
132
|
+
/*#__PURE__*/ jsx(InputGroupAddon, {
|
|
133
|
+
align: "inline-end",
|
|
134
|
+
children: /*#__PURE__*/ jsxs(DropdownMenu, {
|
|
135
|
+
children: [
|
|
136
|
+
/*#__PURE__*/ jsx(DropdownMenuTrigger, {
|
|
137
|
+
asChild: true,
|
|
138
|
+
children: /*#__PURE__*/ jsx(InputGroupButton, {
|
|
139
|
+
icon: true,
|
|
140
|
+
size: "3xs",
|
|
141
|
+
disabled: !onModeChange,
|
|
142
|
+
"aria-label": "Choose value type",
|
|
143
|
+
children: 'expression' === effectiveMode ? /*#__PURE__*/ jsx(Code2, {}) : /*#__PURE__*/ jsx(Type, {})
|
|
144
|
+
})
|
|
145
|
+
}),
|
|
146
|
+
/*#__PURE__*/ jsxs(DropdownMenuContent, {
|
|
147
|
+
align: "end",
|
|
148
|
+
className: "w-56",
|
|
149
|
+
children: [
|
|
150
|
+
/*#__PURE__*/ jsx(ModeMenuItem, {
|
|
151
|
+
icon: Type,
|
|
152
|
+
label: typeMeta.fixedLabel,
|
|
153
|
+
description: typeMeta.fixedDescription,
|
|
154
|
+
active: 'fixed' === effectiveMode,
|
|
155
|
+
onClick: ()=>onModeChange?.('fixed')
|
|
156
|
+
}),
|
|
157
|
+
/*#__PURE__*/ jsx(ModeMenuItem, {
|
|
158
|
+
icon: Code2,
|
|
159
|
+
label: "Expression",
|
|
160
|
+
description: "Use a JS expression",
|
|
161
|
+
active: 'expression' === effectiveMode,
|
|
162
|
+
onClick: ()=>onModeChange?.('expression')
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
})
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
}) : /*#__PURE__*/ jsxs("div", {
|
|
171
|
+
className: "flex items-center gap-2",
|
|
172
|
+
children: [
|
|
173
|
+
/*#__PURE__*/ jsx(LockToggleButton, {
|
|
174
|
+
locked: locked,
|
|
175
|
+
onLockedChange: onLockedChange
|
|
176
|
+
}),
|
|
177
|
+
locked ? /*#__PURE__*/ jsx(Input, {
|
|
178
|
+
id: fieldId,
|
|
179
|
+
readOnly: true,
|
|
180
|
+
value: lockedDisplayValue,
|
|
181
|
+
placeholder: fieldLabel,
|
|
182
|
+
className: "flex-1",
|
|
183
|
+
onBlur: onValueBlur
|
|
184
|
+
}) : 'single-select' === fieldType ? /*#__PURE__*/ jsxs(Select, {
|
|
185
|
+
open: selectOpen,
|
|
186
|
+
onOpenChange: (open)=>{
|
|
187
|
+
setSelectOpen(open);
|
|
188
|
+
if (!open && selectOpen) onValueBlur?.();
|
|
189
|
+
},
|
|
190
|
+
value: value || void 0,
|
|
191
|
+
onValueChange: onValueChange,
|
|
192
|
+
disabled: !onValueChange,
|
|
193
|
+
children: [
|
|
194
|
+
/*#__PURE__*/ jsx(SelectTrigger, {
|
|
195
|
+
id: fieldId,
|
|
196
|
+
className: "flex-1",
|
|
197
|
+
children: /*#__PURE__*/ jsx(SelectValue, {
|
|
198
|
+
placeholder: "Select an option"
|
|
199
|
+
})
|
|
200
|
+
}),
|
|
201
|
+
/*#__PURE__*/ jsx(SelectContent, {
|
|
202
|
+
children: options.map((option)=>/*#__PURE__*/ jsx(SelectItem, {
|
|
203
|
+
value: option.value,
|
|
204
|
+
children: option.label
|
|
205
|
+
}, option.value))
|
|
206
|
+
})
|
|
207
|
+
]
|
|
208
|
+
}) : 'multi-select' === fieldType ? /*#__PURE__*/ jsx(MultiSelect, {
|
|
209
|
+
id: fieldId,
|
|
210
|
+
className: "flex-1",
|
|
211
|
+
options: options,
|
|
212
|
+
selected: parseListValue(value),
|
|
213
|
+
onChange: (selected)=>onValueChange?.(JSON.stringify(selected)),
|
|
214
|
+
placeholder: "Select options...",
|
|
215
|
+
disabled: !onValueChange,
|
|
216
|
+
onBlur: onValueBlur
|
|
217
|
+
}) : 'file' === fieldType && /*#__PURE__*/ jsx(FileUpload, {
|
|
218
|
+
id: fieldId,
|
|
219
|
+
ariaLabel: fileUploadAriaLabel ?? ('string' == typeof label ? label : fieldLabel),
|
|
220
|
+
className: "flex-1",
|
|
221
|
+
onFilesChange: (files)=>onValueChange?.(files.map((f)=>f.name).join(', ')),
|
|
222
|
+
disabled: !onValueChange,
|
|
223
|
+
onBlur: onValueBlur
|
|
224
|
+
})
|
|
225
|
+
]
|
|
226
|
+
})
|
|
227
|
+
]
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
export { LockableValueField };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
FIELD_TYPE_ORDER: ()=>FIELD_TYPE_ORDER,
|
|
28
|
+
FIELD_TYPE_META: ()=>FIELD_TYPE_META
|
|
29
|
+
});
|
|
30
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
31
|
+
const FIELD_TYPE_META = {
|
|
32
|
+
string: {
|
|
33
|
+
label: 'String',
|
|
34
|
+
icon: external_lucide_react_namespaceObject.ALargeSmall,
|
|
35
|
+
supportsExpression: true,
|
|
36
|
+
fixedLabel: 'Fixed value',
|
|
37
|
+
fixedDescription: 'Use a literal string value'
|
|
38
|
+
},
|
|
39
|
+
integer: {
|
|
40
|
+
label: 'Integer',
|
|
41
|
+
icon: external_lucide_react_namespaceObject.Hash,
|
|
42
|
+
supportsExpression: true,
|
|
43
|
+
fixedLabel: 'Fixed value',
|
|
44
|
+
fixedDescription: 'Use a literal number value'
|
|
45
|
+
},
|
|
46
|
+
date: {
|
|
47
|
+
label: 'Date',
|
|
48
|
+
icon: external_lucide_react_namespaceObject.Calendar,
|
|
49
|
+
supportsExpression: true,
|
|
50
|
+
fixedLabel: 'Fixed date',
|
|
51
|
+
fixedDescription: 'Use a literal date value'
|
|
52
|
+
},
|
|
53
|
+
boolean: {
|
|
54
|
+
label: 'Boolean',
|
|
55
|
+
icon: external_lucide_react_namespaceObject.ToggleLeft,
|
|
56
|
+
supportsExpression: true,
|
|
57
|
+
fixedLabel: 'Fixed value',
|
|
58
|
+
fixedDescription: 'Use a literal true or false value'
|
|
59
|
+
},
|
|
60
|
+
'single-select': {
|
|
61
|
+
label: 'Single select',
|
|
62
|
+
icon: external_lucide_react_namespaceObject.List,
|
|
63
|
+
supportsExpression: false,
|
|
64
|
+
fixedLabel: 'Fixed value',
|
|
65
|
+
fixedDescription: 'Choose one option'
|
|
66
|
+
},
|
|
67
|
+
'multi-select': {
|
|
68
|
+
label: 'Multi select',
|
|
69
|
+
icon: external_lucide_react_namespaceObject.ListChecks,
|
|
70
|
+
supportsExpression: false,
|
|
71
|
+
fixedLabel: 'Fixed value',
|
|
72
|
+
fixedDescription: 'Choose one or more options'
|
|
73
|
+
},
|
|
74
|
+
file: {
|
|
75
|
+
label: 'File',
|
|
76
|
+
icon: external_lucide_react_namespaceObject.File,
|
|
77
|
+
supportsExpression: false,
|
|
78
|
+
fixedLabel: 'Fixed value',
|
|
79
|
+
fixedDescription: 'Upload a file'
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const FIELD_TYPE_ORDER = [
|
|
83
|
+
'string',
|
|
84
|
+
'integer',
|
|
85
|
+
'date',
|
|
86
|
+
'boolean',
|
|
87
|
+
'single-select',
|
|
88
|
+
'multi-select',
|
|
89
|
+
'file'
|
|
90
|
+
];
|
|
91
|
+
exports.FIELD_TYPE_META = __webpack_exports__.FIELD_TYPE_META;
|
|
92
|
+
exports.FIELD_TYPE_ORDER = __webpack_exports__.FIELD_TYPE_ORDER;
|
|
93
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
94
|
+
"FIELD_TYPE_META",
|
|
95
|
+
"FIELD_TYPE_ORDER"
|
|
96
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
97
|
+
Object.defineProperty(exports, '__esModule', {
|
|
98
|
+
value: true
|
|
99
|
+
});
|