@omer-x/tailwind-ui-kit 1.0.0-alpha.31 → 1.0.0-alpha.33

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 (55) hide show
  1. package/README.md +138 -0
  2. package/dist/components/dialog/BaseDialogPopup.js +2 -15
  3. package/dist/components/form/BaseAutocomplete.d.ts +198 -0
  4. package/dist/components/form/BaseAutocomplete.js +49 -0
  5. package/dist/components/form/BaseAutocompleteClear.d.ts +18 -0
  6. package/dist/components/form/BaseAutocompleteClear.js +7 -0
  7. package/dist/components/form/BaseAutocompleteCollection.d.ts +8 -0
  8. package/dist/components/form/BaseAutocompleteCollection.js +7 -0
  9. package/dist/components/form/BaseAutocompleteEmpty.d.ts +11 -0
  10. package/dist/components/form/BaseAutocompleteEmpty.js +10 -0
  11. package/dist/components/form/BaseAutocompleteGroup.d.ts +10 -0
  12. package/dist/components/form/BaseAutocompleteGroup.js +7 -0
  13. package/dist/components/form/BaseAutocompleteGroupLabel.d.ts +8 -0
  14. package/dist/components/form/BaseAutocompleteGroupLabel.js +7 -0
  15. package/dist/components/form/BaseAutocompleteIcon.d.ts +8 -0
  16. package/dist/components/form/BaseAutocompleteIcon.js +7 -0
  17. package/dist/components/form/BaseAutocompleteInput.d.ts +12 -0
  18. package/dist/components/form/BaseAutocompleteInput.js +12 -0
  19. package/dist/components/form/BaseAutocompleteInputGroup.d.ts +9 -0
  20. package/dist/components/form/BaseAutocompleteInputGroup.js +11 -0
  21. package/dist/components/form/BaseAutocompleteItem.d.ts +20 -0
  22. package/dist/components/form/BaseAutocompleteItem.js +11 -0
  23. package/dist/components/form/BaseAutocompleteList.d.ts +14 -0
  24. package/dist/components/form/BaseAutocompleteList.js +11 -0
  25. package/dist/components/form/BaseAutocompletePopup.d.ts +111 -0
  26. package/dist/components/form/BaseAutocompletePopup.js +45 -0
  27. package/dist/components/form/BaseAutocompleteRow.d.ts +8 -0
  28. package/dist/components/form/BaseAutocompleteRow.js +7 -0
  29. package/dist/components/form/BaseAutocompleteSeparator.d.ts +13 -0
  30. package/dist/components/form/BaseAutocompleteSeparator.js +7 -0
  31. package/dist/components/form/BaseAutocompleteStatus.d.ts +11 -0
  32. package/dist/components/form/BaseAutocompleteStatus.js +10 -0
  33. package/dist/components/form/BaseAutocompleteTrigger.d.ts +11 -0
  34. package/dist/components/form/BaseAutocompleteTrigger.js +7 -0
  35. package/dist/components/form/BaseAutocompleteValue.d.ts +8 -0
  36. package/dist/components/form/BaseAutocompleteValue.js +7 -0
  37. package/dist/components/form/BaseCheckbox.d.ts +6 -1
  38. package/dist/components/form/BaseCheckbox.js +10 -3
  39. package/dist/components/form/BaseCheckboxGroup.d.ts +24 -0
  40. package/dist/components/form/BaseCheckboxGroup.js +20 -0
  41. package/dist/components/form/BaseFormField.d.ts +10 -1
  42. package/dist/components/form/BaseFormField.js +2 -2
  43. package/dist/components/form/BaseInput.d.ts +2 -1
  44. package/dist/components/form/BaseInput.js +2 -12
  45. package/dist/components/form/autocompleteTypes.d.ts +16 -0
  46. package/dist/components/form/autocompleteTypes.js +1 -0
  47. package/dist/components/form/index.d.ts +12 -2
  48. package/dist/components/form/index.js +4 -1
  49. package/dist/components/form/inputSizes.d.ts +11 -0
  50. package/dist/components/form/inputSizes.js +19 -0
  51. package/dist/components/form/useAutocompleteFilter.d.ts +19 -0
  52. package/dist/components/form/useAutocompleteFilter.js +12 -0
  53. package/dist/utils/split-class-name.d.ts +15 -0
  54. package/dist/utils/split-class-name.js +18 -0
  55. package/package.json +1 -1
