@uipath/apollo-wind 2.55.0 → 2.57.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/combobox.cjs +33 -15
- package/dist/components/ui/combobox.js +33 -15
- package/dist/components/ui/date-picker.cjs +62 -26
- package/dist/components/ui/date-picker.js +62 -26
- package/dist/components/ui/datetime-picker.cjs +29 -12
- package/dist/components/ui/datetime-picker.js +29 -12
- package/dist/components/ui/dropdown-menu.cjs +12 -8
- package/dist/components/ui/dropdown-menu.js +12 -8
- package/dist/components/ui/field-actions/ai-assist-action.cjs +121 -0
- package/dist/components/ui/field-actions/ai-assist-action.d.ts +21 -0
- package/dist/components/ui/field-actions/ai-assist-action.js +84 -0
- package/dist/components/ui/field-actions/collapse.cjs +44 -0
- package/dist/components/ui/field-actions/collapse.d.ts +6 -0
- package/dist/components/ui/field-actions/collapse.js +4 -0
- package/dist/components/ui/field-actions/index.cjs +46 -0
- package/dist/components/ui/field-actions/index.d.ts +2 -0
- package/dist/components/ui/field-actions/index.js +3 -0
- package/dist/components/ui/field-actions/insert-variable-action.cjs +94 -0
- package/dist/components/ui/field-actions/insert-variable-action.d.ts +22 -0
- package/dist/components/ui/field-actions/insert-variable-action.js +57 -0
- package/dist/components/ui/field-addons/index.cjs +50 -0
- package/dist/components/ui/field-addons/index.d.ts +3 -0
- package/dist/components/ui/field-addons/index.js +4 -0
- package/dist/components/ui/field-addons/value-mode-indicator.cjs +57 -0
- package/dist/components/ui/field-addons/value-mode-indicator.d.ts +13 -0
- package/dist/components/ui/field-addons/value-mode-indicator.js +23 -0
- package/dist/components/ui/field-addons/value-mode-menu.cjs +149 -0
- package/dist/components/ui/field-addons/value-mode-menu.d.ts +69 -0
- package/dist/components/ui/field-addons/value-mode-menu.js +112 -0
- package/dist/components/ui/field-addons/value-mode-strings.cjs +69 -0
- package/dist/components/ui/field-addons/value-mode-strings.d.ts +32 -0
- package/dist/components/ui/field-addons/value-mode-strings.js +29 -0
- package/dist/components/ui/form-field.cjs +42 -5
- package/dist/components/ui/form-field.d.ts +21 -1
- package/dist/components/ui/form-field.js +36 -2
- package/dist/components/ui/index.cjs +156 -126
- package/dist/components/ui/index.d.ts +3 -0
- package/dist/components/ui/index.js +3 -0
- package/dist/components/ui/input-group-context.cjs +91 -0
- package/dist/components/ui/input-group-context.d.ts +69 -0
- package/dist/components/ui/input-group-context.js +42 -0
- package/dist/components/ui/input-group.cjs +303 -56
- package/dist/components/ui/input-group.d.ts +70 -3
- package/dist/components/ui/input-group.js +285 -56
- package/dist/components/ui/input.cjs +28 -17
- package/dist/components/ui/input.js +28 -17
- package/dist/components/ui/lockable-value-field/components/field-header.cjs +16 -114
- package/dist/components/ui/lockable-value-field/components/field-header.js +14 -112
- package/dist/components/ui/lockable-value-field/lockable-value-field.cjs +4 -12
- package/dist/components/ui/lockable-value-field/lockable-value-field.js +4 -12
- 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/{lockable-value-field/components/mode-menu-item.cjs → model-picker/primitives/PickerPopup.cjs} +25 -24
- 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/components/ui/multi-select.cjs +82 -58
- package/dist/components/ui/multi-select.js +84 -60
- package/dist/components/ui/popover.cjs +13 -9
- package/dist/components/ui/popover.js +13 -9
- package/dist/components/ui/select.cjs +89 -27
- package/dist/components/ui/select.d.ts +4 -0
- package/dist/components/ui/select.js +90 -28
- package/dist/components/ui/textarea.cjs +16 -11
- package/dist/components/ui/textarea.js +16 -11
- package/dist/index.cjs +144 -21
- package/dist/index.d.ts +10 -4
- package/dist/index.js +6 -3
- package/dist/styles.css +350 -5
- package/package.json +2 -1
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.d.ts +0 -9
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.js +0 -29
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Pencil, Trash2 } from "lucide-react";
|
|
4
|
+
import { memo } from "react";
|
|
5
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../tooltip.js";
|
|
6
|
+
import { cn } from "../../../../lib/index.js";
|
|
7
|
+
import { DEFAULT_MODEL_PICKER_LABELS } from "../labels.js";
|
|
8
|
+
import { ModelTagChip } from "../ModelTagChip.js";
|
|
9
|
+
import { deriveModelTags, isByoModel } from "../utils.js";
|
|
10
|
+
const FULL_OPTION_HEIGHT = 64;
|
|
11
|
+
const DENSE_OPTION_HEIGHT = 44;
|
|
12
|
+
const ModelOptionRowInner = ({ model, index, active, selected, onSelect, onActivate, tagContext, tagVariants, renderActions, renderMeta, dense, hideTagKinds, id, 'data-testid': dataTestId })=>{
|
|
13
|
+
const labels = tagContext?.labels ?? DEFAULT_MODEL_PICKER_LABELS;
|
|
14
|
+
const inlineTags = deriveModelTags(model, tagContext ?? {}).filter((t)=>!hideTagKinds?.includes(t.kind));
|
|
15
|
+
const primaryLabel = model.displayName ?? null;
|
|
16
|
+
const primary = primaryLabel ?? model.modelName;
|
|
17
|
+
const usesFriendlyName = !!primaryLabel && primaryLabel !== model.modelId;
|
|
18
|
+
const techId = usesFriendlyName ? model.modelId : null;
|
|
19
|
+
const contextTokens = model.modelDetails?.contextWindowTokens;
|
|
20
|
+
const contextLabel = null != contextTokens && contextTokens > 0 ? labels.contextWindow(contextTokens) : null;
|
|
21
|
+
const rowActions = renderActions ? renderActions(model) : null;
|
|
22
|
+
const meta = renderMeta?.(model);
|
|
23
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
24
|
+
"aria-selected": selected,
|
|
25
|
+
className: cn('@container relative flex w-full cursor-pointer items-start justify-start text-left', dense ? 'min-h-11 gap-2 px-3 py-1.5' : 'min-h-16 gap-3 px-3.5 py-2.5', selected ? 'bg-surface-selected shadow-[inset_3px_0_0_var(--brand)]' : active ? 'bg-surface-hover' : 'bg-transparent', !selected && 'hover:bg-surface-hover'),
|
|
26
|
+
"data-slot": "model-picker-row",
|
|
27
|
+
"data-testid": dataTestId,
|
|
28
|
+
id: id,
|
|
29
|
+
onClick: ()=>onSelect(model),
|
|
30
|
+
onMouseEnter: onActivate ? ()=>onActivate(index) : void 0,
|
|
31
|
+
role: "option",
|
|
32
|
+
tabIndex: -1,
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ jsxs("div", {
|
|
35
|
+
className: "min-w-0 flex-1",
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ jsxs("div", {
|
|
38
|
+
className: "flex min-w-0 flex-nowrap items-center gap-1.5",
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ jsx("span", {
|
|
41
|
+
className: cn('min-w-0 flex-[0_1_auto] truncate leading-snug font-semibold text-foreground', dense ? 'text-xs' : 'text-sm'),
|
|
42
|
+
children: primary
|
|
43
|
+
}),
|
|
44
|
+
inlineTags.map((t)=>/*#__PURE__*/ jsx("span", {
|
|
45
|
+
className: "flex min-w-0 shrink items-center overflow-hidden [&_[data-slot=model-picker-tag]]:max-w-full [&_[data-slot=model-picker-tag]]:truncate",
|
|
46
|
+
children: /*#__PURE__*/ jsx(ModelTagChip, {
|
|
47
|
+
tag: t,
|
|
48
|
+
variants: tagVariants
|
|
49
|
+
})
|
|
50
|
+
}, `${t.kind}-${t.label}`))
|
|
51
|
+
]
|
|
52
|
+
}),
|
|
53
|
+
techId && /*#__PURE__*/ jsx("span", {
|
|
54
|
+
className: "mt-0.5 block truncate font-mono text-[11px] text-foreground-muted",
|
|
55
|
+
children: techId
|
|
56
|
+
}),
|
|
57
|
+
model.byoConnectionLabel && /*#__PURE__*/ jsx("span", {
|
|
58
|
+
className: cn('block max-w-full truncate text-xs text-foreground-muted', !techId && 'mt-0.5'),
|
|
59
|
+
children: model.byoConnectionLabel
|
|
60
|
+
})
|
|
61
|
+
]
|
|
62
|
+
}),
|
|
63
|
+
(contextLabel ?? meta) && /*#__PURE__*/ jsxs("div", {
|
|
64
|
+
className: "flex shrink-0 flex-col items-end gap-1 pt-px @max-[380px]:hidden",
|
|
65
|
+
onClick: (e)=>e.stopPropagation(),
|
|
66
|
+
children: [
|
|
67
|
+
contextLabel && /*#__PURE__*/ jsx("span", {
|
|
68
|
+
className: "text-[11px] leading-tight text-foreground-muted",
|
|
69
|
+
children: contextLabel
|
|
70
|
+
}),
|
|
71
|
+
meta
|
|
72
|
+
]
|
|
73
|
+
}),
|
|
74
|
+
rowActions && /*#__PURE__*/ jsx("div", {
|
|
75
|
+
className: "flex shrink-0 items-center gap-0.5 pt-px text-foreground-muted",
|
|
76
|
+
onClick: (e)=>e.stopPropagation(),
|
|
77
|
+
children: rowActions
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
const ModelOptionRow = /*#__PURE__*/ memo(ModelOptionRowInner);
|
|
83
|
+
ModelOptionRow.displayName = 'ModelOptionRow';
|
|
84
|
+
function defaultRowActions(model, options = {}) {
|
|
85
|
+
const { labels = DEFAULT_MODEL_PICKER_LABELS, onEdit, onDelete } = options;
|
|
86
|
+
if (!onEdit && !onDelete) return null;
|
|
87
|
+
if (!isByoModel(model)) return null;
|
|
88
|
+
const editTitle = labels.editConfiguration;
|
|
89
|
+
const deleteTitle = labels.deleteConfiguration;
|
|
90
|
+
return /*#__PURE__*/ jsxs(TooltipProvider, {
|
|
91
|
+
children: [
|
|
92
|
+
onEdit && /*#__PURE__*/ jsxs(Tooltip, {
|
|
93
|
+
children: [
|
|
94
|
+
/*#__PURE__*/ jsx(TooltipTrigger, {
|
|
95
|
+
asChild: true,
|
|
96
|
+
children: /*#__PURE__*/ jsx("button", {
|
|
97
|
+
"aria-label": editTitle,
|
|
98
|
+
className: "cursor-pointer rounded p-1 text-inherit hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
|
|
99
|
+
onClick: ()=>onEdit(model),
|
|
100
|
+
tabIndex: -1,
|
|
101
|
+
type: "button",
|
|
102
|
+
children: /*#__PURE__*/ jsx(Pencil, {
|
|
103
|
+
className: "size-3.5"
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
}),
|
|
107
|
+
/*#__PURE__*/ jsx(TooltipContent, {
|
|
108
|
+
children: editTitle
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
}),
|
|
112
|
+
onDelete && /*#__PURE__*/ jsxs(Tooltip, {
|
|
113
|
+
children: [
|
|
114
|
+
/*#__PURE__*/ jsx(TooltipTrigger, {
|
|
115
|
+
asChild: true,
|
|
116
|
+
children: /*#__PURE__*/ jsx("button", {
|
|
117
|
+
"aria-label": deleteTitle,
|
|
118
|
+
className: "cursor-pointer rounded p-1 text-inherit hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
|
|
119
|
+
onClick: ()=>onDelete(model),
|
|
120
|
+
tabIndex: -1,
|
|
121
|
+
type: "button",
|
|
122
|
+
children: /*#__PURE__*/ jsx(Trash2, {
|
|
123
|
+
className: "size-3.5"
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ jsx(TooltipContent, {
|
|
128
|
+
children: deleteTitle
|
|
129
|
+
})
|
|
130
|
+
]
|
|
131
|
+
})
|
|
132
|
+
]
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
export { DENSE_OPTION_HEIGHT, FULL_OPTION_HEIGHT, ModelOptionRow, defaultRowActions };
|
|
@@ -0,0 +1,295 @@
|
|
|
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
|
+
optionDomId: ()=>optionDomId,
|
|
38
|
+
VirtualOptionList: ()=>VirtualOptionList,
|
|
39
|
+
GroupedOptionList: ()=>GroupedOptionList,
|
|
40
|
+
isCollapsibleGroup: ()=>isCollapsibleGroup
|
|
41
|
+
});
|
|
42
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
43
|
+
const react_virtual_namespaceObject = require("@tanstack/react-virtual");
|
|
44
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
45
|
+
const external_react_namespaceObject = require("react");
|
|
46
|
+
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
47
|
+
const external_labels_cjs_namespaceObject = require("../labels.cjs");
|
|
48
|
+
const external_GroupHeader_cjs_namespaceObject = require("./GroupHeader.cjs");
|
|
49
|
+
const external_ModelOptionRow_cjs_namespaceObject = require("./ModelOptionRow.cjs");
|
|
50
|
+
const BYO_GROUP_KEY = 'byo';
|
|
51
|
+
function isCollapsibleGroup(groupKey) {
|
|
52
|
+
return groupKey === BYO_GROUP_KEY;
|
|
53
|
+
}
|
|
54
|
+
const DEFAULT_LIST_MAX_HEIGHT = 362;
|
|
55
|
+
function groupLeadingIcon(groupKey) {
|
|
56
|
+
if (groupKey === BYO_GROUP_KEY) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Shield, {
|
|
57
|
+
className: "size-3.5"
|
|
58
|
+
});
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const GROUP_HINT_KEYS = {
|
|
62
|
+
recommended: 'recommendedGroupHint',
|
|
63
|
+
preview: 'previewGroupHint',
|
|
64
|
+
byo: 'byoGroupHint',
|
|
65
|
+
more: 'moreGroupHint',
|
|
66
|
+
deprecating: 'deprecatingGroupHint'
|
|
67
|
+
};
|
|
68
|
+
function groupHint(groupKey, labels) {
|
|
69
|
+
const key = GROUP_HINT_KEYS[groupKey];
|
|
70
|
+
return key ? labels[key] : void 0;
|
|
71
|
+
}
|
|
72
|
+
function countLabel(n, labels) {
|
|
73
|
+
return null == n ? void 0 : labels.modelCount(n);
|
|
74
|
+
}
|
|
75
|
+
function optionDomId(listboxId, modelId) {
|
|
76
|
+
const safe = modelId.replace(/[^A-Za-z0-9-]/g, (c)=>`_${c.codePointAt(0)?.toString(16)}_`);
|
|
77
|
+
return `${listboxId}-opt-${safe}`;
|
|
78
|
+
}
|
|
79
|
+
const GroupedOptionList = ({ id, options, activeIndex, setActiveIndex, selectedId, onSelect, tagContext, tagVariants, groupCounts, renderRowActions, renderRowMeta, dense, maxHeight = DEFAULT_LIST_MAX_HEIGHT, hideGroupHeaders, hideTagKinds, collapsedGroups, onGroupToggle, 'aria-label': ariaLabel = 'Models' })=>{
|
|
80
|
+
const labels = tagContext?.labels ?? external_labels_cjs_namespaceObject.DEFAULT_MODEL_PICKER_LABELS;
|
|
81
|
+
let lastGroupKey;
|
|
82
|
+
let headerCount = 0;
|
|
83
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
84
|
+
const model = options[activeIndex];
|
|
85
|
+
if (!model) return;
|
|
86
|
+
document.getElementById(optionDomId(id, model.modelId))?.scrollIntoView?.({
|
|
87
|
+
block: 'nearest'
|
|
88
|
+
});
|
|
89
|
+
}, [
|
|
90
|
+
activeIndex,
|
|
91
|
+
id,
|
|
92
|
+
options
|
|
93
|
+
]);
|
|
94
|
+
const derivedCounts = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
95
|
+
if (groupCounts) return groupCounts;
|
|
96
|
+
const out = {};
|
|
97
|
+
for (const o of options)out[o.groupKey] = (out[o.groupKey] ?? 0) + 1;
|
|
98
|
+
return out;
|
|
99
|
+
}, [
|
|
100
|
+
groupCounts,
|
|
101
|
+
options
|
|
102
|
+
]);
|
|
103
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
104
|
+
"aria-label": ariaLabel,
|
|
105
|
+
className: "overflow-y-auto py-1",
|
|
106
|
+
"data-slot": "model-picker-listbox",
|
|
107
|
+
id: id,
|
|
108
|
+
role: "listbox",
|
|
109
|
+
style: {
|
|
110
|
+
maxHeight
|
|
111
|
+
},
|
|
112
|
+
children: options.map((opt, i)=>{
|
|
113
|
+
const showHeader = !hideGroupHeaders && opt.groupKey !== lastGroupKey;
|
|
114
|
+
const isFirstHeader = showHeader && 0 === headerCount;
|
|
115
|
+
if (showHeader) headerCount += 1;
|
|
116
|
+
lastGroupKey = opt.groupKey;
|
|
117
|
+
const isCollapsible = isCollapsibleGroup(opt.groupKey);
|
|
118
|
+
const isCollapsed = isCollapsible && (collapsedGroups?.has(opt.groupKey) ?? false);
|
|
119
|
+
const headerActive = isCollapsed && options[activeIndex]?.groupKey === opt.groupKey;
|
|
120
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_react_default().Fragment, {
|
|
121
|
+
children: [
|
|
122
|
+
showHeader && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_GroupHeader_cjs_namespaceObject.GroupHeader, {
|
|
123
|
+
active: headerActive,
|
|
124
|
+
label: opt.groupLabel,
|
|
125
|
+
hint: groupHint(opt.groupKey, labels),
|
|
126
|
+
count: derivedCounts[opt.groupKey],
|
|
127
|
+
countLabel: countLabel(derivedCounts[opt.groupKey], labels),
|
|
128
|
+
dense: dense,
|
|
129
|
+
isFirst: isFirstHeader,
|
|
130
|
+
leadingIcon: groupLeadingIcon(opt.groupKey),
|
|
131
|
+
collapsible: isCollapsible,
|
|
132
|
+
collapsed: isCollapsed,
|
|
133
|
+
onToggle: isCollapsible ? ()=>onGroupToggle?.(opt.groupKey) : void 0
|
|
134
|
+
}),
|
|
135
|
+
!isCollapsed && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ModelOptionRow_cjs_namespaceObject.ModelOptionRow, {
|
|
136
|
+
id: optionDomId(id, opt.modelId),
|
|
137
|
+
model: opt,
|
|
138
|
+
index: i,
|
|
139
|
+
active: i === activeIndex,
|
|
140
|
+
selected: opt.modelId === selectedId,
|
|
141
|
+
onSelect: onSelect,
|
|
142
|
+
onActivate: setActiveIndex,
|
|
143
|
+
tagContext: tagContext,
|
|
144
|
+
tagVariants: tagVariants,
|
|
145
|
+
hideTagKinds: hideTagKinds?.filter((k)=>k === opt.groupKey),
|
|
146
|
+
renderMeta: renderRowMeta,
|
|
147
|
+
renderActions: renderRowActions,
|
|
148
|
+
dense: dense
|
|
149
|
+
})
|
|
150
|
+
]
|
|
151
|
+
}, opt.modelId);
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
const VirtualOptionList = ({ id, options, activeIndex, setActiveIndex, selectedId, onSelect, tagContext, tagVariants, groupCounts, renderRowActions, renderRowMeta, dense, maxHeight = DEFAULT_LIST_MAX_HEIGHT, hideGroupHeaders, hideTagKinds, collapsedGroups, onGroupToggle, 'aria-label': ariaLabel = 'Models' })=>{
|
|
156
|
+
const labels = tagContext?.labels ?? external_labels_cjs_namespaceObject.DEFAULT_MODEL_PICKER_LABELS;
|
|
157
|
+
const rows = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
158
|
+
const out = [];
|
|
159
|
+
let lastGroupKey;
|
|
160
|
+
let headerCount = 0;
|
|
161
|
+
const counts = groupCounts ?? {};
|
|
162
|
+
if (!groupCounts) for (const o of options)counts[o.groupKey] = (counts[o.groupKey] ?? 0) + 1;
|
|
163
|
+
options.forEach((opt, i)=>{
|
|
164
|
+
const collapsed = isCollapsibleGroup(opt.groupKey) && (collapsedGroups?.has(opt.groupKey) ?? false);
|
|
165
|
+
if (!hideGroupHeaders && opt.groupKey !== lastGroupKey) {
|
|
166
|
+
out.push({
|
|
167
|
+
kind: 'header',
|
|
168
|
+
key: `h-${opt.groupKey}`,
|
|
169
|
+
groupKey: opt.groupKey,
|
|
170
|
+
label: opt.groupLabel,
|
|
171
|
+
isFirst: 0 === headerCount,
|
|
172
|
+
count: counts[opt.groupKey] ?? 0
|
|
173
|
+
});
|
|
174
|
+
headerCount += 1;
|
|
175
|
+
}
|
|
176
|
+
lastGroupKey = opt.groupKey;
|
|
177
|
+
if (!collapsed) out.push({
|
|
178
|
+
kind: 'option',
|
|
179
|
+
key: opt.modelId,
|
|
180
|
+
model: opt,
|
|
181
|
+
index: i
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
return out;
|
|
185
|
+
}, [
|
|
186
|
+
options,
|
|
187
|
+
hideGroupHeaders,
|
|
188
|
+
groupCounts,
|
|
189
|
+
collapsedGroups
|
|
190
|
+
]);
|
|
191
|
+
const headerHeight = dense ? 32 : 48;
|
|
192
|
+
const optionHeight = dense ? external_ModelOptionRow_cjs_namespaceObject.DENSE_OPTION_HEIGHT : external_ModelOptionRow_cjs_namespaceObject.FULL_OPTION_HEIGHT;
|
|
193
|
+
const parentRef = (0, external_react_namespaceObject.useRef)(null);
|
|
194
|
+
const virtualizer = (0, react_virtual_namespaceObject.useVirtualizer)({
|
|
195
|
+
count: rows.length,
|
|
196
|
+
getScrollElement: ()=>parentRef.current,
|
|
197
|
+
estimateSize: (i)=>rows[i]?.kind === 'header' ? headerHeight : optionHeight,
|
|
198
|
+
overscan: 10
|
|
199
|
+
});
|
|
200
|
+
const measure = virtualizer.measureElement;
|
|
201
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
202
|
+
const rowIdx = rows.findIndex((r)=>'option' === r.kind && r.index === activeIndex);
|
|
203
|
+
if (rowIdx >= 0) virtualizer.scrollToIndex(rowIdx, {
|
|
204
|
+
align: 'auto'
|
|
205
|
+
});
|
|
206
|
+
}, [
|
|
207
|
+
activeIndex,
|
|
208
|
+
rows,
|
|
209
|
+
virtualizer
|
|
210
|
+
]);
|
|
211
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
212
|
+
"aria-label": ariaLabel,
|
|
213
|
+
className: "relative overflow-y-auto py-1",
|
|
214
|
+
"data-slot": "model-picker-listbox",
|
|
215
|
+
id: id,
|
|
216
|
+
ref: parentRef,
|
|
217
|
+
role: "listbox",
|
|
218
|
+
style: {
|
|
219
|
+
maxHeight
|
|
220
|
+
},
|
|
221
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
222
|
+
className: "relative w-full",
|
|
223
|
+
style: {
|
|
224
|
+
height: virtualizer.getTotalSize()
|
|
225
|
+
},
|
|
226
|
+
children: virtualizer.getVirtualItems().map((vi)=>{
|
|
227
|
+
const row = rows[vi.index];
|
|
228
|
+
if (!row) return null;
|
|
229
|
+
const baseStyle = {
|
|
230
|
+
position: 'absolute',
|
|
231
|
+
top: 0,
|
|
232
|
+
left: 0,
|
|
233
|
+
width: '100%',
|
|
234
|
+
transform: `translateY(${vi.start}px)`
|
|
235
|
+
};
|
|
236
|
+
if ('header' === row.kind) {
|
|
237
|
+
const isCollapsible = isCollapsibleGroup(row.groupKey);
|
|
238
|
+
const isCollapsed = isCollapsible && (collapsedGroups?.has(row.groupKey) ?? false);
|
|
239
|
+
const headerActive = isCollapsed && options[activeIndex]?.groupKey === row.groupKey;
|
|
240
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
241
|
+
"data-index": vi.index,
|
|
242
|
+
ref: measure,
|
|
243
|
+
style: baseStyle,
|
|
244
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_GroupHeader_cjs_namespaceObject.GroupHeader, {
|
|
245
|
+
active: headerActive,
|
|
246
|
+
label: row.label,
|
|
247
|
+
hint: groupHint(row.groupKey, labels),
|
|
248
|
+
count: row.count,
|
|
249
|
+
countLabel: countLabel(row.count, labels),
|
|
250
|
+
dense: dense,
|
|
251
|
+
isFirst: row.isFirst,
|
|
252
|
+
leadingIcon: groupLeadingIcon(row.groupKey),
|
|
253
|
+
collapsible: isCollapsible,
|
|
254
|
+
collapsed: isCollapsed,
|
|
255
|
+
onToggle: isCollapsible ? ()=>onGroupToggle?.(row.groupKey) : void 0
|
|
256
|
+
})
|
|
257
|
+
}, row.key);
|
|
258
|
+
}
|
|
259
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
260
|
+
"data-index": vi.index,
|
|
261
|
+
ref: measure,
|
|
262
|
+
style: baseStyle,
|
|
263
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ModelOptionRow_cjs_namespaceObject.ModelOptionRow, {
|
|
264
|
+
id: optionDomId(id, row.model.modelId),
|
|
265
|
+
model: row.model,
|
|
266
|
+
index: row.index,
|
|
267
|
+
active: row.index === activeIndex,
|
|
268
|
+
selected: row.model.modelId === selectedId,
|
|
269
|
+
onSelect: onSelect,
|
|
270
|
+
onActivate: setActiveIndex,
|
|
271
|
+
tagContext: tagContext,
|
|
272
|
+
tagVariants: tagVariants,
|
|
273
|
+
hideTagKinds: hideTagKinds?.filter((k)=>k === row.model.groupKey),
|
|
274
|
+
renderMeta: renderRowMeta,
|
|
275
|
+
renderActions: renderRowActions,
|
|
276
|
+
dense: dense
|
|
277
|
+
})
|
|
278
|
+
}, row.key);
|
|
279
|
+
})
|
|
280
|
+
})
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
exports.GroupedOptionList = __webpack_exports__.GroupedOptionList;
|
|
284
|
+
exports.VirtualOptionList = __webpack_exports__.VirtualOptionList;
|
|
285
|
+
exports.isCollapsibleGroup = __webpack_exports__.isCollapsibleGroup;
|
|
286
|
+
exports.optionDomId = __webpack_exports__.optionDomId;
|
|
287
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
288
|
+
"GroupedOptionList",
|
|
289
|
+
"VirtualOptionList",
|
|
290
|
+
"isCollapsibleGroup",
|
|
291
|
+
"optionDomId"
|
|
292
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
293
|
+
Object.defineProperty(exports, '__esModule', {
|
|
294
|
+
value: true
|
|
295
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DiscoveryModel } from '../types';
|
|
3
|
+
import type { DeriveModelTagsContext } from '../utils';
|
|
4
|
+
export interface AnnotatedModel extends DiscoveryModel {
|
|
5
|
+
groupKey: string;
|
|
6
|
+
groupLabel: string;
|
|
7
|
+
}
|
|
8
|
+
export interface OptionListProps {
|
|
9
|
+
id: string;
|
|
10
|
+
options: AnnotatedModel[];
|
|
11
|
+
activeIndex: number;
|
|
12
|
+
setActiveIndex: (i: number) => void;
|
|
13
|
+
selectedId: string | null;
|
|
14
|
+
onSelect: (m: DiscoveryModel) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Forwarded to every row's `deriveModelTags` call. Use for
|
|
17
|
+
* `recommendedModelIds`, `previewModelIds`, `badgesFor`,
|
|
18
|
+
* `customTagsFor`, `homeRegion`, and `labels`.
|
|
19
|
+
*/
|
|
20
|
+
tagContext?: DeriveModelTagsContext;
|
|
21
|
+
/**
|
|
22
|
+
* Variant lookup for tag kinds the design system doesn't know
|
|
23
|
+
* about. Forwarded to every row's `<ModelTagChip>`.
|
|
24
|
+
*/
|
|
25
|
+
tagVariants?: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Group counts used by GroupHeader to render the right-aligned count
|
|
28
|
+
* (e.g. "3 models"). Keyed by `groupKey`. When omitted, the
|
|
29
|
+
* counter is derived from the visible options.
|
|
30
|
+
*/
|
|
31
|
+
groupCounts?: Record<string, number>;
|
|
32
|
+
/** Override the BYO edit/delete row actions. Return null to suppress. */
|
|
33
|
+
renderRowActions?: (m: DiscoveryModel) => React.ReactNode;
|
|
34
|
+
/** Per-row meta column (cost, context window, etc.). */
|
|
35
|
+
renderRowMeta?: (m: DiscoveryModel) => React.ReactNode;
|
|
36
|
+
/** Reduced row + header sizes. */
|
|
37
|
+
dense?: boolean;
|
|
38
|
+
/** Maximum height of the scroll region. Default 362 (design spec). */
|
|
39
|
+
maxHeight?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Suppress group header rows. Options are still grouped + ordered as
|
|
42
|
+
* usual; only the visual section labels are hidden. Use for compact /
|
|
43
|
+
* inline pickers where headers add too much chrome.
|
|
44
|
+
*/
|
|
45
|
+
hideGroupHeaders?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Tag kinds to hide from chips on a row **whose own group already conveys
|
|
48
|
+
* them** — a "Recommended" chip inside the Recommended section is noise.
|
|
49
|
+
* Matching is by group key, so a kind is only suppressed where it is
|
|
50
|
+
* genuinely redundant: a Recommended model filed under Custom Models (BYO)
|
|
51
|
+
* keeps its chip, because that section says nothing about lifecycle.
|
|
52
|
+
*
|
|
53
|
+
* Tags are still derived by `deriveModelTags`; this only affects rendering.
|
|
54
|
+
*
|
|
55
|
+
* Opt-in: `ModelPicker` passes nothing, so every chip renders everywhere.
|
|
56
|
+
*/
|
|
57
|
+
hideTagKinds?: readonly string[];
|
|
58
|
+
/**
|
|
59
|
+
* Accessible name for the listbox. Defaults to "Models". Screen
|
|
60
|
+
* readers announce this when focus enters the picker so users know
|
|
61
|
+
* what they're selecting from.
|
|
62
|
+
*/
|
|
63
|
+
'aria-label'?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Set of group keys currently rendered as collapsed (header visible,
|
|
66
|
+
* options hidden). Today only the BYO group ('byo') is supported as
|
|
67
|
+
* collapsible; the parent ModelPicker owns this state.
|
|
68
|
+
*/
|
|
69
|
+
collapsedGroups?: ReadonlySet<string>;
|
|
70
|
+
/** Click handler for collapsible group headers. */
|
|
71
|
+
onGroupToggle?: (groupKey: string) => void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Which sections can collapse. One rule for both renderers and for the
|
|
75
|
+
* keyboard handler in `useModelPickerState`, so a key in `collapsedGroups`
|
|
76
|
+
* never hides rows in one renderer and not the other. Today: BYO only.
|
|
77
|
+
*/
|
|
78
|
+
export declare function isCollapsibleGroup(groupKey: string): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Build a stable DOM id for a given option, derived from the listbox
|
|
81
|
+
* id + the model's id. Used by the search input's
|
|
82
|
+
* `aria-activedescendant` so screen readers can announce the active
|
|
83
|
+
* option without moving DOM focus.
|
|
84
|
+
*/
|
|
85
|
+
export declare function optionDomId(listboxId: string, modelId: string): string;
|
|
86
|
+
export declare const GroupedOptionList: React.FC<OptionListProps>;
|
|
87
|
+
export declare const VirtualOptionList: React.FC<OptionListProps>;
|