@omer-x/tailwind-ui-kit 1.0.0-alpha.44 → 1.0.0-alpha.46
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 +52 -1707
- package/dist/components/form/BaseAutocomplete.d.ts +1 -1
- package/dist/components/form/BaseSlider.d.ts +136 -0
- package/dist/components/form/BaseSlider.js +66 -0
- package/dist/components/form/BaseSliderControl.d.ts +12 -0
- package/dist/components/form/BaseSliderControl.js +14 -0
- package/dist/components/form/BaseSliderIndicator.d.ts +12 -0
- package/dist/components/form/BaseSliderIndicator.js +14 -0
- package/dist/components/form/BaseSliderLabel.d.ts +9 -0
- package/dist/components/form/BaseSliderLabel.js +7 -0
- package/dist/components/form/BaseSliderThumb.d.ts +30 -0
- package/dist/components/form/BaseSliderThumb.js +15 -0
- package/dist/components/form/BaseSliderTrack.d.ts +12 -0
- package/dist/components/form/BaseSliderTrack.js +12 -0
- package/dist/components/form/BaseSliderValue.d.ts +14 -0
- package/dist/components/form/BaseSliderValue.js +10 -0
- package/dist/components/form/index.d.ts +3 -1
- package/dist/components/form/index.js +2 -1
- package/dist/components/form/sliderStyles.d.ts +5 -0
- package/dist/components/form/sliderStyles.js +32 -0
- package/dist/components/menu/BaseMenu.d.ts +1 -1
- package/dist/components/menu/BaseMenubar.d.ts +1 -1
- package/dist/components/navigation/BaseTabs.d.ts +44 -0
- package/dist/components/navigation/BaseTabs.js +24 -0
- package/dist/components/navigation/BaseTabsIndicator.d.ts +30 -0
- package/dist/components/navigation/BaseTabsIndicator.js +16 -0
- package/dist/components/navigation/BaseTabsList.d.ts +19 -0
- package/dist/components/navigation/BaseTabsList.js +14 -0
- package/dist/components/navigation/BaseTabsPanel.d.ts +19 -0
- package/dist/components/navigation/BaseTabsPanel.js +11 -0
- package/dist/components/navigation/BaseTabsTab.d.ts +20 -0
- package/dist/components/navigation/BaseTabsTab.js +11 -0
- package/dist/components/navigation/index.d.ts +6 -0
- package/dist/components/navigation/index.js +1 -0
- package/dist/components/navigation/tabsTypes.d.ts +8 -0
- package/dist/components/navigation/tabsTypes.js +1 -0
- package/docs/button/BaseButton.md +32 -0
- package/docs/button/BaseToggle.md +29 -0
- package/docs/button/BaseToggleGroup.md +28 -0
- package/docs/dialog/BaseAlertDialog.md +36 -0
- package/docs/dialog/BaseDialog.md +61 -0
- package/docs/dialog/createAlertDialogHandle.md +21 -0
- package/docs/dialog/createDialogHandle.md +31 -0
- package/docs/disclosure/BaseAccordion.md +67 -0
- package/docs/disclosure/BaseCollapsible.md +56 -0
- package/docs/display/BaseAvatar.md +48 -0
- package/docs/display/BaseMeter.md +62 -0
- package/docs/elements/README.md +9 -0
- package/docs/feedback/BaseToast.md +91 -0
- package/docs/feedback/createToastManager.md +19 -0
- package/docs/feedback/useToast.md +37 -0
- package/docs/form/BaseAutocomplete.md +110 -0
- package/docs/form/BaseCheckbox.md +33 -0
- package/docs/form/BaseCheckboxGroup.md +28 -0
- package/docs/form/BaseFieldset.md +24 -0
- package/docs/form/BaseForm.md +89 -0
- package/docs/form/BaseFormField.md +47 -0
- package/docs/form/BaseInput.md +13 -0
- package/docs/form/BaseRadio.md +28 -0
- package/docs/form/BaseRadioGroup.md +35 -0
- package/docs/form/BaseSelect.md +109 -0
- package/docs/form/BaseSlider.md +93 -0
- package/docs/form/BaseSwitch.md +27 -0
- package/docs/form/useFormMessages.md +29 -0
- package/docs/hooks/useRipples.md +26 -0
- package/docs/layout/BaseSeparator.md +24 -0
- package/docs/layout/Container.md +5 -0
- package/docs/menu/BaseContextMenu.md +96 -0
- package/docs/menu/BaseMenu.md +84 -0
- package/docs/menu/BaseMenubar.md +45 -0
- package/docs/menu/createMenuHandle.md +31 -0
- package/docs/navigation/BaseTabs.md +69 -0
- package/docs/overlay/BaseTooltip.md +74 -0
- package/docs/overlay/createTooltipHandle.md +29 -0
- package/docs/page/Pagination.md +37 -0
- package/docs/page/usePagination.md +17 -0
- package/docs/providers/ToastProvider.md +11 -0
- package/docs/providers/TooltipProvider.md +17 -0
- package/docs/table/TableCell.md +16 -0
- package/docs/table/Tdx.md +5 -0
- package/docs/utils/RenderProp.md +5 -0
- package/docs/utils/cn.md +9 -0
- package/docs/utils/mergeProps.md +9 -0
- package/docs/utils/useRender.md +26 -0
- package/package.json +6 -1
|
@@ -108,7 +108,7 @@ declare const _default: (<Item>({ onValueChange, onOpenChange, onItemHighlighted
|
|
|
108
108
|
InputGroup: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
109
109
|
render?: RenderProp<"div", AutocompleteInputState>;
|
|
110
110
|
}) => import("react").JSX.Element;
|
|
111
|
-
Input: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "
|
|
111
|
+
Input: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "value" | "size"> & {
|
|
112
112
|
size?: InputSize;
|
|
113
113
|
render?: RenderProp<"input", AutocompleteInputState>;
|
|
114
114
|
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { SliderSize } from "./sliderStyles.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps, ReactNode } from "react";
|
|
4
|
+
export type SliderOrientation = "horizontal" | "vertical";
|
|
5
|
+
/** The state every slider part gets in its render function. */
|
|
6
|
+
export type SliderState = {
|
|
7
|
+
/** The values, one per thumb. */
|
|
8
|
+
values: readonly number[];
|
|
9
|
+
min: number;
|
|
10
|
+
max: number;
|
|
11
|
+
step: number;
|
|
12
|
+
orientation: SliderOrientation;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
/** A thumb is being dragged. */
|
|
15
|
+
dragging: boolean;
|
|
16
|
+
/** The index of the focused or dragged thumb, `-1` when none is. */
|
|
17
|
+
activeThumbIndex: number;
|
|
18
|
+
/** The slider has lost focus at least once (inside a `BaseFormField`). */
|
|
19
|
+
touched: boolean;
|
|
20
|
+
/** The value differs from the initial one (inside a `BaseFormField`). */
|
|
21
|
+
dirty: boolean;
|
|
22
|
+
/** `null` until the field is validated (inside a `BaseFormField`). */
|
|
23
|
+
valid: boolean | null;
|
|
24
|
+
/** A thumb has focus (inside a `BaseFormField`). */
|
|
25
|
+
focused: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** A single value is a `number`, a range (one value per thumb) an array of numbers. */
|
|
28
|
+
type SliderChangedValue<Value> = Value extends number ? number : Value;
|
|
29
|
+
type BaseSliderProps<Value extends number | readonly number[]> = Omit<ComponentProps<"div">, "children" | "defaultValue" | "onChange"> & {
|
|
30
|
+
render?: RenderProp<"div", SliderState>;
|
|
31
|
+
/** The value, controlled. An array makes a range slider with one thumb per value. */
|
|
32
|
+
value?: Value;
|
|
33
|
+
/** The initial value, uncontrolled. An array makes a range slider with one thumb per value. */
|
|
34
|
+
defaultValue?: Value;
|
|
35
|
+
/** Called with the new value and the DOM event that changed it, on every move. */
|
|
36
|
+
onValueChange?: (value: SliderChangedValue<Value>, event: Event) => void;
|
|
37
|
+
/** Called with the final value when the user releases the thumb or finishes a key press. */
|
|
38
|
+
onValueCommitted?: (value: SliderChangedValue<Value>, event: Event) => void;
|
|
39
|
+
/** @default 0 */
|
|
40
|
+
min?: number;
|
|
41
|
+
/** @default 100 */
|
|
42
|
+
max?: number;
|
|
43
|
+
/** The values snap to multiples of `step`, counted from `min`. @default 1 */
|
|
44
|
+
step?: number;
|
|
45
|
+
/** The step of Page Up / Page Down and Shift + arrow keys. @default 10 */
|
|
46
|
+
largeStep?: number;
|
|
47
|
+
/** The minimum number of steps between the thumbs of a range. @default 0 */
|
|
48
|
+
minStepsBetweenValues?: number;
|
|
49
|
+
/** @default "horizontal" */
|
|
50
|
+
orientation?: SliderOrientation;
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
/** Submitted name. A range submits one value per thumb under it. Inside a `BaseFormField`, the field's name is used. */
|
|
53
|
+
name?: string;
|
|
54
|
+
/** The `id` of a `<form>` to submit with, when the slider isn't inside it. */
|
|
55
|
+
form?: string;
|
|
56
|
+
/** How the value is formatted for `Value` and screen readers. */
|
|
57
|
+
format?: Intl.NumberFormatOptions;
|
|
58
|
+
/** The locale used to format the value. Defaults to the user's runtime locale. */
|
|
59
|
+
locale?: Intl.LocalesArgument;
|
|
60
|
+
/**
|
|
61
|
+
* Where the thumbs sit at `min` and `max`: centered on the control's edge, or inside it (`edge`).
|
|
62
|
+
* `edge-client-only` is `edge` without the server-rendering script.
|
|
63
|
+
* @default "center"
|
|
64
|
+
*/
|
|
65
|
+
thumbAlignment?: "center" | "edge" | "edge-client-only";
|
|
66
|
+
/**
|
|
67
|
+
* What thumbs of a range do when they meet while dragging: push each other, swap places, or stop.
|
|
68
|
+
* @default "push"
|
|
69
|
+
*/
|
|
70
|
+
thumbCollisionBehavior?: "push" | "swap" | "none";
|
|
71
|
+
/** The slider's visible name. It labels every thumb for assistive technology. */
|
|
72
|
+
label?: ReactNode;
|
|
73
|
+
/** Classes for the label `<div>`. */
|
|
74
|
+
labelClassName?: string;
|
|
75
|
+
renderLabel?: RenderProp<"div", SliderState>;
|
|
76
|
+
/** Shows the value as text next to the label. A function shows something else, e.g. `"20 to 80"`. */
|
|
77
|
+
showValue?: boolean | ((formattedValues: readonly string[], values: readonly number[]) => ReactNode);
|
|
78
|
+
/** Classes for the value `<output>`. */
|
|
79
|
+
valueClassName?: string;
|
|
80
|
+
renderValue?: RenderProp<"output", SliderState>;
|
|
81
|
+
/** The track's thickness and the thumbs' size. */
|
|
82
|
+
size?: SliderSize;
|
|
83
|
+
/** Classes for the control `<div>`, the area that reacts to the pointer. */
|
|
84
|
+
controlClassName?: string;
|
|
85
|
+
renderControl?: RenderProp<"div", SliderState>;
|
|
86
|
+
/** Classes for the track `<div>`. */
|
|
87
|
+
trackClassName?: string;
|
|
88
|
+
renderTrack?: RenderProp<"div", SliderState>;
|
|
89
|
+
/** Classes for the indicator `<div>`, the filled part of the track. */
|
|
90
|
+
indicatorClassName?: string;
|
|
91
|
+
renderIndicator?: RenderProp<"div", SliderState>;
|
|
92
|
+
/** Classes for every thumb `<div>`. */
|
|
93
|
+
thumbClassName?: string;
|
|
94
|
+
renderThumb?: RenderProp<"div", SliderState>;
|
|
95
|
+
/** The thumbs' accessible names, built from their index. Use it when no label names the slider. */
|
|
96
|
+
getAriaLabel?: (index: number) => string;
|
|
97
|
+
/** Text that screen readers announce for a thumb's value. */
|
|
98
|
+
getAriaValueText?: (formattedValue: string, value: number, index: number) => string;
|
|
99
|
+
/**
|
|
100
|
+
* Lays out the slider's parts yourself (`BaseSlider.Label`, `.Value`, `.Control`, `.Track`, `.Indicator`, `.Thumb`).
|
|
101
|
+
* When given, the built-in label, value and control aren't rendered.
|
|
102
|
+
*/
|
|
103
|
+
children?: ReactNode;
|
|
104
|
+
};
|
|
105
|
+
declare const _default: (<Value extends number | readonly number[]>({ label, labelClassName, renderLabel, showValue, valueClassName, renderValue, size, controlClassName, renderControl, trackClassName, renderTrack, indicatorClassName, renderIndicator, thumbClassName, renderThumb, getAriaLabel, getAriaValueText, onValueChange, onValueCommitted, className, children, ...otherProps }: BaseSliderProps<Value>) => import("react").JSX.Element) & {
|
|
106
|
+
Label: (props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "id"> & {
|
|
107
|
+
render?: RenderProp<"div", SliderState>;
|
|
108
|
+
}) => import("react").JSX.Element;
|
|
109
|
+
Value: (props: Omit<import("react").DetailedHTMLProps<import("react").OutputHTMLAttributes<HTMLOutputElement>, HTMLOutputElement>, "children"> & {
|
|
110
|
+
render?: RenderProp<"output", SliderState>;
|
|
111
|
+
children?: (formattedValues: readonly string[], values: readonly number[]) => ReactNode;
|
|
112
|
+
}) => import("react").JSX.Element;
|
|
113
|
+
Control: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
114
|
+
render?: RenderProp<"div", SliderState>;
|
|
115
|
+
}) => import("react").JSX.Element;
|
|
116
|
+
Track: ({ size, className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
117
|
+
render?: RenderProp<"div", SliderState>;
|
|
118
|
+
size?: SliderSize;
|
|
119
|
+
}) => import("react").JSX.Element;
|
|
120
|
+
Indicator: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
121
|
+
render?: RenderProp<"div", SliderState>;
|
|
122
|
+
}) => import("react").JSX.Element;
|
|
123
|
+
Thumb: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "onFocus" | "onBlur" | "onKeyDown"> & {
|
|
124
|
+
render?: RenderProp<"div", SliderState>;
|
|
125
|
+
size?: SliderSize;
|
|
126
|
+
index?: number;
|
|
127
|
+
disabled?: boolean;
|
|
128
|
+
getAriaLabel?: (index: number) => string;
|
|
129
|
+
getAriaValueText?: (formattedValue: string, value: number, index: number) => string;
|
|
130
|
+
inputRef?: import("react").Ref<HTMLInputElement>;
|
|
131
|
+
onFocus?: import("react").FocusEventHandler<HTMLInputElement>;
|
|
132
|
+
onBlur?: import("react").FocusEventHandler<HTMLInputElement>;
|
|
133
|
+
onKeyDown?: import("react").KeyboardEventHandler<HTMLInputElement>;
|
|
134
|
+
}) => import("react").JSX.Element;
|
|
135
|
+
};
|
|
136
|
+
export { type SliderSize, _default as default };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Slider } from "@base-ui/react/slider";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import BaseSliderControl from "./BaseSliderControl.js";
|
|
5
|
+
import BaseSliderIndicator from "./BaseSliderIndicator.js";
|
|
6
|
+
import BaseSliderLabel from "./BaseSliderLabel.js";
|
|
7
|
+
import BaseSliderThumb from "./BaseSliderThumb.js";
|
|
8
|
+
import BaseSliderTrack from "./BaseSliderTrack.js";
|
|
9
|
+
import BaseSliderValue from "./BaseSliderValue.js";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
// src/components/form/BaseSlider.tsx
|
|
12
|
+
/**
|
|
13
|
+
* An input for a number, or a range of numbers, within known bounds.
|
|
14
|
+
* Renders a `<div>`: the label and the value on top, the control with its track and thumbs below.
|
|
15
|
+
*/
|
|
16
|
+
const BaseSlider = ({ label, labelClassName, renderLabel, showValue = false, valueClassName, renderValue, size = "md", controlClassName, renderControl, trackClassName, renderTrack, indicatorClassName, renderIndicator, thumbClassName, renderThumb, getAriaLabel, getAriaValueText, onValueChange, onValueCommitted, className, children, ...otherProps }) => {
|
|
17
|
+
const initialValue = otherProps.value ?? otherProps.defaultValue;
|
|
18
|
+
const thumbCount = Array.isArray(initialValue) ? initialValue.length : 1;
|
|
19
|
+
return /* @__PURE__ */ jsx(Slider.Root, {
|
|
20
|
+
...otherProps,
|
|
21
|
+
onValueChange: onValueChange && ((value, details) => onValueChange(value, details.event)),
|
|
22
|
+
onValueCommitted: onValueCommitted && ((value, details) => onValueCommitted(value, details.event)),
|
|
23
|
+
className: cn("flex", "flex-wrap", "items-center", "gap-x-2", "gap-y-1", "data-[orientation=vertical]:flex-col", "data-[orientation=vertical]:flex-nowrap", className),
|
|
24
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
25
|
+
typeof label !== "undefined" && /* @__PURE__ */ jsx(BaseSliderLabel, {
|
|
26
|
+
render: renderLabel,
|
|
27
|
+
className: cn("data-[orientation=horizontal]:grow", labelClassName),
|
|
28
|
+
children: label
|
|
29
|
+
}),
|
|
30
|
+
showValue !== false && /* @__PURE__ */ jsx(BaseSliderValue, {
|
|
31
|
+
render: renderValue,
|
|
32
|
+
className: cn("data-[orientation=horizontal]:ms-auto", "tabular-nums", valueClassName),
|
|
33
|
+
children: typeof showValue === "function" ? showValue : void 0
|
|
34
|
+
}),
|
|
35
|
+
/* @__PURE__ */ jsx(BaseSliderControl, {
|
|
36
|
+
render: renderControl,
|
|
37
|
+
className: controlClassName,
|
|
38
|
+
children: /* @__PURE__ */ jsxs(BaseSliderTrack, {
|
|
39
|
+
size,
|
|
40
|
+
render: renderTrack,
|
|
41
|
+
className: trackClassName,
|
|
42
|
+
children: [/* @__PURE__ */ jsx(BaseSliderIndicator, {
|
|
43
|
+
render: renderIndicator,
|
|
44
|
+
className: indicatorClassName
|
|
45
|
+
}), Array.from({ length: thumbCount }, (_, index) => /* @__PURE__ */ jsx(BaseSliderThumb, {
|
|
46
|
+
index,
|
|
47
|
+
size,
|
|
48
|
+
render: renderThumb,
|
|
49
|
+
className: thumbClassName,
|
|
50
|
+
getAriaLabel,
|
|
51
|
+
getAriaValueText
|
|
52
|
+
}, index))]
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
] })
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
var BaseSlider_default = Object.assign(BaseSlider, {
|
|
59
|
+
Label: BaseSliderLabel,
|
|
60
|
+
Value: BaseSliderValue,
|
|
61
|
+
Control: BaseSliderControl,
|
|
62
|
+
Track: BaseSliderTrack,
|
|
63
|
+
Indicator: BaseSliderIndicator,
|
|
64
|
+
Thumb: BaseSliderThumb
|
|
65
|
+
});
|
|
66
|
+
export { BaseSlider_default as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SliderState } from "./BaseSlider.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
type BaseSliderControlProps = ComponentProps<"div"> & {
|
|
5
|
+
render?: RenderProp<"div", SliderState>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The interactive area: pressing anywhere in it moves the closest thumb there.
|
|
9
|
+
* Put a `BaseSlider.Track` inside it. Renders a `<div>`.
|
|
10
|
+
*/
|
|
11
|
+
declare const BaseSliderControl: ({ className, ...otherProps }: BaseSliderControlProps) => import("react").JSX.Element;
|
|
12
|
+
export { BaseSliderControl as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Slider } from "@base-ui/react/slider";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/form/BaseSliderControl.tsx
|
|
6
|
+
/**
|
|
7
|
+
* The interactive area: pressing anywhere in it moves the closest thumb there.
|
|
8
|
+
* Put a `BaseSlider.Track` inside it. Renders a `<div>`.
|
|
9
|
+
*/
|
|
10
|
+
const BaseSliderControl = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Slider.Control, {
|
|
11
|
+
...otherProps,
|
|
12
|
+
className: cn("flex", "touch-none", "items-center", "select-none", "data-disabled:cursor-not-allowed", "data-[orientation=horizontal]:w-full", "data-[orientation=horizontal]:py-2", "data-[orientation=vertical]:grow", "data-[orientation=vertical]:flex-col", "data-[orientation=vertical]:px-2", className)
|
|
13
|
+
});
|
|
14
|
+
export { BaseSliderControl as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SliderState } from "./BaseSlider.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
type BaseSliderIndicatorProps = ComponentProps<"div"> & {
|
|
5
|
+
render?: RenderProp<"div", SliderState>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The filled part of the track: from the start to the thumb, or between the thumbs of a range.
|
|
9
|
+
* Base UI sets its position and length inline. Renders a `<div>`.
|
|
10
|
+
*/
|
|
11
|
+
declare const BaseSliderIndicator: ({ className, ...otherProps }: BaseSliderIndicatorProps) => import("react").JSX.Element;
|
|
12
|
+
export { BaseSliderIndicator as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Slider } from "@base-ui/react/slider";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/form/BaseSliderIndicator.tsx
|
|
6
|
+
/**
|
|
7
|
+
* The filled part of the track: from the start to the thumb, or between the thumbs of a range.
|
|
8
|
+
* Base UI sets its position and length inline. Renders a `<div>`.
|
|
9
|
+
*/
|
|
10
|
+
const BaseSliderIndicator = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Slider.Indicator, {
|
|
11
|
+
...otherProps,
|
|
12
|
+
className: cn("rounded-full", "select-none", className)
|
|
13
|
+
});
|
|
14
|
+
export { BaseSliderIndicator as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SliderState } from "./BaseSlider.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
type BaseSliderLabelProps = Omit<ComponentProps<"div">, "id"> & {
|
|
5
|
+
render?: RenderProp<"div", SliderState>;
|
|
6
|
+
};
|
|
7
|
+
/** The slider's visible name. It labels every thumb for assistive technology. Renders a `<div>`. */
|
|
8
|
+
declare const BaseSliderLabel: (props: BaseSliderLabelProps) => import("react").JSX.Element;
|
|
9
|
+
export { BaseSliderLabel as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Slider } from "@base-ui/react/slider";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/form/BaseSliderLabel.tsx
|
|
5
|
+
/** The slider's visible name. It labels every thumb for assistive technology. Renders a `<div>`. */
|
|
6
|
+
const BaseSliderLabel = (props) => /* @__PURE__ */ jsx(Slider.Label, { ...props });
|
|
7
|
+
export { BaseSliderLabel as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SliderSize } from "./sliderStyles.js";
|
|
2
|
+
import { SliderState } from "./BaseSlider.js";
|
|
3
|
+
import { RenderProp } from "../../utils/render.js";
|
|
4
|
+
import { ComponentProps, FocusEventHandler, KeyboardEventHandler, Ref } from "react";
|
|
5
|
+
type BaseSliderThumbProps = Omit<ComponentProps<"div">, "onFocus" | "onBlur" | "onKeyDown"> & {
|
|
6
|
+
render?: RenderProp<"div", SliderState>;
|
|
7
|
+
/** The thumb's size. */
|
|
8
|
+
size?: SliderSize;
|
|
9
|
+
/** The index of the thumb's value in a range. Needed for server rendering of a range. */
|
|
10
|
+
index?: number;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** The thumb's accessible name, built from its index. Use it when no label names the slider. */
|
|
13
|
+
getAriaLabel?: (index: number) => string;
|
|
14
|
+
/** Text that screen readers announce for the thumb's value. */
|
|
15
|
+
getAriaValueText?: (formattedValue: string, value: number, index: number) => string;
|
|
16
|
+
/** A ref to the thumb's hidden `<input type="range">`. */
|
|
17
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
18
|
+
/** Called when the thumb's `<input>` gets focus. */
|
|
19
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
20
|
+
/** Called when the thumb's `<input>` loses focus. */
|
|
21
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
22
|
+
/** Called on key presses in the thumb's `<input>`. */
|
|
23
|
+
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The draggable handle of a value. Renders a `<div>` with a hidden `<input type="range">` inside,
|
|
27
|
+
* which takes the focus and submits the value with the form.
|
|
28
|
+
*/
|
|
29
|
+
declare const BaseSliderThumb: ({ size, className, ...otherProps }: BaseSliderThumbProps) => import("react").JSX.Element;
|
|
30
|
+
export { BaseSliderThumb as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Slider } from "@base-ui/react/slider";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { sliderThumbClassName } from "./sliderStyles.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/form/BaseSliderThumb.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The draggable handle of a value. Renders a `<div>` with a hidden `<input type="range">` inside,
|
|
9
|
+
* which takes the focus and submits the value with the form.
|
|
10
|
+
*/
|
|
11
|
+
const BaseSliderThumb = ({ size = "md", className, ...otherProps }) => /* @__PURE__ */ jsx(Slider.Thumb, {
|
|
12
|
+
...otherProps,
|
|
13
|
+
className: cn(sliderThumbClassName(size), className)
|
|
14
|
+
});
|
|
15
|
+
export { BaseSliderThumb as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SliderSize } from "./sliderStyles.js";
|
|
2
|
+
import { SliderState } from "./BaseSlider.js";
|
|
3
|
+
import { RenderProp } from "../../utils/render.js";
|
|
4
|
+
import { ComponentProps } from "react";
|
|
5
|
+
type BaseSliderTrackProps = ComponentProps<"div"> & {
|
|
6
|
+
render?: RenderProp<"div", SliderState>;
|
|
7
|
+
/** The track's thickness. */
|
|
8
|
+
size?: SliderSize;
|
|
9
|
+
};
|
|
10
|
+
/** The whole range of the slider. Put a `BaseSlider.Indicator` and the thumbs inside it. Renders a `<div>`. */
|
|
11
|
+
declare const BaseSliderTrack: ({ size, className, ...otherProps }: BaseSliderTrackProps) => import("react").JSX.Element;
|
|
12
|
+
export { BaseSliderTrack as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Slider } from "@base-ui/react/slider";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { sliderTrackClassName } from "./sliderStyles.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/form/BaseSliderTrack.tsx
|
|
7
|
+
/** The whole range of the slider. Put a `BaseSlider.Indicator` and the thumbs inside it. Renders a `<div>`. */
|
|
8
|
+
const BaseSliderTrack = ({ size = "md", className, ...otherProps }) => /* @__PURE__ */ jsx(Slider.Track, {
|
|
9
|
+
...otherProps,
|
|
10
|
+
className: cn(sliderTrackClassName(size), className)
|
|
11
|
+
});
|
|
12
|
+
export { BaseSliderTrack as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SliderState } from "./BaseSlider.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps, ReactNode } from "react";
|
|
4
|
+
type BaseSliderValueProps = Omit<ComponentProps<"output">, "children"> & {
|
|
5
|
+
render?: RenderProp<"output", SliderState>;
|
|
6
|
+
/** Shows something else than the formatted values, e.g. `(formatted) => formatted.join(" to ")`. */
|
|
7
|
+
children?: (formattedValues: readonly string[], values: readonly number[]) => ReactNode;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The value as text, formatted with the slider's `format` and `locale`. A range shows every thumb's value.
|
|
11
|
+
* Renders an `<output>`.
|
|
12
|
+
*/
|
|
13
|
+
declare const BaseSliderValue: (props: BaseSliderValueProps) => import("react").JSX.Element;
|
|
14
|
+
export { BaseSliderValue as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Slider } from "@base-ui/react/slider";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/form/BaseSliderValue.tsx
|
|
5
|
+
/**
|
|
6
|
+
* The value as text, formatted with the slider's `format` and `locale`. A range shows every thumb's value.
|
|
7
|
+
* Renders an `<output>`.
|
|
8
|
+
*/
|
|
9
|
+
const BaseSliderValue = (props) => /* @__PURE__ */ jsx(Slider.Value, { ...props });
|
|
10
|
+
export { BaseSliderValue as default };
|
|
@@ -23,7 +23,9 @@ import { SelectItemState } from "./BaseSelectItem.js";
|
|
|
23
23
|
import { SelectItemIndicatorState } from "./BaseSelectItemIndicator.js";
|
|
24
24
|
import { SelectArrowState, SelectBackdropState, SelectCollisionAvoidance, SelectFocusTarget, SelectOffsetFunction, SelectPopupState, SelectPositionerState } from "./BaseSelectPopup.js";
|
|
25
25
|
import { SelectSeparatorState } from "./BaseSelectSeparator.js";
|
|
26
|
+
import { SliderSize } from "./sliderStyles.js";
|
|
26
27
|
import { SelectValueState } from "./BaseSelectValue.js";
|
|
27
28
|
import BaseRadioGroup, { RadioGroupState } from "./BaseRadioGroup.js";
|
|
28
29
|
import BaseRadio, { RadioState } from "./BaseRadio.js";
|
|
29
|
-
|
|
30
|
+
import _default$2, { SliderOrientation, SliderState } from "./BaseSlider.js";
|
|
31
|
+
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, BaseFieldset, BaseForm, BaseFormField, BaseInput, BaseRadio, BaseRadioGroup, _default$1 as BaseSelect, _default$2 as BaseSlider, BaseSwitch, type CheckboxGroupState, type CheckboxState, type DisplayedFormMessage, type FieldConstraints, type FieldState, type FieldsetState, type InputSize, type MessageFormatter, type RadioGroupState, type RadioState, type SelectActions, type SelectAlign, type SelectArrowState, type SelectBackdropState, type SelectCollisionAvoidance, type SelectFocusTarget, type SelectIconState, type SelectInteractionType, type SelectItemGroup, type SelectItemIndicatorState, type SelectItemState, type SelectLabeledItem, type SelectOffsetFunction, type SelectPopupState, type SelectPositionerState, type SelectScrollArrowState, type SelectSeparatorState, type SelectSide, type SelectTriggerState, type SelectValueState, type SliderOrientation, type SliderSize, type SliderState, type SwitchState, type UseAutocompleteFilterOptions, useAutocompleteFilter, useFormMessages };
|
|
@@ -11,4 +11,5 @@ import BaseFieldset from "./BaseFieldset.js";
|
|
|
11
11
|
import BaseSelect_default from "./BaseSelect.js";
|
|
12
12
|
import BaseRadioGroup from "./BaseRadioGroup.js";
|
|
13
13
|
import BaseRadio from "./BaseRadio.js";
|
|
14
|
-
|
|
14
|
+
import BaseSlider_default from "./BaseSlider.js";
|
|
15
|
+
export { BaseAutocomplete_default as BaseAutocomplete, BaseCheckbox, BaseCheckboxGroup, BaseFieldset, BaseForm, BaseFormField, BaseInput, BaseRadio, BaseRadioGroup, BaseSelect_default as BaseSelect, BaseSlider_default as BaseSlider, BaseSwitch, useAutocompleteFilter, useFormMessages };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type SliderSize = "lg" | "md" | "sm" | "xs";
|
|
2
|
+
/** Classes for the slider's track: its thickness across the orientation, and the full length along it. */
|
|
3
|
+
export declare function sliderTrackClassName(size: SliderSize): string;
|
|
4
|
+
/** Classes for a thumb. Base UI positions it inline. */
|
|
5
|
+
export declare function sliderThumbClassName(size: SliderSize): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { cn } from "cn";
|
|
2
|
+
// src/components/form/sliderStyles.ts
|
|
3
|
+
/** Classes for the slider's track: its thickness across the orientation, and the full length along it. */
|
|
4
|
+
function sliderTrackClassName(size) {
|
|
5
|
+
return cn({
|
|
6
|
+
"data-[orientation=horizontal]:h-2 data-[orientation=vertical]:w-2": size === "lg",
|
|
7
|
+
"data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:w-1.5": size === "md",
|
|
8
|
+
"data-[orientation=horizontal]:h-1 data-[orientation=vertical]:w-1": size === "sm",
|
|
9
|
+
"data-[orientation=horizontal]:h-0.5 data-[orientation=vertical]:w-0.5": size === "xs"
|
|
10
|
+
}, [
|
|
11
|
+
"rounded-full",
|
|
12
|
+
"select-none",
|
|
13
|
+
"data-[orientation=horizontal]:w-full",
|
|
14
|
+
"data-[orientation=vertical]:h-full"
|
|
15
|
+
]);
|
|
16
|
+
}
|
|
17
|
+
/** Classes for a thumb. Base UI positions it inline. */
|
|
18
|
+
function sliderThumbClassName(size) {
|
|
19
|
+
return cn({
|
|
20
|
+
"size-5": size === "lg",
|
|
21
|
+
"size-4": size === "md",
|
|
22
|
+
"size-3.5": size === "sm",
|
|
23
|
+
"size-3": size === "xs"
|
|
24
|
+
}, [
|
|
25
|
+
"rounded-full",
|
|
26
|
+
"select-none",
|
|
27
|
+
"outline-offset-2",
|
|
28
|
+
"has-focus-visible:outline-2",
|
|
29
|
+
"data-disabled:cursor-not-allowed"
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
export { sliderThumbClassName, sliderTrackClassName };
|
|
@@ -154,7 +154,7 @@ declare const _default: (<Payload>(props: BaseMenuProps<Payload>) => import("rea
|
|
|
154
154
|
closeDelay?: number;
|
|
155
155
|
nativeButton?: boolean;
|
|
156
156
|
}) => import("react").JSX.Element;
|
|
157
|
-
Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "
|
|
157
|
+
Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "value"> & {
|
|
158
158
|
render?: RenderProp<"input", MenuInputState>;
|
|
159
159
|
}) => import("react").JSX.Element;
|
|
160
160
|
Clear: (props: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
@@ -169,7 +169,7 @@ declare const _default: (({ className, ...otherProps }: BaseMenubarProps) => imp
|
|
|
169
169
|
closeDelay?: number;
|
|
170
170
|
nativeButton?: boolean;
|
|
171
171
|
}) => import("react").JSX.Element;
|
|
172
|
-
Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "
|
|
172
|
+
Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "value"> & {
|
|
173
173
|
render?: RenderProp<"input", MenuInputState>;
|
|
174
174
|
}) => import("react").JSX.Element;
|
|
175
175
|
Clear: (props: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TabsTabState } from "./BaseTabsTab.js";
|
|
2
|
+
import { TabsIndicatorState } from "./BaseTabsIndicator.js";
|
|
3
|
+
import { TabsPanelState } from "./BaseTabsPanel.js";
|
|
4
|
+
import { TabsOrientation, TabsState } from "./tabsTypes.js";
|
|
5
|
+
import { RenderProp } from "../../utils/render.js";
|
|
6
|
+
import { ComponentProps } from "react";
|
|
7
|
+
type BaseTabsProps<Value = unknown> = Omit<ComponentProps<"div">, "defaultValue"> & {
|
|
8
|
+
render?: RenderProp<"div", TabsState>;
|
|
9
|
+
/** The value of the active tab (controlled). `null` activates none. */
|
|
10
|
+
value?: Value | null;
|
|
11
|
+
/** The value of the tab active at first. `null` activates none. Defaults to the first enabled tab. */
|
|
12
|
+
defaultValue?: Value | null;
|
|
13
|
+
/**
|
|
14
|
+
* Called with the value of the newly active tab and the DOM event that activated it.
|
|
15
|
+
* Uncontrolled tabs also call it when they pick a tab themselves (at first, or when the active tab is disabled or removed),
|
|
16
|
+
* with no event and possibly `null` when no enabled tab is left.
|
|
17
|
+
*/
|
|
18
|
+
onValueChange?: (value: Value | null, event: Event | undefined) => void;
|
|
19
|
+
/** The direction of the tab list, and of the arrow keys that move between tabs. @default "horizontal" */
|
|
20
|
+
orientation?: TabsOrientation;
|
|
21
|
+
};
|
|
22
|
+
declare const _default: (<Value>({ onValueChange, className, ...otherProps }: BaseTabsProps<Value>) => import("react").JSX.Element) & {
|
|
23
|
+
List: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
24
|
+
render?: RenderProp<"div", TabsState>;
|
|
25
|
+
activateOnFocus?: boolean;
|
|
26
|
+
loopFocus?: boolean;
|
|
27
|
+
}) => import("react").JSX.Element;
|
|
28
|
+
Tab: ({ className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "value"> & {
|
|
29
|
+
render?: RenderProp<"button", TabsTabState>;
|
|
30
|
+
value: unknown;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
nativeButton?: boolean;
|
|
33
|
+
}) => import("react").JSX.Element;
|
|
34
|
+
Indicator: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & {
|
|
35
|
+
render?: RenderProp<"span", TabsIndicatorState>;
|
|
36
|
+
renderBeforeHydration?: boolean;
|
|
37
|
+
}) => import("react").JSX.Element;
|
|
38
|
+
Panel: ({ className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "value"> & {
|
|
39
|
+
render?: RenderProp<"div", TabsPanelState>;
|
|
40
|
+
value: unknown;
|
|
41
|
+
keepMounted?: boolean;
|
|
42
|
+
}) => import("react").JSX.Element;
|
|
43
|
+
};
|
|
44
|
+
export { _default as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Tabs } from "@base-ui/react/tabs";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import BaseTabsIndicator from "./BaseTabsIndicator.js";
|
|
5
|
+
import BaseTabsList from "./BaseTabsList.js";
|
|
6
|
+
import BaseTabsPanel from "./BaseTabsPanel.js";
|
|
7
|
+
import BaseTabsTab from "./BaseTabsTab.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
// src/components/navigation/BaseTabs.tsx
|
|
10
|
+
/** Groups the tab list and its panels. Renders a `<div>`, a flex row while vertical. */
|
|
11
|
+
const BaseTabs = ({ onValueChange, className, ...otherProps }) => /* @__PURE__ */ jsx(Tabs.Root, {
|
|
12
|
+
...otherProps,
|
|
13
|
+
className: cn("data-[orientation=vertical]:flex", className),
|
|
14
|
+
onValueChange: onValueChange && ((value, details) => {
|
|
15
|
+
onValueChange(value, details.reason === "none" ? details.event : void 0);
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
var BaseTabs_default = Object.assign(BaseTabs, {
|
|
19
|
+
List: BaseTabsList,
|
|
20
|
+
Tab: BaseTabsTab,
|
|
21
|
+
Indicator: BaseTabsIndicator,
|
|
22
|
+
Panel: BaseTabsPanel
|
|
23
|
+
});
|
|
24
|
+
export { BaseTabs_default as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TabsState } from "./tabsTypes.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
export type TabsIndicatorState = TabsState & {
|
|
5
|
+
/** The active tab's offsets inside the list, in pixels. `null` while no tab is active. */
|
|
6
|
+
activeTabPosition: {
|
|
7
|
+
left: number;
|
|
8
|
+
right: number;
|
|
9
|
+
top: number;
|
|
10
|
+
bottom: number;
|
|
11
|
+
} | null;
|
|
12
|
+
/** The active tab's size, in pixels. `null` while no tab is active. */
|
|
13
|
+
activeTabSize: {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
} | null;
|
|
17
|
+
};
|
|
18
|
+
type BaseTabsIndicatorProps = ComponentProps<"span"> & {
|
|
19
|
+
render?: RenderProp<"span", TabsIndicatorState>;
|
|
20
|
+
/** Renders the indicator before React hydrates, so it shows sooner after server rendering. @default false */
|
|
21
|
+
renderBeforeHydration?: boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Follows the active tab. Put it inside `BaseTabs.List`. Renders a `<span>`.
|
|
25
|
+
* It covers the active tab and sits behind the tabs, with a transition. Turn it into an underline with
|
|
26
|
+
* e.g. `top-auto bottom-0 h-0.5`. The active tab's box is also in `--active-tab-left`, `-right`, `-top`,
|
|
27
|
+
* `-bottom`, `-width` and `-height`.
|
|
28
|
+
*/
|
|
29
|
+
declare const BaseTabsIndicator: ({ className, ...otherProps }: BaseTabsIndicatorProps) => import("react").JSX.Element;
|
|
30
|
+
export { BaseTabsIndicator as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Tabs } from "@base-ui/react/tabs";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/navigation/BaseTabsIndicator.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Follows the active tab. Put it inside `BaseTabs.List`. Renders a `<span>`.
|
|
8
|
+
* It covers the active tab and sits behind the tabs, with a transition. Turn it into an underline with
|
|
9
|
+
* e.g. `top-auto bottom-0 h-0.5`. The active tab's box is also in `--active-tab-left`, `-right`, `-top`,
|
|
10
|
+
* `-bottom`, `-width` and `-height`.
|
|
11
|
+
*/
|
|
12
|
+
const BaseTabsIndicator = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Tabs.Indicator, {
|
|
13
|
+
...otherProps,
|
|
14
|
+
className: cn("absolute", "-z-10", "top-(--active-tab-top)", "left-(--active-tab-left)", "h-(--active-tab-height)", "w-(--active-tab-width)", "transition-all", "duration-200", "ease-in-out", className)
|
|
15
|
+
});
|
|
16
|
+
export { BaseTabsIndicator as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TabsState } from "./tabsTypes.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
type BaseTabsListProps = ComponentProps<"div"> & {
|
|
5
|
+
render?: RenderProp<"div", TabsState>;
|
|
6
|
+
/**
|
|
7
|
+
* Activates a tab as soon as the arrow keys move focus to it. Otherwise <kbd>Enter</kbd> or <kbd>Space</kbd> activates it.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
activateOnFocus?: boolean;
|
|
11
|
+
/** Moves focus from the last tab back to the first with the arrow keys (and the other way). @default true */
|
|
12
|
+
loopFocus?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Groups the tabs and positions the indicator. Renders a `<div>` with `role="tablist"`:
|
|
16
|
+
* a flex row (a column while vertical) that is `relative`, with its own stacking context.
|
|
17
|
+
*/
|
|
18
|
+
declare const BaseTabsList: ({ className, ...otherProps }: BaseTabsListProps) => import("react").JSX.Element;
|
|
19
|
+
export { BaseTabsList as default };
|