@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.
- package/README.md +165 -0
- package/dist/components/dialog/BaseDialogPopup.js +2 -15
- package/dist/components/disclosure/BaseCollapsible.d.ts +33 -0
- package/dist/components/disclosure/BaseCollapsible.js +16 -0
- package/dist/components/disclosure/BaseCollapsiblePanel.d.ts +20 -0
- package/dist/components/disclosure/BaseCollapsiblePanel.js +15 -0
- package/dist/components/disclosure/BaseCollapsibleTrigger.d.ts +15 -0
- package/dist/components/disclosure/BaseCollapsibleTrigger.js +16 -0
- package/dist/components/disclosure/index.d.ts +3 -1
- package/dist/components/disclosure/index.js +3 -1
- package/dist/components/form/BaseAutocomplete.d.ts +198 -0
- package/dist/components/form/BaseAutocomplete.js +49 -0
- package/dist/components/form/BaseAutocompleteClear.d.ts +18 -0
- package/dist/components/form/BaseAutocompleteClear.js +7 -0
- package/dist/components/form/BaseAutocompleteCollection.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteCollection.js +7 -0
- package/dist/components/form/BaseAutocompleteEmpty.d.ts +11 -0
- package/dist/components/form/BaseAutocompleteEmpty.js +10 -0
- package/dist/components/form/BaseAutocompleteGroup.d.ts +10 -0
- package/dist/components/form/BaseAutocompleteGroup.js +7 -0
- package/dist/components/form/BaseAutocompleteGroupLabel.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteGroupLabel.js +7 -0
- package/dist/components/form/BaseAutocompleteIcon.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteIcon.js +7 -0
- package/dist/components/form/BaseAutocompleteInput.d.ts +12 -0
- package/dist/components/form/BaseAutocompleteInput.js +12 -0
- package/dist/components/form/BaseAutocompleteInputGroup.d.ts +9 -0
- package/dist/components/form/BaseAutocompleteInputGroup.js +11 -0
- package/dist/components/form/BaseAutocompleteItem.d.ts +20 -0
- package/dist/components/form/BaseAutocompleteItem.js +11 -0
- package/dist/components/form/BaseAutocompleteList.d.ts +14 -0
- package/dist/components/form/BaseAutocompleteList.js +11 -0
- package/dist/components/form/BaseAutocompletePopup.d.ts +111 -0
- package/dist/components/form/BaseAutocompletePopup.js +45 -0
- package/dist/components/form/BaseAutocompleteRow.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteRow.js +7 -0
- package/dist/components/form/BaseAutocompleteSeparator.d.ts +13 -0
- package/dist/components/form/BaseAutocompleteSeparator.js +7 -0
- package/dist/components/form/BaseAutocompleteStatus.d.ts +11 -0
- package/dist/components/form/BaseAutocompleteStatus.js +10 -0
- package/dist/components/form/BaseAutocompleteTrigger.d.ts +11 -0
- package/dist/components/form/BaseAutocompleteTrigger.js +7 -0
- package/dist/components/form/BaseAutocompleteValue.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteValue.js +7 -0
- package/dist/components/form/BaseFormField.d.ts +10 -1
- package/dist/components/form/BaseFormField.js +2 -2
- package/dist/components/form/BaseInput.d.ts +2 -1
- package/dist/components/form/BaseInput.js +2 -12
- package/dist/components/form/autocompleteTypes.d.ts +16 -0
- package/dist/components/form/autocompleteTypes.js +1 -0
- package/dist/components/form/index.d.ts +11 -2
- package/dist/components/form/index.js +3 -1
- package/dist/components/form/inputSizes.d.ts +11 -0
- package/dist/components/form/inputSizes.js +19 -0
- package/dist/components/form/useAutocompleteFilter.d.ts +19 -0
- package/dist/components/form/useAutocompleteFilter.js +12 -0
- package/dist/utils/split-class-name.d.ts +15 -0
- package/dist/utils/split-class-name.js +18 -0
- package/package.json +1 -1
|
@@ -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 };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type AutocompleteItemState = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
/** Whether the item is highlighted with the keyboard or the pointer. */
|
|
6
|
+
highlighted: boolean;
|
|
7
|
+
};
|
|
8
|
+
type BaseAutocompleteItemProps = Omit<ComponentProps<"div">, "id"> & {
|
|
9
|
+
render?: RenderProp<"div", AutocompleteItemState>;
|
|
10
|
+
/** The item. Its text (or `itemToStringValue`'s result) fills the input when the item is chosen. */
|
|
11
|
+
value?: unknown;
|
|
12
|
+
/** The item's position in the list. Saves the lookup in long lists. */
|
|
13
|
+
index?: number;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** Set to `true` when `render` renders a `<button>`. */
|
|
16
|
+
nativeButton?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** An option in the list. Renders a `<div>`, with `data-highlighted` and `data-disabled`. */
|
|
19
|
+
declare const BaseAutocompleteItem: ({ className, ...otherProps }: BaseAutocompleteItemProps) => import("react").JSX.Element;
|
|
20
|
+
export { BaseAutocompleteItem 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/BaseAutocompleteItem.tsx
|
|
6
|
+
/** An option in the list. Renders a `<div>`, with `data-highlighted` and `data-disabled`. */
|
|
7
|
+
const BaseAutocompleteItem = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Autocomplete.Item, {
|
|
8
|
+
...otherProps,
|
|
9
|
+
className: cn("flex cursor-default items-center gap-2 outline-none select-none", className)
|
|
10
|
+
});
|
|
11
|
+
export { BaseAutocompleteItem as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
export type AutocompleteListState = {
|
|
4
|
+
/** Whether no item matches. */
|
|
5
|
+
empty: boolean;
|
|
6
|
+
};
|
|
7
|
+
type BaseAutocompleteListProps<Item> = Omit<ComponentProps<"div">, "children"> & {
|
|
8
|
+
render?: RenderProp<"div", AutocompleteListState>;
|
|
9
|
+
/** The items, or a function that renders each filtered item (or group) of `BaseAutocomplete`'s `items`. */
|
|
10
|
+
children?: ReactNode | ((item: Item, index: number) => ReactNode);
|
|
11
|
+
};
|
|
12
|
+
/** The scrollable list of items. Renders a `<div>`, with `data-empty` when no item matches. */
|
|
13
|
+
declare const BaseAutocompleteList: <Item>({ className, ...otherProps }: BaseAutocompleteListProps<Item>) => import("react").JSX.Element;
|
|
14
|
+
export { BaseAutocompleteList 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/BaseAutocompleteList.tsx
|
|
6
|
+
/** The scrollable list of items. Renders a `<div>`, with `data-empty` when no item matches. */
|
|
7
|
+
const BaseAutocompleteList = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Autocomplete.List, {
|
|
8
|
+
...otherProps,
|
|
9
|
+
className: cn("min-h-0 flex-1 overflow-y-auto overscroll-contain outline-none", className)
|
|
10
|
+
});
|
|
11
|
+
export { BaseAutocompleteList as default };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { AutocompleteAlign, AutocompleteInteractionType, AutocompleteSide } from "./autocompleteTypes.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps, ReactNode, RefObject } from "react";
|
|
4
|
+
export type AutocompletePopupState = {
|
|
5
|
+
open: boolean;
|
|
6
|
+
side: AutocompleteSide;
|
|
7
|
+
align: AutocompleteAlign;
|
|
8
|
+
/** Whether the input the popup is placed against is scrolled out of view. */
|
|
9
|
+
anchorHidden: boolean;
|
|
10
|
+
/** Whether no item matches. */
|
|
11
|
+
empty: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type AutocompletePositionerState = AutocompletePopupState;
|
|
14
|
+
export type AutocompleteArrowState = {
|
|
15
|
+
open: boolean;
|
|
16
|
+
side: AutocompleteSide;
|
|
17
|
+
align: AutocompleteAlign;
|
|
18
|
+
/** Whether the arrow can't point at the center of the input. */
|
|
19
|
+
uncentered: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type AutocompleteBackdropState = {
|
|
22
|
+
open: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* - `true`: the default.
|
|
26
|
+
* - `false`: don't move focus.
|
|
27
|
+
* - a ref: focus that element.
|
|
28
|
+
* - a function: return an element, `true` for the default, or `false` / `undefined` to not move focus.
|
|
29
|
+
*/
|
|
30
|
+
export type AutocompleteFocusTarget = boolean | RefObject<HTMLElement | null> | ((interactionType: AutocompleteInteractionType) => boolean | HTMLElement | null | void);
|
|
31
|
+
/** Computes an offset from the popup's placement and the sizes of the input and the popup. */
|
|
32
|
+
export type AutocompleteOffsetFunction = (data: {
|
|
33
|
+
side: AutocompleteSide;
|
|
34
|
+
align: AutocompleteAlign;
|
|
35
|
+
anchor: {
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
};
|
|
39
|
+
positioner: {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
};
|
|
43
|
+
}) => number;
|
|
44
|
+
/** How the popup avoids the edges of `collisionBoundary`. */
|
|
45
|
+
export type AutocompleteCollisionAvoidance = {
|
|
46
|
+
side?: "flip" | "none";
|
|
47
|
+
align?: "flip" | "shift" | "none";
|
|
48
|
+
fallbackAxisSide?: "start" | "end" | "none";
|
|
49
|
+
} | {
|
|
50
|
+
side?: "shift" | "none";
|
|
51
|
+
align?: "shift" | "none";
|
|
52
|
+
fallbackAxisSide?: "start" | "end" | "none";
|
|
53
|
+
};
|
|
54
|
+
type Rect = {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
};
|
|
60
|
+
type BaseAutocompletePopupProps = ComponentProps<"div"> & {
|
|
61
|
+
render?: RenderProp<"div", AutocompletePopupState>;
|
|
62
|
+
/** The element focused when the popup closes. */
|
|
63
|
+
finalFocus?: AutocompleteFocusTarget;
|
|
64
|
+
/** Where the popup is portaled to. Defaults to `<body>`. */
|
|
65
|
+
container?: HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null;
|
|
66
|
+
/** Keeps the popup in the DOM while it's closed. */
|
|
67
|
+
keepMounted?: boolean;
|
|
68
|
+
/** The element the popup is placed against. Defaults to the input group, or the input. */
|
|
69
|
+
anchor?: Element | RefObject<Element | null> | (() => Element | null) | null;
|
|
70
|
+
/** @default "absolute" */
|
|
71
|
+
positionMethod?: "absolute" | "fixed";
|
|
72
|
+
/** @default "bottom" */
|
|
73
|
+
side?: AutocompleteSide;
|
|
74
|
+
/** Distance from the input in pixels. @default 0 */
|
|
75
|
+
sideOffset?: number | AutocompleteOffsetFunction;
|
|
76
|
+
/** @default "start" */
|
|
77
|
+
align?: AutocompleteAlign;
|
|
78
|
+
/** Shift along the side in pixels. @default 0 */
|
|
79
|
+
alignOffset?: number | AutocompleteOffsetFunction;
|
|
80
|
+
/** @default "clipping-ancestors" */
|
|
81
|
+
collisionBoundary?: "clipping-ancestors" | Element | Element[] | Rect;
|
|
82
|
+
/** Space kept from the boundary's edges, in pixels. @default 5 */
|
|
83
|
+
collisionPadding?: number | {
|
|
84
|
+
top?: number;
|
|
85
|
+
right?: number;
|
|
86
|
+
bottom?: number;
|
|
87
|
+
left?: number;
|
|
88
|
+
};
|
|
89
|
+
collisionAvoidance?: AutocompleteCollisionAvoidance;
|
|
90
|
+
/** Keeps the popup in view while the input is scrolled out of view. */
|
|
91
|
+
sticky?: boolean;
|
|
92
|
+
/** Minimum distance between the arrow and the popup's corners, in pixels. @default 5 */
|
|
93
|
+
arrowPadding?: number;
|
|
94
|
+
/** Stops following the input when it moves (e.g. on scroll). */
|
|
95
|
+
disableAnchorTracking?: boolean;
|
|
96
|
+
/** Replaces the element that positions the popup. Give it e.g. a `z-index`. */
|
|
97
|
+
renderPositioner?: RenderProp<"div", AutocompletePositionerState>;
|
|
98
|
+
/** Renders a backdrop under the popup. Use it with `modal` on `BaseAutocomplete`. */
|
|
99
|
+
backdrop?: boolean;
|
|
100
|
+
/** A `className` on the element replaces the kit's conflicting classes. */
|
|
101
|
+
renderBackdrop?: RenderProp<"div", AutocompleteBackdropState>;
|
|
102
|
+
/** The arrow's content (e.g. an `<svg>`). The arrow is rendered when this or `renderArrow` is given. */
|
|
103
|
+
arrow?: ReactNode;
|
|
104
|
+
renderArrow?: RenderProp<"div", AutocompleteArrowState>;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The floating list container, with its portal, positioner and an optional backdrop and arrow.
|
|
108
|
+
* As wide as the input by default, never taller than the space left in the viewport. Renders a `<div>`.
|
|
109
|
+
*/
|
|
110
|
+
declare const BaseAutocompletePopup: ({ container, keepMounted, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, collisionAvoidance, sticky, arrowPadding, disableAnchorTracking, renderPositioner, backdrop, renderBackdrop, arrow, renderArrow, className, children, ...otherProps }: BaseAutocompletePopupProps) => import("react").JSX.Element;
|
|
111
|
+
export { BaseAutocompletePopup as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Autocomplete } from "@base-ui/react/autocomplete";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { splitClassName } from "../../utils/split-class-name.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/components/form/BaseAutocompletePopup.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The floating list container, with its portal, positioner and an optional backdrop and arrow.
|
|
9
|
+
* As wide as the input by default, never taller than the space left in the viewport. Renders a `<div>`.
|
|
10
|
+
*/
|
|
11
|
+
const BaseAutocompletePopup = ({ container, keepMounted, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, collisionAvoidance, sticky, arrowPadding, disableAnchorTracking, renderPositioner, backdrop = false, renderBackdrop, arrow, renderArrow, className, children, ...otherProps }) => {
|
|
12
|
+
const backdropElement = splitClassName(renderBackdrop);
|
|
13
|
+
return /* @__PURE__ */ jsxs(Autocomplete.Portal, {
|
|
14
|
+
container,
|
|
15
|
+
keepMounted,
|
|
16
|
+
children: [backdrop && /* @__PURE__ */ jsx(Autocomplete.Backdrop, {
|
|
17
|
+
render: backdropElement.render,
|
|
18
|
+
className: cn("fixed inset-0", backdropElement.className)
|
|
19
|
+
}), /* @__PURE__ */ jsx(Autocomplete.Positioner, {
|
|
20
|
+
anchor,
|
|
21
|
+
positionMethod,
|
|
22
|
+
side,
|
|
23
|
+
sideOffset,
|
|
24
|
+
align,
|
|
25
|
+
alignOffset,
|
|
26
|
+
collisionBoundary,
|
|
27
|
+
collisionPadding,
|
|
28
|
+
collisionAvoidance,
|
|
29
|
+
sticky,
|
|
30
|
+
arrowPadding,
|
|
31
|
+
disableAnchorTracking,
|
|
32
|
+
render: renderPositioner,
|
|
33
|
+
className: "outline-none",
|
|
34
|
+
children: /* @__PURE__ */ jsxs(Autocomplete.Popup, {
|
|
35
|
+
...otherProps,
|
|
36
|
+
className: cn("flex", "flex-col", "w-(--anchor-width)", "max-w-(--available-width)", "max-h-[min(var(--available-height),24rem)]", "origin-(--transform-origin)", "transition-[opacity,scale]", "duration-150", "data-ending-style:scale-95", "data-ending-style:opacity-0", "data-starting-style:scale-95", "data-starting-style:opacity-0", className),
|
|
37
|
+
children: [(typeof arrow !== "undefined" || renderArrow) && /* @__PURE__ */ jsx(Autocomplete.Arrow, {
|
|
38
|
+
render: renderArrow,
|
|
39
|
+
children: arrow
|
|
40
|
+
}), children]
|
|
41
|
+
})
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export { BaseAutocompletePopup as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type BaseAutocompleteRowProps = ComponentProps<"div"> & {
|
|
4
|
+
render?: RenderProp<"div">;
|
|
5
|
+
};
|
|
6
|
+
/** A row of items in a grid list (`BaseAutocomplete` with `grid`). Renders a `<div>`. */
|
|
7
|
+
declare const BaseAutocompleteRow: (props: BaseAutocompleteRowProps) => import("react").JSX.Element;
|
|
8
|
+
export { BaseAutocompleteRow 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/BaseAutocompleteRow.tsx
|
|
5
|
+
/** A row of items in a grid list (`BaseAutocomplete` with `grid`). Renders a `<div>`. */
|
|
6
|
+
const BaseAutocompleteRow = (props) => /* @__PURE__ */ jsx(Autocomplete.Row, { ...props });
|
|
7
|
+
export { BaseAutocompleteRow as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type AutocompleteSeparatorState = {
|
|
4
|
+
orientation: "horizontal" | "vertical";
|
|
5
|
+
};
|
|
6
|
+
type BaseAutocompleteSeparatorProps = ComponentProps<"div"> & {
|
|
7
|
+
render?: RenderProp<"div", AutocompleteSeparatorState>;
|
|
8
|
+
/** @default "horizontal" */
|
|
9
|
+
orientation?: "horizontal" | "vertical";
|
|
10
|
+
};
|
|
11
|
+
/** A line between items or groups. Renders a `<div>` with `role="separator"` and `data-orientation`. */
|
|
12
|
+
declare const BaseAutocompleteSeparator: (props: BaseAutocompleteSeparatorProps) => import("react").JSX.Element;
|
|
13
|
+
export { BaseAutocompleteSeparator 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/BaseAutocompleteSeparator.tsx
|
|
5
|
+
/** A line between items or groups. Renders a `<div>` with `role="separator"` and `data-orientation`. */
|
|
6
|
+
const BaseAutocompleteSeparator = (props) => /* @__PURE__ */ jsx(Autocomplete.Separator, { ...props });
|
|
7
|
+
export { BaseAutocompleteSeparator as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type BaseAutocompleteStatusProps = ComponentProps<"div"> & {
|
|
4
|
+
render?: RenderProp<"div">;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* A live region announced by screen readers, e.g. "Loading…" or "12 results".
|
|
8
|
+
* Renders a `<div>`. Keep it mounted and change its children.
|
|
9
|
+
*/
|
|
10
|
+
declare const BaseAutocompleteStatus: (props: BaseAutocompleteStatusProps) => import("react").JSX.Element;
|
|
11
|
+
export { BaseAutocompleteStatus 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/BaseAutocompleteStatus.tsx
|
|
5
|
+
/**
|
|
6
|
+
* A live region announced by screen readers, e.g. "Loading…" or "12 results".
|
|
7
|
+
* Renders a `<div>`. Keep it mounted and change its children.
|
|
8
|
+
*/
|
|
9
|
+
const BaseAutocompleteStatus = (props) => /* @__PURE__ */ jsx(Autocomplete.Status, { ...props });
|
|
10
|
+
export { BaseAutocompleteStatus as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AutocompleteInputState } from "./autocompleteTypes.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
type BaseAutocompleteTriggerProps = ComponentProps<"button"> & {
|
|
5
|
+
render?: RenderProp<"button", AutocompleteInputState>;
|
|
6
|
+
/** Set to `false` when `render` doesn't render a `<button>`. */
|
|
7
|
+
nativeButton?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** A button that opens the popup. Renders a `<button>`, with `data-popup-open` while the popup is open. */
|
|
10
|
+
declare const BaseAutocompleteTrigger: (props: BaseAutocompleteTriggerProps) => import("react").JSX.Element;
|
|
11
|
+
export { BaseAutocompleteTrigger 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/BaseAutocompleteTrigger.tsx
|
|
5
|
+
/** A button that opens the popup. Renders a `<button>`, with `data-popup-open` while the popup is open. */
|
|
6
|
+
const BaseAutocompleteTrigger = (props) => /* @__PURE__ */ jsx(Autocomplete.Trigger, { ...props });
|
|
7
|
+
export { BaseAutocompleteTrigger as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
type BaseAutocompleteValueProps = {
|
|
3
|
+
/** Shown as is, or a function of the input's value. Without children, renders the value. */
|
|
4
|
+
children?: ReactNode | ((value: string) => ReactNode);
|
|
5
|
+
};
|
|
6
|
+
/** The input's current value, anywhere inside `BaseAutocomplete`. Renders no element. */
|
|
7
|
+
declare const BaseAutocompleteValue: (props: BaseAutocompleteValueProps) => import("react").JSX.Element;
|
|
8
|
+
export { BaseAutocompleteValue 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/BaseAutocompleteValue.tsx
|
|
5
|
+
/** The input's current value, anywhere inside `BaseAutocomplete`. Renders no element. */
|
|
6
|
+
const BaseAutocompleteValue = (props) => /* @__PURE__ */ jsx(Autocomplete.Value, { ...props });
|
|
7
|
+
export { BaseAutocompleteValue as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
3
|
import { ZodType } from "zod";
|
|
3
4
|
export type FieldState = {
|
|
4
5
|
disabled: boolean;
|
|
@@ -11,14 +12,22 @@ export type FieldState = {
|
|
|
11
12
|
filled: boolean;
|
|
12
13
|
focused: boolean;
|
|
13
14
|
};
|
|
15
|
+
/** The native constraints read from the field's schema. */
|
|
16
|
+
export type FieldConstraints = Pick<ComponentProps<"input">, "type" | "required" | "minLength" | "maxLength" | "min" | "max">;
|
|
14
17
|
type BaseFormFieldProps = {
|
|
15
18
|
schema: ZodType;
|
|
16
19
|
name: string;
|
|
17
20
|
label?: string;
|
|
18
21
|
control?: RenderProp<"input", FieldState>;
|
|
22
|
+
/**
|
|
23
|
+
* Renders a control that isn't a single `<input>` (e.g. `BaseAutocomplete`) instead of `control`.
|
|
24
|
+
* Gets the constraints read from `schema`; pass on the ones the control supports.
|
|
25
|
+
* The control takes the field's `name` by itself.
|
|
26
|
+
*/
|
|
27
|
+
children?: (constraints: FieldConstraints) => ReactNode;
|
|
19
28
|
renderLabel?: RenderProp<"label", FieldState>;
|
|
20
29
|
renderErrors?: RenderProp<"div", FieldState>;
|
|
21
30
|
className?: string;
|
|
22
31
|
};
|
|
23
|
-
declare const BaseFormField: ({ schema, name, label, control, renderLabel, renderErrors, className }: BaseFormFieldProps) => import("react").JSX.Element;
|
|
32
|
+
declare const BaseFormField: ({ schema, name, label, control, children, renderLabel, renderErrors, className }: BaseFormFieldProps) => import("react").JSX.Element;
|
|
24
33
|
export { BaseFormField as default };
|
|
@@ -7,7 +7,7 @@ import FieldRoot from "./FieldRoot.js";
|
|
|
7
7
|
import ServerSideError from "./ServerSideError.js";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
// src/components/form/BaseFormField.tsx
|
|
10
|
-
const BaseFormField = ({ schema, name, label, control, renderLabel, renderErrors, className }) => /* @__PURE__ */ jsxs(FieldRoot, {
|
|
10
|
+
const BaseFormField = ({ schema, name, label, control, children, renderLabel, renderErrors, className }) => /* @__PURE__ */ jsxs(FieldRoot, {
|
|
11
11
|
name,
|
|
12
12
|
className: cn("flex w-full flex-col items-start gap-1", className),
|
|
13
13
|
children: [
|
|
@@ -15,7 +15,7 @@ const BaseFormField = ({ schema, name, label, control, renderLabel, renderErrors
|
|
|
15
15
|
render: renderLabel,
|
|
16
16
|
children: label
|
|
17
17
|
}),
|
|
18
|
-
/* @__PURE__ */ jsx(Field.Control, {
|
|
18
|
+
children ? children(getFieldConstraints(schema)) : /* @__PURE__ */ jsx(Field.Control, {
|
|
19
19
|
name,
|
|
20
20
|
render: control,
|
|
21
21
|
...getFieldConstraints(schema)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
import JustInput from "../elements/JustInput.js";
|
|
3
|
+
import { InputSize } from "./inputSizes.js";
|
|
3
4
|
type BaseInputProps = Omit<ComponentProps<typeof JustInput>, "size"> & {
|
|
4
|
-
size?:
|
|
5
|
+
size?: InputSize;
|
|
5
6
|
};
|
|
6
7
|
declare const BaseInput: ({ size, className, ...otherProps }: BaseInputProps) => import("react").JSX.Element;
|
|
7
8
|
export { BaseInput as default };
|
|
@@ -2,21 +2,11 @@
|
|
|
2
2
|
import { cn } from "cn";
|
|
3
3
|
import "react";
|
|
4
4
|
import JustInput from "../elements/JustInput.js";
|
|
5
|
+
import { inputBaseClasses, inputSizeClasses } from "./inputSizes.js";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
// src/components/form/BaseInput.tsx
|
|
7
8
|
const BaseInput = ({ size = "md", className, ...otherProps }) => /* @__PURE__ */ jsx(JustInput, {
|
|
8
9
|
...otherProps,
|
|
9
|
-
className: cn(
|
|
10
|
-
"h-12 px-5 text-base": size === "lg",
|
|
11
|
-
"h-9 px-3 text-sm": size === "md",
|
|
12
|
-
"h-8 px-2.5 text-sm": size === "sm",
|
|
13
|
-
"h-7 px-2 text-xs": size === "xs"
|
|
14
|
-
}, [
|
|
15
|
-
"rounded-md",
|
|
16
|
-
"outline-2",
|
|
17
|
-
"outline-offset-2",
|
|
18
|
-
"outline-transparent",
|
|
19
|
-
"transition-colors"
|
|
20
|
-
], className)
|
|
10
|
+
className: cn(inputSizeClasses(size), inputBaseClasses, className)
|
|
21
11
|
});
|
|
22
12
|
export { BaseInput as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FieldState } from "./BaseFormField.js";
|
|
2
|
+
/** The side of the input the popup is placed on. */
|
|
3
|
+
export type AutocompleteSide = "top" | "bottom" | "left" | "right" | "inline-end" | "inline-start";
|
|
4
|
+
/** How the popup is aligned along its side. */
|
|
5
|
+
export type AutocompleteAlign = "start" | "center" | "end";
|
|
6
|
+
/** State of the input, the input group and the trigger. */
|
|
7
|
+
export type AutocompleteInputState = FieldState & {
|
|
8
|
+
open: boolean;
|
|
9
|
+
readOnly: boolean;
|
|
10
|
+
/** The side the popup is placed on, `null` while it's closed. */
|
|
11
|
+
popupSide: AutocompleteSide | null;
|
|
12
|
+
/** Whether no item matches. */
|
|
13
|
+
listEmpty: boolean;
|
|
14
|
+
};
|
|
15
|
+
/** How the popup was opened or closed. Empty when it's unknown (e.g. opened from code). */
|
|
16
|
+
export type AutocompleteInteractionType = "mouse" | "touch" | "pen" | "keyboard" | "";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,7 +3,16 @@ import BaseSwitch, { SwitchState } from "./BaseSwitch.js";
|
|
|
3
3
|
import BaseCheckbox, { CheckboxState } from "./BaseCheckbox.js";
|
|
4
4
|
import BaseCheckboxGroup, { CheckboxGroupState } from "./BaseCheckboxGroup.js";
|
|
5
5
|
import BaseForm from "./BaseForm.js";
|
|
6
|
-
import BaseFormField, { FieldState } from "./BaseFormField.js";
|
|
6
|
+
import BaseFormField, { FieldConstraints, FieldState } from "./BaseFormField.js";
|
|
7
7
|
import useFormMessages from "./useFormMessages.js";
|
|
8
8
|
import { DisplayedFormMessage, MessageFormatter } from "./FormContext.js";
|
|
9
|
-
|
|
9
|
+
import _default, { AutocompleteActions, AutocompleteHighlightReason, AutocompleteItemGroup } from "./BaseAutocomplete.js";
|
|
10
|
+
import useAutocompleteFilter, { AutocompleteFilter, UseAutocompleteFilterOptions } from "./useAutocompleteFilter.js";
|
|
11
|
+
import { AutocompleteAlign, AutocompleteInputState, AutocompleteInteractionType, AutocompleteSide } from "./autocompleteTypes.js";
|
|
12
|
+
import { AutocompleteClearState } from "./BaseAutocompleteClear.js";
|
|
13
|
+
import { AutocompleteItemState } from "./BaseAutocompleteItem.js";
|
|
14
|
+
import { AutocompleteListState } from "./BaseAutocompleteList.js";
|
|
15
|
+
import { AutocompleteArrowState, AutocompleteBackdropState, AutocompleteCollisionAvoidance, AutocompleteFocusTarget, AutocompleteOffsetFunction, AutocompletePopupState, AutocompletePositionerState } from "./BaseAutocompletePopup.js";
|
|
16
|
+
import { AutocompleteSeparatorState } from "./BaseAutocompleteSeparator.js";
|
|
17
|
+
import { InputSize } from "./inputSizes.js";
|
|
18
|
+
export { type AutocompleteActions, type AutocompleteAlign, type AutocompleteArrowState, type AutocompleteBackdropState, type AutocompleteClearState, type AutocompleteCollisionAvoidance, type AutocompleteFilter, type AutocompleteFocusTarget, type AutocompleteHighlightReason, type AutocompleteInputState, type AutocompleteInteractionType, type AutocompleteItemGroup, type AutocompleteItemState, type AutocompleteListState, type AutocompleteOffsetFunction, type AutocompletePopupState, type AutocompletePositionerState, type AutocompleteSeparatorState, type AutocompleteSide, _default as BaseAutocomplete, BaseCheckbox, BaseCheckboxGroup, BaseForm, BaseFormField, BaseInput, BaseSwitch, type CheckboxGroupState, type CheckboxState, type DisplayedFormMessage, type FieldConstraints, type FieldState, type InputSize, type MessageFormatter, type SwitchState, type UseAutocompleteFilterOptions, useAutocompleteFilter, useFormMessages };
|
|
@@ -5,4 +5,6 @@ import BaseCheckboxGroup from "./BaseCheckboxGroup.js";
|
|
|
5
5
|
import BaseForm from "./BaseForm.js";
|
|
6
6
|
import BaseFormField from "./BaseFormField.js";
|
|
7
7
|
import useFormMessages from "./useFormMessages.js";
|
|
8
|
-
|
|
8
|
+
import BaseAutocomplete_default from "./BaseAutocomplete.js";
|
|
9
|
+
import useAutocompleteFilter from "./useAutocompleteFilter.js";
|
|
10
|
+
export { BaseAutocomplete_default as BaseAutocomplete, BaseCheckbox, BaseCheckboxGroup, BaseForm, BaseFormField, BaseInput, BaseSwitch, useAutocompleteFilter, useFormMessages };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The text input sizes, shared by every input-like control so they line up in a form. */
|
|
2
|
+
export type InputSize = "lg" | "md" | "sm" | "xs";
|
|
3
|
+
/** Height, padding and text size of a text input, for `cn`. */
|
|
4
|
+
export declare function inputSizeClasses(size: InputSize): {
|
|
5
|
+
"h-12 px-5 text-base": boolean;
|
|
6
|
+
"h-9 px-3 text-sm": boolean;
|
|
7
|
+
"h-8 px-2.5 text-sm": boolean;
|
|
8
|
+
"h-7 px-2 text-xs": boolean;
|
|
9
|
+
};
|
|
10
|
+
/** The colorless base of a text input: corners, a hidden focus outline and color transitions. */
|
|
11
|
+
export declare const inputBaseClasses: string[];
|