@omer-x/tailwind-ui-kit 1.0.0-alpha.40 → 1.0.0-alpha.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +229 -0
- package/dist/components/form/BaseAutocomplete.d.ts +1 -1
- package/dist/components/form/BaseSelect.d.ts +165 -0
- package/dist/components/form/BaseSelect.js +41 -0
- package/dist/components/form/BaseSelectGroup.d.ts +8 -0
- package/dist/components/form/BaseSelectGroup.js +7 -0
- package/dist/components/form/BaseSelectGroupLabel.d.ts +8 -0
- package/dist/components/form/BaseSelectGroupLabel.js +7 -0
- package/dist/components/form/BaseSelectIcon.d.ts +14 -0
- package/dist/components/form/BaseSelectIcon.js +10 -0
- package/dist/components/form/BaseSelectItem.d.ts +24 -0
- package/dist/components/form/BaseSelectItem.js +14 -0
- package/dist/components/form/BaseSelectItemIndicator.d.ts +16 -0
- package/dist/components/form/BaseSelectItemIndicator.js +10 -0
- package/dist/components/form/BaseSelectItemText.d.ts +8 -0
- package/dist/components/form/BaseSelectItemText.js +7 -0
- package/dist/components/form/BaseSelectLabel.d.ts +12 -0
- package/dist/components/form/BaseSelectLabel.js +10 -0
- package/dist/components/form/BaseSelectList.d.ts +8 -0
- package/dist/components/form/BaseSelectList.js +11 -0
- package/dist/components/form/BaseSelectPopup.d.ts +90 -0
- package/dist/components/form/BaseSelectPopup.js +45 -0
- package/dist/components/form/BaseSelectScrollDownArrow.d.ts +15 -0
- package/dist/components/form/BaseSelectScrollDownArrow.js +17 -0
- package/dist/components/form/BaseSelectScrollUpArrow.d.ts +15 -0
- package/dist/components/form/BaseSelectScrollUpArrow.js +17 -0
- package/dist/components/form/BaseSelectSeparator.d.ts +16 -0
- package/dist/components/form/BaseSelectSeparator.js +10 -0
- package/dist/components/form/BaseSelectTrigger.d.ts +17 -0
- package/dist/components/form/BaseSelectTrigger.js +15 -0
- package/dist/components/form/BaseSelectValue.d.ts +21 -0
- package/dist/components/form/BaseSelectValue.js +11 -0
- package/dist/components/form/index.d.ts +9 -1
- package/dist/components/form/index.js +2 -1
- package/dist/components/form/selectTypes.d.ts +27 -0
- package/dist/components/form/selectTypes.js +1 -0
- package/dist/components/overlay/BaseTooltip.d.ts +92 -0
- package/dist/components/overlay/BaseTooltip.js +24 -0
- package/dist/components/overlay/BaseTooltipArrow.d.ts +20 -0
- package/dist/components/overlay/BaseTooltipArrow.js +10 -0
- package/dist/components/overlay/BaseTooltipPopup.d.ts +106 -0
- package/dist/components/overlay/BaseTooltipPopup.js +38 -0
- package/dist/components/overlay/BaseTooltipTrigger.d.ts +31 -0
- package/dist/components/overlay/BaseTooltipTrigger.js +14 -0
- package/dist/components/overlay/BaseTooltipViewport.d.ts +20 -0
- package/dist/components/overlay/BaseTooltipViewport.js +11 -0
- package/dist/components/overlay/createTooltipHandle.d.ts +30 -0
- package/dist/components/overlay/createTooltipHandle.js +27 -0
- package/dist/components/overlay/index.d.ts +7 -0
- package/dist/components/overlay/index.js +3 -0
- package/dist/components/providers/TooltipProvider.d.ts +19 -0
- package/dist/components/providers/TooltipProvider.js +10 -0
- package/dist/components/providers/index.d.ts +2 -0
- package/dist/components/providers/index.js +1 -0
- package/package.json +9 -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`
|
|
@@ -1023,6 +1131,127 @@ import { BaseMenubar } from "@omer-x/tailwind-ui-kit/menu";
|
|
|
1023
1131
|
| `loopFocus` | `boolean` | `true` | Arrow keys wrap from the last trigger to the first |
|
|
1024
1132
|
| `render` | `RenderProp<"div", MenubarState>` | | The state is `{ orientation, modal, hasSubmenuOpen }` |
|
|
1025
1133
|
|
|
1134
|
+
### `@omer-x/tailwind-ui-kit/overlay`
|
|
1135
|
+
|
|
1136
|
+
#### `BaseTooltip`
|
|
1137
|
+
|
|
1138
|
+
A Base UI [`Tooltip`](https://base-ui.com/react/components/tooltip): a popup that shows a hint when its trigger is hovered or focused. `Popup` brings its portal and positioner, so a tooltip needs no more than this:
|
|
1139
|
+
|
|
1140
|
+
```tsx
|
|
1141
|
+
import { BaseTooltip } from "@omer-x/tailwind-ui-kit/overlay";
|
|
1142
|
+
|
|
1143
|
+
<BaseTooltip>
|
|
1144
|
+
<BaseTooltip.Trigger render={<Button />}>Save</BaseTooltip.Trigger>
|
|
1145
|
+
<BaseTooltip.Popup className="rounded bg-neutral-900 px-2 py-1 text-xs text-white" sideOffset={8}>
|
|
1146
|
+
Saves your changes
|
|
1147
|
+
<BaseTooltip.Arrow className="size-2 rotate-45 bg-neutral-900 data-[side=top]:-bottom-1 data-[side=bottom]:-top-1" />
|
|
1148
|
+
</BaseTooltip.Popup>
|
|
1149
|
+
</BaseTooltip>
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
The parts use dot notation, so build tooltips in a `"use client"` file. A tooltip is only a visual hint: it isn't announced to screen readers, so keep the trigger's accessible name (text or `aria-label`) meaningful without it.
|
|
1153
|
+
|
|
1154
|
+
| Part | Renders | Description |
|
|
1155
|
+
|------|---------|-------------|
|
|
1156
|
+
| `BaseTooltip` | nothing | Groups the parts and holds the open state |
|
|
1157
|
+
| `BaseTooltip.Trigger` | `<button>` | Opens the tooltip on hover (after `delay`) or keyboard focus. `data-popup-open` while its tooltip is open, `data-trigger-disabled` when `disabled` |
|
|
1158
|
+
| `BaseTooltip.Popup` | `<div>` | The tooltip, portaled and placed against the trigger, with scale and fade transitions (skipped while `data-instant`) |
|
|
1159
|
+
| `BaseTooltip.Arrow` | `<div>` | An arrow pointing at the trigger, inside `Popup`. `data-side`, `data-align`, `data-uncentered`. Draw it yourself |
|
|
1160
|
+
| `BaseTooltip.Viewport` | `<div>` | Animates the content when one tooltip is opened by several triggers and its content depends on the trigger. `data-activation-direction`, `data-transitioning` |
|
|
1161
|
+
| `BaseTooltip.Provider` | nothing | The same component as [`TooltipProvider`](#tooltipprovider) |
|
|
1162
|
+
|
|
1163
|
+
`BaseTooltip` props:
|
|
1164
|
+
|
|
1165
|
+
| Prop | Type | Default | Description |
|
|
1166
|
+
|------|------|---------|-------------|
|
|
1167
|
+
| `open` / `defaultOpen` | `boolean` | `false` | Controlled / initial open state |
|
|
1168
|
+
| `onOpenChange` | `(open, event) => void` | | Called with the new state and the DOM event that changed it (`undefined` when changed from code) |
|
|
1169
|
+
| `onOpenChangeComplete` | `(open) => void` | | Called after the open or close transition ends |
|
|
1170
|
+
| `disableHoverablePopup` | `boolean` | `false` | Closes the tooltip as soon as the pointer leaves the trigger, even onto the popup |
|
|
1171
|
+
| `trackCursorAxis` | `"none" \| "x" \| "y" \| "both"` | `"none"` | Makes the popup follow the pointer along this axis |
|
|
1172
|
+
| `disabled` | `boolean` | `false` | No trigger opens the tooltip |
|
|
1173
|
+
| `actionsRef` | `RefObject<TooltipActions>` | | `actionsRef.current?.close()` |
|
|
1174
|
+
| `handle` | `TooltipHandle<Payload>` | | Connects triggers outside the tooltip and opens it from code (see below) |
|
|
1175
|
+
| `triggerId` / `defaultTriggerId` | `string \| null` | | The trigger a controlled / initially open tooltip belongs to |
|
|
1176
|
+
| `children` | `ReactNode \| ({ payload }) => ReactNode` | | The parts, or a function that gets the payload of the trigger that opened the tooltip |
|
|
1177
|
+
|
|
1178
|
+
`BaseTooltip.Trigger` props:
|
|
1179
|
+
|
|
1180
|
+
| Prop | Type | Default | Description |
|
|
1181
|
+
|------|------|---------|-------------|
|
|
1182
|
+
| `delay` | `number` | `600` | The wait before opening on hover, in ms. Overrides `TooltipProvider`'s |
|
|
1183
|
+
| `closeDelay` | `number` | `0` | The wait before closing, in ms. Overrides `TooltipProvider`'s |
|
|
1184
|
+
| `closeOnClick` | `boolean` | `true` | Closes the tooltip when the trigger is clicked |
|
|
1185
|
+
| `disabled` | `boolean` | `false` | Stops this trigger from opening the tooltip. The element stays enabled: to disable the button too, pass `disabled` to the `render` element |
|
|
1186
|
+
| `handle` / `payload` | `TooltipHandle<Payload>` / `Payload` | | Connects a trigger outside its `BaseTooltip`, and the payload it passes (see below) |
|
|
1187
|
+
| `render` | `RenderProp<"button", TooltipTriggerState>` | | The state is `{ open }`. Use it to render your themed button, or any other element |
|
|
1188
|
+
|
|
1189
|
+
`BaseTooltip.Popup` props:
|
|
1190
|
+
|
|
1191
|
+
| Prop | Type | Default | Description |
|
|
1192
|
+
|------|------|---------|-------------|
|
|
1193
|
+
| `side` / `align` | `TooltipSide` / `TooltipAlign` | `"top"` / `"center"` | Where the popup sits against the trigger (`"top"`, `"bottom"`, `"left"`, `"right"`, `"inline-start"`, `"inline-end"` / `"start"`, `"center"`, `"end"`). It flips when there's no room |
|
|
1194
|
+
| `sideOffset` / `alignOffset` | `number \| TooltipOffsetFunction` | | Offsets from the anchor, in pixels, or a function of the placement and sizes |
|
|
1195
|
+
| `collisionPadding` | `number \| { top, right, bottom, left }` | `5` | Space kept from the viewport edges |
|
|
1196
|
+
| `collisionBoundary` / `collisionAvoidance` | | `"clipping-ancestors"` | The area the popup stays inside, and how it avoids its edges (flip or shift) |
|
|
1197
|
+
| `anchor` | `Element \| RefObject \| () => Element \| null` | the trigger | The element the popup is placed against |
|
|
1198
|
+
| `disableAnchorTracking` | `boolean` | `false` | Stops following the anchor when it moves |
|
|
1199
|
+
| `arrowPadding` | `number` | `5` | Minimum distance between an `Arrow` and the popup's corners |
|
|
1200
|
+
| `sticky` | `boolean` | `false` | Stays in view while the anchor scrolls away |
|
|
1201
|
+
| `positionMethod` | `"absolute" \| "fixed"` | `"absolute"` | Use `"fixed"` when the anchor is inside a fixed container |
|
|
1202
|
+
| `positionerClassName` / `renderPositioner` | `string` / `RenderProp<"div", TooltipPositionerState>` | | Style or replace the positioner, the `<div>` around the popup that places it (`z-50`) |
|
|
1203
|
+
| `container` | `HTMLElement \| ShadowRoot \| RefObject \| null` | `<body>` | Where the popup is portaled to |
|
|
1204
|
+
| `keepMounted` | `boolean` | `false` | Keeps the popup in the DOM while closed |
|
|
1205
|
+
| `render` | `RenderProp<"div", TooltipPopupState>` | | The state is `{ open, side, align, instant }` |
|
|
1206
|
+
|
|
1207
|
+
Data attributes: the popup has `data-open` / `data-closed`, `data-side`, `data-align` and `data-starting-style` / `data-ending-style` during transitions. `data-instant` is set when the transition should be skipped: `"delay"` (another tooltip was just open), `"focus"` (opened by keyboard focus) or `"dismiss"` (closed by Escape or a click). The popup's own transition is turned off then (`data-instant:transition-none`).
|
|
1208
|
+
|
|
1209
|
+
#### `createTooltipHandle`
|
|
1210
|
+
|
|
1211
|
+
Opens one tooltip from triggers anywhere on the page, or from code. Each trigger can pass a `payload`, which the tooltip's function children receive:
|
|
1212
|
+
|
|
1213
|
+
```tsx
|
|
1214
|
+
import { BaseTooltip, createTooltipHandle } from "@omer-x/tailwind-ui-kit/overlay";
|
|
1215
|
+
|
|
1216
|
+
const shortcutTooltip = createTooltipHandle<{ id: string, keys: string }>();
|
|
1217
|
+
|
|
1218
|
+
// triggers anywhere on the page
|
|
1219
|
+
<BaseTooltip.Trigger id={`shortcut-${s.id}`} handle={shortcutTooltip} payload={s} render={<Button />}>{s.label}</BaseTooltip.Trigger>
|
|
1220
|
+
|
|
1221
|
+
// one tooltip on the page
|
|
1222
|
+
<BaseTooltip handle={shortcutTooltip}>
|
|
1223
|
+
{({ payload }) => payload && (
|
|
1224
|
+
<BaseTooltip.Popup>{payload.keys}</BaseTooltip.Popup>
|
|
1225
|
+
)}
|
|
1226
|
+
</BaseTooltip>
|
|
1227
|
+
|
|
1228
|
+
// from code
|
|
1229
|
+
shortcutTooltip.open("shortcut-copy");
|
|
1230
|
+
```
|
|
1231
|
+
|
|
1232
|
+
A `TooltipHandle<Payload>` has `open(triggerId)`, `close()` and `isOpen`. Like `MenuHandle`, it has no `openWithPayload`: a tooltip is placed against its trigger, so `open` needs the `id` of a trigger with the same handle.
|
|
1233
|
+
|
|
1234
|
+
- Calls are **ignored while the tooltip isn't mounted**. Keep the `BaseTooltip` with the handle rendered.
|
|
1235
|
+
- Call them **from event handlers or effects, never during render**.
|
|
1236
|
+
|
|
1237
|
+
### `@omer-x/tailwind-ui-kit/providers`
|
|
1238
|
+
|
|
1239
|
+
#### `TooltipProvider`
|
|
1240
|
+
|
|
1241
|
+
Shares the hover delay between the tooltips inside it: once one tooltip is shown, the next one opens instantly. Place it once around your app (or a toolbar) in a `"use client"` file. It renders no element and is also available as `BaseTooltip.Provider`.
|
|
1242
|
+
|
|
1243
|
+
```tsx
|
|
1244
|
+
import { TooltipProvider } from "@omer-x/tailwind-ui-kit/providers";
|
|
1245
|
+
|
|
1246
|
+
<TooltipProvider delay={300}>{children}</TooltipProvider>
|
|
1247
|
+
```
|
|
1248
|
+
|
|
1249
|
+
| Prop | Type | Default | Description |
|
|
1250
|
+
|------|------|---------|-------------|
|
|
1251
|
+
| `delay` | `number` | `600` | The wait before opening a tooltip on hover, in ms. A trigger's own `delay` wins |
|
|
1252
|
+
| `closeDelay` | `number` | `0` | The wait before closing a tooltip, in ms. A trigger's own `closeDelay` wins |
|
|
1253
|
+
| `timeout` | `number` | `400` | A tooltip opened within this time after another one closed opens without a delay, in ms |
|
|
1254
|
+
|
|
1026
1255
|
### `@omer-x/tailwind-ui-kit/disclosure`
|
|
1027
1256
|
|
|
1028
1257
|
#### `BaseAccordion`
|
|
@@ -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>, "
|
|
111
|
+
Input: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "size" | "value" | "defaultValue"> & {
|
|
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 };
|