shadcn-ui-react 0.7.10 → 0.7.11

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 CHANGED
@@ -251,12 +251,10 @@ __export(index_exports, {
251
251
  SelectGroup: () => SelectGroup,
252
252
  SelectItem: () => SelectItem,
253
253
  SelectLabel: () => SelectLabel,
254
- SelectScrollDownButton: () => SelectScrollDownButton,
255
- SelectScrollUpButton: () => SelectScrollUpButton,
256
254
  SelectSeparator: () => SelectSeparator,
257
255
  SelectTrigger: () => SelectTrigger,
258
256
  SelectValue: () => SelectValue,
259
- Separator: () => Separator6,
257
+ Separator: () => Separator5,
260
258
  Sheet: () => Sheet,
261
259
  SheetClose: () => SheetClose,
262
260
  SheetContent: () => SheetContent,
@@ -307,9 +305,18 @@ __export(index_exports, {
307
305
  badgeVariants: () => badgeVariants,
308
306
  buttonVariants: () => buttonVariants,
309
307
  cn: () => cn,
308
+ formCompositeControlBase: () => formCompositeControlBase,
309
+ formCompositeControlErrorClass: () => formCompositeControlErrorClass,
310
+ formCompositeVariants: () => formCompositeVariants,
311
+ formControlBase: () => formControlBase,
312
+ formControlErrorClass: () => formControlErrorClass,
313
+ formInputVariants: () => formInputVariants,
314
+ formSizeVariants: () => formSizeVariants,
310
315
  getDefaultOptionLabel: () => getDefaultOptionLabel,
311
316
  getDefaultOptionValue: () => getDefaultOptionValue,
312
317
  getErrorMessage: () => getErrorMessage,
318
+ getFormControlSizeClass: () => getFormControlSizeClass,
319
+ getFormSizeClasses: () => getFormSizeClasses,
313
320
  getNextEnabledIndex: () => getNextEnabledIndex,
314
321
  iconButtonVariants: () => iconButtonVariants,
315
322
  navigationMenuTriggerStyle: () => navigationMenuTriggerStyle,
@@ -319,7 +326,8 @@ __export(index_exports, {
319
326
  toggleVariants: () => toggleVariants,
320
327
  useFormField: () => useFormField,
321
328
  useSidebar: () => useSidebar,
322
- useToast: () => useToast
329
+ useToast: () => useToast,
330
+ variants: () => variants
323
331
  });
324
332
  module.exports = __toCommonJS(index_exports);
325
333
 
@@ -6865,7 +6873,7 @@ var import_react_hook_form4 = require("react-hook-form");
6865
6873
  // src/components/input.tsx
6866
6874
  var React45 = __toESM(require("react"), 1);
6867
6875
 
6868
- // src/components/Form/utils/form-utils.ts
6876
+ // src/utils/form-utils.ts
6869
6877
  var formInputVariants = {
6870
6878
  outline: "rounded-md border border-input bg-input backdrop-blur-sm shadow-sm hover:border-primary/60 focus:border-primary focus:ring-2 focus:ring-primary/20",
6871
6879
  soft: "rounded-md border border-transparent bg-muted/60 shadow-sm hover:bg-muted focus:bg-input/80 focus:ring-2 focus:ring-primary/20",
@@ -6875,6 +6883,15 @@ var formInputVariants = {
6875
6883
  unstyled: "border-0 shadow-none focus:ring-0",
6876
6884
  link: "h-auto border-0 bg-transparent p-0 text-primary shadow-none underline-offset-4 focus:underline focus:ring-0"
6877
6885
  };
6886
+ var formCompositeVariants = {
6887
+ outline: "rounded-md border border-input bg-input backdrop-blur-sm shadow-sm hover:border-primary/60 focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20",
6888
+ soft: "rounded-md border border-transparent bg-muted/60 shadow-sm hover:bg-muted focus-within:bg-input/80 focus-within:ring-2 focus-within:ring-primary/20",
6889
+ ghost: "rounded-md border border-transparent bg-transparent hover:bg-muted/50 focus-within:ring-2 focus-within:ring-ring",
6890
+ filled: "rounded-md border border-input bg-muted/70 shadow-inner hover:bg-muted focus-within:bg-input/70 focus-within:ring-2 focus-within:ring-primary/20",
6891
+ flushed: "rounded-none border-0 border-b border-input px-0 shadow-none focus-within:border-b-2 focus-within:border-primary focus-within:ring-0",
6892
+ unstyled: "border-0 shadow-none focus-within:ring-0",
6893
+ link: "h-auto border-0 bg-transparent p-0 text-primary shadow-none underline-offset-4 focus-within:underline focus-within:ring-0"
6894
+ };
6878
6895
  var variants = formInputVariants;
6879
6896
  var formSizeVariants = {
6880
6897
  "2xs": {
@@ -6955,9 +6972,18 @@ var formSizeVariants = {
6955
6972
  message: "text-base"
6956
6973
  }
6957
6974
  };
6975
+ var formControlBase = "relative inline-flex w-full items-center justify-between gap-2 text-foreground outline-none transition data-[placeholder]:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50";
6976
+ var formCompositeControlBase = "relative flex w-full items-center gap-2 text-foreground outline-none transition";
6977
+ var formControlErrorClass = "border-destructive focus:border-destructive focus:ring-destructive/20";
6978
+ var formCompositeControlErrorClass = "border-destructive focus-within:border-destructive focus-within:ring-destructive/20";
6958
6979
  function getFormSizeClasses(size = "md", customSize) {
6959
6980
  return __spreadValues(__spreadValues({}, formSizeVariants[size]), customSize);
6960
6981
  }
6982
+ function getFormControlSizeClass(variant, sizeClasses) {
6983
+ if (variant === "flushed") return sizeClasses.flushedControl;
6984
+ if (variant === "link") return sizeClasses.linkControl;
6985
+ return sizeClasses.control;
6986
+ }
6961
6987
 
6962
6988
  // src/components/input.tsx
6963
6989
  var import_jsx_runtime22 = require("react/jsx-runtime");
@@ -7167,195 +7193,750 @@ var import_react_hook_form5 = require("react-hook-form");
7167
7193
 
7168
7194
  // src/components/select.tsx
7169
7195
  var import_react_icons9 = require("@radix-ui/react-icons");
7170
- var SelectPrimitive = __toESM(require("@radix-ui/react-select"), 1);
7171
7196
  var React46 = __toESM(require("react"), 1);
7197
+ var import_react_dom = require("react-dom");
7172
7198
  var import_jsx_runtime24 = require("react/jsx-runtime");
7173
- var Select2 = SelectPrimitive.Root;
7174
- var SelectGroup = SelectPrimitive.Group;
7175
- var SelectValue = SelectPrimitive.Value;
7176
- var BODY_UNLOCK_ATTR = "data-select-scroll-unlocked";
7177
- var BODY_UNLOCK_STYLE_ID = "radix-select-scroll-unlock-style";
7178
- var useSafeLayoutEffect = typeof window !== "undefined" ? React46.useLayoutEffect : React46.useEffect;
7179
- function SelectBodyScrollUnlock() {
7180
- useSafeLayoutEffect(() => {
7181
- var _a;
7182
- if (typeof document === "undefined") return;
7183
- if (!document.getElementById(BODY_UNLOCK_STYLE_ID)) {
7184
- const style = document.createElement("style");
7185
- style.id = BODY_UNLOCK_STYLE_ID;
7186
- style.textContent = `
7187
- body[${BODY_UNLOCK_ATTR}][data-scroll-locked] {
7188
- overflow: auto !important;
7189
- margin-right: 0 !important;
7190
- padding-right: 0 !important;
7191
- }
7192
- `;
7193
- document.head.appendChild(style);
7194
- }
7195
- const body = document.body;
7196
- const currentCount = Number((_a = body.getAttribute(BODY_UNLOCK_ATTR)) != null ? _a : "0");
7197
- body.setAttribute(BODY_UNLOCK_ATTR, String(currentCount + 1));
7198
- return () => {
7199
- var _a2;
7200
- const nextCount = Number((_a2 = body.getAttribute(BODY_UNLOCK_ATTR)) != null ? _a2 : "1") - 1;
7201
- if (nextCount <= 0) {
7202
- body.removeAttribute(BODY_UNLOCK_ATTR);
7203
- } else {
7204
- body.setAttribute(BODY_UNLOCK_ATTR, String(nextCount));
7199
+ var SelectContext = React46.createContext(null);
7200
+ function useSelectContext(componentName) {
7201
+ const context = React46.useContext(SelectContext);
7202
+ if (!context) {
7203
+ throw new Error(`${componentName} must be used within <Select />`);
7204
+ }
7205
+ return context;
7206
+ }
7207
+ function useControllableState({
7208
+ value,
7209
+ defaultValue,
7210
+ onChange
7211
+ }) {
7212
+ const [internalValue, setInternalValue] = React46.useState(defaultValue);
7213
+ const isControlled = value !== void 0;
7214
+ const currentValue = isControlled ? value : internalValue;
7215
+ const setValue = React46.useCallback(
7216
+ (nextValue) => {
7217
+ if (!isControlled) {
7218
+ setInternalValue(nextValue);
7205
7219
  }
7206
- };
7207
- }, []);
7208
- return null;
7220
+ onChange == null ? void 0 : onChange(nextValue);
7221
+ },
7222
+ [isControlled, onChange]
7223
+ );
7224
+ return [currentValue, setValue];
7209
7225
  }
7210
- var SelectTrigger = React46.forwardRef((_a, ref) => {
7211
- var _b = _a, { className, children } = _b, props = __objRest(_b, ["className", "children"]);
7212
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
7213
- SelectPrimitive.Trigger,
7214
- __spreadProps(__spreadValues({
7215
- ref,
7216
- className: cn(
7217
- "flex h-9 w-full items-center justify-between gap-2 whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background transition-colors placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
7218
- className
7219
- )
7220
- }, props), {
7221
- children: [
7222
- children,
7223
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_icons9.CaretSortIcon, { className: "h-4 w-4 shrink-0 opacity-50" }) })
7224
- ]
7225
- })
7226
+ function composeRefs(...refs) {
7227
+ return (node) => {
7228
+ refs.forEach((ref) => {
7229
+ if (!ref) return;
7230
+ if (typeof ref === "function") {
7231
+ ref(node);
7232
+ return;
7233
+ }
7234
+ ref.current = node;
7235
+ });
7236
+ };
7237
+ }
7238
+ function getNodeText(node) {
7239
+ if (node === null || node === void 0 || typeof node === "boolean") {
7240
+ return "";
7241
+ }
7242
+ if (typeof node === "string" || typeof node === "number") {
7243
+ return String(node);
7244
+ }
7245
+ if (Array.isArray(node)) {
7246
+ return node.map(getNodeText).join("");
7247
+ }
7248
+ if (React46.isValidElement(node)) {
7249
+ return getNodeText(node.props.children);
7250
+ }
7251
+ return "";
7252
+ }
7253
+ function getEnabledItems(items) {
7254
+ return items.filter((item) => !item.disabled);
7255
+ }
7256
+ function getNextItemValue(items, currentValue, direction) {
7257
+ var _a, _b, _c;
7258
+ const enabledItems = getEnabledItems(items);
7259
+ if (!enabledItems.length) return void 0;
7260
+ const currentIndex = enabledItems.findIndex(
7261
+ (item) => item.value === currentValue
7226
7262
  );
7227
- });
7228
- SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
7229
- var SelectScrollUpButton = React46.forwardRef((_a, ref) => {
7230
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
7231
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7232
- SelectPrimitive.ScrollUpButton,
7233
- __spreadProps(__spreadValues({
7234
- ref,
7235
- className: cn(
7236
- "flex cursor-default items-center justify-center py-1",
7237
- className
7238
- )
7239
- }, props), {
7240
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_icons9.ChevronUpIcon, { className: "h-4 w-4" })
7241
- })
7263
+ if (currentIndex === -1) {
7264
+ return direction === "next" ? (_a = enabledItems[0]) == null ? void 0 : _a.value : (_b = enabledItems[enabledItems.length - 1]) == null ? void 0 : _b.value;
7265
+ }
7266
+ const nextIndex = direction === "next" ? (currentIndex + 1) % enabledItems.length : (currentIndex - 1 + enabledItems.length) % enabledItems.length;
7267
+ return (_c = enabledItems[nextIndex]) == null ? void 0 : _c.value;
7268
+ }
7269
+ function Select2({
7270
+ value,
7271
+ defaultValue = "",
7272
+ onValueChange,
7273
+ open,
7274
+ defaultOpen = false,
7275
+ onOpenChange,
7276
+ disabled = false,
7277
+ name,
7278
+ required,
7279
+ variant = "outline",
7280
+ size = "sm",
7281
+ customSize,
7282
+ invalid = false,
7283
+ children
7284
+ }) {
7285
+ const triggerRef = React46.useRef(null);
7286
+ const contentRef = React46.useRef(null);
7287
+ const [currentValue, setCurrentValue] = useControllableState({
7288
+ value,
7289
+ defaultValue,
7290
+ onChange: onValueChange
7291
+ });
7292
+ const [isOpen, setIsOpen] = useControllableState({
7293
+ value: open,
7294
+ defaultValue: defaultOpen,
7295
+ onChange: onOpenChange
7296
+ });
7297
+ const itemsRef = React46.useRef(/* @__PURE__ */ new Map());
7298
+ const [itemsVersion, forceItemsUpdate] = React46.useReducer(
7299
+ (version) => version + 1,
7300
+ 0
7301
+ );
7302
+ const [activeValue, setActiveValue] = React46.useState();
7303
+ const items = React46.useMemo(
7304
+ () => Array.from(itemsRef.current.values()),
7305
+ [itemsVersion]
7306
+ );
7307
+ const selectedItem = items.find((item) => item.value === currentValue);
7308
+ const registerItem = React46.useCallback((item) => {
7309
+ itemsRef.current.set(item.value, item);
7310
+ forceItemsUpdate();
7311
+ }, []);
7312
+ const unregisterItem = React46.useCallback((value2, id) => {
7313
+ const currentItem = itemsRef.current.get(value2);
7314
+ if (!currentItem || currentItem.id !== id) return;
7315
+ itemsRef.current.set(value2, __spreadProps(__spreadValues({}, currentItem), {
7316
+ ref: null
7317
+ }));
7318
+ forceItemsUpdate();
7319
+ }, []);
7320
+ const updateItemRef = React46.useCallback(
7321
+ (value2, id, node) => {
7322
+ const currentItem = itemsRef.current.get(value2);
7323
+ if (!currentItem || currentItem.id !== id) return;
7324
+ if (currentItem.ref === node) return;
7325
+ itemsRef.current.set(value2, __spreadProps(__spreadValues({}, currentItem), {
7326
+ ref: node
7327
+ }));
7328
+ forceItemsUpdate();
7329
+ },
7330
+ []
7242
7331
  );
7243
- });
7244
- SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
7245
- var SelectScrollDownButton = React46.forwardRef((_a, ref) => {
7246
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
7247
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7248
- SelectPrimitive.ScrollDownButton,
7249
- __spreadProps(__spreadValues({
7250
- ref,
7251
- className: cn(
7252
- "flex cursor-default items-center justify-center py-1",
7253
- className
7254
- )
7255
- }, props), {
7256
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_icons9.ChevronDownIcon, { className: "h-4 w-4" })
7257
- })
7332
+ const handleOpenChange = React46.useCallback(
7333
+ (nextOpen) => {
7334
+ if (disabled) return;
7335
+ setIsOpen(nextOpen);
7336
+ },
7337
+ [disabled, setIsOpen]
7258
7338
  );
7259
- });
7260
- SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
7339
+ const handleValueChange = React46.useCallback(
7340
+ (nextValue) => {
7341
+ if (disabled) return;
7342
+ setCurrentValue(nextValue);
7343
+ setIsOpen(false);
7344
+ requestAnimationFrame(() => {
7345
+ var _a;
7346
+ (_a = triggerRef.current) == null ? void 0 : _a.focus();
7347
+ });
7348
+ },
7349
+ [disabled, setCurrentValue, setIsOpen]
7350
+ );
7351
+ React46.useEffect(() => {
7352
+ var _a;
7353
+ if (!isOpen) return;
7354
+ const selectedEnabledItem = items.find(
7355
+ (item) => item.value === currentValue && !item.disabled
7356
+ );
7357
+ const firstEnabledItem = getEnabledItems(items)[0];
7358
+ setActiveValue((_a = selectedEnabledItem == null ? void 0 : selectedEnabledItem.value) != null ? _a : firstEnabledItem == null ? void 0 : firstEnabledItem.value);
7359
+ }, [currentValue, isOpen, items]);
7360
+ React46.useEffect(() => {
7361
+ if (!isOpen) return;
7362
+ const handlePointerDown = (event) => {
7363
+ var _a, _b;
7364
+ const target = event.target;
7365
+ if (((_a = triggerRef.current) == null ? void 0 : _a.contains(target)) || ((_b = contentRef.current) == null ? void 0 : _b.contains(target))) {
7366
+ return;
7367
+ }
7368
+ setIsOpen(false);
7369
+ };
7370
+ document.addEventListener("pointerdown", handlePointerDown);
7371
+ return () => {
7372
+ document.removeEventListener("pointerdown", handlePointerDown);
7373
+ };
7374
+ }, [isOpen, setIsOpen]);
7375
+ const contextValue = React46.useMemo(
7376
+ () => ({
7377
+ value: currentValue,
7378
+ open: isOpen,
7379
+ disabled,
7380
+ invalid,
7381
+ variant,
7382
+ size,
7383
+ customSize,
7384
+ selectedItem,
7385
+ activeValue,
7386
+ items,
7387
+ triggerRef,
7388
+ contentRef,
7389
+ setOpen: handleOpenChange,
7390
+ setValue: handleValueChange,
7391
+ setActiveValue,
7392
+ registerItem,
7393
+ unregisterItem,
7394
+ updateItemRef
7395
+ }),
7396
+ [
7397
+ currentValue,
7398
+ isOpen,
7399
+ disabled,
7400
+ invalid,
7401
+ variant,
7402
+ size,
7403
+ customSize,
7404
+ selectedItem,
7405
+ activeValue,
7406
+ items,
7407
+ handleOpenChange,
7408
+ handleValueChange,
7409
+ registerItem,
7410
+ unregisterItem,
7411
+ updateItemRef
7412
+ ]
7413
+ );
7414
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(SelectContext.Provider, { value: contextValue, children: [
7415
+ children,
7416
+ name ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7417
+ "input",
7418
+ {
7419
+ type: "hidden",
7420
+ name,
7421
+ value: currentValue,
7422
+ required
7423
+ }
7424
+ ) : null
7425
+ ] });
7426
+ }
7427
+ var SelectTrigger = React46.forwardRef(
7428
+ (_a, ref) => {
7429
+ var _b = _a, {
7430
+ className,
7431
+ children,
7432
+ variant,
7433
+ size,
7434
+ customSize,
7435
+ invalid,
7436
+ disabled,
7437
+ onClick,
7438
+ onKeyDown
7439
+ } = _b, props = __objRest(_b, [
7440
+ "className",
7441
+ "children",
7442
+ "variant",
7443
+ "size",
7444
+ "customSize",
7445
+ "invalid",
7446
+ "disabled",
7447
+ "onClick",
7448
+ "onKeyDown"
7449
+ ]);
7450
+ const context = useSelectContext("SelectTrigger");
7451
+ const resolvedVariant = variant != null ? variant : context.variant;
7452
+ const resolvedSize = size != null ? size : context.size;
7453
+ const resolvedCustomSize = customSize != null ? customSize : context.customSize;
7454
+ const resolvedInvalid = invalid != null ? invalid : context.invalid;
7455
+ const resolvedDisabled = disabled != null ? disabled : context.disabled;
7456
+ const sizeClasses = getFormSizeClasses(resolvedSize, resolvedCustomSize);
7457
+ const controlSizeClass = getFormControlSizeClass(
7458
+ resolvedVariant,
7459
+ sizeClasses
7460
+ );
7461
+ const typeaheadRef = React46.useRef("");
7462
+ const typeaheadTimeoutRef = React46.useRef(null);
7463
+ const moveActiveItem = React46.useCallback(
7464
+ (direction) => {
7465
+ var _a2;
7466
+ const nextValue = getNextItemValue(
7467
+ context.items,
7468
+ (_a2 = context.activeValue) != null ? _a2 : context.value,
7469
+ direction
7470
+ );
7471
+ if (nextValue) {
7472
+ context.setActiveValue(nextValue);
7473
+ }
7474
+ },
7475
+ [context]
7476
+ );
7477
+ const handleTypeahead = React46.useCallback(
7478
+ (key) => {
7479
+ typeaheadRef.current += key.toLowerCase();
7480
+ if (typeaheadTimeoutRef.current) {
7481
+ window.clearTimeout(typeaheadTimeoutRef.current);
7482
+ }
7483
+ typeaheadTimeoutRef.current = window.setTimeout(() => {
7484
+ typeaheadRef.current = "";
7485
+ }, 500);
7486
+ const enabledItems = getEnabledItems(context.items);
7487
+ const match2 = enabledItems.find(
7488
+ (item) => item.textValue.toLowerCase().startsWith(typeaheadRef.current)
7489
+ );
7490
+ if (!match2) return;
7491
+ if (!context.open) {
7492
+ context.setOpen(true);
7493
+ }
7494
+ context.setActiveValue(match2.value);
7495
+ },
7496
+ [context]
7497
+ );
7498
+ React46.useEffect(() => {
7499
+ return () => {
7500
+ if (typeaheadTimeoutRef.current) {
7501
+ window.clearTimeout(typeaheadTimeoutRef.current);
7502
+ }
7503
+ };
7504
+ }, []);
7505
+ const handleKeyDown = (event) => {
7506
+ onKeyDown == null ? void 0 : onKeyDown(event);
7507
+ if (event.defaultPrevented || resolvedDisabled) return;
7508
+ if (event.key === "ArrowDown") {
7509
+ event.preventDefault();
7510
+ if (!context.open) {
7511
+ context.setOpen(true);
7512
+ return;
7513
+ }
7514
+ moveActiveItem("next");
7515
+ return;
7516
+ }
7517
+ if (event.key === "ArrowUp") {
7518
+ event.preventDefault();
7519
+ if (!context.open) {
7520
+ context.setOpen(true);
7521
+ return;
7522
+ }
7523
+ moveActiveItem("previous");
7524
+ return;
7525
+ }
7526
+ if (event.key === "Enter" || event.key === " ") {
7527
+ event.preventDefault();
7528
+ if (!context.open) {
7529
+ context.setOpen(true);
7530
+ return;
7531
+ }
7532
+ if (context.activeValue) {
7533
+ context.setValue(context.activeValue);
7534
+ }
7535
+ return;
7536
+ }
7537
+ if (event.key === "Escape") {
7538
+ event.preventDefault();
7539
+ context.setOpen(false);
7540
+ return;
7541
+ }
7542
+ if (event.key === "Home") {
7543
+ event.preventDefault();
7544
+ const firstEnabledItem = getEnabledItems(context.items)[0];
7545
+ if (firstEnabledItem) {
7546
+ context.setActiveValue(firstEnabledItem.value);
7547
+ }
7548
+ return;
7549
+ }
7550
+ if (event.key === "End") {
7551
+ event.preventDefault();
7552
+ const enabledItems = getEnabledItems(context.items);
7553
+ const lastEnabledItem = enabledItems[enabledItems.length - 1];
7554
+ if (lastEnabledItem) {
7555
+ context.setActiveValue(lastEnabledItem.value);
7556
+ }
7557
+ return;
7558
+ }
7559
+ if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
7560
+ handleTypeahead(event.key);
7561
+ }
7562
+ };
7563
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
7564
+ "button",
7565
+ __spreadProps(__spreadValues({
7566
+ ref: composeRefs(ref, context.triggerRef),
7567
+ type: "button",
7568
+ "aria-haspopup": "listbox",
7569
+ "aria-expanded": context.open,
7570
+ "data-placeholder": !context.value ? "" : void 0,
7571
+ disabled: resolvedDisabled,
7572
+ className: cn(
7573
+ formControlBase,
7574
+ "whitespace-nowrap ring-offset-background [&>span]:line-clamp-1",
7575
+ formInputVariants[resolvedVariant],
7576
+ controlSizeClass,
7577
+ resolvedInvalid && formControlErrorClass,
7578
+ className
7579
+ ),
7580
+ onClick: (event) => {
7581
+ onClick == null ? void 0 : onClick(event);
7582
+ if (!event.defaultPrevented && !resolvedDisabled) {
7583
+ context.setOpen(!context.open);
7584
+ }
7585
+ },
7586
+ onKeyDown: handleKeyDown
7587
+ }, props), {
7588
+ children: [
7589
+ children,
7590
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_icons9.CaretSortIcon, { className: "h-4 w-4 shrink-0 opacity-50" })
7591
+ ]
7592
+ })
7593
+ );
7594
+ }
7595
+ );
7596
+ SelectTrigger.displayName = "SelectTrigger";
7597
+ var SelectValue = React46.forwardRef(
7598
+ (_a, ref) => {
7599
+ var _b = _a, { className, placeholder, children } = _b, props = __objRest(_b, ["className", "placeholder", "children"]);
7600
+ var _a2, _b2;
7601
+ const context = useSelectContext("SelectValue");
7602
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", __spreadProps(__spreadValues({ ref, className: cn("truncate", className) }, props), { children: (_b2 = children != null ? children : (_a2 = context.selectedItem) == null ? void 0 : _a2.label) != null ? _b2 : placeholder }));
7603
+ }
7604
+ );
7605
+ SelectValue.displayName = "SelectValue";
7261
7606
  var SelectContent = React46.forwardRef(
7262
7607
  (_a, ref) => {
7263
7608
  var _b = _a, {
7264
7609
  className,
7265
7610
  children,
7266
- position = "popper",
7267
7611
  sideOffset = 4,
7268
- align = "start"
7612
+ align = "start",
7613
+ position: _position,
7614
+ style
7269
7615
  } = _b, props = __objRest(_b, [
7270
7616
  "className",
7271
7617
  "children",
7272
- "position",
7273
7618
  "sideOffset",
7274
- "align"
7619
+ "align",
7620
+ "position",
7621
+ "style"
7275
7622
  ]);
7276
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
7277
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SelectBodyScrollUnlock, {}),
7278
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SelectPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
7279
- SelectPrimitive.Content,
7280
- __spreadProps(__spreadValues({
7281
- ref,
7282
- position,
7283
- sideOffset,
7284
- align,
7623
+ const context = useSelectContext("SelectContent");
7624
+ const scrollRef = React46.useRef(null);
7625
+ const rafRef = React46.useRef(null);
7626
+ const [mounted, setMounted] = React46.useState(false);
7627
+ const [side, setSide] = React46.useState("bottom");
7628
+ const [contentStyle, setContentStyle] = React46.useState();
7629
+ React46.useEffect(() => {
7630
+ setMounted(true);
7631
+ }, []);
7632
+ const updatePosition = React46.useCallback(() => {
7633
+ const trigger = context.triggerRef.current;
7634
+ if (!trigger) return;
7635
+ const rect = trigger.getBoundingClientRect();
7636
+ const viewportPadding = 8;
7637
+ const preferredMaxHeight = 260;
7638
+ const minUsefulHeight = 140;
7639
+ const availableBelow = window.innerHeight - rect.bottom - viewportPadding - sideOffset;
7640
+ const availableAbove = rect.top - viewportPadding - sideOffset;
7641
+ const nextSide = availableBelow >= Math.min(preferredMaxHeight, minUsefulHeight) || availableBelow >= availableAbove ? "bottom" : "top";
7642
+ const availableHeight = nextSide === "bottom" ? availableBelow : availableAbove;
7643
+ const contentMaxHeight = Math.max(
7644
+ 80,
7645
+ Math.min(preferredMaxHeight, availableHeight)
7646
+ );
7647
+ const baseStyle = {
7648
+ position: "fixed",
7649
+ zIndex: 9999,
7650
+ width: rect.width,
7651
+ minWidth: rect.width,
7652
+ maxWidth: "calc(100vw - 16px)",
7653
+ maxHeight: contentMaxHeight
7654
+ };
7655
+ if (align === "start") {
7656
+ baseStyle.left = rect.left;
7657
+ baseStyle.transform = void 0;
7658
+ }
7659
+ if (align === "center") {
7660
+ baseStyle.left = rect.left + rect.width / 2;
7661
+ baseStyle.transform = "translateX(-50%)";
7662
+ }
7663
+ if (align === "end") {
7664
+ baseStyle.left = rect.right;
7665
+ baseStyle.transform = "translateX(-100%)";
7666
+ }
7667
+ if (nextSide === "bottom") {
7668
+ baseStyle.top = rect.bottom + sideOffset;
7669
+ baseStyle.bottom = void 0;
7670
+ } else {
7671
+ baseStyle.bottom = window.innerHeight - rect.top + sideOffset;
7672
+ baseStyle.top = void 0;
7673
+ }
7674
+ setSide(nextSide);
7675
+ setContentStyle(baseStyle);
7676
+ }, [align, context.triggerRef, sideOffset]);
7677
+ const scheduleUpdatePosition = React46.useCallback(() => {
7678
+ if (rafRef.current) {
7679
+ cancelAnimationFrame(rafRef.current);
7680
+ }
7681
+ rafRef.current = requestAnimationFrame(() => {
7682
+ updatePosition();
7683
+ });
7684
+ }, [updatePosition]);
7685
+ React46.useLayoutEffect(() => {
7686
+ var _a2, _b2;
7687
+ if (!context.open) return;
7688
+ updatePosition();
7689
+ scheduleUpdatePosition();
7690
+ const handleResize = () => {
7691
+ scheduleUpdatePosition();
7692
+ };
7693
+ const handlePageScroll = (event) => {
7694
+ var _a3;
7695
+ const target = event.target;
7696
+ if (target && ((_a3 = scrollRef.current) == null ? void 0 : _a3.contains(target))) {
7697
+ return;
7698
+ }
7699
+ scheduleUpdatePosition();
7700
+ };
7701
+ window.addEventListener("resize", handleResize);
7702
+ window.addEventListener("scroll", handlePageScroll, true);
7703
+ (_a2 = window.visualViewport) == null ? void 0 : _a2.addEventListener("resize", handleResize);
7704
+ (_b2 = window.visualViewport) == null ? void 0 : _b2.addEventListener("scroll", handleResize);
7705
+ return () => {
7706
+ var _a3, _b3;
7707
+ window.removeEventListener("resize", handleResize);
7708
+ window.removeEventListener("scroll", handlePageScroll, true);
7709
+ (_a3 = window.visualViewport) == null ? void 0 : _a3.removeEventListener("resize", handleResize);
7710
+ (_b3 = window.visualViewport) == null ? void 0 : _b3.removeEventListener("scroll", handleResize);
7711
+ if (rafRef.current) {
7712
+ cancelAnimationFrame(rafRef.current);
7713
+ rafRef.current = null;
7714
+ }
7715
+ };
7716
+ }, [context.open, scheduleUpdatePosition, updatePosition]);
7717
+ React46.useLayoutEffect(() => {
7718
+ if (!context.open) return;
7719
+ const frame = requestAnimationFrame(() => {
7720
+ var _a2;
7721
+ const activeItem = context.items.find(
7722
+ (item) => item.value === context.activeValue
7723
+ );
7724
+ (_a2 = activeItem == null ? void 0 : activeItem.ref) == null ? void 0 : _a2.scrollIntoView({
7725
+ block: "nearest"
7726
+ });
7727
+ });
7728
+ return () => {
7729
+ cancelAnimationFrame(frame);
7730
+ };
7731
+ }, [context.activeValue, context.items, context.open]);
7732
+ if (!context.open) {
7733
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { hidden: true, "aria-hidden": "true", style: { display: "none" }, children });
7734
+ }
7735
+ if (!mounted || !contentStyle) return null;
7736
+ return (0, import_react_dom.createPortal)(
7737
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7738
+ "div",
7739
+ __spreadProps(__spreadValues({}, props), {
7740
+ ref: composeRefs(ref, context.contentRef),
7741
+ role: "listbox",
7742
+ "data-side": side,
7285
7743
  className: cn(
7286
- "relative z-50 min-w-32 overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md",
7287
- "data-[state=open]:animate-in data-[state=closed]:animate-out",
7288
- "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
7289
- "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
7290
- "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2",
7291
- "data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
7292
- position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
7744
+ "min-w-32 rounded-md border border-border bg-popover text-popover-foreground shadow-md",
7745
+ "overflow-hidden",
7293
7746
  className
7747
+ ),
7748
+ style: __spreadValues(__spreadValues({}, contentStyle), style),
7749
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7750
+ "div",
7751
+ {
7752
+ ref: scrollRef,
7753
+ "data-select-scroll-content": true,
7754
+ className: cn(
7755
+ "max-h-full px-1 py-1",
7756
+ "!overflow-x-hidden !overflow-y-scroll overscroll-contain",
7757
+ "[scrollbar-gutter:stable]",
7758
+ "[scrollbar-width:thin]",
7759
+ "[&::-webkit-scrollbar]:!block",
7760
+ "[&::-webkit-scrollbar]:!w-2",
7761
+ "[&::-webkit-scrollbar-track]:!bg-transparent",
7762
+ "[&::-webkit-scrollbar-thumb]:!rounded-full",
7763
+ "[&::-webkit-scrollbar-thumb]:!bg-border"
7764
+ ),
7765
+ style: {
7766
+ maxHeight: contentStyle.maxHeight,
7767
+ overflowX: "hidden",
7768
+ overflowY: "scroll",
7769
+ overscrollBehavior: "contain",
7770
+ scrollbarGutter: "stable",
7771
+ WebkitOverflowScrolling: "touch"
7772
+ },
7773
+ onWheel: (event) => {
7774
+ event.stopPropagation();
7775
+ },
7776
+ children
7777
+ }
7294
7778
  )
7295
- }, props), {
7296
- children: [
7297
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SelectScrollUpButton, {}),
7298
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7299
- SelectPrimitive.Viewport,
7300
- {
7301
- className: cn(
7302
- "max-h-[min(20rem,var(--radix-select-content-available-height))] overflow-y-auto p-1",
7303
- position === "popper" && "w-full min-w-(--radix-select-trigger-width)"
7304
- ),
7305
- children
7306
- }
7307
- ),
7308
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SelectScrollDownButton, {})
7309
- ]
7310
7779
  })
