shadcn-ui-react 0.7.11 → 0.7.13
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/index.cjs +386 -245
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +386 -245
- package/dist/style.css +81 -88
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6271,7 +6271,7 @@ import { cva as cva5 } from "class-variance-authority";
|
|
|
6271
6271
|
import * as React42 from "react";
|
|
6272
6272
|
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
6273
6273
|
var labelVariants = cva5(
|
|
6274
|
-
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70
|
|
6274
|
+
"text-sm font-medium leading-none text-label peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
6275
6275
|
);
|
|
6276
6276
|
var Label3 = React42.forwardRef((_a, ref) => {
|
|
6277
6277
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
@@ -6924,7 +6924,9 @@ var SelectContext = React46.createContext(null);
|
|
|
6924
6924
|
function useSelectContext(componentName) {
|
|
6925
6925
|
const context = React46.useContext(SelectContext);
|
|
6926
6926
|
if (!context) {
|
|
6927
|
-
throw new Error(
|
|
6927
|
+
throw new Error(
|
|
6928
|
+
`${componentName} must be used within <Select />. Aseg\xFArate de importar Select, SelectTrigger, SelectContent, SelectValue y SelectItem desde el mismo archivo "../select", sin mezclar Radix ni otra versi\xF3n del componente.`
|
|
6929
|
+
);
|
|
6928
6930
|
}
|
|
6929
6931
|
return context;
|
|
6930
6932
|
}
|
|
@@ -6939,11 +6941,15 @@ function useControllableState({
|
|
|
6939
6941
|
const setValue = React46.useCallback(
|
|
6940
6942
|
(nextValue) => {
|
|
6941
6943
|
if (!isControlled) {
|
|
6942
|
-
setInternalValue(
|
|
6944
|
+
setInternalValue(
|
|
6945
|
+
(previousValue) => Object.is(previousValue, nextValue) ? previousValue : nextValue
|
|
6946
|
+
);
|
|
6947
|
+
}
|
|
6948
|
+
if (!Object.is(currentValue, nextValue)) {
|
|
6949
|
+
onChange == null ? void 0 : onChange(nextValue);
|
|
6943
6950
|
}
|
|
6944
|
-
onChange == null ? void 0 : onChange(nextValue);
|
|
6945
6951
|
},
|
|
6946
|
-
[isControlled, onChange]
|
|
6952
|
+
[currentValue, isControlled, onChange]
|
|
6947
6953
|
);
|
|
6948
6954
|
return [currentValue, setValue];
|
|
6949
6955
|
}
|
|
@@ -6990,6 +6996,31 @@ function getNextItemValue(items, currentValue, direction) {
|
|
|
6990
6996
|
const nextIndex = direction === "next" ? (currentIndex + 1) % enabledItems.length : (currentIndex - 1 + enabledItems.length) % enabledItems.length;
|
|
6991
6997
|
return (_c = enabledItems[nextIndex]) == null ? void 0 : _c.value;
|
|
6992
6998
|
}
|
|
6999
|
+
function areRegisteredItemsEqual(previous, next) {
|
|
7000
|
+
return Boolean(
|
|
7001
|
+
previous && previous.id === next.id && previous.value === next.value && previous.textValue === next.textValue && previous.disabled === next.disabled && previous.label === next.label
|
|
7002
|
+
);
|
|
7003
|
+
}
|
|
7004
|
+
function areStylesEqual(previous, next) {
|
|
7005
|
+
if (!previous) return false;
|
|
7006
|
+
return previous.position === next.position && previous.zIndex === next.zIndex && previous.width === next.width && previous.minWidth === next.minWidth && previous.maxWidth === next.maxWidth && previous.maxHeight === next.maxHeight && previous.left === next.left && previous.right === next.right && previous.top === next.top && previous.bottom === next.bottom && previous.transform === next.transform;
|
|
7007
|
+
}
|
|
7008
|
+
function scrollItemIntoView(container, item) {
|
|
7009
|
+
if (!container || !item) return;
|
|
7010
|
+
const containerRect = container.getBoundingClientRect();
|
|
7011
|
+
const itemRect = item.getBoundingClientRect();
|
|
7012
|
+
const itemTop = itemRect.top - containerRect.top + container.scrollTop;
|
|
7013
|
+
const itemBottom = itemTop + itemRect.height;
|
|
7014
|
+
const visibleTop = container.scrollTop;
|
|
7015
|
+
const visibleBottom = visibleTop + container.clientHeight;
|
|
7016
|
+
if (itemTop < visibleTop) {
|
|
7017
|
+
container.scrollTop = itemTop;
|
|
7018
|
+
return;
|
|
7019
|
+
}
|
|
7020
|
+
if (itemBottom > visibleBottom) {
|
|
7021
|
+
container.scrollTop = itemBottom - container.clientHeight;
|
|
7022
|
+
}
|
|
7023
|
+
}
|
|
6993
7024
|
function Select2({
|
|
6994
7025
|
value,
|
|
6995
7026
|
defaultValue = "",
|
|
@@ -7028,17 +7059,28 @@ function Select2({
|
|
|
7028
7059
|
() => Array.from(itemsRef.current.values()),
|
|
7029
7060
|
[itemsVersion]
|
|
7030
7061
|
);
|
|
7031
|
-
const selectedItem =
|
|
7062
|
+
const selectedItem = React46.useMemo(
|
|
7063
|
+
() => items.find((item) => item.value === currentValue),
|
|
7064
|
+
[currentValue, items]
|
|
7065
|
+
);
|
|
7032
7066
|
const registerItem = React46.useCallback((item) => {
|
|
7067
|
+
const previousItem = itemsRef.current.get(item.value);
|
|
7068
|
+
if (previousItem && previousItem.id === item.id) {
|
|
7069
|
+
previousItem.label = item.label;
|
|
7070
|
+
previousItem.textValue = item.textValue;
|
|
7071
|
+
previousItem.disabled = item.disabled;
|
|
7072
|
+
if (!areRegisteredItemsEqual(previousItem, item)) {
|
|
7073
|
+
forceItemsUpdate();
|
|
7074
|
+
}
|
|
7075
|
+
return;
|
|
7076
|
+
}
|
|
7033
7077
|
itemsRef.current.set(item.value, item);
|
|
7034
7078
|
forceItemsUpdate();
|
|
7035
7079
|
}, []);
|
|
7036
7080
|
const unregisterItem = React46.useCallback((value2, id) => {
|
|
7037
7081
|
const currentItem = itemsRef.current.get(value2);
|
|
7038
7082
|
if (!currentItem || currentItem.id !== id) return;
|
|
7039
|
-
itemsRef.current.
|
|
7040
|
-
ref: null
|
|
7041
|
-
}));
|
|
7083
|
+
itemsRef.current.delete(value2);
|
|
7042
7084
|
forceItemsUpdate();
|
|
7043
7085
|
}, []);
|
|
7044
7086
|
const updateItemRef = React46.useCallback(
|
|
@@ -7046,10 +7088,7 @@ function Select2({
|
|
|
7046
7088
|
const currentItem = itemsRef.current.get(value2);
|
|
7047
7089
|
if (!currentItem || currentItem.id !== id) return;
|
|
7048
7090
|
if (currentItem.ref === node) return;
|
|
7049
|
-
|
|
7050
|
-
ref: node
|
|
7051
|
-
}));
|
|
7052
|
-
forceItemsUpdate();
|
|
7091
|
+
currentItem.ref = node;
|
|
7053
7092
|
},
|
|
7054
7093
|
[]
|
|
7055
7094
|
);
|
|
@@ -7067,7 +7106,7 @@ function Select2({
|
|
|
7067
7106
|
setIsOpen(false);
|
|
7068
7107
|
requestAnimationFrame(() => {
|
|
7069
7108
|
var _a;
|
|
7070
|
-
(_a = triggerRef.current) == null ? void 0 : _a.focus();
|
|
7109
|
+
(_a = triggerRef.current) == null ? void 0 : _a.focus({ preventScroll: true });
|
|
7071
7110
|
});
|
|
7072
7111
|
},
|
|
7073
7112
|
[disabled, setCurrentValue, setIsOpen]
|
|
@@ -7079,21 +7118,24 @@ function Select2({
|
|
|
7079
7118
|
(item) => item.value === currentValue && !item.disabled
|
|
7080
7119
|
);
|
|
7081
7120
|
const firstEnabledItem = getEnabledItems(items)[0];
|
|
7082
|
-
|
|
7121
|
+
const nextActiveValue = (_a = selectedEnabledItem == null ? void 0 : selectedEnabledItem.value) != null ? _a : firstEnabledItem == null ? void 0 : firstEnabledItem.value;
|
|
7122
|
+
setActiveValue(
|
|
7123
|
+
(previousValue) => previousValue === nextActiveValue ? previousValue : nextActiveValue
|
|
7124
|
+
);
|
|
7083
7125
|
}, [currentValue, isOpen, items]);
|
|
7084
7126
|
React46.useEffect(() => {
|
|
7085
7127
|
if (!isOpen) return;
|
|
7086
7128
|
const handlePointerDown = (event) => {
|
|
7087
7129
|
var _a, _b;
|
|
7088
7130
|
const target = event.target;
|
|
7089
|
-
if (((_a = triggerRef.current) == null ? void 0 : _a.contains(target)) || ((_b = contentRef.current) == null ? void 0 : _b.contains(target))) {
|
|
7131
|
+
if (target && (((_a = triggerRef.current) == null ? void 0 : _a.contains(target)) || ((_b = contentRef.current) == null ? void 0 : _b.contains(target)))) {
|
|
7090
7132
|
return;
|
|
7091
7133
|
}
|
|
7092
7134
|
setIsOpen(false);
|
|
7093
7135
|
};
|
|
7094
|
-
document.addEventListener("pointerdown", handlePointerDown);
|
|
7136
|
+
document.addEventListener("pointerdown", handlePointerDown, true);
|
|
7095
7137
|
return () => {
|
|
7096
|
-
document.removeEventListener("pointerdown", handlePointerDown);
|
|
7138
|
+
document.removeEventListener("pointerdown", handlePointerDown, true);
|
|
7097
7139
|
};
|
|
7098
7140
|
}, [isOpen, setIsOpen]);
|
|
7099
7141
|
const contextValue = React46.useMemo(
|
|
@@ -7143,7 +7185,8 @@ function Select2({
|
|
|
7143
7185
|
type: "hidden",
|
|
7144
7186
|
name,
|
|
7145
7187
|
value: currentValue,
|
|
7146
|
-
required
|
|
7188
|
+
required,
|
|
7189
|
+
disabled
|
|
7147
7190
|
}
|
|
7148
7191
|
) : null
|
|
7149
7192
|
] });
|
|
@@ -7159,7 +7202,8 @@ var SelectTrigger = React46.forwardRef(
|
|
|
7159
7202
|
invalid,
|
|
7160
7203
|
disabled,
|
|
7161
7204
|
onClick,
|
|
7162
|
-
onKeyDown
|
|
7205
|
+
onKeyDown,
|
|
7206
|
+
onPointerDown
|
|
7163
7207
|
} = _b, props = __objRest(_b, [
|
|
7164
7208
|
"className",
|
|
7165
7209
|
"children",
|
|
@@ -7169,7 +7213,8 @@ var SelectTrigger = React46.forwardRef(
|
|
|
7169
7213
|
"invalid",
|
|
7170
7214
|
"disabled",
|
|
7171
7215
|
"onClick",
|
|
7172
|
-
"onKeyDown"
|
|
7216
|
+
"onKeyDown",
|
|
7217
|
+
"onPointerDown"
|
|
7173
7218
|
]);
|
|
7174
7219
|
const context = useSelectContext("SelectTrigger");
|
|
7175
7220
|
const resolvedVariant = variant != null ? variant : context.variant;
|
|
@@ -7295,16 +7340,27 @@ var SelectTrigger = React46.forwardRef(
|
|
|
7295
7340
|
disabled: resolvedDisabled,
|
|
7296
7341
|
className: cn(
|
|
7297
7342
|
formControlBase,
|
|
7298
|
-
"whitespace-nowrap ring-offset-background
|
|
7343
|
+
"relative flex w-full items-center justify-between gap-2 overflow-hidden whitespace-nowrap ring-offset-background",
|
|
7299
7344
|
formInputVariants[resolvedVariant],
|
|
7300
7345
|
controlSizeClass,
|
|
7301
7346
|
resolvedInvalid && formControlErrorClass,
|
|
7302
7347
|
className
|
|
7303
7348
|
),
|
|
7349
|
+
onPointerDown: (event) => {
|
|
7350
|
+
onPointerDown == null ? void 0 : onPointerDown(event);
|
|
7351
|
+
if (event.defaultPrevented || resolvedDisabled || event.button !== 0 || event.ctrlKey) {
|
|
7352
|
+
return;
|
|
7353
|
+
}
|
|
7354
|
+
event.preventDefault();
|
|
7355
|
+
},
|
|
7304
7356
|
onClick: (event) => {
|
|
7305
7357
|
onClick == null ? void 0 : onClick(event);
|
|
7306
7358
|
if (!event.defaultPrevented && !resolvedDisabled) {
|
|
7307
7359
|
context.setOpen(!context.open);
|
|
7360
|
+
requestAnimationFrame(() => {
|
|
7361
|
+
var _a2;
|
|
7362
|
+
(_a2 = context.triggerRef.current) == null ? void 0 : _a2.focus({ preventScroll: true });
|
|
7363
|
+
});
|
|
7308
7364
|
}
|
|
7309
7365
|
},
|
|
7310
7366
|
onKeyDown: handleKeyDown
|
|
@@ -7320,13 +7376,25 @@ var SelectTrigger = React46.forwardRef(
|
|
|
7320
7376
|
SelectTrigger.displayName = "SelectTrigger";
|
|
7321
7377
|
var SelectValue = React46.forwardRef(
|
|
7322
7378
|
(_a, ref) => {
|
|
7323
|
-
var _b = _a, { className, placeholder, children } = _b, props = __objRest(_b, ["className", "placeholder", "children"]);
|
|
7324
|
-
var _a2
|
|
7379
|
+
var _b = _a, { className, placeholder = "Select an option", children } = _b, props = __objRest(_b, ["className", "placeholder", "children"]);
|
|
7380
|
+
var _a2;
|
|
7325
7381
|
const context = useSelectContext("SelectValue");
|
|
7326
|
-
|
|
7382
|
+
const hasValue = Boolean(context.selectedItem) || children !== void 0;
|
|
7383
|
+
return /* @__PURE__ */ jsx24(
|
|
7384
|
+
"span",
|
|
7385
|
+
__spreadProps(__spreadValues({
|
|
7386
|
+
ref,
|
|
7387
|
+
className: cn(
|
|
7388
|
+
"min-w-0 flex-1 truncate text-left",
|
|
7389
|
+
!hasValue && "text-muted-foreground",
|
|
7390
|
+
className
|
|
7391
|
+
)
|
|
7392
|
+
}, props), {
|
|
7393
|
+
children: hasValue ? children != null ? children : (_a2 = context.selectedItem) == null ? void 0 : _a2.label : placeholder
|
|
7394
|
+
})
|
|
7395
|
+
);
|
|
7327
7396
|
}
|
|
7328
7397
|
);
|
|
7329
|
-
SelectValue.displayName = "SelectValue";
|
|
7330
7398
|
var SelectContent = React46.forwardRef(
|
|
7331
7399
|
(_a, ref) => {
|
|
7332
7400
|
var _b = _a, {
|
|
@@ -7347,22 +7415,33 @@ var SelectContent = React46.forwardRef(
|
|
|
7347
7415
|
const context = useSelectContext("SelectContent");
|
|
7348
7416
|
const scrollRef = React46.useRef(null);
|
|
7349
7417
|
const rafRef = React46.useRef(null);
|
|
7418
|
+
const lockedSideRef = React46.useRef(null);
|
|
7350
7419
|
const [mounted, setMounted] = React46.useState(false);
|
|
7351
7420
|
const [side, setSide] = React46.useState("bottom");
|
|
7352
7421
|
const [contentStyle, setContentStyle] = React46.useState();
|
|
7353
|
-
React46.
|
|
7422
|
+
React46.useLayoutEffect(() => {
|
|
7354
7423
|
setMounted(true);
|
|
7355
7424
|
}, []);
|
|
7425
|
+
React46.useLayoutEffect(() => {
|
|
7426
|
+
if (!context.open) {
|
|
7427
|
+
lockedSideRef.current = null;
|
|
7428
|
+
setContentStyle(void 0);
|
|
7429
|
+
}
|
|
7430
|
+
}, [context.open]);
|
|
7356
7431
|
const updatePosition = React46.useCallback(() => {
|
|
7357
7432
|
const trigger = context.triggerRef.current;
|
|
7358
7433
|
if (!trigger) return;
|
|
7359
7434
|
const rect = trigger.getBoundingClientRect();
|
|
7360
7435
|
const viewportPadding = 8;
|
|
7361
|
-
const preferredMaxHeight =
|
|
7436
|
+
const preferredMaxHeight = 288;
|
|
7362
7437
|
const minUsefulHeight = 140;
|
|
7363
7438
|
const availableBelow = window.innerHeight - rect.bottom - viewportPadding - sideOffset;
|
|
7364
7439
|
const availableAbove = rect.top - viewportPadding - sideOffset;
|
|
7365
|
-
const
|
|
7440
|
+
const calculatedSide = availableBelow >= Math.min(preferredMaxHeight, minUsefulHeight) || availableBelow >= availableAbove ? "bottom" : "top";
|
|
7441
|
+
if (!lockedSideRef.current) {
|
|
7442
|
+
lockedSideRef.current = calculatedSide;
|
|
7443
|
+
}
|
|
7444
|
+
const nextSide = lockedSideRef.current;
|
|
7366
7445
|
const availableHeight = nextSide === "bottom" ? availableBelow : availableAbove;
|
|
7367
7446
|
const contentMaxHeight = Math.max(
|
|
7368
7447
|
80,
|
|
@@ -7378,14 +7457,17 @@ var SelectContent = React46.forwardRef(
|
|
|
7378
7457
|
};
|
|
7379
7458
|
if (align === "start") {
|
|
7380
7459
|
baseStyle.left = rect.left;
|
|
7460
|
+
baseStyle.right = void 0;
|
|
7381
7461
|
baseStyle.transform = void 0;
|
|
7382
7462
|
}
|
|
7383
7463
|
if (align === "center") {
|
|
7384
7464
|
baseStyle.left = rect.left + rect.width / 2;
|
|
7465
|
+
baseStyle.right = void 0;
|
|
7385
7466
|
baseStyle.transform = "translateX(-50%)";
|
|
7386
7467
|
}
|
|
7387
7468
|
if (align === "end") {
|
|
7388
7469
|
baseStyle.left = rect.right;
|
|
7470
|
+
baseStyle.right = void 0;
|
|
7389
7471
|
baseStyle.transform = "translateX(-100%)";
|
|
7390
7472
|
}
|
|
7391
7473
|
if (nextSide === "bottom") {
|
|
@@ -7395,14 +7477,19 @@ var SelectContent = React46.forwardRef(
|
|
|
7395
7477
|
baseStyle.bottom = window.innerHeight - rect.top + sideOffset;
|
|
7396
7478
|
baseStyle.top = void 0;
|
|
7397
7479
|
}
|
|
7398
|
-
setSide(
|
|
7399
|
-
|
|
7480
|
+
setSide(
|
|
7481
|
+
(previousSide) => previousSide === nextSide ? previousSide : nextSide
|
|
7482
|
+
);
|
|
7483
|
+
setContentStyle(
|
|
7484
|
+
(previousStyle) => areStylesEqual(previousStyle, baseStyle) ? previousStyle : baseStyle
|
|
7485
|
+
);
|
|
7400
7486
|
}, [align, context.triggerRef, sideOffset]);
|
|
7401
7487
|
const scheduleUpdatePosition = React46.useCallback(() => {
|
|
7402
7488
|
if (rafRef.current) {
|
|
7403
7489
|
cancelAnimationFrame(rafRef.current);
|
|
7404
7490
|
}
|
|
7405
7491
|
rafRef.current = requestAnimationFrame(() => {
|
|
7492
|
+
rafRef.current = null;
|
|
7406
7493
|
updatePosition();
|
|
7407
7494
|
});
|
|
7408
7495
|
}, [updatePosition]);
|
|
@@ -7441,13 +7528,10 @@ var SelectContent = React46.forwardRef(
|
|
|
7441
7528
|
React46.useLayoutEffect(() => {
|
|
7442
7529
|
if (!context.open) return;
|
|
7443
7530
|
const frame = requestAnimationFrame(() => {
|
|
7444
|
-
var _a2;
|
|
7445
7531
|
const activeItem = context.items.find(
|
|
7446
7532
|
(item) => item.value === context.activeValue
|
|
7447
7533
|
);
|
|
7448
|
-
(
|
|
7449
|
-
block: "nearest"
|
|
7450
|
-
});
|
|
7534
|
+
scrollItemIntoView(scrollRef.current, activeItem == null ? void 0 : activeItem.ref);
|
|
7451
7535
|
});
|
|
7452
7536
|
return () => {
|
|
7453
7537
|
cancelAnimationFrame(frame);
|
|
@@ -7464,9 +7548,9 @@ var SelectContent = React46.forwardRef(
|
|
|
7464
7548
|
ref: composeRefs(ref, context.contentRef),
|
|
7465
7549
|
role: "listbox",
|
|
7466
7550
|
"data-side": side,
|
|
7551
|
+
"data-select-content": true,
|
|
7467
7552
|
className: cn(
|
|
7468
|
-
"min-w-32 rounded-md border border-border bg-popover text-popover-foreground shadow-md",
|
|
7469
|
-
"overflow-hidden",
|
|
7553
|
+
"pointer-events-auto min-w-32 overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md",
|
|
7470
7554
|
className
|
|
7471
7555
|
),
|
|
7472
7556
|
style: __spreadValues(__spreadValues({}, contentStyle), style),
|
|
@@ -7476,20 +7560,13 @@ var SelectContent = React46.forwardRef(
|
|
|
7476
7560
|
ref: scrollRef,
|
|
7477
7561
|
"data-select-scroll-content": true,
|
|
7478
7562
|
className: cn(
|
|
7479
|
-
"max-h-full px-1 py-1",
|
|
7480
|
-
"
|
|
7481
|
-
"[scrollbar-gutter:stable]",
|
|
7482
|
-
"[scrollbar-width:thin]",
|
|
7483
|
-
"[&::-webkit-scrollbar]:!block",
|
|
7484
|
-
"[&::-webkit-scrollbar]:!w-2",
|
|
7485
|
-
"[&::-webkit-scrollbar-track]:!bg-transparent",
|
|
7486
|
-
"[&::-webkit-scrollbar-thumb]:!rounded-full",
|
|
7487
|
-
"[&::-webkit-scrollbar-thumb]:!bg-border"
|
|
7563
|
+
"max-h-full overflow-x-hidden overflow-y-auto overscroll-contain px-1 py-1",
|
|
7564
|
+
"scrollbar-gutter-stable"
|
|
7488
7565
|
),
|
|
7489
7566
|
style: {
|
|
7490
7567
|
maxHeight: contentStyle.maxHeight,
|
|
7491
7568
|
overflowX: "hidden",
|
|
7492
|
-
overflowY: "
|
|
7569
|
+
overflowY: "auto",
|
|
7493
7570
|
overscrollBehavior: "contain",
|
|
7494
7571
|
scrollbarGutter: "stable",
|
|
7495
7572
|
WebkitOverflowScrolling: "touch"
|
|
@@ -7497,6 +7574,9 @@ var SelectContent = React46.forwardRef(
|
|
|
7497
7574
|
onWheel: (event) => {
|
|
7498
7575
|
event.stopPropagation();
|
|
7499
7576
|
},
|
|
7577
|
+
onTouchMove: (event) => {
|
|
7578
|
+
event.stopPropagation();
|
|
7579
|
+
},
|
|
7500
7580
|
children
|
|
7501
7581
|
}
|
|
7502
7582
|
)
|
|
@@ -7572,7 +7652,7 @@ var SelectItem = React46.forwardRef(
|
|
|
7572
7652
|
const labelText = textValue != null ? textValue : getNodeText(children);
|
|
7573
7653
|
const isSelected = selectedValue === value;
|
|
7574
7654
|
const isActive = activeValue === value;
|
|
7575
|
-
React46.
|
|
7655
|
+
React46.useLayoutEffect(() => {
|
|
7576
7656
|
registerItem({
|
|
7577
7657
|
id: itemId,
|
|
7578
7658
|
value,
|
|
@@ -7589,9 +7669,9 @@ var SelectItem = React46.forwardRef(
|
|
|
7589
7669
|
unregisterItem,
|
|
7590
7670
|
itemId,
|
|
7591
7671
|
value,
|
|
7592
|
-
children,
|
|
7593
7672
|
labelText,
|
|
7594
|
-
disabled
|
|
7673
|
+
disabled,
|
|
7674
|
+
children
|
|
7595
7675
|
]);
|
|
7596
7676
|
const handleItemRef = React46.useCallback(
|
|
7597
7677
|
(node) => {
|
|
@@ -7664,15 +7744,25 @@ SelectSeparator.displayName = "SelectSeparator";
|
|
|
7664
7744
|
|
|
7665
7745
|
// src/components/searchable-select.tsx
|
|
7666
7746
|
import * as React47 from "react";
|
|
7747
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
7667
7748
|
import { CaretSortIcon as CaretSortIcon2, CheckIcon as CheckIcon5, Cross2Icon as Cross2Icon2 } from "@radix-ui/react-icons";
|
|
7668
7749
|
import { jsx as jsx25, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
7669
7750
|
function normalizeText(value) {
|
|
7670
7751
|
return String(value != null ? value : "").normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "").toLowerCase().trim();
|
|
7671
7752
|
}
|
|
7672
7753
|
function getLabelText(value) {
|
|
7754
|
+
if (value === null || value === void 0 || typeof value === "boolean") {
|
|
7755
|
+
return "";
|
|
7756
|
+
}
|
|
7673
7757
|
if (typeof value === "string" || typeof value === "number") {
|
|
7674
7758
|
return String(value);
|
|
7675
7759
|
}
|
|
7760
|
+
if (Array.isArray(value)) {
|
|
7761
|
+
return value.map(getLabelText).join("");
|
|
7762
|
+
}
|
|
7763
|
+
if (React47.isValidElement(value)) {
|
|
7764
|
+
return getLabelText(value.props.children);
|
|
7765
|
+
}
|
|
7676
7766
|
return "";
|
|
7677
7767
|
}
|
|
7678
7768
|
function getOptionText(item) {
|
|
@@ -7691,6 +7781,10 @@ function getNextEnabledIndex2(items, currentIndex, direction) {
|
|
|
7691
7781
|
}
|
|
7692
7782
|
return -1;
|
|
7693
7783
|
}
|
|
7784
|
+
function areStylesEqual2(previous, next) {
|
|
7785
|
+
if (!previous) return false;
|
|
7786
|
+
return previous.position === next.position && previous.zIndex === next.zIndex && previous.width === next.width && previous.minWidth === next.minWidth && previous.maxWidth === next.maxWidth && previous.maxHeight === next.maxHeight && previous.left === next.left && previous.right === next.right && previous.top === next.top && previous.bottom === next.bottom && previous.transform === next.transform;
|
|
7787
|
+
}
|
|
7694
7788
|
function SearchableSelectBase({
|
|
7695
7789
|
items,
|
|
7696
7790
|
value,
|
|
@@ -7714,6 +7808,8 @@ function SearchableSelectBase({
|
|
|
7714
7808
|
}) {
|
|
7715
7809
|
const rootRef = React47.useRef(null);
|
|
7716
7810
|
const inputRef = React47.useRef(null);
|
|
7811
|
+
const contentRef = React47.useRef(null);
|
|
7812
|
+
const rafRef = React47.useRef(null);
|
|
7717
7813
|
const listboxId = React47.useId();
|
|
7718
7814
|
const sizeClasses = getFormSizeClasses(size, customSize);
|
|
7719
7815
|
const triggerSizeClass = getFormControlSizeClass(variant, sizeClasses);
|
|
@@ -7726,9 +7822,14 @@ function SearchableSelectBase({
|
|
|
7726
7822
|
const selectedText = React47.useMemo(() => {
|
|
7727
7823
|
return getOptionText(selectedItem);
|
|
7728
7824
|
}, [selectedItem]);
|
|
7825
|
+
const [mounted, setMounted] = React47.useState(false);
|
|
7729
7826
|
const [open, setOpen] = React47.useState(false);
|
|
7730
7827
|
const [inputValue, setInputValue] = React47.useState(selectedText);
|
|
7731
7828
|
const [activeIndex, setActiveIndex] = React47.useState(-1);
|
|
7829
|
+
const [contentStyle, setContentStyle] = React47.useState();
|
|
7830
|
+
React47.useLayoutEffect(() => {
|
|
7831
|
+
setMounted(true);
|
|
7832
|
+
}, []);
|
|
7732
7833
|
React47.useEffect(() => {
|
|
7733
7834
|
if (!open) {
|
|
7734
7835
|
setInputValue(selectedText);
|
|
@@ -7745,17 +7846,110 @@ function SearchableSelectBase({
|
|
|
7745
7846
|
return haystack.includes(query);
|
|
7746
7847
|
});
|
|
7747
7848
|
}, [inputValue, items]);
|
|
7849
|
+
const updatePosition = React47.useCallback(() => {
|
|
7850
|
+
const root = rootRef.current;
|
|
7851
|
+
if (!root) return;
|
|
7852
|
+
const rect = root.getBoundingClientRect();
|
|
7853
|
+
const viewportPadding = 8;
|
|
7854
|
+
const sideOffset = 6;
|
|
7855
|
+
const preferredMaxHeight = 288;
|
|
7856
|
+
const minUsefulHeight = 140;
|
|
7857
|
+
const availableBelow = window.innerHeight - rect.bottom - viewportPadding - sideOffset;
|
|
7858
|
+
const availableAbove = rect.top - viewportPadding - sideOffset;
|
|
7859
|
+
const shouldOpenBelow = availableBelow >= Math.min(preferredMaxHeight, minUsefulHeight) || availableBelow >= availableAbove;
|
|
7860
|
+
const availableHeight = shouldOpenBelow ? availableBelow : availableAbove;
|
|
7861
|
+
const contentMaxHeight = Math.max(
|
|
7862
|
+
96,
|
|
7863
|
+
Math.min(preferredMaxHeight, availableHeight)
|
|
7864
|
+
);
|
|
7865
|
+
const nextStyle = {
|
|
7866
|
+
position: "fixed",
|
|
7867
|
+
zIndex: 9999,
|
|
7868
|
+
left: Math.max(viewportPadding, rect.left),
|
|
7869
|
+
width: rect.width,
|
|
7870
|
+
minWidth: rect.width,
|
|
7871
|
+
maxWidth: `calc(100vw - ${viewportPadding * 2}px)`,
|
|
7872
|
+
maxHeight: contentMaxHeight
|
|
7873
|
+
};
|
|
7874
|
+
if (shouldOpenBelow) {
|
|
7875
|
+
nextStyle.top = rect.bottom + sideOffset;
|
|
7876
|
+
nextStyle.bottom = void 0;
|
|
7877
|
+
} else {
|
|
7878
|
+
nextStyle.bottom = window.innerHeight - rect.top + sideOffset;
|
|
7879
|
+
nextStyle.top = void 0;
|
|
7880
|
+
}
|
|
7881
|
+
setContentStyle(
|
|
7882
|
+
(previousStyle) => areStylesEqual2(previousStyle, nextStyle) ? previousStyle : nextStyle
|
|
7883
|
+
);
|
|
7884
|
+
}, []);
|
|
7885
|
+
const scheduleUpdatePosition = React47.useCallback(() => {
|
|
7886
|
+
if (rafRef.current) {
|
|
7887
|
+
cancelAnimationFrame(rafRef.current);
|
|
7888
|
+
}
|
|
7889
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
7890
|
+
rafRef.current = null;
|
|
7891
|
+
updatePosition();
|
|
7892
|
+
});
|
|
7893
|
+
}, [updatePosition]);
|
|
7894
|
+
const openDropdown = React47.useCallback(() => {
|
|
7895
|
+
if (disabled) return;
|
|
7896
|
+
if (!open) {
|
|
7897
|
+
setInputValue("");
|
|
7898
|
+
setOpen(true);
|
|
7899
|
+
}
|
|
7900
|
+
requestAnimationFrame(() => {
|
|
7901
|
+
var _a;
|
|
7902
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus({ preventScroll: true });
|
|
7903
|
+
});
|
|
7904
|
+
}, [disabled, open]);
|
|
7905
|
+
React47.useLayoutEffect(() => {
|
|
7906
|
+
if (!open) {
|
|
7907
|
+
setContentStyle(void 0);
|
|
7908
|
+
}
|
|
7909
|
+
}, [open]);
|
|
7910
|
+
React47.useLayoutEffect(() => {
|
|
7911
|
+
var _a, _b;
|
|
7912
|
+
if (!open) return;
|
|
7913
|
+
updatePosition();
|
|
7914
|
+
scheduleUpdatePosition();
|
|
7915
|
+
const handleResizeOrScroll = () => {
|
|
7916
|
+
scheduleUpdatePosition();
|
|
7917
|
+
};
|
|
7918
|
+
window.addEventListener("resize", handleResizeOrScroll);
|
|
7919
|
+
window.addEventListener("scroll", handleResizeOrScroll, true);
|
|
7920
|
+
(_a = window.visualViewport) == null ? void 0 : _a.addEventListener("resize", handleResizeOrScroll);
|
|
7921
|
+
(_b = window.visualViewport) == null ? void 0 : _b.addEventListener("scroll", handleResizeOrScroll);
|
|
7922
|
+
return () => {
|
|
7923
|
+
var _a2, _b2;
|
|
7924
|
+
window.removeEventListener("resize", handleResizeOrScroll);
|
|
7925
|
+
window.removeEventListener("scroll", handleResizeOrScroll, true);
|
|
7926
|
+
(_a2 = window.visualViewport) == null ? void 0 : _a2.removeEventListener(
|
|
7927
|
+
"resize",
|
|
7928
|
+
handleResizeOrScroll
|
|
7929
|
+
);
|
|
7930
|
+
(_b2 = window.visualViewport) == null ? void 0 : _b2.removeEventListener(
|
|
7931
|
+
"scroll",
|
|
7932
|
+
handleResizeOrScroll
|
|
7933
|
+
);
|
|
7934
|
+
if (rafRef.current) {
|
|
7935
|
+
cancelAnimationFrame(rafRef.current);
|
|
7936
|
+
rafRef.current = null;
|
|
7937
|
+
}
|
|
7938
|
+
};
|
|
7939
|
+
}, [open, scheduleUpdatePosition, updatePosition]);
|
|
7748
7940
|
React47.useEffect(() => {
|
|
7749
7941
|
if (!open) return;
|
|
7750
7942
|
const firstEnabledIndex = filteredItems.findIndex((item) => !item.disabled);
|
|
7751
|
-
setActiveIndex(
|
|
7943
|
+
setActiveIndex(
|
|
7944
|
+
(previousIndex) => previousIndex === firstEnabledIndex ? previousIndex : firstEnabledIndex
|
|
7945
|
+
);
|
|
7752
7946
|
}, [filteredItems, open]);
|
|
7753
7947
|
React47.useEffect(() => {
|
|
7754
7948
|
if (!open) return;
|
|
7755
7949
|
const handlePointerDown = (event) => {
|
|
7756
|
-
var _a;
|
|
7950
|
+
var _a, _b;
|
|
7757
7951
|
const target = event.target;
|
|
7758
|
-
if (target && ((_a = rootRef.current) == null ? void 0 : _a.contains(target))) {
|
|
7952
|
+
if (target && (((_a = rootRef.current) == null ? void 0 : _a.contains(target)) || ((_b = contentRef.current) == null ? void 0 : _b.contains(target)))) {
|
|
7759
7953
|
return;
|
|
7760
7954
|
}
|
|
7761
7955
|
setOpen(false);
|
|
@@ -7781,6 +7975,100 @@ function SearchableSelectBase({
|
|
|
7781
7975
|
},
|
|
7782
7976
|
[isControlled, onValueChange]
|
|
7783
7977
|
);
|
|
7978
|
+
const dropdown = open && mounted && contentStyle ? createPortal2(
|
|
7979
|
+
/* @__PURE__ */ jsx25(
|
|
7980
|
+
"div",
|
|
7981
|
+
{
|
|
7982
|
+
ref: contentRef,
|
|
7983
|
+
"data-searchable-select-content": true,
|
|
7984
|
+
className: cn(
|
|
7985
|
+
"pointer-events-auto overflow-hidden rounded-xl border border-border bg-popover text-popover-foreground shadow-xl",
|
|
7986
|
+
contentClassName
|
|
7987
|
+
),
|
|
7988
|
+
style: __spreadProps(__spreadValues({}, contentStyle), {
|
|
7989
|
+
maxHeight: contentStyle.maxHeight
|
|
7990
|
+
}),
|
|
7991
|
+
children: /* @__PURE__ */ jsx25(
|
|
7992
|
+
"div",
|
|
7993
|
+
{
|
|
7994
|
+
id: listboxId,
|
|
7995
|
+
role: "listbox",
|
|
7996
|
+
className: "max-h-full overflow-x-hidden overflow-y-auto overscroll-contain p-1 scrollbar-gutter-stable",
|
|
7997
|
+
style: {
|
|
7998
|
+
maxHeight: contentStyle.maxHeight,
|
|
7999
|
+
overflowX: "hidden",
|
|
8000
|
+
overflowY: "auto",
|
|
8001
|
+
overscrollBehavior: "contain",
|
|
8002
|
+
scrollbarGutter: "stable",
|
|
8003
|
+
WebkitOverflowScrolling: "touch"
|
|
8004
|
+
},
|
|
8005
|
+
onWheel: (event) => {
|
|
8006
|
+
event.stopPropagation();
|
|
8007
|
+
},
|
|
8008
|
+
onTouchMove: (event) => {
|
|
8009
|
+
event.stopPropagation();
|
|
8010
|
+
},
|
|
8011
|
+
children: filteredItems.length === 0 ? /* @__PURE__ */ jsx25(
|
|
8012
|
+
"div",
|
|
8013
|
+
{
|
|
8014
|
+
className: cn(
|
|
8015
|
+
"px-3 py-6 text-center text-muted-foreground",
|
|
8016
|
+
sizeClasses.message
|
|
8017
|
+
),
|
|
8018
|
+
children: emptyText
|
|
8019
|
+
}
|
|
8020
|
+
) : filteredItems.map((item, index) => {
|
|
8021
|
+
const isSelected = item.value === currentValue;
|
|
8022
|
+
const isActive = index === activeIndex;
|
|
8023
|
+
return /* @__PURE__ */ jsxs15(
|
|
8024
|
+
"div",
|
|
8025
|
+
{
|
|
8026
|
+
id: `${listboxId}-option-${index}`,
|
|
8027
|
+
role: "option",
|
|
8028
|
+
"aria-selected": isSelected,
|
|
8029
|
+
"aria-disabled": item.disabled,
|
|
8030
|
+
tabIndex: -1,
|
|
8031
|
+
onMouseMove: () => {
|
|
8032
|
+
if (!item.disabled) {
|
|
8033
|
+
setActiveIndex(index);
|
|
8034
|
+
}
|
|
8035
|
+
},
|
|
8036
|
+
onPointerDown: (event) => {
|
|
8037
|
+
event.preventDefault();
|
|
8038
|
+
event.stopPropagation();
|
|
8039
|
+
if (!item.disabled) {
|
|
8040
|
+
selectItem(item);
|
|
8041
|
+
}
|
|
8042
|
+
},
|
|
8043
|
+
className: cn(
|
|
8044
|
+
"relative flex w-full select-none items-center gap-2 rounded-lg px-3 text-left outline-none transition",
|
|
8045
|
+
sizeClasses.selectItem,
|
|
8046
|
+
item.disabled ? "pointer-events-none opacity-50" : "cursor-pointer",
|
|
8047
|
+
isActive && !item.disabled && "bg-accent text-accent-foreground",
|
|
8048
|
+
!isActive && !item.disabled && "hover:bg-accent/70 hover:text-accent-foreground",
|
|
8049
|
+
isSelected && "font-medium",
|
|
8050
|
+
itemClassName
|
|
8051
|
+
),
|
|
8052
|
+
children: [
|
|
8053
|
+
/* @__PURE__ */ jsx25("span", { className: "min-w-0 flex-1 truncate", children: item.label }),
|
|
8054
|
+
isSelected ? /* @__PURE__ */ jsx25(
|
|
8055
|
+
CheckIcon5,
|
|
8056
|
+
{
|
|
8057
|
+
"aria-hidden": "true",
|
|
8058
|
+
className: "h-4 w-4 shrink-0 text-primary"
|
|
8059
|
+
}
|
|
8060
|
+
) : null
|
|
8061
|
+
]
|
|
8062
|
+
},
|
|
8063
|
+
item.value
|
|
8064
|
+
);
|
|
8065
|
+
})
|
|
8066
|
+
}
|
|
8067
|
+
)
|
|
8068
|
+
}
|
|
8069
|
+
),
|
|
8070
|
+
document.body
|
|
8071
|
+
) : null;
|
|
7784
8072
|
return /* @__PURE__ */ jsxs15("div", { ref: rootRef, className: "relative w-full", children: [
|
|
7785
8073
|
name ? /* @__PURE__ */ jsx25(
|
|
7786
8074
|
"input",
|
|
@@ -7803,13 +8091,10 @@ function SearchableSelectBase({
|
|
|
7803
8091
|
disabled && "cursor-not-allowed opacity-50",
|
|
7804
8092
|
triggerClassName
|
|
7805
8093
|
) : triggerClassName,
|
|
7806
|
-
onPointerDown: () => {
|
|
7807
|
-
if (disabled) return;
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
var _a;
|
|
7811
|
-
(_a = inputRef.current) == null ? void 0 : _a.focus({ preventScroll: true });
|
|
7812
|
-
});
|
|
8094
|
+
onPointerDown: (event) => {
|
|
8095
|
+
if (disabled || event.button !== 0 || event.ctrlKey) return;
|
|
8096
|
+
event.preventDefault();
|
|
8097
|
+
openDropdown();
|
|
7813
8098
|
},
|
|
7814
8099
|
children: [
|
|
7815
8100
|
/* @__PURE__ */ jsx25(
|
|
@@ -7828,11 +8113,7 @@ function SearchableSelectBase({
|
|
|
7828
8113
|
spellCheck: false,
|
|
7829
8114
|
disabled,
|
|
7830
8115
|
onFocus: () => {
|
|
7831
|
-
|
|
7832
|
-
requestAnimationFrame(() => {
|
|
7833
|
-
var _a;
|
|
7834
|
-
(_a = inputRef.current) == null ? void 0 : _a.select();
|
|
7835
|
-
});
|
|
8116
|
+
openDropdown();
|
|
7836
8117
|
},
|
|
7837
8118
|
onChange: (event) => {
|
|
7838
8119
|
setInputValue(event.target.value);
|
|
@@ -7915,86 +8196,7 @@ function SearchableSelectBase({
|
|
|
7915
8196
|
]
|
|
7916
8197
|
}
|
|
7917
8198
|
),
|
|
7918
|
-
|
|
7919
|
-
"div",
|
|
7920
|
-
{
|
|
7921
|
-
className: cn(
|
|
7922
|
-
"absolute left-0 top-full z-50 mt-1 w-full overflow-hidden rounded-xl border border-border bg-popover text-popover-foreground shadow-xl transition",
|
|
7923
|
-
!open && "pointer-events-none invisible opacity-0",
|
|
7924
|
-
open && "visible opacity-100",
|
|
7925
|
-
contentClassName
|
|
7926
|
-
),
|
|
7927
|
-
children: /* @__PURE__ */ jsx25(
|
|
7928
|
-
"div",
|
|
7929
|
-
{
|
|
7930
|
-
id: listboxId,
|
|
7931
|
-
role: "listbox",
|
|
7932
|
-
className: "max-h-72 overflow-y-auto overscroll-contain p-1 [scrollbar-gutter:stable]",
|
|
7933
|
-
onWheelCapture: (event) => {
|
|
7934
|
-
event.stopPropagation();
|
|
7935
|
-
},
|
|
7936
|
-
onTouchMoveCapture: (event) => {
|
|
7937
|
-
event.stopPropagation();
|
|
7938
|
-
},
|
|
7939
|
-
children: filteredItems.length === 0 ? /* @__PURE__ */ jsx25(
|
|
7940
|
-
"div",
|
|
7941
|
-
{
|
|
7942
|
-
className: cn(
|
|
7943
|
-
"px-3 py-6 text-center text-muted-foreground",
|
|
7944
|
-
sizeClasses.message
|
|
7945
|
-
),
|
|
7946
|
-
children: emptyText
|
|
7947
|
-
}
|
|
7948
|
-
) : filteredItems.map((item, index) => {
|
|
7949
|
-
const isSelected = item.value === currentValue;
|
|
7950
|
-
const isActive = index === activeIndex;
|
|
7951
|
-
return /* @__PURE__ */ jsxs15(
|
|
7952
|
-
"div",
|
|
7953
|
-
{
|
|
7954
|
-
id: `${listboxId}-option-${index}`,
|
|
7955
|
-
role: "option",
|
|
7956
|
-
"aria-selected": isSelected,
|
|
7957
|
-
"aria-disabled": item.disabled,
|
|
7958
|
-
tabIndex: -1,
|
|
7959
|
-
onMouseMove: () => {
|
|
7960
|
-
if (!item.disabled) {
|
|
7961
|
-
setActiveIndex(index);
|
|
7962
|
-
}
|
|
7963
|
-
},
|
|
7964
|
-
onPointerDown: (event) => {
|
|
7965
|
-
event.preventDefault();
|
|
7966
|
-
event.stopPropagation();
|
|
7967
|
-
if (!item.disabled) {
|
|
7968
|
-
selectItem(item);
|
|
7969
|
-
}
|
|
7970
|
-
},
|
|
7971
|
-
className: cn(
|
|
7972
|
-
"relative flex w-full select-none items-center gap-2 rounded-lg px-3 text-left outline-none transition",
|
|
7973
|
-
sizeClasses.selectItem,
|
|
7974
|
-
item.disabled ? "pointer-events-none opacity-50" : "cursor-pointer",
|
|
7975
|
-
isActive && !item.disabled && "bg-accent text-accent-foreground",
|
|
7976
|
-
!isActive && !item.disabled && "hover:bg-accent/70 hover:text-accent-foreground",
|
|
7977
|
-
isSelected && "font-medium",
|
|
7978
|
-
itemClassName
|
|
7979
|
-
),
|
|
7980
|
-
children: [
|
|
7981
|
-
/* @__PURE__ */ jsx25("span", { className: "min-w-0 flex-1 truncate", children: item.label }),
|
|
7982
|
-
isSelected ? /* @__PURE__ */ jsx25(
|
|
7983
|
-
CheckIcon5,
|
|
7984
|
-
{
|
|
7985
|
-
"aria-hidden": "true",
|
|
7986
|
-
className: "h-4 w-4 shrink-0 text-primary"
|
|
7987
|
-
}
|
|
7988
|
-
) : null
|
|
7989
|
-
]
|
|
7990
|
-
},
|
|
7991
|
-
item.value
|
|
7992
|
-
);
|
|
7993
|
-
})
|
|
7994
|
-
}
|
|
7995
|
-
)
|
|
7996
|
-
}
|
|
7997
|
-
)
|
|
8199
|
+
dropdown
|
|
7998
8200
|
] });
|
|
7999
8201
|
}
|
|
8000
8202
|
var SearchableSelect = React47.memo(
|
|
@@ -8009,7 +8211,7 @@ var FormSelect = ({
|
|
|
8009
8211
|
rules,
|
|
8010
8212
|
shouldUnregister,
|
|
8011
8213
|
defaultValue,
|
|
8012
|
-
placeholder = "
|
|
8214
|
+
placeholder = "Select an option",
|
|
8013
8215
|
label,
|
|
8014
8216
|
requiredLabel,
|
|
8015
8217
|
className,
|
|
@@ -8025,7 +8227,6 @@ var FormSelect = ({
|
|
|
8025
8227
|
getOptionLabel = getDefaultOptionLabel,
|
|
8026
8228
|
getOptionDisabled,
|
|
8027
8229
|
getOptionData,
|
|
8028
|
-
children,
|
|
8029
8230
|
onChange,
|
|
8030
8231
|
onChangeItem,
|
|
8031
8232
|
disabled,
|
|
@@ -8034,17 +8235,14 @@ var FormSelect = ({
|
|
|
8034
8235
|
variant = "outline",
|
|
8035
8236
|
invalid,
|
|
8036
8237
|
searchable = false,
|
|
8037
|
-
searchPlaceholder = "
|
|
8038
|
-
emptyText = "No
|
|
8039
|
-
classNameDefault = true
|
|
8040
|
-
position
|
|
8238
|
+
searchPlaceholder = "Search\u2026",
|
|
8239
|
+
emptyText = "No results",
|
|
8240
|
+
classNameDefault = true
|
|
8041
8241
|
}) => {
|
|
8042
8242
|
const form = useFormContext4();
|
|
8043
8243
|
const controllerControl = control != null ? control : form == null ? void 0 : form.control;
|
|
8044
8244
|
const sizeClasses = getFormSizeClasses(size, customSize);
|
|
8045
8245
|
const triggerSizeClass = getFormControlSizeClass(variant, sizeClasses);
|
|
8046
|
-
const contentBase = "z-50 rounded-xl border border-border bg-popover text-popover-foreground shadow-xl outline-none";
|
|
8047
|
-
const contentViewport = "[&_[data-radix-select-viewport]]:max-h-72 [&_[data-radix-select-viewport]]:overflow-y-auto [&_[data-radix-select-viewport]]:overscroll-contain [&_[data-radix-select-viewport]]:[scrollbar-gutter:stable]";
|
|
8048
8246
|
const normalizedOptions = React48.useMemo(() => {
|
|
8049
8247
|
if (options) return options;
|
|
8050
8248
|
return (items != null ? items : []).map((item) => {
|
|
@@ -8085,15 +8283,11 @@ var FormSelect = ({
|
|
|
8085
8283
|
onChange == null ? void 0 : onChange(value);
|
|
8086
8284
|
onChangeItem == null ? void 0 : onChangeItem((_a2 = nextOption == null ? void 0 : nextOption.data) != null ? _a2 : null);
|
|
8087
8285
|
};
|
|
8088
|
-
return /* @__PURE__ */ jsxs16(FormItem, { children: [
|
|
8286
|
+
return /* @__PURE__ */ jsxs16(FormItem, { className: itemClassName, children: [
|
|
8089
8287
|
label ? /* @__PURE__ */ jsxs16(
|
|
8090
8288
|
FormLabel,
|
|
8091
8289
|
{
|
|
8092
|
-
className: cn(
|
|
8093
|
-
"flex items-center gap-0.5",
|
|
8094
|
-
sizeClasses.label,
|
|
8095
|
-
labelClassName
|
|
8096
|
-
),
|
|
8290
|
+
className: cn("flex items-center gap-0.5", labelClassName),
|
|
8097
8291
|
children: [
|
|
8098
8292
|
/* @__PURE__ */ jsx26("span", { children: label }),
|
|
8099
8293
|
requiredLabel ? /* @__PURE__ */ jsx26(
|
|
@@ -8109,7 +8303,7 @@ var FormSelect = ({
|
|
|
8109
8303
|
]
|
|
8110
8304
|
}
|
|
8111
8305
|
) : null,
|
|
8112
|
-
searchable ? /* @__PURE__ */ jsx26(
|
|
8306
|
+
searchable ? /* @__PURE__ */ jsx26(FormControl, { children: /* @__PURE__ */ jsx26(
|
|
8113
8307
|
SearchableSelect,
|
|
8114
8308
|
{
|
|
8115
8309
|
items: normalizedOptions,
|
|
@@ -8132,74 +8326,34 @@ var FormSelect = ({
|
|
|
8132
8326
|
var _a2;
|
|
8133
8327
|
field.onChange(value);
|
|
8134
8328
|
onChange == null ? void 0 : onChange(value);
|
|
8135
|
-
onChangeItem == null ? void 0 : onChangeItem(
|
|
8329
|
+
onChangeItem == null ? void 0 : onChangeItem(
|
|
8330
|
+
(_a2 = option == null ? void 0 : option.data) != null ? _a2 : null
|
|
8331
|
+
);
|
|
8136
8332
|
field.onBlur();
|
|
8137
8333
|
}
|
|
8138
8334
|
}
|
|
8139
|
-
) : /* @__PURE__ */
|
|
8335
|
+
) }) : /* @__PURE__ */ jsx26(
|
|
8140
8336
|
Select2,
|
|
8141
8337
|
{
|
|
8142
8338
|
value: (_b = field.value) != null ? _b : "",
|
|
8143
8339
|
onValueChange: handleValueChange,
|
|
8144
8340
|
onOpenChange: (nextOpen) => {
|
|
8145
|
-
if (!nextOpen)
|
|
8146
|
-
field.onBlur();
|
|
8147
|
-
}
|
|
8341
|
+
if (!nextOpen) field.onBlur();
|
|
8148
8342
|
},
|
|
8149
8343
|
disabled,
|
|
8150
|
-
children:
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
) }),
|
|
8164
|
-
/* @__PURE__ */ jsx26(
|
|
8165
|
-
SelectContent,
|
|
8166
|
-
{
|
|
8167
|
-
position,
|
|
8168
|
-
sideOffset: 6,
|
|
8169
|
-
className: cn(
|
|
8170
|
-
contentBase,
|
|
8171
|
-
contentViewport,
|
|
8172
|
-
"w-(--radix-select-trigger-width) min-w-(--radix-select-trigger-width) overflow-hidden!",
|
|
8173
|
-
contentClassName
|
|
8174
|
-
),
|
|
8175
|
-
onWheelCapture: (event) => {
|
|
8176
|
-
event.stopPropagation();
|
|
8177
|
-
},
|
|
8178
|
-
onTouchMoveCapture: (event) => {
|
|
8179
|
-
event.stopPropagation();
|
|
8180
|
-
},
|
|
8181
|
-
children: children ? children : normalizedOptions.length > 0 ? normalizedOptions.map((option) => /* @__PURE__ */ jsx26(
|
|
8182
|
-
SelectItem,
|
|
8183
|
-
{
|
|
8184
|
-
value: option.value,
|
|
8185
|
-
disabled: option.disabled,
|
|
8186
|
-
className: cn(sizeClasses.selectItem, itemClassName),
|
|
8187
|
-
children: option.label
|
|
8188
|
-
},
|
|
8189
|
-
option.value
|
|
8190
|
-
)) : /* @__PURE__ */ jsx26(
|
|
8191
|
-
"div",
|
|
8192
|
-
{
|
|
8193
|
-
className: cn(
|
|
8194
|
-
"px-3 py-2 text-muted-foreground",
|
|
8195
|
-
sizeClasses.message
|
|
8196
|
-
),
|
|
8197
|
-
children: emptyText
|
|
8198
|
-
}
|
|
8199
|
-
)
|
|
8200
|
-
}
|
|
8201
|
-
)
|
|
8202
|
-
]
|
|
8344
|
+
children: /* @__PURE__ */ jsx26(FormControl, { children: /* @__PURE__ */ jsx26(
|
|
8345
|
+
SelectTrigger,
|
|
8346
|
+
{
|
|
8347
|
+
className: classNameDefault ? cn(
|
|
8348
|
+
formControlBase,
|
|
8349
|
+
formInputVariants[variant],
|
|
8350
|
+
triggerSizeClass,
|
|
8351
|
+
hasError && formControlErrorClass,
|
|
8352
|
+
className
|
|
8353
|
+
) : className,
|
|
8354
|
+
children: /* @__PURE__ */ jsx26(SelectValue, { placeholder })
|
|
8355
|
+
}
|
|
8356
|
+
) })
|
|
8203
8357
|
}
|
|
8204
8358
|
),
|
|
8205
8359
|
fieldError ? /* @__PURE__ */ jsx26(
|
|
@@ -9444,7 +9598,7 @@ var TableHead = React63.forwardRef((_a, ref) => {
|
|
|
9444
9598
|
__spreadValues({
|
|
9445
9599
|
ref,
|
|
9446
9600
|
className: cn(
|
|
9447
|
-
"h-10 px-2 text-left align-middle font-medium text-muted-foreground
|
|
9601
|
+
"h-10 px-2 text-left align-middle font-medium text-muted-foreground has-[[role=checkbox]]:pr-0 *:[[role=checkbox]]:translate-y-0.5",
|
|
9448
9602
|
className
|
|
9449
9603
|
)
|
|
9450
9604
|
}, props)
|
|
@@ -9458,7 +9612,7 @@ var TableCell = React63.forwardRef((_a, ref) => {
|
|
|
9458
9612
|
__spreadValues({
|
|
9459
9613
|
ref,
|
|
9460
9614
|
className: cn(
|
|
9461
|
-
"p-2 align-middle
|
|
9615
|
+
"p-2 align-middle has-[[role=checkbox]]:pr-0 *:[[role=checkbox]]:translate-y-0.5",
|
|
9462
9616
|
className
|
|
9463
9617
|
)
|
|
9464
9618
|
}, props)
|
|
@@ -9967,7 +10121,7 @@ import { Asterisk as Asterisk5 } from "lucide-react";
|
|
|
9967
10121
|
import { jsx as jsx54, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
9968
10122
|
function UiSelect({
|
|
9969
10123
|
label,
|
|
9970
|
-
placeholder,
|
|
10124
|
+
placeholder = "Select an option",
|
|
9971
10125
|
value,
|
|
9972
10126
|
defaultValue,
|
|
9973
10127
|
onChange,
|
|
@@ -9985,7 +10139,6 @@ function UiSelect({
|
|
|
9985
10139
|
size = "md",
|
|
9986
10140
|
customSize,
|
|
9987
10141
|
variant = "outline",
|
|
9988
|
-
classNameDefault = true,
|
|
9989
10142
|
errorMessage,
|
|
9990
10143
|
htmlFormItemId,
|
|
9991
10144
|
position
|
|
@@ -9995,20 +10148,16 @@ function UiSelect({
|
|
|
9995
10148
|
const messageId = `${triggerId}-message`;
|
|
9996
10149
|
const hasError = Boolean(errorMessage);
|
|
9997
10150
|
const sizeClasses = getFormSizeClasses(size, customSize);
|
|
9998
|
-
|
|
9999
|
-
const contentBase = "z-50 rounded-xl border border-border bg-popover text-popover-foreground shadow-xl outline-none";
|
|
10000
|
-
const contentViewport = "[&_[data-radix-select-viewport]]:max-h-72 [&_[data-radix-select-viewport]]:overflow-y-auto [&_[data-radix-select-viewport]]:overscroll-contain [&_[data-radix-select-viewport]]:[scrollbar-gutter:stable]";
|
|
10001
|
-
return /* @__PURE__ */ jsxs27("div", { className: cn("w-full space-y-2", selectClassName), children: [
|
|
10151
|
+
return /* @__PURE__ */ jsxs27("div", { className: cn("w-full space-y-0.5", selectClassName), children: [
|
|
10002
10152
|
label ? /* @__PURE__ */ jsxs27(
|
|
10003
10153
|
Label3,
|
|
10004
10154
|
{
|
|
10155
|
+
htmlFor: triggerId,
|
|
10005
10156
|
className: cn(
|
|
10006
|
-
"
|
|
10007
|
-
sizeClasses.label,
|
|
10157
|
+
"flex items-center gap-0.5 text-sm font-medium -mt-0.75 -pt-1.5",
|
|
10008
10158
|
hasError && "text-destructive",
|
|
10009
10159
|
labelClassName
|
|
10010
10160
|
),
|
|
10011
|
-
htmlFor: triggerId,
|
|
10012
10161
|
children: [
|
|
10013
10162
|
/* @__PURE__ */ jsx54("span", { children: label }),
|
|
10014
10163
|
requiredLabel ? /* @__PURE__ */ jsx54(
|
|
@@ -10031,6 +10180,10 @@ function UiSelect({
|
|
|
10031
10180
|
defaultValue,
|
|
10032
10181
|
onValueChange: onChange,
|
|
10033
10182
|
disabled,
|
|
10183
|
+
size,
|
|
10184
|
+
customSize,
|
|
10185
|
+
variant,
|
|
10186
|
+
invalid: hasError,
|
|
10034
10187
|
children: [
|
|
10035
10188
|
/* @__PURE__ */ jsx54(
|
|
10036
10189
|
SelectTrigger,
|
|
@@ -10038,13 +10191,7 @@ function UiSelect({
|
|
|
10038
10191
|
id: triggerId,
|
|
10039
10192
|
"aria-invalid": hasError || void 0,
|
|
10040
10193
|
"aria-describedby": errorMessage ? messageId : void 0,
|
|
10041
|
-
className
|
|
10042
|
-
formControlBase,
|
|
10043
|
-
formInputVariants[variant],
|
|
10044
|
-
triggerSizeClass,
|
|
10045
|
-
hasError && formControlErrorClass,
|
|
10046
|
-
className
|
|
10047
|
-
) : className,
|
|
10194
|
+
className,
|
|
10048
10195
|
children: /* @__PURE__ */ jsx54(SelectValue, { placeholder })
|
|
10049
10196
|
}
|
|
10050
10197
|
),
|
|
@@ -10054,17 +10201,11 @@ function UiSelect({
|
|
|
10054
10201
|
position,
|
|
10055
10202
|
sideOffset: 6,
|
|
10056
10203
|
className: cn(
|
|
10057
|
-
|
|
10058
|
-
contentViewport,
|
|
10059
|
-
"w-(--radix-select-trigger-width) min-w-(--radix-select-trigger-width) overflow-hidden!",
|
|
10204
|
+
"z-50 overflow-hidden rounded-xl border border-border bg-popover text-popover-foreground shadow-xl outline-none",
|
|
10060
10205
|
contentClassName
|
|
10061
10206
|
),
|
|
10062
|
-
onWheelCapture: (event) =>
|
|
10063
|
-
|
|
10064
|
-
},
|
|
10065
|
-
onTouchMoveCapture: (event) => {
|
|
10066
|
-
event.stopPropagation();
|
|
10067
|
-
},
|
|
10207
|
+
onWheelCapture: (event) => event.stopPropagation(),
|
|
10208
|
+
onTouchMoveCapture: (event) => event.stopPropagation(),
|
|
10068
10209
|
children: children != null ? children : items == null ? void 0 : items.map((item) => /* @__PURE__ */ jsx54(
|
|
10069
10210
|
SelectItem,
|
|
10070
10211
|
{
|