@omer-x/tailwind-ui-kit 1.0.0-alpha.40 → 1.0.0-alpha.41

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.
Files changed (39) hide show
  1. package/README.md +108 -0
  2. package/dist/components/form/BaseAutocomplete.d.ts +1 -1
  3. package/dist/components/form/BaseSelect.d.ts +165 -0
  4. package/dist/components/form/BaseSelect.js +41 -0
  5. package/dist/components/form/BaseSelectGroup.d.ts +8 -0
  6. package/dist/components/form/BaseSelectGroup.js +7 -0
  7. package/dist/components/form/BaseSelectGroupLabel.d.ts +8 -0
  8. package/dist/components/form/BaseSelectGroupLabel.js +7 -0
  9. package/dist/components/form/BaseSelectIcon.d.ts +14 -0
  10. package/dist/components/form/BaseSelectIcon.js +10 -0
  11. package/dist/components/form/BaseSelectItem.d.ts +24 -0
  12. package/dist/components/form/BaseSelectItem.js +14 -0
  13. package/dist/components/form/BaseSelectItemIndicator.d.ts +16 -0
  14. package/dist/components/form/BaseSelectItemIndicator.js +10 -0
  15. package/dist/components/form/BaseSelectItemText.d.ts +8 -0
  16. package/dist/components/form/BaseSelectItemText.js +7 -0
  17. package/dist/components/form/BaseSelectLabel.d.ts +12 -0
  18. package/dist/components/form/BaseSelectLabel.js +10 -0
  19. package/dist/components/form/BaseSelectList.d.ts +8 -0
  20. package/dist/components/form/BaseSelectList.js +11 -0
  21. package/dist/components/form/BaseSelectPopup.d.ts +90 -0
  22. package/dist/components/form/BaseSelectPopup.js +45 -0
  23. package/dist/components/form/BaseSelectScrollDownArrow.d.ts +15 -0
  24. package/dist/components/form/BaseSelectScrollDownArrow.js +17 -0
  25. package/dist/components/form/BaseSelectScrollUpArrow.d.ts +15 -0
  26. package/dist/components/form/BaseSelectScrollUpArrow.js +17 -0
  27. package/dist/components/form/BaseSelectSeparator.d.ts +16 -0
  28. package/dist/components/form/BaseSelectSeparator.js +10 -0
  29. package/dist/components/form/BaseSelectTrigger.d.ts +17 -0
  30. package/dist/components/form/BaseSelectTrigger.js +15 -0
  31. package/dist/components/form/BaseSelectValue.d.ts +21 -0
  32. package/dist/components/form/BaseSelectValue.js +11 -0
  33. package/dist/components/form/index.d.ts +9 -1
  34. package/dist/components/form/index.js +2 -1
  35. package/dist/components/form/selectTypes.d.ts +27 -0
  36. package/dist/components/form/selectTypes.js +1 -0
  37. package/dist/components/menu/BaseMenu.d.ts +1 -1
  38. package/dist/components/menu/BaseMenubar.d.ts +1 -1
  39. package/package.json +1 -1
package/README.md CHANGED
@@ -621,6 +621,114 @@ const filter = useAutocompleteFilter();
621
621
  </BaseFormField>
