@passui/react 0.1.45 → 0.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -46
- package/dist/types/src/components/accordion/accordion.d.ts +1 -1
- package/dist/types/src/components/breadcrumb/breadcrumb.d.ts +1 -1
- package/dist/types/src/components/inline-disclosure/inline-disclosure.d.ts +1 -1
- package/dist/types/src/components/popover/anchored-surface.d.ts +5 -1
- package/dist/types/src/components/popover/index.d.ts +41 -0
- package/dist/types/src/components/popover/popover-content.d.ts +32 -0
- package/dist/types/src/components/popover/popover-root.d.ts +22 -0
- package/dist/types/src/components/popover/popover-trigger.d.ts +23 -0
- package/dist/types/src/components/stepper/rolling-digit.d.ts +1 -1
- package/dist/types/src/components/table/table.d.ts +1 -1
- package/dist/types/src/components/view-controller/view-controller.d.ts +2 -2
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/machines/popover.machine.d.ts +30 -0
- package/package.json +307 -307
- package/src/appearance/index.ts +2 -2
- package/src/appearance/platform.tsx +76 -60
- package/src/appearance/theme.tsx +409 -377
- package/src/components/accordion/accordion.tsx +58 -49
- package/src/components/ambient/ambient.tsx +25 -25
- package/src/components/ambient/index.ts +1 -1
- package/src/components/aspect-ratio/aspect-ratio.tsx +21 -16
- package/src/components/breadcrumb/breadcrumb.tsx +63 -57
- package/src/components/button/button-styles.ts +39 -32
- package/src/components/button/button.tsx +91 -84
- package/src/components/button/icon-button.tsx +27 -25
- package/src/components/button/pending-spinner.tsx +8 -8
- package/src/components/button/use-pending-indicator.ts +11 -11
- package/src/components/chip/chip.tsx +35 -30
- package/src/components/code-block/code-block.tsx +40 -39
- package/src/components/combo-box/combo-box.tsx +5 -5
- package/src/components/command/command.tsx +124 -94
- package/src/components/compact-date-picker/calendar-month.ts +75 -53
- package/src/components/compact-date-picker/compact-date-picker.tsx +308 -289
- package/src/components/compact-time-picker/compact-time-picker.tsx +288 -281
- package/src/components/compact-time-picker/time-value.ts +32 -29
- package/src/components/content-unavailable-view/content-unavailable-view.tsx +64 -48
- package/src/components/content-view/content-view.tsx +168 -159
- package/src/components/content-view/index.ts +1 -1
- package/src/components/context-menu/conceal-menu-source.ts +25 -25
- package/src/components/context-menu/context-menu-host.tsx +439 -402
- package/src/components/context-menu/context-menu-store.ts +125 -123
- package/src/components/context-menu/menu-navigation.ts +25 -18
- package/src/components/context-menu/menu-position.ts +33 -29
- package/src/components/context-menu/menu-reveal.ts +32 -32
- package/src/components/context-menu/use-context-menu.ts +63 -56
- package/src/components/conversation/conversation.tsx +265 -263
- package/src/components/conversation/index.ts +1 -1
- package/src/components/date-picker/date-picker.tsx +95 -94
- package/src/components/date-picker/date-value.ts +20 -10
- package/src/components/dialog/dialog-host.tsx +105 -103
- package/src/components/dialog/dialog-store.ts +37 -36
- package/src/components/dialog/dialog.tsx +192 -179
- package/src/components/dialog/index.ts +1 -1
- package/src/components/disclosure-group/disclosure-group.tsx +93 -86
- package/src/components/divider/divider.tsx +24 -22
- package/src/components/inline-disclosure/inline-disclosure.tsx +40 -36
- package/src/components/keyboard-shortcut/keyboard-shortcut.tsx +23 -19
- package/src/components/labeled-content/labeled-content.tsx +68 -68
- package/src/components/locale-switcher/index.ts +1 -1
- package/src/components/locale-switcher/locale-switcher.tsx +279 -251
- package/src/components/menu/menu.tsx +75 -58
- package/src/components/morph/index.ts +2 -2
- package/src/components/morph/morph.tsx +227 -201
- package/src/components/morph/use-morph-disclosure.ts +19 -19
- package/src/components/one-time-code/one-time-code.tsx +216 -200
- package/src/components/picker/picker-trigger.ts +16 -13
- package/src/components/picker/picker.tsx +371 -345
- package/src/components/popover/anchored-surface.tsx +253 -229
- package/src/components/popover/index.ts +50 -0
- package/src/components/popover/popover-content.tsx +334 -0
- package/src/components/popover/popover-fit.ts +58 -53
- package/src/components/popover/popover-root.tsx +97 -0
- package/src/components/popover/popover-trigger.tsx +71 -0
- package/src/components/profile-image/profile-image.tsx +80 -64
- package/src/components/progress-view/progress-view.tsx +61 -59
- package/src/components/progress-view/use-liquid-progress.ts +38 -38
- package/src/components/radio-group/radio-group.tsx +71 -68
- package/src/components/search-field/expanding-search-field.tsx +191 -177
- package/src/components/search-field/search-field.tsx +59 -50
- package/src/components/search-list/search-list.tsx +246 -236
- package/src/components/section/section.tsx +58 -58
- package/src/components/secure-field/secure-field.tsx +3 -3
- package/src/components/segmented-control/segmented-control.tsx +136 -136
- package/src/components/sheet/modal-environment.ts +71 -64
- package/src/components/sheet/sheet-portal.tsx +58 -53
- package/src/components/sheet/sheet.tsx +146 -141
- package/src/components/sheet/use-sheet-focus.ts +97 -82
- package/src/components/sidebar/sidebar.tsx +78 -78
- package/src/components/skeleton/skeleton.tsx +30 -21
- package/src/components/slider/slider.tsx +113 -104
- package/src/components/slosh-slider/liquid-step.ts +32 -31
- package/src/components/slosh-slider/slosh-slider.tsx +265 -228
- package/src/components/stat-tile/index.ts +1 -1
- package/src/components/stat-tile/stat-tile.tsx +79 -68
- package/src/components/status-indicator/status-indicator.tsx +40 -37
- package/src/components/stepper/rolling-digit.tsx +82 -68
- package/src/components/stepper/stepper.tsx +122 -113
- package/src/components/swatch-picker/swatch-picker.tsx +120 -120
- package/src/components/tab-bar/tab-bar.tsx +149 -148
- package/src/components/tab-view/tab-view.tsx +140 -137
- package/src/components/table/table.tsx +117 -98
- package/src/components/text-editor/text-editor.tsx +34 -29
- package/src/components/text-field/text-field.tsx +182 -180
- package/src/components/toast/toast-store.ts +127 -115
- package/src/components/toast/toaster.tsx +361 -347
- package/src/components/toggle/toggle.tsx +297 -282
- package/src/components/tooltip/tooltip-host.tsx +157 -150
- package/src/components/view-controller/index.ts +1 -1
- package/src/components/view-controller/view-controller.tsx +64 -53
- package/src/components/wake-slider/wake-slider.tsx +220 -205
- package/src/hooks/scroll/minimize-decision.ts +11 -7
- package/src/hooks/use-anchored-disclosure.ts +19 -19
- package/src/hooks/use-anchored-placement.ts +29 -25
- package/src/hooks/use-dismiss.ts +33 -29
- package/src/hooks/use-floating-dismiss.ts +24 -22
- package/src/hooks/use-media-query.ts +67 -60
- package/src/hooks/use-minimize-on-scroll.ts +69 -60
- package/src/hooks/use-visual-viewport.ts +63 -63
- package/src/hooks/viewport/types.ts +16 -16
- package/src/hooks/viewport/viewport-metrics.ts +16 -10
- package/src/icons/icons.tsx +440 -328
- package/src/index.ts +91 -91
- package/src/lib/anchored-placement.ts +70 -65
- package/src/lib/class-names.ts +14 -13
- package/src/lib/clipboard.ts +8 -7
- package/src/lib/date.ts +61 -60
- package/src/lib/floating-layers.ts +39 -24
- package/src/lib/haptics.ts +10 -10
- package/src/lib/language.ts +9 -9
- package/src/lib/range-value.ts +27 -21
- package/src/lib/screen-edges.ts +33 -30
- package/src/lib/shapes.ts +38 -34
- package/src/machines/popover.machine.ts +51 -0
- package/src/motion/transitions.ts +46 -43
- package/src/styles/code-block.css +69 -43
- package/src/styles/motion-controls.css +393 -191
- package/src/tokens.ts +1 -1
- package/dist/types/src/components/popover/popover.d.ts +0 -21
- package/src/components/popover/popover.tsx +0 -334
|
@@ -1,218 +1,234 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "react"
|
|
9
|
-
import { CheckIcon } from "../../icons/icons"
|
|
10
|
-
import { cn } from "../../lib/class-names"
|
|
2
|
+
type CSSProperties,
|
|
3
|
+
type InputHTMLAttributes,
|
|
4
|
+
type Ref,
|
|
5
|
+
useEffect,
|
|
6
|
+
useId,
|
|
7
|
+
useRef,
|
|
8
|
+
} from "react";
|
|
9
|
+
import { CheckIcon } from "../../icons/icons";
|
|
10
|
+
import { cn } from "../../lib/class-names";
|
|
11
11
|
|
|
12
|
-
export type OneTimeCodeStatus = "idle" | "verifying" | "success" | "error"
|
|
13
|
-
export type OneTimeCodeFormat = "numeric" | "alphanumeric"
|
|
14
|
-
export type OneTimeCodeSize = "sm" | "md" | "lg"
|
|
12
|
+
export type OneTimeCodeStatus = "idle" | "verifying" | "success" | "error";
|
|
13
|
+
export type OneTimeCodeFormat = "numeric" | "alphanumeric";
|
|
14
|
+
export type OneTimeCodeSize = "sm" | "md" | "lg";
|
|
15
15
|
|
|
16
16
|
const checkSizes: Record<OneTimeCodeSize, number> = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
17
|
+
sm: 20,
|
|
18
|
+
md: 24,
|
|
19
|
+
lg: 28,
|
|
20
|
+
};
|
|
21
21
|
const statusText: Record<OneTimeCodeSize, string> = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
22
|
+
sm: "mt-1.5 text-caption2",
|
|
23
|
+
md: "mt-2 text-footnote",
|
|
24
|
+
lg: "mt-2.5 text-subheadline",
|
|
25
|
+
};
|
|
26
26
|
export interface OneTimeCodeProps
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
extends Omit<
|
|
28
|
+
InputHTMLAttributes<HTMLInputElement>,
|
|
29
|
+
"value" | "defaultValue" | "onChange" | "type" | "maxLength" | "size"
|
|
30
|
+
> {
|
|
31
|
+
label: string;
|
|
32
|
+
value: string;
|
|
33
|
+
onChange: (value: string) => void;
|
|
34
|
+
/** Called when a complete code is entered, including paste and autofill. */
|
|
35
|
+
onComplete?: (value: string) => void;
|
|
36
|
+
/** Number of characters, 3–8. @default 6 */
|
|
37
|
+
length?: number;
|
|
38
|
+
/** Accepted characters. Alphanumeric codes use uppercase ASCII letters and digits. @default "numeric" */
|
|
39
|
+
format?: OneTimeCodeFormat;
|
|
40
|
+
/** Ref to the single native input, for focus and selection. */
|
|
41
|
+
ref?: Ref<HTMLInputElement>;
|
|
42
|
+
status?: OneTimeCodeStatus;
|
|
43
|
+
/** Localized verification feedback announced without reading decorative cells. */
|
|
44
|
+
statusLabel?: string;
|
|
45
|
+
/** Cell height, digit text scale and check icon size. @default "md" */
|
|
46
|
+
size?: OneTimeCodeSize;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/** Normalize common numeric keyboards and optional ASCII letters in one native field. */
|
|
50
50
|
export function normalizeCode(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
value: string,
|
|
52
|
+
length: number,
|
|
53
|
+
format: OneTimeCodeFormat = "numeric",
|
|
54
54
|
) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
return Array.from(value, (digit) => {
|
|
56
|
+
const point = digit.codePointAt(0) ?? 0;
|
|
57
|
+
for (const base of [0x30, 0x660, 0x6f0, 0xff10]) {
|
|
58
|
+
if (point >= base && point < base + 10) return String(point - base);
|
|
59
|
+
}
|
|
60
|
+
return format === "alphanumeric" && /^[a-z]$/i.test(digit)
|
|
61
|
+
? digit.toUpperCase()
|
|
62
|
+
: "";
|
|
63
|
+
})
|
|
64
|
+
.join("")
|
|
65
|
+
.slice(0, length);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
/** Six cells, one field: paste, autofill, selection and Backspace stay native. */
|
|
67
69
|
export function OneTimeCode({
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
label,
|
|
71
|
+
value,
|
|
72
|
+
onChange,
|
|
73
|
+
onComplete,
|
|
74
|
+
length = 6,
|
|
75
|
+
format = "numeric",
|
|
76
|
+
ref,
|
|
77
|
+
status = "idle",
|
|
78
|
+
statusLabel,
|
|
79
|
+
size = "md",
|
|
80
|
+
className,
|
|
81
|
+
disabled,
|
|
82
|
+
id: suppliedId,
|
|
83
|
+
...props
|
|
82
84
|
}: OneTimeCodeProps) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
85
|
+
const generated = useId();
|
|
86
|
+
const id = suppliedId ?? generated;
|
|
87
|
+
const filter = `otp-goo-${generated.replace(/:/g, "")}`;
|
|
88
|
+
const input = useRef<HTMLInputElement>(null);
|
|
89
|
+
const count = Number.isFinite(length)
|
|
90
|
+
? Math.max(3, Math.min(8, Math.round(length)))
|
|
91
|
+
: 6;
|
|
92
|
+
const code = normalizeCode(value, count, format);
|
|
93
|
+
const locked =
|
|
94
|
+
disabled ||
|
|
95
|
+
props.readOnly ||
|
|
96
|
+
status === "verifying" ||
|
|
97
|
+
status === "success";
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (status === "error") input.current?.select();
|
|
100
|
+
}, [status]);
|
|
101
|
+
const update = (next: string) => {
|
|
102
|
+
if (locked) return;
|
|
103
|
+
const normalized = normalizeCode(next, count, format);
|
|
104
|
+
onChange(normalized);
|
|
105
|
+
if (normalized.length === count && normalized !== code)
|
|
106
|
+
onComplete?.(normalized);
|
|
107
|
+
};
|
|
108
|
+
return (
|
|
109
|
+
<div
|
|
110
|
+
className={cn("passui-one-time-code not-typeset", className)}
|
|
111
|
+
data-status={status}
|
|
112
|
+
data-size={size}
|
|
113
|
+
style={
|
|
114
|
+
{
|
|
115
|
+
"--otp-length": count,
|
|
116
|
+
"--otp-middle": (count - 1) / 2,
|
|
117
|
+
} as CSSProperties
|
|
118
|
+
}
|
|
119
|
+
>
|
|
120
|
+
<svg aria-hidden="true" width="0" height="0" className="absolute">
|
|
121
|
+
<defs>
|
|
122
|
+
<filter
|
|
123
|
+
id={filter}
|
|
124
|
+
x="-20%"
|
|
125
|
+
y="-50%"
|
|
126
|
+
width="140%"
|
|
127
|
+
height="200%"
|
|
128
|
+
colorInterpolationFilters="sRGB"
|
|
129
|
+
>
|
|
130
|
+
<feGaussianBlur stdDeviation="3" result="smear" />
|
|
131
|
+
<feColorMatrix
|
|
132
|
+
in="smear"
|
|
133
|
+
type="matrix"
|
|
134
|
+
values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 24 -10"
|
|
135
|
+
/>
|
|
136
|
+
</filter>
|
|
137
|
+
</defs>
|
|
138
|
+
</svg>
|
|
139
|
+
<div className="passui-otp-row" dir="ltr">
|
|
140
|
+
{/* A right code fuses: cells converge on one point while a capsule
|
|
127
141
|
grows there. The filter joins the material, never the digits. */}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
142
|
+
<div
|
|
143
|
+
aria-hidden="true"
|
|
144
|
+
className="passui-otp-materials"
|
|
145
|
+
style={{ filter: `url(#${filter})` }}
|
|
146
|
+
>
|
|
147
|
+
{Array.from({ length: count }, (_, index) => (
|
|
148
|
+
<span
|
|
149
|
+
key={index}
|
|
150
|
+
className="passui-otp-cell"
|
|
151
|
+
style={{ "--otp-index": index } as CSSProperties}
|
|
152
|
+
/>
|
|
153
|
+
))}
|
|
154
|
+
<span className="passui-otp-capsule" />
|
|
155
|
+
</div>
|
|
156
|
+
<div aria-hidden="true" className="passui-otp-digits">
|
|
157
|
+
{Array.from({ length: count }, (_, index) => (
|
|
158
|
+
<span
|
|
159
|
+
key={index}
|
|
160
|
+
className="passui-otp-digit"
|
|
161
|
+
data-active={
|
|
162
|
+
index === Math.min(code.length, count - 1) || undefined
|
|
163
|
+
}
|
|
164
|
+
style={{ "--otp-index": index } as CSSProperties}
|
|
165
|
+
>
|
|
166
|
+
{code[index] && (
|
|
167
|
+
<span key={code[index] ?? index} className="passui-otp-glyph">
|
|
168
|
+
{code[index]}
|
|
169
|
+
</span>
|
|
170
|
+
)}
|
|
171
|
+
</span>
|
|
172
|
+
))}
|
|
173
|
+
</div>
|
|
174
|
+
<CheckIcon
|
|
175
|
+
aria-hidden="true"
|
|
176
|
+
className="passui-otp-check"
|
|
177
|
+
size={checkSizes[size]}
|
|
178
|
+
/>
|
|
179
|
+
<input
|
|
180
|
+
{...props}
|
|
181
|
+
ref={(node) => {
|
|
182
|
+
input.current = node;
|
|
183
|
+
if (typeof ref === "function") return ref(node);
|
|
184
|
+
if (ref) ref.current = node;
|
|
185
|
+
}}
|
|
186
|
+
id={id}
|
|
187
|
+
type="text"
|
|
188
|
+
inputMode={format === "numeric" ? "numeric" : "text"}
|
|
189
|
+
autoComplete={props.autoComplete ?? "one-time-code"}
|
|
190
|
+
autoCapitalize={format === "alphanumeric" ? "characters" : "off"}
|
|
191
|
+
spellCheck={false}
|
|
192
|
+
pattern={format === "numeric" ? "[0-9]*" : "[A-Za-z0-9]*"}
|
|
193
|
+
maxLength={count}
|
|
194
|
+
minLength={count}
|
|
195
|
+
aria-label={label}
|
|
196
|
+
value={code}
|
|
197
|
+
disabled={disabled}
|
|
198
|
+
readOnly={locked}
|
|
199
|
+
aria-busy={status === "verifying" || undefined}
|
|
200
|
+
aria-invalid={status === "error" || props["aria-invalid"]}
|
|
201
|
+
aria-describedby={
|
|
202
|
+
[props["aria-describedby"], statusLabel && `${id}-status`]
|
|
203
|
+
.filter(Boolean)
|
|
204
|
+
.join(" ") || undefined
|
|
205
|
+
}
|
|
206
|
+
onChange={(event) => update(event.target.value)}
|
|
207
|
+
onPaste={(event) => {
|
|
208
|
+
props.onPaste?.(event);
|
|
209
|
+
if (event.defaultPrevented || locked) return;
|
|
210
|
+
const pasted = event.clipboardData.getData("text");
|
|
211
|
+
const normalized = normalizeCode(pasted, count, format);
|
|
212
|
+
if (normalized && normalized !== pasted) {
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
update(normalized);
|
|
215
|
+
}
|
|
216
|
+
}}
|
|
217
|
+
className="passui-otp-input"
|
|
218
|
+
/>
|
|
219
|
+
</div>
|
|
220
|
+
{statusLabel && (
|
|
221
|
+
<p
|
|
222
|
+
id={`${id}-status`}
|
|
223
|
+
role="status"
|
|
224
|
+
className={cn(
|
|
225
|
+
statusText[size],
|
|
226
|
+
status === "error" ? "text-danger" : "text-label-secondary",
|
|
227
|
+
)}
|
|
228
|
+
>
|
|
229
|
+
{statusLabel}
|
|
230
|
+
</p>
|
|
231
|
+
)}
|
|
232
|
+
</div>
|
|
233
|
+
);
|
|
218
234
|
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { cn } from "../../lib/class-names"
|
|
1
|
+
import { cn } from "../../lib/class-names";
|
|
2
2
|
|
|
3
|
-
export type PickerSize = "sm" | "md" | "lg"
|
|
3
|
+
export type PickerSize = "sm" | "md" | "lg";
|
|
4
4
|
|
|
5
5
|
const triggerSizes: Record<PickerSize, string> = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
6
|
+
sm: "px-2.5 py-1.5 text-caption rounded-lg",
|
|
7
|
+
md: "px-3 py-2 text-subheadline rounded-lg",
|
|
8
|
+
lg: "px-4 py-3 text-body rounded-xl",
|
|
9
|
+
};
|
|
10
10
|
|
|
11
11
|
/** Shared field treatment for the popup-based Picker, date and time controls. */
|
|
12
|
-
export function pickerTriggerStyle(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
export function pickerTriggerStyle(
|
|
13
|
+
className?: string,
|
|
14
|
+
size: PickerSize = "md",
|
|
15
|
+
) {
|
|
16
|
+
return cn(
|
|
17
|
+
"control-field text-label flex w-full min-w-0 items-center gap-2 text-start",
|
|
18
|
+
"disabled:cursor-not-allowed disabled:opacity-40",
|
|
19
|
+
triggerSizes[size],
|
|
20
|
+
className,
|
|
21
|
+
);
|
|
19
22
|
}
|