@bloxwap/hig 0.8.1 → 0.9.1

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.
Files changed (102) hide show
  1. package/README.md +1 -0
  2. package/chart/README.md +3 -4
  3. package/chart/dist/altimeter-burst.d.ts +2 -2
  4. package/chart/dist/altimeter-burst.js +8 -7
  5. package/chart/dist/altimeter-chart.d.ts +13 -3
  6. package/chart/dist/altimeter-chart.js +37 -12
  7. package/chart/dist/altimeter-core.d.ts +21 -0
  8. package/chart/dist/altimeter-core.js +13 -0
  9. package/chart/dist/altimeter-targets.d.ts +3 -2
  10. package/chart/dist/altimeter-targets.js +7 -7
  11. package/chart/dist/index.d.ts +2 -2
  12. package/chart/dist/outcome-chart.d.ts +4 -2
  13. package/chart/dist/outcome-chart.js +9 -6
  14. package/chart/dist/outcome-model.d.ts +14 -1
  15. package/chart/dist/outcome-model.js +12 -4
  16. package/contracts/README.md +1 -1
  17. package/contracts/dist/login.d.ts +34 -0
  18. package/contracts/dist/login.js +43 -0
  19. package/contracts/dist/messages.d.ts +1 -1
  20. package/feedback/README.md +1 -1
  21. package/native/README.md +1 -1
  22. package/native/dist/address-readout.d.ts +9 -0
  23. package/native/dist/address-readout.js +22 -0
  24. package/native/dist/animated-number.js +3 -1
  25. package/native/dist/blocks.d.ts +5 -2
  26. package/native/dist/blocks.js +5 -2
  27. package/native/dist/chart.d.ts +20 -0
  28. package/native/dist/chart.js +161 -0
  29. package/native/dist/claim-reward-block.d.ts +22 -0
  30. package/native/dist/claim-reward-block.js +16 -0
  31. package/native/dist/confirm-block.d.ts +1 -5
  32. package/native/dist/confirm-block.js +5 -16
  33. package/native/dist/data.d.ts +1 -1
  34. package/native/dist/data.js +3 -1
  35. package/native/dist/deposit-block.d.ts +19 -0
  36. package/native/dist/deposit-block.js +20 -0
  37. package/native/dist/gesture-sheet.js +1 -1
  38. package/native/dist/language-block.js +1 -1
  39. package/native/dist/login-block.d.ts +4 -0
  40. package/native/dist/login-block.js +22 -0
  41. package/native/dist/manage-position-block.d.ts +7 -0
  42. package/native/dist/manage-position-block.js +29 -28
  43. package/native/dist/modal-radius.d.ts +2 -0
  44. package/native/dist/modal-radius.js +2 -0
  45. package/native/dist/overlay.d.ts +6 -2
  46. package/native/dist/overlay.js +7 -5
  47. package/native/dist/positions-block.d.ts +28 -0
  48. package/native/dist/positions-block.js +15 -0
  49. package/native/dist/screen-header.d.ts +3 -1
  50. package/native/dist/screen-header.js +2 -2
  51. package/native/dist/status.js +3 -2
  52. package/native/dist/{swap-panel-block.d.ts → swap-block.d.ts} +10 -6
  53. package/native/dist/{swap-panel-block.js → swap-block.js} +5 -3
  54. package/native/dist/swap-sheet.d.ts +3 -3
  55. package/native/dist/swap-sheet.js +3 -3
  56. package/native/dist/token-action-block.d.ts +1 -1
  57. package/native/dist/token-action-block.js +2 -1
  58. package/native-fonts/README.md +1 -1
  59. package/og-fonts/README.md +1 -1
  60. package/package.json +76 -21
  61. package/react/README.md +1 -1
  62. package/react/dist/blocks/address-readout.d.ts +9 -0
  63. package/react/dist/blocks/address-readout.js +16 -0
  64. package/react/dist/blocks/claim-reward-block.d.ts +22 -0
  65. package/react/dist/blocks/claim-reward-block.js +10 -0
  66. package/react/dist/blocks/confirm-block.d.ts +1 -5
  67. package/react/dist/blocks/confirm-block.js +3 -13
  68. package/react/dist/blocks/deposit-block.d.ts +19 -0
  69. package/react/dist/blocks/deposit-block.js +18 -0
  70. package/react/dist/blocks/login-block.d.ts +16 -0
  71. package/react/dist/blocks/login-block.js +29 -0
  72. package/react/dist/blocks/manage-position-block.d.ts +7 -0
  73. package/react/dist/blocks/manage-position-block.js +9 -4
  74. package/react/dist/blocks/positions-block.d.ts +28 -0
  75. package/react/dist/blocks/positions-block.js +14 -0
  76. package/react/dist/blocks/{swap-panel-block.d.ts → swap-block.d.ts} +10 -6
  77. package/react/dist/blocks/{swap-panel-block.js → swap-block.js} +5 -3
  78. package/react/dist/blocks/swap-sheet.d.ts +3 -3
  79. package/react/dist/blocks/swap-sheet.js +3 -3
  80. package/react/dist/blocks/token-action-block.d.ts +1 -1
  81. package/react/dist/blocks/token-action-block.js +2 -1
  82. package/react/dist/blocks.d.ts +5 -2
  83. package/react/dist/blocks.js +5 -2
  84. package/react/dist/gesture-sheet.js +6 -2
  85. package/react/dist/overlay.d.ts +1 -29
  86. package/react/dist/overlay.js +3 -31
  87. package/react/dist/popover.d.ts +30 -0
  88. package/react/dist/popover.js +34 -0
  89. package/react/dist/styles.css +186 -33
  90. package/tokens/README.md +1 -1
  91. package/tokens/assets/onramps/apple-pay.svg +33 -0
  92. package/tokens/assets/onramps/bank.svg +98 -0
  93. package/tokens/assets/onramps/blink.svg +37 -0
  94. package/tokens/assets/onramps/cashapp.svg +33 -0
  95. package/tokens/assets/onramps/crypto.svg +121 -0
  96. package/tokens/assets/onramps/exchange.svg +105 -0
  97. package/tokens/dist/deposit-icons.d.ts +1 -0
  98. package/tokens/dist/deposit-icons.js +28 -0
  99. package/native/dist/explainer-block.d.ts +0 -91
  100. package/native/dist/explainer-block.js +0 -34
  101. package/react/dist/blocks/explainer-block.d.ts +0 -80
  102. package/react/dist/blocks/explainer-block.js +0 -20
