@central-ui/react 0.3.0 → 0.5.0
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/dist/components/accordion/index.d.ts +14 -14
- package/dist/components/accordion/index.js +19 -19
- package/dist/components/autocomplete/index.d.ts +51 -47
- package/dist/components/autocomplete/index.js +57 -57
- package/dist/components/avatar/index.d.ts +7 -6
- package/dist/components/avatar/index.js +9 -9
- package/dist/components/banner/index.js +1 -1
- package/dist/components/carousel/index.d.ts +31 -11
- package/dist/components/carousel/index.js +25 -21
- package/dist/components/checkbox/index.d.ts +12 -11
- package/dist/components/checkbox/index.js +21 -21
- package/dist/components/combobox/index.d.ts +56 -56
- package/dist/components/combobox/index.js +67 -68
- package/dist/components/datepicker/index.d.ts +8 -9
- package/dist/components/datepicker/index.js +13 -13
- package/dist/components/dialog/index.d.ts +18 -18
- package/dist/components/dialog/index.js +22 -21
- package/dist/components/drawer/index.d.ts +24 -24
- package/dist/components/drawer/index.js +28 -27
- package/dist/components/exception/index.d.ts +23 -11
- package/dist/components/exception/index.js +17 -17
- package/dist/components/fileupload/index.d.ts +8 -8
- package/dist/components/input/index.d.ts +14 -14
- package/dist/components/input/index.js +27 -27
- package/dist/components/menu/index.d.ts +37 -37
- package/dist/components/menu/index.js +47 -47
- package/dist/components/numberinput/index.d.ts +22 -22
- package/dist/components/numberinput/index.js +35 -35
- package/dist/components/otpinput/index.d.ts +12 -12
- package/dist/components/otpinput/index.js +21 -21
- package/dist/components/pagination/index.d.ts +158 -0
- package/dist/components/pagination/index.js +157 -0
- package/dist/components/passwordinput/index.d.ts +15 -15
- package/dist/components/passwordinput/index.js +27 -27
- package/dist/components/popover/index.d.ts +16 -16
- package/dist/components/popover/index.js +20 -19
- package/dist/components/radio/index.d.ts +12 -12
- package/dist/components/radio/index.js +25 -25
- package/dist/components/ratinginput/index.d.ts +1 -1
- package/dist/components/ratinginput/index.js +3 -3
- package/dist/components/select/index.d.ts +29 -29
- package/dist/components/select/index.js +33 -33
- package/dist/components/slider/index.d.ts +20 -20
- package/dist/components/slider/index.js +27 -27
- package/dist/components/stepper/index.d.ts +135 -44
- package/dist/components/stepper/index.js +185 -62
- package/dist/components/switch/index.d.ts +9 -9
- package/dist/components/switch/index.js +17 -17
- package/dist/components/table/index.d.ts +2 -2
- package/dist/components/table/index.js +16 -16
- package/dist/components/tabs/index.d.ts +10 -10
- package/dist/components/tabs/index.js +11 -11
- package/dist/components/textarea/index.d.ts +13 -13
- package/dist/components/textarea/index.js +25 -25
- package/dist/components/toast/index.d.ts +11 -11
- package/dist/components/toast/index.js +11 -11
- package/dist/components/toggle/index.d.ts +7 -7
- package/dist/components/toggle/index.js +9 -9
- package/dist/components/tooltip/index.d.ts +6 -6
- package/dist/components/tooltip/index.js +6 -7
- package/dist/components/tour/index.d.ts +2 -2
- package/dist/components/tour/index.js +5 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/icons.d.ts +104 -23
- package/dist/utils/icons.js +16 -3
- package/package.json +69 -69
- package/src/presets/shopify-polaris/shopify-polaris-accordion.css +28 -28
- package/src/presets/shopify-polaris/shopify-polaris-pagination.css +55 -0
- package/src/presets/shopify-polaris/shopify-polaris-stepper.css +63 -27
- package/src/presets/shopify-polaris/shopify-polaris.css +1 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-accordion.css +28 -28
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-pagination.css +49 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-stepper.css +64 -26
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy.css +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Switch as BaseSwitch } from '@base-ui/react/switch';
|
|
3
|
-
import { createContext,
|
|
3
|
+
import { createContext, useContext, useEffect, useId, useState, } from 'react';
|
|
4
4
|
import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
|
|
5
5
|
/**
|
|
6
6
|
* Keep Button, Indicator, and Label in the same Root. Indicator follows the checked state automatically; do not add a second boolean just for its position.
|
|
@@ -55,48 +55,48 @@ export function Root({ children, validation, checked, defaultChecked = false, on
|
|
|
55
55
|
validation: readValidation(validation),
|
|
56
56
|
}, children: children }));
|
|
57
57
|
}
|
|
58
|
-
export
|
|
58
|
+
export function Container({ disableStyle, className, ref, ...props }) {
|
|
59
59
|
return (_jsx("div", { ...props, ref: ref, "data-component": "switch-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
60
|
-
}
|
|
61
|
-
export
|
|
60
|
+
}
|
|
61
|
+
export function Button({ disableStyle, className, ref, ...props }) {
|
|
62
62
|
const context = useSwitchContext();
|
|
63
63
|
return (_jsx(BaseSwitch.Root, { ...props, ...context.coreProps, "aria-invalid": context.validation.state === 'error' || props['aria-invalid'] || undefined, "aria-describedby": [props['aria-describedby'], ...context.messageIds].filter(Boolean).join(' ') ||
|
|
64
64
|
undefined, ref: ref, ...validationAttributes(context.validation), "data-component": "switch-button", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
65
|
-
}
|
|
65
|
+
}
|
|
66
66
|
/** Tracks the surrounding item state automatically. Keep it mounted; do not add your own visibility condition. Use the supplied default visual unless customization is needed. */
|
|
67
|
-
export
|
|
67
|
+
export function Indicator({ disableStyle, className, ref, ...props }) {
|
|
68
68
|
return (_jsx(BaseSwitch.Thumb, { ...props, ref: ref, "data-component": "switch-indicator", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
69
|
-
}
|
|
69
|
+
}
|
|
70
70
|
/** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
|
|
71
|
-
export
|
|
71
|
+
export function Label({ disableStyle, className, ref, ...props }) {
|
|
72
72
|
const context = useSwitchContext();
|
|
73
73
|
return (_jsx("label", { ...props, ref: ref, htmlFor: context.coreProps.id, "data-disabled": context.coreProps.disabled ? '' : undefined, "data-component": "switch-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
74
|
-
}
|
|
75
|
-
export
|
|
74
|
+
}
|
|
75
|
+
export function Description({ disableStyle, className, id, ref, ...props }) {
|
|
76
76
|
const messageId = useMessageId(id);
|
|
77
77
|
return (_jsx("div", { id: messageId, ...props, ref: ref, "data-component": "switch-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
78
|
-
}
|
|
78
|
+
}
|
|
79
79
|
/** Shows itself only while Root's validation is `'error'`: with no children it shows the message from `['error', message]`, a function children formats that message, and other children replace it. */
|
|
80
|
-
export
|
|
80
|
+
export function Error({ children, ref, ...props }) {
|
|
81
81
|
const context = useSwitchContext();
|
|
82
82
|
const content = validationMessageContent(context.validation, 'error', children);
|
|
83
83
|
if (content === undefined)
|
|
84
84
|
return null;
|
|
85
85
|
return _jsx(Message, { ...props, ref: ref, role: "alert", component: "switch-error", children: content });
|
|
86
|
-
}
|
|
86
|
+
}
|
|
87
87
|
/** Shows itself only while Root's validation is `'success'`: with no children it shows the message from `['success', message]`, a function children formats that message, and other children replace it. */
|
|
88
|
-
export
|
|
88
|
+
export function Success({ children, ref, ...props }) {
|
|
89
89
|
const context = useSwitchContext();
|
|
90
90
|
const content = validationMessageContent(context.validation, 'success', children);
|
|
91
91
|
if (content === undefined)
|
|
92
92
|
return null;
|
|
93
93
|
return _jsx(Message, { ...props, ref: ref, role: "status", component: "switch-success", children: content });
|
|
94
|
-
}
|
|
94
|
+
}
|
|
95
95
|
// The shared body of Error and Success, mounted only while they show, so only visible messages describe the switch
|
|
96
|
-
|
|
96
|
+
function Message({ disableStyle, className, id, component, ref, ...props }) {
|
|
97
97
|
const messageId = useMessageId(id);
|
|
98
98
|
return _jsx("div", { "aria-atomic": "true", ...props, id: messageId, ref: ref, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
|
|
99
|
-
}
|
|
99
|
+
}
|
|
100
100
|
const SwitchContext = /* @__PURE__ */ createContext(null);
|
|
101
101
|
function useSwitchContext() {
|
|
102
102
|
const context = useContext(SwitchContext);
|
|
@@ -91,8 +91,8 @@ export declare function Table({ disableStyle, className, ...props }: ComponentPr
|
|
|
91
91
|
export declare function ColGroup({ disableStyle, className, ...props }: ComponentProps<'colgroup'> & StyleProps): import("react").JSX.Element;
|
|
92
92
|
export declare function Col({ disableStyle, className, ...props }: ComponentProps<'col'> & StyleProps): import("react").JSX.Element;
|
|
93
93
|
export declare function Head({ disableStyle, className, ...props }: ComponentProps<'thead'> & StyleProps): import("react").JSX.Element;
|
|
94
|
-
export declare
|
|
95
|
-
export declare
|
|
94
|
+
export declare function Body({ disableStyle, className, ref, ...props }: ComponentProps<'tbody'> & StyleProps): import("react").JSX.Element;
|
|
95
|
+
export declare function Row({ disableStyle, className, ref, ...props }: ComponentProps<'tr'> & StyleProps): import("react").JSX.Element;
|
|
96
96
|
export declare function HeadCell({ disableStyle, className, ...props }: ComponentProps<'th'> & StyleProps): import("react").JSX.Element;
|
|
97
97
|
/** Already styled as text: write plain text directly inside it, without a wrapping text element. Add your own elements only when the content needs more than plain text, like an avatar next to a name or a lighter secondary line. */
|
|
98
98
|
export declare function Cell({ disableStyle, className, ...props }: ComponentProps<'td'> & StyleProps): import("react").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { cloneElement, createContext,
|
|
2
|
+
import { cloneElement, createContext, useContext, useEffect, useRef, useState, } from 'react';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
4
|
const PinningContext = /* @__PURE__ */ createContext(null);
|
|
5
5
|
function usePinning() {
|
|
@@ -141,17 +141,17 @@ export function ScrollArea({ disableStyle, className, onScroll, style, ...props
|
|
|
141
141
|
onScroll?.(event);
|
|
142
142
|
}, "data-component": "table-scrollarea", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
143
143
|
}
|
|
144
|
-
const pinningStyles = `
|
|
145
|
-
table[data-slot="table"] > :is(thead, tbody, tfoot) > tr > :is(th, td)[data-pinning="first"]:first-child {
|
|
146
|
-
position: sticky;
|
|
147
|
-
left: 0;
|
|
148
|
-
z-index: 10;
|
|
149
|
-
}
|
|
150
|
-
table[data-slot="table"] > :is(thead, tbody, tfoot) > tr > :is(th, td)[data-pinning="last"]:last-child {
|
|
151
|
-
position: sticky;
|
|
152
|
-
right: 0;
|
|
153
|
-
z-index: 10;
|
|
154
|
-
}
|
|
144
|
+
const pinningStyles = `
|
|
145
|
+
table[data-slot="table"] > :is(thead, tbody, tfoot) > tr > :is(th, td)[data-pinning="first"]:first-child {
|
|
146
|
+
position: sticky;
|
|
147
|
+
left: 0;
|
|
148
|
+
z-index: 10;
|
|
149
|
+
}
|
|
150
|
+
table[data-slot="table"] > :is(thead, tbody, tfoot) > tr > :is(th, td)[data-pinning="last"]:last-child {
|
|
151
|
+
position: sticky;
|
|
152
|
+
right: 0;
|
|
153
|
+
z-index: 10;
|
|
154
|
+
}
|
|
155
155
|
`;
|
|
156
156
|
export function Table({ disableStyle, className, ...props }) {
|
|
157
157
|
return (_jsxs(_Fragment, { children: [_jsx("style", { children: pinningStyles }), _jsx("table", { ...props, "data-slot": "table", "data-component": "table-table", "data-style-disabled": disableStyle ? '' : undefined, className: className })] }));
|
|
@@ -165,12 +165,12 @@ export function Col({ disableStyle, className, ...props }) {
|
|
|
165
165
|
export function Head({ disableStyle, className, ...props }) {
|
|
166
166
|
return (_jsx("thead", { ...props, "data-slot": "table-header", "data-component": "table-head", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
167
167
|
}
|
|
168
|
-
export
|
|
168
|
+
export function Body({ disableStyle, className, ref, ...props }) {
|
|
169
169
|
return (_jsx("tbody", { ...props, ref: ref, "data-component": "table-body", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
170
|
-
}
|
|
171
|
-
export
|
|
170
|
+
}
|
|
171
|
+
export function Row({ disableStyle, className, ref, ...props }) {
|
|
172
172
|
return (_jsx("tr", { ...props, ref: ref, "data-component": "table-row", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
173
|
-
}
|
|
173
|
+
}
|
|
174
174
|
export function HeadCell({ disableStyle, className, ...props }) {
|
|
175
175
|
const pinning = usePinning();
|
|
176
176
|
return (_jsx("th", { ...props, "data-pinning": pinning, "data-component": "table-headcell", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
@@ -47,20 +47,20 @@ import type { SVGIconProps } from '../../types/Icon.ts';
|
|
|
47
47
|
* </Tabs.List>
|
|
48
48
|
*/
|
|
49
49
|
export declare function Root({ children, ...props }: Omit<BaseTabs.Root.Props, 'render' | 'className'>): import("react").JSX.Element;
|
|
50
|
-
export declare
|
|
50
|
+
export declare function List({ disableStyle, className, ref, ...props }: (Omit<BaseTabs.List.Props, 'className' | 'render'> & {
|
|
51
51
|
className?: string;
|
|
52
|
-
} & StyleProps
|
|
53
|
-
export declare
|
|
52
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
53
|
+
export declare function Tab({ disableStyle, className, ref, ...props }: (Omit<BaseTabs.Tab.Props, 'className' | 'render'> & {
|
|
54
54
|
className?: string;
|
|
55
|
-
} & StyleProps
|
|
55
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
56
56
|
/** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
|
|
57
|
-
export declare
|
|
57
|
+
export declare function Icon({ disableStyle, children, className, ref, ...props }: (SVGIconProps & {
|
|
58
58
|
/** Supply the decorative icon; the wrapper forwards the relevant state and preserves its classes. */
|
|
59
59
|
children: ReactElement<SVGIconProps>;
|
|
60
|
-
} & StyleProps,
|
|
61
|
-
export declare
|
|
60
|
+
}) & StyleProps): ReactElement<SVGIconProps, string | import("react").JSXElementConstructor<any>>;
|
|
61
|
+
export declare function Indicator({ disableStyle, className, ref, ...props }: (Omit<BaseTabs.Indicator.Props, 'className' | 'render'> & {
|
|
62
62
|
className?: string;
|
|
63
|
-
} & StyleProps
|
|
64
|
-
export declare
|
|
63
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
64
|
+
export declare function Content({ disableStyle, className, ref, ...props }: (Omit<BaseTabs.Panel.Props, 'className' | 'render'> & {
|
|
65
65
|
className?: string;
|
|
66
|
-
} & StyleProps
|
|
66
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Tabs as BaseTabs } from '@base-ui/react/tabs';
|
|
3
|
-
import { cloneElement
|
|
3
|
+
import { cloneElement } from 'react';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
5
5
|
/**
|
|
6
6
|
* Match each Tab value to a Content value in the same Root. Let Tabs handle the active panel and keyboard navigation; do not add separate visibility conditions. Indicator is optional decoration.
|
|
@@ -50,14 +50,14 @@ export function Root({ children, ...props }) {
|
|
|
50
50
|
// Native Root renders a div; the fragment preserves our wrapper-free Root contract.
|
|
51
51
|
return (_jsx(BaseTabs.Root, { ...props, render: (rootProps) => _jsx(_Fragment, { children: rootProps.children }), children: children }));
|
|
52
52
|
}
|
|
53
|
-
export
|
|
53
|
+
export function List({ disableStyle, className, ref, ...props }) {
|
|
54
54
|
return (_jsx(BaseTabs.List, { ...props, ref: ref, "data-component": "tabs-list", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
55
|
-
}
|
|
56
|
-
export
|
|
55
|
+
}
|
|
56
|
+
export function Tab({ disableStyle, className, ref, ...props }) {
|
|
57
57
|
return (_jsx(BaseTabs.Tab, { ...props, ref: ref, "data-component": "tabs-tab", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
58
|
-
}
|
|
58
|
+
}
|
|
59
59
|
/** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
|
|
60
|
-
export
|
|
60
|
+
export function Icon({ disableStyle, children, className, ref, ...props }) {
|
|
61
61
|
return cloneElement(children, {
|
|
62
62
|
...props,
|
|
63
63
|
ref,
|
|
@@ -68,10 +68,10 @@ export const Icon = /* @__PURE__ */ forwardRef(function Icon({ disableStyle, chi
|
|
|
68
68
|
},
|
|
69
69
|
className: twMerge(children.props.className, className),
|
|
70
70
|
});
|
|
71
|
-
}
|
|
72
|
-
export
|
|
71
|
+
}
|
|
72
|
+
export function Indicator({ disableStyle, className, ref, ...props }) {
|
|
73
73
|
return (_jsx(BaseTabs.Indicator, { ...props, ref: ref, "data-component": "tabs-indicator", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
74
|
-
}
|
|
75
|
-
export
|
|
74
|
+
}
|
|
75
|
+
export function Content({ disableStyle, className, ref, ...props }) {
|
|
76
76
|
return (_jsx(BaseTabs.Panel, { ...props, ref: ref, "data-component": "tabs-content", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
77
|
-
}
|
|
77
|
+
}
|
|
@@ -46,30 +46,30 @@ export declare function Root({ children, id, validation, value, defaultValue, on
|
|
|
46
46
|
export type TextareaProps = Omit<ComponentProps<'textarea'>, keyof Pick<RootProps, 'id' | 'name' | 'form' | 'value' | 'defaultValue' | 'onValueChange' | 'disabled' | 'readOnly' | 'required'>> & {
|
|
47
47
|
className?: string;
|
|
48
48
|
} & StyleProps;
|
|
49
|
-
export declare
|
|
50
|
-
export declare
|
|
51
|
-
export declare
|
|
49
|
+
export declare function Textarea({ disableStyle, className, 'aria-describedby': describedBy, ref, ...props }: TextareaProps): import("react").JSX.Element;
|
|
50
|
+
export declare function TextareaGroup({ disableStyle, className, onClick, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
51
|
+
export declare function Container({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
52
52
|
/** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
|
|
53
|
-
export declare
|
|
54
|
-
export declare
|
|
53
|
+
export declare function Label({ disableStyle, className, id, ref, ...props }: Omit<ComponentProps<'label'>, 'htmlFor'> & StyleProps): import("react").JSX.Element;
|
|
54
|
+
export declare function Description({ disableStyle, className, id, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
55
55
|
type MessageProps = Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
|
|
56
56
|
children?: ValidationMessageChildren;
|
|
57
57
|
};
|
|
58
58
|
/** Shows itself only while Root's validation is `'error'`: with no children it shows the message from `['error', message]`, a function children formats that message, and other children replace it. */
|
|
59
|
-
export declare
|
|
59
|
+
export declare function Error({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
|
|
60
60
|
/** Shows itself only while Root's validation is `'success'`: with no children it shows the message from `['success', message]`, a function children formats that message, and other children replace it. */
|
|
61
|
-
export declare
|
|
62
|
-
export declare
|
|
61
|
+
export declare function Success({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
|
|
62
|
+
export declare function Addon({ disableStyle, className, variant, ref, ...props }: (ComponentProps<'div'> & {
|
|
63
63
|
/** Choose the preset appearance; this does not add action behavior. */
|
|
64
|
-
variant?:
|
|
65
|
-
} & StyleProps
|
|
66
|
-
export declare
|
|
64
|
+
variant?: 'normal' | 'emphasized';
|
|
65
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
66
|
+
export declare function AddonText({ disableStyle, className, ref, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element;
|
|
67
67
|
/** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
|
|
68
68
|
export declare function AddonIcon({ disableStyle, children, className, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
|
|
69
69
|
/** Supply the decorative icon; the wrapper forwards the relevant state and preserves its classes. */
|
|
70
70
|
children: ReactElement<ComponentProps<'svg'>>;
|
|
71
71
|
}) & StyleProps): ReactElement<import("react").SVGProps<SVGSVGElement>, string | import("react").JSXElementConstructor<any>>;
|
|
72
|
-
export declare
|
|
72
|
+
export declare function AddonButton({ disableStyle, className, disabled, type, ref, ...props }: ComponentProps<'button'> & StyleProps): import("react").JSX.Element;
|
|
73
73
|
/** Built-in icon; no children needed. Use it inside its matching control. */
|
|
74
|
-
export declare
|
|
74
|
+
export declare function AddonLoadingIcon({ disableStyle, className, strokeWidth, ref, ...props }: Omit<SVGIconProps, 'children'> & StyleProps): import("react").JSX.Element;
|
|
75
75
|
export {};
|
|
@@ -3,7 +3,7 @@ import { Input as BaseInput } from '@base-ui/react/input';
|
|
|
3
3
|
import { LoaderCircle } from "../../utils/icons.js";
|
|
4
4
|
import { useRef } from 'react';
|
|
5
5
|
import { useForwardClickToInput } from "../../utils/useForwardClickToInput.js";
|
|
6
|
-
import { cloneElement, createContext,
|
|
6
|
+
import { cloneElement, createContext, useContext, useEffect, useId, useState, } from 'react';
|
|
7
7
|
import { twMerge } from 'tailwind-merge';
|
|
8
8
|
import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
|
|
9
9
|
/**
|
|
@@ -60,7 +60,7 @@ export function Root({ children, id, validation, value, defaultValue, onValueCha
|
|
|
60
60
|
validation: readValidation(validation),
|
|
61
61
|
}, children: children }));
|
|
62
62
|
}
|
|
63
|
-
export
|
|
63
|
+
export function Textarea({ disableStyle, className, 'aria-describedby': describedBy, ref, ...props }) {
|
|
64
64
|
const context = useInputContext();
|
|
65
65
|
const inputRef = useRef(null);
|
|
66
66
|
// Resetting the internal value when the surrounding html form resets, since the control is always controlled by Root's value
|
|
@@ -90,58 +90,58 @@ export const Textarea = /* @__PURE__ */ forwardRef(function Textarea({ disableSt
|
|
|
90
90
|
if (!details.isCanceled && !context.controlled)
|
|
91
91
|
context.setValueInternalState(nextValue);
|
|
92
92
|
}, "data-component": "textarea-textarea", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
93
|
-
}
|
|
94
|
-
export
|
|
93
|
+
}
|
|
94
|
+
export function TextareaGroup({ disableStyle, className, onClick, ref, ...props }) {
|
|
95
95
|
const attributes = usePartAttributes();
|
|
96
96
|
const forwardClick = useForwardClickToInput('textarea', onClick);
|
|
97
97
|
return (_jsx("div", { ...attributes, ...props, ref: ref, onClick: forwardClick, "data-component": "textarea-textareagroup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
98
|
-
}
|
|
99
|
-
export
|
|
98
|
+
}
|
|
99
|
+
export function Container({ disableStyle, className, ref, ...props }) {
|
|
100
100
|
const attributes = usePartAttributes();
|
|
101
101
|
return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "textarea-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
102
|
-
}
|
|
102
|
+
}
|
|
103
103
|
/** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
|
|
104
|
-
export
|
|
104
|
+
export function Label({ disableStyle, className, id, ref, ...props }) {
|
|
105
105
|
const context = useInputContext();
|
|
106
106
|
const labelId = id ?? context.inputId + '-label';
|
|
107
107
|
const attributes = usePartAttributes();
|
|
108
108
|
return (_jsx("label", { ...attributes, ...props, id: labelId, ref: ref, htmlFor: context.inputId, "data-component": "textarea-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
109
|
-
}
|
|
110
|
-
export
|
|
109
|
+
}
|
|
110
|
+
export function Description({ disableStyle, className, id, ref, ...props }) {
|
|
111
111
|
const messageId = useMessageId(id);
|
|
112
112
|
const attributes = usePartAttributes();
|
|
113
113
|
return (_jsx("div", { ...attributes, ...props, id: messageId, ref: ref, "data-component": "textarea-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
114
|
-
}
|
|
114
|
+
}
|
|
115
115
|
/** Shows itself only while Root's validation is `'error'`: with no children it shows the message from `['error', message]`, a function children formats that message, and other children replace it. */
|
|
116
|
-
export
|
|
116
|
+
export function Error({ children, ref, ...props }) {
|
|
117
117
|
const context = useInputContext();
|
|
118
118
|
const content = validationMessageContent(context.validation, 'error', children);
|
|
119
119
|
if (content === undefined)
|
|
120
120
|
return null;
|
|
121
121
|
return _jsx(Message, { ...props, ref: ref, role: "alert", component: "textarea-error", children: content });
|
|
122
|
-
}
|
|
122
|
+
}
|
|
123
123
|
/** Shows itself only while Root's validation is `'success'`: with no children it shows the message from `['success', message]`, a function children formats that message, and other children replace it. */
|
|
124
|
-
export
|
|
124
|
+
export function Success({ children, ref, ...props }) {
|
|
125
125
|
const context = useInputContext();
|
|
126
126
|
const content = validationMessageContent(context.validation, 'success', children);
|
|
127
127
|
if (content === undefined)
|
|
128
128
|
return null;
|
|
129
129
|
return _jsx(Message, { ...props, ref: ref, role: "status", component: "textarea-success", children: content });
|
|
130
|
-
}
|
|
130
|
+
}
|
|
131
131
|
// The shared body of Error and Success, mounted only while they show, so only visible messages describe the textarea
|
|
132
|
-
|
|
132
|
+
function Message({ disableStyle, className, id, component, ref, ...props }) {
|
|
133
133
|
const messageId = useMessageId(id);
|
|
134
134
|
const attributes = usePartAttributes();
|
|
135
135
|
return _jsx("div", { "aria-atomic": "true", ...attributes, ...props, id: messageId, ref: ref, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
|
|
136
|
-
}
|
|
137
|
-
export
|
|
136
|
+
}
|
|
137
|
+
export function Addon({ disableStyle, className, variant = 'normal', ref, ...props }) {
|
|
138
138
|
const attributes = usePartAttributes();
|
|
139
139
|
return (_jsx("div", { ...attributes, ...props, ref: ref, "data-variant": variant, "data-component": "textarea-addon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
140
|
-
}
|
|
141
|
-
export
|
|
140
|
+
}
|
|
141
|
+
export function AddonText({ disableStyle, className, ref, ...props }) {
|
|
142
142
|
const attributes = usePartAttributes();
|
|
143
143
|
return (_jsx("span", { ...attributes, ...props, ref: ref, "data-component": "textarea-addontext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
144
|
-
}
|
|
144
|
+
}
|
|
145
145
|
/** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
|
|
146
146
|
export function AddonIcon({ disableStyle, children, className, ...props }) {
|
|
147
147
|
const attributes = usePartAttributes();
|
|
@@ -157,16 +157,16 @@ export function AddonIcon({ disableStyle, children, className, ...props }) {
|
|
|
157
157
|
className: twMerge(children.props.className, className),
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
|
-
export
|
|
160
|
+
export function AddonButton({ disableStyle, className, disabled, type = 'button', ref, ...props }) {
|
|
161
161
|
const context = useInputContext();
|
|
162
162
|
const attributes = usePartAttributes();
|
|
163
163
|
return (_jsx("button", { ...attributes, ...props, ref: ref, type: type, disabled: disabled || context.disabled || context.readOnly, "data-component": "textarea-addonbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
164
|
-
}
|
|
164
|
+
}
|
|
165
165
|
/** Built-in icon; no children needed. Use it inside its matching control. */
|
|
166
|
-
export
|
|
166
|
+
export function AddonLoadingIcon({ disableStyle, className, strokeWidth = 1.5, ref, ...props }) {
|
|
167
167
|
const attributes = usePartAttributes();
|
|
168
168
|
return (_jsx(LoaderCircle, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "textarea-addonloadingicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
169
|
-
}
|
|
169
|
+
}
|
|
170
170
|
const InputContext = /* @__PURE__ */ createContext(null);
|
|
171
171
|
function useInputContext() {
|
|
172
172
|
const context = useContext(InputContext);
|
|
@@ -2,7 +2,7 @@ import type { StyleProps } from '../../types/Style.ts';
|
|
|
2
2
|
import type { AsChildProps } from '../../utils/asChild.ts';
|
|
3
3
|
import { Toast as BaseToast } from '@base-ui/react/toast';
|
|
4
4
|
import type { ComponentProps, ReactElement, ReactNode } from 'react';
|
|
5
|
-
export type ProviderProps = Omit<BaseToast.Provider.Props, 'toastManager'> & Pick<BaseToast.Viewport.Props, 'style'> & {
|
|
5
|
+
export type ProviderProps = Omit<BaseToast.Provider.Props, 'toastManager' | 'render'> & Pick<BaseToast.Viewport.Props, 'style'> & {
|
|
6
6
|
className?: string;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
@@ -64,10 +64,10 @@ export declare function Root({ tone, children, }: {
|
|
|
64
64
|
tone?: 'neutral' | 'success' | 'error';
|
|
65
65
|
children: ReactNode;
|
|
66
66
|
}): import("react").JSX.Element;
|
|
67
|
-
export type ToastProps = Omit<BaseToast.Root.Props, 'toast' | 'className'> & {
|
|
67
|
+
export type ToastProps = Omit<BaseToast.Root.Props, 'toast' | 'className' | 'render'> & {
|
|
68
68
|
className?: string;
|
|
69
69
|
} & StyleProps;
|
|
70
|
-
export declare
|
|
70
|
+
export declare function Toast({ disableStyle, className, style, children, ref, ...props }: ToastProps): import("react").JSX.Element;
|
|
71
71
|
/** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
72
72
|
export declare function Icon({ disableStyle, children, className, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
|
|
73
73
|
/** Omit for the supplied default icon; pass a child only to replace it. */
|
|
@@ -75,20 +75,20 @@ export declare function Icon({ disableStyle, children, className, ...props }: (O
|
|
|
75
75
|
'data-tone'?: string;
|
|
76
76
|
}>;
|
|
77
77
|
}) & StyleProps): import("react").FunctionComponentElement<any>;
|
|
78
|
-
export declare
|
|
78
|
+
export declare function Title({ disableStyle, className, ref, ...props }: (Omit<BaseToast.Title.Props, 'className' | 'render'> & {
|
|
79
79
|
className?: string;
|
|
80
|
-
} & StyleProps
|
|
81
|
-
export declare
|
|
80
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
81
|
+
export declare function Description({ disableStyle, className, ref, ...props }: (Omit<BaseToast.Description.Props, 'className' | 'render'> & {
|
|
82
82
|
className?: string;
|
|
83
|
-
} & StyleProps
|
|
83
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
84
84
|
/** Icon-only: put just a CloseButtonIcon inside, never text like "Close". It is already named "Dismiss notification" for screen readers. Pass asChild to give dismissing behavior to your own button instead, like a "Dismiss" Button, which then names itself. */
|
|
85
|
-
export declare
|
|
85
|
+
export declare function CloseButton({ asChild, disableStyle, children, ref, ...props }: Omit<BaseToast.Close.Props, 'className' | 'render'> & {
|
|
86
86
|
className?: string;
|
|
87
|
-
} & AsChildProps & StyleProps
|
|
87
|
+
} & AsChildProps & StyleProps): import("react").JSX.Element;
|
|
88
88
|
/** Runs the toast's action. Pass asChild to give this behavior to your own button instead; it keeps the state data attributes but none of this part's styling. */
|
|
89
|
-
export declare
|
|
89
|
+
export declare function ActionButton({ asChild, disableStyle, children, ref, ...props }: Omit<BaseToast.Action.Props, 'className' | 'render'> & {
|
|
90
90
|
className?: string;
|
|
91
|
-
} & AsChildProps & StyleProps
|
|
91
|
+
} & AsChildProps & StyleProps): import("react").JSX.Element;
|
|
92
92
|
/** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
93
93
|
export declare function CloseButtonIcon({ disableStyle, children, className, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
|
|
94
94
|
/** Omit for the supplied default icon; pass a child only to replace it. */
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { asChildRendering } from "../../utils/asChild.js";
|
|
3
3
|
import { Toast as BaseToast } from '@base-ui/react/toast';
|
|
4
4
|
import { CircleCheck, Info, TriangleAlert, X } from "../../utils/icons.js";
|
|
5
|
-
import { cloneElement, createContext,
|
|
5
|
+
import { cloneElement, createContext, useContext, useEffect, useState, } from 'react';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
7
|
/**
|
|
8
8
|
* Mount Provider once before calling Show. Show receives the notification composition; do not render Toast directly outside it. Icon follows Root tone automatically. For urgent priority, supply title/description in Show options so the live region can announce them.
|
|
@@ -74,7 +74,7 @@ export function Show(render, options) {
|
|
|
74
74
|
export function Root({ tone = 'neutral', children, }) {
|
|
75
75
|
return _jsx(ToneContext.Provider, { value: tone, children: children });
|
|
76
76
|
}
|
|
77
|
-
export
|
|
77
|
+
export function Toast({ disableStyle, className, style, children, ref, ...props }) {
|
|
78
78
|
const notification = useNotificationContext();
|
|
79
79
|
const tone = useContext(ToneContext);
|
|
80
80
|
return (_jsx(BaseToast.Root, { ...props, ref: ref, toast: notification, "data-tone": tone, "data-component": "toast-toast", "data-style-disabled": disableStyle ? '' : undefined, className: className, style: (state) => {
|
|
@@ -115,7 +115,7 @@ export const Toast = /* @__PURE__ */ forwardRef(function Toast({ disableStyle, c
|
|
|
115
115
|
...(typeof style === 'function' ? style(state) : style),
|
|
116
116
|
};
|
|
117
117
|
}, children: _jsx(BaseToast.Content, { "data-component": "toast-toast-1", children: children }) }));
|
|
118
|
-
}
|
|
118
|
+
}
|
|
119
119
|
/** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
120
120
|
export function Icon({ disableStyle, children, className, ...props }) {
|
|
121
121
|
const tone = useContext(ToneContext);
|
|
@@ -141,24 +141,24 @@ export function Icon({ disableStyle, children, className, ...props }) {
|
|
|
141
141
|
strokeWidth: props.strokeWidth ?? icon.props.strokeWidth ?? 1.8,
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
-
export
|
|
144
|
+
export function Title({ disableStyle, className, ref, ...props }) {
|
|
145
145
|
return (_jsx(BaseToast.Title, { ...props, ref: ref, "data-component": "toast-title", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
146
|
-
}
|
|
147
|
-
export
|
|
146
|
+
}
|
|
147
|
+
export function Description({ disableStyle, className, ref, ...props }) {
|
|
148
148
|
return (_jsx(BaseToast.Description, { ...props, ref: ref, "data-component": "toast-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
149
|
-
}
|
|
149
|
+
}
|
|
150
150
|
/** Icon-only: put just a CloseButtonIcon inside, never text like "Close". It is already named "Dismiss notification" for screen readers. Pass asChild to give dismissing behavior to your own button instead, like a "Dismiss" Button, which then names itself. */
|
|
151
|
-
export
|
|
151
|
+
export function CloseButton({ asChild, disableStyle, children, ref, ...props }) {
|
|
152
152
|
// Naming the icon-only button for screen readers, while the consumer's own button names itself
|
|
153
153
|
const ariaLabel = asChild ? undefined : 'Dismiss notification';
|
|
154
154
|
const rendering = asChildRendering({ asChild, children, component: 'toast-closebutton', disableStyle });
|
|
155
155
|
return _jsx(BaseToast.Close, { "aria-label": ariaLabel, ...props, ref: ref, ...rendering });
|
|
156
|
-
}
|
|
156
|
+
}
|
|
157
157
|
/** Runs the toast's action. Pass asChild to give this behavior to your own button instead; it keeps the state data attributes but none of this part's styling. */
|
|
158
|
-
export
|
|
158
|
+
export function ActionButton({ asChild, disableStyle, children, ref, ...props }) {
|
|
159
159
|
const rendering = asChildRendering({ asChild, children, component: 'toast-actionbutton', disableStyle });
|
|
160
160
|
return _jsx(BaseToast.Action, { ...props, ref: ref, ...rendering });
|
|
161
|
-
}
|
|
161
|
+
}
|
|
162
162
|
/** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
163
163
|
export function CloseButtonIcon({ disableStyle, children = _jsx(X, {}), className, ...props }) {
|
|
164
164
|
const tone = useContext(ToneContext);
|
|
@@ -23,18 +23,18 @@ import type { SVGIconProps } from '../../types/Icon.ts';
|
|
|
23
23
|
* )
|
|
24
24
|
* }
|
|
25
25
|
*/
|
|
26
|
-
export declare
|
|
26
|
+
export declare function Root({ children, className, disableStyle, size, pressed, defaultPressed, onPressedChange, disabled, ref, ...props }: Omit<BaseToggle.Props, 'className'> & {
|
|
27
27
|
className?: string;
|
|
28
28
|
/** Choose the shared size for the visible parts in this composition. */
|
|
29
|
-
size?: ButtonProps[
|
|
30
|
-
} & StyleProps
|
|
29
|
+
size?: ButtonProps['size'];
|
|
30
|
+
} & StyleProps): import("react").JSX.Element;
|
|
31
31
|
/** Render beside InactiveIcon inside Root. It automatically appears only while pressed; supply the decorative icon without another visibility condition. */
|
|
32
|
-
export declare
|
|
32
|
+
export declare function ActiveIcon({ ref, ...props }: SVGIconProps & {
|
|
33
33
|
/** Supply the decorative icon; the wrapper forwards the relevant state and preserves its classes. */
|
|
34
34
|
children: ReactElement<SVGIconProps>;
|
|
35
|
-
} & StyleProps
|
|
35
|
+
} & StyleProps): import("react").JSX.Element | null;
|
|
36
36
|
/** Render beside ActiveIcon inside Root. It automatically appears only while unpressed; supply the decorative icon without another visibility condition. */
|
|
37
|
-
export declare
|
|
37
|
+
export declare function InactiveIcon({ ref, ...props }: SVGIconProps & {
|
|
38
38
|
/** Supply the decorative icon; the wrapper forwards the relevant state and preserves its classes. */
|
|
39
39
|
children: ReactElement<SVGIconProps>;
|
|
40
|
-
} & StyleProps
|
|
40
|
+
} & StyleProps): import("react").JSX.Element | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Toggle as BaseToggle } from '@base-ui/react/toggle';
|
|
3
|
-
import { cloneElement, createContext,
|
|
3
|
+
import { cloneElement, createContext, useContext, useState, } from 'react';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
5
5
|
/**
|
|
6
6
|
* Root is the interactive toggle button. ActiveIcon and InactiveIcon switch automatically with pressed state; do not conditionally render them yourself.
|
|
@@ -22,30 +22,30 @@ import { twMerge } from 'tailwind-merge';
|
|
|
22
22
|
* )
|
|
23
23
|
* }
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export function Root({ children, className, disableStyle, size = 'medium', pressed, defaultPressed = false, onPressedChange, disabled = false, ref, ...props }) {
|
|
26
26
|
const [pressedInternalState, setPressedInternalState] = useState(defaultPressed);
|
|
27
27
|
return (_jsx(BaseToggle, { ...props, ref: ref, pressed: pressed, defaultPressed: defaultPressed, disabled: disabled, "data-size": size, "data-component": "toggle-root", "data-style-disabled": disableStyle ? '' : undefined, onPressedChange: (next, details) => {
|
|
28
28
|
onPressedChange?.(next, details);
|
|
29
29
|
if (!details.isCanceled)
|
|
30
30
|
setPressedInternalState(next);
|
|
31
31
|
}, className: className, children: _jsx(ToggleContext.Provider, { value: { pressed: pressed ?? pressedInternalState, disabled, size }, children: children }) }));
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
33
|
/** Render beside InactiveIcon inside Root. It automatically appears only while pressed; supply the decorative icon without another visibility condition. */
|
|
34
|
-
export
|
|
34
|
+
export function ActiveIcon({ ref, ...props }) {
|
|
35
35
|
const context = useToggleContext();
|
|
36
36
|
if (!context.pressed)
|
|
37
37
|
return null;
|
|
38
38
|
return _jsx(StateIcon, { ...props, ref: ref, component: "toggle-activeicon" });
|
|
39
|
-
}
|
|
39
|
+
}
|
|
40
40
|
/** Render beside ActiveIcon inside Root. It automatically appears only while unpressed; supply the decorative icon without another visibility condition. */
|
|
41
|
-
export
|
|
41
|
+
export function InactiveIcon({ ref, ...props }) {
|
|
42
42
|
const context = useToggleContext();
|
|
43
43
|
if (context.pressed)
|
|
44
44
|
return null;
|
|
45
45
|
return _jsx(StateIcon, { ...props, ref: ref, component: "toggle-inactiveicon" });
|
|
46
|
-
}
|
|
46
|
+
}
|
|
47
47
|
// The shared body of ActiveIcon and InactiveIcon: decorates the supplied icon with the toggle's state
|
|
48
|
-
|
|
48
|
+
function StateIcon({ disableStyle, children, className, component, ref, ...props }) {
|
|
49
49
|
const context = useToggleContext();
|
|
50
50
|
return cloneElement(children, {
|
|
51
51
|
...props,
|
|
@@ -61,7 +61,7 @@ const StateIcon = /* @__PURE__ */ forwardRef(function StateIcon({ disableStyle,
|
|
|
61
61
|
},
|
|
62
62
|
className: twMerge(children.props.className, className),
|
|
63
63
|
});
|
|
64
|
-
}
|
|
64
|
+
}
|
|
65
65
|
const ToggleContext = /* @__PURE__ */ createContext(null);
|
|
66
66
|
function useToggleContext() {
|
|
67
67
|
const context = useContext(ToggleContext);
|