sunpeak 0.5.28 → 0.5.30
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/bin/commands/build.mjs +64 -29
- package/bin/commands/dev.mjs +21 -37
- package/bin/commands/mcp.mjs +11 -9
- package/dist/chatgpt/globals.css +0 -3
- package/package.json +1 -1
- package/template/dist/chatgpt/albums.js +54 -14
- package/template/dist/chatgpt/carousel.js +54 -14
- package/template/dist/chatgpt/counter.js +54 -14
- package/template/index.html +2 -0
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Button.js +858 -13
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Button.js.map +4 -4
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Icon.js +4 -4
- package/template/node_modules/.vite/deps/_metadata.json +24 -81
- package/template/node_modules/.vite/deps/{chunk-ILHRZGIS.js → chunk-5WRI5ZAA.js} +2 -17
- package/template/node_modules/.vite/deps/{chunk-PTVT3RFX.js → chunk-7IRBE5E4.js} +3 -3
- package/template/node_modules/.vite/deps/{chunk-XB525PXG.js → chunk-D3BYX6F4.js} +3 -3
- package/template/node_modules/.vite/deps/{chunk-KFGKZMLK.js → chunk-DUV225XW.js} +3 -3
- package/template/node_modules/.vite/deps/{chunk-4TLBUCVB.js → chunk-TNWQ7JGO.js} +2 -2
- package/template/node_modules/.vite/deps/clsx.js +1 -1
- package/template/node_modules/.vite/deps/embla-carousel-react.js +2 -2
- package/template/node_modules/.vite/deps/embla-carousel-wheel-gestures.js +1 -1
- package/template/node_modules/.vite/deps/react-dom.js +3 -3
- package/template/node_modules/.vite/deps/react-dom_client.js +3 -3
- package/template/node_modules/.vite/deps/react.js +2 -2
- package/template/node_modules/.vite/deps/react_jsx-dev-runtime.js +2 -2
- package/template/node_modules/.vite/deps/react_jsx-runtime.js +3 -3
- package/template/node_modules/.vite/deps/tailwind-merge.js +1 -1
- package/template/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/template/src/styles/globals.css +0 -3
- package/template/tsconfig.json +2 -9
- package/template/vitest.config.ts +0 -1
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Checkbox.js +0 -33
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Checkbox.js.map +0 -7
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Input.js +0 -13
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_SegmentedControl.js +0 -103
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_SegmentedControl.js.map +0 -7
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Select.js +0 -1019
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Select.js.map +0 -7
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Textarea.js +0 -95
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Textarea.js.map +0 -7
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_theme.js +0 -45
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_theme.js.map +0 -7
- package/template/node_modules/.vite/deps/chunk-BAG6OO6S.js +0 -115
- package/template/node_modules/.vite/deps/chunk-BAG6OO6S.js.map +0 -7
- package/template/node_modules/.vite/deps/chunk-CQ3GYAYB.js +0 -112
- package/template/node_modules/.vite/deps/chunk-CQ3GYAYB.js.map +0 -7
- package/template/node_modules/.vite/deps/chunk-EGRHWZRV.js +0 -1
- package/template/node_modules/.vite/deps/chunk-EGRHWZRV.js.map +0 -7
- package/template/node_modules/.vite/deps/chunk-EVJ3DVH5.js +0 -628
- package/template/node_modules/.vite/deps/chunk-EVJ3DVH5.js.map +0 -7
- package/template/node_modules/.vite/deps/chunk-ILHRZGIS.js.map +0 -7
- package/template/node_modules/.vite/deps/chunk-QPJAV452.js +0 -13
- package/template/node_modules/.vite/deps/chunk-QPJAV452.js.map +0 -7
- package/template/node_modules/.vite/deps/chunk-SGWD4VEU.js +0 -15195
- package/template/node_modules/.vite/deps/chunk-SGWD4VEU.js.map +0 -7
- package/template/node_modules/.vite/deps/chunk-YOJ6QPGS.js +0 -231
- package/template/node_modules/.vite/deps/chunk-YOJ6QPGS.js.map +0 -7
- package/template/nodemon.json +0 -7
- package/template/tsconfig.node.json +0 -11
- package/template/vite.config.build.ts +0 -75
- package/template/vite.config.ts +0 -25
- /package/template/node_modules/.vite/deps/{@openai_apps-sdk-ui_components_Input.js.map → chunk-5WRI5ZAA.js.map} +0 -0
- /package/template/node_modules/.vite/deps/{chunk-PTVT3RFX.js.map → chunk-7IRBE5E4.js.map} +0 -0
- /package/template/node_modules/.vite/deps/{chunk-XB525PXG.js.map → chunk-D3BYX6F4.js.map} +0 -0
- /package/template/node_modules/.vite/deps/{chunk-KFGKZMLK.js.map → chunk-DUV225XW.js.map} +0 -0
- /package/template/node_modules/.vite/deps/{chunk-4TLBUCVB.js.map → chunk-TNWQ7JGO.js.map} +0 -0
|
@@ -1,1019 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button,
|
|
3
|
-
LoadingIndicator,
|
|
4
|
-
TransitionGroup
|
|
5
|
-
} from "./chunk-EVJ3DVH5.js";
|
|
6
|
-
import {
|
|
7
|
-
useTimeout
|
|
8
|
-
} from "./chunk-YOJ6QPGS.js";
|
|
9
|
-
import {
|
|
10
|
-
handlePressableMouseEnter,
|
|
11
|
-
preventDefaultHandler,
|
|
12
|
-
toCssVariables,
|
|
13
|
-
waitForAnimationFrame
|
|
14
|
-
} from "./chunk-BAG6OO6S.js";
|
|
15
|
-
import {
|
|
16
|
-
dist_exports,
|
|
17
|
-
dist_exports3 as dist_exports2,
|
|
18
|
-
dist_exports5 as dist_exports3
|
|
19
|
-
} from "./chunk-SGWD4VEU.js";
|
|
20
|
-
import "./chunk-KFGKZMLK.js";
|
|
21
|
-
import {
|
|
22
|
-
Check_default,
|
|
23
|
-
ChevronDownVector_default,
|
|
24
|
-
DropdownVector_default,
|
|
25
|
-
Info_default,
|
|
26
|
-
Search_default,
|
|
27
|
-
X_default
|
|
28
|
-
} from "./chunk-XB525PXG.js";
|
|
29
|
-
import {
|
|
30
|
-
Input
|
|
31
|
-
} from "./chunk-CQ3GYAYB.js";
|
|
32
|
-
import {
|
|
33
|
-
o
|
|
34
|
-
} from "./chunk-QPJAV452.js";
|
|
35
|
-
import "./chunk-EGRHWZRV.js";
|
|
36
|
-
import {
|
|
37
|
-
clsx_default
|
|
38
|
-
} from "./chunk-CNYJBM5F.js";
|
|
39
|
-
import {
|
|
40
|
-
require_jsx_runtime
|
|
41
|
-
} from "./chunk-PTVT3RFX.js";
|
|
42
|
-
import {
|
|
43
|
-
require_react
|
|
44
|
-
} from "./chunk-4TLBUCVB.js";
|
|
45
|
-
import {
|
|
46
|
-
__toESM
|
|
47
|
-
} from "./chunk-ILHRZGIS.js";
|
|
48
|
-
|
|
49
|
-
// ../node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/components/Select/Select.js
|
|
50
|
-
var import_jsx_runtime4 = __toESM(require_jsx_runtime());
|
|
51
|
-
var import_react6 = __toESM(require_react());
|
|
52
|
-
|
|
53
|
-
// ../node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/hooks/useEscCloseStack.js
|
|
54
|
-
var import_react2 = __toESM(require_react());
|
|
55
|
-
|
|
56
|
-
// ../node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/hooks/useLatestValue.js
|
|
57
|
-
var import_react = __toESM(require_react());
|
|
58
|
-
function useLatestValue(value) {
|
|
59
|
-
const ref = (0, import_react.useRef)(value);
|
|
60
|
-
ref.current = value;
|
|
61
|
-
return ref;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// ../node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/hooks/useEscCloseStack.js
|
|
65
|
-
var handlers = [];
|
|
66
|
-
var listenerBound = false;
|
|
67
|
-
var handleKeyDown = (evt) => {
|
|
68
|
-
var _a, _b;
|
|
69
|
-
if (evt.key === "Escape") {
|
|
70
|
-
const [firstHandler] = handlers;
|
|
71
|
-
if (firstHandler) {
|
|
72
|
-
evt.preventDefault();
|
|
73
|
-
(_b = (_a = firstHandler.callback).current) == null ? void 0 : _b.call(_a);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
var managerListener = () => {
|
|
78
|
-
if (handlers.length > 0 && !listenerBound) {
|
|
79
|
-
document.body.addEventListener("keydown", handleKeyDown);
|
|
80
|
-
listenerBound = true;
|
|
81
|
-
} else if (handlers.length === 0 && listenerBound) {
|
|
82
|
-
document.body.removeEventListener("keydown", handleKeyDown);
|
|
83
|
-
listenerBound = false;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
var registerHandler = (handler) => {
|
|
87
|
-
handlers.unshift(handler);
|
|
88
|
-
managerListener();
|
|
89
|
-
};
|
|
90
|
-
var unregisterHandler = ({ id }) => {
|
|
91
|
-
handlers = handlers.filter((h) => h.id !== id);
|
|
92
|
-
managerListener();
|
|
93
|
-
};
|
|
94
|
-
var useEscCloseStack = (listening, cb) => {
|
|
95
|
-
const id = (0, import_react2.useId)();
|
|
96
|
-
const latestCallback = useLatestValue(cb);
|
|
97
|
-
(0, import_react2.useEffect)(() => {
|
|
98
|
-
if (!listening) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const handler = { id, callback: latestCallback };
|
|
102
|
-
registerHandler(handler);
|
|
103
|
-
return () => unregisterHandler(handler);
|
|
104
|
-
}, [id, listening, latestCallback]);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
// ../node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/components/SelectControl/SelectControl.js
|
|
108
|
-
var import_jsx_runtime = __toESM(require_jsx_runtime());
|
|
109
|
-
var import_react3 = __toESM(require_react());
|
|
110
|
-
import s from "/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/components/SelectControl/SelectControl.module.css";
|
|
111
|
-
var SelectControl = ({ ref, onPointerDown, onKeyDown, onPointerEnter, onInteract, invalid, disabled, children, className, variant = "outline", size = "md", block, opticallyAlign, pill = true, loading, onClearClick, selected = false, StartIcon, dropdownIconType = "dropdown", ...restProps }) => {
|
|
112
|
-
const controlRef = (0, import_react3.useRef)(null);
|
|
113
|
-
const clearable = !!onClearClick;
|
|
114
|
-
const showClearAction = clearable && selected && !loading && !disabled;
|
|
115
|
-
const hasDropdownIcon = dropdownIconType && dropdownIconType !== "none" && !loading;
|
|
116
|
-
const hasAnyTertiaryIndicator = showClearAction || loading || hasDropdownIcon;
|
|
117
|
-
const isInteractive = !loading && !disabled;
|
|
118
|
-
const handleKeyDown2 = (evt) => {
|
|
119
|
-
var _a;
|
|
120
|
-
switch (evt.key) {
|
|
121
|
-
case "ArrowDown":
|
|
122
|
-
case "ArrowUp":
|
|
123
|
-
case " ":
|
|
124
|
-
evt.stopPropagation();
|
|
125
|
-
evt.preventDefault();
|
|
126
|
-
if (onInteract) {
|
|
127
|
-
onInteract();
|
|
128
|
-
} else {
|
|
129
|
-
(_a = controlRef.current) == null ? void 0 : _a.dispatchEvent(new PointerEvent("pointerdown", {
|
|
130
|
-
bubbles: true,
|
|
131
|
-
cancelable: true,
|
|
132
|
-
pointerType: "mouse"
|
|
133
|
-
// mimic mouse interaction
|
|
134
|
-
}));
|
|
135
|
-
}
|
|
136
|
-
break;
|
|
137
|
-
case "Enter":
|
|
138
|
-
break;
|
|
139
|
-
default:
|
|
140
|
-
onKeyDown == null ? void 0 : onKeyDown(evt);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
const handlePointerDown = (evt) => {
|
|
144
|
-
var _a;
|
|
145
|
-
if (evt.button === 2) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
evt.stopPropagation();
|
|
149
|
-
if (onInteract) {
|
|
150
|
-
evt.preventDefault();
|
|
151
|
-
onInteract();
|
|
152
|
-
} else {
|
|
153
|
-
onPointerDown == null ? void 0 : onPointerDown(evt);
|
|
154
|
-
(_a = restProps.onClick) == null ? void 0 : _a.call(restProps, evt);
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
return (
|
|
158
|
-
// Intentionally not using <button> and rebuilding the semantics
|
|
159
|
-
(0, import_jsx_runtime.jsxs)("span", {
|
|
160
|
-
ref: o([controlRef, ref]),
|
|
161
|
-
className: clsx_default(s.SelectControl, className),
|
|
162
|
-
// Recreate <button> semantics
|
|
163
|
-
role: "button",
|
|
164
|
-
tabIndex: disabled ? -1 : 0,
|
|
165
|
-
onPointerEnter: (evt) => {
|
|
166
|
-
handlePressableMouseEnter(evt);
|
|
167
|
-
onPointerEnter == null ? void 0 : onPointerEnter(evt);
|
|
168
|
-
},
|
|
169
|
-
onPointerDown: isInteractive ? handlePointerDown : void 0,
|
|
170
|
-
onKeyDown: isInteractive ? handleKeyDown2 : void 0,
|
|
171
|
-
"data-variant": variant,
|
|
172
|
-
"data-block": block ? "" : void 0,
|
|
173
|
-
"data-pill": pill ? "" : void 0,
|
|
174
|
-
"data-size": size,
|
|
175
|
-
"data-optically-align": opticallyAlign,
|
|
176
|
-
"aria-busy": loading ? "true" : void 0,
|
|
177
|
-
"data-selected": selected,
|
|
178
|
-
"data-loading": loading ? "" : void 0,
|
|
179
|
-
"data-invalid": invalid ? "" : void 0,
|
|
180
|
-
"data-disabled": disabled ? "" : void 0,
|
|
181
|
-
"aria-disabled": disabled,
|
|
182
|
-
...restProps,
|
|
183
|
-
// Ignore onClick handler from Radix, because we use onPointerDown to mimic a native select
|
|
184
|
-
onClick: void 0,
|
|
185
|
-
children: [StartIcon && (0, import_jsx_runtime.jsx)(StartIcon, { className: s.StartIcon }), (0, import_jsx_runtime.jsx)("span", { className: s.TriggerText, children }), hasAnyTertiaryIndicator && (0, import_jsx_runtime.jsxs)("div", { className: s.IndicatorWrapper, children: [showClearAction && (0, import_jsx_runtime.jsx)(Button, {
|
|
186
|
-
"aria-label": "Clear current value",
|
|
187
|
-
className: s.Clear,
|
|
188
|
-
onPointerDown: (evt) => {
|
|
189
|
-
evt.stopPropagation();
|
|
190
|
-
},
|
|
191
|
-
onClick: (evt) => {
|
|
192
|
-
evt.stopPropagation();
|
|
193
|
-
evt.preventDefault();
|
|
194
|
-
onClearClick();
|
|
195
|
-
},
|
|
196
|
-
color: "secondary",
|
|
197
|
-
variant: hasDropdownIcon ? "ghost" : "solid",
|
|
198
|
-
// Mostly custom sizing through variables
|
|
199
|
-
size: "3xs",
|
|
200
|
-
uniform: true,
|
|
201
|
-
pill,
|
|
202
|
-
"data-only-child": !hasDropdownIcon ? "" : void 0,
|
|
203
|
-
children: (0, import_jsx_runtime.jsx)(X_default, {})
|
|
204
|
-
}), loading && (0, import_jsx_runtime.jsx)(LoadingIndicator, { className: s.LoadingIndicator }), hasDropdownIcon && (0, import_jsx_runtime.jsx)(DropdownIcon, { iconType: dropdownIconType })] })]
|
|
205
|
-
})
|
|
206
|
-
);
|
|
207
|
-
};
|
|
208
|
-
var DropdownIcon = ({ iconType }) => {
|
|
209
|
-
return iconType === "chevronDown" ? (0, import_jsx_runtime.jsx)(ChevronDownVector_default, { className: clsx_default(s.DropdownIcon, s.DropdownIconChevron) }) : (0, import_jsx_runtime.jsx)(DropdownVector_default, { className: s.DropdownIcon });
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
// ../node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/components/Tooltip/CopyTooltip.js
|
|
213
|
-
var import_jsx_runtime3 = __toESM(require_jsx_runtime());
|
|
214
|
-
var import_react5 = __toESM(require_react());
|
|
215
|
-
|
|
216
|
-
// ../node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/components/Tooltip/Tooltip.js
|
|
217
|
-
var import_jsx_runtime2 = __toESM(require_jsx_runtime());
|
|
218
|
-
var import_react4 = __toESM(require_react());
|
|
219
|
-
import s2 from "/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/components/Tooltip/Tooltip.module.css";
|
|
220
|
-
var Tooltip = (props) => {
|
|
221
|
-
const { ref: forwardedRef, children, content, forceOpen = content === null ? false : void 0, maxWidth = 300, openDelay = 150, interactive = false, compact = false, preventUnintentionalClickToClose, align, alignOffset = 0, side, sideOffset = 5, gutterSize = "md", contentClassName, onPointerDown, onClick, ...restProps } = props;
|
|
222
|
-
const [visible, setVisible] = (0, import_react4.useState)(false);
|
|
223
|
-
const [temporarilyPreventClickToClose, setTemporarilyPreventClickToClose] = (0, import_react4.useState)(false);
|
|
224
|
-
useTimeout(() => setTemporarilyPreventClickToClose(false), temporarilyPreventClickToClose ? 400 : null);
|
|
225
|
-
const open = forceOpen ?? visible;
|
|
226
|
-
const handleOpenChange = (nextState) => {
|
|
227
|
-
if (typeof forceOpen === "boolean")
|
|
228
|
-
return;
|
|
229
|
-
setVisible(nextState);
|
|
230
|
-
if (preventUnintentionalClickToClose) {
|
|
231
|
-
setTemporarilyPreventClickToClose(nextState);
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
const maybePreventClickClose = (evt) => {
|
|
235
|
-
if (preventUnintentionalClickToClose && temporarilyPreventClickToClose) {
|
|
236
|
-
evt.preventDefault();
|
|
237
|
-
evt.stopPropagation();
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
return (0, import_jsx_runtime2.jsxs)(Root, { open, delayDuration: openDelay, onOpenChange: handleOpenChange, disableHoverableContent: !interactive, children: [(0, import_jsx_runtime2.jsx)(dist_exports3.Trigger, { asChild: true, children: (0, import_jsx_runtime2.jsx)(dist_exports.Root, { ...restProps, ref: forwardedRef, onPointerDown: (evt) => {
|
|
241
|
-
maybePreventClickClose(evt);
|
|
242
|
-
onPointerDown == null ? void 0 : onPointerDown(evt);
|
|
243
|
-
}, onClick: (evt) => {
|
|
244
|
-
maybePreventClickClose(evt);
|
|
245
|
-
onClick == null ? void 0 : onClick(evt);
|
|
246
|
-
}, children }) }), (0, import_jsx_runtime2.jsx)(Content, { maxWidth, compact, align, alignOffset, side, sideOffset, gutterSize, className: contentClassName, children: content })] });
|
|
247
|
-
};
|
|
248
|
-
var Root = ({ children, open, onOpenChange, ...restProps }) => {
|
|
249
|
-
useEscCloseStack(open, () => {
|
|
250
|
-
onOpenChange(false);
|
|
251
|
-
});
|
|
252
|
-
return (0, import_jsx_runtime2.jsx)(dist_exports3.Provider, { children: (0, import_jsx_runtime2.jsx)(dist_exports3.Root, { open, onOpenChange, ...restProps, children }) });
|
|
253
|
-
};
|
|
254
|
-
var Content = ({ children, maxWidth = 300, compact = false, clickable = void 0, alignOffset = 0, sideOffset = 5, gutterSize = "md", className, style, ...restProps }) => {
|
|
255
|
-
return (0, import_jsx_runtime2.jsx)(dist_exports3.Portal, { children: (0, import_jsx_runtime2.jsx)(dist_exports3.Content, { ...restProps, className: clsx_default(s2.Tooltip, className), "data-compact": compact, "data-clickable": clickable, "data-gutter-size": gutterSize, alignOffset, sideOffset, collisionPadding: 15, hideWhenDetached: true, style: {
|
|
256
|
-
...style,
|
|
257
|
-
maxWidth
|
|
258
|
-
}, onEscapeKeyDown: preventDefaultHandler, children }) });
|
|
259
|
-
};
|
|
260
|
-
var Trigger = ({ children, asChild = true, ...restProps }) => {
|
|
261
|
-
return (0, import_jsx_runtime2.jsx)(dist_exports3.Trigger, { asChild, ...restProps, children });
|
|
262
|
-
};
|
|
263
|
-
var TriggerDecorator = (props) => {
|
|
264
|
-
const { children, className, focusable = true, ref, ...restProps } = props;
|
|
265
|
-
const isPlainText = typeof children === "string";
|
|
266
|
-
return (0, import_jsx_runtime2.jsx)(dist_exports.Root, { ref, ...restProps, className: clsx_default(s2.TriggerDecorator, className), tabIndex: focusable ? 0 : void 0, children: isPlainText ? (0, import_jsx_runtime2.jsx)("span", { children }) : children });
|
|
267
|
-
};
|
|
268
|
-
Tooltip.Root = Root;
|
|
269
|
-
Tooltip.Content = Content;
|
|
270
|
-
Tooltip.Trigger = Trigger;
|
|
271
|
-
Tooltip.TriggerDecorator = TriggerDecorator;
|
|
272
|
-
|
|
273
|
-
// ../node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/components/Select/Select.js
|
|
274
|
-
import s3 from "/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/components/Select/Select.module.css";
|
|
275
|
-
var SelectContext = (0, import_react6.createContext)(null);
|
|
276
|
-
var useSelectContext = () => {
|
|
277
|
-
const context = (0, import_react6.use)(SelectContext);
|
|
278
|
-
if (!context) {
|
|
279
|
-
throw new Error("Select components must be wrapped in <Select />");
|
|
280
|
-
}
|
|
281
|
-
return context;
|
|
282
|
-
};
|
|
283
|
-
var DefaultOptionView = ({ label }) => (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: label });
|
|
284
|
-
var DefaultSingleTriggerView = ({ label }) => (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: label });
|
|
285
|
-
var DefaultMultiTriggerView = ({ values, selectedAll }) => {
|
|
286
|
-
const displayValue = selectedAll ? "All selected" : values.length === 0 ? (
|
|
287
|
-
// NOTE: Zero length is impossible - an empty option with `placeholder` is always returned
|
|
288
|
-
"Select..."
|
|
289
|
-
) : values.length === 1 ? values[0].label : `${values.length} selected`;
|
|
290
|
-
return (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: displayValue });
|
|
291
|
-
};
|
|
292
|
-
var Select = (props) => {
|
|
293
|
-
const { id, required, value, name, multiple, variant = "outline", size = "md", dropdownIconType = "dropdown", loading = false, clearable = false, disabled = false, placeholder = "Select...", loadingPlaceholder = "Loading...", pill = true, listWidth, options, actions: propActions = [], side = "bottom", avoidCollisions = true, onChange, optionClassName, OptionView = DefaultOptionView, TriggerStartIcon, triggerClassName, opticallyAlign, TriggerView: TriggerViewFromProps, searchPlaceholder = "", searchPredicate = defaultSearchPredicate, searchEmptyMessage = "No results found.", listMaxWidth = "auto" } = props;
|
|
294
|
-
const block = props.block ?? variant !== "ghost";
|
|
295
|
-
const align = props.align ?? (block ? "center" : "start");
|
|
296
|
-
const alignOffset = props.alignOffset ?? (align === "center" ? 0 : -5);
|
|
297
|
-
const listMinWidth = props.listMinWidth ?? (block ? "auto" : 300);
|
|
298
|
-
const onSelectRef = useLatestValue((selectedOption, removeOption) => {
|
|
299
|
-
if (multiple) {
|
|
300
|
-
if (!selectedOption.value) {
|
|
301
|
-
onChange([]);
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
if (removeOption) {
|
|
305
|
-
const nextValues = value.filter((v) => v !== selectedOption.value);
|
|
306
|
-
const currentSelectedOptions = getOptionsByValues(options, nextValues);
|
|
307
|
-
onChange(currentSelectedOptions);
|
|
308
|
-
} else {
|
|
309
|
-
const currentSelectedOptions = getOptionsByValues(options, value);
|
|
310
|
-
onChange(currentSelectedOptions.concat(selectedOption));
|
|
311
|
-
}
|
|
312
|
-
} else {
|
|
313
|
-
onChange(selectedOption);
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
const searchPredicateRef = (0, import_react6.useRef)(searchPredicate);
|
|
317
|
-
searchPredicateRef.current = searchPredicate;
|
|
318
|
-
const actions = (0, import_react6.useMemo)(() => propActions, [propActions.length]);
|
|
319
|
-
const propActionsRef = (0, import_react6.useRef)(propActions);
|
|
320
|
-
propActionsRef.current = propActions;
|
|
321
|
-
const onActionSelect = (0, import_react6.useCallback)((actionId) => {
|
|
322
|
-
var _a;
|
|
323
|
-
(_a = propActionsRef.current.find((a) => a.id === actionId)) == null ? void 0 : _a.onSelect(actionId);
|
|
324
|
-
}, []);
|
|
325
|
-
const optionsCount = (0, import_react6.useMemo)(() => isOptionGroupArray(options) ? options.reduce((acc, group) => {
|
|
326
|
-
return acc + group.options.length;
|
|
327
|
-
}, 0) : options.length, [options]);
|
|
328
|
-
const internalTriggerId = (0, import_react6.useId)();
|
|
329
|
-
const triggerId = `select-trigger-${internalTriggerId}`;
|
|
330
|
-
const searchable = optionsCount > 15;
|
|
331
|
-
const dynamicContextProps = (0, import_react6.useMemo)(() => {
|
|
332
|
-
if (multiple) {
|
|
333
|
-
return {
|
|
334
|
-
multiple: true,
|
|
335
|
-
value,
|
|
336
|
-
TriggerView: TriggerViewFromProps ?? DefaultMultiTriggerView
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
return {
|
|
340
|
-
multiple: false,
|
|
341
|
-
value,
|
|
342
|
-
TriggerView: TriggerViewFromProps ?? DefaultSingleTriggerView
|
|
343
|
-
};
|
|
344
|
-
}, [multiple, value, TriggerViewFromProps]);
|
|
345
|
-
const store = (0, import_react6.useMemo)(() => ({
|
|
346
|
-
...dynamicContextProps,
|
|
347
|
-
triggerId,
|
|
348
|
-
id,
|
|
349
|
-
// Forward props
|
|
350
|
-
name,
|
|
351
|
-
required,
|
|
352
|
-
options,
|
|
353
|
-
placeholder,
|
|
354
|
-
loadingPlaceholder,
|
|
355
|
-
loading,
|
|
356
|
-
clearable,
|
|
357
|
-
variant,
|
|
358
|
-
pill,
|
|
359
|
-
size,
|
|
360
|
-
dropdownIconType,
|
|
361
|
-
block,
|
|
362
|
-
align,
|
|
363
|
-
alignOffset,
|
|
364
|
-
side,
|
|
365
|
-
avoidCollisions,
|
|
366
|
-
listWidth,
|
|
367
|
-
listMinWidth,
|
|
368
|
-
listMaxWidth,
|
|
369
|
-
searchPlaceholder,
|
|
370
|
-
searchEmptyMessage,
|
|
371
|
-
TriggerStartIcon,
|
|
372
|
-
triggerClassName,
|
|
373
|
-
opticallyAlign,
|
|
374
|
-
optionClassName,
|
|
375
|
-
OptionView,
|
|
376
|
-
actions,
|
|
377
|
-
onActionSelect,
|
|
378
|
-
onSelectRef,
|
|
379
|
-
searchPredicateRef,
|
|
380
|
-
// Derived state
|
|
381
|
-
searchable,
|
|
382
|
-
disabled
|
|
383
|
-
}), [
|
|
384
|
-
dynamicContextProps,
|
|
385
|
-
triggerId,
|
|
386
|
-
id,
|
|
387
|
-
required,
|
|
388
|
-
name,
|
|
389
|
-
options,
|
|
390
|
-
placeholder,
|
|
391
|
-
loadingPlaceholder,
|
|
392
|
-
loading,
|
|
393
|
-
clearable,
|
|
394
|
-
variant,
|
|
395
|
-
pill,
|
|
396
|
-
size,
|
|
397
|
-
dropdownIconType,
|
|
398
|
-
block,
|
|
399
|
-
align,
|
|
400
|
-
alignOffset,
|
|
401
|
-
side,
|
|
402
|
-
avoidCollisions,
|
|
403
|
-
listWidth,
|
|
404
|
-
listMinWidth,
|
|
405
|
-
listMaxWidth,
|
|
406
|
-
searchPlaceholder,
|
|
407
|
-
searchEmptyMessage,
|
|
408
|
-
TriggerStartIcon,
|
|
409
|
-
triggerClassName,
|
|
410
|
-
opticallyAlign,
|
|
411
|
-
optionClassName,
|
|
412
|
-
OptionView,
|
|
413
|
-
actions,
|
|
414
|
-
onActionSelect,
|
|
415
|
-
onSelectRef,
|
|
416
|
-
searchable,
|
|
417
|
-
disabled
|
|
418
|
-
]);
|
|
419
|
-
return (
|
|
420
|
-
// NOTE: Cannot peacefully coerce SelectContextValue into a generic, so casting to any here.
|
|
421
|
-
// This is safe because `store` is strongly typed above.
|
|
422
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
423
|
-
(0, import_jsx_runtime4.jsx)(SelectContext.Provider, { value: store, children: (0, import_jsx_runtime4.jsx)(CustomSelect, {}) })
|
|
424
|
-
);
|
|
425
|
-
};
|
|
426
|
-
var SelectTrigger = (props) => {
|
|
427
|
-
const { triggerId, id, required, value, multiple, options, loading, disabled, clearable, name, variant, pill, size, dropdownIconType, placeholder, loadingPlaceholder, block, opticallyAlign, triggerClassName, TriggerStartIcon, TriggerView, onSelectRef } = useSelectContext();
|
|
428
|
-
const {
|
|
429
|
-
onOpenChange,
|
|
430
|
-
// pass along props from Radix
|
|
431
|
-
...restProps
|
|
432
|
-
} = props;
|
|
433
|
-
const firstValue = multiple ? value[0] : value;
|
|
434
|
-
const placeholderValue = loading ? loadingPlaceholder : placeholder;
|
|
435
|
-
const selectedItem = (0, import_react6.useMemo)(() => getOptionByValue(options, firstValue) || {
|
|
436
|
-
value: "",
|
|
437
|
-
label: placeholderValue
|
|
438
|
-
}, [firstValue, options, placeholderValue]);
|
|
439
|
-
const hasSelectedValue = multiple ? value.length > 0 : !!value;
|
|
440
|
-
const isPlaceholder = loading || !hasSelectedValue;
|
|
441
|
-
const typeahead = (0, import_react6.useMemo)(() => createTypeahead(), []);
|
|
442
|
-
const multipleTriggerViewProps = (0, import_react6.useMemo)(() => {
|
|
443
|
-
if (!multiple) {
|
|
444
|
-
return { values: [], selectedAll: false };
|
|
445
|
-
}
|
|
446
|
-
const currentSelectedOptions = getOptionsByValues(options, value);
|
|
447
|
-
const flatOptions = options.flatMap((o2) => "options" in o2 ? o2.options : o2);
|
|
448
|
-
return {
|
|
449
|
-
values: currentSelectedOptions.length ? currentSelectedOptions : [
|
|
450
|
-
{
|
|
451
|
-
value: "",
|
|
452
|
-
label: placeholderValue
|
|
453
|
-
}
|
|
454
|
-
],
|
|
455
|
-
selectedAll: flatOptions.length <= value.length
|
|
456
|
-
};
|
|
457
|
-
}, [multiple, options, value, placeholderValue]);
|
|
458
|
-
const handleKeyDown2 = (evt) => {
|
|
459
|
-
const key = evt.key;
|
|
460
|
-
if (!multiple && isValidTypeaheadChar(key)) {
|
|
461
|
-
const currentTypeaheadValue = typeahead(key);
|
|
462
|
-
evt.stopPropagation();
|
|
463
|
-
const firstMatchingOption = getTypeaheadOption(options, currentTypeaheadValue, firstValue);
|
|
464
|
-
if (firstMatchingOption) {
|
|
465
|
-
onSelectRef.current(firstMatchingOption);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
const handleClearClick = () => {
|
|
470
|
-
onSelectRef.current({ value: "", label: "" });
|
|
471
|
-
onOpenChange == null ? void 0 : onOpenChange(false);
|
|
472
|
-
};
|
|
473
|
-
return (0, import_jsx_runtime4.jsxs)(SelectControl, { id: triggerId, className: triggerClassName, selected: !isPlaceholder, variant, pill, block, size, disabled, loading, StartIcon: TriggerStartIcon, opticallyAlign, dropdownIconType, onClearClick: clearable ? handleClearClick : void 0, onInteract: onOpenChange, onKeyDown: handleKeyDown2, ...restProps, children: [multiple ? (0, import_jsx_runtime4.jsx)(TriggerView, { ...multipleTriggerViewProps }) : (0, import_jsx_runtime4.jsx)(TriggerView, { ...selectedItem }), (name || id) && (0, import_jsx_runtime4.jsx)("input", {
|
|
474
|
-
id,
|
|
475
|
-
name,
|
|
476
|
-
value: firstValue,
|
|
477
|
-
tabIndex: -1,
|
|
478
|
-
onFocus: () => {
|
|
479
|
-
var _a;
|
|
480
|
-
(_a = document.getElementById(triggerId)) == null ? void 0 : _a.focus();
|
|
481
|
-
},
|
|
482
|
-
// keep react from complaining - don't make this readOnly because that
|
|
483
|
-
// prevents the value from being required
|
|
484
|
-
onChange: () => {
|
|
485
|
-
},
|
|
486
|
-
required,
|
|
487
|
-
className: "sr-only w-full h-0 left-0 bottom-0 pointer-events-none",
|
|
488
|
-
"aria-hidden": "true"
|
|
489
|
-
})] });
|
|
490
|
-
};
|
|
491
|
-
var CustomSelect = () => {
|
|
492
|
-
const { triggerId, loading, side, align, alignOffset, avoidCollisions, listWidth, listMinWidth, listMaxWidth } = useSelectContext();
|
|
493
|
-
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
494
|
-
const selectContentRef = (0, import_react6.useRef)(null);
|
|
495
|
-
const handleOpenChange = (maybeNextState) => {
|
|
496
|
-
const nextState = maybeNextState === void 0 ? !open : maybeNextState;
|
|
497
|
-
setOpen(nextState);
|
|
498
|
-
if (!nextState) {
|
|
499
|
-
setTimeout(() => {
|
|
500
|
-
var _a;
|
|
501
|
-
if (!selectContentRef.current) {
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
const activeElement = document.activeElement;
|
|
505
|
-
if (activeElement && !selectContentRef.current.contains(activeElement)) {
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
(_a = document.getElementById(triggerId)) == null ? void 0 : _a.focus();
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
useEscCloseStack(open, () => {
|
|
513
|
-
handleOpenChange(false);
|
|
514
|
-
});
|
|
515
|
-
return (0, import_jsx_runtime4.jsxs)(dist_exports2.Root, { open, onOpenChange: (nextState) => {
|
|
516
|
-
if (loading && nextState) {
|
|
517
|
-
return;
|
|
518
|
-
}
|
|
519
|
-
handleOpenChange(nextState);
|
|
520
|
-
}, modal: false, children: [(0, import_jsx_runtime4.jsx)(dist_exports2.Trigger, { asChild: true, children: (0, import_jsx_runtime4.jsx)(SelectTrigger, { onOpenChange: handleOpenChange }) }), (0, import_jsx_runtime4.jsx)(dist_exports2.Portal, { forceMount: true, children: (0, import_jsx_runtime4.jsx)(TransitionGroup, { className: s3.Menu, enterDuration: 350, exitDuration: 200, disableAnimations: true, children: open && (0, import_jsx_runtime4.jsx)(dist_exports2.Content, {
|
|
521
|
-
ref: selectContentRef,
|
|
522
|
-
forceMount: true,
|
|
523
|
-
className: s3.MenuList,
|
|
524
|
-
side,
|
|
525
|
-
sideOffset: 5,
|
|
526
|
-
align,
|
|
527
|
-
alignOffset,
|
|
528
|
-
avoidCollisions,
|
|
529
|
-
collisionPadding: { bottom: 30, top: 30 },
|
|
530
|
-
// Prevent Radix auto focus so we can handle our own from within <CustomSelectMenu />
|
|
531
|
-
onOpenAutoFocus: preventDefaultHandler,
|
|
532
|
-
// Radix waits until the animation completes before directing focus, which is janky.
|
|
533
|
-
onCloseAutoFocus: preventDefaultHandler,
|
|
534
|
-
onEscapeKeyDown: preventDefaultHandler,
|
|
535
|
-
style: toCssVariables({
|
|
536
|
-
"select-list-width": listWidth,
|
|
537
|
-
"select-list-min-width": listMinWidth,
|
|
538
|
-
"select-list-max-width": listMaxWidth
|
|
539
|
-
}),
|
|
540
|
-
children: (0, import_jsx_runtime4.jsx)(CustomSelectMenu, { onOpenChange: handleOpenChange })
|
|
541
|
-
}, "dropdown") }) })] });
|
|
542
|
-
};
|
|
543
|
-
var CustomSelectMenuContext = (0, import_react6.createContext)(null);
|
|
544
|
-
var useCustomSelectMenuContext = () => {
|
|
545
|
-
const context = (0, import_react6.use)(CustomSelectMenuContext);
|
|
546
|
-
if (!context) {
|
|
547
|
-
throw new Error("CustomSelectMenu components must be wrapped in <CustomSelectMenu />");
|
|
548
|
-
}
|
|
549
|
-
return context;
|
|
550
|
-
};
|
|
551
|
-
var CustomSelectMenu = ({ onOpenChange }) => {
|
|
552
|
-
const { multiple, value, options, searchable, searchPredicateRef } = useSelectContext();
|
|
553
|
-
const requestCloseRef = (0, import_react6.useRef)(() => onOpenChange(false));
|
|
554
|
-
const menuRef = (0, import_react6.useRef)(null);
|
|
555
|
-
const listRef = (0, import_react6.useRef)(null);
|
|
556
|
-
const searchInputRef = (0, import_react6.useRef)(null);
|
|
557
|
-
const [searchTerm, setSearchTerm] = (0, import_react6.useState)("");
|
|
558
|
-
const [highlightedValue, setHighlightedValue] = (0, import_react6.useState)(() => {
|
|
559
|
-
var _a;
|
|
560
|
-
const selectedValue = multiple ? value[0] : value;
|
|
561
|
-
return (selectedValue || ((_a = getFirstValidOption(options)) == null ? void 0 : _a.value)) ?? "";
|
|
562
|
-
});
|
|
563
|
-
const typeahead = (0, import_react6.useMemo)(() => createTypeahead(), []);
|
|
564
|
-
const internalListId = (0, import_react6.useId)();
|
|
565
|
-
const listId = `select-list-${internalListId}`;
|
|
566
|
-
const valueRef = (0, import_react6.useRef)(multiple ? "" : value);
|
|
567
|
-
const literalSearchTerm = (0, import_react6.useMemo)(() => searchTerm.trim().toLocaleLowerCase(), [searchTerm]);
|
|
568
|
-
const filteredOptions = (0, import_react6.useMemo)(() => filterOptions(options, literalSearchTerm, searchPredicateRef.current), [options, literalSearchTerm, searchPredicateRef]);
|
|
569
|
-
const firstOption = (0, import_react6.useMemo)(() => getFirstValidOption(filteredOptions), [filteredOptions]);
|
|
570
|
-
const isMountStableRef = (0, import_react6.useRef)(false);
|
|
571
|
-
const handleKeyDown2 = (evt) => {
|
|
572
|
-
const key = evt.key;
|
|
573
|
-
const firstValue = multiple ? value[0] : value;
|
|
574
|
-
const targetValue = highlightedValue || (firstOption == null ? void 0 : firstOption.value) || firstValue;
|
|
575
|
-
const isFocusedInSearch = document.activeElement === searchInputRef.current;
|
|
576
|
-
const menuElement = menuRef.current;
|
|
577
|
-
if (!menuElement) {
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
const triggerHighlightedOption = () => {
|
|
581
|
-
const pointerUpEvent = new PointerEvent("pointerup", {
|
|
582
|
-
bubbles: true,
|
|
583
|
-
cancelable: true,
|
|
584
|
-
pointerType: "mouse"
|
|
585
|
-
});
|
|
586
|
-
const selectedOption = findOptionByValue(highlightedValue, menuElement);
|
|
587
|
-
selectedOption == null ? void 0 : selectedOption.dispatchEvent(pointerUpEvent);
|
|
588
|
-
};
|
|
589
|
-
const highlightOption = (val, element) => {
|
|
590
|
-
setHighlightedValue(val);
|
|
591
|
-
element.scrollIntoView({ block: "nearest" });
|
|
592
|
-
};
|
|
593
|
-
const highlightSelectedOrFirstOption = () => {
|
|
594
|
-
const maybeFirstValue = multiple ? value[0] : value;
|
|
595
|
-
if (maybeFirstValue) {
|
|
596
|
-
const selectedElement = findOptionByValue(maybeFirstValue, menuElement);
|
|
597
|
-
if (selectedElement) {
|
|
598
|
-
highlightOption(maybeFirstValue, selectedElement);
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
const firstValidOption = getFirstValidOption(options);
|
|
603
|
-
if (firstValidOption) {
|
|
604
|
-
const firstValidOptionElement = findOptionByValue(firstValidOption.value, menuElement);
|
|
605
|
-
if (firstValidOptionElement) {
|
|
606
|
-
highlightOption(firstValidOption.value, firstValidOptionElement);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
};
|
|
610
|
-
switch (key) {
|
|
611
|
-
case "ArrowDown": {
|
|
612
|
-
evt.preventDefault();
|
|
613
|
-
if (!highlightedValue || !findOptionByValue(highlightedValue, menuElement)) {
|
|
614
|
-
highlightSelectedOrFirstOption();
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
const nextElement = findNextOption(highlightedValue, menuElement);
|
|
618
|
-
const nextValue = nextElement == null ? void 0 : nextElement.getAttribute("data-option-id");
|
|
619
|
-
if (nextElement && nextValue) {
|
|
620
|
-
highlightOption(nextValue, nextElement);
|
|
621
|
-
}
|
|
622
|
-
return;
|
|
623
|
-
}
|
|
624
|
-
case "ArrowUp": {
|
|
625
|
-
evt.preventDefault();
|
|
626
|
-
if (!highlightedValue || !findOptionByValue(highlightedValue, menuElement)) {
|
|
627
|
-
highlightSelectedOrFirstOption();
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
630
|
-
const previousElement = findPreviousOption(targetValue, menuElement);
|
|
631
|
-
const previousValue = previousElement == null ? void 0 : previousElement.getAttribute("data-option-id");
|
|
632
|
-
if (previousElement && previousValue) {
|
|
633
|
-
highlightOption(previousValue, previousElement);
|
|
634
|
-
}
|
|
635
|
-
return;
|
|
636
|
-
}
|
|
637
|
-
case "Enter":
|
|
638
|
-
evt.preventDefault();
|
|
639
|
-
triggerHighlightedOption();
|
|
640
|
-
return;
|
|
641
|
-
case " ":
|
|
642
|
-
if (literalSearchTerm && isFocusedInSearch) {
|
|
643
|
-
return;
|
|
644
|
-
}
|
|
645
|
-
evt.preventDefault();
|
|
646
|
-
triggerHighlightedOption();
|
|
647
|
-
return;
|
|
648
|
-
default:
|
|
649
|
-
break;
|
|
650
|
-
}
|
|
651
|
-
if (isValidTypeaheadChar(key)) {
|
|
652
|
-
if (isFocusedInSearch) {
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
655
|
-
const currentTypeaheadValue = typeahead(key);
|
|
656
|
-
evt.stopPropagation();
|
|
657
|
-
const firstMatchingOption = getTypeaheadOption(options, currentTypeaheadValue, highlightedValue);
|
|
658
|
-
if (firstMatchingOption) {
|
|
659
|
-
const matchedNode = findOptionByValue(firstMatchingOption.value, menuElement);
|
|
660
|
-
if (matchedNode) {
|
|
661
|
-
setHighlightedValue(firstMatchingOption.value);
|
|
662
|
-
matchedNode.scrollIntoView({ block: "nearest" });
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
};
|
|
667
|
-
const store = (0, import_react6.useMemo)(() => ({
|
|
668
|
-
valueRef,
|
|
669
|
-
listId,
|
|
670
|
-
highlightedValue,
|
|
671
|
-
setHighlightedValue,
|
|
672
|
-
requestCloseRef,
|
|
673
|
-
searchTerm,
|
|
674
|
-
setSearchTerm,
|
|
675
|
-
searchInputRef,
|
|
676
|
-
listRef
|
|
677
|
-
}), [listId, highlightedValue, setHighlightedValue, searchTerm, setSearchTerm]);
|
|
678
|
-
(0, import_react6.useEffect)(() => {
|
|
679
|
-
waitForAnimationFrame(() => {
|
|
680
|
-
if (!menuRef.current) {
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
const currentOption = findOptionByValue(highlightedValue, menuRef.current);
|
|
684
|
-
currentOption == null ? void 0 : currentOption.scrollIntoView({ block: "center" });
|
|
685
|
-
});
|
|
686
|
-
const autoFocusTarget = searchInputRef.current || menuRef.current;
|
|
687
|
-
autoFocusTarget == null ? void 0 : autoFocusTarget.focus({ preventScroll: true });
|
|
688
|
-
return () => {
|
|
689
|
-
isMountStableRef.current = false;
|
|
690
|
-
};
|
|
691
|
-
}, []);
|
|
692
|
-
(0, import_react6.useLayoutEffect)(() => {
|
|
693
|
-
if (!isMountStableRef.current) {
|
|
694
|
-
isMountStableRef.current = true;
|
|
695
|
-
return;
|
|
696
|
-
}
|
|
697
|
-
if (!listRef.current) {
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
listRef.current.scrollTop = 0;
|
|
701
|
-
const maybeFirstOption = getFirstValidOption(filteredOptions);
|
|
702
|
-
if (maybeFirstOption)
|
|
703
|
-
setHighlightedValue(maybeFirstOption.value);
|
|
704
|
-
}, [filteredOptions]);
|
|
705
|
-
return (0, import_jsx_runtime4.jsx)(CustomSelectMenuContext, { value: store, children: (0, import_jsx_runtime4.jsxs)("div", { id: listId, className: s3.MenuInner, onKeyDown: handleKeyDown2, ref: menuRef, tabIndex: 0, children: [searchable && (0, import_jsx_runtime4.jsx)(CustomSelectSearch, { value: searchTerm, onChange: setSearchTerm }), (0, import_jsx_runtime4.jsx)(CustomSelectList, { filteredOptions }), (0, import_jsx_runtime4.jsx)(CustomSelectActions, {})] }) });
|
|
706
|
-
};
|
|
707
|
-
var CustomSelectSearch = ({ value, onChange }) => {
|
|
708
|
-
const { searchPlaceholder } = useSelectContext();
|
|
709
|
-
const { listId, searchInputRef } = useCustomSelectMenuContext();
|
|
710
|
-
const handleChange = (evt) => {
|
|
711
|
-
onChange(evt.target.value);
|
|
712
|
-
};
|
|
713
|
-
return (0, import_jsx_runtime4.jsx)("div", { className: s3.Search, children: (0, import_jsx_runtime4.jsx)(Input, { startAdornment: (0, import_jsx_runtime4.jsx)(Search_default, { width: 16, height: 16, className: "fill-secondary" }), ref: searchInputRef, value, placeholder: searchPlaceholder, onChange: handleChange, autoComplete: "off", autoCorrect: "off", spellCheck: false, "aria-autocomplete": "list", role: "combobox", "aria-controls": listId, "aria-expanded": true }) });
|
|
714
|
-
};
|
|
715
|
-
var isOptionGroup = (mixedOption) => {
|
|
716
|
-
return "options" in mixedOption;
|
|
717
|
-
};
|
|
718
|
-
var isOptionGroupArray = (arr) => {
|
|
719
|
-
return arr[0] && isOptionGroup(arr[0]);
|
|
720
|
-
};
|
|
721
|
-
var HARD_OPTIONS_LIMIT = 300;
|
|
722
|
-
var CustomSelectList = ({ filteredOptions }) => {
|
|
723
|
-
const { searchEmptyMessage } = useSelectContext();
|
|
724
|
-
const { listRef } = useCustomSelectMenuContext();
|
|
725
|
-
if (!filteredOptions.length) {
|
|
726
|
-
return typeof searchEmptyMessage === "string" ? (0, import_jsx_runtime4.jsx)("p", { className: s3.SearchEmpty, "data-text-only": true, children: searchEmptyMessage }) : (0, import_jsx_runtime4.jsx)("div", { className: s3.SearchEmpty, children: searchEmptyMessage });
|
|
727
|
-
}
|
|
728
|
-
const isGrouped = isOptionGroupArray(filteredOptions);
|
|
729
|
-
const hasHardLimit = !isGrouped && filteredOptions.length > HARD_OPTIONS_LIMIT;
|
|
730
|
-
const options = isGrouped ? filteredOptions.map((group) => (0, import_jsx_runtime4.jsx)(CustomSelectGroup, { ...group }, group.label)) : filteredOptions.slice(0, HARD_OPTIONS_LIMIT).map((option) => (0, import_jsx_runtime4.jsx)(CustomSelectOption, { ...option }, option.value));
|
|
731
|
-
return (0, import_jsx_runtime4.jsxs)("div", { className: s3.OptionsList, ref: listRef, children: [options, hasHardLimit && (0, import_jsx_runtime4.jsx)(CustomSelectHardLimit, { numHidden: filteredOptions.length - HARD_OPTIONS_LIMIT })] });
|
|
732
|
-
};
|
|
733
|
-
var DEFAULT_OPTIONS_LIMIT = {
|
|
734
|
-
limit: 100,
|
|
735
|
-
label: "Show all"
|
|
736
|
-
};
|
|
737
|
-
var CustomSelectGroup = ({ label, options, optionsLimit = DEFAULT_OPTIONS_LIMIT }) => {
|
|
738
|
-
const groupId = (0, import_react6.useId)();
|
|
739
|
-
const { searchTerm, setHighlightedValue } = useCustomSelectMenuContext();
|
|
740
|
-
const [limitExpanded, setLimitExpanded] = (0, import_react6.useState)(false);
|
|
741
|
-
const hasExpandableLimit = optionsLimit.limit < options.length && !searchTerm && !limitExpanded;
|
|
742
|
-
const hasHardLimit = HARD_OPTIONS_LIMIT < options.length && !hasExpandableLimit;
|
|
743
|
-
let maybeLimitedOptions = options;
|
|
744
|
-
if (hasExpandableLimit) {
|
|
745
|
-
maybeLimitedOptions = options.slice(0, optionsLimit.limit);
|
|
746
|
-
} else if (hasHardLimit) {
|
|
747
|
-
maybeLimitedOptions = options.slice(0, HARD_OPTIONS_LIMIT);
|
|
748
|
-
}
|
|
749
|
-
const handleLimitExpanded = () => {
|
|
750
|
-
setLimitExpanded(true);
|
|
751
|
-
setHighlightedValue(options[optionsLimit.limit].value);
|
|
752
|
-
};
|
|
753
|
-
return (
|
|
754
|
-
// NOTE: Important for crawling that groups are flat
|
|
755
|
-
(0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [(0, import_jsx_runtime4.jsxs)("div", { className: s3.OptionGroupHeading, children: [(0, import_jsx_runtime4.jsx)("div", { className: s3.OptionIndicatorSlot }), label] }), maybeLimitedOptions.map((limitedOptions) => (0, import_jsx_runtime4.jsx)(CustomSelectOption, { ...limitedOptions }, limitedOptions.value)), hasExpandableLimit && (0, import_jsx_runtime4.jsx)(CustomSelectExpandableLimit, { value: `group-limit-${groupId}`, label: optionsLimit.label, onPointerUp: handleLimitExpanded }), hasHardLimit && (0, import_jsx_runtime4.jsx)(CustomSelectHardLimit, { numHidden: options.length - HARD_OPTIONS_LIMIT })] })
|
|
756
|
-
);
|
|
757
|
-
};
|
|
758
|
-
var CustomSelectHardLimit = ({ numHidden }) => {
|
|
759
|
-
return (0, import_jsx_runtime4.jsxs)("div", { className: s3.OptionHardLimitHeading, children: [(0, import_jsx_runtime4.jsx)("div", { className: s3.OptionIndicatorSlot }), `…and ${numHidden.toLocaleString()} more options. Use search to refine results further.`] });
|
|
760
|
-
};
|
|
761
|
-
var CustomSelectExpandableLimit = ({ value, label, onPointerUp }) => {
|
|
762
|
-
const { highlightedValue, setHighlightedValue } = useCustomSelectMenuContext();
|
|
763
|
-
const isHighlighted = value === highlightedValue;
|
|
764
|
-
const handlePointerMove = () => {
|
|
765
|
-
if (isHighlighted) {
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
setHighlightedValue(value);
|
|
769
|
-
};
|
|
770
|
-
const handlePointerLeave = () => {
|
|
771
|
-
setHighlightedValue((currentHighlightedValue) => {
|
|
772
|
-
return currentHighlightedValue !== value ? currentHighlightedValue : "";
|
|
773
|
-
});
|
|
774
|
-
};
|
|
775
|
-
return (0, import_jsx_runtime4.jsx)("div", { className: clsx_default(s3.Option, s3.OptionsLimit), "data-option-id": value, "data-highlight": isHighlighted ? "" : void 0, role: "option", "aria-selected": isHighlighted, onPointerUp, onPointerMove: handlePointerMove, onPointerLeave: handlePointerLeave, children: (0, import_jsx_runtime4.jsxs)("div", { className: clsx_default(s3.PressableInner, s3.OptionInner), children: [(0, import_jsx_runtime4.jsx)("div", { className: s3.OptionIndicatorSlot }), label] }) });
|
|
776
|
-
};
|
|
777
|
-
var INTERNAL_DOM_SELECTION_DATA_ATTR = "data-option-id";
|
|
778
|
-
var CustomSelectOption = (option) => {
|
|
779
|
-
const { optionClassName, OptionView, value: propsValue, multiple, onSelectRef } = useSelectContext();
|
|
780
|
-
const { valueRef, requestCloseRef, highlightedValue, setHighlightedValue } = useCustomSelectMenuContext();
|
|
781
|
-
const { value, disabled, tooltip } = option;
|
|
782
|
-
const currentValue = valueRef.current;
|
|
783
|
-
const isSelected = multiple ? propsValue.includes(value) : value === currentValue;
|
|
784
|
-
const isHighlighted = value === highlightedValue;
|
|
785
|
-
const handlePointerUp = () => {
|
|
786
|
-
var _a;
|
|
787
|
-
if (multiple) {
|
|
788
|
-
onSelectRef.current(option, isSelected);
|
|
789
|
-
} else {
|
|
790
|
-
onSelectRef.current(option);
|
|
791
|
-
(_a = requestCloseRef.current) == null ? void 0 : _a.call(requestCloseRef);
|
|
792
|
-
}
|
|
793
|
-
};
|
|
794
|
-
const handlePointerMove = () => {
|
|
795
|
-
if (isHighlighted) {
|
|
796
|
-
return;
|
|
797
|
-
}
|
|
798
|
-
setHighlightedValue(value);
|
|
799
|
-
};
|
|
800
|
-
const handlePointerLeave = () => {
|
|
801
|
-
setHighlightedValue((currentHighlightedValue) => {
|
|
802
|
-
return currentHighlightedValue !== value ? currentHighlightedValue : "";
|
|
803
|
-
});
|
|
804
|
-
};
|
|
805
|
-
return (0, import_jsx_runtime4.jsx)("div", {
|
|
806
|
-
className: clsx_default(s3.Option, optionClassName),
|
|
807
|
-
"data-highlight": isHighlighted ? "" : void 0,
|
|
808
|
-
role: "option",
|
|
809
|
-
"aria-selected": isHighlighted,
|
|
810
|
-
"data-selected": isSelected ? "" : void 0,
|
|
811
|
-
[INTERNAL_DOM_SELECTION_DATA_ATTR]: value,
|
|
812
|
-
// Allow options to behave like a native select, when you can open and select an item in a single click
|
|
813
|
-
onPointerUp: disabled ? void 0 : handlePointerUp,
|
|
814
|
-
// Pointer move allows us to prevent contention from keyboard presses and a still mouse
|
|
815
|
-
// which does trigger events like onMouseEnter, creating weird battles with mouse and keyboard focus.
|
|
816
|
-
onPointerMove: disabled ? void 0 : handlePointerMove,
|
|
817
|
-
onPointerLeave: disabled ? void 0 : handlePointerLeave,
|
|
818
|
-
"aria-disabled": disabled,
|
|
819
|
-
"data-disabled": disabled ? "" : void 0,
|
|
820
|
-
children: (0, import_jsx_runtime4.jsxs)("div", { className: s3.PressableInner, children: [(0, import_jsx_runtime4.jsxs)("div", { className: s3.OptionInner, children: [(0, import_jsx_runtime4.jsx)("div", { className: s3.OptionIndicatorSlot, children: isSelected && (0, import_jsx_runtime4.jsx)(Check_default, { className: s3.OptionCheck }) }), (0, import_jsx_runtime4.jsx)(OptionView, { ...option }), tooltip && (0, import_jsx_runtime4.jsx)(Tooltip, { content: tooltip.content, maxWidth: tooltip.maxWidth, side: "right", children: (0, import_jsx_runtime4.jsx)(Info_default, {}) })] }), option.description && (0, import_jsx_runtime4.jsxs)("div", { className: s3.OptionInner, children: [(0, import_jsx_runtime4.jsx)("div", { className: s3.OptionIndicatorSlot }), option.description] })] })
|
|
821
|
-
});
|
|
822
|
-
};
|
|
823
|
-
var CustomSelectActions = () => {
|
|
824
|
-
const { actions } = useSelectContext();
|
|
825
|
-
if (actions.length === 0) {
|
|
826
|
-
return null;
|
|
827
|
-
}
|
|
828
|
-
return (0, import_jsx_runtime4.jsx)("div", { className: s3.ActionsContainer, children: actions.map((action) => (0, import_jsx_runtime4.jsx)(CustomSelectAction, { ...action }, action.id)) });
|
|
829
|
-
};
|
|
830
|
-
var CustomSelectAction = ({ id, label, Icon, className }) => {
|
|
831
|
-
const { onActionSelect } = useSelectContext();
|
|
832
|
-
const { requestCloseRef } = useCustomSelectMenuContext();
|
|
833
|
-
const handleKeyDown2 = (evt) => {
|
|
834
|
-
const key = evt.key;
|
|
835
|
-
switch (key) {
|
|
836
|
-
case "Tab":
|
|
837
|
-
break;
|
|
838
|
-
case "Enter":
|
|
839
|
-
case " ":
|
|
840
|
-
evt.stopPropagation();
|
|
841
|
-
handlePointerUp();
|
|
842
|
-
break;
|
|
843
|
-
default:
|
|
844
|
-
evt.stopPropagation();
|
|
845
|
-
}
|
|
846
|
-
};
|
|
847
|
-
const handlePointerUp = () => {
|
|
848
|
-
var _a;
|
|
849
|
-
onActionSelect(id);
|
|
850
|
-
(_a = requestCloseRef.current) == null ? void 0 : _a.call(requestCloseRef);
|
|
851
|
-
};
|
|
852
|
-
return (0, import_jsx_runtime4.jsx)("div", { className: s3.Action, onPointerUp: handlePointerUp, onKeyDown: handleKeyDown2, tabIndex: 0, children: (0, import_jsx_runtime4.jsxs)("div", { className: clsx_default(s3.ActionInner, className), children: [Icon && (0, import_jsx_runtime4.jsx)(Icon, { role: "presentation" }), label] }) });
|
|
853
|
-
};
|
|
854
|
-
var defaultSearchPredicate = (option, searchTerm) => option.label.toLowerCase().includes(searchTerm);
|
|
855
|
-
var filterOptions = (options, searchTerm, searchIterator) => {
|
|
856
|
-
const searchValue = searchTerm.trim().toLocaleLowerCase();
|
|
857
|
-
if (!searchValue) {
|
|
858
|
-
return options;
|
|
859
|
-
}
|
|
860
|
-
const filterOption = (option) => searchIterator(option, searchValue);
|
|
861
|
-
if (isOptionGroupArray(options)) {
|
|
862
|
-
return options.reduce((acc, group) => {
|
|
863
|
-
const filtered = group.options.filter(filterOption);
|
|
864
|
-
if (filtered.length) {
|
|
865
|
-
acc.push({
|
|
866
|
-
...group,
|
|
867
|
-
options: filtered
|
|
868
|
-
});
|
|
869
|
-
}
|
|
870
|
-
return acc;
|
|
871
|
-
}, []);
|
|
872
|
-
} else {
|
|
873
|
-
return options.reduce((acc, option) => {
|
|
874
|
-
if (filterOption(option))
|
|
875
|
-
acc.push(option);
|
|
876
|
-
return acc;
|
|
877
|
-
}, []);
|
|
878
|
-
}
|
|
879
|
-
};
|
|
880
|
-
var getFirstValidOption = (options) => {
|
|
881
|
-
if (!options.length) {
|
|
882
|
-
return void 0;
|
|
883
|
-
}
|
|
884
|
-
let found;
|
|
885
|
-
for (const opt of options) {
|
|
886
|
-
if (isOptionGroup(opt)) {
|
|
887
|
-
const firstNonDisabled = opt.options.find((i) => !i.disabled);
|
|
888
|
-
if (firstNonDisabled) {
|
|
889
|
-
found = firstNonDisabled;
|
|
890
|
-
break;
|
|
891
|
-
}
|
|
892
|
-
} else {
|
|
893
|
-
if (!opt.disabled) {
|
|
894
|
-
found = opt;
|
|
895
|
-
break;
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
return found;
|
|
900
|
-
};
|
|
901
|
-
var getOptionByValue = (options, value) => {
|
|
902
|
-
let found;
|
|
903
|
-
for (const opt of options) {
|
|
904
|
-
if (isOptionGroup(opt)) {
|
|
905
|
-
const exists = opt.options.find((i) => i.value === value);
|
|
906
|
-
if (exists) {
|
|
907
|
-
found = exists;
|
|
908
|
-
break;
|
|
909
|
-
}
|
|
910
|
-
} else {
|
|
911
|
-
if (opt.value === value) {
|
|
912
|
-
found = opt;
|
|
913
|
-
break;
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
return found;
|
|
918
|
-
};
|
|
919
|
-
var getOptionsByValues = (options, values) => {
|
|
920
|
-
let found = [];
|
|
921
|
-
const lookup = new Set(values);
|
|
922
|
-
for (const opt of options) {
|
|
923
|
-
if (isOptionGroup(opt)) {
|
|
924
|
-
const exists = opt.options.filter((i) => lookup.has(i.value));
|
|
925
|
-
found = found.concat(exists);
|
|
926
|
-
} else {
|
|
927
|
-
if (lookup.has(opt.value)) {
|
|
928
|
-
found.push(opt);
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
return found;
|
|
933
|
-
};
|
|
934
|
-
var MAX_DOM_CRAWLS = 40;
|
|
935
|
-
var findOptionByValue = (currentValue, container) => container.querySelector(`[data-option-id="${currentValue}"]`);
|
|
936
|
-
var isValidOptionNode = (node) => node.matches("[data-option-id]:not([data-disabled])");
|
|
937
|
-
var findNextOption = (currentValue, container) => {
|
|
938
|
-
const currentOption = findOptionByValue(currentValue, container);
|
|
939
|
-
let nextNode = currentOption == null ? void 0 : currentOption.nextElementSibling;
|
|
940
|
-
let maxSteps = 0;
|
|
941
|
-
while (nextNode && maxSteps < MAX_DOM_CRAWLS) {
|
|
942
|
-
if (isValidOptionNode(nextNode)) {
|
|
943
|
-
return nextNode;
|
|
944
|
-
}
|
|
945
|
-
nextNode = nextNode.nextElementSibling;
|
|
946
|
-
maxSteps += 1;
|
|
947
|
-
}
|
|
948
|
-
};
|
|
949
|
-
var findPreviousOption = (currentValue, container) => {
|
|
950
|
-
const currentOption = findOptionByValue(currentValue, container);
|
|
951
|
-
let nextNode = currentOption == null ? void 0 : currentOption.previousElementSibling;
|
|
952
|
-
let maxSteps = 0;
|
|
953
|
-
while (nextNode && maxSteps < MAX_DOM_CRAWLS) {
|
|
954
|
-
if (isValidOptionNode(nextNode)) {
|
|
955
|
-
return nextNode;
|
|
956
|
-
}
|
|
957
|
-
nextNode = nextNode.previousElementSibling;
|
|
958
|
-
maxSteps += 1;
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
var createTypeahead = () => {
|
|
962
|
-
let currentValue = "";
|
|
963
|
-
let timeoutId;
|
|
964
|
-
return (char) => {
|
|
965
|
-
char = char.toLowerCase();
|
|
966
|
-
currentValue += char;
|
|
967
|
-
if (timeoutId)
|
|
968
|
-
clearTimeout(timeoutId);
|
|
969
|
-
timeoutId = setTimeout(() => {
|
|
970
|
-
currentValue = "";
|
|
971
|
-
}, 500);
|
|
972
|
-
const isCycling = char.repeat(currentValue.length) === currentValue;
|
|
973
|
-
return isCycling ? char : currentValue;
|
|
974
|
-
};
|
|
975
|
-
};
|
|
976
|
-
var isValidTypeaheadChar = (char) => /^[a-zA-Z0-9]$/.test(char);
|
|
977
|
-
var getTypeaheadOption = (options, typeaheadValue, currentHighlightValue) => {
|
|
978
|
-
if (!options.length) {
|
|
979
|
-
return void 0;
|
|
980
|
-
}
|
|
981
|
-
let matchBeforeHighlight;
|
|
982
|
-
let matchAfterHighlight;
|
|
983
|
-
let foundHighlightedValue = !currentHighlightValue;
|
|
984
|
-
const optionValidAndMatches = ({ disabled, label, value }) => {
|
|
985
|
-
if (value === currentHighlightValue) {
|
|
986
|
-
foundHighlightedValue = true;
|
|
987
|
-
return false;
|
|
988
|
-
}
|
|
989
|
-
return !disabled && label.toLowerCase().startsWith(typeaheadValue);
|
|
990
|
-
};
|
|
991
|
-
for (const opt of options) {
|
|
992
|
-
if (isOptionGroup(opt)) {
|
|
993
|
-
for (const option of opt.options) {
|
|
994
|
-
if (optionValidAndMatches(option)) {
|
|
995
|
-
if (foundHighlightedValue) {
|
|
996
|
-
matchAfterHighlight = option;
|
|
997
|
-
break;
|
|
998
|
-
} else {
|
|
999
|
-
matchBeforeHighlight = matchBeforeHighlight || option;
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
} else {
|
|
1004
|
-
if (optionValidAndMatches(opt)) {
|
|
1005
|
-
if (foundHighlightedValue) {
|
|
1006
|
-
matchAfterHighlight = opt;
|
|
1007
|
-
break;
|
|
1008
|
-
} else {
|
|
1009
|
-
matchBeforeHighlight = matchBeforeHighlight || opt;
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
return matchAfterHighlight || matchBeforeHighlight;
|
|
1015
|
-
};
|
|
1016
|
-
export {
|
|
1017
|
-
Select
|
|
1018
|
-
};
|
|
1019
|
-
//# sourceMappingURL=@openai_apps-sdk-ui_components_Select.js.map
|