@wallarm-org/design-system 1.31.0 → 1.33.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/CodeEditor/CodeEditorRoot.d.ts +1 -1
- package/dist/components/CodeEditor/engine/SearchPanel.js +17 -3
- package/dist/components/CodeEditor/engine/completion.d.ts +3 -3
- package/dist/components/CodeEditor/engine/completion.js +142 -2
- package/dist/components/CodeEditor/engine/index.js +21 -4
- package/dist/components/Stepper/Stepper.d.ts +22 -0
- package/dist/components/Stepper/Stepper.figma.d.ts +1 -0
- package/dist/components/Stepper/Stepper.figma.js +59 -0
- package/dist/components/Stepper/Stepper.js +34 -0
- package/dist/components/Stepper/StepperContent.d.ts +16 -0
- package/dist/components/Stepper/StepperContent.js +28 -0
- package/dist/components/Stepper/StepperContext.d.ts +58 -0
- package/dist/components/Stepper/StepperContext.js +37 -0
- package/dist/components/Stepper/StepperDescription.d.ts +8 -0
- package/dist/components/Stepper/StepperDescription.js +30 -0
- package/dist/components/Stepper/StepperIndicator.d.ts +9 -0
- package/dist/components/Stepper/StepperIndicator.js +34 -0
- package/dist/components/Stepper/StepperItem.d.ts +19 -0
- package/dist/components/Stepper/StepperItem.js +48 -0
- package/dist/components/Stepper/StepperList.d.ts +12 -0
- package/dist/components/Stepper/StepperList.js +28 -0
- package/dist/components/Stepper/StepperNextTrigger.d.ts +14 -0
- package/dist/components/Stepper/StepperNextTrigger.js +28 -0
- package/dist/components/Stepper/StepperPrevTrigger.d.ts +13 -0
- package/dist/components/Stepper/StepperPrevTrigger.js +31 -0
- package/dist/components/Stepper/StepperRootProvider.d.ts +18 -0
- package/dist/components/Stepper/StepperRootProvider.js +25 -0
- package/dist/components/Stepper/StepperSeparator.d.ts +7 -0
- package/dist/components/Stepper/StepperSeparator.js +28 -0
- package/dist/components/Stepper/StepperTitle.d.ts +8 -0
- package/dist/components/Stepper/StepperTitle.js +32 -0
- package/dist/components/Stepper/StepperTrigger.d.ts +16 -0
- package/dist/components/Stepper/StepperTrigger.js +32 -0
- package/dist/components/Stepper/classes.d.ts +14 -0
- package/dist/components/Stepper/classes.js +37 -0
- package/dist/components/Stepper/constants.d.ts +22 -0
- package/dist/components/Stepper/constants.js +23 -0
- package/dist/components/Stepper/index.d.ts +15 -0
- package/dist/components/Stepper/index.js +14 -0
- package/dist/components/Stepper/takeAsChildDisabled.d.ts +11 -0
- package/dist/components/Stepper/takeAsChildDisabled.js +17 -0
- package/dist/components/Stepper/types.d.ts +11 -0
- package/dist/components/Stepper/types.js +0 -0
- package/dist/components/Stepper/useStepper.d.ts +38 -0
- package/dist/components/Stepper/useStepper.js +58 -0
- package/dist/components/Table/TableBody/TableBodyVirtualizedCore.js +1 -1
- package/dist/components/Table/TableBody/TableBodyVirtualizedWindow.js +30 -8
- package/dist/components/Table/TableInner/TableInnerWindow.js +7 -2
- package/dist/components/Table/hooks/index.d.ts +1 -0
- package/dist/components/Table/hooks/index.js +1 -0
- package/dist/components/Table/hooks/infiniteScroll/useInfiniteScroll.d.ts +4 -2
- package/dist/components/Table/hooks/infiniteScroll/useInfiniteScroll.js +6 -2
- package/dist/components/Table/hooks/infiniteScroll/useInitialAnchor.d.ts +7 -1
- package/dist/components/Table/hooks/infiniteScroll/useInitialAnchor.js +4 -3
- package/dist/components/Table/hooks/infiniteScroll/usePrependScrollAnchor.d.ts +4 -1
- package/dist/components/Table/hooks/infiniteScroll/usePrependScrollAnchor.js +13 -11
- package/dist/components/Table/hooks/infiniteScroll/useScrollEdge.d.ts +4 -1
- package/dist/components/Table/hooks/infiniteScroll/useScrollEdge.js +7 -18
- package/dist/components/Table/hooks/useWindowScrollRoot.d.ts +26 -0
- package/dist/components/Table/hooks/useWindowScrollRoot.js +62 -0
- package/dist/components/Table/lib/index.d.ts +1 -0
- package/dist/components/Table/lib/index.js +1 -0
- package/dist/components/Table/lib/scrollRoot.d.ts +24 -0
- package/dist/components/Table/lib/scrollRoot.js +22 -0
- package/dist/components/Table/types.d.ts +4 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/metadata/components.json +4104 -433
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type FC, type LiHTMLAttributes, type ReactNode, type Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId';
|
|
3
|
+
import type { StepperItemStatus } from './types';
|
|
4
|
+
export interface StepperItemProps extends LiHTMLAttributes<HTMLLIElement>, TestableProps {
|
|
5
|
+
/** 0-based position of this step. Required, like Ark's `Steps.Item`. */
|
|
6
|
+
index: number;
|
|
7
|
+
/** Status set by the page. Ignored while this item is the current step. Default `'upcoming'`. */
|
|
8
|
+
status?: StepperItemStatus;
|
|
9
|
+
/** Overrides the root `statusLabels` suffix for this item. */
|
|
10
|
+
statusLabel?: string;
|
|
11
|
+
/** `StepperTrigger`, then `StepperSeparator`. */
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
ref?: Ref<HTMLLIElement>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* One step: an `<li>` holding the step's `StepperTrigger` and its `StepperSeparator`. It resolves
|
|
17
|
+
* the rendered status (active while current, else `status`) for the parts inside it.
|
|
18
|
+
*/
|
|
19
|
+
export declare const StepperItem: FC<StepperItemProps>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { Steps, useStepsContext } from "@ark-ui/react/steps";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { TestIdProvider, useTestId } from "../../utils/testId.js";
|
|
6
|
+
import { stepperItemVariants } from "./classes.js";
|
|
7
|
+
import { ARK_ITEM_ARIA_RESET, DEFAULT_STEPPER_STATUS_LABELS } from "./constants.js";
|
|
8
|
+
import { StepperItemContext, StepperListContext, clampStep, useStepperRootContext } from "./StepperContext.js";
|
|
9
|
+
const StepperItem = ({ index, status, statusLabel, children, className, ref, 'data-testid': testIdProp, ...rest })=>{
|
|
10
|
+
const { statusLabels } = useStepperRootContext('StepperItem');
|
|
11
|
+
const inList = useContext(StepperListContext);
|
|
12
|
+
if ('production' !== process.env.NODE_ENV && !inList) console.warn('[Stepper] StepperItem must be rendered inside a StepperList: an <li> outside the <ol> loses the list semantics.');
|
|
13
|
+
const { value, count } = useStepsContext();
|
|
14
|
+
const currentStep = clampStep(value, count);
|
|
15
|
+
const current = index === currentStep;
|
|
16
|
+
if ('production' !== process.env.NODE_ENV && current && value !== currentStep) console.warn(`[Stepper] current step ${value} is out of range [0, ${count - 1}]; showing step ${currentStep}.`);
|
|
17
|
+
const testId = useTestId(`item-${index}`, testIdProp);
|
|
18
|
+
const visual = current ? 'active' : status ?? 'upcoming';
|
|
19
|
+
const context = {
|
|
20
|
+
index,
|
|
21
|
+
current,
|
|
22
|
+
last: index === count - 1,
|
|
23
|
+
status: visual,
|
|
24
|
+
statusLabel: 'completed' === visual || 'danger' === visual ? statusLabel ?? statusLabels?.[visual] ?? DEFAULT_STEPPER_STATUS_LABELS[visual] : void 0
|
|
25
|
+
};
|
|
26
|
+
return /*#__PURE__*/ jsx(Steps.Item, {
|
|
27
|
+
index: index,
|
|
28
|
+
asChild: true,
|
|
29
|
+
...ARK_ITEM_ARIA_RESET,
|
|
30
|
+
children: /*#__PURE__*/ jsx("li", {
|
|
31
|
+
...rest,
|
|
32
|
+
ref: ref,
|
|
33
|
+
"data-slot": "stepper-item",
|
|
34
|
+
"data-status": visual,
|
|
35
|
+
"data-testid": testId,
|
|
36
|
+
className: cn(stepperItemVariants(), className),
|
|
37
|
+
children: /*#__PURE__*/ jsx(StepperItemContext.Provider, {
|
|
38
|
+
value: context,
|
|
39
|
+
children: /*#__PURE__*/ jsx(TestIdProvider, {
|
|
40
|
+
value: testId,
|
|
41
|
+
children: children
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
StepperItem.displayName = 'StepperItem';
|
|
48
|
+
export { StepperItem };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FC, OlHTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId';
|
|
3
|
+
export interface StepperListProps extends OlHTMLAttributes<HTMLOListElement>, TestableProps {
|
|
4
|
+
/** `StepperItem`s, each with its `index`. */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
ref?: Ref<HTMLOListElement>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The step bar: an `<ol>` with the Figma bottom border and padding. Name it with `aria-label` or
|
|
10
|
+
* `aria-labelledby`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const StepperList: FC<StepperListProps>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Steps } from "@ark-ui/react/steps";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { useTestId } from "../../utils/testId.js";
|
|
5
|
+
import { stepperListVariants } from "./classes.js";
|
|
6
|
+
import { ARK_LIST_ARIA_RESET } from "./constants.js";
|
|
7
|
+
import { StepperListContext, useStepperRootContext } from "./StepperContext.js";
|
|
8
|
+
const StepperList = ({ children, className, ref, 'data-testid': testIdProp, ...rest })=>{
|
|
9
|
+
useStepperRootContext('StepperList');
|
|
10
|
+
const testId = useTestId('list', testIdProp);
|
|
11
|
+
return /*#__PURE__*/ jsx(Steps.List, {
|
|
12
|
+
asChild: true,
|
|
13
|
+
...ARK_LIST_ARIA_RESET,
|
|
14
|
+
children: /*#__PURE__*/ jsx("ol", {
|
|
15
|
+
...rest,
|
|
16
|
+
ref: ref,
|
|
17
|
+
"data-slot": "stepper-list",
|
|
18
|
+
"data-testid": testId,
|
|
19
|
+
className: cn(stepperListVariants(), className),
|
|
20
|
+
children: /*#__PURE__*/ jsx(StepperListContext.Provider, {
|
|
21
|
+
value: true,
|
|
22
|
+
children: children
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
StepperList.displayName = 'StepperList';
|
|
28
|
+
export { StepperList };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, FC, ReactNode, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId';
|
|
3
|
+
export interface StepperNextTriggerProps extends ButtonHTMLAttributes<HTMLButtonElement>, TestableProps {
|
|
4
|
+
/** Render the child (e.g. a `Button`) as the trigger instead of a plain `<button>`. */
|
|
5
|
+
asChild?: boolean;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
ref?: Ref<HTMLButtonElement>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Moves to the next step. Disabled on the last step, where the page renders its own submit
|
|
11
|
+
* button instead: Ark would otherwise move to its "completed" state, with no current step. A
|
|
12
|
+
* `disabled` on an `asChild` child is folded in, so the last step still disables it.
|
|
13
|
+
*/
|
|
14
|
+
export declare const StepperNextTrigger: FC<StepperNextTriggerProps>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Steps, useStepsContext } from "@ark-ui/react/steps";
|
|
3
|
+
import { useTestId } from "../../utils/testId.js";
|
|
4
|
+
import { clampStep, useStepperRootContext } from "./StepperContext.js";
|
|
5
|
+
import { takeAsChildDisabled } from "./takeAsChildDisabled.js";
|
|
6
|
+
const StepperNextTrigger = ({ asChild, children, disabled, onClick, ref, 'data-testid': testIdProp, ...rest })=>{
|
|
7
|
+
useStepperRootContext('StepperNextTrigger');
|
|
8
|
+
const { value, count } = useStepsContext();
|
|
9
|
+
const atLast = clampStep(value, count) >= count - 1;
|
|
10
|
+
const testId = useTestId('next-trigger', testIdProp);
|
|
11
|
+
const child = takeAsChildDisabled(asChild, children);
|
|
12
|
+
const handleClick = (event)=>{
|
|
13
|
+
onClick?.(event);
|
|
14
|
+
if (atLast) event.preventDefault();
|
|
15
|
+
};
|
|
16
|
+
return /*#__PURE__*/ jsx(Steps.NextTrigger, {
|
|
17
|
+
...rest,
|
|
18
|
+
asChild: asChild,
|
|
19
|
+
ref: ref,
|
|
20
|
+
disabled: atLast || disabled || child.childDisabled || void 0,
|
|
21
|
+
onClick: handleClick,
|
|
22
|
+
"data-slot": "stepper-next-trigger",
|
|
23
|
+
"data-testid": testId,
|
|
24
|
+
children: child.children
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
StepperNextTrigger.displayName = 'StepperNextTrigger';
|
|
28
|
+
export { StepperNextTrigger };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, FC, ReactNode, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId';
|
|
3
|
+
export interface StepperPrevTriggerProps extends ButtonHTMLAttributes<HTMLButtonElement>, TestableProps {
|
|
4
|
+
/** Render the child (e.g. a `Button`) as the trigger instead of a plain `<button>`. */
|
|
5
|
+
asChild?: boolean;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
ref?: Ref<HTMLButtonElement>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Moves to the previous step. Disabled on the first step. Use `asChild` with a `Button`; a
|
|
11
|
+
* `disabled` on that child is folded in, so the first step still disables it.
|
|
12
|
+
*/
|
|
13
|
+
export declare const StepperPrevTrigger: FC<StepperPrevTriggerProps>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Steps, useStepsContext } from "@ark-ui/react/steps";
|
|
3
|
+
import { useTestId } from "../../utils/testId.js";
|
|
4
|
+
import { clampStep, useStepperRootContext } from "./StepperContext.js";
|
|
5
|
+
import { takeAsChildDisabled } from "./takeAsChildDisabled.js";
|
|
6
|
+
const StepperPrevTrigger = ({ asChild, children, disabled, onClick, ref, 'data-testid': testIdProp, ...rest })=>{
|
|
7
|
+
useStepperRootContext('StepperPrevTrigger');
|
|
8
|
+
const { value, count, setStep } = useStepsContext();
|
|
9
|
+
const current = clampStep(value, count);
|
|
10
|
+
const atFirst = 0 === current;
|
|
11
|
+
const testId = useTestId('prev-trigger', testIdProp);
|
|
12
|
+
const child = takeAsChildDisabled(asChild, children);
|
|
13
|
+
const handleClick = (event)=>{
|
|
14
|
+
onClick?.(event);
|
|
15
|
+
if (event.defaultPrevented) return;
|
|
16
|
+
event.preventDefault();
|
|
17
|
+
if (!atFirst) setStep(current - 1);
|
|
18
|
+
};
|
|
19
|
+
return /*#__PURE__*/ jsx(Steps.PrevTrigger, {
|
|
20
|
+
...rest,
|
|
21
|
+
asChild: asChild,
|
|
22
|
+
ref: ref,
|
|
23
|
+
disabled: atFirst || disabled || child.childDisabled || void 0,
|
|
24
|
+
onClick: handleClick,
|
|
25
|
+
"data-slot": "stepper-prev-trigger",
|
|
26
|
+
"data-testid": testId,
|
|
27
|
+
children: child.children
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
StepperPrevTrigger.displayName = 'StepperPrevTrigger';
|
|
31
|
+
export { StepperPrevTrigger };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FC, ReactNode, Ref } from 'react';
|
|
2
|
+
import { Steps as ArkSteps } from '@ark-ui/react/steps';
|
|
3
|
+
import { type TestableProps } from '../../utils/testId';
|
|
4
|
+
import type { StepperStatusLabels } from './types';
|
|
5
|
+
import type { UseStepperReturn } from './useStepper';
|
|
6
|
+
export interface StepperRootProviderProps extends Omit<ArkSteps.RootProviderProps, 'value' | 'asChild'>, TestableProps {
|
|
7
|
+
/** The machine from `useStepper()`, so the page can drive the steps from outside. */
|
|
8
|
+
value: UseStepperReturn;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** Screen-reader-only suffixes for completed and danger steps. */
|
|
11
|
+
statusLabels?: StepperStatusLabels;
|
|
12
|
+
ref?: Ref<HTMLDivElement>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The `Stepper` root for a machine created with `useStepper()`: the same parts, with the step
|
|
16
|
+
* state owned by the page (e.g. to move steps from a header action).
|
|
17
|
+
*/
|
|
18
|
+
export declare const StepperRootProvider: FC<StepperRootProviderProps>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Steps } from "@ark-ui/react/steps";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { TestIdProvider } from "../../utils/testId.js";
|
|
5
|
+
import { stepperVariants } from "./classes.js";
|
|
6
|
+
import { StepperRootContext } from "./StepperContext.js";
|
|
7
|
+
const StepperRootProvider = ({ value, children, statusLabels, className, ref, 'data-testid': testId, ...rest })=>/*#__PURE__*/ jsx(Steps.RootProvider, {
|
|
8
|
+
...rest,
|
|
9
|
+
value: value,
|
|
10
|
+
ref: ref,
|
|
11
|
+
"data-slot": "stepper",
|
|
12
|
+
"data-testid": testId,
|
|
13
|
+
className: cn(stepperVariants(), className),
|
|
14
|
+
children: /*#__PURE__*/ jsx(TestIdProvider, {
|
|
15
|
+
value: testId,
|
|
16
|
+
children: /*#__PURE__*/ jsx(StepperRootContext.Provider, {
|
|
17
|
+
value: {
|
|
18
|
+
statusLabels
|
|
19
|
+
},
|
|
20
|
+
children: children
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
StepperRootProvider.displayName = 'StepperRootProvider';
|
|
25
|
+
export { StepperRootProvider };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId';
|
|
3
|
+
export interface StepperSeparatorProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'>, TestableProps {
|
|
4
|
+
ref?: Ref<HTMLSpanElement>;
|
|
5
|
+
}
|
|
6
|
+
/** The line after a step, on its first row. Decorative, and renders nothing on the last step. */
|
|
7
|
+
export declare const StepperSeparator: FC<StepperSeparatorProps>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Steps } from "@ark-ui/react/steps";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { useTestId } from "../../utils/testId.js";
|
|
5
|
+
import { stepperSeparatorLineClassNames, stepperSeparatorVariants } from "./classes.js";
|
|
6
|
+
import { useStepperItemContext } from "./StepperContext.js";
|
|
7
|
+
const StepperSeparator = ({ className, ref, 'data-testid': testIdProp, ...rest })=>{
|
|
8
|
+
const { last, status } = useStepperItemContext();
|
|
9
|
+
const testId = useTestId('separator', testIdProp);
|
|
10
|
+
if (last) return null;
|
|
11
|
+
return /*#__PURE__*/ jsx(Steps.Separator, {
|
|
12
|
+
asChild: true,
|
|
13
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
14
|
+
...rest,
|
|
15
|
+
ref: ref,
|
|
16
|
+
"aria-hidden": "true",
|
|
17
|
+
"data-slot": "stepper-separator",
|
|
18
|
+
"data-status": status,
|
|
19
|
+
"data-testid": testId,
|
|
20
|
+
className: cn(stepperSeparatorVariants(), className),
|
|
21
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
22
|
+
className: stepperSeparatorLineClassNames
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
StepperSeparator.displayName = 'StepperSeparator';
|
|
28
|
+
export { StepperSeparator };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId';
|
|
3
|
+
export interface StepperTitleProps extends HTMLAttributes<HTMLSpanElement>, TestableProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
ref?: Ref<HTMLSpanElement>;
|
|
6
|
+
}
|
|
7
|
+
/** The step name: one line, ellipsis at 320px, with the full text in a tooltip when it overflows. */
|
|
8
|
+
export declare const StepperTitle: FC<StepperTitleProps>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { useTestId } from "../../utils/testId.js";
|
|
4
|
+
import { OverflowTooltip, OverflowTooltipContent, OverflowTooltipTrigger } from "../OverflowTooltip/index.js";
|
|
5
|
+
import { stepperTitleVariants } from "./classes.js";
|
|
6
|
+
import { useStepperItemContext } from "./StepperContext.js";
|
|
7
|
+
const StepperTitle = ({ children, className, ref, 'data-testid': testIdProp, ...rest })=>{
|
|
8
|
+
const { status } = useStepperItemContext();
|
|
9
|
+
const testId = useTestId('title', testIdProp);
|
|
10
|
+
return /*#__PURE__*/ jsxs(OverflowTooltip, {
|
|
11
|
+
children: [
|
|
12
|
+
/*#__PURE__*/ jsx(OverflowTooltipTrigger, {
|
|
13
|
+
ref: ref,
|
|
14
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
15
|
+
...rest,
|
|
16
|
+
"data-slot": "stepper-title",
|
|
17
|
+
"data-status": status,
|
|
18
|
+
"data-testid": testId,
|
|
19
|
+
className: cn(stepperTitleVariants({
|
|
20
|
+
status
|
|
21
|
+
}), className),
|
|
22
|
+
children: children
|
|
23
|
+
})
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ jsx(OverflowTooltipContent, {
|
|
26
|
+
children: children
|
|
27
|
+
})
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
StepperTitle.displayName = 'StepperTitle';
|
|
32
|
+
export { StepperTitle };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, FC, ReactNode, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId';
|
|
3
|
+
export interface StepperTriggerProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'>, TestableProps {
|
|
4
|
+
/** `StepperIndicator`, `StepperTitle` and an optional `StepperDescription`. */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
ref?: Ref<HTMLButtonElement>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The step's button: a click makes the step current. Carries `aria-current="step"` while
|
|
10
|
+
* current, a screen-reader-only status suffix (", Completed" / ", Has errors") and every
|
|
11
|
+
* consumer attribute, so analytics land on the real `<button>`.
|
|
12
|
+
*
|
|
13
|
+
* Set its `id` with the root `ids.triggerId` prop: `StepperContent` is named by the root's trigger
|
|
14
|
+
* id, so an `id` passed here leaves the body's `aria-labelledby` pointing at nothing.
|
|
15
|
+
*/
|
|
16
|
+
export declare const StepperTrigger: FC<StepperTriggerProps>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Steps } from "@ark-ui/react/steps";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { useTestId } from "../../utils/testId.js";
|
|
5
|
+
import { stepperTriggerVariants } from "./classes.js";
|
|
6
|
+
import { ARK_TAB_ARIA_RESET } from "./constants.js";
|
|
7
|
+
import { useStepperItemContext } from "./StepperContext.js";
|
|
8
|
+
const StepperTrigger = ({ children, className, ref, 'data-testid': testIdProp, ...rest })=>{
|
|
9
|
+
const { current, status, statusLabel } = useStepperItemContext();
|
|
10
|
+
const testId = useTestId('trigger', testIdProp);
|
|
11
|
+
if ('production' !== process.env.NODE_ENV && void 0 !== rest.id) console.warn(`[Stepper] id="${rest.id}" on StepperTrigger: set trigger ids with the root \`ids.triggerId\` prop, or StepperContent's aria-labelledby points at nothing.`);
|
|
12
|
+
return /*#__PURE__*/ jsxs(Steps.Trigger, {
|
|
13
|
+
...ARK_TAB_ARIA_RESET,
|
|
14
|
+
"aria-current": current ? 'step' : void 0,
|
|
15
|
+
...rest,
|
|
16
|
+
ref: ref,
|
|
17
|
+
type: "button",
|
|
18
|
+
"data-slot": "stepper-trigger",
|
|
19
|
+
"data-status": status,
|
|
20
|
+
"data-testid": testId,
|
|
21
|
+
className: cn(stepperTriggerVariants(), className),
|
|
22
|
+
children: [
|
|
23
|
+
children,
|
|
24
|
+
statusLabel && /*#__PURE__*/ jsx("span", {
|
|
25
|
+
className: "sr-only",
|
|
26
|
+
children: `, ${statusLabel}`
|
|
27
|
+
})
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
StepperTrigger.displayName = 'StepperTrigger';
|
|
32
|
+
export { StepperTrigger };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const stepperVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
2
|
+
export declare const stepperListVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
3
|
+
export declare const stepperItemVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
4
|
+
export declare const stepperTriggerVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
5
|
+
export declare const stepperIndicatorVariants: (props?: ({
|
|
6
|
+
status?: "active" | "completed" | "danger" | "upcoming" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
export declare const stepperTitleVariants: (props?: ({
|
|
9
|
+
status?: "active" | "completed" | "danger" | "upcoming" | null | undefined;
|
|
10
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
|
+
export declare const stepperDescriptionVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
12
|
+
export declare const stepperSeparatorVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
13
|
+
export declare const stepperSeparatorLineClassNames = "block h-px w-full bg-border-primary";
|
|
14
|
+
export declare const stepperContentVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
const stepperVariants = cva('min-w-0');
|
|
4
|
+
const stepperListVariants = cva('m-0 flex min-w-0 list-none items-start border-b-1 border-border-primary-light px-24 py-8');
|
|
5
|
+
const stepperItemVariants = cva('flex min-w-0 items-start');
|
|
6
|
+
const stepperTriggerVariants = cva(cn('grid min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)] grid-rows-[20px] items-start gap-x-4 bg-transparent p-0 text-left', 'rounded-6 focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-focus-primary'));
|
|
7
|
+
const stepperIndicatorVariants = cva("col-start-1 row-span-2 row-start-1 inline-flex h-20 min-w-16 shrink-0 items-center justify-center rounded-full font-mono font-medium text-xs [font-feature-settings:'liga'_0]", {
|
|
8
|
+
variants: {
|
|
9
|
+
status: {
|
|
10
|
+
active: 'bg-states-brand-active px-4 py-2 text-text-brand',
|
|
11
|
+
danger: 'bg-states-danger-active px-4 py-2 text-text-danger',
|
|
12
|
+
completed: 'bg-states-primary-active px-2 py-2 text-icon-primary',
|
|
13
|
+
upcoming: 'border-1 border-border-primary bg-component-outline-button-bg px-3 py-1 text-text-primary'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
status: 'upcoming'
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const stepperTitleVariants = cva('col-start-2 row-start-1 block min-w-0 max-w-320 truncate font-sans font-normal text-sm', {
|
|
21
|
+
variants: {
|
|
22
|
+
status: {
|
|
23
|
+
active: 'text-text-brand',
|
|
24
|
+
danger: 'text-text-danger',
|
|
25
|
+
completed: 'text-text-primary',
|
|
26
|
+
upcoming: 'text-text-primary'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
defaultVariants: {
|
|
30
|
+
status: 'upcoming'
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const stepperDescriptionVariants = cva('col-start-2 row-start-2 -mt-2 block min-w-0 max-w-320 truncate font-sans text-text-secondary text-xs');
|
|
34
|
+
const stepperSeparatorVariants = cva('flex h-20 w-32 shrink-0 items-center px-8');
|
|
35
|
+
const stepperSeparatorLineClassNames = 'block h-px w-full bg-border-primary';
|
|
36
|
+
const stepperContentVariants = cva('min-w-0');
|
|
37
|
+
export { stepperContentVariants, stepperDescriptionVariants, stepperIndicatorVariants, stepperItemVariants, stepperListVariants, stepperSeparatorLineClassNames, stepperSeparatorVariants, stepperTitleVariants, stepperTriggerVariants, stepperVariants };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const ARK_LIST_ARIA_RESET: {
|
|
2
|
+
readonly role: undefined;
|
|
3
|
+
readonly 'aria-owns': undefined;
|
|
4
|
+
readonly 'aria-orientation': undefined;
|
|
5
|
+
};
|
|
6
|
+
export declare const ARK_ITEM_ARIA_RESET: {
|
|
7
|
+
readonly 'aria-current': undefined;
|
|
8
|
+
};
|
|
9
|
+
export declare const ARK_TAB_ARIA_RESET: {
|
|
10
|
+
readonly role: undefined;
|
|
11
|
+
readonly 'aria-selected': undefined;
|
|
12
|
+
readonly 'aria-controls': undefined;
|
|
13
|
+
};
|
|
14
|
+
export declare const ARK_CONTENT_ARIA_RESET: {
|
|
15
|
+
readonly tabIndex: undefined;
|
|
16
|
+
};
|
|
17
|
+
/** The design supports up to six steps; more logs a dev warning. */
|
|
18
|
+
export declare const STEPPER_MAX_STEPS = 6;
|
|
19
|
+
export declare const DEFAULT_STEPPER_STATUS_LABELS: {
|
|
20
|
+
readonly completed: 'Completed';
|
|
21
|
+
readonly danger: 'Has errors';
|
|
22
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const REMOVE = null;
|
|
2
|
+
const ARK_LIST_ARIA_RESET = {
|
|
3
|
+
role: REMOVE,
|
|
4
|
+
'aria-owns': REMOVE,
|
|
5
|
+
'aria-orientation': REMOVE
|
|
6
|
+
};
|
|
7
|
+
const ARK_ITEM_ARIA_RESET = {
|
|
8
|
+
'aria-current': REMOVE
|
|
9
|
+
};
|
|
10
|
+
const ARK_TAB_ARIA_RESET = {
|
|
11
|
+
role: REMOVE,
|
|
12
|
+
'aria-selected': REMOVE,
|
|
13
|
+
'aria-controls': REMOVE
|
|
14
|
+
};
|
|
15
|
+
const ARK_CONTENT_ARIA_RESET = {
|
|
16
|
+
tabIndex: REMOVE
|
|
17
|
+
};
|
|
18
|
+
const STEPPER_MAX_STEPS = 6;
|
|
19
|
+
const DEFAULT_STEPPER_STATUS_LABELS = {
|
|
20
|
+
completed: 'Completed',
|
|
21
|
+
danger: 'Has errors'
|
|
22
|
+
};
|
|
23
|
+
export { ARK_CONTENT_ARIA_RESET, ARK_ITEM_ARIA_RESET, ARK_LIST_ARIA_RESET, ARK_TAB_ARIA_RESET, DEFAULT_STEPPER_STATUS_LABELS, STEPPER_MAX_STEPS };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { Stepper, type StepperProps } from './Stepper';
|
|
2
|
+
export { StepperContent, type StepperContentProps } from './StepperContent';
|
|
3
|
+
export { type StepperItemContextValue, type UseStepperContextReturn, useStepperContext, useStepperItemContext, } from './StepperContext';
|
|
4
|
+
export { StepperDescription, type StepperDescriptionProps } from './StepperDescription';
|
|
5
|
+
export { StepperIndicator, type StepperIndicatorProps } from './StepperIndicator';
|
|
6
|
+
export { StepperItem, type StepperItemProps } from './StepperItem';
|
|
7
|
+
export { StepperList, type StepperListProps } from './StepperList';
|
|
8
|
+
export { StepperNextTrigger, type StepperNextTriggerProps } from './StepperNextTrigger';
|
|
9
|
+
export { StepperPrevTrigger, type StepperPrevTriggerProps } from './StepperPrevTrigger';
|
|
10
|
+
export { StepperRootProvider, type StepperRootProviderProps } from './StepperRootProvider';
|
|
11
|
+
export { StepperSeparator, type StepperSeparatorProps } from './StepperSeparator';
|
|
12
|
+
export { StepperTitle, type StepperTitleProps } from './StepperTitle';
|
|
13
|
+
export { StepperTrigger, type StepperTriggerProps } from './StepperTrigger';
|
|
14
|
+
export type { StepperItemStatus, StepperStatusLabels, StepperVisualStatus } from './types';
|
|
15
|
+
export { type UseStepperProps, type UseStepperReturn, useStepper } from './useStepper';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { Stepper } from "./Stepper.js";
|
|
2
|
+
export { StepperContent } from "./StepperContent.js";
|
|
3
|
+
export { useStepperContext, useStepperItemContext } from "./StepperContext.js";
|
|
4
|
+
export { StepperDescription } from "./StepperDescription.js";
|
|
5
|
+
export { StepperIndicator } from "./StepperIndicator.js";
|
|
6
|
+
export { StepperItem } from "./StepperItem.js";
|
|
7
|
+
export { StepperList } from "./StepperList.js";
|
|
8
|
+
export { StepperNextTrigger } from "./StepperNextTrigger.js";
|
|
9
|
+
export { StepperPrevTrigger } from "./StepperPrevTrigger.js";
|
|
10
|
+
export { StepperRootProvider } from "./StepperRootProvider.js";
|
|
11
|
+
export { StepperSeparator } from "./StepperSeparator.js";
|
|
12
|
+
export { StepperTitle } from "./StepperTitle.js";
|
|
13
|
+
export { StepperTrigger } from "./StepperTrigger.js";
|
|
14
|
+
export { useStepper } from "./useStepper.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* With `asChild`, Ark merges the child's props over the trigger's, so a child `disabled={false}`
|
|
4
|
+
* (e.g. `<Button disabled={isSaving}>`) would re-enable Next on the last step or Prev on the first.
|
|
5
|
+
* This takes the child's `disabled` out, for the trigger to fold into its own, so the trigger's
|
|
6
|
+
* computed value always wins.
|
|
7
|
+
*/
|
|
8
|
+
export declare const takeAsChildDisabled: (asChild: boolean | undefined, children: ReactNode) => {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
childDisabled?: boolean;
|
|
11
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { cloneElement, isValidElement } from "react";
|
|
2
|
+
const takeAsChildDisabled = (asChild, children)=>{
|
|
3
|
+
if (!asChild || !isValidElement(children)) return {
|
|
4
|
+
children
|
|
5
|
+
};
|
|
6
|
+
const { disabled } = children.props;
|
|
7
|
+
if (void 0 === disabled) return {
|
|
8
|
+
children
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
children: cloneElement(children, {
|
|
12
|
+
disabled: void 0
|
|
13
|
+
}),
|
|
14
|
+
childDisabled: disabled
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export { takeAsChildDisabled };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Status set by the page. `'active'` is never passed: it is derived from the current step. */
|
|
2
|
+
export type StepperItemStatus = 'upcoming' | 'completed' | 'danger';
|
|
3
|
+
/** Rendered state, exposed as `data-status`. */
|
|
4
|
+
export type StepperVisualStatus = 'active' | StepperItemStatus;
|
|
5
|
+
/** Screen-reader-only status suffixes (i18n). */
|
|
6
|
+
export interface StepperStatusLabels {
|
|
7
|
+
/** Default `'Completed'`. */
|
|
8
|
+
completed?: string;
|
|
9
|
+
/** Default `'Has errors'`. */
|
|
10
|
+
danger?: string;
|
|
11
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type UseStepsProps, type UseStepsReturn } from '@ark-ui/react/steps';
|
|
2
|
+
/** Ark props the Stepper does not support: it never blocks a step and is horizontal only. */
|
|
3
|
+
export type StepperOmittedArkProps = 'linear' | 'isStepValid' | 'isStepSkippable' | 'onStepInvalid' | 'onStepComplete' | 'orientation';
|
|
4
|
+
export interface StepperGuardProps {
|
|
5
|
+
/** Number of steps, 1–6. Required: each `StepperItem` and `StepperContent` takes its `index`. */
|
|
6
|
+
count: number;
|
|
7
|
+
/** Controlled current step, 0-based. Clamped to `[0, count - 1]`. */
|
|
8
|
+
step?: number;
|
|
9
|
+
/** Uncontrolled initial step. Default `0`. Clamped to `[0, count - 1]`. */
|
|
10
|
+
defaultStep?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Fires when a click changes the step, back or forward: `({ step }) => void`. A click on the
|
|
13
|
+
* current step does not fire it; use the trigger's `onClick` to observe that.
|
|
14
|
+
*/
|
|
15
|
+
onStepChange?: UseStepsProps['onStepChange'];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The root guards shared by `Stepper` and `useStepper`: clamps `step` / `defaultStep`, warns in
|
|
19
|
+
* development, and never reports a step past the last one (Ark's "completed" state).
|
|
20
|
+
*/
|
|
21
|
+
export declare const useStepperGuards: ({ count, step, defaultStep, onStepChange }: StepperGuardProps) => {
|
|
22
|
+
count: number;
|
|
23
|
+
step?: number | undefined;
|
|
24
|
+
defaultStep?: number | undefined;
|
|
25
|
+
onStepChange: ((details: {
|
|
26
|
+
step: number;
|
|
27
|
+
}) => void) | undefined;
|
|
28
|
+
};
|
|
29
|
+
export interface UseStepperProps extends Omit<UseStepsProps, StepperOmittedArkProps | keyof StepperGuardProps>, StepperGuardProps {
|
|
30
|
+
}
|
|
31
|
+
export type UseStepperReturn = UseStepsReturn;
|
|
32
|
+
/**
|
|
33
|
+
* Creates the Stepper machine outside the component, for `StepperRootProvider`. Wraps Ark's
|
|
34
|
+
* `useSteps` with the same guards as `Stepper` and `useStepperContext`: the step is clamped to
|
|
35
|
+
* `[0, count - 1]`, `setStep` clamps too, and Next / Back move from the shown step, so the machine
|
|
36
|
+
* never reaches Ark's "completed" state (`isCompleted` is always `false`).
|
|
37
|
+
*/
|
|
38
|
+
export declare const useStepper: ({ count, step, defaultStep, onStepChange, ...rest }: UseStepperProps) => UseStepperReturn;
|