@central-ui/react 0.4.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.
@@ -0,0 +1,158 @@
1
+ import type { StyleProps } from '../../types/Style.ts';
2
+ import type { SVGIconProps } from '../../types/Icon.ts';
3
+ import type { ComponentProps, HTMLAttributes, ReactElement, ReactNode, Ref } from 'react';
4
+ /** One entry of PageList: a page to go to, or a gap standing for the pages hidden between two numbers. */
5
+ export type PageItem = {
6
+ type: 'page';
7
+ value: number;
8
+ } | {
9
+ type: 'ellipsis';
10
+ index: number;
11
+ };
12
+ export type RootProps = {
13
+ /** The total number of data items, like rows in a table; the page count is worked out from it and pageSize. */
14
+ count: number;
15
+ /** The current page, from 1. Use with onPageChange to control it yourself, like reading it from the URL search params. */
16
+ page?: number;
17
+ /**
18
+ * The page shown first, when you don't control page.
19
+ * @default 1
20
+ */
21
+ defaultPage?: number;
22
+ /** Called with the new page whenever it changes, from a click, or from count or pageSize shrinking so the current page no longer exists. */
23
+ onPageChange?: (page: number) => void;
24
+ /**
25
+ * How many data items one page holds. Together with count, it decides how many pages exist: 240 items at 20 per page make 12 pages.
26
+ * To let the user pick it, like from a "Rows per page" select, keep it in your own state and pass it here.
27
+ * @default 10
28
+ */
29
+ pageSize?: number;
30
+ /**
31
+ * How many page numbers show on each side of the current page, before a gap (…) hides the rest.
32
+ * With page 10 of 20: 1 shows "1 … 9 10 11 … 20", 2 shows "1 … 8 9 10 11 12 … 20", 0 shows "1 … 10 … 20". Lower it for narrow screens.
33
+ * @default 1
34
+ */
35
+ siblingCount?: number;
36
+ /**
37
+ * How many page numbers always show at the very start and the very end, however far the current page is from them.
38
+ * With page 10 of 20: 1 shows "1 … 9 10 11 … 20", 2 shows "1 2 … 9 10 11 … 19 20".
39
+ * @default 1
40
+ */
41
+ boundaryCount?: number;
42
+ /** The Container. */
43
+ children: ReactNode;
44
+ };
45
+ /**
46
+ * Splits a long list of items, like a table's rows, into pages and lets the user move between them.
47
+ * Root holds the page state and renders nothing itself; Container renders the row. It only tracks the page: showing that page's items is up to you, from page and pageSize.
48
+ * PageList renders a Page for every page number and gap it decides to show. First/Previous/Next/Last buttons are optional, and disable themselves on the first or last page.
49
+ * Screen readers hear English labels, like "next page" or "page 3"; to translate one, pass your own aria-label to that part.
50
+ *
51
+ * @example Complete composition
52
+ * import { Pagination } from '@central-ui/react'
53
+ *
54
+ * function Example() {
55
+ * return (
56
+ * <Pagination.Root count={240} pageSize={20}>
57
+ * <Pagination.Container>
58
+ * <Pagination.FirstButton>
59
+ * <Pagination.FirstButtonIcon />
60
+ * </Pagination.FirstButton>
61
+ * <Pagination.PreviousButton>
62
+ * <Pagination.PreviousButtonIcon />
63
+ * </Pagination.PreviousButton>
64
+ * <Pagination.PageList>{(item) => <Pagination.Page item={item} />}</Pagination.PageList>
65
+ * <Pagination.NextButton>
66
+ * <Pagination.NextButtonIcon />
67
+ * </Pagination.NextButton>
68
+ * <Pagination.LastButton>
69
+ * <Pagination.LastButtonIcon />
70
+ * </Pagination.LastButton>
71
+ * </Pagination.Container>
72
+ * </Pagination.Root>
73
+ * )
74
+ * }
75
+ *
76
+ * @example Control the page, like keeping it in the URL search params
77
+ * const { page } = Route.useSearch()
78
+ * const navigate = Route.useNavigate()
79
+ *
80
+ * ;<Pagination.Root
81
+ * count={orders.total}
82
+ * pageSize={20}
83
+ * page={page}
84
+ * onPageChange={(page) => navigate({ search: { page } })}
85
+ * >
86
+ * {
87
+ * // Rest of components here
88
+ * }
89
+ * </Pagination.Root>
90
+ *
91
+ * @example Previous and next only, without page numbers
92
+ * ;<Pagination.Root count={240} pageSize={20}>
93
+ * <Pagination.Container>
94
+ * <Pagination.PreviousButton>
95
+ * <Pagination.PreviousButtonIcon />
96
+ * </Pagination.PreviousButton>
97
+ * <Pagination.NextButton>
98
+ * <Pagination.NextButtonIcon />
99
+ * </Pagination.NextButton>
100
+ * </Pagination.Container>
101
+ * </Pagination.Root>
102
+ */
103
+ export declare function Root({ onPageChange, children, ...props }: RootProps): import("react").JSX.Element;
104
+ /** Lays out the buttons and PageList in a row. Renders a nav labeled for screen readers, no setup needed. */
105
+ export declare function Container({ disableStyle, className, ref, ...props }: ComponentProps<'nav'> & StyleProps): import("react").JSX.Element;
106
+ /**
107
+ * Renders one Page per page number and gap through its children function, which receives that entry.
108
+ * Which numbers show, and where gaps go, comes from the current page, siblingCount and boundaryCount.
109
+ *
110
+ * @example
111
+ * ;<Pagination.PageList>{(item) => <Pagination.Page item={item} />}</Pagination.PageList>
112
+ */
113
+ export declare function PageList({ disableStyle, className, children, ref, ...props }: Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
114
+ /** Called once per page number or gap; return a Page. */
115
+ children: (item: PageItem) => ReactNode;
116
+ }): import("react").JSX.Element;
117
+ /**
118
+ * Renders the item it receives from PageList: a page button going to that page on click (no click handler needed), carrying data-selected while current, or a gap.
119
+ * Shows the page number or an ellipsis icon by default. Carries data-type="page" or data-type="ellipsis", to style each its own way.
120
+ *
121
+ * @example Custom content
122
+ * ;<Pagination.PageList>
123
+ * {(item) => (
124
+ * <Pagination.Page item={item}>
125
+ * {(item) => (item.type === 'page' ? `P${item.value}` : '…')}
126
+ * </Pagination.Page>
127
+ * )}
128
+ * </Pagination.PageList>
129
+ */
130
+ export declare function Page({ item, children, disableStyle, className, ref, ...props }: Omit<HTMLAttributes<HTMLElement>, 'children'> & StyleProps & {
131
+ /** The entry received from PageList's children function. */
132
+ item: PageItem;
133
+ /** Omit for the page number, or the ellipsis icon for a gap. Pass a function only to show something else, from the item. */
134
+ children?: ReactNode | ((item: PageItem) => ReactNode);
135
+ ref?: Ref<HTMLButtonElement | HTMLDivElement>;
136
+ }): import("react").JSX.Element;
137
+ type ButtonPartProps = Omit<ComponentProps<'button'>, 'type'> & StyleProps;
138
+ /** Goes to the first page; no click handler needed. Disabled on the first page. Supply its content: normally FirstButtonIcon, optionally next to a text like "First"; it stays square with only the icon and widens for text. */
139
+ export declare function FirstButton({ disableStyle, ...props }: ButtonPartProps): import("react").JSX.Element;
140
+ /** Goes to the previous page; no click handler needed. Disabled on the first page. Supply its content: normally PreviousButtonIcon, optionally next to a text like "Previous"; it stays square with only the icon and widens for text. */
141
+ export declare function PreviousButton({ disableStyle, ...props }: ButtonPartProps): import("react").JSX.Element;
142
+ /** Goes to the next page; no click handler needed. Disabled on the last page. Supply its content: normally NextButtonIcon, optionally next to a text like "Next"; it stays square with only the icon and widens for text. */
143
+ export declare function NextButton({ disableStyle, ...props }: ButtonPartProps): import("react").JSX.Element;
144
+ /** Goes to the last page; no click handler needed. Disabled on the last page. Supply its content: normally LastButtonIcon, optionally next to a text like "Last"; it stays square with only the icon and widens for text. */
145
+ export declare function LastButton({ disableStyle, ...props }: ButtonPartProps): import("react").JSX.Element;
146
+ type BuiltInIconProps = Omit<SVGIconProps, 'children'> & StyleProps & {
147
+ /** Omit for the supplied default icon; pass a child icon only to replace it. */
148
+ children?: ReactElement<SVGIconProps>;
149
+ };
150
+ /** Built-in decorative first-page icon. Place inside FirstButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2. */
151
+ export declare function FirstButtonIcon(props: BuiltInIconProps): import("react").JSX.Element;
152
+ /** 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 2. */
153
+ export declare function PreviousButtonIcon(props: BuiltInIconProps): import("react").JSX.Element;
154
+ /** 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 2. */
155
+ export declare function NextButtonIcon(props: BuiltInIconProps): import("react").JSX.Element;
156
+ /** Built-in decorative last-page icon. Place inside LastButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2. */
157
+ export declare function LastButtonIcon(props: BuiltInIconProps): import("react").JSX.Element;
158
+ export {};
@@ -0,0 +1,157 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight, Ellipsis } from "../../utils/icons.js";
3
+ import { Pagination as ArkPagination, usePagination, usePaginationContext } from '@ark-ui/react/pagination';
4
+ import { Fragment, cloneElement } from 'react';
5
+ import { twMerge } from 'tailwind-merge';
6
+ /**
7
+ * Splits a long list of items, like a table's rows, into pages and lets the user move between them.
8
+ * Root holds the page state and renders nothing itself; Container renders the row. It only tracks the page: showing that page's items is up to you, from page and pageSize.
9
+ * PageList renders a Page for every page number and gap it decides to show. First/Previous/Next/Last buttons are optional, and disable themselves on the first or last page.
10
+ * Screen readers hear English labels, like "next page" or "page 3"; to translate one, pass your own aria-label to that part.
11
+ *
12
+ * @example Complete composition
13
+ * import { Pagination } from '@central-ui/react'
14
+ *
15
+ * function Example() {
16
+ * return (
17
+ * <Pagination.Root count={240} pageSize={20}>
18
+ * <Pagination.Container>
19
+ * <Pagination.FirstButton>
20
+ * <Pagination.FirstButtonIcon />
21
+ * </Pagination.FirstButton>
22
+ * <Pagination.PreviousButton>
23
+ * <Pagination.PreviousButtonIcon />
24
+ * </Pagination.PreviousButton>
25
+ * <Pagination.PageList>{(item) => <Pagination.Page item={item} />}</Pagination.PageList>
26
+ * <Pagination.NextButton>
27
+ * <Pagination.NextButtonIcon />
28
+ * </Pagination.NextButton>
29
+ * <Pagination.LastButton>
30
+ * <Pagination.LastButtonIcon />
31
+ * </Pagination.LastButton>
32
+ * </Pagination.Container>
33
+ * </Pagination.Root>
34
+ * )
35
+ * }
36
+ *
37
+ * @example Control the page, like keeping it in the URL search params
38
+ * const { page } = Route.useSearch()
39
+ * const navigate = Route.useNavigate()
40
+ *
41
+ * ;<Pagination.Root
42
+ * count={orders.total}
43
+ * pageSize={20}
44
+ * page={page}
45
+ * onPageChange={(page) => navigate({ search: { page } })}
46
+ * >
47
+ * {
48
+ * // Rest of components here
49
+ * }
50
+ * </Pagination.Root>
51
+ *
52
+ * @example Previous and next only, without page numbers
53
+ * ;<Pagination.Root count={240} pageSize={20}>
54
+ * <Pagination.Container>
55
+ * <Pagination.PreviousButton>
56
+ * <Pagination.PreviousButtonIcon />
57
+ * </Pagination.PreviousButton>
58
+ * <Pagination.NextButton>
59
+ * <Pagination.NextButtonIcon />
60
+ * </Pagination.NextButton>
61
+ * </Pagination.Container>
62
+ * </Pagination.Root>
63
+ */
64
+ export function Root({ onPageChange, children, ...props }) {
65
+ const pagination = usePagination({
66
+ ...props,
67
+ onPageChange: onPageChange && ((details) => onPageChange(details.page)),
68
+ });
69
+ return (_jsx(ArkPagination.RootProvider, { value: pagination, asChild: true, children: _jsx(_Fragment, { children: children }) }));
70
+ }
71
+ /** Lays out the buttons and PageList in a row. Renders a nav labeled for screen readers, no setup needed. */
72
+ export function Container({ disableStyle, className, ref, ...props }) {
73
+ const pagination = usePaginationContext();
74
+ return (_jsx("nav", { ...pagination.getRootProps(), ...props, ref: ref, "data-component": "pagination-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
75
+ }
76
+ /**
77
+ * Renders one Page per page number and gap through its children function, which receives that entry.
78
+ * Which numbers show, and where gaps go, comes from the current page, siblingCount and boundaryCount.
79
+ *
80
+ * @example
81
+ * ;<Pagination.PageList>{(item) => <Pagination.Page item={item} />}</Pagination.PageList>
82
+ */
83
+ export function PageList({ disableStyle, className, children, ref, ...props }) {
84
+ const pagination = usePaginationContext();
85
+ return (_jsx("div", { ...props, ref: ref, "data-component": "pagination-pagelist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: pagination.pages.map((page, index) => (_jsx(Fragment, { children: children(page.type === 'page' ? page : { type: 'ellipsis', index }) }, page.type === 'page' ? `page-${page.value}` : `ellipsis-${index}`))) }));
86
+ }
87
+ /**
88
+ * Renders the item it receives from PageList: a page button going to that page on click (no click handler needed), carrying data-selected while current, or a gap.
89
+ * Shows the page number or an ellipsis icon by default. Carries data-type="page" or data-type="ellipsis", to style each its own way.
90
+ *
91
+ * @example Custom content
92
+ * ;<Pagination.PageList>
93
+ * {(item) => (
94
+ * <Pagination.Page item={item}>
95
+ * {(item) => (item.type === 'page' ? `P${item.value}` : '…')}
96
+ * </Pagination.Page>
97
+ * )}
98
+ * </Pagination.PageList>
99
+ */
100
+ export function Page({ item, children, disableStyle, className, ref, ...props }) {
101
+ const content = typeof children === 'function'
102
+ ? children(item)
103
+ : (children ?? (item.type === 'page' ? item.value : _jsx(Ellipsis, { "aria-hidden": true, strokeWidth: 2, "data-component": "pagination-pageicon" })));
104
+ const attributes = {
105
+ 'data-component': 'pagination-page',
106
+ 'data-style-disabled': disableStyle ? '' : undefined,
107
+ 'data-type': item.type,
108
+ className,
109
+ };
110
+ if (item.type === 'ellipsis') {
111
+ return (_jsx(ArkPagination.Ellipsis, { ...props, ...attributes, ref: ref, index: item.index, children: content }));
112
+ }
113
+ return (_jsx(ArkPagination.Item, { ...props, ...attributes, ref: ref, type: "page", value: item.value, children: content }));
114
+ }
115
+ /** Goes to the first page; no click handler needed. Disabled on the first page. Supply its content: normally FirstButtonIcon, optionally next to a text like "First"; it stays square with only the icon and widens for text. */
116
+ export function FirstButton({ disableStyle, ...props }) {
117
+ return _jsx(ArkPagination.FirstTrigger, { ...props, "data-component": "pagination-firstbutton", "data-style-disabled": disableStyle ? '' : undefined });
118
+ }
119
+ /** Goes to the previous page; no click handler needed. Disabled on the first page. Supply its content: normally PreviousButtonIcon, optionally next to a text like "Previous"; it stays square with only the icon and widens for text. */
120
+ export function PreviousButton({ disableStyle, ...props }) {
121
+ return _jsx(ArkPagination.PrevTrigger, { ...props, "data-component": "pagination-previousbutton", "data-style-disabled": disableStyle ? '' : undefined });
122
+ }
123
+ /** Goes to the next page; no click handler needed. Disabled on the last page. Supply its content: normally NextButtonIcon, optionally next to a text like "Next"; it stays square with only the icon and widens for text. */
124
+ export function NextButton({ disableStyle, ...props }) {
125
+ return _jsx(ArkPagination.NextTrigger, { ...props, "data-component": "pagination-nextbutton", "data-style-disabled": disableStyle ? '' : undefined });
126
+ }
127
+ /** Goes to the last page; no click handler needed. Disabled on the last page. Supply its content: normally LastButtonIcon, optionally next to a text like "Last"; it stays square with only the icon and widens for text. */
128
+ export function LastButton({ disableStyle, ...props }) {
129
+ return _jsx(ArkPagination.LastTrigger, { ...props, "data-component": "pagination-lastbutton", "data-style-disabled": disableStyle ? '' : undefined });
130
+ }
131
+ /** Built-in decorative first-page icon. Place inside FirstButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2. */
132
+ export function FirstButtonIcon(props) {
133
+ return _jsx(BuiltInIcon, { ...props, icon: ChevronFirst, component: "pagination-firstbuttonicon" });
134
+ }
135
+ /** 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 2. */
136
+ export function PreviousButtonIcon(props) {
137
+ return _jsx(BuiltInIcon, { ...props, icon: ChevronLeft, component: "pagination-previousbuttonicon" });
138
+ }
139
+ /** 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 2. */
140
+ export function NextButtonIcon(props) {
141
+ return _jsx(BuiltInIcon, { ...props, icon: ChevronRight, component: "pagination-nextbuttonicon" });
142
+ }
143
+ /** Built-in decorative last-page icon. Place inside LastButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2. */
144
+ export function LastButtonIcon(props) {
145
+ return _jsx(BuiltInIcon, { ...props, icon: ChevronLast, component: "pagination-lastbuttonicon" });
146
+ }
147
+ // The shared body of the built-in decorative icons above, which only differ by their icon and component name
148
+ function BuiltInIcon({ disableStyle, className, strokeWidth, icon: Icon, component, children, ...props }) {
149
+ return cloneElement(children ?? _jsx(Icon, {}), {
150
+ 'aria-hidden': true,
151
+ ...props,
152
+ strokeWidth: strokeWidth ?? children?.props.strokeWidth ?? 2,
153
+ 'data-component': component,
154
+ 'data-style-disabled': disableStyle ? '' : undefined,
155
+ className: twMerge(children?.props.className, className),
156
+ });
157
+ }
@@ -1,71 +1,161 @@
1
1
  import type { StyleProps } from '../../types/Style.ts';
2
- import type { UseStepsProps } from '@ark-ui/react/steps';
2
+ import type { SVGIconProps } from '../../types/Icon.ts';
3
3
  import { Steps } from '@ark-ui/react/steps';
4
- export declare function useSteps(props: UseStepsProps): import("@ark-ui/react/steps").UseStepsReturn;
5
- export { useStepsContext } from '@ark-ui/react/steps';
6
- export { useStepsItemContext } from '@ark-ui/react/steps';
4
+ import type { ComponentProps, ReactElement, ReactNode, Ref } from 'react';
5
+ export type RootProps = {
6
+ /** Every step's value, in order, like ['details', 'shipping', 'review']. Each Item and Content takes one of these as its value. */
7
+ items: readonly string[];
8
+ /** The current step's value, or null once every step is done, which shows CompletedContent. Use with onValueChange to control it yourself. */
9
+ value?: string | null;
10
+ /**
11
+ * The step shown first, when you don't control value.
12
+ * @default items[0]
13
+ */
14
+ defaultValue?: string | null;
15
+ /** Called with the new step's value whenever it changes, or with null when NextButton is clicked on the last step, finishing them all. */
16
+ onValueChange?: (value: string | null) => void;
17
+ /**
18
+ * Makes the steps unclickable, so the user can only move with PreviousButton and NextButton, in order. Use it when a step needs the previous one done first, like payment after shipping.
19
+ * @default false
20
+ */
21
+ preventStepClicks?: boolean;
22
+ /** The Container. */
23
+ children: ReactNode;
24
+ };
7
25
  /**
8
- * Root owns the active step. Keep each Item in List with its index, and match Content indices to those items. NextButton/PreviousButton navigate between steps; pass asChild to give their behavior to your own buttons instead. Indicator reflects progress automatically; CompletedContent is shown after the last step.
26
+ * Splits a long task, like a checkout or an onboarding form, into steps the user goes through one by one.
27
+ * Root holds the current step and renders nothing itself. List every step's value in items, in order, then give each Item and Content one of them, like Tabs.
28
+ * Each Content holds its step's Body and Footer, and that Footer holds the step's own PreviousButton and NextButton, so every step words its buttons for itself, like "I agree" or "Place order". Never place the buttons outside a Content.
29
+ * NextButton on the last step finishes them all, showing CompletedContent. Indicator, IndicatorIcon, IndicatorText and Separator follow progress automatically.
9
30
  *
10
31
  * @example Complete composition
11
32
  * import { Button, Stepper } from '@central-ui/react'
12
33
  *
13
34
  * function Example() {
14
35
  * return (
15
- * <Stepper.Root count={2} defaultStep={0}>
16
- * <div className="flex items-start gap-4">
17
- * <Stepper.List className="w-32 shrink-0">
18
- * <Stepper.Item index={0}>
19
- * <Stepper.OpenButton>
20
- * <Stepper.Indicator />
21
- * Details
22
- * </Stepper.OpenButton>
36
+ * <Stepper.Root items={['details', 'review']}>
37
+ * <Stepper.Container>
38
+ * <Stepper.ItemsList>
39
+ * <Stepper.Item value="details">
40
+ * <Stepper.Indicator>
41
+ * <Stepper.IndicatorIcon />
42
+ * <Stepper.IndicatorText />
43
+ * </Stepper.Indicator>
44
+ * <Stepper.ItemTitle>Details</Stepper.ItemTitle>
45
+ * <Stepper.ItemDescription>Set your basics</Stepper.ItemDescription>
23
46
  * <Stepper.Separator />
24
47
  * </Stepper.Item>
25
- * <Stepper.Item index={1}>
26
- * <Stepper.OpenButton>
27
- * <Stepper.Indicator />
28
- * Review
29
- * </Stepper.OpenButton>
48
+ * <Stepper.Item value="review">
49
+ * <Stepper.Indicator>
50
+ * <Stepper.IndicatorIcon />
51
+ * <Stepper.IndicatorText />
52
+ * </Stepper.Indicator>
53
+ * <Stepper.ItemTitle>Review</Stepper.ItemTitle>
54
+ * <Stepper.ItemDescription>Check everything</Stepper.ItemDescription>
55
+ * <Stepper.Separator />
30
56
  * </Stepper.Item>
31
- * </Stepper.List>
32
- * <div className="w-full flex flex-col gap-3">
33
- * <Stepper.Content index={0}>Set your basics.</Stepper.Content>
34
- * <Stepper.Content index={1}>Check everything.</Stepper.Content>
35
- * <Stepper.CompletedContent>Done.</Stepper.CompletedContent>
36
- * <div className="flex gap-2">
37
- * <Stepper.PreviousButton>Previous</Stepper.PreviousButton>
57
+ * </Stepper.ItemsList>
58
+ * <Stepper.Content value="details">
59
+ * <Stepper.Body>Set your basics.</Stepper.Body>
60
+ * <Stepper.Footer>
61
+ * <Stepper.NextButton asChild>
62
+ * <Button.default variant="primary" size="small">
63
+ * Continue
64
+ * </Button.default>
65
+ * </Stepper.NextButton>
66
+ * </Stepper.Footer>
67
+ * </Stepper.Content>
68
+ * <Stepper.Content value="review">
69
+ * <Stepper.Body>Check everything.</Stepper.Body>
70
+ * <Stepper.Footer>
71
+ * <Stepper.PreviousButton>Back</Stepper.PreviousButton>
38
72
  * <Stepper.NextButton asChild>
39
73
  * <Button.default variant="primary" size="small">
40
- * Next
74
+ * Place order
41
75
  * </Button.default>
42
76
  * </Stepper.NextButton>
43
- * </div>
44
- * </div>
45
- * </div>
77
+ * </Stepper.Footer>
78
+ * </Stepper.Content>
79
+ * <Stepper.CompletedContent>Done.</Stepper.CompletedContent>
80
+ * </Stepper.Container>
46
81
  * </Stepper.Root>
47
82
  * )
48
83
  * }
49
84
  *
50
- * @example Show the steps horizontally
51
- * // Keep the same indexed Item and Content pairs.
52
- * ;<Stepper.Root count={2} orientation="horizontal">
85
+ * @example Control the step
86
+ * const [step, setStep] = useState<string | null>('details')
87
+ *
88
+ * ;<Stepper.Root items={['details', 'review']} value={step} onValueChange={setStep}>
53
89
  * {
54
90
  * // Rest of components here
55
91
  * }
56
92
  * </Stepper.Root>
57
93
  */
58
- export declare function Root({ children, className, orientation, ...props }: Omit<Steps.RootProps, 'asChild'>): import("react").JSX.Element;
59
- /** Moves to the next step. Pass asChild to give this behavior to your own button, like a "Continue" Button; it keeps the state data attributes but none of this part's styling. */
60
- export declare function NextButton({ asChild, disableStyle, ...props }: Steps.NextTriggerProps & StyleProps): import("react").JSX.Element;
61
- /** Moves to the previous step. Pass asChild to give this behavior to your own button, like a "Back" Button; it keeps the state data attributes but none of this part's styling. */
62
- export declare function PreviousButton({ asChild, disableStyle, ...props }: Steps.PrevTriggerProps & StyleProps): import("react").JSX.Element;
63
- export declare function List({ disableStyle, className, ...props }: Omit<Steps.ListProps, 'asChild'> & StyleProps): import("react").JSX.Element;
64
- export declare function Item({ disableStyle, className, ...props }: Omit<Steps.ItemProps, 'asChild'> & StyleProps): import("react").JSX.Element;
65
- /** 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. */
66
- export declare function Indicator({ disableStyle, className, ...props }: Omit<Steps.IndicatorProps, 'asChild' | 'children'> & StyleProps): import("react").JSX.Element;
67
- export declare function Separator({ disableStyle, className, ...props }: Omit<Steps.SeparatorProps, 'asChild'> & StyleProps): import("react").JSX.Element;
68
- export declare function Content({ disableStyle, className, ...props }: Omit<Steps.ContentProps, 'asChild'> & StyleProps): import("react").JSX.Element;
94
+ export declare function Root({ items, value, defaultValue, onValueChange, preventStepClicks, children, }: RootProps): import("react").JSX.Element;
95
+ /** Lays out ItemsList on the left of the current Content or CompletedContent. Spacing only, no look of its own. */
96
+ export declare function Container({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
97
+ /** Holds the Items; screen readers hear it as a tab list, no setup needed. */
98
+ export declare function ItemsList({ disableStyle, className, ...props }: Omit<Steps.ListProps, 'asChild'> & StyleProps): import("react").JSX.Element;
99
+ /**
100
+ * One step, as a single button opening its step on click, no click handler needed; does nothing with preventStepClicks.
101
+ * Carries data-current, data-complete or data-incomplete. Its value must be one of Root's items.
102
+ */
103
+ export declare function Item({ value, disableStyle, className, style, ...props }: Omit<Steps.TriggerProps, 'asChild'> & StyleProps & {
104
+ /** One of Root's items. */
105
+ value: string;
106
+ ref?: Ref<HTMLButtonElement>;
107
+ }): import("react").JSX.Element;
108
+ /** The circle marking the step, always shown. Holds IndicatorIcon and IndicatorText, which take turns automatically. */
109
+ export declare function Indicator({ disableStyle, className, ref, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element;
110
+ type BuiltInIconProps = Omit<SVGIconProps, 'children'> & StyleProps & {
111
+ /** Omit for the supplied default icon; pass a child icon only to replace it. */
112
+ children?: ReactElement<SVGIconProps>;
113
+ };
114
+ /** Built-in check icon, shown only once the step is done; renders nothing before. Place inside Indicator. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2.5. */
115
+ export declare function IndicatorIcon({ disableStyle, className, strokeWidth, children, ...props }: BuiltInIconProps): import("react").FunctionComponentElement<any> | null;
116
+ /** The step's number, worked out automatically; renders nothing once the step is done, leaving room for IndicatorIcon. Pass children only to show something else. Place inside Indicator. */
117
+ export declare function IndicatorText({ disableStyle, className, children, ref, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element | null;
118
+ /**
119
+ * Optional small text above ItemTitle, like a date ("Jan 2024") or "Step 1 of 3". Add it only when the steps need that extra context; leave it out otherwise.
120
+ */
121
+ export declare function ItemMeta({ disableStyle, className, ref, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element;
122
+ /** The step's name, beside the Indicator. */
123
+ export declare function ItemTitle({ disableStyle, className, ref, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element;
124
+ /** A short hint under ItemTitle, like "Select product". */
125
+ export declare function ItemDescription({ disableStyle, className, ref, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element;
126
+ /**
127
+ * The line joining a step to the next one, filled once the step is done. Renders nothing on the last step, so every Item can hold one.
128
+ *
129
+ * Changing its gap from the Indicators: the line lives inside its own Item, stretching between two distances measured from that Item's edges.
130
+ * - top: where the line starts, measured from the top of this Item. It must clear this step's Indicator, so it's the Indicator's height plus the gap you want under it.
131
+ * The preset's top-8.5 (34px) is the 26px Indicator + an 8px gap.
132
+ * - bottom: where the line ends, measured from the bottom of this Item. The next step's Indicator starts right at that edge, so bottom is exactly the gap above the next Indicator.
133
+ * The preset's bottom-1 is a 4px gap.
134
+ * Together they set the line's length: the Item's height minus top minus bottom. A taller Item, like one with a longer description, just makes a longer line with the same gaps.
135
+ * If you resize the Indicator, set top to its new height plus your gap, and left to half its width, so the line stays centered under it.
136
+ *
137
+ * @example Even 8px gaps on both ends
138
+ * // 26px Indicator + 8px gap = top-8.5; 8px gap = bottom-2
139
+ * ;<Stepper.Separator className="top-8.5 bottom-2" />
140
+ *
141
+ * @example A line touching both Indicators
142
+ * // top equals the Indicator's height; bottom is 0
143
+ * ;<Stepper.Separator className="top-6.5 bottom-0" />
144
+ */
145
+ export declare function Separator({ disableStyle, className, style, ref, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element | null;
146
+ /** Holds the step's main content, like its form fields. Place inside a Content, above its Footer. Spacing only, no look of its own. */
147
+ export declare function Body({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
148
+ /** One step's side, beside ItemsList, showing only while its step is current, no visibility condition needed. Holds the step's Body and Footer. Its value must be one of Root's items. */
149
+ export declare function Content({ value, disableStyle, className, ...props }: Omit<Steps.ContentProps, 'asChild' | 'index'> & StyleProps & {
150
+ /** One of Root's items. */
151
+ value: string;
152
+ }): import("react").JSX.Element;
153
+ /** Shows only once every step is done, after NextButton on the last step. */
69
154
  export declare function CompletedContent({ disableStyle, className, ...props }: Omit<Steps.CompletedContentProps, 'asChild'> & StyleProps): import("react").JSX.Element;
70
- /** Opens its Item's step. Pass asChild to give this behavior to your own button; it keeps the state data attributes but none of this part's styling. */
71
- export declare function OpenButton({ asChild, disableStyle, ...props }: Steps.TriggerProps & StyleProps): import("react").JSX.Element;
155
+ /** The row under the step's Body, inside its Content, holding that step's PreviousButton and NextButton directly. Leave it out of a step needing no buttons. */
156
+ export declare function Footer({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
157
+ /** Moves to the previous step, no click handler needed. Place it in a Content's Footer, never outside a Content; leave it out of the first step's Footer. Pass asChild to give this behavior to your own button, like a "Back" Button; it keeps the state data attributes but none of this part's styling. */
158
+ export declare function PreviousButton({ asChild, disableStyle, ...props }: Steps.PrevTriggerProps & StyleProps): import("react").JSX.Element;
159
+ /** Moves to the next step, no click handler needed; on the last step, it finishes them all. Place it in a Content's Footer, never outside a Content, worded for that step, like "I agree". Pass asChild to give this behavior to your own button, like a primary "Continue" Button; it keeps the state data attributes but none of this part's styling. */
160
+ export declare function NextButton({ asChild, disableStyle, ...props }: Steps.NextTriggerProps & StyleProps): import("react").JSX.Element;
161
+ export {};