@tempoxyz/ds 0.3.15 → 0.3.17

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 (130) hide show
  1. package/dist/docs/AGENTS.md +10 -6
  2. package/dist/docs/arsenal.md +44 -0
  3. package/dist/docs/marketing.md +703 -4
  4. package/dist/docs/product/components/actions.md +53 -1
  5. package/dist/docs/product/components/blockchain.md +147 -3
  6. package/dist/docs/product/components/feedback-and-status.md +137 -7
  7. package/dist/docs/product/components/navigation.md +1 -1
  8. package/dist/docs/product/documents.md +225 -0
  9. package/dist/docs/product/foundations.md +2 -1
  10. package/dist/docs/product/patterns.md +3 -22
  11. package/dist/document/Document.d.ts +46 -0
  12. package/dist/document/Document.d.ts.map +1 -0
  13. package/dist/document/Document.js +190 -0
  14. package/dist/document/Document.js.map +1 -0
  15. package/dist/document/Enhance.d.ts +13 -0
  16. package/dist/document/Enhance.d.ts.map +1 -0
  17. package/dist/document/Enhance.js +421 -0
  18. package/dist/document/Enhance.js.map +1 -0
  19. package/dist/document/bin.d.ts +3 -0
  20. package/dist/document/bin.d.ts.map +1 -0
  21. package/dist/document/bin.js +38 -0
  22. package/dist/document/bin.js.map +1 -0
  23. package/dist/document/document.css +373 -0
  24. package/dist/document/index.d.ts +3 -0
  25. package/dist/document/index.d.ts.map +1 -0
  26. package/dist/document/index.js +3 -0
  27. package/dist/document/index.js.map +1 -0
  28. package/dist/document/internal/Cli.d.ts +43 -0
  29. package/dist/document/internal/Cli.d.ts.map +1 -0
  30. package/dist/document/internal/Cli.js +87 -0
  31. package/dist/document/internal/Cli.js.map +1 -0
  32. package/dist/document/internal/Template.d.ts +21 -0
  33. package/dist/document/internal/Template.d.ts.map +1 -0
  34. package/dist/document/internal/Template.js +15 -0
  35. package/dist/document/internal/Template.js.map +1 -0
  36. package/dist/document/script.d.ts +2 -0
  37. package/dist/document/script.d.ts.map +1 -0
  38. package/dist/document/script.js +379 -0
  39. package/dist/document/templates/brief.html +96 -0
  40. package/dist/document/templates/essay.html +70 -0
  41. package/dist/document/templates/post.html +69 -0
  42. package/dist/marketing/index.js.zyzz.json +1 -1
  43. package/dist/marketing/vars.d.ts +618 -758
  44. package/dist/marketing/vars.d.ts.map +1 -1
  45. package/dist/marketing/vars.js +8 -5
  46. package/dist/marketing/vars.js.map +1 -1
  47. package/dist/marketing/vars.js.zyzz.json +1 -1
  48. package/dist/marketing/zyzz.config.d.ts +3042 -3757
  49. package/dist/marketing/zyzz.config.d.ts.map +1 -1
  50. package/dist/marketing/zyzz.config.js +1 -1
  51. package/dist/marketing/zyzz.config.js.map +1 -1
  52. package/dist/marketing/zyzz.config.js.zyzz.json +1 -1
  53. package/dist/mobile/components/Button.d.ts +115 -15
  54. package/dist/mobile/components/Button.d.ts.map +1 -1
  55. package/dist/mobile/components/Button.js +85 -14
  56. package/dist/mobile/components/Button.js.map +1 -1
  57. package/dist/mobile/components/IconButton.d.ts +129 -40
  58. package/dist/mobile/components/IconButton.d.ts.map +1 -1
  59. package/dist/mobile/components/IconButton.js +97 -28
  60. package/dist/mobile/components/IconButton.js.map +1 -1
  61. package/dist/mobile/components/TextInput.d.ts +132 -11
  62. package/dist/mobile/components/TextInput.d.ts.map +1 -1
  63. package/dist/mobile/components/TextInput.js +115 -14
  64. package/dist/mobile/components/TextInput.js.map +1 -1
  65. package/dist/mobile/index.d.ts +1 -0
  66. package/dist/mobile/index.d.ts.map +1 -1
  67. package/dist/mobile/index.js +1 -0
  68. package/dist/mobile/index.js.map +1 -1
  69. package/dist/mobile/vars.d.ts +103 -0
  70. package/dist/mobile/vars.d.ts.map +1 -1
  71. package/dist/mobile/vars.js +74 -0
  72. package/dist/mobile/vars.js.map +1 -1
  73. package/dist/mobile/zyzz.config.d.ts +408 -0
  74. package/dist/mobile/zyzz.config.d.ts.map +1 -1
  75. package/dist/web/components/AddressCard.js.zyzz.json +1 -1
  76. package/dist/web/components/Amount.css +1 -1
  77. package/dist/web/components/Amount.d.ts +9 -0
  78. package/dist/web/components/Amount.d.ts.map +1 -1
  79. package/dist/web/components/Amount.js +8 -5
  80. package/dist/web/components/Amount.js.map +1 -1
  81. package/dist/web/components/Amount.js.zyzz.json +1 -1
  82. package/dist/web/components/CopyButton.d.ts +6 -0
  83. package/dist/web/components/CopyButton.d.ts.map +1 -1
  84. package/dist/web/components/CopyButton.js +4 -1
  85. package/dist/web/components/CopyButton.js.map +1 -1
  86. package/dist/web/components/CopyButton.js.zyzz.json +1 -1
  87. package/dist/web/components/Hex.css +1 -1
  88. package/dist/web/components/Hex.d.ts +84 -3
  89. package/dist/web/components/Hex.d.ts.map +1 -1
  90. package/dist/web/components/Hex.js +20 -13
  91. package/dist/web/components/Hex.js.map +1 -1
  92. package/dist/web/components/Hex.js.zyzz.json +1 -1
  93. package/dist/web/components/Progress.css +1 -1
  94. package/dist/web/components/Progress.d.ts +12 -2
  95. package/dist/web/components/Progress.d.ts.map +1 -1
  96. package/dist/web/components/Progress.js +9 -5
  97. package/dist/web/components/Progress.js.map +1 -1
  98. package/dist/web/components/Progress.js.zyzz.json +1 -1
  99. package/dist/web/components/SecretValue.js.zyzz.json +1 -1
  100. package/dist/web/components/SidebarMenu.d.ts +4 -4
  101. package/dist/web/components/SidebarMenu.js +6 -6
  102. package/dist/web/components/SidebarMenu.js.map +1 -1
  103. package/dist/web/components/Snippet.js.zyzz.json +1 -1
  104. package/dist/web/index.js.zyzz.json +1 -1
  105. package/package.json +19 -1
  106. package/src/document/Document.ts +277 -0
  107. package/src/document/Enhance.ts +434 -0
  108. package/src/document/bin.ts +38 -0
  109. package/src/document/document.css +373 -0
  110. package/src/document/index.ts +2 -0
  111. package/src/document/internal/Cli.ts +132 -0
  112. package/src/document/internal/Template.ts +25 -0
  113. package/src/document/script.ts +8 -0
  114. package/src/document/templates/brief.html +96 -0
  115. package/src/document/templates/essay.html +70 -0
  116. package/src/document/templates/post.html +69 -0
  117. package/src/marketing/README.md +1 -1
  118. package/src/marketing/vars.ts +526 -604
  119. package/src/marketing/zyzz.config.ts +5 -4
  120. package/src/mobile/README.md +19 -6
  121. package/src/mobile/components/Button.tsx +94 -17
  122. package/src/mobile/components/IconButton.tsx +122 -30
  123. package/src/mobile/components/TextInput.tsx +139 -24
  124. package/src/mobile/index.ts +1 -0
  125. package/src/mobile/vars.ts +74 -0
  126. package/src/web/components/Amount.tsx +37 -3
  127. package/src/web/components/CopyButton.tsx +8 -0
  128. package/src/web/components/Hex.tsx +79 -13
  129. package/src/web/components/Progress.tsx +8 -2
  130. package/src/web/components/SidebarMenu.tsx +6 -6
