@gridui/select 1.0.0 → 1.0.3

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.js CHANGED
@@ -1,21 +1,23 @@
1
1
  // src/shared/style.ts
2
- import { dropdownContentStyles, dropdownItemStyles } from "@gridui/dropdown-menu";
2
+ import { dropdownItemStyles } from "@gridui/dropdown-menu";
3
+ import { overlaySurfaceStyles } from "@gridui/overlay";
3
4
  import { cn } from "@gridui/style-utils";
4
5
  import { cva } from "class-variance-authority";
5
- var selectItemStyles = cva(cn(dropdownItemStyles(), "min-w-0"));
6
- var selectIconStyles = cva("inline-flex shrink-0 items-center [&_svg]:size-gridui-16");
7
- var selectOptionContentStyles = cva("min-w-0 flex-1 whitespace-normal wrap-anywhere");
8
- var selectOptionDescriptionStyles = cva("block text-muted type-caption mt-gridui-4");
9
- var selectListStyles = cva("min-h-0 overflow-y-auto");
10
- var selectEmptyStyles = cva("p-gridui-8 text-muted type-caption");
11
- var selectActionsStyles = cva("shrink-0 border-t border-border pt-gridui-4");
6
+ var selectItemStyles = cva(cn(dropdownItemStyles(), "gridui-u-min-w-0"));
7
+ var selectIconStyles = cva("gridui-u-inline-flex gridui-u-shrink-0 gridui-u-items-center gridui-u-[&_svg]:size-gridui-16");
8
+ var selectOptionContentStyles = cva("gridui-u-min-w-0 gridui-u-flex-1 gridui-u-whitespace-normal gridui-u-wrap-anywhere");
9
+ var selectOptionDescriptionStyles = cva("gridui-u-block gridui-u-text-muted gridui-u-type-caption gridui-u-mt-gridui-4");
10
+ var selectListStyles = cva("gridui-u-min-h-0 gridui-u-overflow-y-auto");
11
+ var selectEmptyStyles = cva("gridui-u-p-gridui-8 gridui-u-text-muted gridui-u-type-caption");
12
+ var selectActionsStyles = cva("gridui-u-shrink-0 gridui-u-border-t gridui-u-border-border gridui-u-pt-gridui-4");
12
13
  var selectActionStyles = cva(cn(
13
14
  selectItemStyles(),
14
- "w-full text-start whitespace-normal wrap-anywhere hover:bg-surface focus-visible:bg-surface"
15
+ "gridui-u-w-full gridui-u-text-start gridui-u-whitespace-normal gridui-u-wrap-anywhere gridui-u-hover:bg-surface gridui-u-focus-visible:bg-surface"
15
16
  ));
16
17
  var comboboxContentStyles = cva(cn(
17
- dropdownContentStyles(),
18
- "gridui-combobox-content box-border flex flex-col overflow-hidden min-w-0 w-(--anchor-width) max-h-(--available-height) max-w-(--available-width)"
18
+ overlaySurfaceStyles(),
19
+ "gridui-u-z-(--gridui-z-popover) gridui-u-p-gridui-4 gridui-u-type-data",
20
+ "gridui-combobox-content gridui-u-box-border gridui-u-flex gridui-u-flex-col gridui-u-overflow-hidden gridui-u-min-w-0 gridui-u-w-(--anchor-width) gridui-u-max-h-(--available-height) gridui-u-max-w-(--available-width)"
19
21
  ));
20
22
 
21
23
  // src/shared/combobox-options.tsx
@@ -199,7 +201,8 @@ var SelectionActions = (props) => {
199
201
  };
200
202
 
201
203
  // src/shared/selection-form.tsx
202
- import { useEffect, useLayoutEffect, useRef } from "react";
204
+ import { focusInvalidControl, useFormReset } from "@gridui/form";
205
+ import { useLayoutEffect, useRef } from "react";
203
206
  import { flushSync } from "react-dom";
204
207
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
205
208
  var SelectionForm = (props) => {
@@ -224,34 +227,21 @@ var SelectionForm = (props) => {
224
227
  onReset,
225
228
  selectedValue
226
229
  ]);