@@ -1,91 +0,0 @@
1
- import React from 'react';
2
- import { View, type ScrollViewProps } from 'react-native';
3
- import { type ScreenHeaderControlProps } from './screen-header.js';
4
- /** The colour of a section: its tint, its icon disc and its heading. */
5
- export type ExplainerTone = 'up' | 'down' | 'positive' | 'negative' | 'warning';
6
- /** One titled part of the explanation. Every field is optional, so a section can be a heading and a sentence, an icon row, or host media with a caption. */
7
- export interface ExplainerSection {
8
- /** Stable key, also used in the test IDs. */
9
- id: string;
10
- /** The section's heading: Up. */
11
- title?: string;
12
- /** Muted text after the heading on the same line, such as what the heading means: → Momentum is rising. */
13
- meaning?: string;
14
- /** A glyph on the leading edge in a 40dp disc, such as an icon drawn in `useColors()[tone]`. Decorative: hidden from assistive technology. */
15
- icon?: React.ReactNode;
16
- /** Tints the section, its disc and its heading. Without it the section sits on the neutral fill. */
17
- tone?: ExplainerTone;
18
- /** Host content under the heading and before the body, centred, such as an example card and its caption. */
19
- media?: React.ReactNode;
20
- /** The section's text, muted. A string is drawn as Text; anything else as given. */
21
- body?: React.ReactNode;
22
- /** A small note at the end of the section. A string is drawn as Text; anything else as given. */
23
- caveat?: React.ReactNode;
24
- /** The section's test ID, in place of `<testID>-section-<id>`. */
25
- testID?: string;
26
- }
27
- /** One action at the foot of the block. */
28
- export interface ExplainerAction {
29
- label: string;
30
- onSelect: () => void;
31
- /** Defaults to `primary` for `primaryAction` and `secondary` for `secondaryAction`. */
32
- intent?: 'primary' | 'secondary' | 'destructive' | 'ghost';
33
- disabled?: boolean;
34
- busy?: boolean;
35
- /** The button's test ID, in place of `<testID>-primary` or `<testID>-secondary`. */
36
- testID?: string;
37
- /** Pressable props for the button (native), such as `{android_disableSound: true}` when the host plays its own sound. HIG keeps its own name, role, state and press. */
38
- pressProps?: ScreenHeaderControlProps;
39
- /** A glyph after the label, such as an arrow for an action that opens something outside the app (test ID `<button test ID>-icon`). Decorative: hidden from assistive technology, so the label alone names the button. */
40
- icon?: React.ReactNode;
41
- }
42
- export interface ExplainerBlockProps {
43
- /** Heading of the header. Leave it out inside a host sheet that draws its own title. */
44
- title?: string;
45
- /** A kicker above the title in small muted capitals: Builder fee. With `title` it is centred in the header over the heading (`<testID>-eyebrow`); without one it is the block's first line (`<testID>-eyebrow` too). Host text. */
46
- eyebrow?: string;
47
- /** Short host text in a badge beside the title, as `ScreenHeader` `badge` (needs `title`): Demo. */
48
- badge?: string;
49
- /** A ref to the header's title (the title and badge as one header with `badge`), for example to move accessibility focus to it when the sheet opens. Needs `title`. */
50
- titleRef?: React.Ref<React.ComponentRef<typeof View>>;
51
- /** A large figure or host media centred under the header and before the lead (`<testID>-hero`), such as a 68pt “4% off” or a donut. Drawn as given; the host sets its size and colour, and hides decorative media from assistive technology. */
52
- hero?: React.ReactNode;
53
- /** A lead paragraph under the header, muted. A string is drawn as Text; anything else as given. */
54
- description?: React.ReactNode;
55
- /** The titled sections, in order. */
56
- sections?: readonly ExplainerSection[];
57
- /** Numbered steps after the sections, such as how to finish a task. A string is drawn as Text; anything else as given. */
58
- steps?: readonly React.ReactNode[];
59
- /** A small note after the sections and steps. */
60
- caveat?: React.ReactNode;
61
- /** Host content after the sections, steps and closing note and before the actions, such as a field, a link or a share card. Drawn as given. */
62
- children?: React.ReactNode;
63
- /** The main action: Got it, Copy link. */
64
- primaryAction?: ExplainerAction;
65
- /** A second action on the leading side of the main one, the two sharing the row equally: Not now. */
66
- secondaryAction?: ExplainerAction;
67
- /** Keeps the provider's feedback off the actions, for a host that plays its own cue. */
68
- suppressFeedback?: boolean;
69
- /** Shows Back on the leading edge of the header (needs `title`). */
70
- onBack?: () => void;
71
- /** Pressable props for Back, such as `{android_disableSound: true}`. */
72
- backProps?: ScreenHeaderControlProps;
73
- /** A control on the trailing edge of the header, such as a Close IconButton. */
74
- headerAction?: React.ReactNode;
75
- /** `nativeID` of the title, so a sheet can name itself with `accessibilityLabelledBy` (Android). */
76
- headingId?: string;
77
- /** Keeps the header pinned while the rest scrolls: the block becomes its own scroll view with the header as its sticky first child. Needs `title`; place it in a bounded container. */
78
- stickyHeader?: boolean;
79
- /** With `stickyHeader`: the header's fill once content is under it. Defaults to the background role; in a sheet pass the sheet's fill. */
80
- stickyHeaderBackground?: string;
81
- /** The scroll view used with `stickyHeader`, such as a sheet library's own. */
82
- scrollComponent?: React.ComponentType<ScrollViewProps>;
83
- /** Prefix of the test IDs: `<testID>-header`, `-back`, `-title`, `-description`, `-section-<id>` (with `-icon`, `-title`, `-media`, `-body` and `-caveat` after it), `-step-<index>`, `-caveat`, `-actions`, `-secondary` and `-primary`. Defaults to `explainer`. */
84
- testID?: string;
85
- }
86
- /**
87
- * How something works, or how to finish a task, as a screen: an optional header, a lead paragraph, titled sections (each with an optional
88
- * icon and tone, a heading, media, a body and a caveat), numbered steps, a closing note, then one or two actions. Draws the "How Swing
89
- * works" and "How Trend works" sheets and short task dialogs such as inviting a friend.
90
- */
91
- export declare function ExplainerBlock({ title, eyebrow, badge, titleRef, hero, description, sections, steps, caveat, children, primaryAction, secondaryAction, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID }: ExplainerBlockProps): React.JSX.Element;
@@ -1,34 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { View } from 'react-native';
3
- import { withAlpha } from '@bloxwap/hig/tokens';
4
- import { useColors, useFills, useHIG } from './provider.js';
5
- import { Text } from './surface.js';
6
- import * as en from '@bloxwap/hig/contracts/messages';
7
- import { Button, busyAccessibilityLabel } from './button.js';
8
- import { ScreenHeader } from './screen-header.js';
9
- import { StickyHeaderLayout } from './sticky-header.js';
10
- const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
11
- /** Test ID parts, which double as the actions' default intents. */
12
- const primaryPart = 'primary', secondaryPart = 'secondary', descriptionPart = 'description', caveatPart = 'caveat';
13
- /**
14
- * How something works, or how to finish a task, as a screen: an optional header, a lead paragraph, titled sections (each with an optional
15
- * icon and tone, a heading, media, a body and a caveat), numbered steps, a closing note, then one or two actions. Draws the "How Swing
16
- * works" and "How Trend works" sheets and short task dialogs such as inviting a friend.
17
- */
18
- export function ExplainerBlock({ title, eyebrow, badge, titleRef, hero, description, sections = [], steps = [], caveat, children, primaryAction, secondaryAction, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID = 'explainer' }) {
19
- const colors = useColors(), fills = useFills(), { direction, messages } = useHIG();
20
- const id = (part) => `${testID}-${part}`;
21
- const muted = { fontSize: 14, lineHeight: 20, color: colors.muted };
22
- // Host text is drawn as muted Text; host nodes are drawn as given.
23
- const prose = (content, part) => typeof content === 'string' || typeof content === 'number' ? _jsx(Text, { testID: id(part), style: muted, children: content }) : _jsx(View, { testID: id(part), children: content });
24
- const shown = (content) => content != null && content !== false;
25
- const action = (entry, fallback) => { const button = entry.testID ?? id(fallback); /* With an icon, the label alone names the button (and its busy reading), so a Text glyph is never read into it. */ /* With an icon, the label alone names the button (and its busy reading), so a Text glyph is never read into it. */ const named = shown(entry.icon) ? { accessibilityLabel: entry.busy ? busyAccessibilityLabel(entry.label, messages.busy ?? en.busy) : entry.label } : {}; return _jsxs(Button, { ...entry.pressProps, ...named, testID: button, intent: entry.intent ?? fallback, disabled: entry.disabled, busy: entry.busy, suppressFeedback: suppressFeedback, onPress: entry.onSelect, style: { flex: 1, alignSelf: 'auto' }, children: [entry.label, shown(entry.icon) ? _jsx(View, { ...hidden, testID: `${button}-icon`, children: entry.icon }, 'icon') : null] }); };
26
- const header = title !== undefined ? _jsx(ScreenHeader, { title: title, eyebrow: eyebrow, badge: badge, titleRef: titleRef, onBack: onBack, backProps: backProps, action: headerAction, headingId: headingId, testID: testID }) : null;
27
- const body = _jsxs(_Fragment, { children: [header === null && eyebrow ? _jsx(Text, { testID: id('eyebrow'), style: { fontSize: 12, lineHeight: 16, letterSpacing: 1.5, textTransform: 'uppercase', color: colors.muted }, children: eyebrow }) : null, shown(hero) ? _jsx(View, { testID: id('hero'), style: { alignItems: 'center' }, children: hero }) : null, shown(description) ? prose(description, descriptionPart) : null, sections.length > 0 ? _jsx(View, { testID: id('sections'), style: { gap: 12 }, children: sections.map(section => {
28
- const part = `section-${section.id}`, bodyPart = `${part}-body`, sectionCaveatPart = `${part}-caveat`, tone = section.tone ? colors[section.tone] : undefined;
29
- return _jsxs(View, { testID: section.testID ?? id(part), style: { direction, flexDirection: 'row', alignItems: section.icon != null ? 'flex-start' : 'center', gap: 12, padding: 12, borderRadius: section.icon != null ? 32 : 16, backgroundColor: tone ? withAlpha(tone, 0.1) : fills.well }, children: [section.icon != null ? _jsx(View, { ...hidden, testID: id(`${part}-icon`), style: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center', backgroundColor: withAlpha(tone ?? colors.text, 0.15) }, children: section.icon }) : null, _jsxs(View, { style: { flex: 1, minWidth: 0, gap: 4 }, children: [section.title !== undefined ? _jsxs(Text, { testID: id(`${part}-title`), accessibilityRole: 'header', style: { fontSize: 16, lineHeight: 24, fontWeight: '700', color: tone ?? colors.text }, children: [section.title, section.meaning ? _jsx(Text, { style: { color: colors.muted }, children: ` ${section.meaning}` }) : null] }) : null, section.media != null ? _jsx(View, { testID: id(`${part}-media`), style: { alignItems: 'center', gap: 8, marginVertical: 12 }, children: section.media }) : null, shown(section.body) ? prose(section.body, bodyPart) : null, shown(section.caveat) ? prose(section.caveat, sectionCaveatPart) : null] })] }, section.id);
30
- }) }) : null, steps.length > 0 ? _jsx(View, { testID: id('steps'), style: { gap: 8 }, children: steps.map((step, index) => _jsxs(View, { testID: id(`step-${index}`), accessible: typeof step === 'string' || typeof step === 'number', style: { direction, flexDirection: 'row', gap: 8 }, children: [_jsx(Text, { style: { ...muted, minWidth: 16, fontVariant: ['tabular-nums'] }, children: `${index + 1}.` }), typeof step === 'string' || typeof step === 'number' ? _jsx(Text, { style: { ...muted, flexShrink: 1 }, children: step }) : _jsx(View, { style: { flexShrink: 1 }, children: step })] }, index)) }) : null, shown(caveat) ? prose(caveat, caveatPart) : null, children, primaryAction || secondaryAction ? _jsxs(View, { testID: id('actions'), style: { direction, flexDirection: 'row', gap: 8 }, children: [secondaryAction ? action(secondaryAction, secondaryPart) : null, primaryAction ? action(primaryAction, primaryPart) : null] }) : null] });
31
- if (stickyHeader && header)
32
- return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: id('sticky-header'), header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, bodyStyle: { direction, gap: 16, paddingTop: 16 }, children: body });
33
- return _jsxs(View, { testID: testID, style: { direction, padding: 16, gap: 16 }, children: [header, body] });
34
- }
@@ -1,80 +0,0 @@
1
- import React from 'react';
2
- import { type ScreenHeaderControlProps } from './screen-header.js';
3
- /** The colour of a section: its tint, its icon disc and its heading. */
4
- export type ExplainerTone = 'up' | 'down' | 'positive' | 'negative' | 'warning';
5
- /** One titled part of the explanation. Every field is optional, so a section can be a heading and a sentence, an icon row, or host media with a caption. */
6
- export interface ExplainerSection {
7
- /** Stable key, also used in native test IDs. */
8
- id: string;
9
- /** The section's heading: Up. */
10
- title?: string;
11
- /** Muted text after the heading on the same line, such as what the heading means: → Momentum is rising. */
12
- meaning?: string;
13
- /** A glyph on the leading edge in a disc, drawn in `currentColor` (the tone's colour). Decorative: hidden from assistive technology. */
14
- icon?: React.ReactNode;
15
- /** Tints the section, its disc and its heading. Without it the section sits on the neutral fill. */
16
- tone?: ExplainerTone;
17
- /** Host content under the heading and before the body, centred, such as an example card and its caption. */
18
- media?: React.ReactNode;
19
- /** The section's text, muted. */
20
- body?: React.ReactNode;
21
- /** A small note at the end of the section, such as what the signal does not promise. */
22
- caveat?: React.ReactNode;
23
- /** The section's `data-testid`. */
24
- testID?: string;
25
- }
26
- /** One action at the foot of the block. */
27
- export interface ExplainerAction {
28
- label: string;
29
- onSelect: () => void;
30
- /** Defaults to `primary` for `primaryAction` and `secondary` for `secondaryAction`. */
31
- intent?: 'primary' | 'secondary' | 'destructive' | 'ghost';
32
- disabled?: boolean;
33
- busy?: boolean;
34
- /** The button's `data-testid`. */
35
- testID?: string;
36
- /** A glyph after the label, such as an arrow for an action that opens something outside the app. Decorative: hidden from assistive technology, so the label alone names the button. */
37
- icon?: React.ReactNode;
38
- }
39
- export interface ExplainerBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
40
- /** Heading of the header. Leave it out inside a host dialog or sheet that draws its own title. */
41
- title?: string;
42
- /** A kicker above the title in small muted capitals: Builder fee. With `title` it is centred in the header over the heading; without one it is the block's first line. Host text. */
43
- eyebrow?: string;
44
- /** Short host text in a badge beside the title, as `ScreenHeader` `badge` (needs `title`): Demo. */
45
- badge?: string;
46
- /** A large figure or host media centred under the header and before the lead, such as a 68px “4% off” or a donut. Drawn as given; the host sets its size and colour, and hides decorative media from assistive technology. */
47
- hero?: React.ReactNode;
48
- /** A lead paragraph under the header, muted. */
49
- description?: React.ReactNode;
50
- /** The titled sections, in order. */
51
- sections?: readonly ExplainerSection[];
52
- /** Numbered steps after the sections, such as how to finish a task. */
53
- steps?: readonly React.ReactNode[];
54
- /** A small note after the sections and steps, such as what the whole explanation does not promise. */
55
- caveat?: React.ReactNode;
56
- /** Host content after the sections, steps and closing note and before the actions, such as a field, a link or a share card. Drawn as given. */
57
- children?: React.ReactNode;
58
- /** The main action: Got it, Copy link. */
59
- primaryAction?: ExplainerAction;
60
- /** A second action on the leading side of the main one, the two sharing the row equally: Not now. */
61
- secondaryAction?: ExplainerAction;
62
- /** Keeps the provider's feedback off the actions, for a host that plays its own cue. */
63
- suppressFeedback?: boolean;
64
- /** Shows Back on the leading edge of the header (needs `title`). */
65
- onBack?: () => void;
66
- /** Attributes for the header's Back `<button>`. */
67
- backProps?: ScreenHeaderControlProps;
68
- /** A control on the trailing edge of the header, such as a Close `IconButton`. */
69
- headerAction?: React.ReactNode;
70
- /** `id` of the header's heading, so a dialog or sheet can name itself with `aria-labelledby`. */
71
- headingId?: string;
72
- /** Pins the header to the top of the nearest scroller. See Pinned headers. */
73
- stickyHeader?: boolean;
74
- }
75
- /**
76
- * How something works, or how to finish a task: an optional header, a lead paragraph, titled sections (each with an optional icon and
77
- * tone, a heading, media, a body and a caveat), numbered steps, a closing note, then one or two actions. Draws the “How Swing works” and
78
- * “How Trend works” sheets and short task dialogs such as inviting a friend.
79
- */
80
- export declare function ExplainerBlock({ title, eyebrow, badge, hero, description, sections, steps, caveat, children, primaryAction, secondaryAction, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, className, ...rest }: ExplainerBlockProps): React.JSX.Element;
@@ -1,20 +0,0 @@
1
- "use client";
2
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useId } from 'react';
4
- import { Button } from '../button.js';
5
- import { ScreenHeader } from './screen-header.js';
6
- /** The actions' default intents. */
7
- const primaryIntent = 'primary', secondaryIntent = 'secondary';
8
- /**
9
- * How something works, or how to finish a task: an optional header, a lead paragraph, titled sections (each with an optional icon and
10
- * tone, a heading, media, a body and a caveat), numbered steps, a closing note, then one or two actions. Draws the “How Swing works” and
11
- * “How Trend works” sheets and short task dialogs such as inviting a friend.
12
- */
13
- export function ExplainerBlock({ title, eyebrow, badge, hero, description, sections = [], steps = [], caveat, children, primaryAction, secondaryAction, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, className, ...rest }) {
14
- const id = useId();
15
- const action = (entry, fallback) => _jsxs(Button, { intent: entry.intent ?? fallback, disabled: entry.disabled, busy: entry.busy, suppressFeedback: suppressFeedback, "data-testid": entry.testID, onClick: entry.onSelect, children: [entry.label, entry.icon != null && entry.icon !== false ? _jsx("span", { className: 'hig-explainer-action-icon', "aria-hidden": 'true', children: entry.icon }) : null] });
16
- return _jsxs("section", { ...rest, className: `hig-explainer${className ? ` ${className}` : ''}`, children: [title !== undefined ? _jsx(ScreenHeader, { title: title, eyebrow: eyebrow, badge: badge, onBack: onBack, backProps: backProps, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }) : eyebrow ? _jsx("p", { className: 'hig-explainer-eyebrow', children: eyebrow }) : null, hero != null && hero !== false && _jsx("div", { className: 'hig-explainer-hero', children: hero }), description != null && description !== false && _jsx("p", { className: 'hig-explainer-text', children: description }), sections.length > 0 && _jsx("div", { className: 'hig-explainer-sections', children: sections.map(section => {
17
- const heading = section.title !== undefined ? `${id}-${section.id}` : undefined;
18
- return _jsxs("div", { className: 'hig-explainer-section', "data-tone": section.tone, "data-testid": section.testID, children: [section.icon != null && _jsx("span", { className: 'hig-explainer-icon', "aria-hidden": 'true', children: section.icon }), _jsxs("div", { children: [section.title !== undefined && _jsxs("h3", { id: heading, children: [section.title, section.meaning ? _jsxs(_Fragment, { children: [" ", _jsx("span", { children: section.meaning })] }) : null] }), section.media != null && _jsx("div", { className: 'hig-explainer-media', children: section.media }), section.body != null && section.body !== false && _jsx("div", { className: 'hig-explainer-text', children: section.body }), section.caveat != null && section.caveat !== false && _jsx("p", { className: 'hig-explainer-text', "data-caveat": '', children: section.caveat })] })] }, section.id);
19
- }) }), steps.length > 0 && _jsx("ol", { className: 'hig-explainer-steps hig-explainer-text', children: steps.map((step, index) => _jsx("li", { children: step }, index)) }), caveat != null && caveat !== false && _jsx("p", { className: 'hig-explainer-text', "data-caveat": '', children: caveat }), children, (primaryAction || secondaryAction) && _jsxs("div", { className: 'hig-confirm-actions', children: [secondaryAction && action(secondaryAction, secondaryIntent), primaryAction && action(primaryAction, primaryIntent)] })] });
20
- }