@manakind/ui-core 0.37.0 → 0.39.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 CHANGED
@@ -94,6 +94,7 @@ separately, so an app can load only what it renders.
94
94
  | `@manakind/ui-core/radio-group` | `RadioGroup` |
95
95
  | `@manakind/ui-core/scroll-area` | `ScrollArea` |
96
96
  | `@manakind/ui-core/status-dot` | `StatusDot`; a dot that marks something unread, live or new, with its meaning in words for assistive technology |
97
+ | `@manakind/ui-core/stepper` | `Stepper`; a row of numbered steps showing how far through a flow the reader is, complete steps checked and the current one outlined |
97
98
  | `@manakind/ui-core/sticky` | `Sticky` |
98
99
  | `@manakind/ui-core/empty-state` | `EmptyState` |
99
100
  | `@manakind/ui-core/page-layout` | `PageLayout`, `PageHeader`, `PageTitle`, `PageDescription`, `PageActions` |
@@ -141,6 +142,7 @@ separately, so an app can load only what it renders.
141
142
  | `@manakind/ui-core/css/radio-group` | RadioGroup structural CSS |
142
143
  | `@manakind/ui-core/css/scroll-area` | ScrollArea structural CSS |
143
144
  | `@manakind/ui-core/css/status-dot` | StatusDot structural CSS; its label also needs `css/visually-hidden` |
145
+ | `@manakind/ui-core/css/stepper` | Stepper structural CSS; a complete step's word also needs `css/visually-hidden`, its check `css/icon` |
144
146
  | `@manakind/ui-core/css/sticky` | Sticky structural CSS |
145
147
  | `@manakind/ui-core/css/empty-state` | EmptyState structural CSS; its glyph also needs `css/icon` |
146
148
  | `@manakind/ui-core/css/page-layout` | PageLayout structural CSS; its title and description also need `css/text` |
package/dist/index.d.ts CHANGED
@@ -41,6 +41,7 @@ export * from './slider';
41
41
  export * from './spinner';
42
42
  export * from './split-layout';
43
43
  export * from './status-dot';
44
+ export * from './stepper';
44
45
  export * from './sticky';
45
46
  export * from './switch';
46
47
  export * from './table';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aA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YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ export * from './slider';
40
40
  export * from './spinner';
41
41
  export * from './split-layout';
42
42
  export * from './status-dot';
43
+ export * from './stepper';
43
44
  export * from './sticky';
44
45
  export * from './switch';
45
46
  export * from './table';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,EACtB,GAAG,IAAI,WAAW,GACnB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAEvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './accordion';\nexport * from './alert';\nexport * from './avatar';\nexport * from './badge';\nexport * from './breadcrumb';\nexport * from './button';\nexport * from './calendar';\nexport * from './card';\nexport * from './centered-layout';\nexport * from './checkbox';\nexport * from './combobox';\nexport { cx } from './cx';\nexport * from './date-input';\nexport * from './dialog';\nexport * from './divider';\nexport * from './empty-state';\nexport {\n Check as FallbackCheck,\n ChevronLeft as FallbackChevronLeft,\n ChevronRight as FallbackChevronRight,\n Cross as FallbackCross,\n Pin as FallbackPin,\n} from './fallback-glyphs';\nexport * from './field';\nexport * from './form-layout';\nexport * from './icon';\nexport * from './icon-defaults';\nexport * from './illustration';\nexport * from './layout';\nexport * from './link';\nexport type { LinkComponentProps } from './link-component';\nexport * from './menu';\nexport * from './nav-list';\nexport * from './page-layout';\nexport * from './popover';\nexport * from './progress';\nexport * from './radio-group';\nexport * from './reorder-control';\nexport * from './scroll-area';\nexport * from './section';\nexport * from './segment-group';\nexport * from './select';\nexport * from './show';\nexport * from './side-panel-layout';\nexport * from './skeleton';\nexport * from './slider';\nexport * from './spinner';\nexport * from './split-layout';\nexport * from './status-dot';\nexport * from './sticky';\nexport * from './switch';\nexport * from './table';\nexport * from './tabs';\nexport * from './text';\nexport * from './tooltip';\nexport * from './visually-hidden';\nexport * from './wizard-layout';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,EACtB,GAAG,IAAI,WAAW,GACnB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAEvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './accordion';\nexport * from './alert';\nexport * from './avatar';\nexport * from './badge';\nexport * from './breadcrumb';\nexport * from './button';\nexport * from './calendar';\nexport * from './card';\nexport * from './centered-layout';\nexport * from './checkbox';\nexport * from './combobox';\nexport { cx } from './cx';\nexport * from './date-input';\nexport * from './dialog';\nexport * from './divider';\nexport * from './empty-state';\nexport {\n Check as FallbackCheck,\n ChevronLeft as FallbackChevronLeft,\n ChevronRight as FallbackChevronRight,\n Cross as FallbackCross,\n Pin as FallbackPin,\n} from './fallback-glyphs';\nexport * from './field';\nexport * from './form-layout';\nexport * from './icon';\nexport * from './icon-defaults';\nexport * from './illustration';\nexport * from './layout';\nexport * from './link';\nexport type { LinkComponentProps } from './link-component';\nexport * from './menu';\nexport * from './nav-list';\nexport * from './page-layout';\nexport * from './popover';\nexport * from './progress';\nexport * from './radio-group';\nexport * from './reorder-control';\nexport * from './scroll-area';\nexport * from './section';\nexport * from './segment-group';\nexport * from './select';\nexport * from './show';\nexport * from './side-panel-layout';\nexport * from './skeleton';\nexport * from './slider';\nexport * from './spinner';\nexport * from './split-layout';\nexport * from './status-dot';\nexport * from './stepper';\nexport * from './sticky';\nexport * from './switch';\nexport * from './table';\nexport * from './tabs';\nexport * from './text';\nexport * from './tooltip';\nexport * from './visually-hidden';\nexport * from './wizard-layout';\n"]}