227
- useEffect(() => {
228
- const owner = nativeRef.current?.form;
229
- let mounted = true;
230
- const reset = (event) => {
231
- setTimeout(() => {
232
- if (mounted && !event.defaultPrevented) {
233
- flushSync(() => {
234
- resetSelection.current();
235
- });
236
- if (nativeRef.current) {
237
- nativeRef.current.value = currentValue.current;
238
- }
239
- }
240
- }, 0);
241
- };
242
- owner?.addEventListener("reset", reset);
243
- return () => {
244
- mounted = false;
245
- owner?.removeEventListener("reset", reset);
246
- };
247
- }, [form]);
230
+ useFormReset(nativeRef, () => {
231
+ flushSync(() => {
232
+ resetSelection.current();
233
+ });
234
+ if (nativeRef.current) {
235
+ nativeRef.current.value = currentValue.current;
236
+ }
237
+ }, form);
248
238
  return /* @__PURE__ */ jsxs3(
249
239
  "select",
250
240
  {
251
241
  ref: nativeRef,
252
242
  "aria-hidden": "true",
253
243
  tabIndex: -1,
254
- className: "sr-only",
244
+ className: "gridui-u-sr-only",
255
245
  name,
256
246
  form,
257
247
  required,
@@ -261,8 +251,7 @@ var SelectionForm = (props) => {
261
251
  onValueChange(event.currentTarget.value);
262
252
  },
263
253
  onInvalid: (event) => {
264
- event.preventDefault();
265
- onInvalid();
254
+ focusInvalidControl(event, onInvalid);
266
255
  },
267
256
  children: [
268
257
  !allOptions.some((option) => {
@@ -298,6 +287,59 @@ var SelectionForm = (props) => {
298
287
  );
299
288
  };
300
289
 
290
+ // src/shared/selection-popup.tsx
291
+ import * as Primitive from "@radix-ui/react-popover";
292
+ import { jsx as jsx4 } from "react/jsx-runtime";
293
+ var SelectionPopup = (props) => {
294
+ const { container, anchorRef, initialFocus, finalFocus, onEscape, onDismiss, ...restProps } = props;
295
+ return /* @__PURE__ */ jsx4(
296
+ Primitive.Portal,
297
+ {
298
+ container,
299
+ children: /* @__PURE__ */ jsx4(
300
+ Primitive.Content,
301
+ {
302
+ ...restProps,
303
+ sideOffset: 8,
304
+ align: "start",
305
+ collisionPadding: 16,
306
+ className: comboboxContentStyles(),
307
+ onOpenAutoFocus: (event) => {
308
+ event.preventDefault();
309
+ initialFocus?.();
310
+ },
311
+ onCloseAutoFocus: (event) => {
312
+ event.preventDefault();
313
+ const target = finalFocus();
314
+ if (target) {
315
+ target.focus();
316
+ }
317
+ },
318
+ onInteractOutside: (event) => {
319
+ if (anchorRef?.current?.contains(event.target)) {
320
+ event.preventDefault();
321
+ } else {
322
+ onDismiss?.();
323
+ }
324
+ },
325
+ onEscapeKeyDown: (event) => {
326
+ event.preventDefault();
327
+ event.stopPropagation();
328
+ if (!event.isComposing) {
329
+ onEscape();
330
+ }
331
+ },
332
+ onKeyDown: (event) => {
333
+ if (event.key === "Escape") {
334
+ event.stopPropagation();
335
+ }
336
+ }
337
+ }
338
+ )
339
+ }
340
+ );
341
+ };
342
+
301
343
  // src/shared/options.ts
302
344
  var flattenOptions = (options) => {
303
345
  return options.flatMap((entry) => {
@@ -343,7 +385,7 @@ var scrollOption = (id) => {
343
385
  };
344
386
 
345
387
  // src/shared/use-search-options.ts
346
- import { useEffect as useEffect2, useState } from "react";
388
+ import { useEffect, useState } from "react";
347
389
  var INITIAL_SEARCH = {
348
390
  query: null,
349
391
  highlighted: null
@@ -371,12 +413,12 @@ var useSearchOptions = (options, selected, listId, open) => {
371
413
  })}`;
372
414
  };
373
415
  const activeOptionId = active ? optionId(active.value) : void 0;
374
- useEffect2(() => {
416
+ useEffect(() => {
375
417
  if (!open) {
376
418
  setSearch(INITIAL_SEARCH);
377
419
  }
378
420
  }, [open]);
379
- useEffect2(() => {
421
+ useEffect(() => {
380
422
  if (open && activeOptionId !== void 0) {
381
423
  scrollOption(activeOptionId);
382
424
  }
@@ -421,7 +463,7 @@ var useSearchOptions = (options, selected, listId, open) => {
421
463
  };
422
464
 
423
465
  // src/shared/use-selection-popup.ts
424
- import { useEffect as useEffect3, useRef as useRef2, useState as useState2 } from "react";
466
+ import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
425
467
  import { flushSync as flushSync2 } from "react-dom";
426
468
  var useSelectionPopup = ({ disabled, readOnly, controlRef }) => {
427
469
  const [
@@ -431,7 +473,7 @@ var useSelectionPopup = ({ disabled, readOnly, controlRef }) => {
431
473
  const popupRef = useRef2(null);
432
474
  const restoreFocus = useRef2(true);
433
475
  const unavailable = Boolean(disabled || readOnly);
434
- useEffect3(() => {
476
+ useEffect2(() => {
435
477
  if (unavailable) {
436
478
  setLocalOpen(false);
437
479
  }
@@ -523,16 +565,16 @@ var useSelectionValue = (props, available) => {
523
565
 
524
566
  // src/combobox/style.ts
525
567
  import { cva as cva2 } from "class-variance-authority";
526
- var comboboxInputStyles = cva2("pr-11 text-ellipsis");
527
- var comboboxTriggerStyles = cva2("absolute inset-y-0 right-0 flex w-9 items-center justify-center rounded-control text-foreground cursor-pointer disabled:cursor-not-allowed disabled:opacity-50");
568
+ var comboboxInputStyles = cva2("gridui-u-pr-11 gridui-u-text-ellipsis");
569
+ var comboboxTriggerStyles = cva2("gridui-u-absolute gridui-u-inset-y-0 gridui-u-right-0 gridui-u-flex gridui-u-w-9 gridui-u-items-center gridui-u-justify-center gridui-u-rounded-control gridui-u-text-foreground gridui-u-cursor-pointer gridui-u-disabled:cursor-not-allowed gridui-u-disabled:opacity-50");
528
570
 
529
571
  // src/combobox/combobox.tsx
530
572
  import { controlVariants } from "@gridui/input";
531
573
  import { cn as cn2 } from "@gridui/style-utils";
532
- import * as Primitive from "@radix-ui/react-popover";
574
+ import * as Primitive2 from "@radix-ui/react-popover";
533
575
  import { ChevronDown, X } from "lucide-react";
534
576
  import { useId, useRef as useRef4 } from "react";
535
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
577
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
536
578
  var Combobox = (props) => {
537
579
  const {
538
580
  options,
@@ -559,6 +601,7 @@ var Combobox = (props) => {
559
601
  ...restProps
560
602
  } = props;
561
603
  const controlRef = useRef4(null);
604
+ const anchorRef = useRef4(null);
562
605
  const { open, popupRef, available, changeOpen, close, focus, runAction, finalFocus } = useSelectionPopup({
563
606
  disabled,
564
607
  readOnly,
@@ -589,7 +632,7 @@ var Combobox = (props) => {
589
632
  focus();
590
633
  };
591
634
  return /* @__PURE__ */ jsxs4(
592
- Primitive.Root,
635
+ Primitive2.Root,
593
636
  {
594
637
  open,
595
638
  onOpenChange: changeOpen,
@@ -597,19 +640,20 @@ var Combobox = (props) => {
597
640
  /* @__PURE__ */ jsxs4(
598
641
  "div",
599
642
  {
600
- className: "relative flex min-w-0 w-full items-stretch gap-gridui-4",
643
+ className: "gridui-u-relative gridui-u-flex gridui-u-min-w-0 gridui-u-w-full gridui-u-items-stretch gridui-u-gap-gridui-4",
601
644
  dir,
602
645
  children: [
603
- /* @__PURE__ */ jsx4(
604
- Primitive.Anchor,
646
+ /* @__PURE__ */ jsx5(
647
+ Primitive2.Anchor,
605
648
  {
606
649
  asChild: true,
607
650
  children: /* @__PURE__ */ jsxs4(
608
651
  "div",
609
652
  {
610
- className: "relative flex min-w-0 flex-1 items-stretch",
653
+ ref: anchorRef,
654
+ className: "gridui-u-relative gridui-u-flex gridui-u-min-w-0 gridui-u-flex-1 gridui-u-items-stretch",
611
655
  children: [
612
- /* @__PURE__ */ jsx4(
656
+ /* @__PURE__ */ jsx5(
613
657
  "input",
614
658
  {
615
659
  ...restProps,
@@ -694,7 +738,7 @@ var Combobox = (props) => {
694
738
  }
695
739
  }
696
740
  ),
697
- /* @__PURE__ */ jsx4(
741
+ /* @__PURE__ */ jsx5(
698
742
  "button",
699
743
  {
700
744
  type: "button",
@@ -709,7 +753,7 @@ var Combobox = (props) => {
709
753
  }
710
754
  focus();
711
755
  },
712
- children: /* @__PURE__ */ jsx4(
756
+ children: /* @__PURE__ */ jsx5(
713
757
  ChevronDown,
714
758
  {
715
759
  size: 16,
@@ -723,7 +767,7 @@ var Combobox = (props) => {
723
767
  )
724
768
  }
725
769
  ),
726
- clearLabel && /* @__PURE__ */ jsx4(
770
+ clearLabel && /* @__PURE__ */ jsx5(
727
771
  "button",
728
772
  {
729
773
  type: "button",
@@ -734,8 +778,8 @@ var Combobox = (props) => {
734
778
  close();
735
779
  focus();
736
780
  },
737
- className: cn2(controlVariants({ size: controlSize }), "flex w-auto shrink-0 items-center justify-center min-w-11 cursor-pointer hover:enabled:bg-surface"),
738
- children: /* @__PURE__ */ jsx4(
781
+ className: cn2(controlVariants({ size: controlSize }), "gridui-u-flex gridui-u-w-auto gridui-u-shrink-0 gridui-u-items-center gridui-u-justify-center gridui-u-min-w-11 gridui-u-cursor-pointer gridui-u-hover:enabled:bg-surface"),
782
+ children: /* @__PURE__ */ jsx5(
739
783
  X,
740
784
  {
741
785
  size: 16,
@@ -744,7 +788,7 @@ var Combobox = (props) => {
744
788
  )
745
789
  }
746
790
  ),
747
- /* @__PURE__ */ jsx4(
791
+ /* @__PURE__ */ jsx5(
748
792
  SelectionForm,
749
793
  {
750
794
  name,
@@ -764,82 +808,50 @@ var Combobox = (props) => {
764
808
  ]
765
809
  }
766
810
  ),
767
- /* @__PURE__ */ jsx4(
768
- Primitive.Portal,
811
+ /* @__PURE__ */ jsxs4(
812
+ SelectionPopup,
769
813
  {
770
814
  container: portalContainer,
771
- children: /* @__PURE__ */ jsxs4(
772
- Primitive.Content,
773
- {
774
- ref: popupRef,
775
- role: "presentation",
776
- sideOffset: 8,
777
- align: "start",
778
- collisionPadding: 16,
779
- className: comboboxContentStyles(),
780
- dir,
781
- onOpenAutoFocus: (event) => {
782
- event.preventDefault();
783
- },
784
- onCloseAutoFocus: (event) => {
785
- event.preventDefault();
786
- const target = finalFocus();
787
- if (target) {
788
- target.focus();
789
- }
790
- },
791
- onInteractOutside: (event) => {
792
- if (controlRef.current?.parentElement?.contains(event.target)) {
793
- event.preventDefault();
794
- } else {
795
- close();
796
- }
797
- },
798
- onEscapeKeyDown: (event) => {
799
- event.preventDefault();
800
- event.stopPropagation();
801
- if (!event.isComposing) {
802
- close();
803
- focus();
804
- }
805
- },
806
- onKeyDown: (event) => {
807
- if (event.key === "Escape") {
808
- event.stopPropagation();
809
- }
810
- },
811
- children: [
812
- visible.length === 0 && /* @__PURE__ */ jsx4(
813
- "div",
814
- {
815
- role: "status",
816
- className: selectEmptyStyles(),
817
- children: emptyLabel
818
- }
819
- ),
820
- /* @__PURE__ */ jsx4(
821
- ComboboxOptions,
822
- {
823
- id: listId,
824
- label: searchLabel,
825
- options: filtered,
826
- selected: selectedValue,
827
- active,
828
- optionId,
829
- onSelect: choose,
830
- onHighlight: search.highlight
831
- }
832
- ),
833
- /* @__PURE__ */ jsx4(
834
- SelectionActions,
835
- {
836
- actions,
837
- onAction: runAction
838
- }
839
- )
840
- ]
841
- }
842
- )
815
+ ref: popupRef,
816
+ role: "presentation",
817
+ dir,
818
+ finalFocus,
819
+ anchorRef,
820
+ onDismiss: close,
821
+ onEscape: () => {
822
+ close();
823
+ focus();
824
+ },
825
+ children: [
826
+ visible.length === 0 && /* @__PURE__ */ jsx5(
827
+ "div",
828
+ {
829
+ role: "status",
830
+ className: selectEmptyStyles(),
831
+ children: emptyLabel
832
+ }
833
+ ),
834
+ /* @__PURE__ */ jsx5(
835
+ ComboboxOptions,
836
+ {
837
+ id: listId,
838
+ label: searchLabel,
839
+ options: filtered,
840
+ selected: selectedValue,
841
+ active,
842
+ optionId,
843
+ onSelect: choose,
844
+ onHighlight: search.highlight
845
+ }
846
+ ),
847
+ /* @__PURE__ */ jsx5(
848
+ SelectionActions,
849
+ {
850
+ actions,
851
+ onAction: runAction
852
+ }
853
+ )
854
+ ]
843
855
  }
844
856
  )
845
857
  ]
@@ -848,13 +860,13 @@ var Combobox = (props) => {
848
860
  };
849
861
 
850
862
  // src/multi-select/multi-select.tsx
851
- import { useListField } from "@gridui/form";
863
+ import { ListFieldControl, useListField } from "@gridui/form";
852
864
  import { controlVariants as controlVariants2 } from "@gridui/input";
853
865
  import { cn as cn3 } from "@gridui/style-utils";
854
- import * as Primitive2 from "@radix-ui/react-popover";
866
+ import * as Primitive3 from "@radix-ui/react-popover";
855
867
  import { ChevronDown as ChevronDown2, X as X2 } from "lucide-react";
856
868
  import { useId as useId2, useRef as useRef5 } from "react";
857
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
869
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
858
870
  var MultiSelect = (props) => {
859
871
  const {
860
872
  value,
@@ -908,7 +920,7 @@ var MultiSelect = (props) => {
908
920
  search.current?.focus({ preventScroll: true });
909
921
  };
910
922
  return /* @__PURE__ */ jsxs5(
911
- Primitive2.Root,
923
+ Primitive3.Root,
912
924
  {
913
925
  open,
914
926
  onOpenChange: changeOpen,
@@ -916,11 +928,11 @@ var MultiSelect = (props) => {
916
928
  /* @__PURE__ */ jsxs5(
917
929
  "div",
918
930
  {
919
- className: "flex min-w-0 items-stretch gap-gridui-4",
931
+ className: "gridui-u-flex gridui-u-min-w-0 gridui-u-items-stretch gridui-u-gap-gridui-4",
920
932
  dir: restProps.dir,
921
933
  children: [
922
- /* @__PURE__ */ jsx5(
923
- Primitive2.Trigger,
934
+ /* @__PURE__ */ jsx6(
935
+ Primitive3.Trigger,
924
936
  {
925
937
  asChild: true,
926
938
  children: /* @__PURE__ */ jsxs5(
@@ -941,7 +953,7 @@ var MultiSelect = (props) => {
941
953
  ref.current = element;
942
954
  }
943
955
  },
944
- className: cn3(controlVariants2(), "flex flex-1 items-center gap-gridui-8 text-start", className),
956
+ className: cn3(controlVariants2(), "gridui-u-flex gridui-u-flex-1 gridui-u-items-center gridui-u-gap-gridui-8 gridui-u-text-start", className),
945
957
  onKeyDown: (event) => {
946
958
  onKeyDown?.(event);
947
959
  if (!event.defaultPrevented && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
@@ -950,10 +962,10 @@ var MultiSelect = (props) => {
950
962
  }
951
963
  },
952
964
  children: [
953
- /* @__PURE__ */ jsx5(
965
+ /* @__PURE__ */ jsx6(
954
966
  "span",
955
967
  {
956
- className: "min-w-0 flex-1 wrap-anywhere",
968
+ className: "gridui-u-min-w-0 gridui-u-flex-1 gridui-u-wrap-anywhere",
957
969
  children: selected.length ? selected.map((entry) => {
958
970
  return all.find((option) => {
959
971
  return option.value === entry;
@@ -961,7 +973,7 @@ var MultiSelect = (props) => {
961
973
  }).join(", ") : placeholder
962
974
  }
963
975
  ),
964
- /* @__PURE__ */ jsx5(
976
+ /* @__PURE__ */ jsx6(
965
977
  ChevronDown2,
966
978
  {
967
979
  size: 16,
@@ -973,18 +985,18 @@ var MultiSelect = (props) => {
973
985
  )
974
986
  }
975
987
  ),
976
- clearLabel && /* @__PURE__ */ jsx5(
988
+ clearLabel && /* @__PURE__ */ jsx6(
977
989
  "button",
978
990
  {
979
991
  type: "button",
980
992
  "aria-label": clearLabel,
981
993
  disabled: disabled || readOnly || required || !selected.length,
982
- className: cn3(controlVariants2(), "flex w-auto shrink-0 items-center justify-center min-w-11 cursor-pointer hover:enabled:bg-surface"),
994
+ className: cn3(controlVariants2(), "gridui-u-flex gridui-u-w-auto gridui-u-shrink-0 gridui-u-items-center gridui-u-justify-center gridui-u-min-w-11 gridui-u-cursor-pointer gridui-u-hover:enabled:bg-surface"),
983
995
  onClick: () => {
984
996
  change([]);
985
997
  control.current?.focus();
986
998
  },
987
- children: /* @__PURE__ */ jsx5(
999
+ children: /* @__PURE__ */ jsx6(
988
1000
  X2,
989
1001
  {
990
1002
  size: 16,
@@ -994,30 +1006,21 @@ var MultiSelect = (props) => {
994
1006
  }
995
1007
  ),
996
1008
  /* @__PURE__ */ jsxs5(
997
- "select",
1009
+ ListFieldControl,
998
1010
  {
999
1011
  ref: native,
1000
- multiple: true,
1001
- className: "sr-only",
1002
- "aria-hidden": "true",
1003
- tabIndex: -1,
1004
1012
  name,
1005
1013
  form,
1006
1014
  required,
1007
1015
  disabled,
1008
1016
  value: selected,
1009
- onChange: (event) => {
1010
- change(Array.from(event.currentTarget.selectedOptions, (option) => {
1011
- return option.value;
1012
- }));
1013
- },
1014
- onInvalid: (event) => {
1015
- event.preventDefault();
1017
+ onValueChange: change,
1018
+ onInvalidFocus: () => {
1016
1019
  control.current?.focus();
1017
1020
  },
1018
1021
  children: [
1019
1022
  all.map((option) => {
1020
- return /* @__PURE__ */ jsx5(
1023
+ return /* @__PURE__ */ jsx6(
1021
1024
  "option",
1022
1025
  {
1023
1026
  value: option.value,
@@ -1032,7 +1035,7 @@ var MultiSelect = (props) => {
1032
1035
  return option.value === entry;
1033
1036
  });
1034
1037
  }).map((entry) => {
1035
- return /* @__PURE__ */ jsx5(
1038
+ return /* @__PURE__ */ jsx6(
1036
1039
  "option",
1037
1040
  {
1038
1041
  value: entry,
@@ -1047,100 +1050,80 @@ var MultiSelect = (props) => {
1047
1050
  ]
1048
1051
  }
1049
1052
  ),
1050
- /* @__PURE__ */ jsx5(
1051
- Primitive2.Portal,
1053
+ /* @__PURE__ */ jsxs5(
1054
+ SelectionPopup,
1052
1055
  {
1053
1056
  container: portalContainer,
1054
- children: /* @__PURE__ */ jsxs5(
1055
- Primitive2.Content,
1056
- {
1057
- ref: popup,
1058
- "aria-label": searchLabel,
1059
- sideOffset: 8,
1060
- align: "start",
1061
- collisionPadding: 16,
1062
- dir: restProps.dir,
1063
- className: comboboxContentStyles(),
1064
- onOpenAutoFocus: (event) => {
1065
- event.preventDefault();
1066
- search.current?.focus({ preventScroll: true });
1067
- },
1068
- onCloseAutoFocus: (event) => {
1069
- event.preventDefault();
1070
- const target = finalFocus();
1071
- if (target) {
1072
- target.focus();
1073
- }
1074
- },
1075
- onEscapeKeyDown: (event) => {
1076
- event.preventDefault();
1077
- event.stopPropagation();
1078
- if (!event.isComposing) {
1079
- close();
1080
- focus();
1081
- }
1082
- },
1083
- children: [
1084
- /* @__PURE__ */ jsx5(
1085
- "input",
1086
- {
1087
- ref: search,
1088
- type: "text",
1089
- role: "combobox",
1090
- "aria-label": searchLabel,
1091
- "aria-expanded": "true",
1092
- "aria-autocomplete": "list",
1093
- "aria-controls": `${id}-list`,
1094
- "aria-activedescendant": activeOptionId,
1095
- value: query ?? "",
1096
- className: cn3(controlVariants2({ size: "small" }), "mb-gridui-4 shrink-0"),
1097
- onChange: (event) => {
1098
- searchOptions.changeQuery(event.target.value);
1099
- },
1100
- onKeyDown: (event) => {
1101
- if (event.nativeEvent.isComposing) {
1102
- event.stopPropagation();
1103
- return;
1104
- }
1105
- if (event.key === "ArrowDown" || event.key === "ArrowUp") {
1106
- event.preventDefault();
1107
- searchOptions.moveActive(event.key === "ArrowDown" ? 1 : -1);
1108
- }
1109
- if (event.key === "Enter") {
1110
- event.preventDefault();
1111
- const option = searchOptions.activeOption;
1112
- if (option) {
1113
- choose(option);
1114
- }
1115
- }
1116
- }
1057
+ ref: popup,
1058
+ "aria-label": searchLabel,
1059
+ dir: restProps.dir,
1060
+ finalFocus,
1061
+ initialFocus: () => {
1062
+ search.current?.focus({ preventScroll: true });
1063
+ },
1064
+ onEscape: () => {
1065
+ close();
1066
+ focus();
1067
+ },
1068
+ children: [
1069
+ /* @__PURE__ */ jsx6(
1070
+ "input",
1071
+ {
1072
+ ref: search,
1073
+ type: "text",
1074
+ role: "combobox",
1075
+ "aria-label": searchLabel,
1076
+ "aria-expanded": "true",
1077
+ "aria-autocomplete": "list",
1078
+ "aria-controls": `${id}-list`,
1079
+ "aria-activedescendant": activeOptionId,
1080
+ value: query ?? "",
1081
+ className: cn3(controlVariants2({ size: "small" }), "gridui-u-mb-gridui-4 gridui-u-shrink-0"),
1082
+ onChange: (event) => {
1083
+ searchOptions.changeQuery(event.target.value);
1084
+ },
1085
+ onKeyDown: (event) => {
1086
+ if (event.nativeEvent.isComposing) {
1087
+ event.stopPropagation();
1088
+ return;
1117
1089
  }
1118
- ),
1119
- /* @__PURE__ */ jsx5(
1120
- ComboboxOptions,
1121
- {
1122
- id: `${id}-list`,
1123
- label: searchLabel,
1124
- options: filtered,
1125
- selected,
1126
- multiple: true,
1127
- active,
1128
- optionId,
1129
- onSelect: choose,
1130
- onHighlight: searchOptions.highlight
1090
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
1091
+ event.preventDefault();
1092
+ searchOptions.moveActive(event.key === "ArrowDown" ? 1 : -1);
1131
1093
  }
1132
- ),
1133
- !visible.length && /* @__PURE__ */ jsx5(
1134
- "div",
1135
- {
1136
- role: "status",
1137
- className: selectEmptyStyles(),
1138
- children: emptyLabel
1094
+ if (event.key === "Enter") {
1095
+ event.preventDefault();
1096
+ const option = searchOptions.activeOption;
1097
+ if (option) {
1098
+ choose(option);
1099
+ }
1139
1100
  }
1140
- )
1141
- ]
1142
- }
1143
- )
1101
+ }
1102
+ }
1103
+ ),
1104
+ /* @__PURE__ */ jsx6(
1105
+ ComboboxOptions,
1106
+ {
1107
+ id: `${id}-list`,
1108
+ label: searchLabel,
1109
+ options: filtered,
1110
+ selected,
1111
+ multiple: true,
1112
+ active,
1113
+ optionId,
1114
+ onSelect: choose,
1115
+ onHighlight: searchOptions.highlight
1116
+ }
1117
+ ),
1118
+ !visible.length && /* @__PURE__ */ jsx6(
1119
+ "div",
1120
+ {
1121
+ role: "status",
1122
+ className: selectEmptyStyles(),
1123
+ children: emptyLabel
1124
+ }
1125
+ )
1126
+ ]
1144
1127
  }
1145
1128
  )
1146
1129
  ]
@@ -1149,34 +1132,35 @@ var MultiSelect = (props) => {
1149
1132
  };
1150
1133
 
1151
1134
  // src/select/style.ts
1152
- import { dropdownContentStyles as dropdownContentStyles2 } from "@gridui/dropdown-menu";
1135
+ import { overlaySurfaceStyles as overlaySurfaceStyles2 } from "@gridui/overlay";
1153
1136
  import { cn as cn4 } from "@gridui/style-utils";
1154
1137
  import { cva as cva3 } from "class-variance-authority";
1155
1138
  var selectContentStyles = cva3(cn4(
1156
- dropdownContentStyles2(),
1157
- "gridui-select-content box-border relative flex flex-col overflow-hidden min-w-0 w-(--anchor-width) max-w-(--available-width) max-h-(--available-height)"
1139
+ overlaySurfaceStyles2(),
1140
+ "gridui-u-z-(--gridui-z-popover) gridui-u-p-gridui-4 gridui-u-type-data",
1141
+ "gridui-select-content gridui-u-box-border gridui-u-relative gridui-u-flex gridui-u-flex-col gridui-u-overflow-hidden gridui-u-min-w-0 gridui-u-w-(--anchor-width) gridui-u-max-w-(--available-width) gridui-u-max-h-(--available-height)"
1158
1142
  ));
1159
- var selectMenuItemStyles = cva3(cn4(selectItemStyles(), "relative px-gridui-4 pr-9"));
1160
- var selectIndicatorStyles = cva3("absolute inset-y-0 right-gridui-4 flex w-gridui-16 items-center justify-center text-foreground");
1161
- var selectScrollArrowStyles = cva3("absolute inset-x-0 z-(--gridui-z-content) flex h-gridui-24 items-center justify-center bg-background text-foreground", {
1143
+ var selectMenuItemStyles = cva3(cn4(selectItemStyles(), "gridui-u-relative gridui-u-px-gridui-4 gridui-u-pr-9"));
1144
+ var selectIndicatorStyles = cva3("gridui-u-absolute gridui-u-inset-y-0 gridui-u-right-gridui-4 gridui-u-flex gridui-u-w-gridui-16 gridui-u-items-center gridui-u-justify-center gridui-u-text-foreground");
1145
+ var selectScrollArrowStyles = cva3("gridui-u-absolute gridui-u-inset-x-0 gridui-u-z-(--gridui-z-content) gridui-u-flex gridui-u-h-gridui-24 gridui-u-items-center gridui-u-justify-center gridui-u-bg-background gridui-u-text-foreground", {
1162
1146
  variants: {
1163
1147
  direction: {
1164
- up: "top-0",
1165
- down: "bottom-0"
1148
+ up: "gridui-u-top-0",
1149
+ down: "gridui-u-bottom-0"
1166
1150
  }
1167
1151
  }
1168
1152
  });
1169
1153
 
1170
1154
  // src/select/select-options.tsx
1171
1155
  import { dropdownLabelStyles as dropdownLabelStyles2 } from "@gridui/dropdown-menu";
1172
- import * as Primitive3 from "@radix-ui/react-select";
1156
+ import * as Primitive4 from "@radix-ui/react-select";
1173
1157
  import { Check as Check2 } from "lucide-react";
1174
1158
  import { useId as useId3 } from "react";
1175
- import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1159
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
1176
1160
  var SelectOptions = (props) => {
1177
1161
  const { options, id, label } = props;
1178
- return /* @__PURE__ */ jsx6(
1179
- Primitive3.Viewport,
1162
+ return /* @__PURE__ */ jsx7(
1163
+ Primitive4.Viewport,
1180
1164
  {
1181
1165
  className: selectListStyles(),
1182
1166
  role: "listbox",
@@ -1184,7 +1168,7 @@ var SelectOptions = (props) => {
1184
1168
  "aria-label": label,
1185
1169
  children: options.map((entry) => {
1186
1170
  if (!("options" in entry)) {
1187
- return /* @__PURE__ */ jsx6(
1171
+ return /* @__PURE__ */ jsx7(
1188
1172
  SelectOptionItem,
1189
1173
  {
1190
1174
  option: entry
@@ -1193,18 +1177,18 @@ var SelectOptions = (props) => {
1193
1177
  );
1194
1178
  }
1195
1179
  return /* @__PURE__ */ jsxs6(
1196
- Primitive3.Group,
1180
+ Primitive4.Group,
1197
1181
  {
1198
1182
  children: [
1199
- /* @__PURE__ */ jsx6(
1200
- Primitive3.Label,
1183
+ /* @__PURE__ */ jsx7(
1184
+ Primitive4.Label,
1201
1185
  {
1202
1186
  className: dropdownLabelStyles2(),
1203
1187
  children: entry.label
1204
1188
  }
1205
1189
  ),
1206
1190
  entry.options.map((option) => {
1207
- return /* @__PURE__ */ jsx6(
1191
+ return /* @__PURE__ */ jsx7(
1208
1192
  SelectOptionItem,
1209
1193
  {
1210
1194
  option
@@ -1225,7 +1209,7 @@ var SelectOptionItem = (props) => {
1225
1209
  const labelId = useId3();
1226
1210
  const descriptionId = `${labelId}-description`;
1227
1211
  return /* @__PURE__ */ jsxs6(
1228
- Primitive3.Item,
1212
+ Primitive4.Item,
1229
1213
  {
1230
1214
  value: `gridui:${option.value}`,
1231
1215
  "aria-labelledby": labelId,
@@ -1234,7 +1218,7 @@ var SelectOptionItem = (props) => {
1234
1218
  disabled: option.disabled,
1235
1219
  className: selectMenuItemStyles(),
1236
1220
  children: [
1237
- option.icon && /* @__PURE__ */ jsx6(
1221
+ option.icon && /* @__PURE__ */ jsx7(
1238
1222
  "span",
1239
1223
  {
1240
1224
  className: selectIconStyles(),
@@ -1247,14 +1231,14 @@ var SelectOptionItem = (props) => {
1247
1231
  {
1248
1232
  className: selectOptionContentStyles(),
1249
1233
  children: [
1250
- /* @__PURE__ */ jsx6(
1251
- Primitive3.ItemText,
1234
+ /* @__PURE__ */ jsx7(
1235
+ Primitive4.ItemText,
1252
1236
  {
1253
1237
  id: labelId,
1254
1238
  children: option.label
1255
1239
  }
1256
1240
  ),
1257
- option.description && /* @__PURE__ */ jsx6(
1241
+ option.description && /* @__PURE__ */ jsx7(
1258
1242
  "span",
1259
1243
  {
1260
1244
  id: descriptionId,
@@ -1265,12 +1249,12 @@ var SelectOptionItem = (props) => {
1265
1249
  ]
1266
1250
  }
1267
1251
  ),
1268
- /* @__PURE__ */ jsx6(
1269
- Primitive3.ItemIndicator,
1252
+ /* @__PURE__ */ jsx7(
1253
+ Primitive4.ItemIndicator,
1270
1254
  {
1271
1255
  className: selectIndicatorStyles(),
1272
1256
  "aria-hidden": "true",
1273
- children: /* @__PURE__ */ jsx6(
1257
+ children: /* @__PURE__ */ jsx7(
1274
1258
  Check2,
1275
1259
  {
1276
1260
  size: 16
@@ -1286,10 +1270,10 @@ var SelectOptionItem = (props) => {
1286
1270
  // src/select/select.tsx
1287
1271
  import { controlVariants as controlVariants3 } from "@gridui/input";
1288
1272
  import { cn as cn5 } from "@gridui/style-utils";
1289
- import * as Primitive4 from "@radix-ui/react-select";
1273
+ import * as Primitive5 from "@radix-ui/react-select";
1290
1274
  import { ChevronDown as ChevronDown3, ChevronUp, X as X3 } from "lucide-react";
1291
1275
  import { useId as useId4, useRef as useRef6, useState as useState4 } from "react";
1292
- import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1276
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
1293
1277
  var Select = (props) => {
1294
1278
  const {
1295
1279
  options,
@@ -1342,7 +1326,7 @@ var Select = (props) => {
1342
1326
  const fallback = selectedValue === "" ? placeholder ?? "" : selectedValue;
1343
1327
  const display = selected?.label ?? fallback;
1344
1328
  return /* @__PURE__ */ jsxs7(
1345
- Primitive4.Root,
1329
+ Primitive5.Root,
1346
1330
  {
1347
1331
  form: `${listId}-detached`,
1348
1332
  value: selected ? `gridui:${selectedValue}` : "",
@@ -1362,11 +1346,11 @@ var Select = (props) => {
1362
1346
  /* @__PURE__ */ jsxs7(
1363
1347
  "div",
1364
1348
  {
1365
- className: "relative flex min-w-0 w-full items-stretch gap-gridui-4",
1349
+ className: "gridui-u-relative gridui-u-flex gridui-u-min-w-0 gridui-u-w-full gridui-u-items-stretch gridui-u-gap-gridui-4",
1366
1350
  dir,
1367
1351
  children: [
1368
1352
  /* @__PURE__ */ jsxs7(
1369
- Primitive4.Trigger,
1353
+ Primitive5.Trigger,
1370
1354
  {
1371
1355
  ...restProps,
1372
1356
  form,
@@ -1381,9 +1365,9 @@ var Select = (props) => {
1381
1365
  ref.current = element;
1382
1366
  }
1383
1367
  },
1384
- className: cn5(controlVariants3({ size: controlSize }), "flex flex-1 items-center gap-gridui-8 text-start", className),
1368
+ className: cn5(controlVariants3({ size: controlSize }), "gridui-u-flex gridui-u-flex-1 gridui-u-items-center gridui-u-gap-gridui-8 gridui-u-text-start", className),
1385
1369
  children: [
1386
- selected?.icon && /* @__PURE__ */ jsx7(
1370
+ selected?.icon && /* @__PURE__ */ jsx8(
1387
1371
  "span",
1388
1372
  {
1389
1373
  className: selectIconStyles(),
@@ -1391,12 +1375,12 @@ var Select = (props) => {
1391
1375
  children: selected.icon
1392
1376
  }
1393
1377
  ),
1394
- /* @__PURE__ */ jsx7(
1378
+ /* @__PURE__ */ jsx8(
1395
1379
  "span",
1396
1380
  {
1397
- className: "min-w-0 flex-1 whitespace-normal wrap-anywhere",
1398
- children: /* @__PURE__ */ jsx7(
1399
- Primitive4.Value,
1381
+ className: "gridui-u-min-w-0 gridui-u-flex-1 gridui-u-whitespace-normal gridui-u-wrap-anywhere",
1382
+ children: /* @__PURE__ */ jsx8(
1383
+ Primitive5.Value,
1400
1384
  {
1401
1385
  placeholder: display,
1402
1386
  children: display
@@ -1404,18 +1388,18 @@ var Select = (props) => {
1404
1388
  )
1405
1389
  }
1406
1390
  ),
1407
- /* @__PURE__ */ jsx7(Primitive4.Icon, { children: /* @__PURE__ */ jsx7(
1391
+ /* @__PURE__ */ jsx8(Primitive5.Icon, { children: /* @__PURE__ */ jsx8(
1408
1392
  ChevronDown3,
1409
1393
  {
1410
1394
  size: 16,
1411
- className: "shrink-0",
1395
+ className: "gridui-u-shrink-0",
1412
1396
  "aria-hidden": "true"
1413
1397
  }
1414
1398
  ) })
1415
1399
  ]
1416
1400
  }
1417
1401
  ),
1418
- clearLabel && /* @__PURE__ */ jsx7(
1402
+ clearLabel && /* @__PURE__ */ jsx8(
1419
1403
  "button",
1420
1404
  {
1421
1405
  type: "button",
@@ -1425,8 +1409,8 @@ var Select = (props) => {
1425
1409
  change("");
1426
1410
  controlRef.current?.focus();
1427
1411
  },
1428
- className: cn5(controlVariants3({ size: controlSize }), "flex w-auto shrink-0 items-center justify-center min-w-11 cursor-pointer hover:enabled:bg-surface"),
1429
- children: /* @__PURE__ */ jsx7(
1412
+ className: cn5(controlVariants3({ size: controlSize }), "gridui-u-flex gridui-u-w-auto gridui-u-shrink-0 gridui-u-items-center gridui-u-justify-center gridui-u-min-w-11 gridui-u-cursor-pointer gridui-u-hover:enabled:bg-surface"),
1413
+ children: /* @__PURE__ */ jsx8(
1430
1414
  X3,
1431
1415
  {
1432
1416
  size: 16,
@@ -1435,7 +1419,7 @@ var Select = (props) => {
1435
1419
  )
1436
1420
  }
1437
1421
  ),
1438
- /* @__PURE__ */ jsx7(
1422
+ /* @__PURE__ */ jsx8(
1439
1423
  SelectionForm,
1440
1424
  {
1441
1425
  name,
@@ -1455,12 +1439,12 @@ var Select = (props) => {
1455
1439
  ]
1456
1440
  }
1457
1441
  ),
1458
- /* @__PURE__ */ jsx7(
1459
- Primitive4.Portal,
1442
+ /* @__PURE__ */ jsx8(
1443
+ Primitive5.Portal,
1460
1444
  {
1461
1445
  container: portalContainer,
1462
1446
  children: /* @__PURE__ */ jsxs7(
1463
- Primitive4.Content,
1447
+ Primitive5.Content,
1464
1448
  {
1465
1449
  position,
1466
1450
  align: "start",
@@ -1512,13 +1496,13 @@ var Select = (props) => {
1512
1496
  /* @__PURE__ */ jsxs7(
1513
1497
  "div",
1514
1498
  {
1515
- className: "relative flex min-h-0 flex-col",
1499
+ className: "gridui-u-relative gridui-u-flex gridui-u-min-h-0 gridui-u-flex-col",
1516
1500
  children: [
1517
- /* @__PURE__ */ jsx7(
1518
- Primitive4.ScrollUpButton,
1501
+ /* @__PURE__ */ jsx8(
1502
+ Primitive5.ScrollUpButton,
1519
1503
  {
1520
1504
  className: selectScrollArrowStyles({ direction: "up" }),
1521
- children: /* @__PURE__ */ jsx7(
1505
+ children: /* @__PURE__ */ jsx8(
1522
1506
  ChevronUp,
1523
1507
  {
1524
1508
  size: 16,
@@ -1527,7 +1511,7 @@ var Select = (props) => {
1527
1511
  )
1528
1512
  }
1529
1513
  ),
1530
- /* @__PURE__ */ jsx7(
1514
+ /* @__PURE__ */ jsx8(
1531
1515
  SelectOptions,
1532
1516
  {
1533
1517
  options,
@@ -1535,11 +1519,11 @@ var Select = (props) => {
1535
1519
  label: restProps["aria-label"]
1536
1520
  }
1537
1521
  ),
1538
- /* @__PURE__ */ jsx7(
1539
- Primitive4.ScrollDownButton,
1522
+ /* @__PURE__ */ jsx8(
1523
+ Primitive5.ScrollDownButton,
1540
1524
  {
1541
1525
  className: selectScrollArrowStyles({ direction: "down" }),
1542
- children: /* @__PURE__ */ jsx7(
1526
+ children: /* @__PURE__ */ jsx8(
1543
1527
  ChevronDown3,
1544
1528
  {
1545
1529
  size: 16,
@@ -1551,7 +1535,7 @@ var Select = (props) => {
1551
1535
  ]
1552
1536
  }
1553
1537
  ),
1554
- /* @__PURE__ */ jsx7(
1538
+ /* @__PURE__ */ jsx8(
1555
1539
  SelectionActions,
1556
1540
  {
1557
1541
  actions,