@charcuterie/ui 3.5.0 → 3.7.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/Checkbox/Checkbox.d.ts +39 -1
- package/dist/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox/Checkbox.js +131 -71
- package/dist/Checkbox/Checkbox.js.map +1 -1
- package/dist/Field/Field.d.ts +67 -2
- package/dist/Field/Field.d.ts.map +1 -1
- package/dist/Field/Field.js +22 -0
- package/dist/Field/Field.js.map +1 -1
- package/dist/Field/FieldGroup.d.ts +28 -3
- package/dist/Field/FieldGroup.d.ts.map +1 -1
- package/dist/Field/FieldGroup.js +5 -2
- package/dist/Field/FieldGroup.js.map +1 -1
- package/dist/Stepper/Stepper.d.ts +89 -0
- package/dist/Stepper/Stepper.d.ts.map +1 -0
- package/dist/Stepper/Stepper.js +87 -0
- package/dist/Stepper/Stepper.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/slotProps.d.ts +14 -1
- package/dist/slotProps.d.ts.map +1 -1
- package/dist/slotProps.js +13 -0
- package/dist/slotProps.js.map +1 -1
- package/package.json +1 -1
- package/src/Checkbox/Checkbox.mdx +32 -0
- package/src/Checkbox/Checkbox.stories.tsx +74 -0
- package/src/Checkbox/Checkbox.test.tsx +110 -2
- package/src/Checkbox/Checkbox.tsx +234 -125
- package/src/Field/Field.mdx +41 -0
- package/src/Field/Field.stories.tsx +79 -0
- package/src/Field/Field.test.tsx +137 -0
- package/src/Field/Field.tsx +99 -25
- package/src/Field/FieldGroup.tsx +60 -19
- package/src/Stepper/Stepper.mdx +86 -0
- package/src/Stepper/Stepper.stories.tsx +224 -0
- package/src/Stepper/Stepper.test.tsx +112 -0
- package/src/Stepper/Stepper.tsx +246 -0
- package/src/index.ts +7 -0
- package/src/slotProps.ts +16 -2
- package/src/sourceRules.test.ts +8 -1
package/src/Field/Field.test.tsx
CHANGED
|
@@ -13,6 +13,7 @@ const {
|
|
|
13
13
|
AllStates,
|
|
14
14
|
AllVariants,
|
|
15
15
|
Default,
|
|
16
|
+
ForwardsRestProps,
|
|
16
17
|
Group,
|
|
17
18
|
Nested,
|
|
18
19
|
} = composeStories(stories)
|
|
@@ -447,3 +448,139 @@ test("a group describes its error rather than asserting invalidity", async () =>
|
|
|
447
448
|
"A pattern needs at least one capture group.",
|
|
448
449
|
)
|
|
449
450
|
})
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* The gap this closes, stated as the two things that were impossible.
|
|
454
|
+
*
|
|
455
|
+
* `FieldProps` and `FieldGroupProps` were closed types, so the only
|
|
456
|
+
* prop that reached an element was `className` — which is the escape
|
|
457
|
+
* hatch the "configured by props, not a borrowed class" rule exists to
|
|
458
|
+
* close. A component that accepts only `className` forces the very
|
|
459
|
+
* thing the rule forbids, and queuepilot paid for it twice: a
|
|
460
|
+
* `FieldGroup` that had to give up the `id` its screenshot suite
|
|
461
|
+
* drives by, and a box beside it that stayed a hand-rolled
|
|
462
|
+
* `<fieldset>` because it needed `hidden`.
|
|
463
|
+
*
|
|
464
|
+
* `Field` clones its child, so its props are the **control's**. The
|
|
465
|
+
* assertion is which element they landed on, because that is the half
|
|
466
|
+
* that could have gone silently wrong: routing them to the wrapper
|
|
467
|
+
* would have moved every consumer's `id` off the control the
|
|
468
|
+
* `<label htmlFor>` points at.
|
|
469
|
+
*/
|
|
470
|
+
test("a rest prop reaches the control, not the box around it", async () => {
|
|
471
|
+
const { canvas, canvasElement } = await mountStory(
|
|
472
|
+
ForwardsRestProps,
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
const control = expectAgentDrivable(canvas, {
|
|
476
|
+
name: "Scratch path",
|
|
477
|
+
role: "textbox",
|
|
478
|
+
})
|
|
479
|
+
|
|
480
|
+
await expect(control).toHaveAttribute(
|
|
481
|
+
"name",
|
|
482
|
+
"scratchPath",
|
|
483
|
+
)
|
|
484
|
+
|
|
485
|
+
await expect(control).toHaveAttribute(
|
|
486
|
+
"placeholder",
|
|
487
|
+
"/mnt/scratch",
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
// …and the `<div>` did not take them. `Field`'s own `className` is
|
|
491
|
+
// the one prop that stays on the box, so the two destinations have
|
|
492
|
+
// to be distinguishable in the DOM rather than merely documented.
|
|
493
|
+
await expect(
|
|
494
|
+
canvasElement.querySelector("[name='scratchPath']"),
|
|
495
|
+
).toBe(control)
|
|
496
|
+
|
|
497
|
+
await expectNoAxeViolations(canvasElement)
|
|
498
|
+
})
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* `aria-describedby` is a **list**, and opening the type is what makes
|
|
502
|
+
* a caller able to write one at all. A plain spread would keep one
|
|
503
|
+
* side and drop the other — the same silent drop `mergeSlotProps`
|
|
504
|
+
* exists to prevent between two nested slots, arriving by a shorter
|
|
505
|
+
* route now that the outer writer can be the author.
|
|
506
|
+
*
|
|
507
|
+
* Order is behaviour, not formatting: what the caller passed is the
|
|
508
|
+
* outer declaration and reads first, then the field's own description,
|
|
509
|
+
* then its error.
|
|
510
|
+
*/
|
|
511
|
+
test("a caller's aria-describedby composes with the description and the error", async () => {
|
|
512
|
+
const { canvas } = await mountStory(ForwardsRestProps)
|
|
513
|
+
|
|
514
|
+
const control = expectAgentDrivable(canvas, {
|
|
515
|
+
name: "Scratch path",
|
|
516
|
+
role: "textbox",
|
|
517
|
+
})
|
|
518
|
+
|
|
519
|
+
const [policyId, descriptionId, errorId] = (
|
|
520
|
+
control.getAttribute("aria-describedby") ?? ""
|
|
521
|
+
).split(" ")
|
|
522
|
+
|
|
523
|
+
await expect(
|
|
524
|
+
document.getElementById(policyId ?? ""),
|
|
525
|
+
).toHaveTextContent("Cleared between runs.")
|
|
526
|
+
|
|
527
|
+
await expect(
|
|
528
|
+
document.getElementById(descriptionId ?? ""),
|
|
529
|
+
).toHaveTextContent("Absolute paths only.")
|
|
530
|
+
|
|
531
|
+
await expect(
|
|
532
|
+
document.getElementById(errorId ?? ""),
|
|
533
|
+
).toHaveTextContent("That path is not writable.")
|
|
534
|
+
|
|
535
|
+
// The error is still the only source of invalidity, and a caller's
|
|
536
|
+
// own description did not disturb it.
|
|
537
|
+
await expect(control).toHaveAttribute(
|
|
538
|
+
"aria-invalid",
|
|
539
|
+
"true",
|
|
540
|
+
)
|
|
541
|
+
})
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* The other reading of the same rule. `FieldGroup` renders its
|
|
545
|
+
* children as-is, so the only element it owns is the `<fieldset>` and
|
|
546
|
+
* a prop has nowhere else to go — including `disabled`, which on this
|
|
547
|
+
* element is not decoration: the platform disables every control
|
|
548
|
+
* inside it.
|
|
549
|
+
*
|
|
550
|
+
* This is the case queuepilot's `#dyn-lineup` needed and could not
|
|
551
|
+
* have: an `id` on the group's own element.
|
|
552
|
+
*/
|
|
553
|
+
test("a rest prop reaches the fieldset, and the fieldset disables what is inside it", async () => {
|
|
554
|
+
const { canvas, canvasElement } = await mountStory(
|
|
555
|
+
ForwardsRestProps,
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
const group = expectAgentDrivable(canvas, {
|
|
559
|
+
name: "Playback",
|
|
560
|
+
role: "group",
|
|
561
|
+
})
|
|
562
|
+
|
|
563
|
+
await expect(group).toHaveAttribute(
|
|
564
|
+
"id",
|
|
565
|
+
"playback-lineup",
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
await expect(group.tagName).toBe("FIELDSET")
|
|
569
|
+
|
|
570
|
+
// The `<legend>` still names the group, and the group's own
|
|
571
|
+
// description still reaches it, so the rest props did not overwrite
|
|
572
|
+
// the wiring they were spread beside.
|
|
573
|
+
await expect(
|
|
574
|
+
document.getElementById(
|
|
575
|
+
group.getAttribute("aria-describedby") ?? "",
|
|
576
|
+
),
|
|
577
|
+
).toHaveTextContent(
|
|
578
|
+
"The whole group is turned off by the element itself.",
|
|
579
|
+
)
|
|
580
|
+
|
|
581
|
+
await expect(
|
|
582
|
+
canvasElement.querySelector("input[type='number']"),
|
|
583
|
+
).toBeDisabled()
|
|
584
|
+
|
|
585
|
+
await expectNoAxeViolations(canvasElement)
|
|
586
|
+
})
|
package/src/Field/Field.tsx
CHANGED
|
@@ -2,36 +2,88 @@ import {
|
|
|
2
2
|
useClonedChild,
|
|
3
3
|
useUniqueId,
|
|
4
4
|
} from "@charcuterie/logic"
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
ComponentPropsWithRef,
|
|
7
|
+
ReactElement,
|
|
8
|
+
ReactNode,
|
|
9
|
+
Ref,
|
|
10
|
+
} from "react"
|
|
6
11
|
|
|
7
12
|
import type { SlotProps } from "../slotProps.ts"
|
|
8
13
|
import { mergeSlotProps } from "../slotProps.ts"
|
|
9
14
|
import { toClassName } from "../toClassName.ts"
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Everything else a caller writes on a `Field` reaches **the control
|
|
18
|
+
* it clones onto**, not the `<div>` around it.
|
|
19
|
+
*
|
|
20
|
+
* That is not a new destination, it is the existing one finally
|
|
21
|
+
* declared. `SlotProps` was a *closed* five-key type over a runtime
|
|
22
|
+
* that already spread `...receivedSlotProps` into the clone, so
|
|
23
|
+
* `name`, `placeholder`, `autoFocus`, `onBlur` and every `aria-*` all
|
|
24
|
+
* arrived at the `<input>` and none of them type-checked. The only
|
|
25
|
+
* prop a consumer could legally pass was `className` — which is the
|
|
26
|
+
* one escape hatch the fleet's "configured by props, not a borrowed
|
|
27
|
+
* class" rule is trying to close, so the closed type forced the very
|
|
28
|
+
* thing the rule forbids
|
|
29
|
+
* ([decision](../../../../docs/decisions/2026-08-21-a-slot-components-rest-props-are-the-controls-props.md)).
|
|
30
|
+
*
|
|
31
|
+
* `className` stays on the `<div>`, alone, because a class is a
|
|
32
|
+
* statement about the box a **parent** lays out
|
|
33
|
+
* ([decision](../../../../docs/decisions/2026-08-19-classname-is-the-outermost-box-a-component-renders.md)).
|
|
34
|
+
* Every other prop is a statement about the control, and `id` is the
|
|
35
|
+
* proof: it has named the control since the component shipped, and a
|
|
36
|
+
* dated record settles its precedence
|
|
37
|
+
* ([decision](../../../../docs/decisions/2026-08-05-field-adopts-the-childs-own-id.md)).
|
|
38
|
+
* Routing the rest to the `<div>` would have moved it, silently, in
|
|
39
|
+
* every consumer.
|
|
40
|
+
*
|
|
41
|
+
* `"input"` because `SlotProps` already picks from
|
|
42
|
+
* `InputHTMLAttributes` and this is the same set widened, not a
|
|
43
|
+
* second opinion about what a control is. `ref` is re-declared over
|
|
44
|
+
* `HTMLElement`: the child may be a `Picker`'s `<button>` or a
|
|
45
|
+
* `contenteditable` `<div>`, so `Ref<HTMLInputElement>` would be a
|
|
46
|
+
* narrower claim than the slot makes.
|
|
47
|
+
*/
|
|
48
|
+
type ForwardedControlProps = Omit<
|
|
49
|
+
ComponentPropsWithRef<"input">,
|
|
50
|
+
"children" | "className" | "ref"
|
|
51
|
+
>
|
|
52
|
+
|
|
53
|
+
export type FieldProps = ForwardedControlProps &
|
|
54
|
+
SlotProps & {
|
|
55
|
+
/**
|
|
56
|
+
* The control. **Cloned, not wrapped** — the same slot contract
|
|
57
|
+
* as `Popover`'s trigger, so a `Field` can go around an `<input>`,
|
|
58
|
+
* a `<textarea>`, a `Picker`, or an app's own control without
|
|
59
|
+
* changing that control's layout.
|
|
60
|
+
*/
|
|
61
|
+
children: ReactElement
|
|
62
|
+
/**
|
|
63
|
+
* The `<div>` around the label, the control and the messages —
|
|
64
|
+
* the one prop that does **not** reach the control.
|
|
65
|
+
*/
|
|
66
|
+
className?: string
|
|
67
|
+
/**
|
|
68
|
+
* Standing help — units, a format, a warning about what the value
|
|
69
|
+
* does. Announced with the control, before any error.
|
|
70
|
+
*/
|
|
71
|
+
description?: ReactNode
|
|
72
|
+
/**
|
|
73
|
+
* Present means invalid. There is no separate `isInvalid`, because
|
|
74
|
+
* two sources for one fact is how a control ends up
|
|
75
|
+
* `aria-invalid="true"` with nothing saying why — which is what
|
|
76
|
+
* `RegexWithFlagsField` does in mux-magic today.
|
|
77
|
+
*/
|
|
78
|
+
error?: ReactNode
|
|
79
|
+
isRequired?: boolean
|
|
80
|
+
label: ReactNode
|
|
81
|
+
/**
|
|
82
|
+
* Merged onto the control's own, never replacing it — the wiring
|
|
83
|
+
* rule `mergeSlotWiring` states for every slot.
|
|
84
|
+
*/
|
|
85
|
+
ref?: Ref<HTMLElement>
|
|
86
|
+
}
|
|
35
87
|
|
|
36
88
|
/**
|
|
37
89
|
* Sixteen files in the fleet spell a label, a control, and a hint,
|
|
@@ -108,6 +160,28 @@ export type FieldProps = SlotProps & {
|
|
|
108
160
|
* `SlotProps` arriving from an outer slot is forwarded down, and
|
|
109
161
|
* `aria-describedby` is merged rather than replaced.
|
|
110
162
|
* `slotProps.ts` has the reasoning.
|
|
163
|
+
*
|
|
164
|
+
* ### …and a pass-through cannot tell who wrote the prop
|
|
165
|
+
*
|
|
166
|
+
* Which is why the rest props are the **control's** props and not the
|
|
167
|
+
* `<div>`'s. `receivedSlotProps` below is one object holding two
|
|
168
|
+
* things that are indistinguishable at runtime: what a cloning
|
|
169
|
+
* ancestor injected, and what the author typed on the `Field` itself.
|
|
170
|
+
* A `Tooltip` above hands down `getReferenceProps()` — hover, focus
|
|
171
|
+
* and dismiss handlers, `refs.setReference`, and an
|
|
172
|
+
* `aria-describedby` naming the tip — and every bit of it has to
|
|
173
|
+
* reach the `<input>` at the bottom. Sending the rest to the wrapper
|
|
174
|
+
* would need a closed runtime allow-list to hold that case back, and
|
|
175
|
+
* an allow-list is `FieldTooltip`'s silent drop rebuilt inside the
|
|
176
|
+
* fix for it: the first slot that writes an `aria-expanded` is broken
|
|
177
|
+
* and nothing says so.
|
|
178
|
+
*
|
|
179
|
+
* So there is one rule, and it has no exceptions to remember:
|
|
180
|
+
* `className` is the box, everything else is the control. A caller
|
|
181
|
+
* that needs a handle on the **box** — an `id` for a screenshot, a
|
|
182
|
+
* `hidden` that takes the label with it — wants `FieldGroup`, which
|
|
183
|
+
* wraps rather than clones and whose rest props land on its own
|
|
184
|
+
* `<fieldset>`.
|
|
111
185
|
*/
|
|
112
186
|
export const Field = ({
|
|
113
187
|
children,
|
package/src/Field/FieldGroup.tsx
CHANGED
|
@@ -1,23 +1,53 @@
|
|
|
1
1
|
import { useUniqueId } from "@charcuterie/logic"
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
ComponentPropsWithRef,
|
|
4
|
+
ReactNode,
|
|
5
|
+
} from "react"
|
|
3
6
|
|
|
7
|
+
import { mergeSlotProps } from "../slotProps.ts"
|
|
4
8
|
import { toClassName } from "../toClassName.ts"
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Everything a caller writes on a `FieldGroup` reaches the
|
|
12
|
+
* `<fieldset>` — `id`, `hidden`, `data-*`, `aria-*`, `ref`, and the
|
|
13
|
+
* three attributes that are the element's own: `disabled`, `form`
|
|
14
|
+
* and `name`.
|
|
15
|
+
*
|
|
16
|
+
* This is the **opposite** destination from `Field`'s, and the
|
|
17
|
+
* difference is not a preference. `Field` clones onto its child, so
|
|
18
|
+
* its props are that control's props; `FieldGroup` renders its
|
|
19
|
+
* children as-is, so the only element it owns is the `<fieldset>` and
|
|
20
|
+
* a prop has nowhere else to go. One rule reads both:
|
|
21
|
+
* ***a component's props land on the element it owns***
|
|
22
|
+
* ([decision](../../../../docs/decisions/2026-08-21-a-slot-components-rest-props-are-the-controls-props.md)).
|
|
23
|
+
*
|
|
24
|
+
* `disabled` is worth knowing about before reaching for it. On a
|
|
25
|
+
* `<fieldset>` it is not decoration — the platform disables every
|
|
26
|
+
* form control inside the element, not just the box itself. That is
|
|
27
|
+
* usually what a caller wants and occasionally a surprise, and it is
|
|
28
|
+
* a thing a `<div>`-based group could not have offered at all.
|
|
29
|
+
*/
|
|
30
|
+
export type FieldGroupProps =
|
|
31
|
+
ComponentPropsWithRef<"fieldset"> & {
|
|
32
|
+
/**
|
|
33
|
+
* The controls. **Rendered as-is, not cloned** — that is the whole
|
|
34
|
+
* difference from `Field`, and it is why this is a separate
|
|
35
|
+
* component rather than a boolean on that one.
|
|
36
|
+
*/
|
|
37
|
+
children: ReactNode
|
|
38
|
+
/**
|
|
39
|
+
* The `<fieldset>`, which is also the outermost element this
|
|
40
|
+
* component renders — so `className` is not the exception here that
|
|
41
|
+
* it is on `Field`.
|
|
42
|
+
*/
|
|
43
|
+
className?: string
|
|
44
|
+
/** Standing help for the group as a whole. */
|
|
45
|
+
description?: ReactNode
|
|
46
|
+
/** Present means the group is invalid. */
|
|
47
|
+
error?: ReactNode
|
|
48
|
+
isRequired?: boolean
|
|
49
|
+
label: ReactNode
|
|
50
|
+
}
|
|
21
51
|
|
|
22
52
|
/**
|
|
23
53
|
* A label over **several** controls.
|
|
@@ -66,6 +96,7 @@ export const FieldGroup = ({
|
|
|
66
96
|
error,
|
|
67
97
|
isRequired = false,
|
|
68
98
|
label,
|
|
99
|
+
...receivedFieldsetProps
|
|
69
100
|
}: FieldGroupProps): ReactNode => {
|
|
70
101
|
const baseId = useUniqueId()
|
|
71
102
|
|
|
@@ -85,9 +116,19 @@ export const FieldGroup = ({
|
|
|
85
116
|
|
|
86
117
|
return (
|
|
87
118
|
<fieldset
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
119
|
+
/*
|
|
120
|
+
Through `mergeSlotProps`, not around it. A caller may now pass
|
|
121
|
+
an `aria-describedby` of its own, and that attribute is the
|
|
122
|
+
one prop in the set that is a **list** — a plain spread keeps
|
|
123
|
+
whichever side is written last and drops the other, silently,
|
|
124
|
+
which is the defect `mergeSlotProps` exists to prevent one
|
|
125
|
+
level down. Received first, then this group's description and
|
|
126
|
+
error, for the reason the ordering array above gives.
|
|
127
|
+
*/
|
|
128
|
+
{...mergeSlotProps(receivedFieldsetProps, {
|
|
129
|
+
"aria-describedby":
|
|
130
|
+
describedBy === "" ? undefined : describedBy,
|
|
131
|
+
})}
|
|
91
132
|
className={toClassName(
|
|
92
133
|
// A `<fieldset>` arrives with a border, an inline margin, a
|
|
93
134
|
// block padding, and `min-inline-size: min-content` — the
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Canvas, Controls, Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
import * as StepperStories from "./Stepper.stories";
|
|
4
|
+
|
|
5
|
+
<Meta of={StepperStories} />
|
|
6
|
+
|
|
7
|
+
# Stepper
|
|
8
|
+
|
|
9
|
+
An ordered sequence of steps, with **what belongs to each one** under it.
|
|
10
|
+
|
|
11
|
+
Docket asked for this. Its phases — *"these 3 cards have to be done in order"* — were a
|
|
12
|
+
hand-rolled numbered rail with a connector drawn in a `::before`, and a `ProgressBar` per
|
|
13
|
+
phase for the count. Neither says which things go together.
|
|
14
|
+
|
|
15
|
+
<Canvas of={StepperStories.Default} />
|
|
16
|
+
|
|
17
|
+
## Props
|
|
18
|
+
|
|
19
|
+
<Controls />
|
|
20
|
+
|
|
21
|
+
## Why a step carries content
|
|
22
|
+
|
|
23
|
+
This is the difference between a stepper and a progress bar with a legend. A bar says a
|
|
24
|
+
sequence is half done; only the contents say **which three things go together and which
|
|
25
|
+
one is next**.
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
<Stepper
|
|
29
|
+
label="Ingest sequence"
|
|
30
|
+
steps={phases.map((phase) => ({
|
|
31
|
+
content: <TaskList tasks={tasksIn(phase)} />,
|
|
32
|
+
description: gateReason(phase),
|
|
33
|
+
key: phase.id,
|
|
34
|
+
label: phase.name,
|
|
35
|
+
status: statusOf(phase),
|
|
36
|
+
}))}
|
|
37
|
+
/>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## The four statuses, and why `blocked` is not a worse `upcoming`
|
|
41
|
+
|
|
42
|
+
| Status | Means |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `done` | Finished. |
|
|
45
|
+
| `current` | Being worked on. |
|
|
46
|
+
| `upcoming` | Its turn has not come. |
|
|
47
|
+
| `blocked` | Its turn **has** come and something is in the way. |
|
|
48
|
+
|
|
49
|
+
The last two look alike and are not. `upcoming` is a thing to wait for; `blocked` is a
|
|
50
|
+
thing to go and fix, and collapsing them hides the second behind the first. Docket's case
|
|
51
|
+
is exact: a phase gated behind an *unfinished* phase is normal, and a phase gated behind an
|
|
52
|
+
**empty** one is a mistake somebody has to correct — the same grey pill for both is how
|
|
53
|
+
that sits unnoticed.
|
|
54
|
+
|
|
55
|
+
## Status is never colour alone
|
|
56
|
+
|
|
57
|
+
Four marker colours is four colours as far as assistive technology, a greyscale print and
|
|
58
|
+
the ePaper build are concerned — a WCAG 1.4.1 failure however clear it looks. So the status
|
|
59
|
+
reaches a screen reader as a **word**, in a `VisuallyHidden` beside the label, and gets a
|
|
60
|
+
second visual channel besides hue: a filled marker for finished work, an outlined one
|
|
61
|
+
ahead of it, and a connector that is solid behind and subdued in front.
|
|
62
|
+
|
|
63
|
+
## The marker is the ordinal, never a tick
|
|
64
|
+
|
|
65
|
+
This library
|
|
66
|
+
[ships no icons and no symbol glyphs](?path=/docs/guides-decisions--docs). A `✓` renders as
|
|
67
|
+
an empty box wherever the font lacks it — the sandbox chromium, the kiosk image, the ePaper
|
|
68
|
+
build — and an empty box in the "done" position reads as an *error*, which is the opposite
|
|
69
|
+
of what it meant. The ordinal always renders. An app that owns a glyph set passes one as
|
|
70
|
+
`marker`.
|
|
71
|
+
|
|
72
|
+
## `horizontal` is a request, not a promise
|
|
73
|
+
|
|
74
|
+
It collapses to the vertical column below `cq-md`. Four steps side by side in a narrow
|
|
75
|
+
container squash into `2. / De- / dupe` — measured, in the app this came out of, before any
|
|
76
|
+
of them contained anything. A step carrying `content` should stay vertical regardless: a
|
|
77
|
+
column cannot hold a list.
|
|
78
|
+
|
|
79
|
+
<Canvas of={StepperStories.Responsive} />
|
|
80
|
+
|
|
81
|
+
## There is nothing to focus
|
|
82
|
+
|
|
83
|
+
A stepper is a **document outline**, not a widget: an `<ol>` of headings. Advancing is the
|
|
84
|
+
app's operation and the component only reports where the sequence got to, so there is no
|
|
85
|
+
roving focus, no `aria-current` on a control, and nothing to arrow between. If your steps
|
|
86
|
+
are *navigable* — a checkout you can click back into — you want `Tabs`.
|