@tempoxyz/ds 0.3.14 → 0.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/AGENTS.md +75 -10
- package/dist/docs/arsenal.md +44 -0
- package/dist/docs/{marketing/introduction/getting-started.md → marketing.md} +32 -24
- package/dist/docs/product/components/actions.md +2110 -0
- package/dist/docs/product/components/blockchain.md +3969 -0
- package/dist/docs/product/components/data-display.md +5901 -0
- package/dist/docs/product/components/feedback-and-status.md +4138 -0
- package/dist/docs/product/components/forms-and-inputs.md +10543 -0
- package/dist/docs/product/components/layout.md +3339 -0
- package/dist/docs/product/components/navigation.md +2914 -0
- package/dist/docs/product/components/overlays.md +4917 -0
- package/dist/docs/product/components.md +125 -125
- package/dist/docs/product/foundations.md +4597 -0
- package/dist/docs/product/patterns.md +10110 -0
- package/dist/marketing/index.js.zyzz.json +1 -1
- package/dist/marketing/vars.d.ts +618 -758
- package/dist/marketing/vars.d.ts.map +1 -1
- package/dist/marketing/vars.js +8 -5
- package/dist/marketing/vars.js.map +1 -1
- package/dist/marketing/vars.js.zyzz.json +1 -1
- package/dist/marketing/zyzz.config.d.ts +3042 -3757
- package/dist/marketing/zyzz.config.d.ts.map +1 -1
- package/dist/marketing/zyzz.config.js +1 -1
- package/dist/marketing/zyzz.config.js.map +1 -1
- package/dist/marketing/zyzz.config.js.zyzz.json +1 -1
- package/dist/mobile/components/Button.d.ts +115 -15
- package/dist/mobile/components/Button.d.ts.map +1 -1
- package/dist/mobile/components/Button.js +85 -14
- package/dist/mobile/components/Button.js.map +1 -1
- package/dist/mobile/components/IconButton.d.ts +129 -40
- package/dist/mobile/components/IconButton.d.ts.map +1 -1
- package/dist/mobile/components/IconButton.js +97 -28
- package/dist/mobile/components/IconButton.js.map +1 -1
- package/dist/mobile/components/TextInput.d.ts +132 -11
- package/dist/mobile/components/TextInput.d.ts.map +1 -1
- package/dist/mobile/components/TextInput.js +115 -14
- package/dist/mobile/components/TextInput.js.map +1 -1
- package/dist/mobile/index.d.ts +1 -0
- package/dist/mobile/index.d.ts.map +1 -1
- package/dist/mobile/index.js +1 -0
- package/dist/mobile/index.js.map +1 -1
- package/dist/mobile/vars.d.ts +103 -0
- package/dist/mobile/vars.d.ts.map +1 -1
- package/dist/mobile/vars.js +74 -0
- package/dist/mobile/vars.js.map +1 -1
- package/dist/mobile/zyzz.config.d.ts +408 -0
- package/dist/mobile/zyzz.config.d.ts.map +1 -1
- package/dist/web/components/AddressCard.js.zyzz.json +1 -1
- package/dist/web/components/Amount.css +1 -1
- package/dist/web/components/Amount.d.ts +9 -0
- package/dist/web/components/Amount.d.ts.map +1 -1
- package/dist/web/components/Amount.js +8 -5
- package/dist/web/components/Amount.js.map +1 -1
- package/dist/web/components/Amount.js.zyzz.json +1 -1
- package/dist/web/components/CopyButton.d.ts +6 -0
- package/dist/web/components/CopyButton.d.ts.map +1 -1
- package/dist/web/components/CopyButton.js +4 -1
- package/dist/web/components/CopyButton.js.map +1 -1
- package/dist/web/components/CopyButton.js.zyzz.json +1 -1
- package/dist/web/components/Hex.css +1 -1
- package/dist/web/components/Hex.d.ts +84 -3
- package/dist/web/components/Hex.d.ts.map +1 -1
- package/dist/web/components/Hex.js +20 -13
- package/dist/web/components/Hex.js.map +1 -1
- package/dist/web/components/Hex.js.zyzz.json +1 -1
- package/dist/web/components/Progress.css +1 -1
- package/dist/web/components/Progress.d.ts +12 -2
- package/dist/web/components/Progress.d.ts.map +1 -1
- package/dist/web/components/Progress.js +9 -5
- package/dist/web/components/Progress.js.map +1 -1
- package/dist/web/components/Progress.js.zyzz.json +1 -1
- package/dist/web/components/SecretValue.js.zyzz.json +1 -1
- package/dist/web/components/SidebarMenu.d.ts +4 -4
- package/dist/web/components/SidebarMenu.js +6 -6
- package/dist/web/components/SidebarMenu.js.map +1 -1
- package/dist/web/components/Snippet.js.zyzz.json +1 -1
- package/dist/web/index.js.zyzz.json +1 -1
- package/package.json +1 -1
- package/src/marketing/README.md +1 -1
- package/src/marketing/vars.ts +526 -604
- package/src/marketing/zyzz.config.ts +5 -4
- package/src/mobile/README.md +19 -6
- package/src/mobile/components/Button.tsx +94 -17
- package/src/mobile/components/IconButton.tsx +122 -30
- package/src/mobile/components/TextInput.tsx +139 -24
- package/src/mobile/index.ts +1 -0
- package/src/mobile/vars.ts +74 -0
- package/src/web/components/Amount.tsx +37 -3
- package/src/web/components/CopyButton.tsx +8 -0
- package/src/web/components/Hex.tsx +79 -13
- package/src/web/components/Progress.tsx +8 -2
- package/src/web/components/SidebarMenu.tsx +6 -6
- package/dist/docs/index.md +0 -145
- package/dist/docs/product/components/accordion.md +0 -489
- package/dist/docs/product/components/address-card.md +0 -147
- package/dist/docs/product/components/agent-logo.md +0 -194
- package/dist/docs/product/components/alert-dialog.md +0 -631
- package/dist/docs/product/components/alert.md +0 -448
- package/dist/docs/product/components/amount-input.md +0 -305
- package/dist/docs/product/components/amount.md +0 -794
- package/dist/docs/product/components/app-shell.md +0 -559
- package/dist/docs/product/components/asset-chip.md +0 -294
- package/dist/docs/product/components/autocomplete.md +0 -620
- package/dist/docs/product/components/avatar.md +0 -321
- package/dist/docs/product/components/badge.md +0 -339
- package/dist/docs/product/components/badged-logo.md +0 -116
- package/dist/docs/product/components/banner.md +0 -379
- package/dist/docs/product/components/bar-chart.md +0 -208
- package/dist/docs/product/components/breadcrumbs.md +0 -380
- package/dist/docs/product/components/button-group.md +0 -286
- package/dist/docs/product/components/button.md +0 -650
- package/dist/docs/product/components/calendar.md +0 -375
- package/dist/docs/product/components/callout.md +0 -96
- package/dist/docs/product/components/checkbox-group.md +0 -521
- package/dist/docs/product/components/checkbox.md +0 -467
- package/dist/docs/product/components/choice-group.md +0 -516
- package/dist/docs/product/components/choicebox.md +0 -641
- package/dist/docs/product/components/code.md +0 -100
- package/dist/docs/product/components/combobox.md +0 -939
- package/dist/docs/product/components/container.md +0 -257
- package/dist/docs/product/components/copy-button.md +0 -642
- package/dist/docs/product/components/date-picker.md +0 -514
- package/dist/docs/product/components/dialog.md +0 -1332
- package/dist/docs/product/components/drawer.md +0 -966
- package/dist/docs/product/components/empty.md +0 -340
- package/dist/docs/product/components/field.md +0 -570
- package/dist/docs/product/components/fieldset.md +0 -398
- package/dist/docs/product/components/frame.md +0 -434
- package/dist/docs/product/components/gauge.md +0 -299
- package/dist/docs/product/components/get-started-visual.md +0 -117
- package/dist/docs/product/components/grid.md +0 -288
- package/dist/docs/product/components/hero-visual.md +0 -155
- package/dist/docs/product/components/hex.md +0 -487
- package/dist/docs/product/components/icon-tile.md +0 -292
- package/dist/docs/product/components/identicon.md +0 -371
- package/dist/docs/product/components/inline.md +0 -233
- package/dist/docs/product/components/inset.md +0 -225
- package/dist/docs/product/components/kbd.md +0 -423
- package/dist/docs/product/components/list-group.md +0 -981
- package/dist/docs/product/components/loading-dots.md +0 -237
- package/dist/docs/product/components/menu.md +0 -934
- package/dist/docs/product/components/native-select.md +0 -204
- package/dist/docs/product/components/network-logo.md +0 -248
- package/dist/docs/product/components/number-field.md +0 -543
- package/dist/docs/product/components/otp-field.md +0 -616
- package/dist/docs/product/components/pagination.md +0 -516
- package/dist/docs/product/components/popover.md +0 -544
- package/dist/docs/product/components/progress.md +0 -388
- package/dist/docs/product/components/qr.md +0 -314
- package/dist/docs/product/components/radio-group.md +0 -528
- package/dist/docs/product/components/secret-value.md +0 -406
- package/dist/docs/product/components/select.md +0 -751
- package/dist/docs/product/components/separator.md +0 -379
- package/dist/docs/product/components/sidebar-menu.md +0 -922
- package/dist/docs/product/components/skeleton.md +0 -517
- package/dist/docs/product/components/slider.md +0 -539
- package/dist/docs/product/components/snippet.md +0 -424
- package/dist/docs/product/components/spinner.md +0 -216
- package/dist/docs/product/components/split-bar.md +0 -139
- package/dist/docs/product/components/split-button.md +0 -464
- package/dist/docs/product/components/stack.md +0 -299
- package/dist/docs/product/components/status-chip.md +0 -226
- package/dist/docs/product/components/status-indicator.md +0 -119
- package/dist/docs/product/components/status-row.md +0 -174
- package/dist/docs/product/components/stepper.md +0 -451
- package/dist/docs/product/components/success-hero.md +0 -157
- package/dist/docs/product/components/surface.md +0 -639
- package/dist/docs/product/components/switch.md +0 -472
- package/dist/docs/product/components/table.md +0 -968
- package/dist/docs/product/components/tabs.md +0 -627
- package/dist/docs/product/components/tempo-logo.md +0 -185
- package/dist/docs/product/components/text-input.md +0 -624
- package/dist/docs/product/components/textarea.md +0 -352
- package/dist/docs/product/components/toast.md +0 -535
- package/dist/docs/product/components/token-logo.md +0 -371
- package/dist/docs/product/components/token.md +0 -247
- package/dist/docs/product/components/tooltip.md +0 -490
- package/dist/docs/product/components/verification-code.md +0 -116
- package/dist/docs/product/components/visual.md +0 -249
- package/dist/docs/product/foundations/accessibility.md +0 -377
- package/dist/docs/product/foundations/agents.md +0 -159
- package/dist/docs/product/foundations/color.md +0 -522
- package/dist/docs/product/foundations/content/tone.md +0 -194
- package/dist/docs/product/foundations/content/voice.md +0 -194
- package/dist/docs/product/foundations/content/writing-style.md +0 -406
- package/dist/docs/product/foundations/iconography.md +0 -282
- package/dist/docs/product/foundations/intent.md +0 -360
- package/dist/docs/product/foundations/layout.md +0 -508
- package/dist/docs/product/foundations/linter.md +0 -523
- package/dist/docs/product/foundations/motion.md +0 -151
- package/dist/docs/product/foundations/radius-and-padding.md +0 -86
- package/dist/docs/product/foundations/typography.md +0 -331
- package/dist/docs/product/introduction/faq.md +0 -133
- package/dist/docs/product/introduction/getting-started.md +0 -377
- package/dist/docs/product/patterns/blockchain-values.md +0 -709
- package/dist/docs/product/patterns/dashboards.md +0 -638
- package/dist/docs/product/patterns/destructive-actions.md +0 -626
- package/dist/docs/product/patterns/empty-states.md +0 -612
- package/dist/docs/product/patterns/errors-and-validation.md +0 -808
- package/dist/docs/product/patterns/feedback-and-status.md +0 -518
- package/dist/docs/product/patterns/forms.md +0 -679
- package/dist/docs/product/patterns/loading.md +0 -630
- package/dist/docs/product/patterns/navigation.md +0 -397
- package/dist/docs/product/patterns/payments.md +0 -765
- package/dist/docs/product/patterns/responsive-layout.md +0 -997
- package/dist/docs/product/patterns/tables-and-lists.md +0 -1170
- package/dist/docs/product/products/tempo-console.md +0 -671
- package/dist/docs/product/products/tempo-performance.md +0 -435
- package/dist/docs/product/products/tempo-wallet.md +0 -438
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 &&
|
|
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.
|
|
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
|
-
|
|
83
|
-
|
|
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: '
|
|
94
|
-
paddingVertical: '
|
|
95
|
-
typography: '
|
|
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
|
-
|
|
110
|
-
|
|
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
|
-
|
|
120
|
-
|
|
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
|
}
|
package/src/mobile/index.ts
CHANGED
|
@@ -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'
|
package/src/mobile/vars.ts
CHANGED
|
@@ -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
|
-
{
|
|
52
|
-
{
|
|
53
|
-
|
|
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
|
-
/**
|
|
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
|
-
{...(
|
|
101
|
+
{...(stretch && { 'data-stretch': '' })}
|
|
94
102
|
// A transformed button would become the containing block for the row-wide ::after.
|
|
95
103
|
style={{
|
|
96
|
-
...(
|
|
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 {
|
|
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
|
|
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',
|