@@ -11,10 +11,15 @@
11
11
  font-size: var(--ds-radio-group-label-font-size);
12
12
  }
13
13
 
14
+ /*
15
+ * Two columns, the radio and then its label with any description under
16
+ * it, so a description that wraps lines up with the label, not the circle.
17
+ */
14
18
  & .ds-radio-group__item {
15
- display: inline-flex;
19
+ display: inline-grid;
20
+ grid-template-columns: auto minmax(0, 1fr);
16
21
  align-items: center;
17
- gap: var(--ds-radio-group-label-gap);
22
+ column-gap: var(--ds-radio-group-label-gap);
18
23
  max-width: 100%;
19
24
  color: var(--ds-radio-group-label-text);
20
25
  font-size: var(--ds-radio-group-label-font-size);
@@ -25,6 +30,13 @@
25
30
  }
26
31
  }
27
32
 
33
+ /* The hint text of a Field: a choice's description reads as the hint under a label. */
34
+ & .ds-radio-group__description {
35
+ grid-column: 2;
36
+ color: var(--ds-field-hint-text);
37
+ font-size: var(--ds-field-hint-font-size);
38
+ }
39
+
28
40
  /*
29
41
  * Checked, the circle fills with the primary and a dot in the primary's
30
42
  * own text colour sits in it, as a checked Checkbox's box holds its check.
@@ -33,7 +45,6 @@
33
45
  & .ds-radio-group__control {
34
46
  box-sizing: border-box;
35
47
  position: relative;
36
- flex-shrink: 0;
37
48
  inline-size: var(--ds-radio-group-control-size);
38
49
  block-size: var(--ds-radio-group-control-size);
39
50
  border: 1px solid var(--ds-radio-group-control-border);
@@ -86,6 +97,7 @@
86
97
 
87
98
  & .ds-radio-group__item {
88
99
  box-sizing: border-box;
100
+ display: flex;
89
101
  flex-direction: column;
90
102
  justify-content: center;
91
103
  gap: var(--ds-radio-group-card-gap);
@@ -5,6 +5,13 @@ export interface RadioGroupItem {
5
5
  value: string;
6
6
  /** Text beside the radio. The whole row is its click target. */
7
7
  label: string;
8
+ /**
9
+ * A sentence under the label saying what the choice means, in the muted
10
+ * hint text of a Field. The radio's accessible description; its name
11
+ * stays the label alone. A list group shows it; a cards group, which
12
+ * shows `visual` instead, ignores it.
13
+ */
14
+ description?: string;
8
15
  /** Individually disable this choice without removing it. */
9
16
  disabled?: boolean;
