@omer-x/tailwind-ui-kit 1.0.0-alpha.32 → 1.0.0-alpha.34

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 (59) hide show
  1. package/README.md +165 -0
  2. package/dist/components/dialog/BaseDialogPopup.js +2 -15
  3. package/dist/components/disclosure/BaseCollapsible.d.ts +33 -0
  4. package/dist/components/disclosure/BaseCollapsible.js +16 -0
  5. package/dist/components/disclosure/BaseCollapsiblePanel.d.ts +20 -0
  6. package/dist/components/disclosure/BaseCollapsiblePanel.js +15 -0
  7. package/dist/components/disclosure/BaseCollapsibleTrigger.d.ts +15 -0
  8. package/dist/components/disclosure/BaseCollapsibleTrigger.js +16 -0
  9. package/dist/components/disclosure/index.d.ts +3 -1
  10. package/dist/components/disclosure/index.js +3 -1
  11. package/dist/components/form/BaseAutocomplete.d.ts +198 -0
  12. package/dist/components/form/BaseAutocomplete.js +49 -0
  13. package/dist/components/form/BaseAutocompleteClear.d.ts +18 -0
  14. package/dist/components/form/BaseAutocompleteClear.js +7 -0
  15. package/dist/components/form/BaseAutocompleteCollection.d.ts +8 -0
  16. package/dist/components/form/BaseAutocompleteCollection.js +7 -0
  17. package/dist/components/form/BaseAutocompleteEmpty.d.ts +11 -0
  18. package/dist/components/form/BaseAutocompleteEmpty.js +10 -0
  19. package/dist/components/form/BaseAutocompleteGroup.d.ts +10 -0
  20. package/dist/components/form/BaseAutocompleteGroup.js +7 -0
  21. package/dist/components/form/BaseAutocompleteGroupLabel.d.ts +8 -0
  22. package/dist/components/form/BaseAutocompleteGroupLabel.js +7 -0
  23. package/dist/components/form/BaseAutocompleteIcon.d.ts +8 -0
  24. package/dist/components/form/BaseAutocompleteIcon.js +7 -0
  25. package/dist/components/form/BaseAutocompleteInput.d.ts +12 -0
  26. package/dist/components/form/BaseAutocompleteInput.js +12 -0
  27. package/dist/components/form/BaseAutocompleteInputGroup.d.ts +9 -0
  28. package/dist/components/form/BaseAutocompleteInputGroup.js +11 -0
  29. package/dist/components/form/BaseAutocompleteItem.d.ts +20 -0
  30. package/dist/components/form/BaseAutocompleteItem.js +11 -0
  31. package/dist/components/form/BaseAutocompleteList.d.ts +14 -0
  32. package/dist/components/form/BaseAutocompleteList.js +11 -0
  33. package/dist/components/form/BaseAutocompletePopup.d.ts +111 -0
  34. package/dist/components/form/BaseAutocompletePopup.js +45 -0
  35. package/dist/components/form/BaseAutocompleteRow.d.ts +8 -0
  36. package/dist/components/form/BaseAutocompleteRow.js +7 -0
  37. package/dist/components/form/BaseAutocompleteSeparator.d.ts +13 -0
  38. package/dist/components/form/BaseAutocompleteSeparator.js +7 -0
  39. package/dist/components/form/BaseAutocompleteStatus.d.ts +11 -0
  40. package/dist/components/form/BaseAutocompleteStatus.js +10 -0
  41. package/dist/components/form/BaseAutocompleteTrigger.d.ts +11 -0
  42. package/dist/components/form/BaseAutocompleteTrigger.js +7 -0
  43. package/dist/components/form/BaseAutocompleteValue.d.ts +8 -0
  44. package/dist/components/form/BaseAutocompleteValue.js +7 -0
  45. package/dist/components/form/BaseFormField.d.ts +10 -1
  46. package/dist/components/form/BaseFormField.js +2 -2
  47. package/dist/components/form/BaseInput.d.ts +2 -1
  48. package/dist/components/form/BaseInput.js +2 -12
  49. package/dist/components/form/autocompleteTypes.d.ts +16 -0
  50. package/dist/components/form/autocompleteTypes.js +1 -0
  51. package/dist/components/form/index.d.ts +11 -2
  52. package/dist/components/form/index.js +3 -1
  53. package/dist/components/form/inputSizes.d.ts +11 -0
  54. package/dist/components/form/inputSizes.js +19 -0
  55. package/dist/components/form/useAutocompleteFilter.d.ts +19 -0
  56. package/dist/components/form/useAutocompleteFilter.js +12 -0
  57. package/dist/utils/split-class-name.d.ts +15 -0
  58. package/dist/utils/split-class-name.js +18 -0
  59. package/package.json +1 -1