622
622
  ```
623
623
 
624
+ #### `BaseSelect`
625
+
626
+ A Base UI [`Select`](https://base-ui.com/react/components/select): choose a predefined value from a dropdown. Like a native `<select>`, the popup opens over the trigger with the selected item on top of the value. A simple one:
627
+
628
+ ```tsx
629
+ import { BaseSelect } from "@omer-x/tailwind-ui-kit/form";
630
+
631
+ const fruits = { apple: "Apple", banana: "Banana", cherry: "Cherry" };
632
+
633
+ <BaseSelect items={fruits}>
634
+ <BaseSelect.Label>Fruit</BaseSelect.Label>
635
+ <BaseSelect.Trigger className="border border-neutral-300">
636
+ <BaseSelect.Value placeholder="Pick a fruit" className="data-placeholder:text-neutral-500" />
637
+ <BaseSelect.Icon><ChevronIcon /></BaseSelect.Icon>
638
+ </BaseSelect.Trigger>
639
+ <BaseSelect.Popup className="rounded-md bg-white py-1 shadow-lg">
640
+ <BaseSelect.List>
641
+ {Object.entries(fruits).map(([value, label]) => (
642
+ <BaseSelect.Item key={value} value={value} className="px-2 py-1.5 data-highlighted:bg-blue-600">
643
+ <BaseSelect.ItemIndicator><CheckIcon /></BaseSelect.ItemIndicator>
644
+ <BaseSelect.ItemText>{label}</BaseSelect.ItemText>
645
+ </BaseSelect.Item>
646
+ ))}
647
+ </BaseSelect.List>
648
+ </BaseSelect.Popup>
649
+ </BaseSelect>
650
+ ```
651
+
652
+ The parts are reached with dot notation, which only works in client components. Build selects in a `"use client"` file, e.g. your app's themed wrapper.
653
+
654
+ | Part | Renders | Description |
655
+ |------|---------|-------------|
656
+ | `BaseSelect` | a hidden `<input>` | Groups the parts and holds the value. The hidden input carries the value for the form |
657
+ | `.Label` | `<div>` | Names the trigger. Not needed inside `BaseFormField`, whose `label` names it |
658
+ | `.Trigger` | `<button>` | Shows the value and opens the popup (`flex items-center justify-between gap-2`). Takes `size` (`"lg" \| "md" \| "sm" \| "xs"`, default `"md"`), the same sizes as `BaseInput`. `data-popup-open`, `data-placeholder` |
659
+ | `.Value` | `<span>` | The selected item's label (`min-w-0 flex-1 truncate`). `placeholder` shows while nothing is selected (`data-placeholder`). Children can be a function of the value |
660
+ | `.Icon` | `<span>` | A decorative icon (e.g. a chevron), hidden from assistive technology. Bring your own icon as children |
661
+ | `.Popup` | `<div>` | The floating container, portaled and positioned. At least as wide as the trigger, with scale and fade transitions (none while it's over the trigger) |
662
+ | `.List` | `<div>` | The scrollable list, never taller than the space left in the viewport |
663
+ | `.Item` | `<div>` | An option (`flex items-center gap-2`). `value` is what it selects (`null` clears the selection), `label` its typeahead text. `data-selected`, `data-highlighted`, `data-disabled` |
664
+ | `.ItemText` | `<div>` | The item's text. Over the trigger, it's lined up with the value |
665
+ | `.ItemIndicator` | `<span>` | Marks the selected item. Only rendered while selected (`keepMounted` keeps it, e.g. to keep texts lined up). Bring your own icon, and give it `aria-hidden` so it stays out of the item's accessible name |
666
+ | `.Group` | `<div>` | A group of items |
667
+ | `.GroupLabel` | `<div>` | Names a group |
668
+ | `.Separator` | `<div>` | A line between items or groups, with `data-orientation`. It has `role="presentation"`: a listbox can't hold separators |
669
+ | `.ScrollUpArrow`, `.ScrollDownArrow` | `<div>` | Put them in `.Popup`, next to `.List`. They scroll the list while hovered, and are only rendered while it can scroll their way (`keepMounted` keeps them). Pinned to the popup's top / bottom edge. No content by default: bring your own icon |
670
+
671
+ Every part takes `className` and a `render` prop. Render functions get the part's state (`SelectTriggerState`, `SelectItemState`, `SelectPopupState`, …), which is also set as data attributes: `data-open`, `data-popup-side`, `data-placeholder`, `data-selected`, `data-highlighted`, `data-side`, `data-align`, `data-starting-style`, … The trigger and `.Label` also carry the field's state (`data-invalid`, `data-dirty`, `data-touched`, `data-filled`, `data-focused`).
672
+
673
+ `BaseSelect` props:
674
+
675
+ | Prop | Type | Description |
676
+ |------|------|-------------|
677
+ | `value` / `defaultValue` | `Value \| null` (an array with `multiple`) | The selected value, controlled / uncontrolled |
678
+ | `onValueChange` | `(value, event) => void` | Called with the new value and the DOM event (none when changed from code) |
679
+ | `multiple` | `boolean` | Lets the user select several items. The popup stays open while choosing |
680
+ | `items` | `Record<string, ReactNode> \| { value, label }[] \| { items }[]` | The items' labels, so `.Value` shows the selected label (not the raw value) before the popup has ever opened |
681
+ | `itemToStringLabel` | `(value) => string` | Text shown for an object value. `{ value, label }` objects use `label` without it |
682
+ | `itemToStringValue` | `(value) => string` | Text submitted for an object value. `{ value, label }` objects use `value` without it |
683
+ | `isItemEqualToValue` | `(itemValue, value) => boolean` | Matches object values, e.g. by id. Defaults to `Object.is` |
684
+ | `open` / `defaultOpen` | `boolean` | The popup's state |
685
+ | `onOpenChange` | `(open, event) => void` | Called with the new state and the DOM event |
686
+ | `onOpenChangeComplete` | `(open) => void` | Called after the transition ends |
687
+ | `modal` | `boolean` | Default `true`. Locks page scroll and outside pointer input while open |
688
+ | `highlightItemOnHover` | `boolean` | Default `true`. `false` lets `:hover` and `data-highlighted` differ |
689
+ | `name`, `form`, `autoComplete`, `id`, `required`, `disabled`, `readOnly` | | Form props. Inside `BaseFormField`, the field's `name` is used |
690
+ | `inputRef` | `Ref<HTMLInputElement>` | The hidden input |
691
+ | `actionsRef` | `RefObject<SelectActions>` | `actionsRef.current?.close()` |
692
+
693
+ `BaseSelect.Popup` props, besides `<div>` props:
694
+
695
+ | Prop | Description |
696
+ |------|-------------|
697
+ | `alignItemWithTrigger` | Default `true`: the popup opens over the trigger (`data-side="none"`), and `side`, `align` and their offsets don't apply. Touch input and too little space fall back to a regular placement. `false` always places it beside the trigger |
698
+ | `side`, `align` | Placement against the trigger. Default `"bottom"`, `"center"` |
699
+ | `sideOffset`, `alignOffset` | Offsets in pixels, or a function of the placement and sizes |
700
+ | `anchor`, `positionMethod`, `collisionBoundary`, `collisionPadding`, `collisionAvoidance`, `sticky`, `disableAnchorTracking` | Positioning control |
701
+ | `renderPositioner` | Replaces the element that positions the popup, e.g. `<div className="z-50" />` |
702
+ | `container` | Portal target (default `<body>`) |
703
+ | `backdrop`, `renderBackdrop` | Renders a `fixed inset-0` backdrop (off by default) |
704
+ | `arrow`, `renderArrow`, `arrowPadding` | An arrow pointing at the trigger. Rendered when `arrow` (its content, e.g. an `<svg>`) or `renderArrow` is given. Only shows while the popup is beside the trigger |
705
+ | `finalFocus` | The element focused when the popup closes. Defaults to the trigger |
706
+
707
+ **Several values.** With `multiple`, the value is an array. Render it in `.Value` with a function:
708
+
709
+ ```tsx
710
+ <BaseSelect multiple items={fruits}>
711
+ <BaseSelect.Trigger>
712
+ <BaseSelect.Value placeholder="Pick fruits">
713
+ {(values: string[]) => values.map(value => fruits[value]).join(", ")}
714
+ </BaseSelect.Value>
715
+ </BaseSelect.Trigger>
716
+ …
717
+ </BaseSelect>
718
+ ```
719
+
720
+ **In a form.** Put it in `BaseFormField`'s `children`. The field gives it its `name`, label, validation, server errors and `data-invalid`, and `onlyDirty` sees its value (`defaultValues` holds the item values, an array with `multiple`). `BaseForm` never resets the form after a submit (#4), so the select keeps its value. Only `required` is checked in the browser; other schema rules are checked by the server:
721
+
722
+ ```tsx
723
+ <BaseFormField name="fruit" label="Fruit" schema={Schema.shape.fruit}>
724
+ {constraints => (
725
+ <BaseSelect items={fruits} required={constraints.required}>
726
+ …
727
+ </BaseSelect>
728
+ )}
729
+ </BaseFormField>
730
+ ```
731
+
624
732
  ### `@omer-x/tailwind-ui-kit/dialog`
625
733
 
626
734
  #### `BaseDialog`
@@ -108,7 +108,7 @@ declare const _default: (<Item>({ onValueChange, onOpenChange, onItemHighlighted
108
108
  InputGroup: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
109
109
  render?: RenderProp<"div", AutocompleteInputState>;
110
110
  }) => import("react").JSX.Element;
111
- Input: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "value" | "defaultValue" | "size"> & {
111
+ Input: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "value" | "size"> & {
112
112
  size?: InputSize;
113
113
  render?: RenderProp<"input", AutocompleteInputState>;
114
114
  }) => import("react").JSX.Element;
@@ -0,0 +1,165 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { FieldState } from "./BaseFormField.js";
3
+ import "../../utils/index.js";
4
+ import { InputSize } from "./inputSizes.js";
5
+ import { SelectAlign, SelectScrollArrowState, SelectSide, SelectTriggerState } from "./selectTypes.js";
6
+ import { SelectValueState } from "./BaseSelectValue.js";
7
+ import { SelectIconState } from "./BaseSelectIcon.js";
8
+ import { SelectArrowState, SelectBackdropState, SelectCollisionAvoidance, SelectFocusTarget, SelectOffsetFunction, SelectPopupState, SelectPositionerState } from "./BaseSelectPopup.js";
9
+ import { SelectItemState } from "./BaseSelectItem.js";
10
+ import { SelectItemIndicatorState } from "./BaseSelectItemIndicator.js";
11
+ import { SelectSeparatorState } from "./BaseSelectSeparator.js";
12
+ import { ReactNode, Ref, RefObject } from "react";
13
+ /** An item in `items`: its value and the label shown for it. */
14
+ export type SelectLabeledItem<Value = unknown> = {
15
+ value: Value;
16
+ label: ReactNode;
17
+ };
18
+ /** A group of items in `items`: any object with an `items` array, e.g. `{ label: "Fruits", items: [...] }`. */
19
+ export type SelectItemGroup<Item = SelectLabeledItem> = {
20
+ items: readonly Item[];
21
+ };
22
+ /** Imperative actions, through `actionsRef`. */
23
+ export type SelectActions = {
24
+ /** Closes the popup. */
25
+ close: () => void;
26
+ };
27
+ type SelectInputValue<Value, Multiple extends boolean | undefined> = Multiple extends true ? readonly Value[] : Value;
28
+ type SelectOutputValue<Value, Multiple extends boolean | undefined> = Multiple extends true ? Value[] : Value | null;
29
+ type BaseSelectProps<Value, Multiple extends boolean | undefined = false> = {
30
+ /** Lets the user select several items. The value is then an array. */
31
+ multiple?: Multiple;
32
+ /** The selected value, controlled. `null` selects nothing. */
33
+ value?: SelectInputValue<Value, Multiple> | null;
34
+ /** The initially selected value, uncontrolled. */
35
+ defaultValue?: SelectInputValue<Value, Multiple> | null;
36
+ /** Called with the new value and the DOM event that changed it (none when it was changed from code). */
37
+ onValueChange?: (value: SelectOutputValue<Value, Multiple>, event: Event | undefined) => void;
38
+ /**
39
+ * The items' labels, so `Value` can show the selected item's label instead of its value before the popup
40
+ * has ever opened. A `{ value: label }` record, `{ value, label }` objects, or groups of them.
41
+ */
42
+ items?: Record<string, ReactNode> | readonly SelectLabeledItem[] | readonly SelectItemGroup[];
43
+ /** Turns an object value into the text shown by `Value`. `{ value, label }` objects use their `label` without it. */
44
+ itemToStringLabel?: (value: Value) => string;
45
+ /** Turns an object value into the text submitted with the form. `{ value, label }` objects use their `value` without it. */
46
+ itemToStringValue?: (value: Value) => string;
47
+ /** Decides whether an item's value is the selected one, e.g. for objects compared by id. Defaults to `Object.is`. */
48
+ isItemEqualToValue?: (itemValue: Value, value: Value) => boolean;
49
+ open?: boolean;
50
+ defaultOpen?: boolean;
51
+ /** Called with the new state and the DOM event that changed it (none when it was changed from code). */
52
+ onOpenChange?: (open: boolean, event: Event | undefined) => void;
53
+ /** Called after the open or close transition ends. */
54
+ onOpenChangeComplete?: (open: boolean) => void;
55
+ /** Locks page scroll and blocks outside pointer input while open. @default true */
56
+ modal?: boolean;
57
+ /**
58
+ * Set to `false` to stop the pointer from highlighting items, so `:hover` and `data-highlighted` can differ.
59
+ * @default true
60
+ */
61
+ highlightItemOnHover?: boolean;
62
+ /** The hidden input's `name`. Inside a `BaseFormField`, the field's name is used. */
63
+ name?: string;
64
+ /** The `id` of a `<form>` to submit with, when the select isn't inside it. */
65
+ form?: string;
66
+ /** A hint for the browser's autofill. */
67
+ autoComplete?: string;
68
+ id?: string;
69
+ required?: boolean;
70
+ disabled?: boolean;
71
+ /** Shows the value but doesn't let the user change it. */
72
+ readOnly?: boolean;
73
+ /** A ref to the hidden `<input>` that holds the value for the form. */
74
+ inputRef?: Ref<HTMLInputElement>;
75
+ /** Imperative actions, e.g. `actionsRef.current?.close()`. */
76
+ actionsRef?: RefObject<SelectActions | null>;
77
+ children?: ReactNode;
78
+ };
79
+ declare const _default: (<Value, Multiple extends boolean | undefined = false>({ onValueChange, onOpenChange, ...otherProps }: BaseSelectProps<Value, Multiple>) => import("react").JSX.Element) & {
80
+ Label: (props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "id"> & {
81
+ render?: RenderProp<"div", FieldState>;
82
+ }) => import("react").JSX.Element;
83
+ Trigger: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "value"> & {
84
+ size?: InputSize;
85
+ render?: RenderProp<"button", SelectTriggerState>;
86
+ nativeButton?: boolean;
87
+ }) => import("react").JSX.Element;
88
+ Value: <Value>({ className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "children"> & {
89
+ render?: RenderProp<"span", SelectValueState>;
90
+ placeholder?: ReactNode;
91
+ children?: ReactNode | ((value: Value) => ReactNode);
92
+ }) => import("react").JSX.Element;
93
+ Icon: (props: import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & {
94
+ render?: RenderProp<"span", SelectIconState>;
95
+ }) => import("react").JSX.Element;
96
+ Popup: ({ container, alignItemWithTrigger, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, collisionAvoidance, sticky, arrowPadding, disableAnchorTracking, renderPositioner, backdrop, renderBackdrop, arrow, renderArrow, className, children, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
97
+ render?: RenderProp<"div", SelectPopupState>;
98
+ finalFocus?: SelectFocusTarget;
99
+ container?: HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null;
100
+ alignItemWithTrigger?: boolean;
101
+ anchor?: Element | RefObject<Element | null> | (() => Element | null) | null;
102
+ positionMethod?: "absolute" | "fixed";
103
+ side?: SelectSide;
104
+ sideOffset?: number | SelectOffsetFunction;
105
+ align?: SelectAlign;
106
+ alignOffset?: number | SelectOffsetFunction;
107
+ collisionBoundary?: "clipping-ancestors" | Element | Element[] | {
108
+ x: number;
109
+ y: number;
110
+ width: number;
111
+ height: number;
112
+ };
113
+ collisionPadding?: number | {
114
+ top?: number;
115
+ right?: number;
116
+ bottom?: number;
117
+ left?: number;
118
+ };
119
+ collisionAvoidance?: SelectCollisionAvoidance;
120
+ sticky?: boolean;
121
+ arrowPadding?: number;
122
+ disableAnchorTracking?: boolean;
123
+ renderPositioner?: RenderProp<"div", SelectPositionerState>;
124
+ backdrop?: boolean;
125
+ renderBackdrop?: RenderProp<"div", SelectBackdropState>;
126
+ arrow?: ReactNode;
127
+ renderArrow?: RenderProp<"div", SelectArrowState>;
128
+ }) => import("react").JSX.Element;
129
+ ScrollUpArrow: ({ className, children, render, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
130
+ render?: RenderProp<"div", SelectScrollArrowState>;
131
+ keepMounted?: boolean;
132
+ }) => import("react").JSX.Element;
133
+ ScrollDownArrow: ({ className, children, render, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
134
+ render?: RenderProp<"div", SelectScrollArrowState>;
135
+ keepMounted?: boolean;
136
+ }) => import("react").JSX.Element;
137
+ List: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
138
+ render?: RenderProp<"div">;
139
+ }) => import("react").JSX.Element;
140
+ Item: ({ className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "id"> & {
141
+ render?: RenderProp<"div", SelectItemState>;
142
+ value?: unknown;
143
+ label?: string;
144
+ disabled?: boolean;
145
+ nativeButton?: boolean;
146
+ }) => import("react").JSX.Element;
147
+ ItemText: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
148
+ render?: RenderProp<"div">;
149
+ }) => import("react").JSX.Element;
150
+ ItemIndicator: (props: import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & {
151
+ render?: RenderProp<"span", SelectItemIndicatorState>;
152
+ keepMounted?: boolean;
153
+ }) => import("react").JSX.Element;
154
+ Group: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
155
+ render?: RenderProp<"div">;
156
+ }) => import("react").JSX.Element;
157
+ GroupLabel: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
158
+ render?: RenderProp<"div">;
159
+ }) => import("react").JSX.Element;
160
+ Separator: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
161
+ render?: RenderProp<"div", SelectSeparatorState>;
162
+ orientation?: "horizontal" | "vertical";
163
+ }) => import("react").JSX.Element;
164
+ };
165
+ export { _default as default };
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import BaseSelectGroup from "./BaseSelectGroup.js";
4
+ import BaseSelectGroupLabel from "./BaseSelectGroupLabel.js";
5
+ import BaseSelectIcon from "./BaseSelectIcon.js";
6
+ import BaseSelectItem from "./BaseSelectItem.js";
7
+ import BaseSelectItemIndicator from "./BaseSelectItemIndicator.js";
8
+ import BaseSelectItemText from "./BaseSelectItemText.js";
9
+ import BaseSelectLabel from "./BaseSelectLabel.js";
10
+ import BaseSelectList from "./BaseSelectList.js";
11
+ import BaseSelectPopup from "./BaseSelectPopup.js";
12
+ import BaseSelectScrollDownArrow from "./BaseSelectScrollDownArrow.js";
13
+ import BaseSelectScrollUpArrow from "./BaseSelectScrollUpArrow.js";
14
+ import BaseSelectSeparator from "./BaseSelectSeparator.js";
15
+ import BaseSelectTrigger from "./BaseSelectTrigger.js";
16
+ import BaseSelectValue from "./BaseSelectValue.js";
17
+ import { jsx } from "react/jsx-runtime";
18
+ // src/components/form/BaseSelect.tsx
19
+ /** Groups the parts of a select and holds its value. Renders no element (only a hidden input for the form). */
20
+ const BaseSelect = ({ onValueChange, onOpenChange, ...otherProps }) => /* @__PURE__ */ jsx(Select.Root, {
21
+ ...otherProps,
22
+ onValueChange: onValueChange && ((value, details) => onValueChange(value, details.event)),
23
+ onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event))
24
+ });
25
+ var BaseSelect_default = Object.assign(BaseSelect, {
26
+ Label: BaseSelectLabel,
27
+ Trigger: BaseSelectTrigger,
28
+ Value: BaseSelectValue,
29
+ Icon: BaseSelectIcon,
30
+ Popup: BaseSelectPopup,
31
+ ScrollUpArrow: BaseSelectScrollUpArrow,
32
+ ScrollDownArrow: BaseSelectScrollDownArrow,
33
+ List: BaseSelectList,
34
+ Item: BaseSelectItem,
35
+ ItemText: BaseSelectItemText,
36
+ ItemIndicator: BaseSelectItemIndicator,
37
+ Group: BaseSelectGroup,
38
+ GroupLabel: BaseSelectGroupLabel,
39
+ Separator: BaseSelectSeparator
40
+ });
41
+ export { BaseSelect_default as default };
@@ -0,0 +1,8 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ type BaseSelectGroupProps = ComponentProps<"div"> & {
4
+ render?: RenderProp<"div">;
5
+ };
6
+ /** Groups related items under a `GroupLabel`. Renders a `<div>` with `role="group"`. */
7
+ declare const BaseSelectGroup: (props: BaseSelectGroupProps) => import("react").JSX.Element;
8
+ export { BaseSelectGroup as default };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseSelectGroup.tsx
5
+ /** Groups related items under a `GroupLabel`. Renders a `<div>` with `role="group"`. */
6
+ const BaseSelectGroup = (props) => /* @__PURE__ */ jsx(Select.Group, { ...props });
7
+ export { BaseSelectGroup as default };
@@ -0,0 +1,8 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ type BaseSelectGroupLabelProps = ComponentProps<"div"> & {
4
+ render?: RenderProp<"div">;
5
+ };
6
+ /** The heading that names a group. Renders a `<div>`. */
7
+ declare const BaseSelectGroupLabel: (props: BaseSelectGroupLabelProps) => import("react").JSX.Element;
8
+ export { BaseSelectGroupLabel as default };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseSelectGroupLabel.tsx
5
+ /** The heading that names a group. Renders a `<div>`. */
6
+ const BaseSelectGroupLabel = (props) => /* @__PURE__ */ jsx(Select.GroupLabel, { ...props });
7
+ export { BaseSelectGroupLabel as default };
@@ -0,0 +1,14 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ export type SelectIconState = {
4
+ open: boolean;
5
+ };
6
+ type BaseSelectIconProps = ComponentProps<"span"> & {
7
+ render?: RenderProp<"span", SelectIconState>;
8
+ };
9
+ /**
10
+ * A decorative icon in the trigger (e.g. a chevron), hidden from assistive technology. Renders a `<span>`,
11
+ * with `data-popup-open` while the popup is open. Bring your own icon as children.
12
+ */
13
+ declare const BaseSelectIcon: (props: BaseSelectIconProps) => import("react").JSX.Element;
14
+ export { BaseSelectIcon as default };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseSelectIcon.tsx
5
+ /**
6
+ * A decorative icon in the trigger (e.g. a chevron), hidden from assistive technology. Renders a `<span>`,
7
+ * with `data-popup-open` while the popup is open. Bring your own icon as children.
8
+ */
9
+ const BaseSelectIcon = (props) => /* @__PURE__ */ jsx(Select.Icon, { ...props });
10
+ export { BaseSelectIcon as default };
@@ -0,0 +1,24 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ export type SelectItemState = {
4
+ disabled: boolean;
5
+ selected: boolean;
6
+ /** Whether the item is highlighted with the keyboard or the pointer. */
7
+ highlighted: boolean;
8
+ };
9
+ type BaseSelectItemProps = Omit<ComponentProps<"div">, "id"> & {
10
+ render?: RenderProp<"div", SelectItemState>;
11
+ /** The value the item selects. `null` makes it a "none" item that clears the selection. */
12
+ value?: unknown;
13
+ /** The item's text for typeahead, when it differs from its text content. */
14
+ label?: string;
15
+ disabled?: boolean;
16
+ /** Set to `true` when `render` renders a `<button>`. */
17
+ nativeButton?: boolean;
18
+ };
19
+ /**
20
+ * An option in the list. Put its text in `ItemText`, so the trigger can show it.
21
+ * Renders a `<div>`, with `data-selected`, `data-highlighted` and `data-disabled`.
22
+ */
23
+ declare const BaseSelectItem: ({ className, ...otherProps }: BaseSelectItemProps) => import("react").JSX.Element;
24
+ export { BaseSelectItem as default };
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/form/BaseSelectItem.tsx
6
+ /**
7
+ * An option in the list. Put its text in `ItemText`, so the trigger can show it.
8
+ * Renders a `<div>`, with `data-selected`, `data-highlighted` and `data-disabled`.
9
+ */
10
+ const BaseSelectItem = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Select.Item, {
11
+ ...otherProps,
12
+ className: cn("flex cursor-default items-center gap-2 outline-none select-none", className)
13
+ });
14
+ export { BaseSelectItem as default };
@@ -0,0 +1,16 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ export type SelectItemIndicatorState = {
4
+ selected: boolean;
5
+ };
6
+ type BaseSelectItemIndicatorProps = ComponentProps<"span"> & {
7
+ render?: RenderProp<"span", SelectItemIndicatorState>;
8
+ /** Keeps the indicator in the DOM while the item isn't selected, e.g. to keep the items' text lined up. */
9
+ keepMounted?: boolean;
10
+ };
11
+ /**
12
+ * Marks the selected item (e.g. a check mark). Only rendered while the item is selected.
13
+ * Renders a `<span>`. Bring your own icon as children, with `aria-hidden` so it stays out of the item's accessible name.
14
+ */
15
+ declare const BaseSelectItemIndicator: (props: BaseSelectItemIndicatorProps) => import("react").JSX.Element;
16
+ export { BaseSelectItemIndicator as default };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseSelectItemIndicator.tsx
5
+ /**
6
+ * Marks the selected item (e.g. a check mark). Only rendered while the item is selected.
7
+ * Renders a `<span>`. Bring your own icon as children, with `aria-hidden` so it stays out of the item's accessible name.
8
+ */
9
+ const BaseSelectItemIndicator = (props) => /* @__PURE__ */ jsx(Select.ItemIndicator, { ...props });
10
+ export { BaseSelectItemIndicator as default };
@@ -0,0 +1,8 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ type BaseSelectItemTextProps = ComponentProps<"div"> & {
4
+ render?: RenderProp<"div">;
5
+ };
6
+ /** The item's text. Over the trigger (`alignItemWithTrigger`), it's lined up with the value. Renders a `<div>`. */
7
+ declare const BaseSelectItemText: (props: BaseSelectItemTextProps) => import("react").JSX.Element;
8
+ export { BaseSelectItemText as default };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseSelectItemText.tsx
5
+ /** The item's text. Over the trigger (`alignItemWithTrigger`), it's lined up with the value. Renders a `<div>`. */
6
+ const BaseSelectItemText = (props) => /* @__PURE__ */ jsx(Select.ItemText, { ...props });
7
+ export { BaseSelectItemText as default };
@@ -0,0 +1,12 @@
1
+ import { FieldState } from "./BaseFormField.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ type BaseSelectLabelProps = Omit<ComponentProps<"div">, "id"> & {
5
+ render?: RenderProp<"div", FieldState>;
6
+ };
7
+ /**
8
+ * Names the select for assistive technology. Clicking it focuses the trigger. Renders a `<div>`.
9
+ * Not needed inside `BaseFormField`, whose `label` already names it.
10
+ */
11
+ declare const BaseSelectLabel: (props: BaseSelectLabelProps) => import("react").JSX.Element;
12
+ export { BaseSelectLabel as default };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseSelectLabel.tsx
5
+ /**
6
+ * Names the select for assistive technology. Clicking it focuses the trigger. Renders a `<div>`.
7
+ * Not needed inside `BaseFormField`, whose `label` already names it.
8
+ */
9
+ const BaseSelectLabel = (props) => /* @__PURE__ */ jsx(Select.Label, { ...props });
10
+ export { BaseSelectLabel as default };
@@ -0,0 +1,8 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ type BaseSelectListProps = ComponentProps<"div"> & {
4
+ render?: RenderProp<"div">;
5
+ };
6
+ /** The scrollable list of items, never taller than the space left in the viewport. Renders a `<div>`. */
7
+ declare const BaseSelectList: ({ className, ...otherProps }: BaseSelectListProps) => import("react").JSX.Element;
8
+ export { BaseSelectList as default };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/form/BaseSelectList.tsx
6
+ /** The scrollable list of items, never taller than the space left in the viewport. Renders a `<div>`. */
7
+ const BaseSelectList = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Select.List, {
8
+ ...otherProps,
9
+ className: cn("max-h-(--available-height) overflow-y-auto overscroll-contain outline-none", className)
10
+ });
11
+ export { BaseSelectList as default };
@@ -0,0 +1,90 @@
1
+ import { AutocompleteCollisionAvoidance, AutocompleteFocusTarget, AutocompleteOffsetFunction } from "./BaseAutocompletePopup.js";
2
+ import { SelectAlign, SelectSide } from "./selectTypes.js";
3
+ import { RenderProp } from "../../utils/render.js";
4
+ import { ComponentProps, ReactNode, RefObject } from "react";
5
+ export type SelectPopupState = {
6
+ open: boolean;
7
+ /** `"none"` while the popup is placed over the trigger (`alignItemWithTrigger`). */
8
+ side: SelectSide | "none";
9
+ align: SelectAlign;
10
+ };
11
+ export type SelectPositionerState = SelectPopupState & {
12
+ /** Whether the trigger the popup is placed against is scrolled out of view. */
13
+ anchorHidden: boolean;
14
+ };
15
+ export type SelectArrowState = SelectPopupState & {
16
+ /** Whether the arrow can't point at the center of the trigger. */
17
+ uncentered: boolean;
18
+ };
19
+ export type SelectBackdropState = {
20
+ open: boolean;
21
+ };
22
+ /** The element focused when the popup closes. See `AutocompleteFocusTarget`. */
23
+ export type SelectFocusTarget = AutocompleteFocusTarget;
24
+ /** Computes an offset from the popup's placement and the sizes of the trigger and the popup. */
25
+ export type SelectOffsetFunction = AutocompleteOffsetFunction;
26
+ /** How the popup avoids the edges of `collisionBoundary`. */
27
+ export type SelectCollisionAvoidance = AutocompleteCollisionAvoidance;
28
+ type Rect = {
29
+ x: number;
30
+ y: number;
31
+ width: number;
32
+ height: number;
33
+ };
34
+ type BaseSelectPopupProps = ComponentProps<"div"> & {
35
+ render?: RenderProp<"div", SelectPopupState>;
36
+ /** The element focused when the popup closes. Defaults to the trigger. */
37
+ finalFocus?: SelectFocusTarget;
38
+ /** Where the popup is portaled to. Defaults to `<body>`. */
39
+ container?: HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null;
40
+ /**
41
+ * Places the popup over the trigger, with the selected item on top of the value, like a native `<select>`.
42
+ * The popup then has `data-side="none"`, and `side`, `align` and their offsets don't apply.
43
+ * Touch input and too little space fall back to a regular placement. Set to `false` to always place it beside the trigger.
44
+ * @default true
45
+ */
46
+ alignItemWithTrigger?: boolean;
47
+ /** The element the popup is placed against. Defaults to the trigger. */
48
+ anchor?: Element | RefObject<Element | null> | (() => Element | null) | null;
49
+ /** @default "absolute" */
50
+ positionMethod?: "absolute" | "fixed";
51
+ /** @default "bottom" */
52
+ side?: SelectSide;
53
+ /** Distance from the trigger in pixels. @default 0 */
54
+ sideOffset?: number | SelectOffsetFunction;
55
+ /** @default "center" */
56
+ align?: SelectAlign;
57
+ /** Shift along the side in pixels. @default 0 */
58
+ alignOffset?: number | SelectOffsetFunction;
59
+ /** @default "clipping-ancestors" */
60
+ collisionBoundary?: "clipping-ancestors" | Element | Element[] | Rect;
61
+ /** Space kept from the boundary's edges, in pixels. @default 5 */
62
+ collisionPadding?: number | {
63
+ top?: number;
64
+ right?: number;
65
+ bottom?: number;
66
+ left?: number;
67
+ };
68
+ collisionAvoidance?: SelectCollisionAvoidance;
69
+ /** Keeps the popup in view while the trigger is scrolled out of view. */
70
+ sticky?: boolean;
71
+ /** Minimum distance between the arrow and the popup's corners, in pixels. @default 5 */
72
+ arrowPadding?: number;
73
+ /** Stops following the trigger when it moves (e.g. on scroll). */
74
+ disableAnchorTracking?: boolean;
75
+ /** Replaces the element that positions the popup. Give it e.g. a `z-index`. */
76
+ renderPositioner?: RenderProp<"div", SelectPositionerState>;
77
+ /** Renders a backdrop under the popup. */
78
+ backdrop?: boolean;
79
+ /** A `className` on the element replaces the kit's conflicting classes. */
80
+ renderBackdrop?: RenderProp<"div", SelectBackdropState>;
81
+ /** The arrow's content (e.g. an `<svg>`). The arrow is rendered when this or `renderArrow` is given. */
82
+ arrow?: ReactNode;
83
+ renderArrow?: RenderProp<"div", SelectArrowState>;
84
+ };
85
+ /**
86
+ * The floating container of the list, with its portal, positioner and an optional backdrop and arrow.
87
+ * At least as wide as the trigger. Renders a `<div>`.
88
+ */
89
+ declare const BaseSelectPopup: ({ container, alignItemWithTrigger, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, collisionAvoidance, sticky, arrowPadding, disableAnchorTracking, renderPositioner, backdrop, renderBackdrop, arrow, renderArrow, className, children, ...otherProps }: BaseSelectPopupProps) => import("react").JSX.Element;
90
+ export { BaseSelectPopup as default };
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { cn } from "cn";
4
+ import { splitClassName } from "../../utils/split-class-name.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/form/BaseSelectPopup.tsx
7
+ /**
8
+ * The floating container of the list, with its portal, positioner and an optional backdrop and arrow.
9
+ * At least as wide as the trigger. Renders a `<div>`.
10
+ */
11
+ const BaseSelectPopup = ({ container, alignItemWithTrigger, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, collisionAvoidance, sticky, arrowPadding, disableAnchorTracking, renderPositioner, backdrop = false, renderBackdrop, arrow, renderArrow, className, children, ...otherProps }) => {
12
+ const backdropElement = splitClassName(renderBackdrop);
13
+ return /* @__PURE__ */ jsxs(Select.Portal, {
14
+ container,
15
+ children: [backdrop && /* @__PURE__ */ jsx(Select.Backdrop, {
16
+ render: backdropElement.render,
17
+ className: cn("fixed inset-0", backdropElement.className)
18
+ }), /* @__PURE__ */ jsx(Select.Positioner, {
19
+ alignItemWithTrigger,
20
+ anchor,
21
+ positionMethod,
22
+ side,
23
+ sideOffset,
24
+ align,
25
+ alignOffset,
26
+ collisionBoundary,
27
+ collisionPadding,
28
+ collisionAvoidance,
29
+ sticky,
30
+ arrowPadding,
31
+ disableAnchorTracking,
32
+ render: renderPositioner,
33
+ className: "outline-none select-none",
34
+ children: /* @__PURE__ */ jsxs(Select.Popup, {
35
+ ...otherProps,
36
+ className: cn("relative", "min-w-(--anchor-width)", "max-w-(--available-width)", "origin-(--transform-origin)", "outline-none", "transition-[opacity,scale]", "duration-150", "data-ending-style:scale-95", "data-ending-style:opacity-0", "data-starting-style:scale-95", "data-starting-style:opacity-0", "data-[side=none]:data-starting-style:scale-100", "data-[side=none]:data-starting-style:opacity-100", "data-[side=none]:data-starting-style:transition-none", className),
37
+ children: [(typeof arrow !== "undefined" || renderArrow) && /* @__PURE__ */ jsx(Select.Arrow, {
38
+ render: renderArrow,
39
+ children: arrow
40
+ }), children]
41
+ })
42
+ })]
43
+ });
44
+ };
45
+ export { BaseSelectPopup as default };
@@ -0,0 +1,15 @@
1
+ import { SelectScrollArrowState } from "./selectTypes.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ type BaseSelectScrollDownArrowProps = ComponentProps<"div"> & {
5
+ render?: RenderProp<"div", SelectScrollArrowState>;
6
+ /** Keeps the arrow in the DOM while the list can't scroll down. */
7
+ keepMounted?: boolean;
8
+ };
9
+ /**
10
+ * Scrolls the list down while the pointer rests on it. Only rendered while the list can scroll down.
11
+ * Put it in `Popup`, next to `List`. Renders a `<div>` pinned to the popup's bottom edge,
12
+ * hidden from assistive technology. Bring your own icon as children: there's none by default.
13
+ */
14
+ declare const BaseSelectScrollDownArrow: ({ className, children, render, ...otherProps }: BaseSelectScrollDownArrowProps) => import("react").JSX.Element;
15
+ export { BaseSelectScrollDownArrow as default };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/form/BaseSelectScrollDownArrow.tsx
6
+ /**
7
+ * Scrolls the list down while the pointer rests on it. Only rendered while the list can scroll down.
8
+ * Put it in `Popup`, next to `List`. Renders a `<div>` pinned to the popup's bottom edge,
9
+ * hidden from assistive technology. Bring your own icon as children: there's none by default.
10
+ */
11
+ const BaseSelectScrollDownArrow = ({ className, children = null, render, ...otherProps }) => /* @__PURE__ */ jsx(Select.ScrollDownArrow, {
12
+ ...otherProps,
13
+ render,
14
+ className: cn("bottom-0 left-0 z-1 flex w-full cursor-default items-center justify-center", className),
15
+ children
16
+ });
17
+ export { BaseSelectScrollDownArrow as default };
@@ -0,0 +1,15 @@
1
+ import { SelectScrollArrowState } from "./selectTypes.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ type BaseSelectScrollUpArrowProps = ComponentProps<"div"> & {
5
+ render?: RenderProp<"div", SelectScrollArrowState>;
6
+ /** Keeps the arrow in the DOM while the list can't scroll up. */
7
+ keepMounted?: boolean;
8
+ };
9
+ /**
10
+ * Scrolls the list up while the pointer rests on it. Only rendered while the list can scroll up.
11
+ * Put it in `Popup`, next to `List`. Renders a `<div>` pinned to the popup's top edge,
12
+ * hidden from assistive technology. Bring your own icon as children: there's none by default.
13
+ */
14
+ declare const BaseSelectScrollUpArrow: ({ className, children, render, ...otherProps }: BaseSelectScrollUpArrowProps) => import("react").JSX.Element;
15
+ export { BaseSelectScrollUpArrow as default };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/form/BaseSelectScrollUpArrow.tsx
6
+ /**
7
+ * Scrolls the list up while the pointer rests on it. Only rendered while the list can scroll up.
8
+ * Put it in `Popup`, next to `List`. Renders a `<div>` pinned to the popup's top edge,
9
+ * hidden from assistive technology. Bring your own icon as children: there's none by default.
10
+ */
11
+ const BaseSelectScrollUpArrow = ({ className, children = null, render, ...otherProps }) => /* @__PURE__ */ jsx(Select.ScrollUpArrow, {
12
+ ...otherProps,
13
+ render,
14
+ className: cn("top-0 left-0 z-1 flex w-full cursor-default items-center justify-center", className),
15
+ children
16
+ });
17
+ export { BaseSelectScrollUpArrow as default };
@@ -0,0 +1,16 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ export type SelectSeparatorState = {
4
+ orientation: "horizontal" | "vertical";
5
+ };
6
+ type BaseSelectSeparatorProps = ComponentProps<"div"> & {
7
+ render?: RenderProp<"div", SelectSeparatorState>;
8
+ /** @default "horizontal" */
9
+ orientation?: "horizontal" | "vertical";
10
+ };
11
+ /**
12
+ * A line between items or groups. Renders a `<div>` with `data-orientation`,
13
+ * and `role="presentation"` (a listbox can't hold separators).
14
+ */
15
+ declare const BaseSelectSeparator: (props: BaseSelectSeparatorProps) => import("react").JSX.Element;
16
+ export { BaseSelectSeparator as default };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseSelectSeparator.tsx
5
+ /**
6
+ * A line between items or groups. Renders a `<div>` with `data-orientation`,
7
+ * and `role="presentation"` (a listbox can't hold separators).
8
+ */
9
+ const BaseSelectSeparator = (props) => /* @__PURE__ */ jsx(Select.Separator, { ...props });
10
+ export { BaseSelectSeparator as default };
@@ -0,0 +1,17 @@
1
+ import { InputSize } from "./inputSizes.js";
2
+ import { SelectTriggerState } from "./selectTypes.js";
3
+ import { RenderProp } from "../../utils/render.js";
4
+ import { ComponentProps } from "react";
5
+ type BaseSelectTriggerProps = Omit<ComponentProps<"button">, "value"> & {
6
+ /** The same sizes as `BaseInput`. */
7
+ size?: InputSize;
8
+ render?: RenderProp<"button", SelectTriggerState>;
9
+ /** Set to `false` when `render` doesn't render a `<button>`. */
10
+ nativeButton?: boolean;
11
+ };
12
+ /**
13
+ * The button that shows the value and opens the popup. Renders a `<button>`, sized like `BaseInput`,
14
+ * with `data-popup-open` while the popup is open and `data-placeholder` while nothing is selected.
15
+ */
16
+ declare const BaseSelectTrigger: ({ size, className, ...otherProps }: BaseSelectTriggerProps) => import("react").JSX.Element;
17
+ export { BaseSelectTrigger as default };
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { cn } from "cn";
4
+ import { inputBaseClasses, inputSizeClasses } from "./inputSizes.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ // src/components/form/BaseSelectTrigger.tsx
7
+ /**
8
+ * The button that shows the value and opens the popup. Renders a `<button>`, sized like `BaseInput`,
9
+ * with `data-popup-open` while the popup is open and `data-placeholder` while nothing is selected.
10
+ */
11
+ const BaseSelectTrigger = ({ size = "md", className, ...otherProps }) => /* @__PURE__ */ jsx(Select.Trigger, {
12
+ ...otherProps,
13
+ className: cn("flex cursor-default items-center justify-between gap-2 text-left select-none", inputSizeClasses(size), inputBaseClasses, className)
14
+ });
15
+ export { BaseSelectTrigger as default };
@@ -0,0 +1,21 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps, ReactNode } from "react";
3
+ export type SelectValueState = {
4
+ /** The selected value (an array with `multiple`), `null` when nothing is selected. */
5
+ value: unknown;
6
+ /** Whether nothing is selected, so the placeholder shows. */
7
+ placeholder: boolean;
8
+ };
9
+ type BaseSelectValueProps<Value> = Omit<ComponentProps<"span">, "children"> & {
10
+ render?: RenderProp<"span", SelectValueState>;
11
+ /** Shown while nothing is selected. */
12
+ placeholder?: ReactNode;
13
+ /**
14
+ * Shown as is, or a function of the selected value.
15
+ * Without children, renders the selected item's label (from `items`, or the item's text).
16
+ */
17
+ children?: ReactNode | ((value: Value) => ReactNode);
18
+ };
19
+ /** The selected value's label, inside the trigger. Renders a `<span>`, with `data-placeholder` while nothing is selected. */
20
+ declare const BaseSelectValue: <Value>({ className, ...otherProps }: BaseSelectValueProps<Value>) => import("react").JSX.Element;
21
+ export { BaseSelectValue as default };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { Select } from "@base-ui/react/select";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/form/BaseSelectValue.tsx
6
+ /** The selected value's label, inside the trigger. Renders a `<span>`, with `data-placeholder` while nothing is selected. */
7
+ const BaseSelectValue = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Select.Value, {
8
+ ...otherProps,
9
+ className: cn("min-w-0 flex-1 truncate", className)
10
+ });
11
+ export { BaseSelectValue as default };
@@ -16,6 +16,14 @@ import { AutocompleteArrowState, AutocompleteBackdropState, AutocompleteCollisio
16
16
  import { AutocompleteSeparatorState } from "./BaseAutocompleteSeparator.js";
17
17
  import { InputSize } from "./inputSizes.js";
18
18
  import BaseFieldset, { FieldsetState } from "./BaseFieldset.js";
19
+ import _default$1, { SelectActions, SelectItemGroup, SelectLabeledItem } from "./BaseSelect.js";
20
+ import { SelectAlign, SelectInteractionType, SelectScrollArrowState, SelectSide, SelectTriggerState } from "./selectTypes.js";
21
+ import { SelectIconState } from "./BaseSelectIcon.js";
22
+ import { SelectItemState } from "./BaseSelectItem.js";
23
+ import { SelectItemIndicatorState } from "./BaseSelectItemIndicator.js";
24
+ import { SelectArrowState, SelectBackdropState, SelectCollisionAvoidance, SelectFocusTarget, SelectOffsetFunction, SelectPopupState, SelectPositionerState } from "./BaseSelectPopup.js";
25
+ import { SelectSeparatorState } from "./BaseSelectSeparator.js";
26
+ import { SelectValueState } from "./BaseSelectValue.js";
19
27
  import BaseRadioGroup, { RadioGroupState } from "./BaseRadioGroup.js";
20
28
  import BaseRadio, { RadioState } from "./BaseRadio.js";
21
- export { type AutocompleteActions, type AutocompleteAlign, type AutocompleteArrowState, type AutocompleteBackdropState, type AutocompleteClearState, type AutocompleteCollisionAvoidance, type AutocompleteFilter, type AutocompleteFocusTarget, type AutocompleteHighlightReason, type AutocompleteInputState, type AutocompleteInteractionType, type AutocompleteItemGroup, type AutocompleteItemState, type AutocompleteListState, type AutocompleteOffsetFunction, type AutocompletePopupState, type AutocompletePositionerState, type AutocompleteSeparatorState, type AutocompleteSide, _default as BaseAutocomplete, BaseCheckbox, BaseCheckboxGroup, BaseFieldset, BaseForm, BaseFormField, BaseInput, BaseRadio, BaseRadioGroup, BaseSwitch, type CheckboxGroupState, type CheckboxState, type DisplayedFormMessage, type FieldConstraints, type FieldState, type FieldsetState, type InputSize, type MessageFormatter, type RadioGroupState, type RadioState, type SwitchState, type UseAutocompleteFilterOptions, useAutocompleteFilter, useFormMessages };
29
+ export { type AutocompleteActions, type AutocompleteAlign, type AutocompleteArrowState, type AutocompleteBackdropState, type AutocompleteClearState, type AutocompleteCollisionAvoidance, type AutocompleteFilter, type AutocompleteFocusTarget, type AutocompleteHighlightReason, type AutocompleteInputState, type AutocompleteInteractionType, type AutocompleteItemGroup, type AutocompleteItemState, type AutocompleteListState, type AutocompleteOffsetFunction, type AutocompletePopupState, type AutocompletePositionerState, type AutocompleteSeparatorState, type AutocompleteSide, _default as BaseAutocomplete, BaseCheckbox, BaseCheckboxGroup, BaseFieldset, BaseForm, BaseFormField, BaseInput, BaseRadio, BaseRadioGroup, _default$1 as BaseSelect, BaseSwitch, type CheckboxGroupState, type CheckboxState, type DisplayedFormMessage, type FieldConstraints, type FieldState, type FieldsetState, type InputSize, type MessageFormatter, type RadioGroupState, type RadioState, type SelectActions, type SelectAlign, type SelectArrowState, type SelectBackdropState, type SelectCollisionAvoidance, type SelectFocusTarget, type SelectIconState, type SelectInteractionType, type SelectItemGroup, type SelectItemIndicatorState, type SelectItemState, type SelectLabeledItem, type SelectOffsetFunction, type SelectPopupState, type SelectPositionerState, type SelectScrollArrowState, type SelectSeparatorState, type SelectSide, type SelectTriggerState, type SelectValueState, type SwitchState, type UseAutocompleteFilterOptions, useAutocompleteFilter, useFormMessages };
@@ -8,6 +8,7 @@ import useFormMessages from "./useFormMessages.js";
8
8
  import BaseAutocomplete_default from "./BaseAutocomplete.js";
9
9
  import useAutocompleteFilter from "./useAutocompleteFilter.js";
10
10
  import BaseFieldset from "./BaseFieldset.js";
11
+ import BaseSelect_default from "./BaseSelect.js";
11
12
  import BaseRadioGroup from "./BaseRadioGroup.js";
12
13
  import BaseRadio from "./BaseRadio.js";
13
- export { BaseAutocomplete_default as BaseAutocomplete, BaseCheckbox, BaseCheckboxGroup, BaseFieldset, BaseForm, BaseFormField, BaseInput, BaseRadio, BaseRadioGroup, BaseSwitch, useAutocompleteFilter, useFormMessages };
14
+ export { BaseAutocomplete_default as BaseAutocomplete, BaseCheckbox, BaseCheckboxGroup, BaseFieldset, BaseForm, BaseFormField, BaseInput, BaseRadio, BaseRadioGroup, BaseSelect_default as BaseSelect, BaseSwitch, useAutocompleteFilter, useFormMessages };
@@ -0,0 +1,27 @@
1
+ import { FieldState } from "./BaseFormField.js";
2
+ import { AutocompleteAlign, AutocompleteInteractionType, AutocompleteSide } from "./autocompleteTypes.js";
3
+ /** The side of the trigger the popup is placed on. */
4
+ export type SelectSide = AutocompleteSide;
5
+ /** How the popup is aligned along its side. */
6
+ export type SelectAlign = AutocompleteAlign;
7
+ /** How the popup was opened or closed. Empty when it's unknown (e.g. opened from code). */
8
+ export type SelectInteractionType = AutocompleteInteractionType;
9
+ /** State of the trigger. */
10
+ export type SelectTriggerState = FieldState & {
11
+ open: boolean;
12
+ readOnly: boolean;
13
+ /** The side the popup is placed on, `null` while it's closed. */
14
+ popupSide: SelectSide | null;
15
+ /** The selected value (an array with `multiple`), `null` when nothing is selected. */
16
+ value: unknown;
17
+ /** Whether nothing is selected, so the placeholder shows. */
18
+ placeholder: boolean;
19
+ };
20
+ /** State of the scroll arrows. */
21
+ export type SelectScrollArrowState = {
22
+ direction: "up" | "down";
23
+ /** Whether the list can scroll in the arrow's direction. */
24
+ visible: boolean;
25
+ /** The side the popup is placed on, `"none"` over the trigger. */
26
+ side: SelectSide | "none";
27
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -154,7 +154,7 @@ declare const _default: (<Payload>(props: BaseMenuProps<Payload>) => import("rea
154
154
  closeDelay?: number;
155
155
  nativeButton?: boolean;
156
156
  }) => import("react").JSX.Element;
157
- Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "value" | "defaultValue"> & {
157
+ Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "value"> & {
158
158
  render?: RenderProp<"input", MenuInputState>;
159
159
  }) => import("react").JSX.Element;
160
160
  Clear: (props: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
@@ -169,7 +169,7 @@ declare const _default: (({ className, ...otherProps }: BaseMenubarProps) => imp
169
169
  closeDelay?: number;
170
170
  nativeButton?: boolean;
171
171
  }) => import("react").JSX.Element;
172
- Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "value" | "defaultValue"> & {
172
+ Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "value"> & {
173
173
  render?: RenderProp<"input", MenuInputState>;
174
174
  }) => import("react").JSX.Element;
175
175
  Clear: (props: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omer-x/tailwind-ui-kit",
3
- "version": "1.0.0-alpha.40",
3
+ "version": "1.0.0-alpha.41",
4
4
  "description": "Tailwind CSS-based React component library for building user interfaces",
5
5
  "keywords": [
6
6
  "tailwind",