@delacour/react-native-ui 0.1.0-alpha.20260925063438 → 0.1.0-alpha.20260925063807

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delacour/react-native-ui",
3
- "version": "0.1.0-alpha.20260925063438",
3
+ "version": "0.1.0-alpha.20260925063807",
4
4
  "description": "React Native UI components — Uniwind, Reanimated, Gesture Handler",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -59,6 +59,7 @@
59
59
  "./skeleton": "./src/components/skeleton/index.ts",
60
60
  "./slider": "./src/components/slider/index.ts",
61
61
  "./spinner": "./src/components/spinner/index.ts",
62
+ "./steps": "./src/components/steps/index.ts",
62
63
  "./surface": "./src/components/surface/index.ts",
63
64
  "./switch": "./src/components/switch/index.ts",
64
65
  "./tabs": "./src/components/tabs/index.ts",
@@ -93,7 +94,7 @@
93
94
  },
94
95
  "peerDependencies": {
95
96
  "@central-icons-react-native/round-outlined-radius-1-stroke-1.5": "^1.1",
96
- "@delacour/react-native-charts": "0.1.0-alpha.20260925063438",
97
+ "@delacour/react-native-charts": "0.1.0-alpha.20260925063807",
97
98
  "@gorhom/bottom-sheet": "^5.2.8",
98
99
  "@legendapp/list": ">=3.3",
99
100
  "expo-linear-gradient": ">=15",
@@ -0,0 +1,153 @@
1
+ # Steps
2
+
3
+ A stepper for a multi-step flow. Compound root plus `Steps.Item`, `Steps.Indicator`,
4
+ `Steps.Title`, `Steps.Description` and `Steps.Panel`; the connectors between steps are
5
+ internal and drawn by the items themselves.
6
+
7
+ `import { Steps } from "@delacour/react-native-ui/steps";`
8
+
9
+ ## Files
10
+
11
+ | File | What it holds |
12
+ | --- | --- |
13
+ | `index.ts` | → `@delacour/react-native-ui/steps` |
14
+ | `steps.tsx` | Root — the value, the item count, and the `Object.assign` |
15
+ | `steps-item.tsx` | `Steps.Item` — the outer box, the trigger (a `Pressable` or a `View`), and `splitChildren` |
16
+ | `steps-track.tsx` | The track `[half] [circle] [half]`, and the rail beside a vertical panel — internal |
17
+ | `steps-panel.tsx` | `Steps.Panel` — content outside the tap target |
18
+ | `steps-indicator.tsx` | `Steps.Indicator` — the circle and its number, check, cross or spinner |
19
+ | `steps-title.tsx` | `Steps.Title` |
20
+ | `steps-description.tsx` | `Steps.Description` |
21
+ | `steps-connector.tsx` | One half of the line between two steps — internal |
22
+ | `steps.context.tsx` | The stepper's and the step's contexts, with their hooks |
23
+ | `steps.variants.ts` | Pure `tv()` slots + every resolver, no RN imports |
24
+ | `steps.variants.test.ts` | |
25
+
26
+ ## Design
27
+
28
+ - **Variants**: `primary` (a completed step is solid, the current one a ring, the
29
+ steps ahead hollow) and `secondary` (every indicator filled — completed soft,
30
+ current solid, upcoming muted). **Sizes**: `sm`, `md`, `lg` — the circle's edge
31
+ (24/32/40), the number's type step, the glyph's icon step, the title's `Text`
32
+ step and the gaps, on one axis. **Orientations**: `horizontal` (titles centred
33
+ under the circles, equal-width columns) and `vertical` (titles beside, the line
34
+ running down).
35
+ - **Three statuses, off one number.** `resolveStepStatus` reads the step's index
36
+ against the zero-based `value`: before it `completed`, at it `current`, after it
37
+ `upcoming`. A step's own `completed` overrides that — `true` wins everywhere
38
+ (the last step of a finished flow), `false` un-completes a passed step (a
39
+ skipped optional one) but never demotes the current step, which would leave a
40
+ stepper with nowhere the user is. `isCurrent` is kept beside the status for the
41
+ same reason: a completed current step is still where the user is, and it still
42
+ announces `selected`.
43
+ - **Invalid and loading are flags, not statuses.** A step can be completed *and*
44
+ invalid (the payment failed on review), or current *and* loading. Folding them
45
+ into the status would make the status a list of every pair.
46
+ `resolveIndicatorGlyph` ranks what the circle draws: spinner over cross over
47
+ check over number — loading outranks invalid because a failed step being
48
+ retried is retrying.
49
+
50
+ ## The connectors are laid out, not measured
51
+
52
+ - **The root counts its items and each item draws its own halves.** A horizontal
53
+ item is an equal `flex-1` column whose track is `[half] [circle] [half]`; the
54
+ line between two steps is one item's right half meeting the next item's left
55
+ half at the column boundary. The outer halves of the first and last steps are
56
+ transparent spacers, so every circle stays centred. A vertical item's track is
57
+ `[circle] [line]`, the line `flex-1` down whatever height the content gives it,
58
+ and the last step draws none. `resolveStepConnectors` is that whole decision.
59
+ Nothing calls `onLayout`, so a title that wraps to three lines moves nothing a
60
+ frame late — the failure a measured connector has on every first paint.
61
+ - **Both halves of one line fill off the value, never off a step's status.**
62
+ `isConnectorComplete(step, value)` is `step < value`. Each half lives in a
63
+ different item and can see only its own step's `completed` override, so a line
64
+ coloured by status could be half filled. The value is the one thing both ends
65
+ agree on.
66
+ - **The halves are square-ended.** Rounded ends meeting at the column boundary
67
+ pinch a two-point line visibly at every joint.
68
+ - **Counting walks the direct children**, the way [`Tabs`](../tabs/AGENTS.md)
69
+ walks its panels. A `.map()` is flattened by `Children.toArray` and counts; an
70
+ item behind a wrapper component does not, and the root warns in development.
71
+ With no count every item looks like the last and no line is drawn, which is the
72
+ visible failure the warning names. An item also warns when its `step` falls
73
+ outside the count — the usual cause is one-based indices.
74
+ - **A vertical title is padded down to sit level with its circle** — by half the
75
+ circle's edge less the title's line height. It is the one number derived from
76
+ another, and `steps.variants.test.ts` recomputes it from the slot classes, so a
77
+ retuned circle or title step fails the suite instead of drifting half a line.
78
+
79
+ ## Interaction
80
+
81
+ - **Read-only is inferred from the props React already has.** A controlled
82
+ `value` with no `onValueChange` cannot move — a press would be thrown away —
83
+ so the steps render as plain `View`s and are not announced as buttons.
84
+ `isReadOnly` states it outright either way. `resolveStepsReadOnly` is the rule.
85
+ - **`resolveStepInteraction` returns `static`, `pressable` or `blocked`.**
86
+ Blocked is still a `Pressable`, announced disabled: the step is disabled,
87
+ loading, or ahead of the value under `isLinear`, where the flow's own Continue
88
+ button is the only way forward and the steps behind stay open for going back.
89
+ A loading step is passed to `Pressable` as `busy` rather than `disabled`, so it
90
+ is announced busy, not dimmed.
91
+ - **Re-pressing the current step does not call `onValueChange`** —
92
+ `shouldEmitStep`, the rule `Radio.Group` keeps.
93
+ - **The fade lands on the circle and the content, never on the trigger.** The
94
+ trigger is `Pressable`'s own `Animated.View`, whose animated style writes `opacity`
95
+ every frame and silently overwrites an `opacity-50` class — see
96
+ [`Radio`](../radio/AGENTS.md). A root `isDisabled` wins over a step's own, the
97
+ radio group's ladder.
98
+
99
+ ## Accessibility
100
+
101
+ - **One element per step.** The trigger is `accessible`, so the circle, title and
102
+ description merge into one stop. Its name is the title (the text it holds) and
103
+ its `accessibilityValue.text` is `resolveStepAccessibilityValue` — "Step 2 of 3,
104
+ completed", with ", has an error" and ", loading" appended. VoiceOver reads it
105
+ as "Payment, Step 2 of 3, completed". The current step is `selected`.
106
+ - **The number does not scale with the OS text size.** The circle is a fixed
107
+ edge, so a scaled numeral would spill out of it, and the position it shows is
108
+ already in the accessibility value. The title and description scale as usual.
109
+ - **The connectors are hidden from assistive technology**, like `Separator` —
110
+ they restate the status every step already announces.
111
+
112
+ ## Colour
113
+
114
+ - **The number is a `Text` and the glyphs are SVG, and one test holds them
115
+ together.** The number takes its colour as a class from the `indicatorLabel`
116
+ slot (rule 1); the check, cross and spinner take theirs as a token through one
117
+ `IconDefaultsProvider`. `resolveIndicatorForeground` names the token and the
118
+ suite asserts, for every cell, that the slot emits `text-<that token>` and that
119
+ `theme.css` declares it — a drift would be a white numeral beside a black check.
120
+ - **Every colour cell is a compound, invalid last.** `tv` emits compounds after
121
+ plain variants, so a plain `isInvalid` branch would lose to the status cells —
122
+ `radioVariants`' reason.
123
+ - **The title follows the step; the description does not.** Upcoming titles are
124
+ muted, an invalid title is destructive. The description keeps `Text.Caption`'s
125
+ muted colour in every state: the circle and the title already say where the step
126
+ stands.
127
+ - **The check and cross land with a short `ZoomIn`**, keyed by glyph so a change
128
+ of glyph replays it. Reduce motion is left at Reanimated's `System`, which snaps
129
+ it in — the state is the glyph's presence, not its motion.
130
+
131
+ ## The panel
132
+
133
+ - **`Steps.Panel` exists because the trigger is one accessibility element.** A
134
+ form written inside the trigger was unreachable: `accessible` merges every
135
+ descendant into one VoiceOver stop, so its text field and its Continue button
136
+ could not be focused, and its button's tap gesture sat inside the step's own.
137
+ The item therefore splits its children — the indicator into the track, a panel
138
+ after the trigger, everything else into the text column — and a panel's
139
+ controls are ordinary elements that never move the stepper.
140
+ - **A vertical panel sits beside a rail as wide as the circle**, which carries the
141
+ trailing line on past it, so the panel reads as part of its step and the line
142
+ still reaches the next circle. The gap before the next step moves from under
143
+ the title to under the panel; the suite pins both halves of that move.
144
+ - **There is no "only while current".** A finished step's summary is as common a
145
+ panel as the current step's form, so the caller gates it on `value`.
146
+ - **`className` styles the item's outer box; every other prop reaches the
147
+ trigger.** `testID`, `onPress`, `haptic` and the accessibility props all belong
148
+ to the thing that is pressed and announced.
149
+
150
+ ## What it does not do
151
+
152
+ - **No `Steps.Separator`.** The connectors are derived from the count; exposing
153
+ them would reintroduce the dangling-line failure the count exists to prevent.
@@ -0,0 +1,45 @@
1
+ export { Steps, type StepsProps } from "./steps";
2
+ export {
3
+ type StepsContextValue,
4
+ type StepsItemContextValue,
5
+ StepsItemProvider,
6
+ StepsProvider,
7
+ useSteps,
8
+ useStepsContext,
9
+ useStepsItem,
10
+ useStepsItemContext,
11
+ } from "./steps.context";
12
+ export {
13
+ isConnectorComplete,
14
+ resolveIndicatorForeground,
15
+ resolveIndicatorGlyph,
16
+ resolveStepAccessibilityValue,
17
+ resolveStepConnectors,
18
+ resolveStepInteraction,
19
+ resolveStepStatus,
20
+ resolveStepsReadOnly,
21
+ STEP_STATUSES,
22
+ STEPS_DEFAULT_ORIENTATION,
23
+ STEPS_DEFAULT_SIZE,
24
+ STEPS_DEFAULT_VARIANT,
25
+ STEPS_DESCRIPTION_TEXT_SIZE,
26
+ STEPS_ORIENTATIONS,
27
+ STEPS_SIZES,
28
+ STEPS_TITLE_TEXT_SIZE,
29
+ STEPS_VARIANTS,
30
+ type StepConnectorSlot,
31
+ type StepIndicatorGlyph,
32
+ type StepInteraction,
33
+ type StepStatus,
34
+ type StepsOrientation,
35
+ type StepsSize,
36
+ type StepsVariant,
37
+ type StepsVariantProps,
38
+ shouldEmitStep,
39
+ stepsVariants,
40
+ } from "./steps.variants";
41
+ export type { StepsDescriptionProps } from "./steps-description";
42
+ export type { StepsIndicatorChildrenProps, StepsIndicatorProps } from "./steps-indicator";
43
+ export type { StepsItemProps } from "./steps-item";
44
+ export type { StepsPanelProps } from "./steps-panel";
45
+ export type { StepsTitleProps } from "./steps-title";
@@ -0,0 +1,31 @@
1
+ import type { ReactElement } from "react";
2
+ import { View } from "react-native";
3
+ import type { StepConnectorSlot, StepsOrientation } from "./steps.variants";
4
+ import { stepsVariants } from "./steps.variants";
5
+
6
+ export type StepsConnectorProps = {
7
+ slot: Exclude<StepConnectorSlot, "none">;
8
+ orientation: StepsOrientation;
9
+ isComplete: boolean;
10
+ };
11
+
12
+ /**
13
+ * One half of the line between two steps, or the invisible half that keeps an
14
+ * end indicator centred. Internal — nobody places one; see
15
+ * `resolveStepConnectors`.
16
+ *
17
+ * Hidden from assistive technology, like `Separator`: the line restates the
18
+ * status every step already announces.
19
+ */
20
+ export function StepsConnector({ slot, orientation, isComplete }: StepsConnectorProps): ReactElement {
21
+ const slots = stepsVariants({ isConnectorComplete: isComplete, orientation });
22
+
23
+ return (
24
+ <View
25
+ accessibilityElementsHidden
26
+ className={slot === "spacer" ? slots.spacer() : slots.connector()}
27
+ importantForAccessibility="no-hide-descendants"
28
+ />
29
+ );
30
+ }
31
+ StepsConnector.displayName = "DelacourUI.Steps.Connector";
@@ -0,0 +1,26 @@
1
+ import type { ReactElement } from "react";
2
+ import { Text, type TextPresetProps } from "../text";
3
+ import { useStepsItemPart } from "./steps.context";
4
+ import { STEPS_DESCRIPTION_TEXT_SIZE, stepsVariants } from "./steps.variants";
5
+
6
+ export type StepsDescriptionProps = TextPresetProps;
7
+
8
+ /**
9
+ * A line of supporting text under the title. Optional.
10
+ *
11
+ * Renders `Text.Caption` one size step below the title and keeps the preset's
12
+ * muted colour in every state — the indicator and the title already say where
13
+ * the step stands, and a third voice saying it would only be louder.
14
+ */
15
+ export function StepsDescription({ className, size, ...props }: StepsDescriptionProps): ReactElement {
16
+ const item = useStepsItemPart("Steps.Description");
17
+
18
+ return (
19
+ <Text.Caption
20
+ className={stepsVariants({ orientation: item.orientation }).description({ className })}
21
+ size={size ?? STEPS_DESCRIPTION_TEXT_SIZE[item.size]}
22
+ {...props}
23
+ />
24
+ );
25
+ }
26
+ StepsDescription.displayName = "DelacourUI.Steps.Description";
@@ -0,0 +1,106 @@
1
+ import { type ReactElement, type ReactNode, useMemo } from "react";
2
+ import { View, type ViewProps } from "react-native";
3
+ import Animated, { ZoomIn } from "react-native-reanimated";
4
+ import { IconCheckmark1Small, IconCrossSmall } from "../../icons/central";
5
+ import { Icon, IconDefaultsProvider } from "../icon";
6
+ import { Spinner } from "../spinner";
7
+ import { Text } from "../text";
8
+ import { type StepsItemContextValue, useStepsItemPart } from "./steps.context";
9
+ import { resolveIndicatorForeground, resolveIndicatorGlyph, stepsVariants } from "./steps.variants";
10
+
11
+ export type StepsIndicatorChildrenProps = Pick<
12
+ StepsItemContextValue,
13
+ "step" | "status" | "isCurrent" | "isInvalid" | "isLoading" | "size" | "variant"
14
+ >;
15
+
16
+ export type StepsIndicatorProps = Omit<ViewProps, "children"> & {
17
+ className?: string;
18
+ /**
19
+ * Replaces what the circle draws. The circle, its size and its colours are
20
+ * still the step's, and an `Icon` inside inherits the glyph size and colour.
21
+ */
22
+ children?: ReactNode | ((props: StepsIndicatorChildrenProps) => ReactNode);
23
+ };
24
+
25
+ /**
26
+ * The glyph's entrance. Short and un-sprung: a check lands, it does not bounce.
27
+ * Reduce motion is Reanimated's default `System`, which snaps it in — the state
28
+ * is carried by the glyph's presence, not by its motion.
29
+ */
30
+ const GLYPH_ENTERING = ZoomIn.duration(180);
31
+
32
+ /**
33
+ * The circle: a spinner while loading, a cross while invalid, a check once
34
+ * completed, and otherwise the step's one-based number.
35
+ *
36
+ * Composed in automatically, so write it out only to restyle it or to draw
37
+ * something of your own inside the circle — an icon per step, say. Wherever it
38
+ * is written among a step's children, the step lifts it into the track between
39
+ * the connector halves; it never lands in the text column.
40
+ *
41
+ * **The circle is hidden from assistive technology.** The trigger merges its
42
+ * children into one element, and the numeral would otherwise lead the name —
43
+ * "2, Shipping" — restating the position the accessibility value already reads.
44
+ *
45
+ * **The number does not scale with the OS text size.** The circle is a fixed
46
+ * edge, so a scaled numeral would spill out of it, and the position it shows is
47
+ * already announced in the step's accessibility value — scaling would buy the
48
+ * reader nothing the screen reader has not said.
49
+ *
50
+ * The check and cross are Central Icons and the spinner is `Spinner`; all three
51
+ * take their size and colour from one `IconDefaultsProvider`, whose token
52
+ * {@link resolveIndicatorForeground} keeps equal to the number's class.
53
+ */
54
+ export function StepsIndicator({ className, children, ...props }: StepsIndicatorProps): ReactElement {
55
+ const item = useStepsItemPart("Steps.Indicator");
56
+ const { step, status, isCurrent, isInvalid, isLoading, isDisabled, size, variant } = item;
57
+
58
+ const slots = stepsVariants({ isDisabled, isInvalid, size, status, variant });
59
+ const glyphClass = slots.glyph();
60
+ const labelClass = slots.indicatorLabel();
61
+ const color = resolveIndicatorForeground({ isInvalid, status, variant });
62
+ const iconDefaults = useMemo(() => ({ className: glyphClass ?? "", color }), [glyphClass, color]);
63
+
64
+ const renderGlyph = (): ReactNode => {
65
+ if (typeof children === "function") {
66
+ return children({ isCurrent, isInvalid, isLoading, size, status, step, variant });
67
+ }
68
+ if (children) return children;
69
+
70
+ const glyph = resolveIndicatorGlyph({ isInvalid, isLoading, status, step });
71
+ switch (glyph.kind) {
72
+ case "spinner":
73
+ return <Spinner />;
74
+ case "alert":
75
+ return (
76
+ <Animated.View entering={GLYPH_ENTERING} key="alert">
77
+ <Icon icon={IconCrossSmall} />
78
+ </Animated.View>
79
+ );
80
+ case "check":
81
+ return (
82
+ <Animated.View entering={GLYPH_ENTERING} key="check">
83
+ <Icon icon={IconCheckmark1Small} />
84
+ </Animated.View>
85
+ );
86
+ case "number":
87
+ return (
88
+ <Text allowFontScaling={false} className={labelClass}>
89
+ {glyph.label}
90
+ </Text>
91
+ );
92
+ }
93
+ };
94
+
95
+ return (
96
+ <View
97
+ accessibilityElementsHidden
98
+ className={slots.indicator({ className })}
99
+ importantForAccessibility="no-hide-descendants"
100
+ {...props}
101
+ >
102
+ <IconDefaultsProvider value={iconDefaults}>{renderGlyph()}</IconDefaultsProvider>
103
+ </View>
104
+ );
105
+ }
106
+ StepsIndicator.displayName = "DelacourUI.Steps.Indicator";
@@ -0,0 +1,225 @@
1
+ import { Children, isValidElement, type ReactElement, type ReactNode, useCallback, useMemo } from "react";
2
+ import { View } from "react-native";
3
+ import { Pressable, type PressableProps } from "../pressable";
4
+ import { type StepsItemContextValue, StepsItemProvider, useStepsPart } from "./steps.context";
5
+ import {
6
+ resolveStepAccessibilityValue,
7
+ resolveStepInteraction,
8
+ resolveStepStatus,
9
+ stepsVariants,
10
+ } from "./steps.variants";
11
+ import { StepsIndicator } from "./steps-indicator";
12
+ import { StepsPanel } from "./steps-panel";
13
+ import { StepsTitle } from "./steps-title";
14
+ import { StepsRail, StepsTrack } from "./steps-track";
15
+
16
+ export type StepsItemProps = Omit<PressableProps, "asChild" | "busy" | "children" | "disabled" | "ref"> & {
17
+ /** This step's index, zero-based. The indicator draws it one-based. */
18
+ step: number;
19
+ /**
20
+ * Overrides whether the step reads as done. `true` completes it wherever it
21
+ * sits — a finished flow's last step. `false` leaves a passed step looking
22
+ * unfinished — a skipped optional one. Never demotes the current step.
23
+ */
24
+ completed?: boolean;
25
+ /** The step cannot be pressed, and fades. A stepper that names `isDisabled` wins over this. */
26
+ isDisabled?: boolean;
27
+ /** The step has an error: a cross in the indicator and a destructive title. */
28
+ isInvalid?: boolean;
29
+ /** A spinner in the indicator. The step is announced busy and cannot be pressed. */
30
+ isLoading?: boolean;
31
+ children?: ReactNode;
32
+ };
33
+
34
+ /**
35
+ * One step: its indicator, the connector halves either side of it, its title and
36
+ * description, and any `Steps.Panel`.
37
+ *
38
+ * The trigger is the control — the circle, the title and the space between them
39
+ * are one tap target and one accessibility element, whose name is the title and
40
+ * whose value is "Step 2 of 3, completed". It renders a `Pressable` when the
41
+ * stepper takes presses and a plain `View` when it is read-only, so a progress
42
+ * display is never announced as a row of buttons. A panel renders after the
43
+ * trigger, outside both.
44
+ *
45
+ * `className` styles the step's outer box; every other prop — `testID`,
46
+ * `onPress`, `haptic`, the accessibility props — reaches the trigger.
47
+ *
48
+ * Bare text is wrapped in a `Steps.Title`, and a `Steps.Indicator` is composed
49
+ * in when the children hold none — the shortest step that works is
50
+ * `<Steps.Item step={0}>Account</Steps.Item>`.
51
+ */
52
+ export function StepsItem({
53
+ step,
54
+ completed,
55
+ isDisabled,
56
+ isInvalid = false,
57
+ isLoading = false,
58
+ feedback = "fade",
59
+ haptic,
60
+ onLongPress,
61
+ pressedOpacity,
62
+ pressedScale,
63
+ accessibilityState,
64
+ className,
65
+ children,
66
+ onPress,
67
+ ...props
68
+ }: StepsItemProps): ReactElement {
69
+ const root = useStepsPart("Steps.Item");
70
+ const { value, count, orientation, size, variant, select } = root;
71
+
72
+ const status = resolveStepStatus({ completed, step, value });
73
+ const isCurrent = step === value;
74
+ const resolvedIsDisabled = root.isDisabled ?? isDisabled ?? false;
75
+ const isLast = step >= count - 1;
76
+
77
+ if (process.env.NODE_ENV !== "production" && count > 0 && (step < 0 || step >= count)) {
78
+ console.warn(`Steps.Item: step ${step} is outside the ${count} steps the root counted. Steps are zero-based.`);
79
+ }
80
+
81
+ const interaction = resolveStepInteraction({
82
+ isDisabled: resolvedIsDisabled,
83
+ isLinear: root.isLinear,
84
+ isLoading,
85
+ isReadOnly: root.isReadOnly,
86
+ step,
87
+ value,
88
+ });
89
+
90
+ const context = useMemo<StepsItemContextValue>(
91
+ () => ({
92
+ isCurrent,
93
+ isDisabled: resolvedIsDisabled,
94
+ isInvalid,
95
+ isLast,
96
+ isLoading,
97
+ orientation,
98
+ size,
99
+ status,
100
+ step,
101
+ variant,
102
+ }),
103
+ [isCurrent, resolvedIsDisabled, isInvalid, isLast, isLoading, orientation, size, status, step, variant]
104
+ );
105
+
106
+ const handlePress = useCallback(() => {
107
+ select(step);
108
+ onPress?.();
109
+ }, [onPress, select, step]);
110
+
111
+ const { indicator, content, panels } = useMemo(() => splitChildren(children), [children]);
112
+ const hasPanel = panels.length > 0;
113
+ const slots = stepsVariants({ hasPanel, isDisabled: resolvedIsDisabled, isLast, orientation, size });
114
+
115
+ const trigger = (
116
+ <>
117
+ <StepsTrack indicator={indicator} />
118
+ {content.length > 0 ? <View className={slots.content()}>{content}</View> : null}
119
+ </>
120
+ );
121
+
122
+ // A vertical panel sits beside a rail that carries the line on past it; a
123
+ // horizontal one simply follows the trigger.
124
+ const panelRow =
125
+ hasPanel && orientation === "vertical" ? (
126
+ <View className={slots.panelRow()}>
127
+ <StepsRail />
128
+ {panels}
129
+ </View>
130
+ ) : (
131
+ panels
132
+ );
133
+
134
+ const accessibilityValue = {
135
+ text: resolveStepAccessibilityValue({ count, isInvalid, isLoading, status, step }),
136
+ };
137
+ const state = { ...accessibilityState, selected: isCurrent };
138
+
139
+ return (
140
+ <StepsItemProvider value={context}>
141
+ <View className={slots.item({ className })}>
142
+ {interaction === "static" ? (
143
+ <View
144
+ accessibilityState={state}
145
+ accessibilityValue={accessibilityValue}
146
+ accessible
147
+ className={slots.trigger()}
148
+ {...props}
149
+ >
150
+ {trigger}
151
+ </View>
152
+ ) : (
153
+ <Pressable
154
+ accessibilityState={state}
155
+ accessibilityValue={accessibilityValue}
156
+ busy={isLoading}
157
+ className={slots.trigger()}
158
+ disabled={interaction === "blocked" && !isLoading}
159
+ feedback={feedback}
160
+ haptic={haptic}
161
+ onLongPress={onLongPress}
162
+ onPress={handlePress}
163
+ pressedOpacity={pressedOpacity}
164
+ pressedScale={pressedScale}
165
+ {...props}
166
+ >
167
+ {trigger}
168
+ </Pressable>
169
+ )}
170
+ {panelRow}
171
+ </View>
172
+ </StepsItemProvider>
173
+ );
174
+ }
175
+ StepsItem.displayName = "DelacourUI.Steps.Item";
176
+
177
+ /**
178
+ * Lifts a `Steps.Indicator` and any `Steps.Panel` out of a step's children, and
179
+ * wraps bare text in a `Steps.Title`.
180
+ *
181
+ * Both places are structural — the indicator between the connector halves, a
182
+ * panel after the trigger — so each is pulled out wherever it was written rather
183
+ * than rendered in the text column.
184
+ * Consecutive strings and numbers collapse into one title, as `Radio` does, so
185
+ * `Step {n}` is one piece of text rather than two spaced apart.
186
+ *
187
+ * Lives here rather than in the root: it is the item that wraps its own
188
+ * children, and a helper in the root file would close a cycle. See AGENTS.md.
189
+ */
190
+ function splitChildren(children: ReactNode): {
191
+ indicator: ReactNode | null;
192
+ content: ReactNode[];
193
+ panels: ReactNode[];
194
+ } {
195
+ let indicator: ReactNode | null = null;
196
+ const content: ReactNode[] = [];
197
+ const panels: ReactNode[] = [];
198
+ let run: (string | number)[] = [];
199
+
200
+ const flushRun = () => {
201
+ if (run.length === 0) return;
202
+ content.push(<StepsTitle key={`title-${content.length}`}>{run.join("")}</StepsTitle>);
203
+ run = [];
204
+ };
205
+
206
+ for (const child of Children.toArray(children)) {
207
+ if (typeof child === "string" || typeof child === "number") {
208
+ run.push(child);
209
+ continue;
210
+ }
211
+ flushRun();
212
+ if (indicator === null && isValidElement(child) && child.type === StepsIndicator) {
213
+ indicator = child;
214
+ continue;
215
+ }
216
+ if (isValidElement(child) && child.type === StepsPanel) {
217
+ panels.push(child);
218
+ continue;
219
+ }
220
+ content.push(child);
221
+ }
222
+ flushRun();
223
+
224
+ return { content, indicator, panels };
225
+ }
@@ -0,0 +1,41 @@
1
+ import type { ReactElement } from "react";
2
+ import { View, type ViewProps } from "react-native";
3
+ import { useStepsItemPart } from "./steps.context";
4
+ import { stepsVariants } from "./steps.variants";
5
+
6
+ export type StepsPanelProps = ViewProps & { className?: string };
7
+
8
+ /**
9
+ * Content for a step that sits below its title but outside its tap target — a
10
+ * form for the current step, a summary of a finished one.
11
+ *
12
+ * **It exists because the trigger is one accessibility element.** The trigger
13
+ * merges its indicator, title and description into a single stop, so a text
14
+ * field or a button inside it would be unreachable by VoiceOver, and its own
15
+ * tap gesture would sit inside the step's. The panel renders beside the
16
+ * trigger instead: every control in it is its own element, and a press on it
17
+ * never moves the stepper.
18
+ *
19
+ * Wherever it is written among a step's children, the step lifts it out and
20
+ * renders it after the trigger. In a vertical stepper the line carries on down
21
+ * a rail beside it, so the panel reads as part of its step. Show it
22
+ * conditionally — `{value === 1 ? <Steps.Panel>…</Steps.Panel> : null}` — there
23
+ * is no built-in "only while current", because a finished step's summary is as
24
+ * common a panel as the current step's form.
25
+ */
26
+ export function StepsPanel({ className, ...props }: StepsPanelProps): ReactElement {
27
+ const item = useStepsItemPart("Steps.Panel");
28
+
29
+ return (
30
+ <View
31
+ className={stepsVariants({
32
+ hasPanel: true,
33
+ isLast: item.isLast,
34
+ orientation: item.orientation,
35
+ size: item.size,
36
+ }).panel({ className })}
37
+ {...props}
38
+ />
39
+ );
40
+ }
41
+ StepsPanel.displayName = "DelacourUI.Steps.Panel";