@uipath/apollo-wind 2.55.0 → 2.56.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/ui/index.cjs +106 -96
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/components/ui/model-picker/ModelPicker.cjs +495 -0
- package/dist/components/ui/model-picker/ModelPicker.d.ts +304 -0
- package/dist/components/ui/model-picker/ModelPicker.js +451 -0
- package/dist/components/ui/model-picker/ModelTagChip.cjs +101 -0
- package/dist/components/ui/model-picker/ModelTagChip.d.ts +29 -0
- package/dist/components/ui/model-picker/ModelTagChip.js +67 -0
- package/dist/components/ui/model-picker/badges.cjs +52 -0
- package/dist/components/ui/model-picker/badges.d.ts +41 -0
- package/dist/components/ui/model-picker/badges.js +18 -0
- package/dist/components/ui/model-picker/index.cjs +117 -0
- package/dist/components/ui/model-picker/index.d.ts +27 -0
- package/dist/components/ui/model-picker/index.js +14 -0
- package/dist/components/ui/model-picker/labels.cjs +107 -0
- package/dist/components/ui/model-picker/labels.d.ts +81 -0
- package/dist/components/ui/model-picker/labels.js +67 -0
- package/dist/components/ui/model-picker/primitives/FolderSwitcher.cjs +108 -0
- package/dist/components/ui/model-picker/primitives/FolderSwitcher.d.ts +38 -0
- package/dist/components/ui/model-picker/primitives/FolderSwitcher.js +74 -0
- package/dist/components/ui/model-picker/primitives/GroupHeader.cjs +84 -0
- package/dist/components/ui/model-picker/primitives/GroupHeader.d.ts +64 -0
- package/dist/components/ui/model-picker/primitives/GroupHeader.js +50 -0
- package/dist/components/ui/model-picker/primitives/ModelOptionRow.cjs +178 -0
- package/dist/components/ui/model-picker/primitives/ModelOptionRow.d.ts +95 -0
- package/dist/components/ui/model-picker/primitives/ModelOptionRow.js +135 -0
- package/dist/components/ui/model-picker/primitives/OptionList.cjs +295 -0
- package/dist/components/ui/model-picker/primitives/OptionList.d.ts +87 -0
- package/dist/components/ui/model-picker/primitives/OptionList.js +242 -0
- package/dist/components/ui/model-picker/primitives/PickerPopup.cjs +64 -0
- package/dist/components/ui/model-picker/primitives/PickerPopup.d.ts +39 -0
- package/dist/components/ui/model-picker/primitives/PickerPopup.js +30 -0
- package/dist/components/ui/model-picker/primitives/PickerSearchInput.cjs +77 -0
- package/dist/components/ui/model-picker/primitives/PickerSearchInput.d.ts +43 -0
- package/dist/components/ui/model-picker/primitives/PickerSearchInput.js +43 -0
- package/dist/components/ui/model-picker/primitives/PickerTrigger.cjs +112 -0
- package/dist/components/ui/model-picker/primitives/PickerTrigger.d.ts +73 -0
- package/dist/components/ui/model-picker/primitives/PickerTrigger.js +78 -0
- package/dist/components/ui/model-picker/types.cjs +18 -0
- package/dist/components/ui/model-picker/types.d.ts +154 -0
- package/dist/components/ui/model-picker/types.js +0 -0
- package/dist/components/ui/model-picker/useModelPickerState.cjs +250 -0
- package/dist/components/ui/model-picker/useModelPickerState.d.ts +135 -0
- package/dist/components/ui/model-picker/useModelPickerState.js +216 -0
- package/dist/components/ui/model-picker/utils.cjs +327 -0
- package/dist/components/ui/model-picker/utils.d.ts +121 -0
- package/dist/components/ui/model-picker/utils.js +272 -0
- package/dist/index.cjs +83 -10
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/styles.css +108 -0
- package/package.json +2 -1
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.n = (module)=>{
|
|
6
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
7
|
+
__webpack_require__.d(getter, {
|
|
8
|
+
a: getter
|
|
9
|
+
});
|
|
10
|
+
return getter;
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
(()=>{
|
|
14
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
15
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: definition[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
})();
|
|
21
|
+
(()=>{
|
|
22
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.r = (exports1)=>{
|
|
26
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
27
|
+
value: 'Module'
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
30
|
+
value: true
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
34
|
+
var __webpack_exports__ = {};
|
|
35
|
+
__webpack_require__.r(__webpack_exports__);
|
|
36
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
37
|
+
ModelPicker: ()=>ModelPicker_ModelPicker
|
|
38
|
+
});
|
|
39
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
40
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
41
|
+
const external_react_namespaceObject = require("react");
|
|
42
|
+
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
43
|
+
const external_alert_dialog_cjs_namespaceObject = require("../alert-dialog.cjs");
|
|
44
|
+
const external_form_field_cjs_namespaceObject = require("../form-field.cjs");
|
|
45
|
+
const external_popover_cjs_namespaceObject = require("../popover.cjs");
|
|
46
|
+
const external_spinner_cjs_namespaceObject = require("../spinner.cjs");
|
|
47
|
+
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
48
|
+
const external_labels_cjs_namespaceObject = require("./labels.cjs");
|
|
49
|
+
const FolderSwitcher_cjs_namespaceObject = require("./primitives/FolderSwitcher.cjs");
|
|
50
|
+
const ModelOptionRow_cjs_namespaceObject = require("./primitives/ModelOptionRow.cjs");
|
|
51
|
+
const OptionList_cjs_namespaceObject = require("./primitives/OptionList.cjs");
|
|
52
|
+
const PickerPopup_cjs_namespaceObject = require("./primitives/PickerPopup.cjs");
|
|
53
|
+
const PickerSearchInput_cjs_namespaceObject = require("./primitives/PickerSearchInput.cjs");
|
|
54
|
+
const PickerTrigger_cjs_namespaceObject = require("./primitives/PickerTrigger.cjs");
|
|
55
|
+
const external_useModelPickerState_cjs_namespaceObject = require("./useModelPickerState.cjs");
|
|
56
|
+
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
57
|
+
const AUTO_VIRTUALIZE_THRESHOLD = 120;
|
|
58
|
+
const ModelPicker_ModelPicker = /*#__PURE__*/ external_react_default().forwardRef(function({ models, value, valueConnectionId, onChange, label, ariaLabel, required, placeholder, disabled, invalid, errorText, variant = 'searchable', groupBy = "subscription", allowGroupingChange = true, homeRegion, recommendedModelIds, previewModelIds, filter, badgesFor, customTagsFor, customTagVariants, canManageByo, onUseCustomModel, folders, folder: folderProp, onFolderChange, allFoldersLabel, loading, error, showGroupHeaders = true, popupContainer, onDeleteModel, onEditModel, labels: labelOverrides, slots, testId }, forwardedRef) {
|
|
59
|
+
const labels = external_react_default().useMemo(()=>(0, external_labels_cjs_namespaceObject.resolveLabels)(labelOverrides), [
|
|
60
|
+
labelOverrides
|
|
61
|
+
]);
|
|
62
|
+
const defaultLabel = labels.fieldLabel;
|
|
63
|
+
const resolvedLabel = label ?? defaultLabel;
|
|
64
|
+
const labelHidden = null === label;
|
|
65
|
+
const resolvedPlaceholder = placeholder ?? labels.placeholder;
|
|
66
|
+
const initiallyCollapsedGroups = external_react_default().useMemo(()=>[], []);
|
|
67
|
+
const [internalFolder, setInternalFolder] = external_react_default().useState(null);
|
|
68
|
+
const folderIsControlled = void 0 !== folderProp;
|
|
69
|
+
const folder = folderIsControlled ? folderProp : internalFolder;
|
|
70
|
+
const handleFolderChange = external_react_default().useCallback((next)=>{
|
|
71
|
+
if (!folderIsControlled) setInternalFolder(next);
|
|
72
|
+
onFolderChange?.(next);
|
|
73
|
+
}, [
|
|
74
|
+
folderIsControlled,
|
|
75
|
+
onFolderChange
|
|
76
|
+
]);
|
|
77
|
+
const catalog = models;
|
|
78
|
+
const effectiveLoading = loading ?? false;
|
|
79
|
+
const [pendingDelete, setPendingDelete] = external_react_default().useState(null);
|
|
80
|
+
const [deleteError, setDeleteError] = external_react_default().useState(null);
|
|
81
|
+
const pendingDeleteRef = external_react_default().useRef(null);
|
|
82
|
+
pendingDeleteRef.current = pendingDelete;
|
|
83
|
+
const deleteInFlight = external_react_default().useRef(false);
|
|
84
|
+
const handleDeleteModel = external_react_default().useMemo(()=>{
|
|
85
|
+
if (!onDeleteModel) return;
|
|
86
|
+
return (m)=>{
|
|
87
|
+
if (deleteInFlight.current) return;
|
|
88
|
+
setDeleteError(null);
|
|
89
|
+
setPendingDelete(m);
|
|
90
|
+
};
|
|
91
|
+
}, [
|
|
92
|
+
onDeleteModel
|
|
93
|
+
]);
|
|
94
|
+
const confirmPendingDelete = external_react_default().useCallback(async ()=>{
|
|
95
|
+
const model = pendingDelete;
|
|
96
|
+
setPendingDelete(null);
|
|
97
|
+
if (!model || !onDeleteModel || deleteInFlight.current) return;
|
|
98
|
+
deleteInFlight.current = true;
|
|
99
|
+
try {
|
|
100
|
+
await onDeleteModel(model);
|
|
101
|
+
} catch (err) {
|
|
102
|
+
setDeleteError(err instanceof Error ? err : new Error(String(err)));
|
|
103
|
+
} finally{
|
|
104
|
+
deleteInFlight.current = false;
|
|
105
|
+
}
|
|
106
|
+
}, [
|
|
107
|
+
pendingDelete,
|
|
108
|
+
onDeleteModel
|
|
109
|
+
]);
|
|
110
|
+
const effectiveError = error ?? null;
|
|
111
|
+
const effectiveModels = external_react_default().useMemo(()=>catalog.filter((m)=>!m.isBlockedByPolicy), [
|
|
112
|
+
catalog
|
|
113
|
+
]);
|
|
114
|
+
const state = (0, external_useModelPickerState_cjs_namespaceObject.useModelPickerState)({
|
|
115
|
+
models: effectiveModels,
|
|
116
|
+
value,
|
|
117
|
+
valueConnectionId,
|
|
118
|
+
onChange,
|
|
119
|
+
groupBy,
|
|
120
|
+
recommendedModelIds,
|
|
121
|
+
previewModelIds,
|
|
122
|
+
filter,
|
|
123
|
+
initiallyCollapsedGroups,
|
|
124
|
+
collapsibleGroups: showGroupHeaders,
|
|
125
|
+
labels
|
|
126
|
+
});
|
|
127
|
+
const { open, setOpen, query, setQuery, groupBy: activeGroupBy, setGroupBy, filtered, groupCounts, collapsedGroups, toggleGroup, selected, unknownValue, activeIndex, setActiveIndex, onSearchKeyDown, choose, id, triggerRef, searchRef, activeVisible } = state;
|
|
128
|
+
const listboxId = `${id}-listbox`;
|
|
129
|
+
const List = 'virtualized' === variant || filtered.length > AUTO_VIRTUALIZE_THRESHOLD ? OptionList_cjs_namespaceObject.VirtualOptionList : OptionList_cjs_namespaceObject.GroupedOptionList;
|
|
130
|
+
const handleTriggerRef = external_react_default().useCallback((node)=>{
|
|
131
|
+
triggerRef.current = node;
|
|
132
|
+
if ('function' == typeof forwardedRef) forwardedRef(node);
|
|
133
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
134
|
+
}, [
|
|
135
|
+
forwardedRef,
|
|
136
|
+
triggerRef
|
|
137
|
+
]);
|
|
138
|
+
const closePopup = external_react_default().useCallback(()=>{
|
|
139
|
+
setOpen(false);
|
|
140
|
+
setDeleteError(null);
|
|
141
|
+
}, [
|
|
142
|
+
setOpen
|
|
143
|
+
]);
|
|
144
|
+
const handleOpenChange = external_react_default().useCallback((next)=>{
|
|
145
|
+
if (next) return void setOpen(true);
|
|
146
|
+
if (pendingDeleteRef.current) return;
|
|
147
|
+
closePopup();
|
|
148
|
+
}, [
|
|
149
|
+
setOpen,
|
|
150
|
+
closePopup
|
|
151
|
+
]);
|
|
152
|
+
const slotCtx = external_react_default().useMemo(()=>({
|
|
153
|
+
selected,
|
|
154
|
+
close: closePopup
|
|
155
|
+
}), [
|
|
156
|
+
selected,
|
|
157
|
+
closePopup
|
|
158
|
+
]);
|
|
159
|
+
const effectiveCanManageByo = canManageByo ?? false;
|
|
160
|
+
const effectiveFolders = folders;
|
|
161
|
+
const listReady = !effectiveLoading && !effectiveError;
|
|
162
|
+
const handleSearchKeyDown = external_react_default().useCallback((e)=>{
|
|
163
|
+
if (!listReady) {
|
|
164
|
+
if ('Escape' === e.key) onSearchKeyDown(e);
|
|
165
|
+
else if ('Enter' === e.key || e.key.startsWith('Arrow')) e.preventDefault();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const active = filtered[activeIndex];
|
|
169
|
+
if (active && activeVisible && effectiveCanManageByo && (0, external_utils_cjs_namespaceObject.isByoModel)(active)) {
|
|
170
|
+
if ('Enter' === e.key && e.shiftKey && onEditModel) {
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
onEditModel(active);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const field = e.currentTarget;
|
|
176
|
+
const nothingToDelete = field.selectionStart === field.value.length && field.selectionEnd === field.selectionStart;
|
|
177
|
+
if ('Delete' === e.key && nothingToDelete && handleDeleteModel) {
|
|
178
|
+
e.preventDefault();
|
|
179
|
+
handleDeleteModel(active);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
onSearchKeyDown(e);
|
|
184
|
+
}, [
|
|
185
|
+
listReady,
|
|
186
|
+
filtered,
|
|
187
|
+
activeIndex,
|
|
188
|
+
activeVisible,
|
|
189
|
+
effectiveCanManageByo,
|
|
190
|
+
onEditModel,
|
|
191
|
+
handleDeleteModel,
|
|
192
|
+
onSearchKeyDown
|
|
193
|
+
]);
|
|
194
|
+
external_react_default().useEffect(()=>{
|
|
195
|
+
if ("u" < typeof process || 'production' === process.env.NODE_ENV || !effectiveFolders) return;
|
|
196
|
+
const seen = new Set();
|
|
197
|
+
for (const f of effectiveFolders){
|
|
198
|
+
if (seen.has(f.id)) return void console.warn(`[ModelPicker] Duplicate folder id "${f.id}" — folder selection will misbehave.`);
|
|
199
|
+
seen.add(f.id);
|
|
200
|
+
}
|
|
201
|
+
}, [
|
|
202
|
+
effectiveFolders
|
|
203
|
+
]);
|
|
204
|
+
const homeGeography = (0, external_utils_cjs_namespaceObject.resolveHomeGeography)(homeRegion);
|
|
205
|
+
const tagContext = external_react_default().useMemo(()=>({
|
|
206
|
+
labels,
|
|
207
|
+
homeRegion: homeGeography,
|
|
208
|
+
recommendedModelIds,
|
|
209
|
+
previewModelIds,
|
|
210
|
+
badgesFor,
|
|
211
|
+
customTagsFor
|
|
212
|
+
}), [
|
|
213
|
+
labels,
|
|
214
|
+
homeGeography,
|
|
215
|
+
recommendedModelIds,
|
|
216
|
+
previewModelIds,
|
|
217
|
+
badgesFor,
|
|
218
|
+
customTagsFor
|
|
219
|
+
]);
|
|
220
|
+
const renderRowActions = external_react_default().useMemo(()=>{
|
|
221
|
+
if (slots?.optionActions) return slots.optionActions;
|
|
222
|
+
if (!effectiveCanManageByo) return ()=>null;
|
|
223
|
+
if (!onEditModel && !handleDeleteModel) return ()=>null;
|
|
224
|
+
return (m)=>(0, ModelOptionRow_cjs_namespaceObject.defaultRowActions)(m, {
|
|
225
|
+
labels,
|
|
226
|
+
onEdit: onEditModel,
|
|
227
|
+
onDelete: handleDeleteModel
|
|
228
|
+
});
|
|
229
|
+
}, [
|
|
230
|
+
slots?.optionActions,
|
|
231
|
+
effectiveCanManageByo,
|
|
232
|
+
onEditModel,
|
|
233
|
+
handleDeleteModel,
|
|
234
|
+
labels
|
|
235
|
+
]);
|
|
236
|
+
const footerNode = external_react_default().useMemo(()=>{
|
|
237
|
+
if (slots && 'popupFooter' in slots) return slots.popupFooter ? slots.popupFooter(slotCtx) : null;
|
|
238
|
+
if (!effectiveCanManageByo) return null;
|
|
239
|
+
const activate = onUseCustomModel;
|
|
240
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(UseCustomModelFooter, {
|
|
241
|
+
disabled: !activate,
|
|
242
|
+
labels: labels,
|
|
243
|
+
onActivate: ()=>{
|
|
244
|
+
activate?.();
|
|
245
|
+
closePopup();
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}, [
|
|
249
|
+
slots,
|
|
250
|
+
effectiveCanManageByo,
|
|
251
|
+
onUseCustomModel,
|
|
252
|
+
slotCtx,
|
|
253
|
+
closePopup,
|
|
254
|
+
labels
|
|
255
|
+
]);
|
|
256
|
+
const pendingValue = effectiveLoading && !selected && value ? value : null;
|
|
257
|
+
const errorMessage = errorText ?? effectiveError?.message;
|
|
258
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_form_field_cjs_namespaceObject.FormField, {
|
|
259
|
+
className: "w-full",
|
|
260
|
+
"data-slot": "model-picker",
|
|
261
|
+
"data-testid": testId,
|
|
262
|
+
children: [
|
|
263
|
+
!labelHidden && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldLabel, {
|
|
264
|
+
htmlFor: `${id}-trigger`,
|
|
265
|
+
required: required,
|
|
266
|
+
children: resolvedLabel
|
|
267
|
+
}),
|
|
268
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
269
|
+
onOpenChange: handleOpenChange,
|
|
270
|
+
open: open,
|
|
271
|
+
children: [
|
|
272
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
273
|
+
asChild: true,
|
|
274
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(PickerTrigger_cjs_namespaceObject.PickerTrigger, {
|
|
275
|
+
controlsId: listboxId,
|
|
276
|
+
describedById: errorMessage ? `${id}-error` : void 0,
|
|
277
|
+
disabled: disabled,
|
|
278
|
+
extra: slots?.triggerExtra?.(selected),
|
|
279
|
+
"aria-label": labelHidden ? ariaLabel ?? defaultLabel : void 0,
|
|
280
|
+
id: `${id}-trigger`,
|
|
281
|
+
invalid: !!invalid || !!effectiveError || !!unknownValue,
|
|
282
|
+
open: open,
|
|
283
|
+
pendingValue: pendingValue,
|
|
284
|
+
placeholder: resolvedPlaceholder,
|
|
285
|
+
ref: handleTriggerRef,
|
|
286
|
+
required: required,
|
|
287
|
+
selected: selected,
|
|
288
|
+
tagContext: tagContext,
|
|
289
|
+
tagVariants: customTagVariants,
|
|
290
|
+
unknownValue: unknownValue
|
|
291
|
+
})
|
|
292
|
+
}),
|
|
293
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(PickerPopup_cjs_namespaceObject.PickerPopup, {
|
|
294
|
+
container: popupContainer,
|
|
295
|
+
footer: footerNode,
|
|
296
|
+
header: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
297
|
+
children: [
|
|
298
|
+
slots?.popupHeader?.(),
|
|
299
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(PickerSearchInput_cjs_namespaceObject.PickerSearchInput, {
|
|
300
|
+
activeDescendantId: listReady && activeVisible && filtered[activeIndex] ? (0, OptionList_cjs_namespaceObject.optionDomId)(listboxId, filtered[activeIndex].modelId) : void 0,
|
|
301
|
+
inputRef: searchRef,
|
|
302
|
+
leading: slots?.searchLeading?.() ?? (effectiveFolders && effectiveFolders.length > 0 ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FolderSwitcher_cjs_namespaceObject.FolderSwitcher, {
|
|
303
|
+
allFoldersLabel: allFoldersLabel ?? labels.allFolders,
|
|
304
|
+
container: popupContainer,
|
|
305
|
+
folders: effectiveFolders,
|
|
306
|
+
onChange: handleFolderChange,
|
|
307
|
+
value: folder ?? null
|
|
308
|
+
}) : void 0),
|
|
309
|
+
listboxId: listboxId,
|
|
310
|
+
onChange: (next)=>{
|
|
311
|
+
setQuery(next);
|
|
312
|
+
setActiveIndex(0);
|
|
313
|
+
},
|
|
314
|
+
onKeyDown: handleSearchKeyDown,
|
|
315
|
+
placeholder: labels.searchPlaceholder,
|
|
316
|
+
trailing: allowGroupingChange ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(GroupBySegmented, {
|
|
317
|
+
labels: labels,
|
|
318
|
+
onChange: setGroupBy,
|
|
319
|
+
value: activeGroupBy
|
|
320
|
+
}) : void 0,
|
|
321
|
+
value: query
|
|
322
|
+
})
|
|
323
|
+
]
|
|
324
|
+
}),
|
|
325
|
+
onOpenAutoFocus: (e)=>{
|
|
326
|
+
e.preventDefault();
|
|
327
|
+
searchRef.current?.focus();
|
|
328
|
+
},
|
|
329
|
+
children: [
|
|
330
|
+
effectiveLoading && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
331
|
+
"aria-label": labels.loading,
|
|
332
|
+
"aria-live": "polite",
|
|
333
|
+
className: "flex justify-center py-6 text-foreground-muted",
|
|
334
|
+
role: "status",
|
|
335
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_spinner_cjs_namespaceObject.Spinner, {
|
|
336
|
+
size: "sm"
|
|
337
|
+
})
|
|
338
|
+
}),
|
|
339
|
+
effectiveError && !effectiveLoading && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
340
|
+
className: "px-4 py-4 text-center text-sm text-error",
|
|
341
|
+
role: "alert",
|
|
342
|
+
children: effectiveError.message
|
|
343
|
+
}),
|
|
344
|
+
deleteError && !effectiveError && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
345
|
+
className: "border-b border-border px-4 py-2 text-sm text-error",
|
|
346
|
+
role: "alert",
|
|
347
|
+
children: deleteError.message
|
|
348
|
+
}),
|
|
349
|
+
!effectiveLoading && !effectiveError && 0 === filtered.length && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
350
|
+
"aria-live": "polite",
|
|
351
|
+
className: "py-6 text-center text-sm text-foreground-muted",
|
|
352
|
+
role: "status",
|
|
353
|
+
children: query.trim() ? labels.emptyNoMatch(query.trim()) : labels.emptyNoModels
|
|
354
|
+
}),
|
|
355
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
356
|
+
"aria-atomic": "true",
|
|
357
|
+
"aria-live": "polite",
|
|
358
|
+
className: "sr-only",
|
|
359
|
+
children: effectiveLoading || effectiveError || !(filtered.length > 0) ? '' : 1 === filtered.length ? labels.resultCount(filtered.length) : labels.resultCount(filtered.length)
|
|
360
|
+
}),
|
|
361
|
+
!effectiveLoading && !effectiveError && filtered.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
362
|
+
children: [
|
|
363
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(List, {
|
|
364
|
+
activeIndex: activeIndex,
|
|
365
|
+
"aria-label": labels.listboxLabel,
|
|
366
|
+
collapsedGroups: collapsedGroups,
|
|
367
|
+
groupCounts: groupCounts,
|
|
368
|
+
hideGroupHeaders: !showGroupHeaders || 'flat' === activeGroupBy,
|
|
369
|
+
id: listboxId,
|
|
370
|
+
onGroupToggle: toggleGroup,
|
|
371
|
+
onSelect: choose,
|
|
372
|
+
options: filtered,
|
|
373
|
+
renderRowActions: renderRowActions,
|
|
374
|
+
renderRowMeta: slots?.optionMeta,
|
|
375
|
+
selectedId: selected?.modelId ?? value ?? null,
|
|
376
|
+
setActiveIndex: setActiveIndex,
|
|
377
|
+
tagContext: tagContext,
|
|
378
|
+
tagVariants: customTagVariants
|
|
379
|
+
}),
|
|
380
|
+
slots?.listFooter?.(slotCtx)
|
|
381
|
+
]
|
|
382
|
+
})
|
|
383
|
+
]
|
|
384
|
+
})
|
|
385
|
+
]
|
|
386
|
+
}),
|
|
387
|
+
errorMessage && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
388
|
+
id: `${id}-error`,
|
|
389
|
+
role: "alert",
|
|
390
|
+
children: errorMessage
|
|
391
|
+
}),
|
|
392
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_dialog_cjs_namespaceObject.AlertDialog, {
|
|
393
|
+
onOpenChange: (next)=>!next && setPendingDelete(null),
|
|
394
|
+
open: null !== pendingDelete,
|
|
395
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_alert_dialog_cjs_namespaceObject.AlertDialogContent, {
|
|
396
|
+
container: popupContainer,
|
|
397
|
+
onCloseAutoFocus: (e)=>{
|
|
398
|
+
e.preventDefault();
|
|
399
|
+
searchRef.current?.focus();
|
|
400
|
+
},
|
|
401
|
+
children: [
|
|
402
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_alert_dialog_cjs_namespaceObject.AlertDialogHeader, {
|
|
403
|
+
children: [
|
|
404
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_dialog_cjs_namespaceObject.AlertDialogTitle, {
|
|
405
|
+
children: labels.deleteConfirmTitle
|
|
406
|
+
}),
|
|
407
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_dialog_cjs_namespaceObject.AlertDialogDescription, {
|
|
408
|
+
children: labels.deleteConfirmMessage(pendingDelete ? pendingDelete.displayName ?? pendingDelete.modelName : '')
|
|
409
|
+
})
|
|
410
|
+
]
|
|
411
|
+
}),
|
|
412
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_alert_dialog_cjs_namespaceObject.AlertDialogFooter, {
|
|
413
|
+
children: [
|
|
414
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_dialog_cjs_namespaceObject.AlertDialogCancel, {
|
|
415
|
+
autoFocus: true,
|
|
416
|
+
children: labels.deleteConfirmCancel
|
|
417
|
+
}),
|
|
418
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_dialog_cjs_namespaceObject.AlertDialogAction, {
|
|
419
|
+
className: "bg-error-background text-error hover:bg-error-background/80",
|
|
420
|
+
onClick: confirmPendingDelete,
|
|
421
|
+
children: labels.deleteConfirmConfirm
|
|
422
|
+
})
|
|
423
|
+
]
|
|
424
|
+
})
|
|
425
|
+
]
|
|
426
|
+
})
|
|
427
|
+
})
|
|
428
|
+
]
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
ModelPicker_ModelPicker.displayName = 'ModelPicker';
|
|
432
|
+
const GroupBySegmented = ({ value, onChange, labels })=>{
|
|
433
|
+
const groupByOptions = [
|
|
434
|
+
{
|
|
435
|
+
key: "subscription",
|
|
436
|
+
label: labels.groupByCategory
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
key: 'vendor',
|
|
440
|
+
label: labels.groupByProvider
|
|
441
|
+
}
|
|
442
|
+
];
|
|
443
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
444
|
+
"aria-label": labels.groupByAriaLabel,
|
|
445
|
+
className: "inline-flex gap-[3px] rounded-lg bg-surface-raised p-[3px]",
|
|
446
|
+
"data-slot": "model-picker-group-by",
|
|
447
|
+
role: "group",
|
|
448
|
+
children: groupByOptions.map((opt)=>{
|
|
449
|
+
const active = opt.key === value;
|
|
450
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
451
|
+
"aria-pressed": active,
|
|
452
|
+
className: (0, index_cjs_namespaceObject.cn)('cursor-pointer rounded-md px-2.5 py-1.5 text-xs leading-tight font-semibold transition-colors', 'focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none', active ? 'bg-popover text-brand shadow-sm' : 'text-foreground-muted hover:bg-surface-hover'),
|
|
453
|
+
onClick: ()=>onChange(opt.key),
|
|
454
|
+
type: "button",
|
|
455
|
+
children: opt.label
|
|
456
|
+
}, opt.key);
|
|
457
|
+
})
|
|
458
|
+
});
|
|
459
|
+
};
|
|
460
|
+
const UseCustomModelFooter = ({ onActivate, disabled, labels })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("button", {
|
|
461
|
+
className: (0, index_cjs_namespaceObject.cn)('flex w-full cursor-pointer items-center justify-start gap-3 px-4 py-3 text-left text-brand transition-colors', 'focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-inset', 'disabled:cursor-default', disabled ? 'opacity-55' : 'hover:bg-surface-hover'),
|
|
462
|
+
"data-slot": "model-picker-use-custom-model",
|
|
463
|
+
disabled: disabled,
|
|
464
|
+
onClick: disabled ? void 0 : onActivate,
|
|
465
|
+
title: disabled ? labels.useCustomModelDisabledHint : void 0,
|
|
466
|
+
type: "button",
|
|
467
|
+
children: [
|
|
468
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
469
|
+
className: "flex size-[30px] shrink-0 items-center justify-center rounded-lg bg-brand/10 text-brand",
|
|
470
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Plus, {
|
|
471
|
+
className: "size-[18px]"
|
|
472
|
+
})
|
|
473
|
+
}),
|
|
474
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
475
|
+
className: "flex min-w-0 flex-col",
|
|
476
|
+
children: [
|
|
477
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
478
|
+
className: "text-sm leading-snug font-semibold",
|
|
479
|
+
children: labels.useCustomModelTitle
|
|
480
|
+
}),
|
|
481
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
482
|
+
className: "text-xs leading-snug font-normal text-foreground-muted",
|
|
483
|
+
children: labels.useCustomModelSubtitle
|
|
484
|
+
})
|
|
485
|
+
]
|
|
486
|
+
})
|
|
487
|
+
]
|
|
488
|
+
});
|
|
489
|
+
exports.ModelPicker = __webpack_exports__.ModelPicker;
|
|
490
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
491
|
+
"ModelPicker"
|
|
492
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
493
|
+
Object.defineProperty(exports, '__esModule', {
|
|
494
|
+
value: true
|
|
495
|
+
});
|