7311
- ) })
7312
- ] });
7780
+ ),
7781
+ document.body
7782
+ );
7313
7783
  }
7314
7784
  );
7315
- SelectContent.displayName = SelectPrimitive.Content.displayName;
7316
- var SelectLabel = React46.forwardRef((_a, ref) => {
7317
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
7318
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7319
- SelectPrimitive.Label,
7320
- __spreadValues({
7321
- ref,
7322
- className: cn("px-2 py-1.5 text-sm font-semibold", className)
7323
- }, props)
7324
- );
7325
- });
7326
- SelectLabel.displayName = SelectPrimitive.Label.displayName;
7327
- var SelectItem = React46.forwardRef((_a, ref) => {
7328
- var _b = _a, { className, children } = _b, props = __objRest(_b, ["className", "children"]);
7329
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
7330
- SelectPrimitive.Item,
7331
- __spreadProps(__spreadValues({
7332
- ref,
7333
- className: cn(
7334
- "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none transition-colors",
7335
- "focus:bg-accent focus:text-accent-foreground",
7336
- "data-disabled:pointer-events-none data-disabled:opacity-50",
7337
- className
7338
- )
7339
- }, props), {
7340
- children: [
7341
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_icons9.CheckIcon, { className: "h-4 w-4" }) }) }),
7342
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SelectPrimitive.ItemText, { children })
7343
- ]
7344
- })
7345
- );
7346
- });
7347
- SelectItem.displayName = SelectPrimitive.Item.displayName;
7348
- var SelectSeparator = React46.forwardRef((_a, ref) => {
7349
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
7350
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7351
- SelectPrimitive.Separator,
7352
- __spreadValues({
7353
- ref,
7354
- className: cn("-mx-1 my-1 h-px bg-muted", className)
7355
- }, props)
7356
- );
7357
- });
7358
- SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
7785
+ SelectContent.displayName = "SelectContent";
7786
+ var SelectGroup = React46.forwardRef(
7787
+ (_a, ref) => {
7788
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
7789
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", __spreadValues({ ref, role: "group", className }, props));
7790
+ }
7791
+ );
7792
+ SelectGroup.displayName = "SelectGroup";
7793
+ var SelectLabel = React46.forwardRef(
7794
+ (_a, ref) => {
7795
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
7796
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7797
+ "div",
7798
+ __spreadValues({
7799
+ ref,
7800
+ className: cn("px-2 py-1.5 text-sm font-semibold", className)
7801
+ }, props)
7802
+ );
7803
+ }
7804
+ );
7805
+ SelectLabel.displayName = "SelectLabel";
7806
+ var SelectItem = React46.forwardRef(
7807
+ (_a, ref) => {
7808
+ var _b = _a, {
7809
+ className,
7810
+ children,
7811
+ value,
7812
+ disabled = false,
7813
+ textValue,
7814
+ size,
7815
+ customSize,
7816
+ onClick,
7817
+ onMouseMove,
7818
+ onMouseDown
7819
+ } = _b, props = __objRest(_b, [
7820
+ "className",
7821
+ "children",
7822
+ "value",
7823
+ "disabled",
7824
+ "textValue",
7825
+ "size",
7826
+ "customSize",
7827
+ "onClick",
7828
+ "onMouseMove",
7829
+ "onMouseDown"
7830
+ ]);
7831
+ const context = useSelectContext("SelectItem");
7832
+ const {
7833
+ registerItem,
7834
+ unregisterItem,
7835
+ updateItemRef,
7836
+ setActiveValue,
7837
+ setValue,
7838
+ value: selectedValue,
7839
+ activeValue,
7840
+ size: contextSize,
7841
+ customSize: contextCustomSize
7842
+ } = context;
7843
+ const itemId = React46.useId();
7844
+ const localRef = React46.useRef(null);
7845
+ const resolvedSize = size != null ? size : contextSize;
7846
+ const resolvedCustomSize = customSize != null ? customSize : contextCustomSize;
7847
+ const sizeClasses = getFormSizeClasses(resolvedSize, resolvedCustomSize);
7848
+ const labelText = textValue != null ? textValue : getNodeText(children);
7849
+ const isSelected = selectedValue === value;
7850
+ const isActive = activeValue === value;
7851
+ React46.useEffect(() => {
7852
+ registerItem({
7853
+ id: itemId,
7854
+ value,
7855
+ label: children,
7856
+ textValue: labelText,
7857
+ disabled,
7858
+ ref: localRef.current
7859
+ });
7860
+ return () => {
7861
+ unregisterItem(value, itemId);
7862
+ };
7863
+ }, [
7864
+ registerItem,
7865
+ unregisterItem,
7866
+ itemId,
7867
+ value,
7868
+ children,
7869
+ labelText,
7870
+ disabled
7871
+ ]);
7872
+ const handleItemRef = React46.useCallback(
7873
+ (node) => {
7874
+ localRef.current = node;
7875
+ updateItemRef(value, itemId, node);
7876
+ },
7877
+ [updateItemRef, value, itemId]
7878
+ );
7879
+ const setRefs = React46.useMemo(
7880
+ () => composeRefs(ref, handleItemRef),
7881
+ [ref, handleItemRef]
7882
+ );
7883
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
7884
+ "div",
7885
+ __spreadProps(__spreadValues({
7886
+ ref: setRefs,
7887
+ id: itemId,
7888
+ role: "option",
7889
+ "aria-selected": isSelected,
7890
+ "aria-disabled": disabled,
7891
+ "data-highlighted": isActive ? "" : void 0,
7892
+ "data-disabled": disabled ? "" : void 0,
7893
+ className: cn(
7894
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 outline-none transition-colors",
7895
+ sizeClasses.selectItem,
7896
+ !disabled && "data-highlighted:bg-accent data-highlighted:text-accent-foreground",
7897
+ disabled && "pointer-events-none opacity-50",
7898
+ className
7899
+ ),
7900
+ onMouseDown: (event) => {
7901
+ event.preventDefault();
7902
+ onMouseDown == null ? void 0 : onMouseDown(event);
7903
+ },
7904
+ onMouseMove: (event) => {
7905
+ onMouseMove == null ? void 0 : onMouseMove(event);
7906
+ if (!disabled) {
7907
+ setActiveValue(value);
7908
+ }
7909
+ },
7910
+ onClick: (event) => {
7911
+ onClick == null ? void 0 : onClick(event);
7912
+ if (!event.defaultPrevented && !disabled) {
7913
+ setValue(value);
7914
+ }
7915
+ }
7916
+ }, props), {
7917
+ children: [
7918
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: isSelected ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_icons9.CheckIcon, { className: "h-4 w-4" }) : null }),
7919
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "truncate", children })
7920
+ ]
7921
+ })
7922
+ );
7923
+ }
7924
+ );
7925
+ SelectItem.displayName = "SelectItem";
7926
+ var SelectSeparator = React46.forwardRef(
7927
+ (_a, ref) => {
7928
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
7929
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7930
+ "div",
7931
+ __spreadValues({
7932
+ ref,
7933
+ role: "separator",
7934
+ className: cn("-mx-1 my-1 h-px bg-muted", className)
7935
+ }, props)
7936
+ );
7937
+ }
7938
+ );
7939
+ SelectSeparator.displayName = "SelectSeparator";
7359
7940
 