package/README.md CHANGED
@@ -337,6 +337,7 @@ A Base UI [`Field`](https://base-ui.com/react/components/field) made of a label,
337
337
  | `schema` | `ZodType` | Source of the HTML constraints applied to the control |
338
338
  | `label` | `string` | Label text. No label is rendered when omitted |
339
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 |
340
341
  | `renderLabel` | `RenderProp<"label", FieldState>` | Style the label |
341
342
  | `renderErrors` | `RenderProp<"div", FieldState>` | Style client-side and server-side error messages. Each error is its own element |
342
343
  | `className` | `string` | Classes for the field root (a flex column by default) |
@@ -372,6 +373,115 @@ export const UserSchema = z.object({
372
373
 
373
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.
374
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
+
375
485
  ### `@omer-x/tailwind-ui-kit/dialog`
376
486
 
377
487
  #### `BaseDialog`
@@ -587,6 +697,61 @@ Every part takes `className` and `render`.
587
697
 
588
698
  Data attributes: the item, heading and panel have `data-open` and `data-index`. The trigger has `data-panel-open`. Disabled parts have `data-disabled`. The panel has `data-starting-style` / `data-ending-style` during its transition.
589
699
 
700
+ #### `BaseCollapsible`
701
+
702
+ A Base UI [`Collapsible`](https://base-ui.com/react/components/collapsible): a panel shown or hidden by a button.
703
+
704
+ ```tsx
705
+ import { BaseCollapsible } from "@omer-x/tailwind-ui-kit/disclosure";
706
+
707
+ <BaseCollapsible>
708
+ <BaseCollapsible.Trigger className="rounded-md px-3 py-1.5" icon={<ChevronDown />} iconClassName="in-data-panel-open:rotate-180">
709
+ Recovery keys
710
+ </BaseCollapsible.Trigger>
711
+ <BaseCollapsible.Panel>
712
+ <div className="p-4">alien-bean-pasta</div>
713
+ </BaseCollapsible.Panel>
714
+ </BaseCollapsible>
715
+ ```
716
+
717
+ Like `BaseAccordion`, the parts use dot notation, so build collapsibles in a `"use client"` file.
718
+
719
+ | Part | Renders | Description |
720
+ |------|---------|-------------|
721
+ | `BaseCollapsible` | `<div>` | Groups the trigger with the panel and holds whether it is open |
722
+ | `BaseCollapsible.Trigger` | `<button>` | Opens and closes the panel. An inline flex row with a focus outline |
723
+ | `BaseCollapsible.Panel` | `<div>` | The content, with a height transition (shared with Accordion). **Put padding on an element inside it**, so it can shrink to zero |
724
+
725
+ Every part takes `className` and `render`.
726
+
727
+ `BaseCollapsible` props:
728
+
729
+ | Prop | Type | Default | Description |
730
+ |------|------|---------|-------------|
731
+ | `open` / `defaultOpen` | `boolean` | `false` | Controlled / initial state of the panel |
732
+ | `onOpenChange` | `(open, event) => void` | | Called with the new state and the DOM event that changed it (`undefined` when changed from code) |
733
+ | `disabled` | `boolean` | `false` | Ignores user interaction |
734
+ | `render` | `RenderProp<"div", CollapsibleState>` | | The state is `{ open, disabled }` |
735
+
736
+ `BaseCollapsible.Trigger` props:
737
+
738
+ | Prop | Type | Default | Description |
739
+ |------|------|---------|-------------|
740
+ | `icon` | `ReactNode` | | Shown after the text, in a `<span>` with a transform transition. Nothing is rendered without it |
741
+ | `iconClassName` | `string` | | Classes for the icon's `<span>`, e.g. `in-data-panel-open:rotate-180` |
742
+ | `render` | `RenderProp<"button", CollapsibleState>` | | Replaces the button |
743
+ | `nativeButton` | `boolean` | `true` | Set to `false` when `render` doesn't render a `<button>` |
744
+
745
+ `BaseCollapsible.Panel` props:
746
+
747
+ | Prop | Type | Default | Description |
748
+ |------|------|---------|-------------|
749
+ | `keepMounted` | `boolean` | `false` | Keeps the closed panel in the DOM |
750
+ | `hiddenUntilFound` | `boolean` | `false` | Keeps the closed panel hidden with `hidden="until-found"`, so the browser's page search finds and opens it. Overrides `keepMounted` |
751
+ | `render` | `RenderProp<"div", CollapsiblePanelState>` | | The state is `{ open, disabled, transitionStatus }` |
752
+
753
+ Data attributes: the root and panel have `data-open` / `data-closed`. The trigger has `data-panel-open`. Disabled parts have `data-disabled`. The panel has `data-starting-style` / `data-ending-style` during its transition.
754
+
590
755
  ### `@omer-x/tailwind-ui-kit/display`
591
756
 
592
757
  #### `BaseAvatar`
@@ -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,33 @@
1
+ import { CollapsiblePanelState } from "./BaseCollapsiblePanel.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ export type CollapsibleState = {
5
+ /** Whether the panel is open. */
6
+ open: boolean;
7
+ disabled: boolean;
8
+ };
9
+ type BaseCollapsibleProps = ComponentProps<"div"> & {
10
+ render?: RenderProp<"div", CollapsibleState>;
11
+ /** Whether the panel is open (controlled). */
12
+ open?: boolean;
13
+ /** Whether the panel is open at first. */
14
+ defaultOpen?: boolean;
15
+ /** Called with the new state and the DOM event that changed it (none when changed from code). */
16
+ onOpenChange?: (open: boolean, event: Event | undefined) => void;
17
+ /** Ignores user interaction. */
18
+ disabled?: boolean;
19
+ };
20
+ declare const _default: (({ onOpenChange, ...otherProps }: BaseCollapsibleProps) => import("react").JSX.Element) & {
21
+ Trigger: ({ icon, iconClassName, className, children, ...otherProps }: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
22
+ render?: RenderProp<"button", CollapsibleState>;
23
+ icon?: import("react").ReactNode;
24
+ iconClassName?: string;
25
+ nativeButton?: boolean;
26
+ }) => import("react").JSX.Element;
27
+ Panel: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
28
+ render?: RenderProp<"div", CollapsiblePanelState>;
29
+ keepMounted?: boolean;
30
+ hiddenUntilFound?: boolean;
31
+ }) => import("react").JSX.Element;
32
+ };
33
+ export { _default as default };
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { Collapsible } from "@base-ui/react/collapsible";
3
+ import BaseCollapsiblePanel from "./BaseCollapsiblePanel.js";
4
+ import BaseCollapsibleTrigger from "./BaseCollapsibleTrigger.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ // src/components/disclosure/BaseCollapsible.tsx
7
+ /** Groups a trigger with its panel. Renders a `<div>`, with `data-open` while the panel is open. */
8
+ const BaseCollapsible = ({ onOpenChange, ...otherProps }) => /* @__PURE__ */ jsx(Collapsible.Root, {
9
+ ...otherProps,
10
+ onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event))
11
+ });
12
+ var BaseCollapsible_default = Object.assign(BaseCollapsible, {
13
+ Trigger: BaseCollapsibleTrigger,
14
+ Panel: BaseCollapsiblePanel
15
+ });
16
+ export { BaseCollapsible_default as default };
@@ -0,0 +1,20 @@
1
+ import { CollapsibleState } from "./BaseCollapsible.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ export type CollapsiblePanelState = CollapsibleState & {
5
+ /** `"starting"` while opening, `"ending"` while closing. */
6
+ transitionStatus: "starting" | "ending" | "idle" | undefined;
7
+ };
8
+ type BaseCollapsiblePanelProps = ComponentProps<"div"> & {
9
+ render?: RenderProp<"div", CollapsiblePanelState>;
10
+ /** Keeps the panel in the DOM while closed. */
11
+ keepMounted?: boolean;
12
+ /** Lets the browser's page search find and open the panel. Overrides `keepMounted`. */
13
+ hiddenUntilFound?: boolean;
14
+ };
15
+ /**
16
+ * The collapsible content, with a height transition. Renders a `<div>`.
17
+ * Put padding on an element inside it, so the panel can shrink to zero.
18
+ */
19
+ declare const BaseCollapsiblePanel: ({ className, ...otherProps }: BaseCollapsiblePanelProps) => import("react").JSX.Element;
20
+ export { BaseCollapsiblePanel as default };
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { Collapsible } from "@base-ui/react/collapsible";
3
+ import { cn } from "cn";
4
+ import panelTransition from "./panelTransition.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ // src/components/disclosure/BaseCollapsiblePanel.tsx
7
+ /**
8
+ * The collapsible content, with a height transition. Renders a `<div>`.
9
+ * Put padding on an element inside it, so the panel can shrink to zero.
10
+ */
11
+ const BaseCollapsiblePanel = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Collapsible.Panel, {
12
+ ...otherProps,
13
+ className: cn("[--disclosure-panel-height:var(--collapsible-panel-height)]", panelTransition, className)
14
+ });
15
+ export { BaseCollapsiblePanel as default };
@@ -0,0 +1,15 @@
1
+ import { CollapsibleState } from "./BaseCollapsible.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps, ReactNode } from "react";
4
+ type BaseCollapsibleTriggerProps = ComponentProps<"button"> & {
5
+ render?: RenderProp<"button", CollapsibleState>;
6
+ /** Shown after the text, e.g. a chevron. Rotate it with `iconClassName="in-data-panel-open:rotate-180"`. */
7
+ icon?: ReactNode;
8
+ /** Classes for the `<span>` around the icon. */
9
+ iconClassName?: string;
10
+ /** Set to `false` when `render` doesn't render a `<button>`. */
11
+ nativeButton?: boolean;
12
+ };
13
+ /** A button that opens and closes the panel. Renders a `<button>`, with `data-panel-open` while the panel is open. */
14
+ declare const BaseCollapsibleTrigger: ({ icon, iconClassName, className, children, ...otherProps }: BaseCollapsibleTriggerProps) => import("react").JSX.Element;
15
+ export { BaseCollapsibleTrigger as default };
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { Collapsible } from "@base-ui/react/collapsible";
3
+ import { cn } from "cn";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ // src/components/disclosure/BaseCollapsibleTrigger.tsx
6
+ /** A button that opens and closes the panel. Renders a `<button>`, with `data-panel-open` while the panel is open. */
7
+ const BaseCollapsibleTrigger = ({ icon, iconClassName, className, children, ...otherProps }) => /* @__PURE__ */ jsxs(Collapsible.Trigger, {
8
+ ...otherProps,
9
+ className: cn("inline-flex", "items-center", "gap-2", "text-left", "focus-visible:outline-2", "focus-visible:outline-offset-2", "data-disabled:cursor-not-allowed", className),
10
+ children: [children, icon && /* @__PURE__ */ jsx("span", {
11
+ "aria-hidden": "true",
12
+ className: cn("flex", "shrink-0", "transition-transform", "duration-150", iconClassName),
13
+ children: icon
14
+ })]
15
+ });
16
+ export { BaseCollapsibleTrigger as default };
@@ -1,4 +1,6 @@
1
1
  import _default, { AccordionState } from "./BaseAccordion.js";
2
2
  import { AccordionItemState } from "./BaseAccordionItem.js";
3
3
  import { AccordionPanelState } from "./BaseAccordionPanel.js";
4
- export { type AccordionItemState, type AccordionPanelState, type AccordionState, _default as BaseAccordion };
4
+ import _default$1, { CollapsibleState } from "./BaseCollapsible.js";
5
+ import { CollapsiblePanelState } from "./BaseCollapsiblePanel.js";
6
+ export { type AccordionItemState, type AccordionPanelState, type AccordionState, _default as BaseAccordion, _default$1 as BaseCollapsible, type CollapsiblePanelState, type CollapsibleState };
@@ -1 +1,3 @@
1
- export { default as BaseAccordion } from "./BaseAccordion.js";
1
+ import BaseAccordion_default from "./BaseAccordion.js";
2
+ import BaseCollapsible_default from "./BaseCollapsible.js";
3
+ export { BaseAccordion_default as BaseAccordion, BaseCollapsible_default as BaseCollapsible };
@@ -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>, "value" | "defaultValue" | "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 };