@central-ui/react 0.3.0 → 0.4.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/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 +8 -7
- package/dist/components/stepper/index.js +4 -2
- 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/utils/icons.d.ts +92 -23
- package/dist/utils/icons.js +3 -3
- package/package.json +69 -69
- package/src/presets/shopify-polaris/shopify-polaris-accordion.css +28 -28
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-accordion.css +28 -28
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { NumberField as BaseNumber } from '@base-ui/react/number-field';
|
|
3
3
|
import { ChevronUp, ChevronDown, LoaderCircle } from "../../utils/icons.js";
|
|
4
4
|
import { useForwardClickToInput } from "../../utils/useForwardClickToInput.js";
|
|
5
|
-
import { cloneElement, createContext,
|
|
5
|
+
import { cloneElement, createContext, useContext, useEffect, useId, useState, } from 'react';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
7
|
import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
|
|
8
8
|
/**
|
|
@@ -41,7 +41,7 @@ import { readValidation, validationAttributes, validationMessageContent } from "
|
|
|
41
41
|
* }
|
|
42
42
|
* </NumberInput.Root>
|
|
43
43
|
*/
|
|
44
|
-
export
|
|
44
|
+
export function Root({ id, validation, children, ref, ...props }) {
|
|
45
45
|
const generatedId = useId();
|
|
46
46
|
const inputId = id ?? generatedId;
|
|
47
47
|
// Holding the ids of Description, Error and Success, so the control announces them to screen readers through aria-describedby
|
|
@@ -55,59 +55,59 @@ export const Root = /* @__PURE__ */ forwardRef(function Root({ id, validation, c
|
|
|
55
55
|
max: props.max,
|
|
56
56
|
validation: readValidation(validation),
|
|
57
57
|
}, children: _jsx("div", { ...rootProps }) })), children: children }));
|
|
58
|
-
}
|
|
59
|
-
export
|
|
58
|
+
}
|
|
59
|
+
export function Input({ disableStyle, className, 'aria-describedby': describedBy, ref, ...props }) {
|
|
60
60
|
const context = useInputContext();
|
|
61
61
|
return (_jsx(BaseNumber.Input, { ...props, ref: ref, ...validationAttributes(context.validation), "aria-invalid": context.validation.state === 'error' || props['aria-invalid'] || undefined, "aria-describedby": [describedBy, ...context.describedByIds]
|
|
62
62
|
.filter(Boolean)
|
|
63
63
|
.join(' ') || undefined, "data-component": "numberinput-input", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
64
|
-
}
|
|
65
|
-
export
|
|
64
|
+
}
|
|
65
|
+
export function Container({ disableStyle, className, ref, ...props }) {
|
|
66
66
|
const attributes = usePartAttributes();
|
|
67
67
|
return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "numberinput-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
68
|
-
}
|
|
68
|
+
}
|
|
69
69
|
/** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
|
|
70
|
-
export
|
|
70
|
+
export function Label({ disableStyle, className, id, ref, ...props }) {
|
|
71
71
|
const context = useInputContext();
|
|
72
72
|
const labelId = id ?? context.inputId + '-label';
|
|
73
73
|
const attributes = usePartAttributes();
|
|
74
74
|
return (_jsx("label", { ...attributes, ...props, id: labelId, ref: ref, htmlFor: context.inputId, "data-component": "numberinput-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
75
|
-
}
|
|
76
|
-
export
|
|
75
|
+
}
|
|
76
|
+
export function Description({ disableStyle, className, id, ref, ...props }) {
|
|
77
77
|
const messageId = useMessageId(id);
|
|
78
78
|
const attributes = usePartAttributes();
|
|
79
79
|
return (_jsx("div", { ...attributes, ...props, id: messageId, ref: ref, "data-component": "numberinput-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
80
|
-
}
|
|
80
|
+
}
|
|
81
81
|
/** 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. */
|
|
82
|
-
export
|
|
82
|
+
export function Error({ children, ref, ...props }) {
|
|
83
83
|
const context = useInputContext();
|
|
84
84
|
const content = validationMessageContent(context.validation, 'error', children);
|
|
85
85
|
if (content === undefined)
|
|
86
86
|
return null;
|
|
87
87
|
return _jsx(Message, { ...props, ref: ref, role: "alert", component: "numberinput-error", children: content });
|
|
88
|
-
}
|
|
88
|
+
}
|
|
89
89
|
/** 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. */
|
|
90
|
-
export
|
|
90
|
+
export function Success({ children, ref, ...props }) {
|
|
91
91
|
const context = useInputContext();
|
|
92
92
|
const content = validationMessageContent(context.validation, 'success', children);
|
|
93
93
|
if (content === undefined)
|
|
94
94
|
return null;
|
|
95
95
|
return _jsx(Message, { ...props, ref: ref, role: "status", component: "numberinput-success", children: content });
|
|
96
|
-
}
|
|
96
|
+
}
|
|
97
97
|
// The shared body of Error and Success, mounted only while they show, so only visible messages describe the number input
|
|
98
|
-
|
|
98
|
+
function Message({ disableStyle, className, id, component, ref, ...props }) {
|
|
99
99
|
const messageId = useMessageId(id);
|
|
100
100
|
const attributes = usePartAttributes();
|
|
101
101
|
return _jsx("div", { "aria-atomic": "true", ...attributes, ...props, id: messageId, ref: ref, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
|
|
102
|
-
}
|
|
103
|
-
export
|
|
102
|
+
}
|
|
103
|
+
export function Addon({ disableStyle, className, variant = 'normal', ref, ...props }) {
|
|
104
104
|
const attributes = usePartAttributes();
|
|
105
105
|
return (_jsx("div", { ...attributes, ...props, ref: ref, "data-variant": variant, "data-component": "numberinput-addon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
106
|
-
}
|
|
107
|
-
export
|
|
106
|
+
}
|
|
107
|
+
export function AddonText({ disableStyle, className, ref, ...props }) {
|
|
108
108
|
const attributes = usePartAttributes();
|
|
109
109
|
return (_jsx("span", { ...attributes, ...props, ref: ref, "data-component": "numberinput-addontext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
110
|
-
}
|
|
110
|
+
}
|
|
111
111
|
/** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
|
|
112
112
|
export function AddonIcon({ disableStyle, children, className, ...props }) {
|
|
113
113
|
const attributes = usePartAttributes();
|
|
@@ -123,34 +123,34 @@ export function AddonIcon({ disableStyle, children, className, ...props }) {
|
|
|
123
123
|
className: twMerge(children.props.className, className),
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
|
-
export
|
|
126
|
+
export function AddonButton({ disableStyle, className, disabled, type = 'button', ref, ...props }) {
|
|
127
127
|
const context = useInputContext();
|
|
128
128
|
const attributes = usePartAttributes();
|
|
129
129
|
return (_jsx("button", { ...attributes, ...props, ref: ref, type: type, disabled: disabled || context.disabled || context.readOnly, "data-component": "numberinput-addonbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
130
|
-
}
|
|
130
|
+
}
|
|
131
131
|
/** Built-in icon; no children needed. Use it inside its matching control. */
|
|
132
|
-
export
|
|
132
|
+
export function AddonLoadingIcon({ disableStyle, className, strokeWidth = 1.5, ref, ...props }) {
|
|
133
133
|
const attributes = usePartAttributes();
|
|
134
134
|
return (_jsx(LoaderCircle, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "numberinput-addonloadingicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
135
|
-
}
|
|
136
|
-
export
|
|
135
|
+
}
|
|
136
|
+
export function InputGroup({ disableStyle, className, onClick, ref, ...props }) {
|
|
137
137
|
const attributes = usePartAttributes();
|
|
138
138
|
const forwardClick = useForwardClickToInput('input:not([type="hidden"])', onClick);
|
|
139
139
|
return (_jsx(BaseNumber.Group, { ...attributes, ...props, ref: ref, onClick: forwardClick, "data-component": "numberinput-inputgroup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
140
|
-
}
|
|
141
|
-
export
|
|
140
|
+
}
|
|
141
|
+
export function ButtonsList({ disableStyle, className, ref, ...props }) {
|
|
142
142
|
const attributes = usePartAttributes();
|
|
143
143
|
return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "numberinput-buttonslist", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
144
|
-
}
|
|
144
|
+
}
|
|
145
145
|
/** Formats the current number automatically. Omit children for the default display; customize only when the usual number formatting is insufficient. */
|
|
146
|
-
export
|
|
146
|
+
export function ValueText({ disableStyle, className, ref, ...props }) {
|
|
147
147
|
const context = useInputContext();
|
|
148
148
|
const attributes = usePartAttributes();
|
|
149
149
|
return (_jsx("span", { ...attributes, ...props, ref: ref, "data-component": "numberinput-valuetext", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: context.inputValue }));
|
|
150
|
-
}
|
|
151
|
-
export
|
|
150
|
+
}
|
|
151
|
+
export function IncrementButton({ disableStyle, className, ref, ...props }) {
|
|
152
152
|
return (_jsx(BaseNumber.Increment, { ...props, ref: ref, "data-component": "numberinput-incrementbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
153
|
-
}
|
|
153
|
+
}
|
|
154
154
|
/** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
155
155
|
export function IncrementButtonIcon({ disableStyle, children = _jsx(ChevronUp, {}), className, ...props }) {
|
|
156
156
|
const context = useInputContext();
|
|
@@ -173,9 +173,9 @@ export function IncrementButtonIcon({ disableStyle, children = _jsx(ChevronUp, {
|
|
|
173
173
|
className: twMerge(children.props.className, className),
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
|
-
export
|
|
176
|
+
export function DecrementButton({ disableStyle, className, ref, ...props }) {
|
|
177
177
|
return (_jsx(BaseNumber.Decrement, { ...props, ref: ref, "data-component": "numberinput-decrementbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
178
|
-
}
|
|
178
|
+
}
|
|
179
179
|
/** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
180
180
|
export function DecrementButtonIcon({ disableStyle, children = _jsx(ChevronDown, {}), className, ...props }) {
|
|
181
181
|
const context = useInputContext();
|
|
@@ -42,27 +42,27 @@ export type RootProps = Omit<BaseOtp.Root.Props, 'className' | 'render'> & {
|
|
|
42
42
|
* }
|
|
43
43
|
* </OtpInput.Root>
|
|
44
44
|
*/
|
|
45
|
-
export declare
|
|
46
|
-
export declare
|
|
45
|
+
export declare function Root({ id, validation, children, ref, ...props }: RootProps): import("react").JSX.Element;
|
|
46
|
+
export declare function Input({ disableStyle, className, 'aria-describedby': describedBy, ref, ...props }: (Omit<BaseOtp.Input.Props, 'className' | 'id' | 'value' | 'defaultValue' | 'disabled' | 'readOnly' | 'required' | 'name' | 'form' | 'render'> & {
|
|
47
47
|
className?: string;
|
|
48
|
-
} & StyleProps
|
|
49
|
-
export declare
|
|
48
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
49
|
+
export declare function Container({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
50
50
|
/** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
|
|
51
|
-
export declare
|
|
52
|
-
export declare
|
|
51
|
+
export declare function Label({ disableStyle, className, id, ref, ...props }: Omit<ComponentProps<'label'>, 'htmlFor'> & StyleProps): import("react").JSX.Element;
|
|
52
|
+
export declare function Description({ disableStyle, className, id, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
53
53
|
type MessageProps = Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
|
|
54
54
|
children?: ValidationMessageChildren;
|
|
55
55
|
};
|
|
56
56
|
/** 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. */
|
|
57
|
-
export declare
|
|
57
|
+
export declare function Error({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
|
|
58
58
|
/** 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. */
|
|
59
|
-
export declare
|
|
59
|
+
export declare function Success({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
|
|
60
60
|
/** Calls children for each code slot. Render Input inside each callback; the component handles slot ordering and keyboard/paste behavior. */
|
|
61
|
-
export declare
|
|
61
|
+
export declare function List({ disableStyle, className, children, ref, ...props }: (Omit<ComponentProps<'div'>, 'children'> & {
|
|
62
62
|
/** Render an Input for each slot. Use the index for keys or separator placement; input ordering is automatic. */
|
|
63
63
|
children: (index: number) => ReactNode;
|
|
64
|
-
} & StyleProps
|
|
65
|
-
export declare
|
|
64
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
65
|
+
export declare function Separator({ disableStyle, className, ref, ...props }: (Omit<BaseOtp.Separator.Props, 'className' | 'render'> & {
|
|
66
66
|
className?: string;
|
|
67
|
-
} & StyleProps
|
|
67
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
68
68
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { OTPField as BaseOtp } from '@base-ui/react/otp-field';
|
|
3
|
-
import { Fragment, createContext,
|
|
3
|
+
import { Fragment, createContext, useContext, useEffect, useId, useState, } from 'react';
|
|
4
4
|
import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
|
|
5
5
|
/**
|
|
6
6
|
* Configure length and value on Root. Render an Input for each callback invocation from List; slot order is managed automatically. Keyboard navigation and paste distribution are built in; do not split or synchronize the code yourself.
|
|
@@ -36,7 +36,7 @@ import { readValidation, validationAttributes, validationMessageContent } from "
|
|
|
36
36
|
* }
|
|
37
37
|
* </OtpInput.Root>
|
|
38
38
|
*/
|
|
39
|
-
export
|
|
39
|
+
export function Root({ id, validation, children, ref, ...props }) {
|
|
40
40
|
const generatedId = useId();
|
|
41
41
|
const inputId = id ?? generatedId;
|
|
42
42
|
const [connections, setConnections] = useState({
|
|
@@ -45,19 +45,19 @@ export const Root = /* @__PURE__ */ forwardRef(function Root({ id, validation, c
|
|
|
45
45
|
return (_jsx(BaseOtp.Root, { ...props, id: inputId, ref: ref, "aria-labelledby": connections.labelId ?? props['aria-labelledby'], "aria-describedby": [props['aria-describedby'], ...connections.descriptionIds]
|
|
46
46
|
.filter(Boolean)
|
|
47
47
|
.join(' ') || undefined, render: (rootProps, state) => (_jsx(InputContext.Provider, { value: { ...state, inputId, connections, setConnections, validation: readValidation(validation) }, children: _jsx("div", { ...rootProps }) })), children: children }));
|
|
48
|
-
}
|
|
49
|
-
export
|
|
48
|
+
}
|
|
49
|
+
export function Input({ disableStyle, className, 'aria-describedby': describedBy, ref, ...props }) {
|
|
50
50
|
const context = useInputContext();
|
|
51
51
|
return (_jsx(BaseOtp.Input, { ...props, ref: ref, ...validationAttributes(context.validation), "aria-invalid": context.validation.state === 'error' || props['aria-invalid'] || undefined, "aria-describedby": [describedBy, ...context.connections.descriptionIds]
|
|
52
52
|
.filter(Boolean)
|
|
53
53
|
.join(' ') || undefined, "aria-labelledby": props['aria-labelledby'] ?? context.connections.labelId, "data-component": "otpinput-input", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
54
|
-
}
|
|
55
|
-
export
|
|
54
|
+
}
|
|
55
|
+
export function Container({ disableStyle, className, ref, ...props }) {
|
|
56
56
|
const attributes = usePartAttributes();
|
|
57
57
|
return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "otpinput-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
58
|
-
}
|
|
58
|
+
}
|
|
59
59
|
/** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
|
|
60
|
-
export
|
|
60
|
+
export function Label({ disableStyle, className, id, ref, ...props }) {
|
|
61
61
|
const context = useInputContext();
|
|
62
62
|
const labelId = id ?? context.inputId + '-label';
|
|
63
63
|
const attributes = usePartAttributes();
|
|
@@ -69,43 +69,43 @@ export const Label = /* @__PURE__ */ forwardRef(function Label({ disableStyle, c
|
|
|
69
69
|
}));
|
|
70
70
|
}, [labelId, context.setConnections]);
|
|
71
71
|
return (_jsx("label", { ...attributes, ...props, id: labelId, ref: ref, htmlFor: context.inputId, "data-component": "otpinput-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
72
|
-
}
|
|
73
|
-
export
|
|
72
|
+
}
|
|
73
|
+
export function Description({ disableStyle, className, id, ref, ...props }) {
|
|
74
74
|
const messageId = useMessageId(id);
|
|
75
75
|
const attributes = usePartAttributes();
|
|
76
76
|
return (_jsx("div", { ...attributes, ...props, id: messageId, ref: ref, "data-component": "otpinput-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
77
|
-
}
|
|
77
|
+
}
|
|
78
78
|
/** 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. */
|
|
79
|
-
export
|
|
79
|
+
export function Error({ children, ref, ...props }) {
|
|
80
80
|
const context = useInputContext();
|
|
81
81
|
const content = validationMessageContent(context.validation, 'error', children);
|
|
82
82
|
if (content === undefined)
|
|
83
83
|
return null;
|
|
84
84
|
return _jsx(Message, { ...props, ref: ref, role: "alert", component: "otpinput-error", children: content });
|
|
85
|
-
}
|
|
85
|
+
}
|
|
86
86
|
/** 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. */
|
|
87
|
-
export
|
|
87
|
+
export function Success({ children, ref, ...props }) {
|
|
88
88
|
const context = useInputContext();
|
|
89
89
|
const content = validationMessageContent(context.validation, 'success', children);
|
|
90
90
|
if (content === undefined)
|
|
91
91
|
return null;
|
|
92
92
|
return _jsx(Message, { ...props, ref: ref, role: "status", component: "otpinput-success", children: content });
|
|
93
|
-
}
|
|
93
|
+
}
|
|
94
94
|
// The shared body of Error and Success, mounted only while they show, so only visible messages describe the otp input
|
|
95
|
-
|
|
95
|
+
function Message({ disableStyle, className, id, component, ref, ...props }) {
|
|
96
96
|
const messageId = useMessageId(id);
|
|
97
97
|
const attributes = usePartAttributes();
|
|
98
98
|
return _jsx("div", { "aria-atomic": "true", ...attributes, ...props, id: messageId, ref: ref, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
|
|
99
|
-
}
|
|
99
|
+
}
|
|
100
100
|
/** Calls children for each code slot. Render Input inside each callback; the component handles slot ordering and keyboard/paste behavior. */
|
|
101
|
-
export
|
|
101
|
+
export function List({ disableStyle, className, children, ref, ...props }) {
|
|
102
102
|
const context = useInputContext();
|
|
103
103
|
const attributes = usePartAttributes();
|
|
104
104
|
return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "otpinput-list", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: Array.from({ length: context.length }, (_, index) => (_jsx(Fragment, { children: children(index) }, index))) }));
|
|
105
|
-
}
|
|
106
|
-
export
|
|
105
|
+
}
|
|
106
|
+
export function Separator({ disableStyle, className, ref, ...props }) {
|
|
107
107
|
return (_jsx(BaseOtp.Separator, { ...props, ref: ref, "data-component": "otpinput-separator", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
108
|
-
}
|
|
108
|
+
}
|
|
109
109
|
const InputContext = /* @__PURE__ */ createContext(null);
|
|
110
110
|
function useInputContext() {
|
|
111
111
|
const context = useContext(InputContext);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StyleProps } from '../../types/Style.ts';
|
|
2
|
-
import { Root as RadixRoot, Input as RadixInput } from '@radix-ui/react-password-toggle-field';
|
|
2
|
+
import { Root as RadixRoot, Input as RadixInput, Toggle as RadixToggle } from '@radix-ui/react-password-toggle-field';
|
|
3
3
|
import { Input as BaseInput } from '@base-ui/react/input';
|
|
4
4
|
import type { SVGIconProps } from '../../types/Icon.ts';
|
|
5
5
|
import type { ComponentProps, ComponentPropsWithRef, ReactElement } from 'react';
|
|
@@ -50,34 +50,34 @@ export declare function Root({ children, id, validation, value, defaultValue, on
|
|
|
50
50
|
export type InputProps = Omit<ComponentPropsWithRef<typeof RadixInput>, keyof Pick<RootProps, 'id' | 'name' | 'form' | 'value' | 'defaultValue' | 'onValueChange' | 'disabled' | 'readOnly' | 'required'> | 'asChild'> & {
|
|
51
51
|
className?: string;
|
|
52
52
|
} & StyleProps;
|
|
53
|
-
export declare
|
|
54
|
-
export declare
|
|
55
|
-
export declare
|
|
53
|
+
export declare function Input({ disableStyle, className, 'aria-describedby': describedBy, ref, ...props }: InputProps): import("react").JSX.Element;
|
|
54
|
+
export declare function InputGroup({ disableStyle, className, onClick, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
55
|
+
export declare function Container({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
56
56
|
/** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
|
|
57
|
-
export declare
|
|
58
|
-
export declare
|
|
57
|
+
export declare function Label({ disableStyle, className, id, ref, ...props }: Omit<ComponentProps<'label'>, 'htmlFor'> & StyleProps): import("react").JSX.Element;
|
|
58
|
+
export declare function Description({ disableStyle, className, id, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
59
59
|
type MessageProps = Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
|
|
60
60
|
children?: ValidationMessageChildren;
|
|
61
61
|
};
|
|
62
62
|
/** 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. */
|
|
63
|
-
export declare
|
|
63
|
+
export declare function Error({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
|
|
64
64
|
/** 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. */
|
|
65
|
-
export declare
|
|
66
|
-
export declare
|
|
65
|
+
export declare function Success({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
|
|
66
|
+
export declare function Addon({ disableStyle, className, variant, ref, ...props }: (ComponentProps<'div'> & {
|
|
67
67
|
/** Choose the preset appearance; this does not add action behavior. */
|
|
68
|
-
variant?:
|
|
69
|
-
} & StyleProps
|
|
70
|
-
export declare
|
|
68
|
+
variant?: 'normal' | 'emphasized';
|
|
69
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
70
|
+
export declare function AddonText({ disableStyle, className, ref, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element;
|
|
71
71
|
/** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
|
|
72
72
|
export declare function AddonIcon({ disableStyle, children, className, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
|
|
73
73
|
/** Supply the decorative icon; the wrapper forwards the relevant state and preserves its classes. */
|
|
74
74
|
children: ReactElement<ComponentProps<'svg'>>;
|
|
75
75
|
}) & StyleProps): ReactElement<import("react").SVGProps<SVGSVGElement>, string | import("react").JSXElementConstructor<any>>;
|
|
76
|
-
export declare
|
|
76
|
+
export declare function AddonButton({ disableStyle, className, disabled, type, ref, ...props }: ComponentProps<'button'> & StyleProps): import("react").JSX.Element;
|
|
77
77
|
/** Built-in icon; no children needed. Use it inside its matching control. */
|
|
78
|
-
export declare
|
|
78
|
+
export declare function AddonLoadingIcon({ disableStyle, className, strokeWidth, ref, ...props }: Omit<SVGIconProps, 'children'> & StyleProps): import("react").JSX.Element;
|
|
79
79
|
/** Toggles password visibility automatically; do not maintain another visibility state. */
|
|
80
|
-
export declare
|
|
80
|
+
export declare function AddonVisibilityButton({ disableStyle, className, disabled, id, ref, ...props }: ComponentPropsWithRef<typeof RadixToggle> & StyleProps): import("react").JSX.Element;
|
|
81
81
|
/** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
82
82
|
export declare function AddonVisibleIcon({ disableStyle, children, className, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
|
|
83
83
|
/** Omit for the supplied default icon; pass a child only to replace it. */
|
|
@@ -4,7 +4,7 @@ import { Input as BaseInput } from '@base-ui/react/input';
|
|
|
4
4
|
import { Eye, EyeOff, LoaderCircle } from "../../utils/icons.js";
|
|
5
5
|
import { useRef } from 'react';
|
|
6
6
|
import { useForwardClickToInput } from "../../utils/useForwardClickToInput.js";
|
|
7
|
-
import { cloneElement, createContext,
|
|
7
|
+
import { cloneElement, createContext, useContext, useEffect, useId, useState, } from 'react';
|
|
8
8
|
import { twMerge } from 'tailwind-merge';
|
|
9
9
|
import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
|
|
10
10
|
/**
|
|
@@ -66,7 +66,7 @@ export function Root({ children, id, validation, value, defaultValue, onValueCha
|
|
|
66
66
|
validation: readValidation(validation),
|
|
67
67
|
}, children: children }) }));
|
|
68
68
|
}
|
|
69
|
-
export
|
|
69
|
+
export function Input({ disableStyle, className, 'aria-describedby': describedBy, ref, ...props }) {
|
|
70
70
|
const context = useInputContext();
|
|
71
71
|
const inputRef = useRef(null);
|
|
72
72
|
// Resetting the internal value when the surrounding html form resets, since the control is always controlled by Root's value
|
|
@@ -96,58 +96,58 @@ export const Input = /* @__PURE__ */ forwardRef(function Input({ disableStyle, c
|
|
|
96
96
|
if (!details.isCanceled && !context.controlled)
|
|
97
97
|
context.setValueInternalState(nextValue);
|
|
98
98
|
}, "data-component": "passwordinput-input", "data-style-disabled": disableStyle ? '' : undefined, className: className }) }));
|
|
99
|
-
}
|
|
100
|
-
export
|
|
99
|
+
}
|
|
100
|
+
export function InputGroup({ disableStyle, className, onClick, ref, ...props }) {
|
|
101
101
|
const attributes = usePartAttributes();
|
|
102
102
|
const forwardClick = useForwardClickToInput('input:not([type="hidden"])', onClick);
|
|
103
103
|
return (_jsx("div", { ...attributes, ...props, ref: ref, onClick: forwardClick, "data-component": "passwordinput-inputgroup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
104
|
-
}
|
|
105
|
-
export
|
|
104
|
+
}
|
|
105
|
+
export function Container({ disableStyle, className, ref, ...props }) {
|
|
106
106
|
const attributes = usePartAttributes();
|
|
107
107
|
return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "passwordinput-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
108
|
-
}
|
|
108
|
+
}
|
|
109
109
|
/** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
|
|
110
|
-
export
|
|
110
|
+
export function Label({ disableStyle, className, id, ref, ...props }) {
|
|
111
111
|
const context = useInputContext();
|
|
112
112
|
const labelId = id ?? context.inputId + '-label';
|
|
113
113
|
const attributes = usePartAttributes();
|
|
114
114
|
return (_jsx("label", { ...attributes, ...props, id: labelId, ref: ref, htmlFor: context.inputId, "data-component": "passwordinput-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
115
|
-
}
|
|
116
|
-
export
|
|
115
|
+
}
|
|
116
|
+
export function Description({ disableStyle, className, id, ref, ...props }) {
|
|
117
117
|
const messageId = useMessageId(id);
|
|
118
118
|
const attributes = usePartAttributes();
|
|
119
119
|
return (_jsx("div", { ...attributes, ...props, id: messageId, ref: ref, "data-component": "passwordinput-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
120
|
-
}
|
|
120
|
+
}
|
|
121
121
|
/** 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. */
|
|
122
|
-
export
|
|
122
|
+
export function Error({ children, ref, ...props }) {
|
|
123
123
|
const context = useInputContext();
|
|
124
124
|
const content = validationMessageContent(context.validation, 'error', children);
|
|
125
125
|
if (content === undefined)
|
|
126
126
|
return null;
|
|
127
127
|
return _jsx(Message, { ...props, ref: ref, role: "alert", component: "passwordinput-error", children: content });
|
|
128
|
-
}
|
|
128
|
+
}
|
|
129
129
|
/** 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. */
|
|
130
|
-
export
|
|
130
|
+
export function Success({ children, ref, ...props }) {
|
|
131
131
|
const context = useInputContext();
|
|
132
132
|
const content = validationMessageContent(context.validation, 'success', children);
|
|
133
133
|
if (content === undefined)
|
|
134
134
|
return null;
|
|
135
135
|
return _jsx(Message, { ...props, ref: ref, role: "status", component: "passwordinput-success", children: content });
|
|
136
|
-
}
|
|
136
|
+
}
|
|
137
137
|
// The shared body of Error and Success, mounted only while they show, so only visible messages describe the password input
|
|
138
|
-
|
|
138
|
+
function Message({ disableStyle, className, id, component, ref, ...props }) {
|
|
139
139
|
const messageId = useMessageId(id);
|
|
140
140
|
const attributes = usePartAttributes();
|
|
141
141
|
return _jsx("div", { "aria-atomic": "true", ...attributes, ...props, id: messageId, ref: ref, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
|
|
142
|
-
}
|
|
143
|
-
export
|
|
142
|
+
}
|
|
143
|
+
export function Addon({ disableStyle, className, variant = 'normal', ref, ...props }) {
|
|
144
144
|
const attributes = usePartAttributes();
|
|
145
145
|
return (_jsx("div", { ...attributes, ...props, ref: ref, "data-variant": variant, "data-component": "passwordinput-addon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
146
|
-
}
|
|
147
|
-
export
|
|
146
|
+
}
|
|
147
|
+
export function AddonText({ disableStyle, className, ref, ...props }) {
|
|
148
148
|
const attributes = usePartAttributes();
|
|
149
149
|
return (_jsx("span", { ...attributes, ...props, ref: ref, "data-component": "passwordinput-addontext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
150
|
-
}
|
|
150
|
+
}
|
|
151
151
|
/** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
|
|
152
152
|
export function AddonIcon({ disableStyle, children, className, ...props }) {
|
|
153
153
|
const attributes = usePartAttributes();
|
|
@@ -163,22 +163,22 @@ export function AddonIcon({ disableStyle, children, className, ...props }) {
|
|
|
163
163
|
className: twMerge(children.props.className, className),
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
export
|
|
166
|
+
export function AddonButton({ disableStyle, className, disabled, type = 'button', ref, ...props }) {
|
|
167
167
|
const context = useInputContext();
|
|
168
168
|
const attributes = usePartAttributes();
|
|
169
169
|
return (_jsx("button", { ...attributes, ...props, ref: ref, type: type, disabled: disabled || context.disabled || context.readOnly, "data-component": "passwordinput-addonbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
170
|
-
}
|
|
170
|
+
}
|
|
171
171
|
/** Built-in icon; no children needed. Use it inside its matching control. */
|
|
172
|
-
export
|
|
172
|
+
export function AddonLoadingIcon({ disableStyle, className, strokeWidth = 1.5, ref, ...props }) {
|
|
173
173
|
const attributes = usePartAttributes();
|
|
174
174
|
return (_jsx(LoaderCircle, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "passwordinput-addonloadingicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
175
|
-
}
|
|
175
|
+
}
|
|
176
176
|
/** Toggles password visibility automatically; do not maintain another visibility state. */
|
|
177
|
-
export
|
|
177
|
+
export function AddonVisibilityButton({ disableStyle, className, disabled, id, ref, ...props }) {
|
|
178
178
|
const context = useInputContext();
|
|
179
179
|
const attributes = usePartAttributes();
|
|
180
180
|
return (_jsx(RadixToggle, { ...attributes, ...props, id: id ?? context.inputId + '-toggle', ref: ref, disabled: disabled || context.disabled || context.readOnly, "data-component": "passwordinput-addonvisibilitybutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
181
|
-
}
|
|
181
|
+
}
|
|
182
182
|
/** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
183
183
|
export function AddonVisibleIcon({ disableStyle, children = _jsx(EyeOff, {}), className, ...props }) {
|
|
184
184
|
const attributes = usePartAttributes();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StyleProps } from '../../types/Style.ts';
|
|
2
2
|
import type { AsChildProps } from '../../utils/asChild.ts';
|
|
3
3
|
import { Popover as BasePopover } from '@base-ui/react/popover';
|
|
4
|
-
import type { ComponentPropsWithRef, ReactElement } from 'react';
|
|
4
|
+
import type { ComponentProps, ComponentPropsWithRef, ReactElement } from 'react';
|
|
5
5
|
import type { SVGIconProps } from '../../types/Icon.ts';
|
|
6
6
|
/**
|
|
7
7
|
* OpenButton and CloseButton render their own buttons; pass asChild to give their behavior to your own button instead. Popup already includes its portal and positioner. Use Header/Body/Footer as needed; an Arrow is optional.
|
|
@@ -40,30 +40,30 @@ import type { SVGIconProps } from '../../types/Icon.ts';
|
|
|
40
40
|
*/
|
|
41
41
|
export declare function Root<Payload = unknown>(props: BasePopover.Root.Props<Payload>): import("react").JSX.Element;
|
|
42
42
|
/** Opens the popover. Pass asChild to give this behavior to your own element, like your app's Button. */
|
|
43
|
-
export declare
|
|
43
|
+
export declare function OpenButton({ asChild, disableStyle, children, ref, ...props }: Omit<BasePopover.Trigger.Props, 'className' | 'render'> & {
|
|
44
44
|
className?: string;
|
|
45
|
-
} & AsChildProps & StyleProps
|
|
46
|
-
export type PopupProps = Omit<ComponentPropsWithRef<typeof BasePopover.Popup>, 'className'> & {
|
|
45
|
+
} & AsChildProps & StyleProps): import("react").JSX.Element;
|
|
46
|
+
export type PopupProps = Omit<ComponentPropsWithRef<typeof BasePopover.Popup>, 'className' | 'render'> & {
|
|
47
47
|
className?: string;
|
|
48
48
|
} & Pick<BasePopover.Portal.Props, 'container' | 'keepMounted'> & Pick<BasePopover.Positioner.Props, 'anchor' | 'positionMethod' | 'side' | 'sideOffset' | 'align' | 'alignOffset' | 'collisionBoundary' | 'collisionPadding' | 'sticky' | 'arrowPadding' | 'disableAnchorTracking' | 'collisionAvoidance'> & StyleProps;
|
|
49
49
|
/** Already includes the portal and positioner. Keep it in the matching Root and let the native open state control visibility. */
|
|
50
50
|
export declare function Popup({ disableStyle, container, keepMounted, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, sticky, arrowPadding, disableAnchorTracking, collisionAvoidance, className, style, ...props }: PopupProps): import("react").JSX.Element;
|
|
51
|
-
export declare
|
|
52
|
-
export declare
|
|
53
|
-
export declare
|
|
54
|
-
export declare
|
|
55
|
-
export declare
|
|
51
|
+
export declare function Arrow({ disableStyle, className, style, ref, ...props }: Omit<ComponentProps<'svg'>, 'children' | 'dangerouslySetInnerHTML'> & StyleProps): import("react").JSX.Element;
|
|
52
|
+
export declare function Header({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
53
|
+
export declare function Body({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
54
|
+
export declare function Footer({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
55
|
+
export declare function Title({ disableStyle, className, ref, ...props }: (Omit<BasePopover.Title.Props, 'className' | 'render'> & {
|
|
56
56
|
className?: string;
|
|
57
|
-
} & StyleProps
|
|
58
|
-
export declare
|
|
57
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
58
|
+
export declare function Description({ disableStyle, className, ref, ...props }: (Omit<BasePopover.Description.Props, 'className' | 'render'> & {
|
|
59
59
|
className?: string;
|
|
60
|
-
} & StyleProps
|
|
60
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
61
61
|
/** Icon-only: put just a CloseButtonIcon inside, never text like "Close". Name it for screen readers with aria-label instead, e.g. aria-label="Close". Pass asChild to give closing behavior to your own button instead, like a "Done" Button. */
|
|
62
|
-
export declare
|
|
62
|
+
export declare function CloseButton({ asChild, disableStyle, children, ref, ...props }: Omit<BasePopover.Close.Props, 'className' | 'render'> & {
|
|
63
63
|
className?: string;
|
|
64
|
-
} & AsChildProps & StyleProps
|
|
64
|
+
} & AsChildProps & StyleProps): import("react").JSX.Element;
|
|
65
65
|
/** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
66
|
-
export declare
|
|
66
|
+
export declare function CloseButtonIcon({ disableStyle, children, className, ref, ...props }: (SVGIconProps & {
|
|
67
67
|
/** Omit for the supplied default icon; pass a child only to replace it. */
|
|
68
68
|
children?: ReactElement<SVGIconProps>;
|
|
69
|
-
} & StyleProps
|
|
69
|
+
}) & StyleProps): import("react").FunctionComponentElement<any>;
|