7360
7941
  // src/components/searchable-select.tsx
7361
7942
  var React47 = __toESM(require("react"), 1);
@@ -7397,6 +7978,11 @@ function SearchableSelectBase({
7397
7978
  disabled,
7398
7979
  name,
7399
7980
  required,
7981
+ invalid = false,
7982
+ size = "md",
7983
+ customSize,
7984
+ variant = "outline",
7985
+ classNameDefault = true,
7400
7986
  triggerClassName,
7401
7987
  contentClassName,
7402
7988
  itemClassName,
@@ -7405,6 +7991,8 @@ function SearchableSelectBase({
7405
7991
  const rootRef = React47.useRef(null);
7406
7992
  const inputRef = React47.useRef(null);
7407
7993
  const listboxId = React47.useId();
7994
+ const sizeClasses = getFormSizeClasses(size, customSize);
7995
+ const triggerSizeClass = getFormControlSizeClass(variant, sizeClasses);
7408
7996
  const isControlled = value !== void 0;
7409
7997
  const [internalValue, setInternalValue] = React47.useState(defaultValue != null ? defaultValue : "");
7410
7998
  const currentValue = isControlled ? value != null ? value : "" : internalValue;
@@ -7483,12 +8071,14 @@ function SearchableSelectBase({
7483
8071
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
7484
8072
  "div",
7485
8073
  {
7486
- className: cn(
7487
- "relative flex h-9 w-full items-center gap-2 rounded-md border border-input bg-background px-3 text-sm shadow-sm transition",
7488
- "focus-within:border-primary/60 focus-within:ring-2 focus-within:ring-primary/20",
8074
+ className: classNameDefault ? cn(
8075
+ formCompositeControlBase,
8076
+ formCompositeVariants[variant],
8077
+ triggerSizeClass,
8078
+ invalid && formCompositeControlErrorClass,
7489
8079
  disabled && "cursor-not-allowed opacity-50",
7490
8080
  triggerClassName
7491
- ),
8081
+ ) : triggerClassName,
7492
8082
  onPointerDown: () => {
7493
8083
  if (disabled) return;
7494
8084
  setOpen(true);
@@ -7507,6 +8097,7 @@ function SearchableSelectBase({
7507
8097
  "aria-autocomplete": "list",
7508
8098
  "aria-expanded": open,
7509
8099
  "aria-controls": listboxId,
8100
+ "aria-invalid": invalid || void 0,
7510
8101
  "aria-activedescendant": activeIndex >= 0 ? `${listboxId}-option-${activeIndex}` : void 0,
7511
8102
  placeholder: open ? searchPlaceholder : placeholder,
7512
8103
  autoComplete: "off",
@@ -7558,7 +8149,7 @@ function SearchableSelectBase({
7558
8149
  }
7559
8150
  },
7560
8151
  className: cn(
7561
- "h-full min-w-0 flex-1 border-0 bg-transparent p-0 text-sm outline-none",
8152
+ "h-full min-w-0 flex-1 border-0 bg-transparent p-0 outline-none",
7562
8153
  "placeholder:text-muted-foreground disabled:cursor-not-allowed",
7563
8154
  searchInputClassName
7564
8155
  )
@@ -7621,7 +8212,16 @@ function SearchableSelectBase({
7621
8212
  onTouchMoveCapture: (event) => {
7622
8213
  event.stopPropagation();
7623
8214
  },
7624
- children: filteredItems.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "px-3 py-6 text-center text-sm text-muted-foreground", children: emptyText }) : filteredItems.map((item, index) => {
8215
+ children: filteredItems.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
8216
+ "div",
8217
+ {
8218
+ className: cn(
8219
+ "px-3 py-6 text-center text-muted-foreground",
8220
+ sizeClasses.message
8221
+ ),
8222
+ children: emptyText
8223
+ }
8224
+ ) : filteredItems.map((item, index) => {
7625
8225
  const isSelected = item.value === currentValue;
7626
8226
  const isActive = index === activeIndex;
7627
8227
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
@@ -7645,7 +8245,8 @@ function SearchableSelectBase({
7645
8245
  }
7646
8246
  },
7647
8247
  className: cn(
7648
- "relative flex w-full select-none items-center gap-2 rounded-lg px-3 py-2 text-left text-sm outline-none transition",
8248
+ "relative flex w-full select-none items-center gap-2 rounded-lg px-3 text-left outline-none transition",
8249
+ sizeClasses.selectItem,
7649
8250
  item.disabled ? "pointer-events-none opacity-50" : "cursor-pointer",
7650
8251
  isActive && !item.disabled && "bg-accent text-accent-foreground",
7651
8252
  !isActive && !item.disabled && "hover:bg-accent/70 hover:text-accent-foreground",
@@ -7711,13 +8312,13 @@ var FormSelect = ({
7711
8312
  searchable = false,
7712
8313
  searchPlaceholder = "Buscar\u2026",
7713
8314
  emptyText = "No hay resultados",
7714
- position = "popper"
8315
+ classNameDefault = true,
8316
+ position
7715
8317
  }) => {
7716
8318
  const form = (0, import_react_hook_form5.useFormContext)();
7717
8319
  const controllerControl = control != null ? control : form == null ? void 0 : form.control;
7718
8320
  const sizeClasses = getFormSizeClasses(size, customSize);
7719
- const triggerBase = "relative inline-flex w-full items-center justify-between gap-2 text-foreground outline-none ring-offset-background transition placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50";
7720
- const triggerSizeClass = variant === "flushed" ? sizeClasses.flushedControl : variant === "link" ? sizeClasses.linkControl : sizeClasses.control;
8321
+ const triggerSizeClass = getFormControlSizeClass(variant, sizeClasses);
7721
8322
  const contentBase = "z-50 rounded-xl border border-border bg-popover text-popover-foreground shadow-xl outline-none";
7722
8323
  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]";
7723
8324
  const normalizedOptions = React48.useMemo(() => {
@@ -7794,21 +8395,15 @@ var FormSelect = ({
7794
8395
  searchPlaceholder,
7795
8396
  emptyText,
7796
8397
  disabled,
7797
- triggerClassName: cn(
7798
- "min-h-10 w-full rounded-xl border border-input bg-input px-3 text-sm shadow-sm",
7799
- "focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20",
7800
- hasError && "border-destructive ring-destructive/20",
7801
- className
7802
- ),
7803
- contentClassName: cn(
7804
- "z-50 mt-1 max-h-72 w-full overflow-hidden rounded-xl border border-border bg-popover shadow-xl",
7805
- contentClassName
7806
- ),
7807
- itemClassName: cn(sizeClasses.selectItem, itemClassName),
7808
- searchInputClassName: cn(
7809
- "h-full w-full min-w-0 bg-transparent outline-none placeholder:text-muted-foreground",
7810
- searchInputClassName
7811
- ),
8398
+ invalid: hasError,
8399
+ size,
8400
+ customSize,
8401
+ variant,
8402
+ classNameDefault,
8403
+ triggerClassName: className,
8404
+ contentClassName,
8405
+ itemClassName,
8406
+ searchInputClassName,
7812
8407
  onValueChange: (value, option) => {
7813
8408
  var _a2;
7814
8409
  field.onChange(value);
@@ -7832,13 +8427,13 @@ var FormSelect = ({
7832
8427
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(FormControl, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
7833
8428
  SelectTrigger,
7834
8429
  {
7835
- className: cn(
7836
- triggerBase,
7837
- variants[variant],
8430
+ className: classNameDefault ? cn(
8431
+ formControlBase,
8432
+ formInputVariants[variant],
7838
8433
  triggerSizeClass,
7839
- hasError && "border-destructive ring-destructive focus:ring-destructive/40",
8434
+ hasError && formControlErrorClass,
7840
8435
  className
7841
- ),
8436
+ ) : className,
7842
8437
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SelectValue, { placeholder })
7843
8438
  }
7844
8439
  ) }),
@@ -8790,7 +9385,7 @@ SearchInput.displayName = "SearchInput";
8790
9385
  var SeparatorPrimitive = __toESM(require("@radix-ui/react-separator"), 1);
8791
9386
  var React59 = __toESM(require("react"), 1);
8792
9387
  var import_jsx_runtime39 = require("react/jsx-runtime");
8793
- var Separator6 = React59.forwardRef(
9388
+ var Separator5 = React59.forwardRef(
8794
9389
  (_a, ref) => {
8795
9390
  var _b = _a, { className, orientation = "horizontal", decorative = true } = _b, props = __objRest(_b, ["className", "orientation", "decorative"]);
8796
9391
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
@@ -8808,7 +9403,7 @@ var Separator6 = React59.forwardRef(
8808
9403
  );
8809
9404
  }
8810
9405
  );
8811
- Separator6.displayName = SeparatorPrimitive.Root.displayName;
9406
+ Separator5.displayName = SeparatorPrimitive.Root.displayName;
8812
9407
 
8813
9408
  // src/components/sheet.tsx
8814
9409
  var SheetPrimitive = __toESM(require("@radix-ui/react-dialog"), 1);
@@ -9609,20 +10204,6 @@ UiInput.displayName = "UiInput";
9609
10204
  // src/components/ui/select.tsx
9610
10205
  var React72 = __toESM(require("react"), 1);
9611
10206
  var import_lucide_react9 = require("lucide-react");
9612
-
9613
- // src/types/select.ts
9614
- var selectVariants = {
9615
- outline: "rounded-md border border-input bg-input backdrop-blur-sm shadow-sm hover:border-primary/60 focus:border-primary focus:ring-2 focus:ring-primary/20",
9616
- soft: "rounded-md border border-transparent bg-muted/60 shadow-sm hover:bg-muted focus:bg-input/80 focus:ring-2 focus:ring-primary/20",
9617
- ghost: "rounded-md border border-transparent bg-transparent hover:bg-muted/50 focus:ring-2 focus:ring-ring",
9618
- filled: "rounded-md border border-input bg-muted/70 shadow-inner hover:bg-muted focus:bg-input/70 focus:ring-2 focus:ring-primary/20",
9619
- flushed: "rounded-none border-0 border-b border-input px-0 shadow-none focus:border-b-2 focus:border-primary focus:ring-0",
9620
- unstyled: "border-0 shadow-none focus:ring-0",
9621
- link: "h-auto border-0 bg-transparent p-0 text-primary shadow-none underline-offset-4 focus:underline focus:ring-0"
9622
- };
9623
- var variants2 = selectVariants;
9624
-
9625
- // src/components/ui/select.tsx
9626
10207
  var import_jsx_runtime54 = require("react/jsx-runtime");
9627
10208
  function UiSelect({
9628
10209
  label,
@@ -9642,33 +10223,28 @@ function UiSelect({
9642
10223
  messageClassName,
9643
10224
  requiredLabelClassName,
9644
10225
  size = "md",
10226
+ customSize,
9645
10227
  variant = "outline",
10228
+ classNameDefault = true,
9646
10229
  errorMessage,
9647
- htmlFormItemId
10230
+ htmlFormItemId,
10231
+ position
9648
10232
  }) {
9649
10233
  const generatedId = React72.useId();
9650
10234
  const triggerId = htmlFormItemId != null ? htmlFormItemId : generatedId;
9651
10235
  const messageId = `${triggerId}-message`;
9652
10236
  const hasError = Boolean(errorMessage);
9653
- const triggerBase = "relative inline-flex w-full items-center justify-between text-foreground outline-none ring-offset-background transition placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50";
9654
- const sizeTrigger = {
9655
- sm: "h-9 px-3 text-sm",
9656
- md: "h-10 px-3.5 text-sm",
9657
- lg: "h-11 px-4 text-base"
9658
- };
9659
- const itemSize = {
9660
- sm: "h-8 text-sm",
9661
- md: "h-9 text-sm",
9662
- lg: "h-10 text-base"
9663
- };
9664
- const specialFlushed = variant === "flushed" ? size === "sm" ? "h-9 text-sm" : size === "lg" ? "h-11 text-base" : "h-10 text-sm" : "";
9665
- const specialLink = variant === "link" ? "text-sm" : "";
9666
- return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: cn("w-full space-y-1.5", selectClassName), children: [
10237
+ const sizeClasses = getFormSizeClasses(size, customSize);
10238
+ const triggerSizeClass = getFormControlSizeClass(variant, sizeClasses);
10239
+ const contentBase = "z-50 rounded-xl border border-border bg-popover text-popover-foreground shadow-xl outline-none";
10240
+ 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]";
10241
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: cn("w-full space-y-2", selectClassName), children: [
9667
10242
  label ? /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
9668
10243
  Label3,
9669
10244
  {
9670
10245
  className: cn(
9671
- "inline-flex items-start gap-0.5 text-sm font-medium",
10246
+ "inline-flex items-start gap-0.5 font-medium",
10247
+ sizeClasses.label,
9672
10248
  hasError && "text-destructive",
9673
10249
  labelClassName
9674
10250
  ),
@@ -9680,7 +10256,7 @@ function UiSelect({
9680
10256
  {
9681
10257
  "aria-hidden": "true",
9682
10258
  className: cn(
9683
- "mt-0.5 h-3 w-3 shrink-0 text-red-500",
10259
+ "h-3 w-3 shrink-0 text-red-500",
9684
10260
  requiredLabelClassName
9685
10261
  )
9686
10262
  }
@@ -9702,26 +10278,45 @@ function UiSelect({
9702
10278
  id: triggerId,
9703
10279
  "aria-invalid": hasError || void 0,
9704
10280
  "aria-describedby": errorMessage ? messageId : void 0,
9705
- className: cn(
9706
- triggerBase,
9707
- variants2[variant],
9708
- variant === "flushed" ? specialFlushed : variant === "link" ? specialLink : sizeTrigger[size],
9709
- hasError && "border-destructive ring-destructive focus:ring-destructive/40",
10281
+ className: classNameDefault ? cn(
10282
+ formControlBase,
10283
+ formInputVariants[variant],
10284
+ triggerSizeClass,
10285
+ hasError && formControlErrorClass,
9710
10286
  className
9711
- ),
10287
+ ) : className,
9712
10288
  children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(SelectValue, { placeholder })
9713
10289
  }
9714
10290
  ),
9715
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(SelectContent, { className: contentClassName, children: children != null ? children : items == null ? void 0 : items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
9716
- SelectItem,
10291
+ /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
10292
+ SelectContent,
9717
10293
  {
9718
- value: item.value,
9719
- disabled: item.disabled,
9720
- className: cn(itemSize[size], itemClassName),
9721
- children: item.label
9722
- },
9723
- item.value
9724
- )) })
10294
+ position,
10295
+ sideOffset: 6,
10296
+ className: cn(
10297
+ contentBase,
10298
+ contentViewport,
10299
+ "w-(--radix-select-trigger-width) min-w-(--radix-select-trigger-width) overflow-hidden!",
10300
+ contentClassName
10301
+ ),
10302
+ onWheelCapture: (event) => {
10303
+ event.stopPropagation();
10304
+ },
10305
+ onTouchMoveCapture: (event) => {
10306
+ event.stopPropagation();
10307
+ },
10308
+ children: children != null ? children : items == null ? void 0 : items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
10309
+ SelectItem,
10310
+ {
10311
+ value: item.value,
10312
+ disabled: item.disabled,
10313
+ className: cn(sizeClasses.selectItem, itemClassName),
10314
+ children: item.label
10315
+ },
10316
+ item.value
10317
+ ))
10318
+ }
10319
+ )
9725
10320
  ]
9726
10321
  }
9727
10322
  ),
@@ -9729,7 +10324,11 @@ function UiSelect({
9729
10324
  "p",
9730
10325
  {
9731
10326
  id: messageId,
9732
- className: cn("text-sm font-medium text-destructive", messageClassName),
10327
+ className: cn(
10328
+ "font-medium text-destructive",
10329
+ sizeClasses.message,
10330
+ messageClassName
10331
+ ),
9733
10332
  children: errorMessage
9734
10333
  }
9735
10334
  ) : null
@@ -10330,7 +10929,7 @@ function DataTable({
10330
10929
  children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(SelectValue, { placeholder: `${pageSize}` })
10331
10930
  }
10332
10931
  ),
10333
- /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(SelectContent, { side: "top", children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(SelectItem, { value: `${size}`, children: size }, size)) })
10932
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(SelectContent, { children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(SelectItem, { value: `${size}`, children: size }, size)) })
10334
10933
  ]
10335
10934
  }
10336
10935
  )
@@ -10855,8 +11454,6 @@ function PaginationSection({
10855
11454
  SelectGroup,
10856
11455
  SelectItem,
10857
11456
  SelectLabel,
10858
- SelectScrollDownButton,
10859
- SelectScrollUpButton,
10860
11457
  SelectSeparator,
10861
11458
  SelectTrigger,
10862
11459
  SelectValue,
@@ -10911,9 +11508,18 @@ function PaginationSection({
10911
11508
  badgeVariants,
10912
11509
  buttonVariants,
10913
11510
  cn,
11511
+ formCompositeControlBase,
11512
+ formCompositeControlErrorClass,
11513
+ formCompositeVariants,
11514
+ formControlBase,
11515
+ formControlErrorClass,
11516
+ formInputVariants,
11517
+ formSizeVariants,
10914
11518
  getDefaultOptionLabel,
10915
11519
  getDefaultOptionValue,
10916
11520
  getErrorMessage,
11521
+ getFormControlSizeClass,
11522
+ getFormSizeClasses,
10917
11523
  getNextEnabledIndex,
10918
11524
  iconButtonVariants,
10919
11525
  navigationMenuTriggerStyle,
@@ -10923,5 +11529,6 @@ function PaginationSection({
10923
11529
  toggleVariants,
10924
11530
  useFormField,
10925
11531
  useSidebar,
10926
- useToast
11532
+ useToast,
11533
+ variants
10927
11534
  });