@@ -1,5 +1,6 @@
1
- import type { ComponentPropsWithRef } from 'react'
2
- import { TextInput as NativeTextInput, Text, View } from 'react-native'
1
+ /** Native text entry and validation styles for the Mobile App input family. @module */
2
+ import { type ComponentPropsWithRef, useState } from 'react'
3
+ import { TextInput as NativeTextInput, Platform, Text, View } from 'react-native'
3
4
  import type * as zyzz from 'zyzz'
4
5
  import { useColor } from '../useColor.js'
5
6
  import { style, variants } from '../zyzz.config.js'
@@ -8,7 +9,10 @@ import { style, variants } from '../zyzz.config.js'
8
9
  * A native text input with an optional `label` and `secondaryLabel` above it and `helper` text
9
10
  * below. `extended` makes the input multiline and 80 points tall. Defaults to
10
11
  * `appearance="primary"`. `ref`, `style` and other native props reach the inner input, and the
11
- * wrapper stretches to its parent.
12
+ * wrapper stretches to its parent. `invalid` marks an error. `editable={false}` or `readOnly`
13
+ * applies the disabled design and prevents editing. Controlled and uncontrolled values remain native.
14
+ *
15
+ * Base UI Input renders a DOM input, so this surface uses React Native TextInput instead.
12
16
  *
