@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.
- package/README.md +138 -0
- package/dist/components/dialog/BaseDialogPopup.js +2 -15
- 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/BaseCheckbox.d.ts +6 -1
- package/dist/components/form/BaseCheckbox.js +10 -3
- package/dist/components/form/BaseCheckboxGroup.d.ts +24 -0
- package/dist/components/form/BaseCheckboxGroup.js +20 -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 +12 -2
- package/dist/components/form/index.js +4 -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,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 };
|
|
@@ -28,6 +28,11 @@ type BaseCheckboxProps = Omit<ComponentProps<"span">, "onChange" | "defaultCheck
|
|
|
28
28
|
defaultChecked?: boolean;
|
|
29
29
|
/** Shows the mixed state. It doesn't change `checked`. */
|
|
30
30
|
indeterminate?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Makes this the "select all" checkbox of a `BaseCheckboxGroup` with `allValues`.
|
|
33
|
+
* It checks or clears the whole group, is indeterminate when only some boxes are checked, and isn't submitted.
|
|
34
|
+
*/
|
|
35
|
+
parent?: boolean;
|
|
31
36
|
/** Called with the new state and the DOM event that changed it. */
|
|
32
37
|
onCheckedChange?: (checked: boolean, event: Event) => void;
|
|
33
38
|
disabled?: boolean;
|
|
@@ -40,5 +45,5 @@ type BaseCheckboxProps = Omit<ComponentProps<"span">, "onChange" | "defaultCheck
|
|
|
40
45
|
/** Set to `true` when `render` renders a `<button>`. */
|
|
41
46
|
nativeButton?: boolean;
|
|
42
47
|
};
|
|
43
|
-
declare const BaseCheckbox: ({ label, labelClassName, icon, indeterminateIcon, renderIndicator, keepIndicatorMounted, onCheckedChange, value, uncheckedValue, indeterminate, className, ...otherProps }: BaseCheckboxProps) => import("react").JSX.Element;
|
|
48
|
+
declare const BaseCheckbox: ({ label, labelClassName, icon, indeterminateIcon, renderIndicator, keepIndicatorMounted, onCheckedChange, value, uncheckedValue, indeterminate, parent, className, ...otherProps }: BaseCheckboxProps) => import("react").JSX.Element;
|
|
44
49
|
export { BaseCheckbox as default };
|
|
@@ -2,22 +2,29 @@
|
|
|
2
2
|
import { Checkbox } from "@base-ui/react/checkbox";
|
|
3
3
|
import { cn } from "cn";
|
|
4
4
|
import "react";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
// src/components/form/BaseCheckbox.tsx
|
|
7
|
-
const BaseCheckbox = ({ label, labelClassName, icon, indeterminateIcon, renderIndicator, keepIndicatorMounted, onCheckedChange, value = "true", uncheckedValue = "false", indeterminate, className, ...otherProps }) => /* @__PURE__ */ jsxs("label", {
|
|
7
|
+
const BaseCheckbox = ({ label, labelClassName, icon, indeterminateIcon, renderIndicator, keepIndicatorMounted, onCheckedChange, value = "true", uncheckedValue = "false", indeterminate, parent, className, ...otherProps }) => /* @__PURE__ */ jsxs("label", {
|
|
8
8
|
className: cn("flex items-center gap-2 text-sm font-normal", labelClassName),
|
|
9
9
|
children: [/* @__PURE__ */ jsx(Checkbox.Root, {
|
|
10
10
|
...otherProps,
|
|
11
11
|
value,
|
|
12
12
|
uncheckedValue,
|
|
13
13
|
indeterminate,
|
|
14
|
+
parent,
|
|
14
15
|
onCheckedChange: onCheckedChange && ((checked, details) => onCheckedChange(checked, details.event)),
|
|
15
16
|
className: cn("flex", "size-4", "shrink-0", "items-center", "justify-center", "transition-colors", "duration-150", "ease-[ease]", "focus-visible:outline-2", "focus-visible:outline-offset-2", className),
|
|
16
17
|
children: /* @__PURE__ */ jsx(Checkbox.Indicator, {
|
|
17
18
|
keepMounted: keepIndicatorMounted,
|
|
18
19
|
className: "flex size-full items-center justify-center",
|
|
19
20
|
render: renderIndicator,
|
|
20
|
-
children:
|
|
21
|
+
children: parent ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
22
|
+
className: "contents in-data-indeterminate:hidden",
|
|
23
|
+
children: icon
|
|
24
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
25
|
+
className: "hidden in-data-indeterminate:contents",
|
|
26
|
+
children: indeterminateIcon ?? icon
|
|
27
|
+
})] }) : indeterminate ? indeterminateIcon ?? icon : icon
|
|
21
28
|
})
|
|
22
29
|
}), label]
|
|
23
30
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type CheckboxGroupState = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
};
|
|
6
|
+
type BaseCheckboxGroupProps = Omit<ComponentProps<"div">, "onChange" | "defaultValue"> & {
|
|
7
|
+
render?: RenderProp<"div", CheckboxGroupState>;
|
|
8
|
+
/**
|
|
9
|
+
* Submitted name of every checkbox in the group.
|
|
10
|
+
* Each checked box adds its own `value` under this name, so the server gets them all with `formData.getAll(name)`.
|
|
11
|
+
*/
|
|
12
|
+
name?: string;
|
|
13
|
+
/** The `value`s of the checked boxes, when controlled. */
|
|
14
|
+
value?: string[];
|
|
15
|
+
/** The `value`s of the boxes checked at first. */
|
|
16
|
+
defaultValue?: string[];
|
|
17
|
+
/** Called with the new list of checked `value`s and the DOM event that changed it. */
|
|
18
|
+
onValueChange?: (value: string[], event: Event) => void;
|
|
19
|
+
/** Every child `value`. Needed by a parent ("select all") checkbox. */
|
|
20
|
+
allValues?: string[];
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
};
|
|
23
|
+
declare const BaseCheckboxGroup: ({ name, onValueChange, className, ...otherProps }: BaseCheckboxGroupProps) => import("react").JSX.Element;
|
|
24
|
+
export { BaseCheckboxGroup as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { CheckboxGroup } from "@base-ui/react/checkbox-group";
|
|
3
|
+
import { Field } from "@base-ui/react/field";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/form/BaseCheckboxGroup.tsx
|
|
7
|
+
const BaseCheckboxGroup = ({ name, onValueChange, className, ...otherProps }) => {
|
|
8
|
+
const group = /* @__PURE__ */ jsx(CheckboxGroup, {
|
|
9
|
+
...otherProps,
|
|
10
|
+
onValueChange: onValueChange && ((value, details) => onValueChange(value, details.event)),
|
|
11
|
+
className: cn("flex flex-col gap-2", className)
|
|
12
|
+
});
|
|
13
|
+
if (!name) return group;
|
|
14
|
+
return /* @__PURE__ */ jsx(Field.Root, {
|
|
15
|
+
name,
|
|
16
|
+
className: "contents",
|
|
17
|
+
children: group
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
export { BaseCheckboxGroup 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 {};
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import BaseInput from "./BaseInput.js";
|
|
2
2
|
import BaseSwitch, { SwitchState } from "./BaseSwitch.js";
|
|
3
3
|
import BaseCheckbox, { CheckboxState } from "./BaseCheckbox.js";
|
|
4
|
+
import BaseCheckboxGroup, { CheckboxGroupState } from "./BaseCheckboxGroup.js";
|
|
4
5
|
import BaseForm from "./BaseForm.js";
|
|
5
|
-
import BaseFormField, { FieldState } from "./BaseFormField.js";
|
|
6
|
+
import BaseFormField, { FieldConstraints, FieldState } from "./BaseFormField.js";
|
|
6
7
|
import useFormMessages from "./useFormMessages.js";
|
|
7
8
|
import { DisplayedFormMessage, MessageFormatter } from "./FormContext.js";
|
|
8
|
-
|
|
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 };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import BaseInput from "./BaseInput.js";
|
|
2
2
|
import BaseSwitch from "./BaseSwitch.js";
|
|
3
3
|
import BaseCheckbox from "./BaseCheckbox.js";
|
|
4
|
+
import BaseCheckboxGroup from "./BaseCheckboxGroup.js";
|
|
4
5
|
import BaseForm from "./BaseForm.js";
|
|
5
6
|
import BaseFormField from "./BaseFormField.js";
|
|
6
7
|
import useFormMessages from "./useFormMessages.js";
|
|
7
|
-
|
|
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[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/components/form/inputSizes.ts
|
|
2
|
+
/** Height, padding and text size of a text input, for `cn`. */
|
|
3
|
+
function inputSizeClasses(size) {
|
|
4
|
+
return {
|
|
5
|
+
"h-12 px-5 text-base": size === "lg",
|
|
6
|
+
"h-9 px-3 text-sm": size === "md",
|
|
7
|
+
"h-8 px-2.5 text-sm": size === "sm",
|
|
8
|
+
"h-7 px-2 text-xs": size === "xs"
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/** The colorless base of a text input: corners, a hidden focus outline and color transitions. */
|
|
12
|
+
const inputBaseClasses = [
|
|
13
|
+
"rounded-md",
|
|
14
|
+
"outline-2",
|
|
15
|
+
"outline-offset-2",
|
|
16
|
+
"outline-transparent",
|
|
17
|
+
"transition-colors"
|
|
18
|
+
];
|
|
19
|
+
export { inputBaseClasses, inputSizeClasses };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Locale-aware string matchers. `itemToString` turns an object item into the text to match. */
|
|
2
|
+
export type AutocompleteFilter = {
|
|
3
|
+
/** Whether the item contains the query anywhere. */
|
|
4
|
+
contains: <Item>(item: Item, query: string, itemToString?: (item: Item) => string) => boolean;
|
|
5
|
+
/** Whether the item starts with the query. */
|
|
6
|
+
startsWith: <Item>(item: Item, query: string, itemToString?: (item: Item) => string) => boolean;
|
|
7
|
+
/** Whether the item ends with the query. */
|
|
8
|
+
endsWith: <Item>(item: Item, query: string, itemToString?: (item: Item) => string) => boolean;
|
|
9
|
+
};
|
|
10
|
+
export type UseAutocompleteFilterOptions = Intl.CollatorOptions & {
|
|
11
|
+
/** Defaults to the user's locale. */
|
|
12
|
+
locale?: Intl.LocalesArgument;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Returns locale-aware matchers (`Intl.Collator`, case- and accent-insensitive by default with
|
|
16
|
+
* `sensitivity: "base"`) for `BaseAutocomplete`'s `filter` prop, or for filtering items yourself
|
|
17
|
+
* (e.g. before passing `filteredItems`).
|
|
18
|
+
*/
|
|
19
|
+
export default function useAutocompleteFilter(options?: UseAutocompleteFilterOptions): AutocompleteFilter;
|