@xsolla/xui-b2b-chip-stepper 0.195.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/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @xsolla/xui-b2b-chip-stepper
2
+
3
+ The full API reference lives at
4
+ [`docs/api/components/b2b-chip-stepper.md`](../../../docs/api/components/b2b-chip-stepper.md).
5
+
6
+ > **Maintainer note.** Sibling packages keep this file as a **symlink** to the
7
+ > docs page (`README.md -> ../../../docs/api/components/b2b-chip-stepper.md`) so
8
+ > npm publishes the real reference. This copy is a plain file because the commit
9
+ > that created it went through the GitLab API, which cannot create symlinks.
10
+ > Please convert it before merge:
11
+ >
12
+ > ```bash
13
+ > cd packages/b2b/chip-stepper
14
+ > rm README.md
15
+ > ln -s ../../../docs/api/components/b2b-chip-stepper.md README.md
16
+ > ```
@@ -0,0 +1,137 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { BoxProps } from '@xsolla/xui-primitives-core';
4
+ import { ThemeOverrideProps } from '@xsolla/xui-core';
5
+
6
+ /**
7
+ * Visual state of a single chip step.
8
+ *
9
+ * | Value | Appearance |
10
+ * | ---------- | ----------------------------------------------------------------- |
11
+ * | `active` | Current step — `overlay/brand` fill, `border/brand`, primary text. |
12
+ * | `next` | Upcoming — `background/primary` fill, `border/secondary`, tertiary text. |
13
+ * | `done` | Completed — same neutral chip as `next`, but `content/primary` text. |
14
+ * | `error` | `overlay/alert` fill, `border/alert`, alert text; leading icon swaps to a warning glyph. |
15
+ * | `disabled` | `background/neutral-secondary` fill, disabled text colour. |
16
+ */
17
+ type ChipStepStatus = "active" | "next" | "done" | "error" | "disabled";
18
+ /**
19
+ * Chip size. Maps to the Figma `Size` variant: `sm` = S (22px tall),
20
+ * `md` = M (28px tall). Named with the toolkit's `ComponentSize` vocabulary
21
+ * rather than Figma's single letters.
22
+ */
23
+ type ChipStepSize = "sm" | "md";
24
+ /** Payload handed to {@link ChipStepperProps.onStepClick}. */
25
+ type ChipStepClickType = (args: {
26
+ /** 1-based position of the clicked step. */
27
+ number: number;
28
+ step: ChipStepType;
29
+ }) => void;
30
+ type ChipStepType = {
31
+ /**
32
+ * Step label. The leading ordinal (`"1."`, `"2."`, …) is computed by the
33
+ * component from the step's position — do NOT bake it into this string.
34
+ */
35
+ label: ReactNode;
36
+ /** Visual state. Defaults to `"next"`. */
37
+ status?: ChipStepStatus;
38
+ /**
39
+ * Per-step click handler. Runs in addition to the container-level
40
+ * {@link ChipStepperProps.onStepClick}. Ignored when `status` is
41
+ * `"disabled"`.
42
+ */
43
+ onClick?: () => void;
44
+ /**
45
+ * Optional leading icon rendered before the ordinal. Overridden by the
46
+ * warning glyph when `status` is `"error"`.
47
+ */
48
+ leftIcon?: ReactNode;
49
+ /**
50
+ * Adds one extra gap unit of leading inset. Use when the step has no
51
+ * `leftIcon` but must optically align with sibling steps that do.
52
+ * Defaults to `false`.
53
+ */
54
+ showLeftExtraPadding?: boolean;
55
+ /** Stable React key override. Defaults to the step index. */
56
+ key?: string;
57
+ };
58
+ interface ChipStepperProps extends Omit<BoxProps, "onClick">, ThemeOverrideProps {
59
+ /** Ordered list of steps. Ordinals are derived from array position. */
60
+ steps: ChipStepType[];
61
+ /** Chip size. Defaults to `"sm"`, matching the Figma default variant. */
62
+ size?: ChipStepSize;
63
+ /**
64
+ * Called when any step is clicked. When provided (or when a step carries its
65
+ * own `onClick`), non-disabled steps render as real `<button>` elements and
66
+ * are keyboard-operable.
67
+ */
68
+ onStepClick?: ChipStepClickType;
69
+ /**
70
+ * Render the computed ordinal (`"1."`) before each label. Defaults to `true`.
71
+ */
72
+ showStepNumbers?: boolean;
73
+ /**
74
+ * Render the chevron glyph between steps. Defaults to `true`. Set to `false`
75
+ * for a separator-less row where the chips sit side by side.
76
+ */
77
+ showSeparators?: boolean;
78
+ className?: string;
79
+ "aria-label"?: string;
80
+ testID?: string;
81
+ }
82
+
83
+ /**
84
+ * A horizontal, pill-per-step progress indicator for B2B surfaces.
85
+ *
86
+ * Each step renders as a small chip (`"1. Label"`, optionally with a leading
87
+ * icon) and steps are separated by chevron glyphs. Step numbers are derived
88
+ * from array position — callers pass labels only.
89
+ *
90
+ * Distinct from `@xsolla/xui-b2b-stepper`, which renders numbered circles with
91
+ * title/description blocks and supports a vertical layout. Reach for this one
92
+ * in tight horizontal spaces such as form and drawer headers.
93
+ *
94
+ * ```tsx
95
+ * <ChipStepper
96
+ * steps={[
97
+ * { label: "Details", status: "done" },
98
+ * { label: "Billing", status: "active" },
99
+ * { label: "Confirm" },
100
+ * ]}
101
+ * onStepClick={({ number }) => goTo(number)}
102
+ * />
103
+ * ```
104
+ */
105
+ declare const ChipStepper: react.ForwardRefExoticComponent<ChipStepperProps & react.RefAttributes<HTMLDivElement>>;
106
+
107
+ /**
108
+ * Chip-stepper metrics, measured from the Figma `.Step-item` component set
109
+ * (file `fGm4yji206wAW2ZU7hhRRV`, node `15643:9363`) rather than derived from
110
+ * prose. Read via the Figma API on 2026-07-30.
111
+ *
112
+ * Kept local to the package rather than added to `theme.sizing` (where the
113
+ * circle-based `stepperB2b()` lives) because these values are specific to the
114
+ * pill layout and are not shared with any other component. If a second
115
+ * consumer appears, promote this into `theme.sizing.chipStepperB2b()`.
116
+ *
117
+ * Colours are NOT defined here — every colour is read from the active theme so
118
+ * the component follows all theme modes.
119
+ */
120
+ type ChipStepperSizing = {
121
+ /** Auto-layout gap between chip children, and between chip and separator. */
122
+ itemGap: number;
123
+ chipPaddingTop: number;
124
+ chipPaddingBottom: number;
125
+ /** Leading inset. Measured smaller than the trailing inset in both sizes. */
126
+ chipPaddingLeft: number;
127
+ chipPaddingRight: number;
128
+ chipRadius: number;
129
+ chipBorderWidth: number;
130
+ chipIconSize: number;
131
+ separatorIconSize: number;
132
+ labelFontSize: number;
133
+ labelLineHeight: number;
134
+ };
135
+ declare const chipStepperSizing: Record<ChipStepSize, ChipStepperSizing>;
136
+
137
+ export { type ChipStepClickType, type ChipStepSize, type ChipStepStatus, type ChipStepType, ChipStepper, type ChipStepperProps, type ChipStepperSizing, chipStepperSizing };
@@ -0,0 +1,137 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { BoxProps } from '@xsolla/xui-primitives-core';
4
+ import { ThemeOverrideProps } from '@xsolla/xui-core';
5
+
6
+ /**
7
+ * Visual state of a single chip step.
8
+ *
9
+ * | Value | Appearance |
10
+ * | ---------- | ----------------------------------------------------------------- |
11
+ * | `active` | Current step — `overlay/brand` fill, `border/brand`, primary text. |
12
+ * | `next` | Upcoming — `background/primary` fill, `border/secondary`, tertiary text. |
13
+ * | `done` | Completed — same neutral chip as `next`, but `content/primary` text. |
14
+ * | `error` | `overlay/alert` fill, `border/alert`, alert text; leading icon swaps to a warning glyph. |
15
+ * | `disabled` | `background/neutral-secondary` fill, disabled text colour. |
16
+ */
17
+ type ChipStepStatus = "active" | "next" | "done" | "error" | "disabled";
18
+ /**
19
+ * Chip size. Maps to the Figma `Size` variant: `sm` = S (22px tall),
20
+ * `md` = M (28px tall). Named with the toolkit's `ComponentSize` vocabulary
21
+ * rather than Figma's single letters.
22
+ */
23
+ type ChipStepSize = "sm" | "md";
24
+ /** Payload handed to {@link ChipStepperProps.onStepClick}. */
25
+ type ChipStepClickType = (args: {
26
+ /** 1-based position of the clicked step. */
27
+ number: number;
28
+ step: ChipStepType;
29
+ }) => void;
30
+ type ChipStepType = {
31
+ /**
32
+ * Step label. The leading ordinal (`"1."`, `"2."`, …) is computed by the
33
+ * component from the step's position — do NOT bake it into this string.
34
+ */
35
+ label: ReactNode;
36
+ /** Visual state. Defaults to `"next"`. */
37
+ status?: ChipStepStatus;
38
+ /**
39
+ * Per-step click handler. Runs in addition to the container-level
40
+ * {@link ChipStepperProps.onStepClick}. Ignored when `status` is
41
+ * `"disabled"`.
42
+ */
43
+ onClick?: () => void;
44
+ /**
45
+ * Optional leading icon rendered before the ordinal. Overridden by the
46
+ * warning glyph when `status` is `"error"`.
47
+ */
48
+ leftIcon?: ReactNode;
49
+ /**
50
+ * Adds one extra gap unit of leading inset. Use when the step has no
51
+ * `leftIcon` but must optically align with sibling steps that do.
52
+ * Defaults to `false`.
53
+ */
54
+ showLeftExtraPadding?: boolean;
55
+ /** Stable React key override. Defaults to the step index. */
56
+ key?: string;
57
+ };
58
+ interface ChipStepperProps extends Omit<BoxProps, "onClick">, ThemeOverrideProps {
59
+ /** Ordered list of steps. Ordinals are derived from array position. */
60
+ steps: ChipStepType[];
61
+ /** Chip size. Defaults to `"sm"`, matching the Figma default variant. */
62
+ size?: ChipStepSize;
63
+ /**
64
+ * Called when any step is clicked. When provided (or when a step carries its
65
+ * own `onClick`), non-disabled steps render as real `<button>` elements and
66
+ * are keyboard-operable.
67
+ */
68
+ onStepClick?: ChipStepClickType;
69
+ /**
70
+ * Render the computed ordinal (`"1."`) before each label. Defaults to `true`.
71
+ */
72
+ showStepNumbers?: boolean;
73
+ /**
74
+ * Render the chevron glyph between steps. Defaults to `true`. Set to `false`
75
+ * for a separator-less row where the chips sit side by side.
76
+ */
77
+ showSeparators?: boolean;
78
+ className?: string;
79
+ "aria-label"?: string;
80
+ testID?: string;
81
+ }
82
+
83
+ /**
84
+ * A horizontal, pill-per-step progress indicator for B2B surfaces.
85
+ *
86
+ * Each step renders as a small chip (`"1. Label"`, optionally with a leading
87
+ * icon) and steps are separated by chevron glyphs. Step numbers are derived
88
+ * from array position — callers pass labels only.
89
+ *
90
+ * Distinct from `@xsolla/xui-b2b-stepper`, which renders numbered circles with
91
+ * title/description blocks and supports a vertical layout. Reach for this one
92
+ * in tight horizontal spaces such as form and drawer headers.
93
+ *
94
+ * ```tsx
95
+ * <ChipStepper
96
+ * steps={[
97
+ * { label: "Details", status: "done" },
98
+ * { label: "Billing", status: "active" },
99
+ * { label: "Confirm" },
100
+ * ]}
101
+ * onStepClick={({ number }) => goTo(number)}
102
+ * />
103
+ * ```
104
+ */
105
+ declare const ChipStepper: react.ForwardRefExoticComponent<ChipStepperProps & react.RefAttributes<HTMLDivElement>>;
106
+
107
+ /**
108
+ * Chip-stepper metrics, measured from the Figma `.Step-item` component set
109
+ * (file `fGm4yji206wAW2ZU7hhRRV`, node `15643:9363`) rather than derived from
110
+ * prose. Read via the Figma API on 2026-07-30.
111
+ *
112
+ * Kept local to the package rather than added to `theme.sizing` (where the
113
+ * circle-based `stepperB2b()` lives) because these values are specific to the
114
+ * pill layout and are not shared with any other component. If a second
115
+ * consumer appears, promote this into `theme.sizing.chipStepperB2b()`.
116
+ *
117
+ * Colours are NOT defined here — every colour is read from the active theme so
118
+ * the component follows all theme modes.
119
+ */
120
+ type ChipStepperSizing = {
121
+ /** Auto-layout gap between chip children, and between chip and separator. */
122
+ itemGap: number;
123
+ chipPaddingTop: number;
124
+ chipPaddingBottom: number;
125
+ /** Leading inset. Measured smaller than the trailing inset in both sizes. */
126
+ chipPaddingLeft: number;
127
+ chipPaddingRight: number;
128
+ chipRadius: number;
129
+ chipBorderWidth: number;
130
+ chipIconSize: number;
131
+ separatorIconSize: number;
132
+ labelFontSize: number;
133
+ labelLineHeight: number;
134
+ };
135
+ declare const chipStepperSizing: Record<ChipStepSize, ChipStepperSizing>;
136
+
137
+ export { type ChipStepClickType, type ChipStepSize, type ChipStepStatus, type ChipStepType, ChipStepper, type ChipStepperProps, type ChipStepperSizing, chipStepperSizing };