13
17
  * - Pass `accessibilityLabel` when you omit the visible `label`.
14
18
  * - Set `keyboardType`, `textContentType` and `autoComplete` for the expected value.
@@ -30,44 +34,87 @@ import { style, variants } from '../zyzz.config.js'
30
34
  * @see {@link https://www.w3.org/WAI/WCAG22/Understanding/identify-input-purpose.html | WCAG 2.2 Identify Input Purpose}
31
35
  */
32
36
  export function TextInput(props: TextInput.Props) {
33
- const { appearance, extended, helper, label, secondaryLabel, ...inputProps } = props
34
- const placeholder = useColor(styles.helper().style)
37
+ const { appearance, extended, helper, invalid, label, secondaryLabel, ...inputProps } = props
38
+ const [focused, setFocused] = useState(false)
39
+ const disabled = props.editable === false || props.readOnly === true
40
+ const state = (() => {
41
+ if (disabled) return 'disabled'
42
+ if (invalid) return 'error'
43
+ if (focused) return 'focused'
44
+ return 'default'
45
+ })()
46
+ const caret = useColor(styles.caret().style)
47
+ const placeholder = useColor(styles.placeholder({ state }).style)
35
48
 
36
49
  return (
37
50
  <View style={styles.textInput().style}>
38
51
  {label !== undefined && (
39
52
  <View style={styles.labels().style}>
40
- <Text style={styles.label().style}>{label}</Text>
53
+ <Text style={styles.label({ disabled }).style}>{label}</Text>
41
54
  {secondaryLabel !== undefined && (
42
- <Text style={styles.secondaryLabel().style}>{secondaryLabel}</Text>
55
+ <Text style={styles.secondaryLabel({ disabled }).style}>{secondaryLabel}</Text>
43
56
  )}
44
57
  </View>
45
58
  )}
46
59
  <NativeTextInput
47
- accessibilityHint={helper}
60
+ // React Native has no invalid accessibilityState. Announce the error through its hint.
61
+ accessibilityHint={invalid ? `Error: ${helper ?? 'Invalid value'}` : helper}
48
62
  accessibilityLabel={label}
63
+ cursorColor={caret}
49
64
  multiline={extended === true}
50
65
  placeholderTextColor={placeholder}
66
+ // Android selectionColor paints an opaque highlight, not just the caret.
67
+ selectionColor={Platform.OS === 'ios' ? caret : undefined}
51
68
  // Android centers multiline text unless the input aligns it to the top.
52
69
  textAlignVertical={extended === true ? 'top' : undefined}
53
70
  // Android otherwise draws its platform underline over the Figma border and fill.
54
71
  underlineColorAndroid="transparent"
55
72
  {...inputProps}
56
- style={[styles.input({ appearance, extended }).style, props.style]}
73
+ accessibilityState={{
74
+ ...props.accessibilityState,
75
+ disabled: disabled || props.accessibilityState?.disabled,
76
+ }}
77
+ aria-disabled={disabled || props['aria-disabled']}
78
+ editable={disabled ? false : props.editable}
79
+ onBlur={(event) => {
80
+ setFocused(false)
81
+ props.onBlur?.(event)
82
+ }}
83
+ onFocus={(event) => {
84
+ setFocused(true)
85
+ props.onFocus?.(event)
86
+ }}
87
+ readOnly={disabled ? true : props.readOnly}
88
+ // Zyzz's native subset does not yet accept this iOS-only React Native property.
89
+ style={[
90
+ { borderCurve: 'continuous' },
91
+ styles.input({ appearance, extended, state }).style,
92
+ props.style,
93
+ ]}
57
94
  />
58
- {helper !== undefined && <Text style={styles.helper().style}>{helper}</Text>}
95
+ {helper !== undefined && (
96
+ <Text
97
+ accessibilityLiveRegion={invalid && !disabled ? 'polite' : undefined}
98
+ style={styles.helper({ disabled, invalid: Boolean(invalid) && !disabled }).style}
99
+ >
100
+ {helper}
101
+ </Text>
102
+ )}
59
103
  </View>
60
104
  )
61
105
  }
62
106
 
107
+ /** Native input props and the supported design axes. */
63
108
  export namespace TextInput {
109
+ /** Native text input attributes, excluding multiline, which extended controls. */
64
110
  export type Props = Omit<ComponentPropsWithRef<typeof NativeTextInput>, 'multiline'> &
65
- zyzz.Props.Variants<typeof styles.input> & {
111
+ Omit<zyzz.Props.Variants<typeof styles.input>, 'state'> & {
66
112
  /**
67
- * Text below the input, also used as its accessibility hint. The placeholder shares its
68
- * color.
113
+ * Text below the input, also used as its accessibility hint. Errors use the negative color.
69
114
  */
70
115
  helper?: string | undefined
116
+ /** Marks the value invalid and announces the helper as an error. Defaults to false. */
117
+ invalid?: boolean | undefined
71
118
  /** Visible label above the input, also used as its accessibility label. */
72
119
  label?: string | undefined
73
120
  /**
@@ -78,48 +125,116 @@ export namespace TextInput {
78
125
  }
79
126
  }
80
127
 
128
+ /** Compiled native recipes for the verified input family. */
81
129
  export namespace styles {
82
- export const helper = style(
83
- { color: 'content.tertiary', paddingTop: '12', typography: 'body.b2' },
130
+ /** Native caret color, shared by both appearances. */
131
+ export const caret = style({ color: 'content.primary' }, { id: 'tds/mobile/text-input/caret' })
132
+
133
+ /** Optional message beneath the field. */
134
+ export const helper = variants(
135
+ {
136
+ base: {
137
+ color: 'component.control.content.tertiary',
138
+ paddingTop: '12',
139
+ typography: 'control.label',
140
+ },
141
+ variants: {
142
+ // Figma paints disabled Message black despite its tertiary variable binding.
143
+ disabled: { false: {}, true: { color: 'rgb(0 0 0 / 1) !custom' } },
144
+ invalid: { false: {}, true: { color: 'content.negative' } },
145
+ },
146
+ },
84
147
  { id: 'tds/mobile/text-input/helper' },
85
148
  )
86
149
 
150
+ /** Field geometry and the native interaction states, with disabled taking precedence. */
87
151
  export const input = variants(
88
152
  {
89
153
  base: {
90
154
  borderRadius: 'xs',
91
155
  color: 'content.primary',
92
156
  height: '48',
93
- paddingHorizontal: '20',
94
- paddingVertical: '16',
95
- typography: 'body.b2',
157
+ paddingHorizontal: '16',
158
+ paddingVertical: '12',
159
+ typography: 'control.label',
96
160
  },
97
- defaultVariants: { appearance: 'primary', extended: false },
161
+ defaultVariants: { appearance: 'primary', extended: false, state: 'default' },
98
162
  variants: {
99
163
  appearance: {
100
164
  primary: { backgroundColor: 'container.regular' },
101
165
  secondary: { borderColor: 'line.primary', borderWidth: 'regular' },
102
166
  },
103
- extended: { false: {}, true: { height: '80px !custom' } },
167
+ extended: { false: {}, true: { height: '80px !custom', paddingVertical: '16' } },
168
+ state: {
169
+ default: {},
170
+ // Preserve the literal black Value paint confirmed in Figma's rendered family.
171
+ disabled: { color: 'rgb(0 0 0 / 1) !custom' },
172
+ error: {
173
+ backgroundColor: 'container.negative',
174
+ borderColor: 'border.negative',
175
+ borderWidth: 'regular',
176
+ },
177
+ focused: {},
178
+ },
104
179
  },
180
+ compoundVariants: [
181
+ {
182
+ when: { appearance: 'primary', state: 'disabled' },
183
+ style: { backgroundColor: 'container.subtle' },
184
+ },
185
+ {
186
+ when: { appearance: 'secondary', state: 'disabled' },
187
+ style: { borderColor: 'line.secondary' },
188
+ },
189
+ {
190
+ when: { appearance: 'secondary', state: 'focused' },
191
+ style: { borderColor: 'border.focus' },
192
+ },
193
+ ],
105
194
  },
106
195
  { id: 'tds/mobile/text-input/input' },
107
196
  )
108
197
 
109
- export const label = style(
110
- { color: 'content.primary', typography: 'body.b2' },
198
+ /** Primary label, dimmed only while editing is disabled. */
199
+ export const label = variants(
200
+ {
201
+ base: { color: 'content.primary', typography: 'control.label' },
202
+ variants: { disabled: { false: {}, true: { color: 'component.control.content.tertiary' } } },
203
+ },
111
204
  { id: 'tds/mobile/text-input/label' },
112
205
  )
113
206
 
207
+ /** Label row spacing above the field. */
114
208
  export const labels = style(
115
209
  { alignItems: 'center', flexDirection: 'row', gap: '4', paddingBottom: '12' },
116
210
  { id: 'tds/mobile/text-input/labels' },
117
211
  )
118
212
 
119
- export const secondaryLabel = style(
120
- { color: 'content.secondary', typography: 'body.b2' },
213
+ /** Placeholder paint remains distinct from the native input's actual value. */
214
+ export const placeholder = variants(
215
+ {
216
+ base: { color: 'component.control.content.tertiary' },
217
+ variants: {
218
+ state: {
219
+ default: {},
220
+ disabled: { color: 'rgb(0 0 0 / 1) !custom' },
221
+ error: { color: 'content.primary' },
222
+ focused: { color: 'content.primary' },
223
+ },
224
+ },
225
+ },
226
+ { id: 'tds/mobile/text-input/placeholder' },
227
+ )
228
+
229
+ /** Secondary label beside the primary label. */
230
+ export const secondaryLabel = variants(
231
+ {
232
+ base: { color: 'component.control.content.secondary', typography: 'control.label' },
233
+ variants: { disabled: { false: {}, true: { color: 'component.control.content.tertiary' } } },
234
+ },
121
235
  { id: 'tds/mobile/text-input/secondary-label' },
122
236
  )
123
237
 
238
+ /** Stretch to the consumer's available width without fixing Figma's sample width. */
124
239
  export const textInput = style({ alignSelf: 'stretch' }, { id: 'tds/mobile/text-input' })
125
240
  }
@@ -1,3 +1,4 @@
1
+ /** Native product components, variables, and styling helpers. See the mobile README for setup and alignment limits. @module */
1
2
  export { Avatar } from './components/Avatar.js'
2
3
  export { Badge } from './components/Badge.js'
3
4
  export { Button } from './components/Button.js'
@@ -1,3 +1,4 @@
1
+ /** Mobile variables and control-scoped aliases for native product interfaces. @module */
1
2
  import { Vars } from 'zyzz'
2
3
  import { variables as core } from './primitives.js'
3
4
 
@@ -58,6 +59,10 @@ export const variables = Vars.define(
58
59
  },
59
60
  fill: { light: core.color.neutral['100'], dark: core.color.neutral['000'] },
60
61
  },
62
+ primaryPressed: {
63
+ light: core.color.neutral.shade['080'],
64
+ dark: core.color.neutral.tint['080'],
65
+ },
61
66
  tertiary: {
62
67
  border: {
63
68
  light: core.color.neutral.shade['000'],
@@ -66,6 +71,28 @@ export const variables = Vars.define(
66
71
  fill: { light: core.color.neutral.shade['000'], dark: core.color.neutral.tint['000'] },
67
72
  },
68
73
  },
74
+ control: {
75
+ content: {
76
+ secondary: {
77
+ light: core.color.neutral.shade['056'],
78
+ dark: core.color.neutral.tint['064'],
79
+ },
80
+ tertiary: {
81
+ light: core.color.neutral.shade['040'],
82
+ dark: core.color.neutral.tint['052'],
83
+ },
84
+ },
85
+ },
86
+ iconButton: {
87
+ glass: {
88
+ border: { light: core.color.neutral.shade['008'], dark: 'rgba(255, 255, 255, 0.05)' },
89
+ // Geometry is authored in IconButton: native boxShadow accepts the resolved color.
90
+ shadow: {
91
+ light: core.color.neutral.shade['012'],
92
+ dark: core.color.neutral.shade['024'],
93
+ },
94
+ },
95
+ },
69
96
  input: {
70
97
  overlay: {
71
98
  border: {
@@ -276,6 +303,29 @@ export const variables = Vars.define(
276
303
  lineHeight: '16px',
277
304
  },
278
305
  },
306
+ control: {
307
+ compact: {
308
+ fontFamily: vars.type.typeface.fonts.body,
309
+ fontSize: '12px',
310
+ fontWeight: 500,
311
+ letterSpacing: '0px',
312
+ lineHeight: '16px',
313
+ },
314
+ label: {
315
+ fontFamily: vars.type.typeface.fonts.body,
316
+ fontSize: '14px',
317
+ fontWeight: 400,
318
+ letterSpacing: '-0.084px',
319
+ lineHeight: '20px',
320
+ },
321
+ labelStrong: {
322
+ fontFamily: vars.type.typeface.fonts.body,
323
+ fontSize: '14px',
324
+ fontWeight: 500,
325
+ letterSpacing: '-0.084px',
326
+ lineHeight: '20px',
327
+ },
328
+ },
279
329
  display: {
280
330
  d1: {
281
331
  fontFamily: vars.type.typeface.fonts.display,
@@ -353,6 +403,30 @@ export const inverse = Vars.extend(variables, {
353
403
  secondary: { light: core.color.neutral['092'], dark: core.color.neutral['092'] },
354
404
  },
355
405
  component: {
406
+ button: {
407
+ primaryPressed: {
408
+ light: core.color.neutral.tint['080'],
409
+ dark: core.color.neutral.shade['080'],
410
+ },
411
+ },
412
+ control: {
413
+ content: {
414
+ secondary: {
415
+ light: core.color.neutral.tint['064'],
416
+ dark: core.color.neutral.shade['056'],
417
+ },
418
+ tertiary: {
419
+ light: core.color.neutral.tint['052'],
420
+ dark: core.color.neutral.shade['040'],
421
+ },
422
+ },
423
+ },
424
+ iconButton: {
425
+ glass: {
426
+ border: { light: 'rgba(255, 255, 255, 0.05)', dark: core.color.neutral.shade['008'] },
427
+ shadow: { light: core.color.neutral.shade['024'], dark: core.color.neutral.shade['012'] },
428
+ },
429
+ },
356
430
  pullTab: { light: core.color.neutral.tint['024'], dark: core.color.neutral.shade['012'] },
357
431
  },
358
432
  container: {
@@ -2,6 +2,8 @@ import type { ComponentPropsWithRef } from 'react'
2
2
  import type * as zyzz from 'zyzz'
3
3
  import { style, variants } from '../zyzz.config.js'
4
4
 
5
+ const mask = '•'.repeat(6)
6
+
5
7
  /**
6
8
  * Formats a number in `en-US`, or in `locale` when set, inside a `span` with tabular figures.
7
9
  * `currency` formats an ISO 4217 code as money, and `symbol` follows the number with a token
@@ -15,6 +17,7 @@ import { style, variants } from '../zyzz.config.js'
15
17
  * @example
16
18
  * <Amount currency="USD" value="1250.50" />
17
19
  * <Amount symbol="PathUSD" value="12.000001" />
20
+ * <Amount currency="USD" masked value="1250.50" />
18
21
  *
19
22
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat | MDN Intl.NumberFormat}
20
23
  * @see {@link https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html | WCAG 2.2 Info and Relationships}
@@ -25,6 +28,7 @@ export function Amount(props: Amount.Props) {
25
28
  className,
26
29
  currency,
27
30
  locale,
31
+ masked,
28
32
  maxDecimals,
29
33
  precise,
30
34
  sign,
@@ -39,6 +43,7 @@ export function Amount(props: Amount.Props) {
39
43
  return (
40
44
  <span
41
45
  {...attributes}
46
+ data-masked={masked || undefined}
42
47
  {...styles.amount({
43
48
  align: props.align,
44
49
  className,
@@ -48,9 +53,19 @@ export function Amount(props: Amount.Props) {
48
53
  vars,
49
54
  })}
50
55
  >
51
- {sign}
52
- {format({ currency, locale, maxDecimals, precise, value })}
53
- {symbol && <span {...styles.symbol()}> {symbol}</span>}
56
+ {/* A masked amount never formats its value, so the page holds only the fixed mask. */}
57
+ {masked ? (
58
+ <>
59
+ <span aria-hidden="true">{mask}</span>
60
+ <span {...styles.hidden()}>Hidden</span>
61
+ </>
62
+ ) : (
63
+ <>
64
+ {sign}
65
+ {format({ currency, locale, maxDecimals, precise, value })}
66
+ {symbol && <span {...styles.symbol()}> {symbol}</span>}
67
+ </>
68
+ )}
54
69
  </span>
55
70
  )
56
71
  }
@@ -65,6 +80,13 @@ export namespace Amount {
65
80
  * @default 'en-US'
66
81
  */
67
82
  locale?: string | undefined
83
+ /**
84
+ * Renders six dots in place of the sign, value, and unit. Screen readers read `Hidden` instead
85
+ * of the dots, and the value stays out of the DOM. The mask has a fixed length, so it does not
86
+ * reveal the size of the value.
87
+ * @default false
88
+ */
89
+ masked?: boolean | undefined
68
90
  /**
69
91
  * Caps the fraction digits shown. With `currency`, it never exceeds the currency's own digits
70
92
  * and sets the exact count, so `0` renders `$5`.
@@ -181,5 +203,17 @@ namespace styles {
181
203
  { id: 'tds/web/amount' },
182
204
  )
183
205
 
206
+ export const hidden = style(
207
+ {
208
+ clipPath: 'inset(50%) !custom',
209
+ height: '1',
210
+ overflow: 'hidden',
211
+ position: 'absolute',
212
+ whiteSpace: 'nowrap',
213
+ width: '1',
214
+ },
215
+ { id: 'tds/web/amount/hidden' },
216
+ )
217
+
184
218
  export const symbol = style({ color: 'content.secondary' }, { id: 'tds/web/amount/symbol' })
185
219
  }
@@ -14,6 +14,7 @@ import { useCopy } from './internal/useCopy.js'
14
14
  *
15
15
  * - Name the button by what it copies, such as `Copy address`, when the raw value reads poorly.
16
16
  * - Falls back to `document.execCommand('copy')` where the Clipboard API is unavailable or denied.
17
+ * If both fail, it calls `onCopyError` and shows no confirmation.
17
18
  *
18
19
  * @example
19
20
  * <CopyButton aria-label="Copy address" value={address} />
@@ -29,6 +30,7 @@ export function CopyButton(props: CopyButton.Props) {
29
30
  'aria-label': ariaLabel,
30
31
  copied: copiedProp,
31
32
  onCopy,
33
+ onCopyError,
32
34
  size = 'small',
33
35
  title,
34
36
  value,
@@ -49,6 +51,7 @@ export function CopyButton(props: CopyButton.Props) {
49
51
  // A parent that passes `copied` handles the click as it bubbles, so the button only reports.
50
52
  if (copiedProp !== undefined) return
51
53
  if (await own.copy()) onCopy?.()
54
+ else onCopyError?.()
52
55
  }}
53
56
  shape="icon"
54
57
  size={size}
@@ -78,6 +81,11 @@ export namespace CopyButton {
78
81
  disabled?: boolean | undefined
79
82
  /** Called after the value reaches the clipboard. */
80
83
  onCopy?: (() => void) | undefined
84
+ /**
85
+ * Called when neither the Clipboard API nor the fallback writes the value. The button keeps
86
+ * its copy icon and name, so show the recovery, such as selectable text, from this callback.
87
+ */
88
+ onCopyError?: (() => void) | undefined
81
89
  /** Text written to the clipboard. */
82
90
  value: string
83
91
  /**
@@ -10,6 +10,7 @@ const HexContext = createContext<
10
10
  evm?: boolean | undefined
11
11
  setSlack: (slack: number) => void
12
12
  slack: number
13
+ truncate: boolean
13
14
  value: string
14
15
  variant: 'filled' | 'inline'
15
16
  }
@@ -53,6 +54,8 @@ export declare namespace formatHex {
53
54
  *
54
55
  * - Truncation keeps both ends visible, so readers can compare prefixes and checksum endings.
55
56
  * - Add `copy` wherever readers need the full value, since the visible text omits its middle.
57
+ * - Set `truncate={false}` to show every character, wrapped across lines, such as for a receive
58
+ * address that people check or select by hand.
56
59
  * - The copy button is named `Copy <value>` by default. Pass `aria-label` to `Hex.Copy` to name
57
60
  * what it copies, such as `Copy address`.
58
61
  *
@@ -80,20 +83,25 @@ export namespace Hex {
80
83
  copy?: boolean | undefined
81
84
  }
82
85
 
83
- /** Copy button for the surrounding `Hex.Root`. In the `filled` variant, the whole row copies. */
86
+ /**
87
+ * Copy button for the surrounding `Hex.Root`. In the `filled` variant, the whole row copies,
88
+ * unless `truncate` is `false`, which keeps the full value selectable.
89
+ */
84
90
  export function Copy(props: Copy.Props) {
85
91
  const context = use(HexContext)
86
92
 
87
93
  if (!context) throw new Error('Hex.Copy must render inside Hex.Root')
88
94
 
95
+ const stretch = context.variant === 'filled' && context.truncate
96
+
89
97
  return (
90
98
  <CopyButton
91
99
  {...props}
92
100
  data-hex-copy=""
93
- {...(context.variant === 'filled' && { 'data-stretch': '' })}
101
+ {...(stretch && { 'data-stretch': '' })}
94
102
  // A transformed button would become the containing block for the row-wide ::after.
95
103
  style={{
96
- ...(context.variant === 'filled' && { position: 'static', transform: 'none' }),
104
+ ...(stretch && { position: 'static', transform: 'none' }),
97
105
  // Pulls the button over the space Midcut leaves after the visible text. `translate` keeps layout unchanged.
98
106
  ...(context.variant === 'inline' && { translate: `${-context.slack}px 0` }),
99
107
  ...props.style,
@@ -112,14 +120,24 @@ export namespace Hex {
112
120
  * Both parts throw when rendered outside it.
113
121
  */
114
122
  export function Root(props: Root.Props) {
115
- const { children, className, evm, size, value, variant = 'inline', vars, ...attributes } = props
123
+ const {
124
+ children,
125
+ className,
126
+ evm,
127
+ size,
128
+ truncate = true,
129
+ value,
130
+ variant = 'inline',
131
+ vars,
132
+ ...attributes
133
+ } = props
116
134
  const [slack, setSlack] = useState(0)
117
135
 
118
136
  return (
119
- <HexContext value={{ evm, setSlack, slack, value, variant }}>
137
+ <HexContext value={{ evm, setSlack, slack, truncate, value, variant }}>
120
138
  <span
121
139
  {...attributes}
122
- {...styles.root({ className, size, style: props.style, variant, vars })}
140
+ {...styles.root({ className, size, style: props.style, truncate, variant, vars })}
123
141
  >
124
142
  {children}
125
143
  </span>
@@ -129,12 +147,18 @@ export namespace Hex {
129
147
 
130
148
  export namespace Root {
131
149
  export type Props = ComponentPropsWithRef<'span'> &
132
- Omit<zyzz.Props.Variants<typeof styles.root>, 'variant'> & {
150
+ Omit<zyzz.Props.Variants<typeof styles.root>, 'truncate' | 'variant'> & {
133
151
  /**
134
152
  * Keeps a leading `0x` outside the truncated characters.
135
153
  * @default true
136
154
  */
137
155
  evm?: boolean | undefined
156
+ /**
157
+ * Middle-truncates the value to fit its container. `false` shows every character and wraps
158
+ * the value across lines.
159
+ * @default true
160
+ */
161
+ truncate?: boolean | undefined
138
162
  value: string
139
163
  /**
140
164
  * `filled` renders a tinted row sized by `size`: 32, 40 or 56px.
@@ -146,16 +170,17 @@ export namespace Hex {
146
170
 
147
171
  /**
148
172
  * The value, middle-truncated to the width of its container. The full value stays available
149
- * to assistive technology.
173
+ * to assistive technology. When `Hex.Root` sets `truncate={false}`, it renders every character
174
+ * and wraps.
150
175
  */
151
176
  export function Text(props: Text.Props) {
152
177
  const context = use(HexContext)
153
178
 
154
179
  if (!context) throw new Error('Hex.Text must render inside Hex.Root')
155
180
 
156
- const { evm = true, setSlack, value } = context
181
+ const { evm = true, setSlack, truncate, value } = context
157
182
  const prefix = evm && /^0x/i.test(value) ? value.slice(0, 2) : ''
158
- const short = formatHex(value, context) === value
183
+ const short = !truncate || formatHex(value, context) === value
159
184
  const ref = useRef<HTMLSpanElement>(null)
160
185
 
161
186
  // Midcut snaps its text to whole character pairs, so the visible end can fall short of this box.
@@ -180,11 +205,15 @@ export namespace Hex {
180
205
  observer.disconnect()
181
206
  setSlack(0)
182
207
  }
183
- }, [setSlack, value])
208
+ }, [setSlack, truncate, value])
184
209
 
185
210
  if (short)
186
211
  return (
187
- <span {...props} {...styles.text({ className: props.className, style: props.style })}>
212
+ <span
213
+ {...props}
214
+ data-hex-text=""
215
+ {...styles.text({ className: props.className, style: props.style })}
216
+ >
188
217
  {value}
189
218
  </span>
190
219
  )
@@ -314,10 +343,47 @@ namespace styles {
314
343
  },
315
344
  },
316
345
  },
346
+ // A wrapped value grows the row from its first line. The text pads that line to the height
347
+ // of the copy button, and the row pads the button, so the button centres on the first line.
348
+ {
349
+ when: { truncate: false, variant: 'inline' },
350
+ style: { selectors: { '&:has([data-hex-copy]) [data-hex-text]': { paddingBlock: '4' } } },
351
+ },
352
+ {
353
+ when: { size: 'large', truncate: false, variant: 'filled' },
354
+ style: {
355
+ height: 'auto !custom',
356
+ minHeight: '56',
357
+ paddingBlock: '8',
358
+ selectors: { '& [data-hex-text]': { paddingBlock: '12' } },
359
+ },
360
+ },
361
+ {
362
+ when: { size: 'medium', truncate: false, variant: 'filled' },
363
+ style: {
364
+ height: 'auto !custom',
365
+ minHeight: '40',
366
+ paddingBlock: '6',
367
+ selectors: { '& [data-hex-text]': { paddingBlock: '6' } },
368
+ },
369
+ },
370
+ {
371
+ when: { size: 'small', truncate: false, variant: 'filled' },
372
+ style: {
373
+ height: 'auto !custom',
374
+ minHeight: '32',
375
+ paddingBlock: '4',
376
+ selectors: { '& [data-hex-text]': { paddingBlock: '4' } },
377
+ },
378
+ },
317
379
  ],
318
- defaultVariants: { size: 'medium', variant: 'inline' },
380
+ defaultVariants: { size: 'medium', truncate: true, variant: 'inline' },
319
381
  variants: {
320
382
  size: { large: {}, medium: {}, small: {} },
383
+ truncate: {
384
+ false: { alignItems: 'start', whiteSpace: 'normal', wordBreak: 'break-all' },
385
+ true: {},
386
+ },
321
387
  variant: {
322
388
  filled: {
323
389
  backgroundColor: 'container.regular',