@underverse-ui/underverse 2.0.17 → 2.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/api-reference.json +23 -2
- package/dist/{EmojiPicker-3X2S7XPP.js → EmojiPicker-SFPFCRI4.js} +4 -4
- package/dist/{chunk-HTGAV4IG.js → chunk-LQCKCWVZ.js} +3 -3
- package/dist/{chunk-YM56RXIZ.js → chunk-MSTO23JM.js} +6 -6
- package/dist/{chunk-HEXF4EOB.js → chunk-NJ53GV74.js} +3 -3
- package/dist/{chunk-EPBYGZHZ.js → chunk-PZCD342B.js} +6 -4
- package/dist/{chunk-EPBYGZHZ.js.map → chunk-PZCD342B.js.map} +1 -1
- package/dist/{chunk-23VKHYEB.js → chunk-RSLY7UU2.js} +70 -50
- package/dist/chunk-RSLY7UU2.js.map +1 -0
- package/dist/{chunk-SKCO2GFM.js → chunk-SBDZKVUJ.js} +2 -2
- package/dist/index.cjs +114 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +49 -18
- package/dist/index.js.map +1 -1
- package/dist/{menu-bar-7MPCNTHR.js → menu-bar-JXYQ5CH5.js} +4 -4
- package/dist/ueditor.cjs +69 -47
- package/dist/ueditor.cjs.map +1 -1
- package/dist/ueditor.js +4 -4
- package/package.json +2 -1
- package/dist/chunk-23VKHYEB.js.map +0 -1
- /package/dist/{EmojiPicker-3X2S7XPP.js.map → EmojiPicker-SFPFCRI4.js.map} +0 -0
- /package/dist/{chunk-HTGAV4IG.js.map → chunk-LQCKCWVZ.js.map} +0 -0
- /package/dist/{chunk-YM56RXIZ.js.map → chunk-MSTO23JM.js.map} +0 -0
- /package/dist/{chunk-HEXF4EOB.js.map → chunk-NJ53GV74.js.map} +0 -0
- /package/dist/{chunk-SKCO2GFM.js.map → chunk-SBDZKVUJ.js.map} +0 -0
- /package/dist/{menu-bar-7MPCNTHR.js.map → menu-bar-JXYQ5CH5.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cn
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PZCD342B.js";
|
|
4
4
|
|
|
5
5
|
// src/components/emoji-ui.tsx
|
|
6
6
|
import React from "react";
|
|
@@ -71,4 +71,4 @@ export {
|
|
|
71
71
|
getEmojiImageUrl,
|
|
72
72
|
EmojiGridButton
|
|
73
73
|
};
|
|
74
|
-
//# sourceMappingURL=chunk-
|
|
74
|
+
//# sourceMappingURL=chunk-SBDZKVUJ.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -2416,11 +2416,13 @@ function UEditorPortalProvider({
|
|
|
2416
2416
|
function useUEditorPortalContainerGetter() {
|
|
2417
2417
|
return React12.useContext(UEditorPortalContext);
|
|
2418
2418
|
}
|
|
2419
|
-
function resolveUEditorPortalContainer(getPortalContainer) {
|
|
2419
|
+
function resolveUEditorPortalContainer(getPortalContainer, fallbackGetPortalContainer) {
|
|
2420
2420
|
if (typeof document === "undefined") return null;
|
|
2421
|
-
|
|
2421
|
+
const getters = [getPortalContainer, fallbackGetPortalContainer];
|
|
2422
|
+
for (const getter of getters) {
|
|
2423
|
+
if (!getter) continue;
|
|
2422
2424
|
try {
|
|
2423
|
-
const container =
|
|
2425
|
+
const container = getter();
|
|
2424
2426
|
if (container) return container;
|
|
2425
2427
|
} catch {
|
|
2426
2428
|
}
|
|
@@ -3967,24 +3969,26 @@ var init_Modal = __esm({
|
|
|
3967
3969
|
});
|
|
3968
3970
|
|
|
3969
3971
|
// src/utils/animations.ts
|
|
3970
|
-
function ensureAnimationStylesInjected() {
|
|
3971
|
-
|
|
3972
|
+
function ensureAnimationStylesInjected(targetDocument) {
|
|
3973
|
+
const resolvedDocument = targetDocument ?? (typeof document !== "undefined" ? document : void 0);
|
|
3974
|
+
if (resolvedDocument) {
|
|
3972
3975
|
const styleId = "shadcn-animations";
|
|
3973
|
-
if (!
|
|
3974
|
-
const styleElement =
|
|
3976
|
+
if (!resolvedDocument.getElementById(styleId)) {
|
|
3977
|
+
const styleElement = resolvedDocument.createElement("style");
|
|
3975
3978
|
styleElement.id = styleId;
|
|
3976
3979
|
styleElement.textContent = shadcnAnimationStyles;
|
|
3977
|
-
|
|
3980
|
+
resolvedDocument.head.appendChild(styleElement);
|
|
3978
3981
|
}
|
|
3979
3982
|
}
|
|
3980
3983
|
}
|
|
3981
|
-
function useShadCNAnimations() {
|
|
3984
|
+
function useShadCNAnimations(targetDocument) {
|
|
3982
3985
|
(0, import_react14.useEffect)(() => {
|
|
3983
|
-
|
|
3984
|
-
|
|
3986
|
+
if (targetDocument === null) return;
|
|
3987
|
+
ensureAnimationStylesInjected(targetDocument);
|
|
3988
|
+
}, [targetDocument]);
|
|
3985
3989
|
}
|
|
3986
|
-
function injectAnimationStyles() {
|
|
3987
|
-
ensureAnimationStylesInjected();
|
|
3990
|
+
function injectAnimationStyles(targetDocument) {
|
|
3991
|
+
ensureAnimationStylesInjected(targetDocument);
|
|
3988
3992
|
}
|
|
3989
3993
|
function getAnimationStyles() {
|
|
3990
3994
|
return shadcnAnimationStyles;
|
|
@@ -4193,20 +4197,30 @@ function overflowAmount(left, width, viewportWidth, padding) {
|
|
|
4193
4197
|
return overflowLeft + overflowRight;
|
|
4194
4198
|
}
|
|
4195
4199
|
function computePopoverPosition(args) {
|
|
4196
|
-
const { triggerRect, contentSize, placement, offset, padding, viewport } = args;
|
|
4200
|
+
const { triggerRect, contentSize, placement, offset, padding, viewport, constrainToAvailableHeight } = args;
|
|
4197
4201
|
let { side, align } = normalizePlacement(placement);
|
|
4202
|
+
const availableBelow = Math.max(0, viewport.height - padding - triggerRect.bottom - offset);
|
|
4203
|
+
const availableAbove = Math.max(0, triggerRect.top - padding - offset);
|
|
4198
4204
|
if (side === "bottom") {
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4205
|
+
if (constrainToAvailableHeight) {
|
|
4206
|
+
if (contentSize.height > availableBelow && availableAbove > availableBelow) side = "top";
|
|
4207
|
+
} else {
|
|
4208
|
+
const bottomTop = triggerRect.bottom + offset;
|
|
4209
|
+
const overflowsBottom = bottomTop + contentSize.height > viewport.height - padding;
|
|
4210
|
+
const topTop = triggerRect.top - offset - contentSize.height;
|
|
4211
|
+
const fitsTop = topTop >= padding;
|
|
4212
|
+
if (overflowsBottom && fitsTop) side = "top";
|
|
4213
|
+
}
|
|
4204
4214
|
} else if (side === "top") {
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4215
|
+
if (constrainToAvailableHeight) {
|
|
4216
|
+
if (contentSize.height > availableAbove && availableBelow > availableAbove) side = "bottom";
|
|
4217
|
+
} else {
|
|
4218
|
+
const topTop = triggerRect.top - offset - contentSize.height;
|
|
4219
|
+
const overflowsTop = topTop < padding;
|
|
4220
|
+
const bottomTop = triggerRect.bottom + offset;
|
|
4221
|
+
const fitsBottom = bottomTop + contentSize.height <= viewport.height - padding;
|
|
4222
|
+
if (overflowsTop && fitsBottom) side = "bottom";
|
|
4223
|
+
}
|
|
4210
4224
|
} else if (side === "right") {
|
|
4211
4225
|
const rightLeft = triggerRect.right + offset;
|
|
4212
4226
|
const overflowsRight = rightLeft + contentSize.width > viewport.width - padding;
|
|
@@ -4230,16 +4244,18 @@ function computePopoverPosition(args) {
|
|
|
4230
4244
|
if (align === "start" && startOverflow > 0 && endOverflow < startOverflow) align = "end";
|
|
4231
4245
|
if (align === "end" && endOverflow > 0 && startOverflow < endOverflow) align = "start";
|
|
4232
4246
|
left = align === "end" ? leftEnd : leftStart;
|
|
4233
|
-
|
|
4247
|
+
const availableHeight = side === "top" ? availableAbove : availableBelow;
|
|
4248
|
+
const renderedHeight = constrainToAvailableHeight ? Math.min(contentSize.height, availableHeight) : contentSize.height;
|
|
4249
|
+
top = side === "top" ? triggerRect.top - offset - renderedHeight : triggerRect.bottom + offset;
|
|
4234
4250
|
left = clamp2(left, padding, viewport.width - contentSize.width - padding);
|
|
4235
|
-
top = clamp2(top, padding, viewport.height -
|
|
4236
|
-
return { top, left, side, align };
|
|
4251
|
+
top = clamp2(top, padding, viewport.height - renderedHeight - padding);
|
|
4252
|
+
return { top, left, side, align, availableHeight };
|
|
4237
4253
|
}
|
|
4238
4254
|
top = triggerRect.top;
|
|
4239
4255
|
left = side === "left" ? triggerRect.left - offset - contentSize.width : triggerRect.right + offset;
|
|
4240
4256
|
left = clamp2(left, padding, viewport.width - contentSize.width - padding);
|
|
4241
4257
|
top = clamp2(top, padding, viewport.height - contentSize.height - padding);
|
|
4242
|
-
return { top, left, side, align };
|
|
4258
|
+
return { top, left, side, align, availableHeight: Math.max(0, viewport.height - padding * 2) };
|
|
4243
4259
|
}
|
|
4244
4260
|
var React25, import_react_dom3, import_jsx_runtime27, clamp2, Popover;
|
|
4245
4261
|
var init_Popover = __esm({
|
|
@@ -4270,7 +4286,9 @@ var init_Popover = __esm({
|
|
|
4270
4286
|
onOpenChange,
|
|
4271
4287
|
matchTriggerWidth = false,
|
|
4272
4288
|
contentWidth,
|
|
4273
|
-
borderMode
|
|
4289
|
+
borderMode,
|
|
4290
|
+
getPortalContainer,
|
|
4291
|
+
constrainToAvailableHeight = false
|
|
4274
4292
|
}) => {
|
|
4275
4293
|
const isControlled = open !== void 0;
|
|
4276
4294
|
const [internalOpen, setInternalOpen] = React25.useState(false);
|
|
@@ -4278,14 +4296,14 @@ var init_Popover = __esm({
|
|
|
4278
4296
|
const positionerRef = React25.useRef(null);
|
|
4279
4297
|
const panelRef = React25.useRef(null);
|
|
4280
4298
|
const lastAppliedRef = React25.useRef(null);
|
|
4281
|
-
useShadCNAnimations();
|
|
4282
4299
|
const globalConfig = useUnderverseUIConfig();
|
|
4283
4300
|
const resolvedBorderMode = borderMode ?? globalConfig.popover?.borderMode ?? globalConfig.borderMode;
|
|
4284
4301
|
const isOpen = isControlled ? open : internalOpen;
|
|
4285
|
-
const
|
|
4286
|
-
const portalContainer = isOpen ? resolveUEditorPortalContainer(getPortalContainer) : null;
|
|
4302
|
+
const contextGetPortalContainer = useUEditorPortalContainerGetter();
|
|
4303
|
+
const portalContainer = isOpen ? resolveUEditorPortalContainer(getPortalContainer, contextGetPortalContainer) : null;
|
|
4287
4304
|
const portalDocument = portalContainer?.ownerDocument ?? null;
|
|
4288
4305
|
const portalWindow = portalDocument?.defaultView ?? null;
|
|
4306
|
+
useShadCNAnimations(portalDocument);
|
|
4289
4307
|
const setIsOpen = React25.useCallback(
|
|
4290
4308
|
(next) => {
|
|
4291
4309
|
if (!isControlled) setInternalOpen(next);
|
|
@@ -4295,20 +4313,14 @@ var init_Popover = __esm({
|
|
|
4295
4313
|
);
|
|
4296
4314
|
const offset = 4;
|
|
4297
4315
|
const padding = 8;
|
|
4298
|
-
const triggerSelector = React25.useId();
|
|
4299
4316
|
const initialPlacement = React25.useMemo(() => normalizePlacement(placement), [placement]);
|
|
4300
|
-
React25.useLayoutEffect(() => {
|
|
4301
|
-
if (typeof document === "undefined") return;
|
|
4302
|
-
const triggerEl = document.querySelector(`[data-underverse-popover-trigger="${triggerSelector}"]`);
|
|
4303
|
-
if (triggerEl) {
|
|
4304
|
-
triggerRef.current = triggerEl;
|
|
4305
|
-
}
|
|
4306
|
-
}, [triggerSelector, trigger]);
|
|
4307
4317
|
const updatePosition = React25.useCallback(() => {
|
|
4308
4318
|
const triggerEl = triggerRef.current;
|
|
4309
4319
|
const positionerEl = positionerRef.current;
|
|
4310
4320
|
const panelEl = panelRef.current;
|
|
4311
|
-
if (!triggerEl || !positionerEl || !panelEl) return;
|
|
4321
|
+
if (!triggerEl || !positionerEl || !panelEl || !portalWindow) return;
|
|
4322
|
+
const contentEl = panelEl.firstElementChild;
|
|
4323
|
+
if (!contentEl) return;
|
|
4312
4324
|
const triggerRect = triggerEl.getBoundingClientRect();
|
|
4313
4325
|
const widthWanted = matchTriggerWidth ? triggerRect.width : contentWidth;
|
|
4314
4326
|
const widthPx = widthWanted == null ? void 0 : Math.max(0, Math.round(widthWanted));
|
|
@@ -4322,7 +4334,7 @@ var init_Popover = __esm({
|
|
|
4322
4334
|
const measuredHeight = positionerEl.offsetHeight;
|
|
4323
4335
|
const contentRect = positionerEl.getBoundingClientRect();
|
|
4324
4336
|
const contentBoxWidth = measuredWidth || contentRect.width;
|
|
4325
|
-
const contentBoxHeight = measuredHeight
|
|
4337
|
+
const contentBoxHeight = Math.max(measuredHeight, contentRect.height, contentEl.scrollHeight);
|
|
4326
4338
|
const next = computePopoverPosition({
|
|
4327
4339
|
triggerRect,
|
|
4328
4340
|
contentSize: { width: contentBoxWidth, height: contentBoxHeight },
|
|
@@ -4330,20 +4342,31 @@ var init_Popover = __esm({
|
|
|
4330
4342
|
offset,
|
|
4331
4343
|
padding,
|
|
4332
4344
|
viewport: {
|
|
4333
|
-
width: portalWindow
|
|
4334
|
-
height: portalWindow
|
|
4335
|
-
}
|
|
4345
|
+
width: portalWindow.innerWidth,
|
|
4346
|
+
height: portalWindow.innerHeight
|
|
4347
|
+
},
|
|
4348
|
+
constrainToAvailableHeight
|
|
4336
4349
|
});
|
|
4337
4350
|
const top = Math.round(next.top);
|
|
4338
4351
|
const left = Math.round(next.left);
|
|
4339
|
-
const applied = prevApplied && Math.abs(prevApplied.top - top) < 0.5 && Math.abs(prevApplied.left - left) < 0.5 && prevApplied.side === next.side && prevApplied.align === next.align && prevApplied.width === widthPx;
|
|
4352
|
+
const applied = prevApplied && Math.abs(prevApplied.top - top) < 0.5 && Math.abs(prevApplied.left - left) < 0.5 && prevApplied.side === next.side && prevApplied.align === next.align && prevApplied.width === widthPx && prevApplied.availableHeight === next.availableHeight;
|
|
4340
4353
|
if (applied) return;
|
|
4341
|
-
lastAppliedRef.current = {
|
|
4354
|
+
lastAppliedRef.current = {
|
|
4355
|
+
top,
|
|
4356
|
+
left,
|
|
4357
|
+
side: next.side,
|
|
4358
|
+
align: next.align,
|
|
4359
|
+
width: widthPx,
|
|
4360
|
+
availableHeight: next.availableHeight
|
|
4361
|
+
};
|
|
4342
4362
|
positionerEl.style.transform = `translate3d(${left}px, ${top}px, 0)`;
|
|
4363
|
+
positionerEl.style.setProperty("--underverse-popover-available-height", `${next.availableHeight}px`);
|
|
4364
|
+
positionerEl.dataset.side = next.side;
|
|
4365
|
+
positionerEl.dataset.align = next.align;
|
|
4343
4366
|
panelEl.style.transformOrigin = getTransformOrigin2(next.side, next.align);
|
|
4344
4367
|
if (positionerEl.style.visibility !== "visible") positionerEl.style.visibility = "visible";
|
|
4345
4368
|
if (positionerEl.style.pointerEvents !== "auto") positionerEl.style.pointerEvents = "auto";
|
|
4346
|
-
}, [placement, matchTriggerWidth, contentWidth, portalWindow]);
|
|
4369
|
+
}, [placement, matchTriggerWidth, contentWidth, portalWindow, constrainToAvailableHeight]);
|
|
4347
4370
|
React25.useLayoutEffect(() => {
|
|
4348
4371
|
if (!isOpen || !portalWindow) return;
|
|
4349
4372
|
updatePosition();
|
|
@@ -4492,7 +4515,6 @@ var init_Popover = __esm({
|
|
|
4492
4515
|
ref: mergeRefs(childRef, (node) => {
|
|
4493
4516
|
triggerRef.current = node;
|
|
4494
4517
|
}),
|
|
4495
|
-
"data-underverse-popover-trigger": triggerSelector,
|
|
4496
4518
|
onClick: chainEventHandlers(
|
|
4497
4519
|
(e) => {
|
|
4498
4520
|
triggerRef.current = e.currentTarget;
|
|
@@ -13191,7 +13213,12 @@ var useToast = () => {
|
|
|
13191
13213
|
}
|
|
13192
13214
|
return context;
|
|
13193
13215
|
};
|
|
13194
|
-
var ToastProvider = ({
|
|
13216
|
+
var ToastProvider = ({
|
|
13217
|
+
children,
|
|
13218
|
+
position = "top-right",
|
|
13219
|
+
maxToasts = 5,
|
|
13220
|
+
viewportClassName
|
|
13221
|
+
}) => {
|
|
13195
13222
|
const [toasts, setToasts] = (0, import_react13.useState)([]);
|
|
13196
13223
|
const idRef = (0, import_react13.useRef)(0);
|
|
13197
13224
|
const removeToast = (0, import_react13.useCallback)((id) => {
|
|
@@ -13218,7 +13245,15 @@ var ToastProvider = ({ children, position = "top-right", maxToasts = 5 }) => {
|
|
|
13218
13245
|
};
|
|
13219
13246
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(ToastContext.Provider, { value: { addToast, removeToast, toasts }, children: [
|
|
13220
13247
|
children,
|
|
13221
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
13248
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
13249
|
+
"div",
|
|
13250
|
+
{
|
|
13251
|
+
className: cn("fixed z-99999 flex flex-col gap-2 pointer-events-none", positionClasses[position], viewportClassName),
|
|
13252
|
+
"aria-live": "polite",
|
|
13253
|
+
"aria-atomic": true,
|
|
13254
|
+
children: toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ToastComponent, { toast, onRemove: removeToast }, toast.id))
|
|
13255
|
+
}
|
|
13256
|
+
)
|
|
13222
13257
|
] });
|
|
13223
13258
|
};
|
|
13224
13259
|
var ToastComponent = ({ toast, onRemove }) => {
|
|
@@ -13290,6 +13325,7 @@ var ToastComponent = ({ toast, onRemove }) => {
|
|
|
13290
13325
|
isVisible ? "opacity-100 translate-x-0" : "opacity-0 translate-x-full"
|
|
13291
13326
|
),
|
|
13292
13327
|
role: "status",
|
|
13328
|
+
"data-variant": toast.type,
|
|
13293
13329
|
"aria-live": toast.type === "error" ? "assertive" : "polite",
|
|
13294
13330
|
onMouseEnter: () => {
|
|
13295
13331
|
if (toast.duration === 0) return;
|
|
@@ -14366,6 +14402,7 @@ var Combobox = ({
|
|
|
14366
14402
|
variant = "default",
|
|
14367
14403
|
allowClear = false,
|
|
14368
14404
|
usePortal = true,
|
|
14405
|
+
getPortalContainer,
|
|
14369
14406
|
label,
|
|
14370
14407
|
labelClassName,
|
|
14371
14408
|
required,
|
|
@@ -14407,7 +14444,6 @@ var Combobox = ({
|
|
|
14407
14444
|
const [activeIndex, setActiveIndex] = React31.useState(null);
|
|
14408
14445
|
const [localRequiredError, setLocalRequiredError] = React31.useState();
|
|
14409
14446
|
const [triggerBackgroundColor, setTriggerBackgroundColor] = React31.useState();
|
|
14410
|
-
useShadCNAnimations();
|
|
14411
14447
|
const inputRef = React31.useRef(null);
|
|
14412
14448
|
const optionsViewportRef = React31.useRef(null);
|
|
14413
14449
|
useOverlayScrollbarTarget(optionsViewportRef, { enabled: open && useOverlayScrollbar && !virtualized });
|
|
@@ -14448,10 +14484,16 @@ var Combobox = ({
|
|
|
14448
14484
|
});
|
|
14449
14485
|
const virtualItems = canVirtualize ? optionVirtualizer.getVirtualItems() : [];
|
|
14450
14486
|
const triggerRef = React31.useRef(null);
|
|
14487
|
+
React31.useEffect(() => {
|
|
14488
|
+
const triggerDocument = triggerRef.current?.ownerDocument;
|
|
14489
|
+
if (triggerDocument) injectAnimationStyles(triggerDocument);
|
|
14490
|
+
}, []);
|
|
14451
14491
|
const updateTriggerBackgroundColor = React31.useCallback(() => {
|
|
14452
14492
|
const trigger = triggerRef.current;
|
|
14453
14493
|
if (!trigger) return;
|
|
14454
|
-
const
|
|
14494
|
+
const triggerWindow = trigger.ownerDocument.defaultView;
|
|
14495
|
+
if (!triggerWindow) return;
|
|
14496
|
+
const backgroundColor = triggerWindow.getComputedStyle(trigger).backgroundColor;
|
|
14455
14497
|
setTriggerBackgroundColor((current) => current === backgroundColor ? current : backgroundColor);
|
|
14456
14498
|
}, []);
|
|
14457
14499
|
const scrollVirtualListToIndex = React31.useCallback((index) => {
|
|
@@ -14491,15 +14533,21 @@ var Combobox = ({
|
|
|
14491
14533
|
setActiveIndex(null);
|
|
14492
14534
|
scrollVirtualListToStart();
|
|
14493
14535
|
} else if (enableSearch) {
|
|
14494
|
-
|
|
14536
|
+
const triggerWindow = triggerRef.current?.ownerDocument.defaultView;
|
|
14537
|
+
if (!triggerWindow) return void 0;
|
|
14538
|
+
const timeoutId = triggerWindow.setTimeout(() => {
|
|
14495
14539
|
inputRef.current?.focus();
|
|
14496
14540
|
}, 100);
|
|
14541
|
+
return () => triggerWindow.clearTimeout(timeoutId);
|
|
14497
14542
|
}
|
|
14543
|
+
return void 0;
|
|
14498
14544
|
}, [enableSearch, open, scrollVirtualListToStart]);
|
|
14499
14545
|
React31.useEffect(() => {
|
|
14500
14546
|
if (!onSearchChange) return void 0;
|
|
14501
|
-
const
|
|
14502
|
-
|
|
14547
|
+
const triggerWindow = triggerRef.current?.ownerDocument.defaultView;
|
|
14548
|
+
if (!triggerWindow) return void 0;
|
|
14549
|
+
const timeoutId = triggerWindow.setTimeout(() => onSearchChange(query), searchDebounceMs);
|
|
14550
|
+
return () => triggerWindow.clearTimeout(timeoutId);
|
|
14503
14551
|
}, [onSearchChange, query, searchDebounceMs]);
|
|
14504
14552
|
React31.useEffect(() => {
|
|
14505
14553
|
if (process.env.NODE_ENV !== "production" && options.length > 300 && !virtualized && searchMode !== "manual" && maxInitialOptions === void 0) {
|
|
@@ -14513,13 +14561,15 @@ var Combobox = ({
|
|
|
14513
14561
|
setTriggerBackgroundColor(void 0);
|
|
14514
14562
|
return void 0;
|
|
14515
14563
|
}
|
|
14564
|
+
const triggerWindow = triggerRef.current?.ownerDocument.defaultView;
|
|
14565
|
+
if (!triggerWindow) return void 0;
|
|
14516
14566
|
let raf = 0;
|
|
14517
14567
|
const tick = () => {
|
|
14518
14568
|
updateTriggerBackgroundColor();
|
|
14519
|
-
raf =
|
|
14569
|
+
raf = triggerWindow.requestAnimationFrame(tick);
|
|
14520
14570
|
};
|
|
14521
14571
|
tick();
|
|
14522
|
-
return () =>
|
|
14572
|
+
return () => triggerWindow.cancelAnimationFrame(raf);
|
|
14523
14573
|
}, [matchTriggerBackground, open, updateTriggerBackgroundColor]);
|
|
14524
14574
|
const selectedOption = findOptionByValue(options, value) ?? (selectedOptionProp && getOptionValue(selectedOptionProp) === value ? selectedOptionProp : void 0);
|
|
14525
14575
|
const displayValue = selectedOption ? getOptionLabel(selectedOption) : "";
|
|
@@ -14631,9 +14681,10 @@ var Combobox = ({
|
|
|
14631
14681
|
{
|
|
14632
14682
|
"data-combobox-dropdown": true,
|
|
14633
14683
|
"data-state": open ? "open" : "closed",
|
|
14634
|
-
|
|
14684
|
+
style: usePortal ? { maxHeight: "var(--underverse-popover-available-height)" } : void 0,
|
|
14685
|
+
className: cn("w-full overflow-hidden", usePortal && "flex min-h-0 flex-col", getPanelBorderRadiusClass(resolvedBorderMode)),
|
|
14635
14686
|
children: [
|
|
14636
|
-
enableSearch && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: cn("relative border-b border-border/30", size === "xs" ? "p-1.5" : size === "sm" ? "p-2" : size === "lg" ? "p-3" : size === "xl" ? "p-3.5" : "p-2.5"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "relative", children: [
|
|
14687
|
+
enableSearch && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: cn("relative shrink-0 border-b border-border/30", size === "xs" ? "p-1.5" : size === "sm" ? "p-2" : size === "lg" ? "p-3" : size === "xl" ? "p-3.5" : "p-2.5"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "relative", children: [
|
|
14637
14688
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
14638
14689
|
import_lucide_react15.Search,
|
|
14639
14690
|
{
|
|
@@ -14703,7 +14754,7 @@ var Combobox = ({
|
|
|
14703
14754
|
role: "listbox",
|
|
14704
14755
|
"aria-labelledby": labelId,
|
|
14705
14756
|
"data-os-ignore": virtualized ? "" : void 0,
|
|
14706
|
-
className: cn("overflow-y-auto overscroll-contain", (!useOverlayScrollbar || virtualized) && comboboxScrollClassName),
|
|
14757
|
+
className: cn("overflow-y-auto overscroll-contain", usePortal && "min-h-0", (!useOverlayScrollbar || virtualized) && comboboxScrollClassName),
|
|
14707
14758
|
style: { maxHeight },
|
|
14708
14759
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: cn(size === "xs" ? "p-1" : size === "sm" ? "p-1" : size === "lg" || size === "xl" ? "p-2" : "p-1.5"), children: loading2 ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "px-3 py-10 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex flex-col items-center gap-3 animate-in fade-in-0 zoom-in-95 duration-300", children: [
|
|
14709
14760
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "relative", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "w-10 h-10 rounded-full border-2 border-primary/20 border-t-primary animate-spin" }) }),
|
|
@@ -14911,6 +14962,8 @@ var Combobox = ({
|
|
|
14911
14962
|
matchTriggerWidth: true,
|
|
14912
14963
|
className: "z-50",
|
|
14913
14964
|
borderMode: resolvedBorderMode,
|
|
14965
|
+
getPortalContainer,
|
|
14966
|
+
constrainToAvailableHeight: true,
|
|
14914
14967
|
contentClassName: "p-0 overflow-hidden",
|
|
14915
14968
|
contentProps: { style: dropdownBackgroundStyle },
|
|
14916
14969
|
children: dropdownBody
|