package/README.md CHANGED
@@ -166,6 +166,7 @@ A Base UI [`Checkbox`](https://base-ui.com/react/components/checkbox) with its l
166
166
  | `renderIndicator` | `RenderProp<"span", CheckboxState>` | | Style the indicator that holds the icon |
167
167
  | `keepIndicatorMounted` | `boolean` | `false` | Keep the indicator in the DOM when unchecked (e.g. to animate it out) |
168
168
  | `indeterminate` | `boolean` | `false` | Show the mixed state (`aria-checked="mixed"`). It doesn't change `checked` |
169
+ | `parent` | `boolean` | `false` | Make it the "select all" checkbox of a `BaseCheckboxGroup` with `allValues`. It checks or clears the whole group, is indeterminate when only some are checked, and isn't submitted |
169
170
  | `value` | `string` | `"true"` | Submitted when checked |
170
171
  | `uncheckedValue` | `string` | `"false"` | Submitted when unchecked |
171
172
  | `onCheckedChange` | `(checked: boolean, event: Event) => void` | | Called with the new state and the DOM event that changed it |
@@ -184,6 +185,33 @@ Render functions get `CheckboxState`: `{ checked, disabled, readOnly, required,
184
185
  />
185
186
  ```
186
187
 
188
+ #### `BaseCheckboxGroup`
189
+
190
+ A Base UI [`Checkbox Group`](https://base-ui.com/react/components/checkbox-group): shared state for the checkboxes inside it. Its `name` is passed to every checkbox in the group, and each checked box submits its own `value` under that name, so the server reads them all with `formData.getAll(name)`. Checkboxes in a group never submit an unchecked value.
191
+
192
+ | Prop | Type | Default | Description |
193
+ |------|------|---------|-------------|
194
+ | `name` | `string` | | Submitted name of every checkbox in the group |
195
+ | `value` | `string[]` | | The `value`s of the checked boxes, when controlled |
196
+ | `defaultValue` | `string[]` | | The `value`s of the boxes checked at first |
197
+ | `onValueChange` | `(value: string[], event: Event) => void` | | Called with the new checked `value`s and the DOM event that changed it |
198
+ | `allValues` | `string[]` | | Every child `value`. Needed by a `BaseCheckbox` with `parent` ("select all") |
199
+ | `disabled` | `boolean` | | Disables every checkbox in the group |
200
+ | `className` | `string` | | Classes for the group `<div>` (default `flex flex-col gap-2`) |
201
+ | `render` | `RenderProp<"div", CheckboxGroupState>` | | Render another element for the group |
202
+ | …rest | | | `<div>` props. Give the group an accessible name with `aria-label` or `aria-labelledby` |
203
+
204
+ Render functions get `CheckboxGroupState`: `{ disabled }`. The group sets `data-disabled` when disabled.
205
+
206
+ With `BaseForm`'s `onlyDirty`, give the group an array default (`defaultValues={{ channels: ["email"] }}`). It is sent only when the set of checked values changed, and as an empty value when everything was unchecked.
207
+
208
+ ```tsx
209
+ <BaseCheckboxGroup name="channels" aria-label="Channels" defaultValue={["email"]}>
210
+ <BaseCheckbox value="email" label="Email" />
211
+ <BaseCheckbox value="sms" label="SMS" />
212
+ </BaseCheckboxGroup>
213
+ ```
214
+
187
215
  #### `BaseForm`
188
216
 
189
217
  A Base UI [`Form`](https://base-ui.com/react/components/form) connected to an action through React's `useActionState`. Actions are made with [`@omer-x/next-form-actions`](https://github.com/omermecitoglu/next-form-actions) (v2), which defines the result shape. Install it next to the kit:
@@ -309,6 +337,7 @@ A Base UI [`Field`](https://base-ui.com/react/components/field) made of a label,
309
337
  | `schema` | `ZodType` | Source of the HTML constraints applied to the control |
310
338
  | `label` | `string` | Label text. No label is rendered when omitted |
311
339
  | `control` | `RenderProp<"input", FieldState>` | The input to render, as Base UI's `Field.Control` (so it gets `aria-invalid`, `data-invalid`, … and is validated). Defaults to a plain `<input>`. Pass your themed input here |
340
+ | `children` | `(constraints: FieldConstraints) => ReactNode` | Renders a control that isn't a single `<input>` (e.g. [`BaseAutocomplete`](#baseautocomplete)) instead of `control`. Gets the constraints read from `schema` (`required`, `minLength`, …); pass on the ones the control supports. The control takes the field's `name` by itself |
312
341
  | `renderLabel` | `RenderProp<"label", FieldState>` | Style the label |
313
342
  | `renderErrors` | `RenderProp<"div", FieldState>` | Style client-side and server-side error messages. Each error is its own element |
314
343
  | `className` | `string` | Classes for the field root (a flex column by default) |
@@ -344,6 +373,115 @@ export const UserSchema = z.object({
344
373
 
345
374
  The browser can check only the rules that map to HTML attributes (`required`, `minLength`, `maxLength`, `min`, `max`, …). Refinements, transforms, cross-field rules and async checks such as "username taken" only run on the server, and come back as `fieldErrors`. Users can also bypass browser checks, so **the server action must always validate the full schema**. The client constraints only give earlier feedback.
346
375
 
376
+ #### `BaseAutocomplete`
377
+
378
+ A Base UI [`Autocomplete`](https://base-ui.com/react/components/autocomplete): a text input that suggests matching items as you type. The input is free text; choosing an item fills it in. A simple one needs no more than this:
379
+
380
+ ```tsx
381
+ import { BaseAutocomplete } from "@omer-x/tailwind-ui-kit/form";
382
+
383
+ <BaseAutocomplete items={fruits}>
384
+ <BaseAutocomplete.Input aria-label="Fruit" className="border border-neutral-300" />
385
+ <BaseAutocomplete.Popup sideOffset={4} className="rounded-md bg-white py-1 shadow-lg">
386
+ <BaseAutocomplete.Empty className="px-3 not-empty:py-1.5">No fruits found</BaseAutocomplete.Empty>
387
+ <BaseAutocomplete.List>
388
+ {(fruit: string) => (
389
+ <BaseAutocomplete.Item key={fruit} value={fruit} className="px-3 py-1.5 data-highlighted:bg-blue-600">
390
+ {fruit}
391
+ </BaseAutocomplete.Item>
392
+ )}
393
+ </BaseAutocomplete.List>
394
+ </BaseAutocomplete.Popup>
395
+ </BaseAutocomplete>
396
+ ```
397
+
398
+ The parts are reached with dot notation, which only works in client components. Build autocompletes in a `"use client"` file, e.g. your app's themed wrapper.
399
+
400
+ | Part | Renders | Description |
401
+ |------|---------|-------------|
402
+ | `BaseAutocomplete` | nothing | Groups the parts, holds the input's value and filters `items` |
403
+ | `.Input` | `<input>` | The text input. Takes `size` (`"lg" \| "md" \| "sm" \| "xs"`, default `"md"`), the same sizes as `BaseInput` |
404
+ | `.InputGroup` | `<div>` | Optional. Wraps the input with a trigger and a clear button (`relative flex items-center`). The popup is placed against it |
405
+ | `.Trigger` | `<button>` | Opens the popup. `data-popup-open` while it's open |
406
+ | `.Icon` | `<span>` | A decorative icon, hidden from assistive technology. Bring your own icon as children |
407
+ | `.Clear` | `<button>` | Clears the input. Only rendered while the input has a value (`keepMounted` keeps it) |
408
+ | `.Value` | nothing | The input's value, or a function of it, anywhere inside the root |
409
+ | `.Popup` | `<div>` | The floating container, portaled and positioned. As wide as the input, never taller than the space left (max `24rem`), with scale and fade transitions |
410
+ | `.Status` | `<div>` | A live region for screen readers ("Loading…", "12 results") |
411
+ | `.Empty` | `<div>` | Its children show only when no item matches. Always rendered (it's a live region): style it with `not-empty:` / `empty:` |
412
+ | `.List` | `<div>` | The scrollable list. Children can be a function that renders each filtered item (or group). `data-empty` when nothing matches |
413
+ | `.Item` | `<div>` | An option (`flex items-center gap-2`). `value` is the item. `data-highlighted`, `data-disabled` |
414
+ | `.Group` | `<div>` | A group of items. Pass the group's `items` to use `.Collection` inside |
415
+ | `.GroupLabel` | `<div>` | Names a group |
416
+ | `.Collection` | nothing | Renders the filtered items of the surrounding group with a function |
417
+ | `.Separator` | `<div>` | A `role="separator"` line, with `data-orientation` |
418
+ | `.Row` | `<div>` | A row of items when the root has `grid` |
419
+
420
+ Every part takes `className` and a `render` prop. Render functions get the part's state (`AutocompleteInputState`, `AutocompleteItemState`, `AutocompletePopupState`, …), which is also set as data attributes: `data-open`, `data-popup-side`, `data-list-empty`, `data-highlighted`, `data-side`, `data-align`, `data-starting-style`, … The input, input group and trigger also carry the field's state (`data-invalid`, `data-dirty`, `data-touched`, `data-filled`, `data-focused`).
421
+
422
+ `BaseAutocomplete` props:
423
+
424
+ | Prop | Type | Description |
425
+ |------|------|-------------|
426
+ | `items` | `Item[] \| { items: Item[] }[]` | The items, flat or in groups. Filtered by the input's value and passed to `List`'s function children |
427
+ | `filteredItems` | same as `items` | Items you filtered yourself, shown instead |
428
+ | `filter` | `(item, query, itemToString?) => boolean \| null` | Decides what matches. `null` turns filtering off. Defaults to a case-insensitive "contains" |
429
+ | `limit` | `number` | Shows at most this many matches |
430
+ | `mode` | `"list" \| "both" \| "inline" \| "none"` | `list` (default) filters; `both` also fills the input with the highlighted item; `inline` only fills; `none` does neither |
431
+ | `itemToStringValue` | `(item) => string` | Text of an object item. `{ value, label }` objects use `label` without it |
432
+ | `value` / `defaultValue` | `string` | The input's value, controlled / uncontrolled |
433
+ | `onValueChange` | `(value, event) => void` | Called with the new value and the DOM event (none when changed from code) |
434
+ | `open` / `defaultOpen` | `boolean` | The popup's state |
435
+ | `onOpenChange` | `(open, event) => void` | Called with the new state and the DOM event |
436
+ | `onOpenChangeComplete` | `(open) => void` | Called after the transition ends |
437
+ | `openOnInputClick` | `boolean` | Opens the popup on click |
438
+ | `autoHighlight` | `boolean \| "always"` | Highlights the first match while typing (`"always"`: also on open) |
439
+ | `keepHighlight` | `boolean` | Keeps the highlight when the pointer leaves the list |
440
+ | `highlightItemOnHover` | `boolean` | Default `true`. `false` lets `:hover` and `data-highlighted` differ |
441
+ | `onItemHighlighted` | `(item, { reason, index }) => void` | `reason` is `"keyboard"`, `"pointer"` or `"none"` |
442
+ | `loopFocus` | `boolean` | Default `true`. Arrow keys wrap around the list |
443
+ | `submitOnItemClick` | `boolean` | Submits the form when an item is chosen (e.g. a search box) |
444
+ | `grid` | `boolean` | Items in `Row`s, navigated with all four arrow keys |
445
+ | `inline` | `boolean` | Renders the list in place, without a popup. Use with `open` |
446
+ | `modal` | `boolean` | Locks page scroll and outside pointer input while open |
447
+ | `virtualized` | `boolean` | For lists rendered by a virtualizer (give each item its `index`) |
448
+ | `locale` | `Intl.LocalesArgument` | Locale of the default filter |
449
+ | `name`, `form`, `id`, `required`, `disabled`, `readOnly` | | Form props. Inside `BaseFormField`, the field's `name` is used |
450
+ | `inputRef` | `Ref<HTMLInputElement>` | The hidden input used for validation |
451
+ | `actionsRef` | `RefObject<AutocompleteActions>` | `actionsRef.current?.close()` |
452
+
453
+ `BaseAutocomplete.Popup` props, besides `<div>` props:
454
+
455
+ | Prop | Description |
456
+ |------|-------------|
457
+ | `side`, `align` | Placement against the input (group). Default `"bottom"`, `"start"` |
458
+ | `sideOffset`, `alignOffset` | Offsets in pixels, or a function of the placement and sizes |
459
+ | `anchor`, `positionMethod`, `collisionBoundary`, `collisionPadding`, `collisionAvoidance`, `sticky`, `disableAnchorTracking` | Positioning control |
460
+ | `renderPositioner` | Replaces the element that positions the popup, e.g. `<div className="z-50" />` |
461
+ | `container`, `keepMounted` | Portal target (default `<body>`), and keeping the popup in the DOM while closed |
462
+ | `backdrop`, `renderBackdrop` | Renders a `fixed inset-0` backdrop (off by default, use it with `modal`) |
463
+ | `arrow`, `renderArrow`, `arrowPadding` | An arrow pointing at the input. Rendered when `arrow` (its content, e.g. an `<svg>`) or `renderArrow` is given |
464
+ | `finalFocus` | The element focused when the popup closes |
465
+
466
+ **Your own filtering.** `useAutocompleteFilter(options?)` returns locale-aware matchers (`contains`, `startsWith`, `endsWith`, accent- and case-insensitive by default). Pass one as `filter`, or filter items yourself and pass `filteredItems`:
467
+
468
+ ```tsx
469
+ const filter = useAutocompleteFilter();
470
+ <BaseAutocomplete items={fruits} filter={filter.startsWith}>…</BaseAutocomplete>
471
+ ```
472
+
473
+ **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. Only `required` is checked in the browser; other schema rules are checked by the server:
474
+
475
+ ```tsx
476
+ <BaseFormField name="fruit" label="Fruit" schema={Schema.shape.fruit}>
477
+ {constraints => (
478
+ <BaseAutocomplete items={fruits} required={constraints.required}>
479
+ …
480
+ </BaseAutocomplete>
481
+ )}
482
+ </BaseFormField>
483
+ ```
484
+
347
485
  ### `@omer-x/tailwind-ui-kit/dialog`
348
486
 
349
487
  #### `BaseDialog`
@@ -1,7 +1,8 @@
1
1
  "use client";
2
2
  import { Dialog } from "@base-ui/react/dialog";
3
3
  import { cn } from "cn";
4
- import { cloneElement, isValidElement } from "react";
4
+ import "react";
5
+ import { splitClassName } from "../../utils/split-class-name.js";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
7
  // src/components/dialog/BaseDialogPopup.tsx
7
8
  const sizes = {
@@ -10,20 +11,6 @@ const sizes = {
10
11
  md: "w-96",
11
12
  lg: "w-lg"
12
13
  };
13
- /**
14
- * Base UI only joins the `className` of a `render` element with the part's own, so conflicting
15
- * Tailwind classes would win by their order in the CSS. Moves it into `cn` instead, last so it wins (#14).
16
- */
17
- function splitClassName(render) {
18
- if (!isValidElement(render) || !render.props.className) return {
19
- render,
20
- className: void 0
21
- };
22
- return {
23
- render: cloneElement(render, { className: void 0 }),
24
- className: render.props.className
25
- };
26
- }
27
14
  /** The dialog's window, with its portal and backdrop. Renders a `<div>`. */
28
15
  const BaseDialogPopup = ({ size = "md", container, keepMounted, backdrop = true, renderBackdrop, className, ...otherProps }) => {
29
16
  const backdropElement = splitClassName(renderBackdrop);
@@ -0,0 +1,198 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { AutocompleteAlign, AutocompleteInputState, AutocompleteSide } from "./autocompleteTypes.js";
3
+ import "../../utils/index.js";
4
+ import { InputSize } from "./inputSizes.js";
5
+ import { AutocompleteClearState } from "./BaseAutocompleteClear.js";
6
+ import { AutocompleteArrowState, AutocompleteBackdropState, AutocompleteCollisionAvoidance, AutocompleteFocusTarget, AutocompleteOffsetFunction, AutocompletePopupState, AutocompletePositionerState } from "./BaseAutocompletePopup.js";
7
+ import { AutocompleteListState } from "./BaseAutocompleteList.js";
8
+ import { AutocompleteItemState } from "./BaseAutocompleteItem.js";
9
+ import { AutocompleteSeparatorState } from "./BaseAutocompleteSeparator.js";
10
+ import { ReactNode, Ref, RefObject } from "react";
11
+ /** A group of items in `items`: any object with an `items` array, e.g. `{ label: "Fruits", items: [...] }`. */
12
+ export type AutocompleteItemGroup<Item> = {
13
+ items: readonly Item[];
14
+ };
15
+ /** Imperative actions, through `actionsRef`. */
16
+ export type AutocompleteActions = {
17
+ /** Closes the popup. */
18
+ close: () => void;
19
+ };
20
+ /** Why the highlighted item changed: arrow keys, the pointer, or anything else (typing, `autoHighlight`, …). */
21
+ export type AutocompleteHighlightReason = "keyboard" | "pointer" | "none";
22
+ type BaseAutocompleteProps<Item> = {
23
+ /**
24
+ * The items, flat or in groups. They're filtered by the input's value and passed to the
25
+ * function children of `List` (and of `Collection` in groups).
26
+ */
27
+ items?: readonly Item[] | readonly AutocompleteItemGroup<Item>[];
28
+ /**
29
+ * Items you filtered yourself (e.g. with `useAutocompleteFilter`), shown instead of filtering `items`.
30
+ * Keep the same flat or grouped shape.
31
+ */
32
+ filteredItems?: readonly Item[] | readonly AutocompleteItemGroup<Item>[];
33
+ /** Decides whether an item matches the query. `null` turns filtering off. Defaults to a case-insensitive "contains". */
34
+ filter?: ((item: Item, query: string, itemToString?: (item: Item) => string) => boolean) | null;
35
+ /** Shows at most this many matching items. @default -1 (no limit) */
36
+ limit?: number;
37
+ /**
38
+ * - `list`: items are filtered by the input's value.
39
+ * - `both`: filtered, and the highlighted item fills the input temporarily (inline completion).
40
+ * - `inline`: not filtered, with inline completion.
41
+ * - `none`: not filtered, without inline completion.
42
+ * @default "list"
43
+ */
44
+ mode?: "list" | "both" | "inline" | "none";
45
+ /**
46
+ * Turns an object item into the text put in the input and submitted.
47
+ * `{ value, label }` objects use their `label` without it.
48
+ */
49
+ itemToStringValue?: (item: Item) => string;
50
+ /** The input's value, controlled. */
51
+ value?: string;
52
+ /** The input's initial value, uncontrolled. */
53
+ defaultValue?: string;
54
+ /** Called with the new value and the DOM event that changed it (none when it was changed from code). */
55
+ onValueChange?: (value: string, event: Event | undefined) => void;
56
+ open?: boolean;
57
+ defaultOpen?: boolean;
58
+ /** Called with the new state and the DOM event that changed it (none when it was changed from code). */
59
+ onOpenChange?: (open: boolean, event: Event | undefined) => void;
60
+ /** Called after the open or close transition ends. */
61
+ onOpenChangeComplete?: (open: boolean) => void;
62
+ /** Opens the popup when the input is clicked. */
63
+ openOnInputClick?: boolean;
64
+ /** Highlights the first match while typing, or `"always"` (also when the popup opens). */
65
+ autoHighlight?: boolean | "always";
66
+ /** Keeps the highlight when the pointer leaves the list. */
67
+ keepHighlight?: boolean;
68
+ /**
69
+ * Set to `false` to stop the pointer from highlighting items, so `:hover` and `data-highlighted` can differ.
70
+ * @default true
71
+ */
72
+ highlightItemOnHover?: boolean;
73
+ /** Called when an item is highlighted, or with `undefined` when none is. */
74
+ onItemHighlighted?: (item: Item | undefined, details: {
75
+ reason: AutocompleteHighlightReason;
76
+ index: number;
77
+ }) => void;
78
+ /** Wraps keyboard navigation from the last item to the first and back. @default true */
79
+ loopFocus?: boolean;
80
+ /** Submits the form when an item is chosen, e.g. for a search box. */
81
+ submitOnItemClick?: boolean;
82
+ /** Lays items out in `Row`s, navigated with all four arrow keys. */
83
+ grid?: boolean;
84
+ /** Renders the list in place, without the popup. Use it with `open`. */
85
+ inline?: boolean;
86
+ /** Locks page scroll and blocks outside pointer input while open. */
87
+ modal?: boolean;
88
+ /** Set when the list is rendered by a virtualizer, with each item's `index`. */
89
+ virtualized?: boolean;
90
+ /** The locale used by the default filter. Defaults to the user's locale. */
91
+ locale?: Intl.LocalesArgument;
92
+ /** The input's `name`. Inside a `BaseFormField`, the field's name is used. */
93
+ name?: string;
94
+ /** The `id` of a `<form>` to submit with, when the autocomplete isn't inside it. */
95
+ form?: string;
96
+ /** The `id` of the input. */
97
+ id?: string;
98
+ required?: boolean;
99
+ disabled?: boolean;
100
+ readOnly?: boolean;
101
+ /** A ref to the hidden `<input>` used for validation. */
102
+ inputRef?: Ref<HTMLInputElement>;
103
+ /** Imperative actions, e.g. `actionsRef.current?.close()`. */
104
+ actionsRef?: RefObject<AutocompleteActions | null>;
105
+ children?: ReactNode;
106
+ };
107
+ declare const _default: (<Item>({ onValueChange, onOpenChange, onItemHighlighted, ...otherProps }: BaseAutocompleteProps<Item>) => import("react").JSX.Element) & {
108
+ InputGroup: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
109
+ render?: RenderProp<"div", AutocompleteInputState>;
110
+ }) => import("react").JSX.Element;
111
+ Input: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "value" | "size"> & {
112
+ size?: InputSize;
113
+ render?: RenderProp<"input", AutocompleteInputState>;
114
+ }) => import("react").JSX.Element;
115
+ Trigger: (props: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
116
+ render?: RenderProp<"button", AutocompleteInputState>;
117
+ nativeButton?: boolean;
118
+ }) => import("react").JSX.Element;
119
+ Icon: (props: import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & {
120
+ render?: RenderProp<"span">;
121
+ }) => import("react").JSX.Element;
122
+ Clear: (props: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
123
+ render?: RenderProp<"button", AutocompleteClearState>;
124
+ keepMounted?: boolean;
125
+ nativeButton?: boolean;
126
+ }) => import("react").JSX.Element;
127
+ Value: (props: {
128
+ children?: ReactNode | ((value: string) => ReactNode);
129
+ }) => import("react").JSX.Element;
130
+ Popup: ({ container, keepMounted, 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> & {
131
+ render?: RenderProp<"div", AutocompletePopupState>;
132
+ finalFocus?: AutocompleteFocusTarget;
133
+ container?: HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null;
134
+ keepMounted?: boolean;
135
+ anchor?: Element | RefObject<Element | null> | (() => Element | null) | null;
136
+ positionMethod?: "absolute" | "fixed";
137
+ side?: AutocompleteSide;
138
+ sideOffset?: number | AutocompleteOffsetFunction;
139
+ align?: AutocompleteAlign;
140
+ alignOffset?: number | AutocompleteOffsetFunction;
141
+ collisionBoundary?: "clipping-ancestors" | Element | Element[] | {
142
+ x: number;
143
+ y: number;
144
+ width: number;
145
+ height: number;
146
+ };
147
+ collisionPadding?: number | {
148
+ top?: number;
149
+ right?: number;
150
+ bottom?: number;
151
+ left? /** Called with the new state and the DOM event that changed it (none when it was changed from code). */ : number;
152
+ };
153
+ collisionAvoidance?: AutocompleteCollisionAvoidance;
154
+ sticky?: boolean;
155
+ arrowPadding?: number;
156
+ disableAnchorTracking?: boolean;
157
+ renderPositioner?: RenderProp<"div", AutocompletePositionerState>;
158
+ backdrop?: boolean;
159
+ renderBackdrop?: RenderProp<"div", AutocompleteBackdropState>;
160
+ arrow?: ReactNode;
161
+ renderArrow?: RenderProp<"div", AutocompleteArrowState>;
162
+ }) => import("react").JSX.Element;
163
+ Status: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
164
+ render?: RenderProp<"div">;
165
+ }) => import("react").JSX.Element;
166
+ Empty: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
167
+ render?: RenderProp<"div">;
168
+ }) => import("react").JSX.Element;
169
+ List: <Item>({ className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children"> & {
170
+ render?: RenderProp<"div", AutocompleteListState>;
171
+ children?: ReactNode | ((item: Item, index: number) => ReactNode);
172
+ }) => import("react").JSX.Element;
173
+ Row: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
174
+ render?: RenderProp<"div">;
175
+ }) => import("react").JSX.Element;
176
+ Item: ({ className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "id"> & {
177
+ render?: RenderProp<"div", AutocompleteItemState>;
178
+ value?: unknown;
179
+ index?: number;
180
+ disabled?: boolean;
181
+ nativeButton?: boolean;
182
+ }) => import("react").JSX.Element;
183
+ Separator: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
184
+ render?: RenderProp<"div", AutocompleteSeparatorState>;
185
+ orientation?: "horizontal" | "vertical";
186
+ }) => import("react").JSX.Element;
187
+ Group: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
188
+ render?: RenderProp<"div">;
189
+ items?: readonly unknown[];
190
+ }) => import("react").JSX.Element;
191
+ GroupLabel: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
192
+ render?: RenderProp<"div">;
193
+ }) => import("react").JSX.Element;
194
+ Collection: <Item>({ children }: {
195
+ children: (item: Item, index: number) => ReactNode;
196
+ }) => import("react").JSX.Element;
197
+ };
198
+ export { _default as default };
@@ -0,0 +1,49 @@
1
+ "use client";
2
+ import { Autocomplete } from "@base-ui/react/autocomplete";
3
+ import BaseAutocompleteClear from "./BaseAutocompleteClear.js";
4
+ import BaseAutocompleteCollection from "./BaseAutocompleteCollection.js";
5
+ import BaseAutocompleteEmpty from "./BaseAutocompleteEmpty.js";
6
+ import BaseAutocompleteGroup from "./BaseAutocompleteGroup.js";
7
+ import BaseAutocompleteGroupLabel from "./BaseAutocompleteGroupLabel.js";
8
+ import BaseAutocompleteIcon from "./BaseAutocompleteIcon.js";
9
+ import BaseAutocompleteInput from "./BaseAutocompleteInput.js";
10
+ import BaseAutocompleteInputGroup from "./BaseAutocompleteInputGroup.js";
11
+ import BaseAutocompleteItem from "./BaseAutocompleteItem.js";
12
+ import BaseAutocompleteList from "./BaseAutocompleteList.js";
13
+ import BaseAutocompletePopup from "./BaseAutocompletePopup.js";
14
+ import BaseAutocompleteRow from "./BaseAutocompleteRow.js";
15
+ import BaseAutocompleteSeparator from "./BaseAutocompleteSeparator.js";
16
+ import BaseAutocompleteStatus from "./BaseAutocompleteStatus.js";
17
+ import BaseAutocompleteTrigger from "./BaseAutocompleteTrigger.js";
18
+ import BaseAutocompleteValue from "./BaseAutocompleteValue.js";
19
+ import { jsx } from "react/jsx-runtime";
20
+ // src/components/form/BaseAutocomplete.tsx
21
+ /** Groups the parts of an autocomplete and holds its value. Renders no element. */
22
+ const BaseAutocomplete = ({ onValueChange, onOpenChange, onItemHighlighted, ...otherProps }) => /* @__PURE__ */ jsx(Autocomplete.Root, {
23
+ ...otherProps,
24
+ onValueChange: onValueChange && ((value, details) => onValueChange(value, details.event)),
25
+ onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event)),
26
+ onItemHighlighted: onItemHighlighted && ((item, details) => onItemHighlighted(item, {
27
+ reason: details.reason,
28
+ index: details.index
29
+ }))
30
+ });
31
+ var BaseAutocomplete_default = Object.assign(BaseAutocomplete, {
32
+ InputGroup: BaseAutocompleteInputGroup,
33
+ Input: BaseAutocompleteInput,
34
+ Trigger: BaseAutocompleteTrigger,
35
+ Icon: BaseAutocompleteIcon,
36
+ Clear: BaseAutocompleteClear,
37
+ Value: BaseAutocompleteValue,
38
+ Popup: BaseAutocompletePopup,
39
+ Status: BaseAutocompleteStatus,
40
+ Empty: BaseAutocompleteEmpty,
41
+ List: BaseAutocompleteList,
42
+ Row: BaseAutocompleteRow,
43
+ Item: BaseAutocompleteItem,
44
+ Separator: BaseAutocompleteSeparator,
45
+ Group: BaseAutocompleteGroup,
46
+ GroupLabel: BaseAutocompleteGroupLabel,
47
+ Collection: BaseAutocompleteCollection
48
+ });
49
+ export { BaseAutocomplete_default as default };
@@ -0,0 +1,18 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ export type AutocompleteClearState = {
4
+ open: boolean;
5
+ disabled: boolean;
6
+ /** Whether the input has a value to clear. */
7
+ visible: boolean;
8
+ };
9
+ type BaseAutocompleteClearProps = ComponentProps<"button"> & {
10
+ render?: RenderProp<"button", AutocompleteClearState>;
11
+ /** Keeps the button in the DOM while the input is empty. */
12
+ keepMounted?: boolean;
13
+ /** Set to `false` when `render` doesn't render a `<button>`. */
14
+ nativeButton?: boolean;
15
+ };
16
+ /** A button that clears the input. Renders a `<button>`, only while the input has a value. */
17
+ declare const BaseAutocompleteClear: (props: BaseAutocompleteClearProps) => import("react").JSX.Element;
18
+ export { BaseAutocompleteClear as default };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { Autocomplete } from "@base-ui/react/autocomplete";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseAutocompleteClear.tsx
5
+ /** A button that clears the input. Renders a `<button>`, only while the input has a value. */
6
+ const BaseAutocompleteClear = (props) => /* @__PURE__ */ jsx(Autocomplete.Clear, { ...props });
7
+ export { BaseAutocompleteClear as default };
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from "react";
2
+ type BaseAutocompleteCollectionProps<Item> = {
3
+ /** Renders each filtered item of the surrounding `Group`'s `items`. */
4
+ children: (item: Item, index: number) => ReactNode;
5
+ };
6
+ /** Renders the filtered items of a group. Renders no element. */
7
+ declare const BaseAutocompleteCollection: <Item>({ children }: BaseAutocompleteCollectionProps<Item>) => import("react").JSX.Element;
8
+ export { BaseAutocompleteCollection as default };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { Autocomplete } from "@base-ui/react/autocomplete";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseAutocompleteCollection.tsx
5
+ /** Renders the filtered items of a group. Renders no element. */
6
+ const BaseAutocompleteCollection = ({ children }) => /* @__PURE__ */ jsx(Autocomplete.Collection, { children });
7
+ export { BaseAutocompleteCollection as default };
@@ -0,0 +1,11 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ type BaseAutocompleteEmptyProps = ComponentProps<"div"> & {
4
+ render?: RenderProp<"div">;
5
+ };
6
+ /**
7
+ * Its children are shown only when no item matches. Renders a `<div>` that is always there (it's a
8
+ * live region), so give it spacing with `not-empty:` or remove it with `empty:` variants.
9
+ */
10
+ declare const BaseAutocompleteEmpty: (props: BaseAutocompleteEmptyProps) => import("react").JSX.Element;
11
+ export { BaseAutocompleteEmpty as default };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Autocomplete } from "@base-ui/react/autocomplete";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseAutocompleteEmpty.tsx
5
+ /**
6
+ * Its children are shown only when no item matches. Renders a `<div>` that is always there (it's a
7
+ * live region), so give it spacing with `not-empty:` or remove it with `empty:` variants.
8
+ */
9
+ const BaseAutocompleteEmpty = (props) => /* @__PURE__ */ jsx(Autocomplete.Empty, { ...props });
10
+ export { BaseAutocompleteEmpty as default };
@@ -0,0 +1,10 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ type BaseAutocompleteGroupProps = ComponentProps<"div"> & {
4
+ render?: RenderProp<"div">;
5
+ /** The group's filtered items, for `BaseAutocomplete.Collection` inside it. */
6
+ items?: readonly unknown[];
7
+ };
8
+ /** Groups related items under a `GroupLabel`. Renders a `<div>`. */
9
+ declare const BaseAutocompleteGroup: (props: BaseAutocompleteGroupProps) => import("react").JSX.Element;
10
+ export { BaseAutocompleteGroup as default };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { Autocomplete } from "@base-ui/react/autocomplete";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseAutocompleteGroup.tsx
5
+ /** Groups related items under a `GroupLabel`. Renders a `<div>`. */
6
+ const BaseAutocompleteGroup = (props) => /* @__PURE__ */ jsx(Autocomplete.Group, { ...props });
7
+ export { BaseAutocompleteGroup as default };
@@ -0,0 +1,8 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ type BaseAutocompleteGroupLabelProps = ComponentProps<"div"> & {
4
+ render?: RenderProp<"div">;
5
+ };
6
+ /** The heading that names a group. Renders a `<div>`. */
7
+ declare const BaseAutocompleteGroupLabel: (props: BaseAutocompleteGroupLabelProps) => import("react").JSX.Element;
8
+ export { BaseAutocompleteGroupLabel as default };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { Autocomplete } from "@base-ui/react/autocomplete";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseAutocompleteGroupLabel.tsx
5
+ /** The heading that names a group. Renders a `<div>`. */
6
+ const BaseAutocompleteGroupLabel = (props) => /* @__PURE__ */ jsx(Autocomplete.GroupLabel, { ...props });
7
+ export { BaseAutocompleteGroupLabel as default };
@@ -0,0 +1,8 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ type BaseAutocompleteIconProps = ComponentProps<"span"> & {
4
+ render?: RenderProp<"span">;
5
+ };
6
+ /** A decorative icon, hidden from assistive technology. Renders a `<span>`. Bring your own icon as children. */
7
+ declare const BaseAutocompleteIcon: (props: BaseAutocompleteIconProps) => import("react").JSX.Element;
8
+ export { BaseAutocompleteIcon as default };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { Autocomplete } from "@base-ui/react/autocomplete";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/form/BaseAutocompleteIcon.tsx
5
+ /** A decorative icon, hidden from assistive technology. Renders a `<span>`. Bring your own icon as children. */
6
+ const BaseAutocompleteIcon = (props) => /* @__PURE__ */ jsx(Autocomplete.Icon, { ...props });
7
+ export { BaseAutocompleteIcon as default };
@@ -0,0 +1,12 @@
1
+ import { InputSize } from "./inputSizes.js";
2
+ import { AutocompleteInputState } from "./autocompleteTypes.js";
3
+ import { RenderProp } from "../../utils/render.js";
4
+ import { ComponentProps } from "react";
5
+ type BaseAutocompleteInputProps = Omit<ComponentProps<"input">, "size" | "value" | "defaultValue"> & {
6
+ /** The same sizes as `BaseInput`. */
7
+ size?: InputSize;
8
+ render?: RenderProp<"input", AutocompleteInputState>;
9
+ };
10
+ /** The text input the user types in. Renders an `<input>`, sized like `BaseInput`. */
11
+ declare const BaseAutocompleteInput: ({ size, className, ...otherProps }: BaseAutocompleteInputProps) => import("react").JSX.Element;
12
+ export { BaseAutocompleteInput as default };
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { Autocomplete } from "@base-ui/react/autocomplete";
3
+ import { cn } from "cn";
4
+ import { inputBaseClasses, inputSizeClasses } from "./inputSizes.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ // src/components/form/BaseAutocompleteInput.tsx
7
+ /** The text input the user types in. Renders an `<input>`, sized like `BaseInput`. */
8
+ const BaseAutocompleteInput = ({ size = "md", className, ...otherProps }) => /* @__PURE__ */ jsx(Autocomplete.Input, {
9
+ ...otherProps,
10
+ className: cn(inputSizeClasses(size), inputBaseClasses, className)
11
+ });
12
+ export { BaseAutocompleteInput as default };
@@ -0,0 +1,9 @@
1
+ import { AutocompleteInputState } from "./autocompleteTypes.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ type BaseAutocompleteInputGroupProps = ComponentProps<"div"> & {
5
+ render?: RenderProp<"div", AutocompleteInputState>;
6
+ };
7
+ /** Groups the input with its trigger and clear button. The popup is placed against it. Renders a `<div>`. */
8
+ declare const BaseAutocompleteInputGroup: ({ className, ...otherProps }: BaseAutocompleteInputGroupProps) => import("react").JSX.Element;
9
+ export { BaseAutocompleteInputGroup as default };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { Autocomplete } from "@base-ui/react/autocomplete";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/form/BaseAutocompleteInputGroup.tsx
6
+ /** Groups the input with its trigger and clear button. The popup is placed against it. Renders a `<div>`. */
7
+ const BaseAutocompleteInputGroup = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Autocomplete.InputGroup, {
8
+ ...otherProps,
9
+ className: cn("relative flex items-center", className)
10
+ });
11
+ export { BaseAutocompleteInputGroup as default };