@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { StyleProps } from '../../types/Style.ts';
|
|
2
2
|
import { Avatar as BaseAvatar } from '@base-ui/react/avatar';
|
|
3
|
+
import type { ComponentProps } from 'react';
|
|
3
4
|
export type RootProps = Omit<BaseAvatar.Root.Props, 'render' | 'className'> & {
|
|
4
5
|
/** Choose the shared size for the visible parts in this composition. */
|
|
5
6
|
size?: 'big' | 'medium' | 'small';
|
|
@@ -33,15 +34,15 @@ export type RootProps = Omit<BaseAvatar.Root.Props, 'render' | 'className'> & {
|
|
|
33
34
|
* </Avatar.List>
|
|
34
35
|
*/
|
|
35
36
|
export declare function Root({ children, size, ...props }: RootProps): import("react").JSX.Element;
|
|
36
|
-
export declare
|
|
37
|
-
export declare
|
|
37
|
+
export declare function List({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
38
|
+
export declare function Image({ disableStyle, className, ref, ...props }: (Omit<BaseAvatar.Image.Props, 'className' | 'render'> & {
|
|
38
39
|
className?: string;
|
|
39
|
-
} & StyleProps
|
|
40
|
-
export declare
|
|
40
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
41
|
+
export declare function FallbackNameInitials({ disableStyle, color, children, className, style, ref, ...props }: (Omit<BaseAvatar.Fallback.Props, 'className' | 'children' | 'render'> & {
|
|
41
42
|
className?: string;
|
|
42
43
|
/** Choose the initials background. The name-to-initials conversion is automatic. */
|
|
43
44
|
color: string;
|
|
44
45
|
/** Pass the full name; initials are derived automatically. Do not shorten it yourself. */
|
|
45
46
|
children: string;
|
|
46
|
-
} & StyleProps
|
|
47
|
-
export declare
|
|
47
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
48
|
+
export declare function FallbackImage({ disableStyle, className, delay, ref, ...props }: (ComponentProps<'img'> & Pick<BaseAvatar.Fallback.Props, 'delay'>) & 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 { Avatar as BaseAvatar } from '@base-ui/react/avatar';
|
|
3
|
-
import { createContext,
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
4
|
/**
|
|
5
5
|
* Root supplies sizing and image/fallback coordination. Image loading chooses the fallback automatically; do not implement your own image-error state. Choose initials or an image fallback.
|
|
6
6
|
*
|
|
@@ -33,14 +33,14 @@ export function Root({ children, size = 'medium', ...props }) {
|
|
|
33
33
|
// Native Root renders a span; the fragment preserves our wrapper-free Root contract.
|
|
34
34
|
return (_jsx(SizeContext.Provider, { value: size, children: _jsx(BaseAvatar.Root, { ...props, render: (rootProps) => _jsx(_Fragment, { children: rootProps.children }), children: children }) }));
|
|
35
35
|
}
|
|
36
|
-
export
|
|
36
|
+
export function List({ disableStyle, className, ref, ...props }) {
|
|
37
37
|
return (_jsx("div", { ...props, ref: ref, "data-component": "avatar-list", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
38
|
-
}
|
|
39
|
-
export
|
|
38
|
+
}
|
|
39
|
+
export function Image({ disableStyle, className, ref, ...props }) {
|
|
40
40
|
const size = useContext(SizeContext);
|
|
41
41
|
return (_jsx(BaseAvatar.Image, { ...props, ref: ref, "data-size": size, "data-component": "avatar-image", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
42
|
-
}
|
|
43
|
-
export
|
|
42
|
+
}
|
|
43
|
+
export function FallbackNameInitials({ disableStyle, color, children, className, style, ref, ...props }) {
|
|
44
44
|
const size = useContext(SizeContext);
|
|
45
45
|
return (_jsx(BaseAvatar.Fallback, { ...props, ref: ref, "data-size": size, role: "img", "aria-label": children, style: typeof style === 'function'
|
|
46
46
|
? (state) => ({ backgroundColor: color, ...style(state) })
|
|
@@ -51,10 +51,10 @@ export const FallbackNameInitials = /* @__PURE__ */ forwardRef(function Fallback
|
|
|
51
51
|
.map((word) => word[0].toUpperCase())
|
|
52
52
|
.join('')
|
|
53
53
|
.slice(0, 2) }));
|
|
54
|
-
}
|
|
55
|
-
export
|
|
54
|
+
}
|
|
55
|
+
export function FallbackImage({ disableStyle, className, delay, ref, ...props }) {
|
|
56
56
|
const size = useContext(SizeContext);
|
|
57
57
|
return (_jsx(BaseAvatar.Fallback, { delay: delay, render: _jsx("img", { ...props, ref: ref }), "data-size": size, "data-component": "avatar-fallbackimage", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
58
|
-
}
|
|
58
|
+
}
|
|
59
59
|
const SizeContext =
|
|
60
60
|
/* @__PURE__ */ createContext('medium');
|
|
@@ -104,7 +104,7 @@ export function CloseButtonIcon({ disableStyle, children = _jsx(X, {}), classNam
|
|
|
104
104
|
'data-style-disabled': disableStyle ? '' : undefined,
|
|
105
105
|
},
|
|
106
106
|
className: twMerge(children.props.className, className),
|
|
107
|
-
strokeWidth: props.strokeWidth ?? children.props.strokeWidth ??
|
|
107
|
+
strokeWidth: props.strokeWidth ?? children.props.strokeWidth ?? 2,
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
export function Body({ disableStyle, className, ...props }) {
|
|
@@ -36,6 +36,26 @@ export type RootProps = {
|
|
|
36
36
|
* @default false
|
|
37
37
|
*/
|
|
38
38
|
dragFree?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* How far a drag must move, in pixels, before it counts as a drag instead of a click on the slide's content.
|
|
41
|
+
* @default 10
|
|
42
|
+
*/
|
|
43
|
+
dragThreshold?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Whether a hard swipe may fly past several slides instead of stopping on the next one.
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
skipSnaps?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* How long a move to another slide takes, from 20 (fast) to 60 (slow). Not in milliseconds.
|
|
51
|
+
* @default 25
|
|
52
|
+
*/
|
|
53
|
+
duration?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Removes the empty space at the start and end when slides are narrower than SlidesList. 'trimSnaps' also drops the positions landing in that space, 'keepSnaps' keeps them, false keeps the space. Ignored with loop.
|
|
56
|
+
* @default 'trimSnaps'
|
|
57
|
+
*/
|
|
58
|
+
containScroll?: false | 'trimSnaps' | 'keepSnaps';
|
|
39
59
|
/**
|
|
40
60
|
* Space between slides, as a number of pixels or any CSS length. Size slides with a className on Slide, like `basis-1/3`; the gap is already subtracted from it.
|
|
41
61
|
* @default 0
|
|
@@ -115,19 +135,19 @@ export type RootProps = {
|
|
|
115
135
|
* const [index, setIndex] = useState(0)
|
|
116
136
|
* ;<Carousel.Root index={index} onIndexChange={setIndex}>
|
|
117
137
|
*/
|
|
118
|
-
export declare function Root({ orientation, loop, align, slidesToScroll, dragFree, gap, disabled, autoplay, index, defaultIndex, onIndexChange, children, }: RootProps): import("react").JSX.Element;
|
|
138
|
+
export declare function Root({ orientation, loop, align, slidesToScroll, dragFree, dragThreshold, skipSnaps, duration, containScroll, gap, disabled, autoplay, index, defaultIndex, onIndexChange, children, }: RootProps): import("react").JSX.Element;
|
|
119
139
|
/** The visible window the slides move inside, announced to screen readers as the carousel. Style it freely (background, border, radius); a vertical carousel needs a height here. Put only Slides inside. */
|
|
120
|
-
export declare
|
|
140
|
+
export declare function SlidesList({ disableStyle, style, children, ref, ...props }: ComponentProps<'div'> & StyleProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
121
141
|
/**
|
|
122
142
|
* One slide; each can hold different content. Size it with a className, like `basis-1/3`; it fills SlidesList by default.
|
|
123
143
|
* Its padding makes the gap between slides, so put backgrounds, borders and radius on its content, not on the Slide itself.
|
|
124
144
|
*/
|
|
125
|
-
export declare
|
|
145
|
+
export declare function Slide({ disableStyle, style, ref, ...props }: ComponentProps<'div'> & StyleProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
126
146
|
type ButtonPartProps = ComponentProps<'button'> & AsChildProps & StyleProps;
|
|
127
147
|
/** Moves to the previous slide; no click handler needed. Disabled when there's no slide before (never with loop). Supply its content, normally PreviousButtonIcon, and an accessible label. Pass asChild to give this behavior to your own button instead. */
|
|
128
|
-
export declare
|
|
148
|
+
export declare function PreviousButton({ ref, ...props }: ButtonPartProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
129
149
|
/** Moves to the next slide; no click handler needed. Disabled when there's no slide after (never with loop). Supply its content, normally NextButtonIcon, and an accessible label. Pass asChild to give this behavior to your own button instead. */
|
|
130
|
-
export declare
|
|
150
|
+
export declare function NextButton({ ref, ...props }: ButtonPartProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
131
151
|
/**
|
|
132
152
|
* Renders one IndicatorButton per position through its children function, which receives that position's index.
|
|
133
153
|
* The count comes from the carousel itself: with several slides per view, it counts positions, not slides.
|
|
@@ -137,10 +157,10 @@ export declare const NextButton: import("react").ForwardRefExoticComponent<Omit<
|
|
|
137
157
|
* {(index) => <Carousel.IndicatorButton index={index} />}
|
|
138
158
|
* </Carousel.IndicatorList>
|
|
139
159
|
*/
|
|
140
|
-
export declare
|
|
160
|
+
export declare function IndicatorList({ disableStyle, children, ref, ...props }: Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
|
|
141
161
|
/** Called once per position with its index; return an IndicatorButton. */
|
|
142
162
|
children: (index: number) => ReactNode;
|
|
143
|
-
},
|
|
163
|
+
}): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
144
164
|
/**
|
|
145
165
|
* Moves to its position when clicked, and carries data-selected while that position is shown. Shows as a dot when empty.
|
|
146
166
|
* Pass asChild to give this behavior to your own button instead.
|
|
@@ -154,16 +174,16 @@ export declare const IndicatorList: import("react").ForwardRefExoticComponent<Om
|
|
|
154
174
|
* )}
|
|
155
175
|
* </Carousel.IndicatorList>
|
|
156
176
|
*/
|
|
157
|
-
export declare
|
|
177
|
+
export declare function IndicatorButton({ index, ref, ...props }: ButtonPartProps & {
|
|
158
178
|
/** The position this button moves to, from IndicatorList's children function. */
|
|
159
179
|
index: number;
|
|
160
|
-
},
|
|
180
|
+
}): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
161
181
|
type BuiltInIconProps = Omit<IconProps, 'children'> & StyleProps & {
|
|
162
182
|
/** Omit for the supplied default icon; pass a child icon only to replace it. */
|
|
163
183
|
children?: ReactElement<SVGIconProps>;
|
|
164
184
|
};
|
|
165
185
|
/** Built-in decorative previous icon. Place inside PreviousButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 1.5. */
|
|
166
|
-
export declare
|
|
186
|
+
export declare function PreviousButtonIcon({ ref, ...props }: BuiltInIconProps): import("react").JSX.Element;
|
|
167
187
|
/** Built-in decorative next icon. Place inside NextButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 1.5. */
|
|
168
|
-
export declare
|
|
188
|
+
export declare function NextButtonIcon({ ref, ...props }: BuiltInIconProps): import("react").JSX.Element;
|
|
169
189
|
export {};
|
|
@@ -6,7 +6,7 @@ import { mergeProps } from '@base-ui/react/merge-props';
|
|
|
6
6
|
import { useRender } from '@base-ui/react/use-render';
|
|
7
7
|
import useEmblaCarousel from 'embla-carousel-react';
|
|
8
8
|
import Autoplay from 'embla-carousel-autoplay';
|
|
9
|
-
import { Fragment, cloneElement, createContext,
|
|
9
|
+
import { Fragment, cloneElement, createContext, useContext, useEffect, useState } from 'react';
|
|
10
10
|
import { twMerge } from 'tailwind-merge';
|
|
11
11
|
const CarouselContext = /* @__PURE__ */ createContext(null);
|
|
12
12
|
/**
|
|
@@ -56,7 +56,7 @@ const CarouselContext = /* @__PURE__ */ createContext(null);
|
|
|
56
56
|
* const [index, setIndex] = useState(0)
|
|
57
57
|
* ;<Carousel.Root index={index} onIndexChange={setIndex}>
|
|
58
58
|
*/
|
|
59
|
-
export function Root({ orientation = 'horizontal', loop = false, align = 'center', slidesToScroll = 1, dragFree = false, gap = 0, disabled = false, autoplay = false, index, defaultIndex = 0, onIndexChange, children, }) {
|
|
59
|
+
export function Root({ orientation = 'horizontal', loop = false, align = 'center', slidesToScroll = 1, dragFree = false, dragThreshold = 10, skipSnaps = false, duration = 25, containScroll = 'trimSnaps', gap = 0, disabled = false, autoplay = false, index, defaultIndex = 0, onIndexChange, children, }) {
|
|
60
60
|
const direction = useDirection();
|
|
61
61
|
// Embla reads the start only once; keeping it fixed stops a controlled index from restarting the carousel
|
|
62
62
|
const [startIndex] = useState(index ?? defaultIndex);
|
|
@@ -67,6 +67,10 @@ export function Root({ orientation = 'horizontal', loop = false, align = 'center
|
|
|
67
67
|
align,
|
|
68
68
|
slidesToScroll,
|
|
69
69
|
dragFree,
|
|
70
|
+
dragThreshold,
|
|
71
|
+
skipSnaps,
|
|
72
|
+
duration,
|
|
73
|
+
containScroll,
|
|
70
74
|
startIndex,
|
|
71
75
|
active: !disabled,
|
|
72
76
|
}, autoplay ? [Autoplay(autoplay === true ? {} : autoplay)] : []);
|
|
@@ -127,7 +131,7 @@ export function Root({ orientation = 'horizontal', loop = false, align = 'center
|
|
|
127
131
|
return _jsx(CarouselContext.Provider, { value: context, children: children });
|
|
128
132
|
}
|
|
129
133
|
/** The visible window the slides move inside, announced to screen readers as the carousel. Style it freely (background, border, radius); a vertical carousel needs a height here. Put only Slides inside. */
|
|
130
|
-
export
|
|
134
|
+
export function SlidesList({ disableStyle, style, children, ref, ...props }) {
|
|
131
135
|
const context = useCarouselContext('SlidesList');
|
|
132
136
|
const vertical = context.orientation === 'vertical';
|
|
133
137
|
// The track Embla moves; its negative margin cancels the first slide's gap
|
|
@@ -139,7 +143,7 @@ export const SlidesList = /* @__PURE__ */ forwardRef(function SlidesList({ disab
|
|
|
139
143
|
[vertical ? 'marginBlockStart' : 'marginInlineStart']: negativeLength(context.gap),
|
|
140
144
|
}, children: children }));
|
|
141
145
|
return useRender({
|
|
142
|
-
ref: [ref, context.emblaRef],
|
|
146
|
+
ref: [ref ?? null, context.emblaRef],
|
|
143
147
|
state: partState(context),
|
|
144
148
|
props: {
|
|
145
149
|
role: 'region',
|
|
@@ -151,12 +155,12 @@ export const SlidesList = /* @__PURE__ */ forwardRef(function SlidesList({ disab
|
|
|
151
155
|
children: track,
|
|
152
156
|
},
|
|
153
157
|
});
|
|
154
|
-
}
|
|
158
|
+
}
|
|
155
159
|
/**
|
|
156
160
|
* One slide; each can hold different content. Size it with a className, like `basis-1/3`; it fills SlidesList by default.
|
|
157
161
|
* Its padding makes the gap between slides, so put backgrounds, borders and radius on its content, not on the Slide itself.
|
|
158
162
|
*/
|
|
159
|
-
export
|
|
163
|
+
export function Slide({ disableStyle, style, ref, ...props }) {
|
|
160
164
|
const context = useCarouselContext('Slide');
|
|
161
165
|
const vertical = context.orientation === 'vertical';
|
|
162
166
|
return useRender({
|
|
@@ -178,25 +182,25 @@ export const Slide = /* @__PURE__ */ forwardRef(function Slide({ disableStyle, s
|
|
|
178
182
|
'data-style-disabled': disableStyle ? '' : undefined,
|
|
179
183
|
},
|
|
180
184
|
});
|
|
181
|
-
}
|
|
185
|
+
}
|
|
182
186
|
/** Moves to the previous slide; no click handler needed. Disabled when there's no slide before (never with loop). Supply its content, normally PreviousButtonIcon, and an accessible label. Pass asChild to give this behavior to your own button instead. */
|
|
183
|
-
export
|
|
187
|
+
export function PreviousButton({ ref, ...props }) {
|
|
184
188
|
const context = useCarouselContext('PreviousButton');
|
|
185
189
|
return useActionButton(props, ref, context, {
|
|
186
190
|
component: 'carousel-previousbutton',
|
|
187
191
|
disabled: context.disabled || !context.canScrollPrevious,
|
|
188
192
|
onClick: () => context.api?.scrollPrev(),
|
|
189
193
|
});
|
|
190
|
-
}
|
|
194
|
+
}
|
|
191
195
|
/** Moves to the next slide; no click handler needed. Disabled when there's no slide after (never with loop). Supply its content, normally NextButtonIcon, and an accessible label. Pass asChild to give this behavior to your own button instead. */
|
|
192
|
-
export
|
|
196
|
+
export function NextButton({ ref, ...props }) {
|
|
193
197
|
const context = useCarouselContext('NextButton');
|
|
194
198
|
return useActionButton(props, ref, context, {
|
|
195
199
|
component: 'carousel-nextbutton',
|
|
196
200
|
disabled: context.disabled || !context.canScrollNext,
|
|
197
201
|
onClick: () => context.api?.scrollNext(),
|
|
198
202
|
});
|
|
199
|
-
}
|
|
203
|
+
}
|
|
200
204
|
/**
|
|
201
205
|
* Renders one IndicatorButton per position through its children function, which receives that position's index.
|
|
202
206
|
* The count comes from the carousel itself: with several slides per view, it counts positions, not slides.
|
|
@@ -206,7 +210,7 @@ export const NextButton = /* @__PURE__ */ forwardRef(function NextButton(props,
|
|
|
206
210
|
* {(index) => <Carousel.IndicatorButton index={index} />}
|
|
207
211
|
* </Carousel.IndicatorList>
|
|
208
212
|
*/
|
|
209
|
-
export
|
|
213
|
+
export function IndicatorList({ disableStyle, children, ref, ...props }) {
|
|
210
214
|
const context = useCarouselContext('IndicatorList');
|
|
211
215
|
return useRender({
|
|
212
216
|
ref,
|
|
@@ -218,7 +222,7 @@ export const IndicatorList = /* @__PURE__ */ forwardRef(function IndicatorList({
|
|
|
218
222
|
children: Array.from({ length: context.snapCount }, (_, index) => _jsx(Fragment, { children: children(index) }, index)),
|
|
219
223
|
},
|
|
220
224
|
});
|
|
221
|
-
}
|
|
225
|
+
}
|
|
222
226
|
/**
|
|
223
227
|
* Moves to its position when clicked, and carries data-selected while that position is shown. Shows as a dot when empty.
|
|
224
228
|
* Pass asChild to give this behavior to your own button instead.
|
|
@@ -232,7 +236,7 @@ export const IndicatorList = /* @__PURE__ */ forwardRef(function IndicatorList({
|
|
|
232
236
|
* )}
|
|
233
237
|
* </Carousel.IndicatorList>
|
|
234
238
|
*/
|
|
235
|
-
export
|
|
239
|
+
export function IndicatorButton({ index, ref, ...props }) {
|
|
236
240
|
const context = useCarouselContext('IndicatorButton');
|
|
237
241
|
const selected = context.selectedIndex === index;
|
|
238
242
|
return useActionButton(props, ref, context, {
|
|
@@ -242,17 +246,17 @@ export const IndicatorButton = /* @__PURE__ */ forwardRef(function IndicatorButt
|
|
|
242
246
|
attributes: { 'aria-label': `Go to slide ${index + 1}`, 'aria-current': selected ? 'true' : undefined },
|
|
243
247
|
onClick: () => context.api?.scrollTo(index),
|
|
244
248
|
});
|
|
245
|
-
}
|
|
249
|
+
}
|
|
246
250
|
/** Built-in decorative previous icon. Place inside PreviousButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 1.5. */
|
|
247
|
-
export
|
|
251
|
+
export function PreviousButtonIcon({ ref, ...props }) {
|
|
248
252
|
return _jsx(BuiltInIcon, { ...props, ref: ref, icon: ChevronLeft, component: "carousel-previousbuttonicon" });
|
|
249
|
-
}
|
|
253
|
+
}
|
|
250
254
|
/** Built-in decorative next icon. Place inside NextButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 1.5. */
|
|
251
|
-
export
|
|
255
|
+
export function NextButtonIcon({ ref, ...props }) {
|
|
252
256
|
return _jsx(BuiltInIcon, { ...props, ref: ref, icon: ChevronRight, component: "carousel-nextbuttonicon" });
|
|
253
|
-
}
|
|
257
|
+
}
|
|
254
258
|
// The shared body of the built-in decorative icons above, which only differ by their icon and component name
|
|
255
|
-
|
|
259
|
+
function BuiltInIcon({ disableStyle, className, strokeWidth, icon: Icon, component, children, ref, ...props }) {
|
|
256
260
|
const attributes = partAttributes(useCarouselContext('Icon'));
|
|
257
261
|
return cloneElement(children ?? _jsx(Icon, {}), {
|
|
258
262
|
...attributes,
|
|
@@ -264,7 +268,7 @@ const BuiltInIcon = /* @__PURE__ */ forwardRef(function BuiltInIcon({ disableSty
|
|
|
264
268
|
'data-style-disabled': disableStyle ? '' : undefined,
|
|
265
269
|
className: twMerge(children?.props.className, className),
|
|
266
270
|
});
|
|
267
|
-
}
|
|
271
|
+
}
|
|
268
272
|
// The shared body of the action buttons: the part's own styled button, or the consumer's child with asChild
|
|
269
273
|
function useActionButton({ asChild, disableStyle, children, ...props }, ref, context, internal) {
|
|
270
274
|
return useRender({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { StyleProps } from '../../types/Style.ts';
|
|
2
2
|
import { Checkbox as BaseCheckbox } from '@base-ui/react/checkbox';
|
|
3
|
+
import { CheckboxGroup as BaseCheckboxGroup } from '@base-ui/react/checkbox-group';
|
|
3
4
|
import type { ComponentProps, ReactNode } from 'react';
|
|
4
5
|
import type { ValidationProps } from '../../types/Validation.ts';
|
|
5
6
|
import type { ValidationMessageChildren } from '../../utils/Validation.ts';
|
|
@@ -44,25 +45,25 @@ export type RootProps = Pick<BaseCheckbox.Root.Props, CoreKeys> & ValidationProp
|
|
|
44
45
|
*/
|
|
45
46
|
export declare function Root({ children, id, validation, ...coreProps }: RootProps): import("react").JSX.Element;
|
|
46
47
|
/** Optional: controls multiple checkboxes as a native array of checked values. Put individual Roots inside and give each child a value. For a select-all checkbox, use parent on its Root and provide allValues on this controlled group; Base UI derives checked and indeterminate automatically. */
|
|
47
|
-
export declare
|
|
48
|
+
export declare function CheckboxGroup({ disableStyle, className, ref, ...props }: (Omit<BaseCheckboxGroup.Props, 'className'> & {
|
|
48
49
|
className?: string;
|
|
49
|
-
} & StyleProps
|
|
50
|
-
export declare
|
|
51
|
-
export declare
|
|
50
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
51
|
+
export declare function Container({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
52
|
+
export declare function Button({ disableStyle, className, ref, ...props }: (Omit<BaseCheckbox.Root.Props, CoreKeys | 'className' | 'render' | 'nativeButton'> & {
|
|
52
53
|
className?: string;
|
|
53
|
-
} & StyleProps
|
|
54
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
54
55
|
/** 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. */
|
|
55
|
-
export declare
|
|
56
|
+
export declare function Indicator({ disableStyle, className, ref, ...props }: (Omit<BaseCheckbox.Indicator.Props, 'className' | 'children' | 'render'> & {
|
|
56
57
|
className?: string;
|
|
57
|
-
} & StyleProps
|
|
58
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
58
59
|
/** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
|
|
59
|
-
export declare
|
|
60
|
-
export declare
|
|
60
|
+
export declare function Label({ disableStyle, className, ref, ...props }: Omit<ComponentProps<'label'>, 'htmlFor'> & StyleProps): import("react").JSX.Element;
|
|
61
|
+
export declare function Description({ disableStyle, className, id, ref, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element;
|
|
61
62
|
type MessageProps = Omit<ComponentProps<'span'>, 'children'> & StyleProps & {
|
|
62
63
|
children?: ValidationMessageChildren;
|
|
63
64
|
};
|
|
64
65
|
/** 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. */
|
|
65
|
-
export declare
|
|
66
|
+
export declare function Error({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
|
|
66
67
|
/** 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. */
|
|
67
|
-
export declare
|
|
68
|
+
export declare function Success({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
|
|
68
69
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Checkbox as BaseCheckbox } from '@base-ui/react/checkbox';
|
|
3
3
|
import { CheckboxGroup as BaseCheckboxGroup } from '@base-ui/react/checkbox-group';
|
|
4
|
-
import { createContext,
|
|
4
|
+
import { createContext, useContext, useEffect, useId, useState, } from 'react';
|
|
5
5
|
import { Check, Minus } from "../../utils/icons.js";
|
|
6
6
|
import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
|
|
7
7
|
/**
|
|
@@ -62,20 +62,20 @@ export function Root({ children, id, validation, ...coreProps }) {
|
|
|
62
62
|
}, children: children }));
|
|
63
63
|
}
|
|
64
64
|
/** Optional: controls multiple checkboxes as a native array of checked values. Put individual Roots inside and give each child a value. For a select-all checkbox, use parent on its Root and provide allValues on this controlled group; Base UI derives checked and indeterminate automatically. */
|
|
65
|
-
export
|
|
65
|
+
export function CheckboxGroup({ disableStyle, className, ref, ...props }) {
|
|
66
66
|
return (_jsx(BaseCheckboxGroup, { ...props, ref: ref, "data-component": "checkbox-checkboxgroup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
67
|
-
}
|
|
68
|
-
export
|
|
67
|
+
}
|
|
68
|
+
export function Container({ disableStyle, className, ref, ...props }) {
|
|
69
69
|
return (_jsx("div", { ...props, ref: ref, "data-component": "checkbox-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
70
|
-
}
|
|
71
|
-
export
|
|
70
|
+
}
|
|
71
|
+
export function Button({ disableStyle, className, ref, ...props }) {
|
|
72
72
|
const context = useCheckboxContext();
|
|
73
73
|
return (_jsx(BaseCheckbox.Root, { ...props, ...context.coreProps, ref: ref, ...validationAttributes(context.validation), "aria-invalid": context.validation.state === 'error' || props['aria-invalid'] || undefined, "aria-describedby": [props['aria-describedby'], ...context.messageIds]
|
|
74
74
|
.filter(Boolean)
|
|
75
75
|
.join(' ') || undefined, "data-component": "checkbox-button", "data-style-disabled": disableStyle ? '' : undefined, className: className, render: (buttonProps, state) => (_jsx(CheckboxButtonSurface, { ...buttonProps, state: state })) }));
|
|
76
|
-
}
|
|
76
|
+
}
|
|
77
77
|
/** 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. */
|
|
78
|
-
export
|
|
78
|
+
export function Indicator({ disableStyle, className, ref, ...props }) {
|
|
79
79
|
return (_jsx(BaseCheckbox.Indicator, { ...props, ref: ref, "data-component": "checkbox-indicator", "data-style-disabled": disableStyle ? '' : undefined, className: className, render: (indicatorProps, state) => (_jsx("span", { ...indicatorProps, children: (() => {
|
|
80
80
|
if (state.indeterminate)
|
|
81
81
|
return _jsx(Minus, { "aria-hidden": true, strokeWidth: 3.5, "data-component": "checkbox-indicator-1" });
|
|
@@ -83,37 +83,37 @@ export const Indicator = /* @__PURE__ */ forwardRef(function Indicator({ disable
|
|
|
83
83
|
return _jsx(Check, { "aria-hidden": true, strokeWidth: 3.5, "data-component": "checkbox-indicator-2" });
|
|
84
84
|
return null;
|
|
85
85
|
})() })) }));
|
|
86
|
-
}
|
|
86
|
+
}
|
|
87
87
|
/** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
|
|
88
|
-
export
|
|
88
|
+
export function Label({ disableStyle, className, ref, ...props }) {
|
|
89
89
|
const context = useCheckboxContext();
|
|
90
90
|
return (_jsx("label", { ...usePartAttributes(), ...props, ref: ref, htmlFor: context.coreProps.id, "data-component": "checkbox-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
91
|
-
}
|
|
92
|
-
export
|
|
91
|
+
}
|
|
92
|
+
export function Description({ disableStyle, className, id, ref, ...props }) {
|
|
93
93
|
const messageId = useMessageId(id);
|
|
94
94
|
return (_jsx("span", { ...usePartAttributes(), ...props, ref: ref, id: messageId, "data-component": "checkbox-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 = useCheckboxContext();
|
|
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: "checkbox-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 = useCheckboxContext();
|
|
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: "checkbox-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 checkbox
|
|
113
|
-
|
|
113
|
+
function Message({ disableStyle, className, id, component, ref, ...props }) {
|
|
114
114
|
const messageId = useMessageId(id);
|
|
115
115
|
return _jsx("span", { "aria-atomic": "true", ...usePartAttributes(), ...props, ref: ref, id: messageId, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
|
|
116
|
-
}
|
|
116
|
+
}
|
|
117
117
|
const CheckboxContext = /* @__PURE__ */ createContext(null);
|
|
118
118
|
function useCheckboxContext() {
|
|
119
119
|
const context = useContext(CheckboxContext);
|
|
@@ -133,7 +133,7 @@ function usePartAttributes() {
|
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
135
|
// Rendered by Base UI as the checkbox element, it reports Base UI's live state back to Root's mirror
|
|
136
|
-
|
|
136
|
+
function CheckboxButtonSurface({ state, ref, ...props }) {
|
|
137
137
|
const context = useCheckboxContext();
|
|
138
138
|
useEffect(() => {
|
|
139
139
|
context.setState({
|
|
@@ -152,7 +152,7 @@ const CheckboxButtonSurface = /* @__PURE__ */ forwardRef(function CheckboxButton
|
|
|
152
152
|
context.setState,
|
|
153
153
|
]);
|
|
154
154
|
return _jsx("span", { ...props, ref: ref });
|
|
155
|
-
}
|
|
155
|
+
}
|
|
156
156
|
// Registering a message part's id in Button's aria-describedby while the part is mounted
|
|
157
157
|
function useMessageId(id) {
|
|
158
158
|
const generatedId = useId();
|