10
17
  /**
@@ -82,6 +89,30 @@ export type RadioGroupProps = RadioGroupName & {
82
89
  * />
83
90
  * ```
84
91
  *
92
+ * A choice whose label alone would not say what it does takes a
93
+ * `description`, a sentence set under the label and read as the radio's
94
+ * description:
95
+ *
96
+ * ```tsx
97
+ * <RadioGroup
98
+ * label="Completing a task"
99
+ * items={[
100
+ * {
101
+ * value: 'archive',
102
+ * label: 'Archive',
103
+ * description: 'Done tasks leave the list and stay searchable.',
104
+ * },
105
+ * {
106
+ * value: 'keep',
107
+ * label: 'Keep in place',
108
+ * description: 'Done tasks stay where they are, struck through.',
109
+ * },
110
+ * ]}
111
+ * value={mode}
112
+ * onValueChange={setMode}
113
+ * />
114
+ * ```
115
+ *
85
116
  * Choices told apart by how they look (a colour, a theme) take
86
117
  * `appearance="cards"`, each with a `visual`. A few short choices seen at
87
118
  * once in a row are a `SegmentGroup`; a long list, or one in a form row, is
@@ -1 +1 @@
1
- {"version":3,"file":"radio-group.d.ts","sourceRoot":"","sources":["../../src/radio-group/radio-group.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAU,MAAM,OAAO,CAAC;AAC/C,OAAO,mBAAmB,CAAC;AA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SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,KAAK,EACL,KAAK,EACL,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,UAAmB,EACnB,SAAS,EACT,YAAY,EAAE,SAAS,GACxB,EAAE,eAAe,2CAkEjB"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { RadioGroup as ArkRadioGroup } from '@ark-ui/react/radio-group';
3
- import { useRef } from 'react';
3
+ import { useId, useRef } from 'react';
4
4
  import './radio-group.css';
5
5
  import { radioGroupChangeHandler, renderVisibleLabel } from '../ark-native-input';
6
6
  import { cx } from '../cx';
@@ -26,6 +26,30 @@ import { cx } from '../cx';
26
26
  * />
27
27
  * ```
28
28
  *
29
+ * A choice whose label alone would not say what it does takes a
30
+ * `description`, a sentence set under the label and read as the radio's
31
+ * description:
32
+ *
33
+ * ```tsx
34
+ * <RadioGroup
35
+ * label="Completing a task"
36
+ * items={[
37
+ * {
38
+ * value: 'archive',
39
+ * label: 'Archive',
40
+ * description: 'Done tasks leave the list and stay searchable.',
41
+ * },
42
+ * {
43
+ * value: 'keep',
44
+ * label: 'Keep in place',
45
+ * description: 'Done tasks stay where they are, struck through.',
46
+ * },
47
+ * ]}
48
+ * value={mode}
49
+ * onValueChange={setMode}
50
+ * />
51
+ * ```
52
+ *
29
53
  * Choices told apart by how they look (a colour, a theme) take
30
54
  * `appearance="cards"`, each with a `visual`. A few short choices seen at
31
55
  * once in a row are a `SegmentGroup`; a long list, or one in a form row, is
@@ -34,6 +58,7 @@ import { cx } from '../cx';
34
58
  export function RadioGroup({ label, items, value, defaultValue, onValueChange, disabled, name, appearance = 'list', className, 'aria-label': ariaLabel, }) {
35
59
  const cards = appearance === 'cards';
36
60
  const rootRef = useRef(null);
61
+ const descriptionId = useId();
37
62
  const handleValueChange = radioGroupChangeHandler(rootRef, value, onValueChange);
38
63
  const visibleLabel = renderVisibleLabel(ArkRadioGroup.Label, {
39
64
  label,
@@ -41,7 +66,10 @@ export function RadioGroup({ label, items, value, defaultValue, onValueChange, d
41
66
  className: 'ds-radio-group__label',
42
67
  });
43
68
  const marker = (item) => cards ? (_jsx("span", { className: "ds-radio-group__visual", "aria-hidden": true, children: item.visual })) : (_jsx(ArkRadioGroup.ItemControl, { className: "ds-radio-group__control" }));
44
- const renderItem = (item) => (_jsxs(ArkRadioGroup.Item, { value: item.value, disabled: item.disabled, className: "ds-radio-group__item", children: [marker(item), _jsx(ArkRadioGroup.ItemText, { className: "ds-radio-group__text", children: item.label }), _jsx(ArkRadioGroup.ItemHiddenInput, {})] }, item.value));
69
+ const renderItem = (item, index) => {
70
+ const describedBy = !cards && item.description ? `${descriptionId}-${index}` : undefined;
71
+ return (_jsxs(ArkRadioGroup.Item, { value: item.value, disabled: item.disabled, className: "ds-radio-group__item", children: [marker(item), _jsx(ArkRadioGroup.ItemText, { className: "ds-radio-group__text", children: item.label }), describedBy && (_jsx("span", { id: describedBy, className: "ds-radio-group__description", children: item.description })), _jsx(ArkRadioGroup.ItemHiddenInput, { "aria-describedby": describedBy })] }, item.value));
72
+ };
45
73
  const choices = cards ? (_jsx("div", { className: "ds-radio-group__cards", children: items.map(renderItem) })) : (items.map(renderItem));
46
74
  return (_jsxs(ArkRadioGroup.Root, { ref: rootRef, className: cx('ds-radio-group', cards && 'ds-radio-group--cards', className), value: value, defaultValue: defaultValue, onValueChange: handleValueChange, disabled: disabled, name: name, orientation: "vertical", "aria-label": ariaLabel, children: [visibleLabel, choices] }));
47
75
  }
@@ -1 +1 @@
1
- {"version":3,"file":"radio-group.js","sourceRoot":"","sources":["../../src/radio-group/radio-group.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACxE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BAAsB,YAAE,IAAI,CAAC,KAAK,GAA0B,EAC9F,KAAC,aAAa,CAAC,eAAe,KAAG,KAP5B,IAAI,CAAC,KAAK,CAQI,CACtB,CAAC;IAEF,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CACtB,cAAK,SAAS,EAAC,uBAAuB,YAAE,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAO,CACrE,CAAC,CAAC,CAAC,CACF,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CACtB,CAAC;IAEF,OAAO,CACL,MAAC,aAAa,CAAC,IAAI,IACjB,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,KAAK,IAAI,uBAAuB,EAAE,SAAS,CAAC,EAC5E,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,iBAAiB,EAChC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,WAAW,EAAC,UAAU,gBACV,SAAS,aAEpB,YAAY,EACZ,OAAO,IACW,CACtB,CAAC;AACJ,CAAC","sourcesContent":["import { RadioGroup as ArkRadioGroup } from '@ark-ui/react/radio-group';\nimport { type ReactNode, useRef } from 'react';\nimport './radio-group.css';\nimport { radioGroupChangeHandler, renderVisibleLabel } from '../ark-native-input';\nimport { cx } from '../cx';\n\nexport interface RadioGroupItem {\n /** Stable value reported by `onValueChange` and compared with `value`. */\n value: string;\n /** Text beside the radio. The whole row is its click target. */\n label: string;\n /** Individually disable this choice without removing it. */\n disabled?: boolean;\n /**\n * A picture of the choice, above its label on a `cards` group: a swatch,\n * a badge, a preview. Decorative: the label names the choice. A `list`\n * group ignores it.\n */\n visual?: ReactNode;\n}\n\n/** `list` (default) sets radios one under the other; `cards` sets each choice on a card in a wrapping grid. */\nexport type RadioGroupAppearance = 'list' | 'cards';\n\n/**\n * A radio group has to have a name, expressed as a union so an unnamed group\n * is a compile error rather than an axe finding, as `SegmentGroup` does.\n */\ntype RadioGroupName =\n | {\n /** Visible label, above the choices, naming the group. */\n label: ReactNode;\n /**\n * A different accessible name when the visible label alone would not\n * say what the choice is. Keep the visible words in it.\n */\n 'aria-label'?: string;\n }\n | {\n label?: undefined;\n /** Accessible name when a heading or a section title around it already says what the choice is. */\n 'aria-label': string;\n };\n\nexport type RadioGroupProps = RadioGroupName & {\n /** The choices, in order. */\n items: RadioGroupItem[];\n /**\n * `list` (default) sets a radio beside each label, one under the other.\n * `cards` sets each choice on a card, its `visual` above its label, in a\n * grid that fills the width and wraps; the chosen card carries a heavier\n * ring instead of a radio. For choices told apart by how they look, such\n * as colours or themes.\n */\n appearance?: RadioGroupAppearance;\n /**\n * Controlled value. `null` is controlled with nothing chosen; `undefined`\n * leaves the component to own its value from `defaultValue` onward.\n */\n value?: string | null;\n /** Initial value when uncontrolled. */\n defaultValue?: string;\n /** Fired with the newly chosen value. Choosing the chosen one again does nothing. */\n onValueChange?: (value: string) => void;\n /** Disable every choice. The chosen one keeps showing which is set. */\n disabled?: boolean;\n /** Name for native form participation through the radio inputs. */\n name?: string;\n /** Extra class names appended after `ds-radio-group`. */\n className?: string;\n};\n\n/**\n * One choice among several, as a column of radios, built on Ark UI's\n * RadioGroup: a filter's period, a setting with a handful of options whose\n * labels are worth reading side by side.\n *\n * Ark owns the behaviour: native radio inputs carry the state, the arrow keys\n * move the choice and Tab leaves the group in one step. This wrapper\n * contributes `ds-` classes, the `--ds-radio-group-*` bindings and a flat\n * `items` API.\n *\n * ```tsx\n * <RadioGroup\n * aria-label=\"Scheduled in\"\n * items={[\n * { value: 'any', label: 'Any time' },\n * { value: 'this-week', label: 'This week' },\n * ]}\n * value={when}\n * onValueChange={setWhen}\n * />\n * ```\n *\n * Choices told apart by how they look (a colour, a theme) take\n * `appearance=\"cards\"`, each with a `visual`. A few short choices seen at\n * once in a row are a `SegmentGroup`; a long list, or one in a form row, is\n * a `Select`.\n */\nexport function RadioGroup({\n label,\n items,\n value,\n defaultValue,\n onValueChange,\n disabled,\n name,\n appearance = 'list',\n className,\n 'aria-label': ariaLabel,\n}: RadioGroupProps) {\n const cards = appearance === 'cards';\n const rootRef = useRef<HTMLDivElement>(null);\n\n const handleValueChange = radioGroupChangeHandler(rootRef, value, onValueChange);\n\n const visibleLabel = renderVisibleLabel(ArkRadioGroup.Label, {\n label,\n ariaLabel,\n className: 'ds-radio-group__label',\n });\n\n const marker = (item: RadioGroupItem) =>\n cards ? (\n <span className=\"ds-radio-group__visual\" aria-hidden>\n {item.visual}\n </span>\n ) : (\n <ArkRadioGroup.ItemControl className=\"ds-radio-group__control\" />\n );\n const renderItem = (item: RadioGroupItem) => (\n <ArkRadioGroup.Item\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n className=\"ds-radio-group__item\"\n >\n {marker(item)}\n <ArkRadioGroup.ItemText className=\"ds-radio-group__text\">{item.label}</ArkRadioGroup.ItemText>\n <ArkRadioGroup.ItemHiddenInput />\n </ArkRadioGroup.Item>\n );\n\n const choices = cards ? (\n <div className=\"ds-radio-group__cards\">{items.map(renderItem)}</div>\n ) : (\n items.map(renderItem)\n );\n\n return (\n <ArkRadioGroup.Root\n ref={rootRef}\n className={cx('ds-radio-group', cards && 'ds-radio-group--cards', className)}\n value={value}\n defaultValue={defaultValue}\n onValueChange={handleValueChange}\n disabled={disabled}\n name={name}\n orientation=\"vertical\"\n aria-label={ariaLabel}\n >\n {visibleLabel}\n {choices}\n </ArkRadioGroup.Root>\n );\n}\n"]}
1
+ {"version":3,"file":"radio-group.js","sourceRoot":"","sources":["../../src/radio-group/radio-group.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAkB,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,mBAAmB,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,EAAE,E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AAI,CAAC,EACb,KAAC,aAAa,CAAC,QAAQ,IAAC,SAAS,EAAC,sBAAsB,YACrD,IAAI,CAAC,KAAK,GACY,EACxB,WAAW,IAAI,CACd,eAAM,EAAE,EAAE,WAAW,EAAE,SAAS,EAAC,6BAA6B,YAC3D,IAAI,CAAC,WAAW,GACZ,CACR,EACD,KAAC,aAAa,CAAC,eAAe,wBAAmB,WAAW,GAAI,KAd3D,IAAI,CAAC,KAAK,CAeI,CACtB,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CACtB,cAAK,SAAS,EAAC,uBAAuB,YAAE,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAO,CACrE,CAAC,CAAC,CAAC,CACF,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CACtB,CAAC;IAEF,OAAO,CACL,MAAC,aAAa,CAAC,IAAI,IACjB,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,KAAK,IAAI,uBAAuB,EAAE,SAAS,CAAC,EAC5E,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,iBAAiB,EAChC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,WAAW,EAAC,UAAU,gBACV,SAAS,aAEpB,YAAY,EACZ,OAAO,IACW,CACtB,CAAC;AACJ,CAAC","sourcesContent":["import { RadioGroup as ArkRadioGroup } from '@ark-ui/react/radio-group';\nimport { type ReactNode, useId, useRef } from 'react';\nimport './radio-group.css';\nimport { radioGroupChangeHandler, renderVisibleLabel } from '../ark-native-input';\nimport { cx } from '../cx';\n\nexport interface RadioGroupItem {\n /** Stable value reported by `onValueChange` and compared with `value`. */\n value: string;\n /** Text beside the radio. The whole row is its click target. */\n label: string;\n /**\n * A sentence under the label saying what the choice means, in the muted\n * hint text of a Field. The radio's accessible description; its name\n * stays the label alone. A list group shows it; a cards group, which\n * shows `visual` instead, ignores it.\n */\n description?: string;\n /** Individually disable this choice without removing it. */\n disabled?: boolean;\n /**\n * A picture of the choice, above its label on a `cards` group: a swatch,\n * a badge, a preview. Decorative: the label names the choice. A `list`\n * group ignores it.\n */\n visual?: ReactNode;\n}\n\n/** `list` (default) sets radios one under the other; `cards` sets each choice on a card in a wrapping grid. */\nexport type RadioGroupAppearance = 'list' | 'cards';\n\n/**\n * A radio group has to have a name, expressed as a union so an unnamed group\n * is a compile error rather than an axe finding, as `SegmentGroup` does.\n */\ntype RadioGroupName =\n | {\n /** Visible label, above the choices, naming the group. */\n label: ReactNode;\n /**\n * A different accessible name when the visible label alone would not\n * say what the choice is. Keep the visible words in it.\n */\n 'aria-label'?: string;\n }\n | {\n label?: undefined;\n /** Accessible name when a heading or a section title around it already says what the choice is. */\n 'aria-label': string;\n };\n\nexport type RadioGroupProps = RadioGroupName & {\n /** The choices, in order. */\n items: RadioGroupItem[];\n /**\n * `list` (default) sets a radio beside each label, one under the other.\n * `cards` sets each choice on a card, its `visual` above its label, in a\n * grid that fills the width and wraps; the chosen card carries a heavier\n * ring instead of a radio. For choices told apart by how they look, such\n * as colours or themes.\n */\n appearance?: RadioGroupAppearance;\n /**\n * Controlled value. `null` is controlled with nothing chosen; `undefined`\n * leaves the component to own its value from `defaultValue` onward.\n */\n value?: string | null;\n /** Initial value when uncontrolled. */\n defaultValue?: string;\n /** Fired with the newly chosen value. Choosing the chosen one again does nothing. */\n onValueChange?: (value: string) => void;\n /** Disable every choice. The chosen one keeps showing which is set. */\n disabled?: boolean;\n /** Name for native form participation through the radio inputs. */\n name?: string;\n /** Extra class names appended after `ds-radio-group`. */\n className?: string;\n};\n\n/**\n * One choice among several, as a column of radios, built on Ark UI's\n * RadioGroup: a filter's period, a setting with a handful of options whose\n * labels are worth reading side by side.\n *\n * Ark owns the behaviour: native radio inputs carry the state, the arrow keys\n * move the choice and Tab leaves the group in one step. This wrapper\n * contributes `ds-` classes, the `--ds-radio-group-*` bindings and a flat\n * `items` API.\n *\n * ```tsx\n * <RadioGroup\n * aria-label=\"Scheduled in\"\n * items={[\n * { value: 'any', label: 'Any time' },\n * { value: 'this-week', label: 'This week' },\n * ]}\n * value={when}\n * onValueChange={setWhen}\n * />\n * ```\n *\n * A choice whose label alone would not say what it does takes a\n * `description`, a sentence set under the label and read as the radio's\n * description:\n *\n * ```tsx\n * <RadioGroup\n * label=\"Completing a task\"\n * items={[\n * {\n * value: 'archive',\n * label: 'Archive',\n * description: 'Done tasks leave the list and stay searchable.',\n * },\n * {\n * value: 'keep',\n * label: 'Keep in place',\n * description: 'Done tasks stay where they are, struck through.',\n * },\n * ]}\n * value={mode}\n * onValueChange={setMode}\n * />\n * ```\n *\n * Choices told apart by how they look (a colour, a theme) take\n * `appearance=\"cards\"`, each with a `visual`. A few short choices seen at\n * once in a row are a `SegmentGroup`; a long list, or one in a form row, is\n * a `Select`.\n */\nexport function RadioGroup({\n label,\n items,\n value,\n defaultValue,\n onValueChange,\n disabled,\n name,\n appearance = 'list',\n className,\n 'aria-label': ariaLabel,\n}: RadioGroupProps) {\n const cards = appearance === 'cards';\n const rootRef = useRef<HTMLDivElement>(null);\n const descriptionId = useId();\n\n const handleValueChange = radioGroupChangeHandler(rootRef, value, onValueChange);\n\n const visibleLabel = renderVisibleLabel(ArkRadioGroup.Label, {\n label,\n ariaLabel,\n className: 'ds-radio-group__label',\n });\n\n const marker = (item: RadioGroupItem) =>\n cards ? (\n <span className=\"ds-radio-group__visual\" aria-hidden>\n {item.visual}\n </span>\n ) : (\n <ArkRadioGroup.ItemControl className=\"ds-radio-group__control\" />\n );\n const renderItem = (item: RadioGroupItem, index: number) => {\n const describedBy = !cards && item.description ? `${descriptionId}-${index}` : undefined;\n return (\n <ArkRadioGroup.Item\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n className=\"ds-radio-group__item\"\n >\n {marker(item)}\n <ArkRadioGroup.ItemText className=\"ds-radio-group__text\">\n {item.label}\n </ArkRadioGroup.ItemText>\n {describedBy && (\n <span id={describedBy} className=\"ds-radio-group__description\">\n {item.description}\n </span>\n )}\n <ArkRadioGroup.ItemHiddenInput aria-describedby={describedBy} />\n </ArkRadioGroup.Item>\n );\n };\n\n const choices = cards ? (\n <div className=\"ds-radio-group__cards\">{items.map(renderItem)}</div>\n ) : (\n items.map(renderItem)\n );\n\n return (\n <ArkRadioGroup.Root\n ref={rootRef}\n className={cx('ds-radio-group', cards && 'ds-radio-group--cards', className)}\n value={value}\n defaultValue={defaultValue}\n onValueChange={handleValueChange}\n disabled={disabled}\n name={name}\n orientation=\"vertical\"\n aria-label={ariaLabel}\n >\n {visibleLabel}\n {choices}\n </ArkRadioGroup.Root>\n );\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export type { StepperProps } from './stepper';
2
+ export { Stepper } from './stepper';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stepper/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Stepper } from './stepper';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stepper/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC","sourcesContent":["export type { StepperProps } from './stepper';\nexport { Stepper } from './stepper';\n"]}
@@ -0,0 +1,169 @@
1
+ @layer components {
2
+ .ds-stepper {
3
+ container: ds-stepper / inline-size;
4
+ display: flex;
5
+ flex-direction: column;
6
+ gap: var(--ds-stepper-gap);
7
+ }
8
+
9
+ /*
10
+ * The steps share the row evenly. Each spans the same two rows (marker,
11
+ * name) through subgrid, so a name that wraps never pushes its marker off
12
+ * the line.
13
+ */
14
+ .ds-stepper__list {
15
+ display: grid;
16
+ grid-template-rows: repeat(2, auto);
17
+ grid-auto-columns: minmax(0, 1fr);
18
+ grid-auto-flow: column;
19
+ row-gap: var(--ds-stepper-gap);
20
+ margin: 0;
21
+ padding: 0;
22
+ list-style: none;
23
+ }
24
+
25
+ .ds-stepper__step {
26
+ position: relative;
27
+ display: grid;
28
+ grid-row: span 2;
29
+ grid-template-rows: subgrid;
30
+ justify-items: center;
31
+ row-gap: var(--ds-stepper-gap);
32
+ min-inline-size: 0;
33
+ text-align: center;
34
+ }
35
+
36
+ /*
37
+ * The line joins each marker to the next and stops at their edges, so no
38
+ * marker needs a fill to hide it: every step draws its half on each side,
39
+ * except the first's start and the last's end.
40
+ */
41
+ .ds-stepper__track {
42
+ --_reach: calc(50% + var(--ds-stepper-marker-size) / 2);
43
+
44
+ position: relative;
45
+ display: flex;
46
+ justify-content: center;
47
+ justify-self: stretch;
48
+
49
+ &::before,
50
+ &::after {
51
+ content: "";
52
+ position: absolute;
53
+ inset-block-start: calc(50% - var(--ds-stepper-line-width) / 2);
54
+ block-size: var(--ds-stepper-line-width);
55
+ background-color: var(--ds-stepper-line);
56
+ }
57
+
58
+ &::before {
59
+ inset-inline: 0 var(--_reach);
60
+ }
61
+
62
+ &::after {
63
+ inset-inline: var(--_reach) 0;
64
+ }
65
+ }
66
+
67
+ .ds-stepper__step:first-child .ds-stepper__track::before,
68
+ .ds-stepper__step:last-child .ds-stepper__track::after {
69
+ content: none;
70
+ }
71
+
72
+ /*
73
+ * Only a complete marker fills, and only the current one draws a ring;
74
+ * the steps ahead show their number alone.
75
+ */
76
+ .ds-stepper__marker {
77
+ box-sizing: border-box;
78
+ position: relative;
79
+ display: grid;
80
+ place-items: center;
81
+ inline-size: var(--ds-stepper-marker-size);
82
+ block-size: var(--ds-stepper-marker-size);
83
+ border: var(--ds-stepper-line-width) solid transparent;
84
+ border-radius: 50%;
85
+ color: var(--ds-stepper-marker-text);
86
+ font-size: var(--ds-stepper-label-font-size);
87
+ font-variant-numeric: tabular-nums;
88
+ }
89
+
90
+ .ds-stepper__step--complete .ds-stepper__marker {
91
+ border-color: var(--ds-stepper-complete-bg);
92
+ background-color: var(--ds-stepper-complete-bg);
93
+ color: var(--ds-stepper-complete-text);
94
+ }
95
+
96
+ .ds-stepper__step--current .ds-stepper__marker {
97
+ border-color: var(--ds-stepper-marker-ring);
98
+ color: var(--ds-stepper-marker-text-strong);
99
+ font-weight: var(--ds-stepper-label-font-weight-strong);
100
+ }
101
+
102
+ .ds-stepper__label {
103
+ max-inline-size: 100%;
104
+ color: var(--ds-stepper-label-text);
105
+ font-size: var(--ds-stepper-label-font-size);
106
+ overflow-wrap: anywhere;
107
+ }
108
+
109
+ .ds-stepper__step--current .ds-stepper__label {
110
+ font-weight: var(--ds-stepper-label-font-weight-strong);
111
+ }
112
+
113
+ .ds-stepper__step--upcoming .ds-stepper__label {
114
+ color: var(--ds-stepper-label-text-muted);
115
+ }
116
+
117
+ /* Wide, every step's name sits under its marker, so the caption is not needed. */
118
+ .ds-stepper__caption {
119
+ display: none;
120
+ margin: 0;
121
+ color: var(--ds-stepper-label-text);
122
+ font-size: var(--ds-stepper-label-font-size);
123
+ font-weight: var(--ds-stepper-label-font-weight-strong);
124
+ overflow-wrap: anywhere;
125
+ }
126
+
127
+ /*
128
+ * Narrow, a column is too slim for a name: the row keeps only its markers
129
+ * and the current step's name shows on the caption's line below. The
130
+ * names are clipped rather than removed, so the list still reads every
131
+ * step; the caption is hidden from assistive technology, which would hear
132
+ * the name twice.
133
+ */
134
+ @container ds-stepper (max-width: 36rem) {
135
+ .ds-stepper__list,
136
+ .ds-stepper__step {
137
+ row-gap: 0;
138
+ }
139
+
140
+ .ds-stepper__label {
141
+ position: absolute;
142
+ inline-size: 1px;
143
+ block-size: 1px;
144
+ overflow: hidden;
145
+ clip-path: inset(50%);
146
+ white-space: nowrap;
147
+ }
148
+
149
+ .ds-stepper__caption {
150
+ display: block;
151
+ }
152
+ }
153
+
154
+ /*
155
+ * Forced colours drop the fills, so complete and current markers ring in
156
+ * the text colour, a complete one keeps its check, and the steps ahead
157
+ * stay bare: status still shows in shape.
158
+ */
159
+ @media (forced-colors: active) {
160
+ .ds-stepper__step--complete .ds-stepper__marker,
161
+ .ds-stepper__step--current .ds-stepper__marker {
162
+ border-color: currentColor;
163
+ }
164
+
165
+ .ds-stepper__step--upcoming .ds-stepper__marker {
166
+ border-style: none;
167
+ }
168
+ }
169
+ }
@@ -0,0 +1,2 @@
1
+ /* AUTOGENERATED: types for the stylesheet beside it. */
2
+ export {};
@@ -0,0 +1,41 @@
1
+ import './stepper.css';
2
+ export interface StepperProps {
3
+ /** Names the list of steps, e.g. "Weekly plan steps". */
4
+ 'aria-label': string;
5
+ /** Each step's name, in order. */
6
+ steps: string[];
7
+ /**
8
+ * The index of the step the reader is on. Every step before it is
9
+ * complete; `steps.length` marks them all complete, for a finished flow.
10
+ */
11
+ current: number;
12
+ /** Words said after a complete step's name, e.g. "Done". */
13
+ completeLabel: string;
14
+ /** Extra class names on the outermost element. */
15
+ className?: string;
16
+ }
17
+ /**
18
+ * A row of numbered steps on a line, showing how far through a flow the
19
+ * reader is: steps already taken are filled and checked, the current one is
20
+ * outlined, and the steps still ahead show only their number.
21
+ *
22
+ * It reports progress and is not a control; the flow's own buttons move
23
+ * between steps. It renders an ordered list, so a screen reader counts the
24
+ * steps; the current one is `aria-current="step"` and a complete one adds
25
+ * `completeLabel` to its name. Status shows in shape as well as colour.
26
+ *
27
+ * The steps share the row evenly. Below 36rem of width the names leave the
28
+ * row, which keeps only its markers, and the current step's name shows on a
29
+ * line of its own below it; the list still reads every step out.
30
+ *
31
+ * ```tsx
32
+ * <Stepper
33
+ * aria-label="Weekly plan steps"
34
+ * steps={['Reconnect', 'Results', 'Prioritise', 'Schedule', 'Commit']}
35
+ * current={1}
36
+ * completeLabel="Done"
37
+ * />
38
+ * ```
39
+ */
40
+ export declare function Stepper({ 'aria-label': ariaLabel, steps, current, completeLabel, className, }: StepperProps): import("react/jsx-runtime").JSX.Element;
41
+ //# sourceMappingURL=stepper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stepper.d.ts","sourceRoot":"","sources":["../../src/stepper/stepper.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AASvB,MAAM,WAAW,YAAY;IAC3B,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CAAC,EACtB,YAAY,EAAE,SAAS,EACvB,KAAK,EACL,OAAO,EACP,aAAa,EACb,SAAS,GACV,EAAE,YAAY,2CAoCd"}
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import './stepper.css';
3
+ import { cx } from '../cx';
4
+ import { Icon } from '../icon/icon';
5
+ import { useIconDefaults } from '../icon-defaults';
6
+ import { VisuallyHidden } from '../visually-hidden/visually-hidden';
7
+ const statusOf = (index, current) => index < current ? 'complete' : index === current ? 'current' : 'upcoming';
8
+ /**
9
+ * A row of numbered steps on a line, showing how far through a flow the
10
+ * reader is: steps already taken are filled and checked, the current one is
11
+ * outlined, and the steps still ahead show only their number.
12
+ *
13
+ * It reports progress and is not a control; the flow's own buttons move
14
+ * between steps. It renders an ordered list, so a screen reader counts the
15
+ * steps; the current one is `aria-current="step"` and a complete one adds
16
+ * `completeLabel` to its name. Status shows in shape as well as colour.
17
+ *
18
+ * The steps share the row evenly. Below 36rem of width the names leave the
19
+ * row, which keeps only its markers, and the current step's name shows on a
20
+ * line of its own below it; the list still reads every step out.
21
+ *
22
+ * ```tsx
23
+ * <Stepper
24
+ * aria-label="Weekly plan steps"
25
+ * steps={['Reconnect', 'Results', 'Prioritise', 'Schedule', 'Commit']}
26
+ * current={1}
27
+ * completeLabel="Done"
28
+ * />
29
+ * ```
30
+ */
31
+ export function Stepper({ 'aria-label': ariaLabel, steps, current, completeLabel, className, }) {
32
+ const { check } = useIconDefaults();
33
+ const renderStep = (label, index) => {
34
+ const status = statusOf(index, current);
35
+ return (_jsxs("li", { className: cx('ds-stepper__step', `ds-stepper__step--${status}`), "aria-current": status === 'current' ? 'step' : undefined, children: [_jsx("span", { className: "ds-stepper__track", children: _jsx("span", { className: "ds-stepper__marker", "aria-hidden": true, children: status === 'complete' ? _jsx(Icon, { source: check, size: "sm", decorative: true }) : index + 1 }) }), _jsxs("span", { className: "ds-stepper__label", children: [label, status === 'complete' && _jsxs(VisuallyHidden, { children: [", ", completeLabel] })] })] }, index));
36
+ };
37
+ return (_jsxs("div", { className: cx('ds-stepper', className), children: [_jsx("ol", { className: "ds-stepper__list", role: "list", "aria-label": ariaLabel, children: steps.map(renderStep) }), steps[current] && (_jsx("p", { className: "ds-stepper__caption", "aria-hidden": true, children: steps[current] }))] }));
38
+ }
39
+ //# sourceMappingURL=stepper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stepper.js","sourceRoot":"","sources":["../../src/stepper/stepper.tsx"],"names":[],"mappings":";AAAA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAqBpE,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,OAAe,EAAiB,EAAE,CACjE,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;AAE5E;;;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x';\nimport { Icon } from '../icon/icon';\nimport { useIconDefaults } from '../icon-defaults';\nimport { VisuallyHidden } from '../visually-hidden/visually-hidden';\n\n/** Where a step stands against the current one. */\ntype StepperStatus = 'complete' | 'current' | 'upcoming';\n\nexport interface StepperProps {\n /** Names the list of steps, e.g. \"Weekly plan steps\". */\n 'aria-label': string;\n /** Each step's name, in order. */\n steps: string[];\n /**\n * The index of the step the reader is on. Every step before it is\n * complete; `steps.length` marks them all complete, for a finished flow.\n */\n current: number;\n /** Words said after a complete step's name, e.g. \"Done\". */\n completeLabel: string;\n /** Extra class names on the outermost element. */\n className?: string;\n}\n\nconst statusOf = (index: number, current: number): StepperStatus =>\n index < current ? 'complete' : index === current ? 'current' : 'upcoming';\n\n/**\n * A row of numbered steps on a line, showing how far through a flow the\n * reader is: steps already taken are filled and checked, the current one is\n * outlined, and the steps still ahead show only their number.\n *\n * It reports progress and is not a control; the flow's own buttons move\n * between steps. It renders an ordered list, so a screen reader counts the\n * steps; the current one is `aria-current=\"step\"` and a complete one adds\n * `completeLabel` to its name. Status shows in shape as well as colour.\n *\n * The steps share the row evenly. Below 36rem of width the names leave the\n * row, which keeps only its markers, and the current step's name shows on a\n * line of its own below it; the list still reads every step out.\n *\n * ```tsx\n * <Stepper\n * aria-label=\"Weekly plan steps\"\n * steps={['Reconnect', 'Results', 'Prioritise', 'Schedule', 'Commit']}\n * current={1}\n * completeLabel=\"Done\"\n * />\n * ```\n */\nexport function Stepper({\n 'aria-label': ariaLabel,\n steps,\n current,\n completeLabel,\n className,\n}: StepperProps) {\n const { check } = useIconDefaults();\n const renderStep = (label: string, index: number) => {\n const status = statusOf(index, current);\n return (\n <li\n key={index}\n className={cx('ds-stepper__step', `ds-stepper__step--${status}`)}\n aria-current={status === 'current' ? 'step' : undefined}\n >\n <span className=\"ds-stepper__track\">\n <span className=\"ds-stepper__marker\" aria-hidden>\n {status === 'complete' ? <Icon source={check} size=\"sm\" decorative /> : index + 1}\n </span>\n </span>\n <span className=\"ds-stepper__label\">\n {label}\n {status === 'complete' && <VisuallyHidden>, {completeLabel}</VisuallyHidden>}\n </span>\n </li>\n );\n };\n\n return (\n <div className={cx('ds-stepper', className)}>\n {/* biome-ignore lint/a11y/noRedundantRoles: Safari drops the list role from an unstyled list */}\n <ol className=\"ds-stepper__list\" role=\"list\" aria-label={ariaLabel}>\n {steps.map(renderStep)}\n </ol>\n {steps[current] && (\n <p className=\"ds-stepper__caption\" aria-hidden>\n {steps[current]}\n </p>\n )}\n </div>\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manakind/ui-core",
3
- "version": "0.37.0",
3
+ "version": "0.39.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -176,6 +176,10 @@
176
176
  "types": "./dist/status-dot/index.d.ts",
177
177
  "import": "./dist/status-dot/index.js"
178
178
  },
179
+ "./stepper": {
180
+ "types": "./dist/stepper/index.d.ts",
181
+ "import": "./dist/stepper/index.js"
182
+ },
179
183
  "./sticky": {
180
184
  "types": "./dist/sticky/index.d.ts",
181
185
  "import": "./dist/sticky/index.js"
@@ -356,6 +360,10 @@
356
360
  "types": "./dist/status-dot/status-dot.css.d.ts",
357
361
  "default": "./dist/status-dot/status-dot.css"
358
362
  },
363
+ "./css/stepper": {
364
+ "types": "./dist/stepper/stepper.css.d.ts",
365
+ "default": "./dist/stepper/stepper.css"
366
+ },
359
367
  "./css/sticky": {
360
368
  "types": "./dist/sticky/sticky.css.d.ts",
361
369
  "default": "./dist/sticky/sticky.css"
@@ -412,7 +420,7 @@
412
420
  },
413
421
  "devDependencies": {
414
422
  "@manakind/ds-config": "*",
415
- "@manakind/manuia-tokens": "0.35.0",
423
+ "@manakind/manuia-tokens": "0.37.0",
416
424
  "@testing-library/jest-dom": "^6.9.1",
417
425
  "@testing-library/react": "^16.3.2",
418
426
  "@testing-library/user-event": "^14.6.1",