@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
|
@@ -115,23 +115,23 @@ export type RootProps<T extends readonly GroupShape[], Multiple extends boolean
|
|
|
115
115
|
* </Select.Root>
|
|
116
116
|
*/
|
|
117
117
|
export declare function Root<T extends readonly GroupShape[], Multiple extends boolean | undefined = false>({ children, items, id, validation, defaultOpen, onOpenChange, ...props }: RootProps<T, Multiple>): import("react").JSX.Element;
|
|
118
|
-
export declare
|
|
119
|
-
export declare
|
|
118
|
+
export declare function Container({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
119
|
+
export declare function Label({ disableStyle, className, ref, ...props }: (Omit<BaseSelect.Label.Props, 'className' | 'render'> & {
|
|
120
120
|
className?: string;
|
|
121
|
-
} & StyleProps
|
|
121
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
122
122
|
export declare const Value: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").SelectValueProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
123
|
-
export type OpenButtonValueProps<Value extends ItemShape | ItemShape[] | null = ItemShape | ItemShape[] | null> = Omit<ComponentPropsWithRef<typeof BaseSelect.Value>, 'className' | 'children'> & {
|
|
123
|
+
export type OpenButtonValueProps<Value extends ItemShape | ItemShape[] | null = ItemShape | ItemShape[] | null> = Omit<ComponentPropsWithRef<typeof BaseSelect.Value>, 'className' | 'children' | 'render'> & {
|
|
124
124
|
className?: string;
|
|
125
125
|
/** Omit to keep the automatic formatted selection. Only for a custom display, annotate the callback with ItemType<typeof rootItems> or SelectionsType<typeof rootItems> for multiple selection, using the same items as Root. */
|
|
126
126
|
children?: ReactNode | ((value: Value) => ReactNode);
|
|
127
127
|
} & StyleProps;
|
|
128
128
|
/** Omit children to keep the built-in formatted value. Supply children only for a special display; do not format the selection yourself for the usual case. */
|
|
129
129
|
export declare function OpenButtonValue<Value extends ItemShape | ItemShape[] | null = ItemShape | ItemShape[] | null>({ disableStyle, className, ...props }: OpenButtonValueProps<Value>): import("react").JSX.Element;
|
|
130
|
-
export type ScrollAreaProps = Omit<ComponentPropsWithRef<typeof BaseSelect.List>, 'children' | 'className'> & {
|
|
130
|
+
export type ScrollAreaProps = Omit<ComponentPropsWithRef<typeof BaseSelect.List>, 'children' | 'className' | 'render'> & {
|
|
131
131
|
className?: string;
|
|
132
132
|
children?: ReactNode;
|
|
133
133
|
} & StyleProps;
|
|
134
|
-
export declare
|
|
134
|
+
export declare function ScrollArea({ disableStyle, className, ref, ...props }: ScrollAreaProps): import("react").JSX.Element;
|
|
135
135
|
export type GroupsListProps<Group extends GroupShape = GroupShape> = Omit<ComponentPropsWithRef<'div'>, 'children'> & {
|
|
136
136
|
/** Return Group with ItemsList. Manually annotate group with Select.GroupType<typeof rootItems>, using the exact items variable passed to Root. */
|
|
137
137
|
children: ReactNode | ((group: Group, index: number) => ReactNode);
|
|
@@ -145,61 +145,61 @@ export type ItemsListProps<Item extends ItemShape = ItemShape> = Omit<ComponentP
|
|
|
145
145
|
} & StyleProps;
|
|
146
146
|
/** Let this list render the surrounding group. Manually annotate its callback with Select.ItemType<typeof rootItems>, using the SAME items variable passed to Root. */
|
|
147
147
|
export declare function ItemsList<Item extends ItemShape = ItemShape>({ disableStyle, children, className, ...props }: ItemsListProps<Item>): import("react").JSX.Element;
|
|
148
|
-
export type GroupProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<typeof BaseSelect.Group>, 'className'> & {
|
|
148
|
+
export type GroupProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<typeof BaseSelect.Group>, 'className' | 'render'> & {
|
|
149
149
|
className?: string;
|
|
150
150
|
/** Prepare groups before passing items. For a flat-looking list, use one group with label: empty string and omit GroupLabel; keep Group and ItemsList. */
|
|
151
151
|
items: readonly Item[];
|
|
152
152
|
} & StyleProps;
|
|
153
153
|
export declare function Group<Item extends ItemShape = ItemShape>({ disableStyle, items, children, className, ...props }: GroupProps<Item>): import("react").JSX.Element;
|
|
154
|
-
export type ItemProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<typeof BaseSelect.Item>, 'value' | 'className'> & {
|
|
154
|
+
export type ItemProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<typeof BaseSelect.Item>, 'value' | 'className' | 'render'> & {
|
|
155
155
|
className?: string;
|
|
156
156
|
/** Pass the item from ItemsList; matching uses its value identifier, so recreated item objects still select correctly. */
|
|
157
157
|
/** Pass the item from ItemsList; matching uses its value identifier, so recreated item objects still select correctly. */
|
|
158
158
|
value: Item;
|
|
159
159
|
} & StyleProps;
|
|
160
160
|
export declare function Item<Item extends ItemShape = ItemShape>({ disableStyle, className, ...props }: ItemProps<Item>): import("react").JSX.Element;
|
|
161
|
-
export type PopupProps = Omit<ComponentPropsWithRef<typeof BaseSelect.Popup>, 'className'> & {
|
|
161
|
+
export type PopupProps = Omit<ComponentPropsWithRef<typeof BaseSelect.Popup>, 'className' | 'render'> & {
|
|
162
162
|
className?: string;
|
|
163
163
|
} & Pick<BaseSelect.Portal.Props, 'container'> & Pick<BaseSelect.Positioner.Props, 'anchor' | 'positionMethod' | 'side' | 'sideOffset' | 'align' | 'alignOffset' | 'collisionBoundary' | 'collisionPadding' | 'sticky' | 'arrowPadding' | 'disableAnchorTracking' | 'collisionAvoidance' | 'alignItemWithTrigger'> & StyleProps;
|
|
164
164
|
/** Already includes the portal and positioner. Keep it in the matching Root and let the native open state control visibility. */
|
|
165
165
|
export declare function Popup({ disableStyle, container, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, sticky, arrowPadding, disableAnchorTracking, collisionAvoidance, alignItemWithTrigger, className, style, ...props }: PopupProps): import("react").JSX.Element;
|
|
166
|
-
export declare
|
|
166
|
+
export declare function Arrow({ disableStyle, className, style, ref, ...props }: Omit<ComponentProps<'svg'>, 'children' | 'dangerouslySetInnerHTML'> & StyleProps): import("react").JSX.Element;
|
|
167
167
|
/** Opens the select. Pass asChild to make your own button the trigger instead, like a "Sort" Button. */
|
|
168
|
-
export declare
|
|
168
|
+
export declare function OpenButton({ asChild, disableStyle, children, 'aria-describedby': describedBy, ref, ...props }: Omit<BaseSelect.Trigger.Props, 'className' | 'render'> & {
|
|
169
169
|
className?: string;
|
|
170
|
-
} & AsChildProps & StyleProps
|
|
170
|
+
} & AsChildProps & StyleProps): import("react").JSX.Element;
|
|
171
171
|
/** Omit for an unlabeled/flat-looking group; keep the Group wrapper. Supply the heading only when grouping should be visible. */
|
|
172
|
-
export declare
|
|
172
|
+
export declare function GroupLabel({ disableStyle, className, ref, ...props }: (Omit<BaseSelect.GroupLabel.Props, 'className' | 'render'> & {
|
|
173
173
|
className?: string;
|
|
174
|
-
} & StyleProps
|
|
175
|
-
export declare
|
|
174
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
175
|
+
export declare function Separator({ disableStyle, className, ref, ...props }: (Omit<BaseSelect.Separator.Props, 'className' | 'render'> & {
|
|
176
176
|
className?: string;
|
|
177
|
-
} & StyleProps
|
|
178
|
-
export declare
|
|
177
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
178
|
+
export declare function ItemText({ disableStyle, className, ref, ...props }: (Omit<BaseSelect.ItemText.Props, 'className' | 'render'> & {
|
|
179
179
|
className?: string;
|
|
180
|
-
} & StyleProps
|
|
181
|
-
export declare
|
|
180
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
181
|
+
export declare function Description({ disableStyle, className, id, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
182
182
|
type MessageProps = Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
|
|
183
183
|
children?: ValidationMessageChildren;
|
|
184
184
|
};
|
|
185
185
|
/** 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. */
|
|
186
|
-
export declare
|
|
186
|
+
export declare function Error({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
|
|
187
187
|
/** 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. */
|
|
188
|
-
export declare
|
|
188
|
+
export declare function Success({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
|
|
189
189
|
/** Built-in icon. Use it inside its matching control. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 1.5. */
|
|
190
|
-
export declare
|
|
190
|
+
export declare function OpenButtonIcon({ disableStyle, className, strokeWidth, children, ref, ...props }: Omit<SVGIconProps, 'children'> & StyleProps & {
|
|
191
191
|
/** Omit for the supplied default icon; pass a child icon only to replace it. */
|
|
192
192
|
children?: ReactElement<SVGIconProps>;
|
|
193
|
-
}
|
|
193
|
+
}): import("react").FunctionComponentElement<any>;
|
|
194
194
|
/** 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. */
|
|
195
|
-
export declare
|
|
195
|
+
export declare function ItemIndicator({ disableStyle, children, keepMounted, ref, ...props }: Omit<SVGIconProps, 'children'> & Pick<BaseSelect.ItemIndicator.Props, 'keepMounted'> & {
|
|
196
196
|
/** Optional replacement SVG icon. It receives this indicator's props and ref. */
|
|
197
197
|
children?: ReactElement<SVGIconProps>;
|
|
198
|
-
} & StyleProps
|
|
199
|
-
export declare
|
|
198
|
+
} & StyleProps): import("react").JSX.Element;
|
|
199
|
+
export declare function ScrollUpArrow({ disableStyle, children, className, ref, ...props }: (Omit<BaseSelect.ScrollUpArrow.Props, 'className' | 'render'> & {
|
|
200
200
|
className?: string;
|
|
201
|
-
} & StyleProps
|
|
202
|
-
export declare
|
|
201
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
202
|
+
export declare function ScrollDownArrow({ disableStyle, children, className, ref, ...props }: (Omit<BaseSelect.ScrollDownArrow.Props, 'className' | 'render'> & {
|
|
203
203
|
className?: string;
|
|
204
|
-
} & StyleProps
|
|
204
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
205
205
|
export {};
|
|
@@ -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 { Select as BaseSelect } from '@base-ui/react/select';
|
|
4
4
|
import { Check, ChevronDown, ChevronUp, ChevronsUpDown } from "../../utils/icons.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
|
/**
|
|
@@ -114,21 +114,21 @@ export function Root({ children, items, id, validation, defaultOpen = false, onO
|
|
|
114
114
|
setDescribedByIds,
|
|
115
115
|
}, children: children }) }));
|
|
116
116
|
}
|
|
117
|
-
export
|
|
117
|
+
export function Container({ disableStyle, className, ref, ...props }) {
|
|
118
118
|
return (_jsx("div", { ...props, ref: ref, "data-component": "select-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
119
|
-
}
|
|
120
|
-
export
|
|
119
|
+
}
|
|
120
|
+
export function Label({ disableStyle, className, ref, ...props }) {
|
|
121
121
|
const attributes = usePartAttributes();
|
|
122
122
|
return (_jsx(BaseSelect.Label, { ...attributes, ...props, ref: ref, "data-component": "select-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
123
|
-
}
|
|
123
|
+
}
|
|
124
124
|
export const Value = BaseSelect.Value;
|
|
125
125
|
/** Omit children to keep the built-in formatted value. Supply children only for a special display; do not format the selection yourself for the usual case. */
|
|
126
126
|
export function OpenButtonValue({ disableStyle, className, ...props }) {
|
|
127
127
|
return (_jsx(BaseSelect.Value, { ...props, "data-component": "select-openbuttonvalue", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
128
128
|
}
|
|
129
|
-
export
|
|
129
|
+
export function ScrollArea({ disableStyle, className, ref, ...props }) {
|
|
130
130
|
return (_jsx(BaseSelect.List, { ...props, ref: ref, "data-component": "select-scrollarea", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
131
|
-
}
|
|
131
|
+
}
|
|
132
132
|
/** Let this list render the groups. Manually annotate its children callback with Select.GroupType<typeof rootItems>, using the SAME items variable passed to Root. */
|
|
133
133
|
export function GroupsList({ disableStyle, children, className, ...props }) {
|
|
134
134
|
const context = useSelectContext();
|
|
@@ -157,54 +157,54 @@ export function Popup({ disableStyle, container, anchor, positionMethod, side =
|
|
|
157
157
|
? (state) => ({ ...baseStyle, ...style(state) })
|
|
158
158
|
: { ...baseStyle, ...style } }) }) }));
|
|
159
159
|
}
|
|
160
|
-
export
|
|
160
|
+
export function Arrow({ disableStyle, className, style, ref, ...props }) {
|
|
161
161
|
return (_jsxs(BaseSelect.Arrow, { style: style, render: _jsx("svg", { ...props, ref: ref, "aria-hidden": true, width: "20", height: "10", viewBox: "0 0 20 10" }), "data-component": "select-arrow", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: [_jsx("path", { d: "M9.66437 2.60207L4.80758 6.97318C4.07308 7.63423 3.11989 8 2.13172 8H0V10H20V8H18.5349C17.5468 8 16.5936 7.63423 15.8591 6.97318L11.0023 2.60207C10.622 2.2598 10.0447 2.25979 9.66437 2.60207Z", "data-component": "select-arrow-1" }), _jsx("path", { d: "M8.99542 1.85876C9.75604 1.17425 10.9106 1.17422 11.6713 1.85878L16.5281 6.22989C17.0789 6.72568 17.7938 7.00001 18.5349 7.00001L15.89 7L11.0023 2.60207C10.622 2.2598 10.0447 2.2598 9.66436 2.60207L4.77734 7L2.13171 7.00001C2.87284 7.00001 3.58774 6.72568 4.13861 6.22989L8.99542 1.85876Z", "data-component": "select-arrow-2" }), _jsx("path", { d: "M10.3333 3.34539L5.47654 7.71648C4.55842 8.54279 3.36693 9 2.13172 9H0V8H2.13172C3.11989 8 4.07308 7.63423 4.80758 6.97318L9.66437 2.60207C10.0447 2.25979 10.622 2.2598 11.0023 2.60207L15.8591 6.97318C16.5936 7.63423 17.5468 8 18.5349 8H20V9H18.5349C17.2998 9 16.1083 8.54278 15.1901 7.71648L10.3333 3.34539Z", "data-component": "select-arrow-3" })] }));
|
|
162
|
-
}
|
|
162
|
+
}
|
|
163
163
|
/** Opens the select. Pass asChild to make your own button the trigger instead, like a "Sort" Button. */
|
|
164
|
-
export
|
|
164
|
+
export function OpenButton({ asChild, disableStyle, children, 'aria-describedby': describedBy, ref, ...props }) {
|
|
165
165
|
const context = useSelectContext();
|
|
166
166
|
const rendering = asChildRendering({ asChild, children, component: 'select-openbutton', disableStyle });
|
|
167
167
|
return _jsx(BaseSelect.Trigger, { ...validationAttributes(context.validation), "aria-invalid": context.validation.state === 'error' || props['aria-invalid'] || undefined, "aria-describedby": [describedBy, ...context.describedByIds].filter(Boolean).join(' ') || undefined, ...props, ref: ref, ...rendering });
|
|
168
|
-
}
|
|
168
|
+
}
|
|
169
169
|
/** Omit for an unlabeled/flat-looking group; keep the Group wrapper. Supply the heading only when grouping should be visible. */
|
|
170
|
-
export
|
|
170
|
+
export function GroupLabel({ disableStyle, className, ref, ...props }) {
|
|
171
171
|
return (_jsx(BaseSelect.GroupLabel, { ...props, ref: ref, "data-component": "select-grouplabel", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
172
|
-
}
|
|
173
|
-
export
|
|
172
|
+
}
|
|
173
|
+
export function Separator({ disableStyle, className, ref, ...props }) {
|
|
174
174
|
return (_jsx(BaseSelect.Separator, { ...props, ref: ref, "data-component": "select-separator", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
175
|
-
}
|
|
176
|
-
export
|
|
175
|
+
}
|
|
176
|
+
export function ItemText({ disableStyle, className, ref, ...props }) {
|
|
177
177
|
return (_jsx(BaseSelect.ItemText, { ...props, ref: ref, "data-component": "select-itemtext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
178
|
-
}
|
|
179
|
-
export
|
|
178
|
+
}
|
|
179
|
+
export function Description({ disableStyle, className, id, ref, ...props }) {
|
|
180
180
|
const describedById = useDescribedById(id);
|
|
181
181
|
const attributes = usePartAttributes();
|
|
182
182
|
return (_jsx("div", { ...attributes, ...props, id: describedById, ref: ref, "data-component": "select-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
183
|
-
}
|
|
183
|
+
}
|
|
184
184
|
/** 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. */
|
|
185
|
-
export
|
|
185
|
+
export function Error({ children, ref, ...props }) {
|
|
186
186
|
const context = useSelectContext();
|
|
187
187
|
const content = validationMessageContent(context.validation, 'error', children);
|
|
188
188
|
if (content === undefined)
|
|
189
189
|
return null;
|
|
190
190
|
return _jsx(Message, { ...props, ref: ref, role: "alert", component: "select-error", children: content });
|
|
191
|
-
}
|
|
191
|
+
}
|
|
192
192
|
/** 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. */
|
|
193
|
-
export
|
|
193
|
+
export function Success({ children, ref, ...props }) {
|
|
194
194
|
const context = useSelectContext();
|
|
195
195
|
const content = validationMessageContent(context.validation, 'success', children);
|
|
196
196
|
if (content === undefined)
|
|
197
197
|
return null;
|
|
198
198
|
return _jsx(Message, { ...props, ref: ref, role: "status", component: "select-success", children: content });
|
|
199
|
-
}
|
|
199
|
+
}
|
|
200
200
|
// The shared body of Error and Success, mounted only while they show, so only visible messages describe the select
|
|
201
|
-
|
|
201
|
+
function Message({ disableStyle, className, id, component, ref, ...props }) {
|
|
202
202
|
const describedById = useDescribedById(id);
|
|
203
203
|
const attributes = usePartAttributes();
|
|
204
204
|
return _jsx("div", { "aria-atomic": "true", ...attributes, ...props, id: describedById, ref: ref, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
|
|
205
|
-
}
|
|
205
|
+
}
|
|
206
206
|
/** Built-in icon. Use it inside its matching control. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 1.5. */
|
|
207
|
-
export
|
|
207
|
+
export function OpenButtonIcon({ disableStyle, className, strokeWidth, children, ref, ...props }) {
|
|
208
208
|
const attributes = usePartAttributes();
|
|
209
209
|
return cloneElement(children ?? _jsx(ChevronsUpDown, {}), {
|
|
210
210
|
...attributes,
|
|
@@ -216,9 +216,9 @@ export const OpenButtonIcon = /* @__PURE__ */ forwardRef(function OpenButtonIcon
|
|
|
216
216
|
'data-style-disabled': disableStyle ? '' : undefined,
|
|
217
217
|
className: twMerge(children?.props.className, className),
|
|
218
218
|
});
|
|
219
|
-
}
|
|
219
|
+
}
|
|
220
220
|
/** 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. */
|
|
221
|
-
export
|
|
221
|
+
export function ItemIndicator({ disableStyle, children, keepMounted, ref, ...props }) {
|
|
222
222
|
const iconProps = {
|
|
223
223
|
'aria-hidden': true,
|
|
224
224
|
strokeWidth: 2,
|
|
@@ -228,13 +228,13 @@ export const ItemIndicator = /* @__PURE__ */ forwardRef(function ItemIndicator({
|
|
|
228
228
|
'data-style-disabled': disableStyle ? '' : undefined,
|
|
229
229
|
};
|
|
230
230
|
return (_jsx(BaseSelect.ItemIndicator, { keepMounted: keepMounted, children: null, render: cloneElement(children ?? _jsx(Check, {}), iconProps) }));
|
|
231
|
-
}
|
|
232
|
-
export
|
|
231
|
+
}
|
|
232
|
+
export function ScrollUpArrow({ disableStyle, children, className, ref, ...props }) {
|
|
233
233
|
return (_jsx(BaseSelect.ScrollUpArrow, { ...props, ref: ref, "data-component": "select-scrolluparrow", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: children ?? (_jsx(ChevronUp, { "aria-hidden": true, "data-component": "select-scrolluparrow-1" })) }));
|
|
234
|
-
}
|
|
235
|
-
export
|
|
234
|
+
}
|
|
235
|
+
export function ScrollDownArrow({ disableStyle, children, className, ref, ...props }) {
|
|
236
236
|
return (_jsx(BaseSelect.ScrollDownArrow, { ...props, ref: ref, "data-component": "select-scrolldownarrow", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: children ?? (_jsx(ChevronDown, { "aria-hidden": true, "data-component": "select-scrolldownarrow-1" })) }));
|
|
237
|
-
}
|
|
237
|
+
}
|
|
238
238
|
const ItemsContext = /* @__PURE__ */ createContext(null);
|
|
239
239
|
function useItemsContext() {
|
|
240
240
|
const items = useContext(ItemsContext);
|
|
@@ -40,38 +40,38 @@ export type RootProps<Value extends number | readonly number[] = number | readon
|
|
|
40
40
|
* </Slider.Track>
|
|
41
41
|
*/
|
|
42
42
|
export declare function Root<Value extends number | readonly number[]>({ children, validation, ...props }: RootProps<Value>): import("react").JSX.Element;
|
|
43
|
-
export declare
|
|
44
|
-
export declare
|
|
43
|
+
export declare function Container({ disableStyle, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
44
|
+
export declare function Label({ disableStyle, className, ref, ...props }: (Omit<BaseSlider.Label.Props, 'className' | 'render'> & {
|
|
45
45
|
className?: string;
|
|
46
|
-
} & StyleProps
|
|
47
|
-
export declare
|
|
46
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
47
|
+
export declare function Value({ disableStyle, className, ref, ...props }: (Omit<BaseSlider.Value.Props, 'className' | 'render'> & {
|
|
48
48
|
className?: string;
|
|
49
|
-
} & StyleProps
|
|
50
|
-
export declare
|
|
49
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
50
|
+
export declare function TrackGroup({ disableStyle, className, ref, ...props }: (Omit<BaseSlider.Control.Props, 'className' | 'render'> & {
|
|
51
51
|
className?: string;
|
|
52
|
-
} & StyleProps
|
|
53
|
-
export declare
|
|
52
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
53
|
+
export declare function Track({ disableStyle, className, ref, ...props }: (Omit<BaseSlider.Track.Props, 'className' | 'render'> & {
|
|
54
54
|
className?: string;
|
|
55
|
-
} & StyleProps
|
|
56
|
-
export declare
|
|
55
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
56
|
+
export declare function Indicator({ disableStyle, className, ref, ...props }: (Omit<BaseSlider.Indicator.Props, 'className' | 'render'> & {
|
|
57
57
|
className?: string;
|
|
58
|
-
} & StyleProps
|
|
59
|
-
export declare
|
|
58
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
59
|
+
export declare function DragHandle({ disableStyle, className, ref, ...props }: (Omit<BaseSlider.Thumb.Props, 'className' | 'render'> & {
|
|
60
60
|
className?: string;
|
|
61
|
-
} & StyleProps
|
|
62
|
-
export declare
|
|
61
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
62
|
+
export declare function MarksList({ disableStyle, children, className, ref, ...props }: (Omit<ComponentProps<'div'>, 'children'> & {
|
|
63
63
|
children: (value: number) => ReactNode;
|
|
64
|
-
} & StyleProps
|
|
65
|
-
export declare
|
|
64
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
65
|
+
export declare function Mark({ disableStyle, value, children, className, style, ref, ...props }: (ComponentProps<'div'> & {
|
|
66
66
|
/** Place this mark at the corresponding value within Root bounds; its position is calculated automatically. */
|
|
67
67
|
value: number;
|
|
68
|
-
} & StyleProps
|
|
69
|
-
export declare
|
|
68
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
69
|
+
export declare function Description({ disableStyle, className, id, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
70
70
|
type MessageProps = Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
|
|
71
71
|
children?: ValidationMessageChildren;
|
|
72
72
|
};
|
|
73
73
|
/** 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. */
|
|
74
|
-
export declare
|
|
74
|
+
export declare function Error({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
|
|
75
75
|
/** 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. */
|
|
76
|
-
export declare
|
|
76
|
+
export declare function Success({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
|
|
77
77
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Slider as BaseSlider } from '@base-ui/react/slider';
|
|
3
3
|
import { useDirection } from '@base-ui/react/direction-provider';
|
|
4
|
-
import { Fragment as ReactFragment, createContext, useCallback,
|
|
4
|
+
import { Fragment as ReactFragment, createContext, useCallback, useContext, useEffect, useId, useState, } from 'react';
|
|
5
5
|
import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
|
|
6
6
|
/**
|
|
7
7
|
* Configure bounds and value on Root. Keep Track inside TrackGroup, then Indicator and indexed DragHandles inside Track. One handle adjusts a single value; a range needs a handle for each end. MarksList/Mark are optional labels, not interactive handles.
|
|
@@ -42,33 +42,33 @@ export function Root({ children, validation, ...props }) {
|
|
|
42
42
|
return (_jsx(SliderContext.Provider, { value: { elementProps, state, messageIds, setMessageIds, validation: readValidation(validation) }, children: _jsx(_Fragment, { children: children }) }));
|
|
43
43
|
}, children: children }));
|
|
44
44
|
}
|
|
45
|
-
export
|
|
45
|
+
export function Container({ disableStyle, ref, ...props }) {
|
|
46
46
|
const context = useSliderContext();
|
|
47
47
|
const { ref: nativeRef, ...nativeProps } = context.elementProps;
|
|
48
48
|
return (_jsx("div", { ...nativeProps, ...props, ref: useRootRef(nativeRef, ref), ...validationAttributes(context.validation), "data-component": "slider-container", "data-style-disabled": disableStyle ? '' : undefined, className: props.className }));
|
|
49
|
-
}
|
|
50
|
-
export
|
|
49
|
+
}
|
|
50
|
+
export function Label({ disableStyle, className, ref, ...props }) {
|
|
51
51
|
return (_jsx(BaseSlider.Label, { ...props, ref: ref, "data-component": "slider-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
52
|
-
}
|
|
53
|
-
export
|
|
52
|
+
}
|
|
53
|
+
export function Value({ disableStyle, className, ref, ...props }) {
|
|
54
54
|
return (_jsx(BaseSlider.Value, { ...props, ref: ref, "data-component": "slider-value", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
55
|
-
}
|
|
56
|
-
export
|
|
55
|
+
}
|
|
56
|
+
export function TrackGroup({ disableStyle, className, ref, ...props }) {
|
|
57
57
|
return (_jsx(BaseSlider.Control, { ...props, ref: ref, "data-component": "slider-trackgroup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
58
|
-
}
|
|
59
|
-
export
|
|
58
|
+
}
|
|
59
|
+
export function Track({ disableStyle, className, ref, ...props }) {
|
|
60
60
|
return (_jsx(BaseSlider.Track, { ...props, ref: ref, "data-component": "slider-track", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
61
|
-
}
|
|
62
|
-
export
|
|
61
|
+
}
|
|
62
|
+
export function Indicator({ disableStyle, className, ref, ...props }) {
|
|
63
63
|
const context = useSliderContext();
|
|
64
64
|
return (_jsx(BaseSlider.Indicator, { ...props, ref: ref, ...validationAttributes(context.validation), "data-component": "slider-indicator", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
65
|
-
}
|
|
66
|
-
export
|
|
65
|
+
}
|
|
66
|
+
export function DragHandle({ disableStyle, className, ref, ...props }) {
|
|
67
67
|
const context = useSliderContext();
|
|
68
68
|
return (_jsx(BaseSlider.Thumb, { ...props, ref: ref, "aria-invalid": context.validation.state === 'error' || props['aria-invalid'] || undefined, "aria-describedby": [props['aria-describedby'], ...context.messageIds].filter(Boolean).join(' ') ||
|
|
69
69
|
undefined, "data-component": "slider-draghandle", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
70
|
-
}
|
|
71
|
-
export
|
|
70
|
+
}
|
|
71
|
+
export function MarksList({ disableStyle, children, className, ref, ...props }) {
|
|
72
72
|
const context = useSliderContext();
|
|
73
73
|
const count = Math.floor(Number(((context.state.max - context.state.min) / context.state.step).toPrecision(15))) +
|
|
74
74
|
1;
|
|
@@ -76,8 +76,8 @@ export const MarksList = /* @__PURE__ */ forwardRef(function MarksList({ disable
|
|
|
76
76
|
const value = Number((context.state.min + index * context.state.step).toPrecision(15));
|
|
77
77
|
return _jsx(ReactFragment, { children: children(value) }, value);
|
|
78
78
|
}) }));
|
|
79
|
-
}
|
|
80
|
-
export
|
|
79
|
+
}
|
|
80
|
+
export function Mark({ disableStyle, value, children, className, style, ref, ...props }) {
|
|
81
81
|
const context = useSliderContext();
|
|
82
82
|
const direction = useDirection();
|
|
83
83
|
const percent = ((value - context.state.min) / (context.state.max - context.state.min)) * 100;
|
|
@@ -87,34 +87,34 @@ export const Mark = /* @__PURE__ */ forwardRef(function Mark({ disableStyle, val
|
|
|
87
87
|
: { insetInlineStart: percent + '%' }),
|
|
88
88
|
...style,
|
|
89
89
|
}, "data-component": "slider-mark", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: [_jsx("span", { "data-component": "slider-mark-1", "data-orientation": context.state.orientation }), children != null && (_jsx("span", { "data-orientation": context.state.orientation, "data-component": "slider-mark-2", children: children }))] }));
|
|
90
|
-
}
|
|
91
|
-
export
|
|
90
|
+
}
|
|
91
|
+
export function Description({ disableStyle, className, id, ref, ...props }) {
|
|
92
92
|
const messageId = useMessageId(id);
|
|
93
93
|
const context = useSliderContext();
|
|
94
94
|
return (_jsx("div", { ...props, ref: ref, id: messageId, "data-disabled": context.state.disabled ? '' : undefined, ...validationAttributes(context.validation), "data-component": "slider-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
95
|
-
}
|
|
95
|
+
}
|
|
96
96
|
/** 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. */
|
|
97
|
-
export
|
|
97
|
+
export function Error({ children, ref, ...props }) {
|
|
98
98
|
const context = useSliderContext();
|
|
99
99
|
const content = validationMessageContent(context.validation, 'error', children);
|
|
100
100
|
if (content === undefined)
|
|
101
101
|
return null;
|
|
102
102
|
return _jsx(Message, { ...props, ref: ref, role: "alert", component: "slider-error", children: content });
|
|
103
|
-
}
|
|
103
|
+
}
|
|
104
104
|
/** 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. */
|
|
105
|
-
export
|
|
105
|
+
export function Success({ children, ref, ...props }) {
|
|
106
106
|
const context = useSliderContext();
|
|
107
107
|
const content = validationMessageContent(context.validation, 'success', children);
|
|
108
108
|
if (content === undefined)
|
|
109
109
|
return null;
|
|
110
110
|
return _jsx(Message, { ...props, ref: ref, role: "status", component: "slider-success", children: content });
|
|
111
|
-
}
|
|
111
|
+
}
|
|
112
112
|
// The shared body of Error and Success, mounted only while they show, so only visible messages describe the slider
|
|
113
|
-
|
|
113
|
+
function Message({ disableStyle, className, id, component, ref, ...props }) {
|
|
114
114
|
const messageId = useMessageId(id);
|
|
115
115
|
const context = useSliderContext();
|
|
116
116
|
return _jsx("div", { "aria-atomic": "true", ...props, ref: ref, id: messageId, "data-disabled": context.state.disabled ? '' : undefined, ...validationAttributes(context.validation), "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
|
|
117
|
-
}
|
|
117
|
+
}
|
|
118
118
|
const SliderContext = /* @__PURE__ */ createContext(null);
|
|
119
119
|
function useSliderContext() {
|
|
120
120
|
const context = useContext(SliderContext);
|