@alulore/kumiko 0.17.3 → 0.18.2
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/avatar/avatar-name.d.ts +12 -0
- package/dist/avatar/avatar-name.js +42 -0
- package/dist/avatar/avatar.css +274 -0
- package/dist/avatar/avatar.d.ts +72 -0
- package/dist/avatar/avatar.js +45 -0
- package/dist/avatar/index.d.ts +3 -0
- package/dist/avatar/index.js +3 -0
- package/dist/board/board-api.d.ts +1 -0
- package/dist/board/board-selection.d.ts +1 -0
- package/dist/board/board-slots.d.ts +7 -0
- package/dist/board/board-slots.js +2 -1
- package/dist/board/refused-home.js +26 -1
- package/dist/dialog/dialog.css +7 -1
- package/dist/dialog/dialog.d.ts +9 -0
- package/dist/dialog/dialog.js +20 -0
- package/dist/dialog/index.d.ts +4 -3
- package/dist/dialog/index.js +4 -3
- package/dist/drawer/drawer.css +514 -0
- package/dist/drawer/drawer.d.ts +55 -0
- package/dist/drawer/drawer.js +43 -0
- package/dist/drawer/index.d.ts +2 -0
- package/dist/drawer/index.js +2 -0
- package/dist/file-input/file-dropzone.d.ts +67 -0
- package/dist/file-input/file-dropzone.js +97 -0
- package/dist/file-input/file-input.css +505 -0
- package/dist/file-input/file-input.d.ts +29 -0
- package/dist/file-input/file-input.js +21 -0
- package/dist/file-input/file-preview.d.ts +15 -0
- package/dist/file-input/file-preview.js +41 -0
- package/dist/file-input/index.d.ts +4 -0
- package/dist/file-input/index.js +4 -0
- package/dist/hover-card/hover-card.js +2 -0
- package/dist/media-viewer/index.d.ts +1 -0
- package/dist/media-viewer/index.js +1 -0
- package/dist/media-viewer/labels.d.ts +27 -0
- package/dist/media-viewer/labels.js +23 -0
- package/dist/media-viewer/media-viewer.d.ts +3 -0
- package/dist/media-viewer/media-viewer.js +6 -3
- package/dist/media-viewer/video-controls.js +4 -2
- package/dist/media-viewer/viewer-chrome.js +11 -5
- package/dist/menu/menu.js +2 -0
- package/dist/motion/settle-close.d.ts +5 -0
- package/dist/motion/settle-close.js +78 -0
- package/dist/otp-input/index.d.ts +2 -0
- package/dist/otp-input/index.js +2 -0
- package/dist/otp-input/otp-input.css +336 -0
- package/dist/otp-input/otp-input.d.ts +56 -0
- package/dist/otp-input/otp-input.js +44 -0
- package/dist/popover/index.d.ts +2 -1
- package/dist/popover/index.js +2 -1
- package/dist/popover/popover.d.ts +3 -0
- package/dist/popover/popover.js +8 -0
- package/dist/server-render.test.d.ts +1 -0
- package/dist/server-render.test.js +57 -0
- package/dist/skeleton/index.d.ts +1 -0
- package/dist/skeleton/index.js +1 -0
- package/dist/skeleton/skeleton.css +143 -0
- package/dist/skeleton/skeleton.d.ts +44 -0
- package/dist/skeleton/skeleton.js +22 -0
- package/dist/smooth-caret/smooth-caret.css +4 -2
- package/dist/tabs/index.d.ts +2 -0
- package/dist/tabs/index.js +2 -0
- package/dist/tabs/tabs.css +616 -0
- package/dist/tabs/tabs.d.ts +51 -0
- package/dist/tabs/tabs.js +20 -0
- package/dist/titlebar/index.d.ts +1 -1
- package/dist/titlebar/index.js +1 -1
- package/dist/titlebar/titlebar.d.ts +15 -2
- package/dist/titlebar/titlebar.js +18 -9
- package/dist/toast/index.d.ts +2 -1
- package/dist/toast/index.js +2 -1
- package/dist/tooltip/tooltip.js +2 -0
- package/package.json +59 -5
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
@import "../motion/motion.css";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Styles ui-sdk's one-time code input. One invisible native input lies over the slots and takes every press, key,
|
|
5
|
+
* paste and autofill; the slots only show the code. The colours fall back to the text input's.
|
|
6
|
+
*/
|
|
7
|
+
@layer kumiko {
|
|
8
|
+
:where(:root) {
|
|
9
|
+
--kumiko-otp-slot-width-sm: 2.25rem;
|
|
10
|
+
--kumiko-otp-slot-width: 2.75rem;
|
|
11
|
+
--kumiko-otp-slot-width-lg: 3.25rem;
|
|
12
|
+
--kumiko-otp-slot-height-sm: 2.5rem;
|
|
13
|
+
--kumiko-otp-slot-height: 3rem;
|
|
14
|
+
--kumiko-otp-slot-height-lg: 3.75rem;
|
|
15
|
+
--kumiko-otp-font-size-sm: 1rem;
|
|
16
|
+
--kumiko-otp-font-size: 1.25rem;
|
|
17
|
+
--kumiko-otp-font-size-lg: 1.625rem;
|
|
18
|
+
--kumiko-otp-font-family: inherit;
|
|
19
|
+
--kumiko-otp-font-weight: 500;
|
|
20
|
+
--kumiko-otp-gap: 0.5rem;
|
|
21
|
+
--kumiko-otp-group-gap: 0.75rem;
|
|
22
|
+
--kumiko-otp-radius: 0.625rem;
|
|
23
|
+
--kumiko-otp-border-width: 1px;
|
|
24
|
+
--kumiko-otp-fg: currentColor;
|
|
25
|
+
--kumiko-otp-bg: color-mix(in oklab, currentColor 5%, transparent);
|
|
26
|
+
--kumiko-otp-border: color-mix(in oklab, currentColor 18%, transparent);
|
|
27
|
+
--kumiko-otp-border-hover: color-mix(in oklab, currentColor 30%, transparent);
|
|
28
|
+
--kumiko-otp-filled-border: color-mix(in oklab, currentColor 30%, transparent);
|
|
29
|
+
--kumiko-otp-ring-width: 3px;
|
|
30
|
+
--kumiko-otp-separator: color-mix(in oklab, currentColor 40%, transparent);
|
|
31
|
+
--kumiko-otp-caret-width: 2px;
|
|
32
|
+
--kumiko-otp-shake-distance: 6px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
* The tokens that fall back to the input's resolve on each part, not on the root, so an input token set on any
|
|
37
|
+
* container reaches the code inside it.
|
|
38
|
+
*/
|
|
39
|
+
:where([data-slot^="otp-input"]) {
|
|
40
|
+
--_otp-accent: var(--kumiko-otp-accent, var(--kumiko-input-accent, Highlight));
|
|
41
|
+
--_otp-invalid: var(
|
|
42
|
+
--kumiko-otp-invalid,
|
|
43
|
+
var(--kumiko-input-invalid, light-dark(oklch(0.55 0.19 25), oklch(0.72 0.15 25)))
|
|
44
|
+
);
|
|
45
|
+
--_otp-caret-blink-duration: var(
|
|
46
|
+
--kumiko-otp-caret-blink-duration,
|
|
47
|
+
var(--kumiko-smooth-caret-blink-duration, 1.1s)
|
|
48
|
+
);
|
|
49
|
+
--_otp-disabled-opacity: var(
|
|
50
|
+
--kumiko-otp-disabled-opacity,
|
|
51
|
+
var(--kumiko-input-disabled-opacity, 0.5)
|
|
52
|
+
);
|
|
53
|
+
--_otp-readonly-border: var(
|
|
54
|
+
--kumiko-otp-readonly-border,
|
|
55
|
+
var(--kumiko-input-readonly-border, color-mix(in oklab, currentColor 16%, transparent))
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:where([data-slot="otp-input"]) {
|
|
60
|
+
--_otp-w: var(--kumiko-otp-slot-width);
|
|
61
|
+
--_otp-h: var(--kumiko-otp-slot-height);
|
|
62
|
+
--_otp-fs: var(--kumiko-otp-font-size);
|
|
63
|
+
--_otp-ring: color-mix(in oklab, var(--_otp-accent) 28%, transparent);
|
|
64
|
+
|
|
65
|
+
display: inline-flex;
|
|
66
|
+
gap: var(--kumiko-otp-group-gap);
|
|
67
|
+
align-items: center;
|
|
68
|
+
color: var(--kumiko-otp-fg);
|
|
69
|
+
cursor: text;
|
|
70
|
+
|
|
71
|
+
/* A code is digits and Latin letters, read left to right on any page, so "123" never shows as "321". */
|
|
72
|
+
direction: ltr;
|
|
73
|
+
unicode-bidi: isolate;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:where([data-slot="otp-input"][data-size="sm"]) {
|
|
77
|
+
--_otp-w: var(--kumiko-otp-slot-width-sm);
|
|
78
|
+
--_otp-h: var(--kumiko-otp-slot-height-sm);
|
|
79
|
+
--_otp-fs: var(--kumiko-otp-font-size-sm);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
:where([data-slot="otp-input"][data-size="lg"]) {
|
|
83
|
+
--_otp-w: var(--kumiko-otp-slot-width-lg);
|
|
84
|
+
--_otp-h: var(--kumiko-otp-slot-height-lg);
|
|
85
|
+
--_otp-fs: var(--kumiko-otp-font-size-lg);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:where([data-slot="otp-input-group"]) {
|
|
89
|
+
display: flex;
|
|
90
|
+
gap: var(--kumiko-otp-gap);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
:where([data-slot="otp-input-slot"]) {
|
|
94
|
+
position: relative;
|
|
95
|
+
display: grid;
|
|
96
|
+
box-sizing: border-box;
|
|
97
|
+
inline-size: var(--_otp-w);
|
|
98
|
+
block-size: var(--_otp-h);
|
|
99
|
+
border: var(--kumiko-otp-border-width) solid var(--kumiko-otp-border);
|
|
100
|
+
border-radius: var(--kumiko-otp-radius);
|
|
101
|
+
background: var(--kumiko-otp-bg);
|
|
102
|
+
font-family: var(--kumiko-otp-font-family);
|
|
103
|
+
font-size: var(--_otp-fs);
|
|
104
|
+
font-weight: var(--kumiko-otp-font-weight);
|
|
105
|
+
font-variant-numeric: tabular-nums;
|
|
106
|
+
line-height: 1;
|
|
107
|
+
place-items: center;
|
|
108
|
+
transition:
|
|
109
|
+
border-color var(--kumiko-fade-duration) var(--kumiko-fade-ease),
|
|
110
|
+
box-shadow var(--kumiko-fade-duration) var(--kumiko-fade-ease);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
:where([data-slot="otp-input-slot"][data-filled]) {
|
|
114
|
+
border-color: var(--kumiko-otp-filled-border);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@media (hover: hover) and (pointer: fine) {
|
|
118
|
+
:where(
|
|
119
|
+
[data-slot="otp-input"]:not([data-disabled]):not(:has(input[readonly])):hover
|
|
120
|
+
[data-slot="otp-input-slot"]:not([data-active])
|
|
121
|
+
) {
|
|
122
|
+
border-color: var(--kumiko-otp-border-hover);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* The slot typing goes to: the accent edge and a soft ring, as a focused text field has. */
|
|
127
|
+
:where([data-slot="otp-input-slot"][data-active]) {
|
|
128
|
+
z-index: 1;
|
|
129
|
+
border-color: var(--_otp-accent);
|
|
130
|
+
box-shadow: 0 0 0 var(--kumiko-otp-ring-width) var(--_otp-ring);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* The caret: the input's own is hidden, so an empty active slot draws one, blinking. */
|
|
134
|
+
:where([data-slot="otp-input-slot"][data-fake-caret])::after {
|
|
135
|
+
inline-size: var(--kumiko-otp-caret-width);
|
|
136
|
+
block-size: 1.1em;
|
|
137
|
+
border-radius: var(--kumiko-otp-caret-width);
|
|
138
|
+
background: var(--_otp-accent);
|
|
139
|
+
content: "";
|
|
140
|
+
animation: kumiko-otp-caret var(--_otp-caret-blink-duration) ease-in-out infinite;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@keyframes kumiko-otp-caret {
|
|
144
|
+
0%,
|
|
145
|
+
30% {
|
|
146
|
+
opacity: 1;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
65% {
|
|
150
|
+
opacity: 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
100% {
|
|
154
|
+
opacity: 1;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* A typed character pops in from a little smaller, on the pop tokens, which reduced and still motion zero. */
|
|
159
|
+
:where([data-slot="otp-input-char"]) {
|
|
160
|
+
animation: kumiko-otp-pop var(--kumiko-pop-duration) var(--kumiko-pop-ease);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
:where(
|
|
164
|
+
[data-slot="otp-input"]:is(
|
|
165
|
+
[data-pop="false"],
|
|
166
|
+
:not([data-pop]):is([data-kumiko-otp~="no-pop"] *)
|
|
167
|
+
)
|
|
168
|
+
[data-slot="otp-input-char"]
|
|
169
|
+
) {
|
|
170
|
+
animation: none;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@keyframes kumiko-otp-pop {
|
|
174
|
+
from {
|
|
175
|
+
scale: var(--kumiko-pop-scale);
|
|
176
|
+
opacity: 0;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* The separator: a short dash unless the app draws its own. */
|
|
181
|
+
:where([data-slot="otp-input-separator"]) {
|
|
182
|
+
display: flex;
|
|
183
|
+
align-items: center;
|
|
184
|
+
color: var(--kumiko-otp-separator);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
:where([data-slot="otp-input-separator"]:empty)::before {
|
|
188
|
+
inline-size: calc(var(--_otp-fs) * 0.5);
|
|
189
|
+
block-size: 2px;
|
|
190
|
+
border-radius: 2px;
|
|
191
|
+
background: currentColor;
|
|
192
|
+
content: "";
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/* Joined: the slots of a group share their edges and round only the group's ends. */
|
|
196
|
+
:where(
|
|
197
|
+
[data-slot="otp-input"]:is(
|
|
198
|
+
[data-look="joined"],
|
|
199
|
+
:not([data-look]):is([data-kumiko-otp~="joined"] *)
|
|
200
|
+
)
|
|
201
|
+
) {
|
|
202
|
+
& [data-slot="otp-input-group"] {
|
|
203
|
+
gap: 0;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
& [data-slot="otp-input-slot"] {
|
|
207
|
+
border-radius: 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
& [data-slot="otp-input-slot"] + [data-slot="otp-input-slot"] {
|
|
211
|
+
margin-inline-start: calc(-1 * var(--kumiko-otp-border-width));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
& [data-slot="otp-input-slot"]:first-child {
|
|
215
|
+
border-start-start-radius: var(--kumiko-otp-radius);
|
|
216
|
+
border-end-start-radius: var(--kumiko-otp-radius);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
& [data-slot="otp-input-slot"]:last-child {
|
|
220
|
+
border-start-end-radius: var(--kumiko-otp-radius);
|
|
221
|
+
border-end-end-radius: var(--kumiko-otp-radius);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* Underline: no box, a line under each character that takes the accent where typing goes. */
|
|
226
|
+
:where(
|
|
227
|
+
[data-slot="otp-input"]:is(
|
|
228
|
+
[data-look="underline"],
|
|
229
|
+
:not([data-look]):is([data-kumiko-otp~="underline"] *)
|
|
230
|
+
)
|
|
231
|
+
) {
|
|
232
|
+
& [data-slot="otp-input-slot"] {
|
|
233
|
+
border-width: 0 0 calc(var(--kumiko-otp-border-width) * 2);
|
|
234
|
+
border-radius: 0;
|
|
235
|
+
background: transparent;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
& [data-slot="otp-input-slot"][data-active] {
|
|
239
|
+
box-shadow: 0 var(--kumiko-otp-ring-width) 0 -1px var(--_otp-ring);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* An invalid code: the error colour, and one shake as it turns invalid. */
|
|
244
|
+
:where([data-slot="otp-input"]:has(input[aria-invalid="true"])) {
|
|
245
|
+
--_otp-ring: color-mix(in oklab, var(--_otp-invalid) 28%, transparent);
|
|
246
|
+
|
|
247
|
+
& [data-slot="otp-input-slot"],
|
|
248
|
+
& [data-slot="otp-input-slot"][data-active] {
|
|
249
|
+
border-color: var(--_otp-invalid);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
& [data-slot="otp-input-slot"][data-fake-caret]::after {
|
|
253
|
+
background: var(--_otp-invalid);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/*
|
|
258
|
+
* The shake starts when the code turns invalid and plays once. Its length comes from the move tokens, so
|
|
259
|
+
* reduced and still motion, which zero them, leave it out.
|
|
260
|
+
*/
|
|
261
|
+
:where(
|
|
262
|
+
[data-slot="otp-input"]:not([data-shake="false"]):not(
|
|
263
|
+
:not([data-shake]):is([data-kumiko-otp~="no-shake"] *)
|
|
264
|
+
):has(input[aria-invalid="true"])
|
|
265
|
+
[data-slot="otp-input-group"]
|
|
266
|
+
) {
|
|
267
|
+
animation: kumiko-otp-shake calc(var(--kumiko-move-duration) * 1.5) var(--kumiko-move-ease);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
@keyframes kumiko-otp-shake {
|
|
271
|
+
20% {
|
|
272
|
+
translate: calc(-1 * var(--kumiko-otp-shake-distance)) 0;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
40% {
|
|
276
|
+
translate: var(--kumiko-otp-shake-distance) 0;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
60% {
|
|
280
|
+
translate: calc(-0.5 * var(--kumiko-otp-shake-distance)) 0;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
80% {
|
|
284
|
+
translate: calc(0.5 * var(--kumiko-otp-shake-distance)) 0;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/* Read-only shows the code without inviting typing: no fill, a quiet edge and no caret. */
|
|
289
|
+
:where([data-slot="otp-input"]:has(input[readonly])) {
|
|
290
|
+
cursor: default;
|
|
291
|
+
|
|
292
|
+
& [data-slot="otp-input-slot"] {
|
|
293
|
+
border-color: var(--_otp-readonly-border);
|
|
294
|
+
background: transparent;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
& [data-slot="otp-input-slot"][data-active] {
|
|
298
|
+
box-shadow: none;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
& [data-slot="otp-input-slot"][data-fake-caret]::after {
|
|
302
|
+
content: none;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
:where([data-slot="otp-input"][data-disabled]) {
|
|
307
|
+
cursor: not-allowed;
|
|
308
|
+
opacity: var(--_otp-disabled-opacity);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/* A steady caret for anyone who asked for less motion. */
|
|
312
|
+
@media (prefers-reduced-motion: reduce) {
|
|
313
|
+
:where([data-slot="otp-input-slot"][data-fake-caret])::after {
|
|
314
|
+
animation: none;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
:where([data-kumiko-motion="still"] [data-slot="otp-input-slot"][data-fake-caret])::after {
|
|
319
|
+
animation: none;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
@media (forced-colors: active) {
|
|
323
|
+
:where([data-slot="otp-input-slot"]) {
|
|
324
|
+
border-color: CanvasText;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
:where([data-slot="otp-input-slot"][data-active]) {
|
|
328
|
+
border-color: Highlight;
|
|
329
|
+
outline: 2px solid Highlight;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
:where([data-slot="otp-input-slot"][data-fake-caret])::after {
|
|
333
|
+
background: CanvasText;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { OTPInput as SdkOTPInput, OTPInputSlot as SdkOTPInputSlot } from "@ui-sdk/react/otp-input";
|
|
2
|
+
/** How the slots look: separate boxes, boxes joined into one field per group, or a line under each character. */
|
|
3
|
+
export type OTPInputLook = "boxes" | "joined" | "underline";
|
|
4
|
+
/** How big the slots are. */
|
|
5
|
+
export type OTPInputSize = "sm" | "md" | "lg";
|
|
6
|
+
type SdkProps = Parameters<typeof SdkOTPInput>[0];
|
|
7
|
+
export type OTPInputProps = SdkProps & {
|
|
8
|
+
/**
|
|
9
|
+
* How the slots look. Without it, `data-kumiko-otp="joined"` or `"underline"` on any container picks.
|
|
10
|
+
* @defaultValue "boxes"
|
|
11
|
+
*/
|
|
12
|
+
look?: OTPInputLook;
|
|
13
|
+
/** @defaultValue "md" */
|
|
14
|
+
size?: OTPInputSize;
|
|
15
|
+
/**
|
|
16
|
+
* Shows this character, or "•" for `true`, in every filled slot instead of the code, as for a PIN. The value and
|
|
17
|
+
* what the form submits stay the real code.
|
|
18
|
+
*/
|
|
19
|
+
mask?: boolean | string;
|
|
20
|
+
/**
|
|
21
|
+
* Whether a typed character pops in. Without it, `data-kumiko-otp="no-pop"` on any container turns it off.
|
|
22
|
+
* Reduced and still motion leave it out.
|
|
23
|
+
* @defaultValue true
|
|
24
|
+
*/
|
|
25
|
+
pop?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the slots shake once when the code turns invalid. Without it, `data-kumiko-otp="no-shake"` on any
|
|
28
|
+
* container turns it off. Reduced and still motion leave the shake out and keep the error colour.
|
|
29
|
+
* @defaultValue true
|
|
30
|
+
*/
|
|
31
|
+
shake?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* How the slots are split when you give no children, like `[3, 3]` for "123-456". Left out, the slots form one
|
|
34
|
+
* group of `maxLength`.
|
|
35
|
+
*/
|
|
36
|
+
groups?: number[];
|
|
37
|
+
/** @defaultValue 6 */
|
|
38
|
+
maxLength?: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Ui-sdk's one-time code input with Kumiko's slots. Without children it draws its own slots, split by `groups`;
|
|
42
|
+
* with children, lay them out with `OTPInputSlots`, or with `OTPInputGroup`, `OTPInputSlot` and `OTPInputSeparator`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function OTPInput({ look, size, mask, pop, shake, groups, maxLength, children, ...props }: OTPInputProps): React.JSX.Element;
|
|
45
|
+
export type OTPInputSlotProps = Parameters<typeof SdkOTPInputSlot>[0];
|
|
46
|
+
/** One character of the code. Without children it shows the character, masked when the input says so. */
|
|
47
|
+
export declare function OTPInputSlot({ children, ...props }: OTPInputSlotProps): React.JSX.Element | null;
|
|
48
|
+
export interface OTPInputSlotsProps {
|
|
49
|
+
/** How many slots each group holds, in order, like `[3, 3]`. */
|
|
50
|
+
groups: number[];
|
|
51
|
+
/** Drawn between groups. Left out, a short dash. */
|
|
52
|
+
separator?: React.ReactNode;
|
|
53
|
+
}
|
|
54
|
+
/** The slots and separators for a code split into groups, so you don't write each slot out. */
|
|
55
|
+
export declare function OTPInputSlots({ groups, separator }: OTPInputSlotsProps): React.JSX.Element;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { OTPInput as SdkOTPInput, OTPInputGroup, OTPInputSeparator, OTPInputSlot as SdkOTPInputSlot } from "@ui-sdk/react/otp-input";
|
|
3
|
+
import { createContext, Fragment, useContext } from "react";
|
|
4
|
+
/** The character a masked slot shows, or none when the code shows as typed. */
|
|
5
|
+
const MaskContext = createContext(null);
|
|
6
|
+
function onOff(on) {
|
|
7
|
+
return on === undefined ? undefined : String(on);
|
|
8
|
+
}
|
|
9
|
+
function maskOf(mask) {
|
|
10
|
+
if (mask === true) {
|
|
11
|
+
return "•";
|
|
12
|
+
}
|
|
13
|
+
return typeof mask === "string" && mask !== "" ? mask : null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Ui-sdk's one-time code input with Kumiko's slots. Without children it draws its own slots, split by `groups`;
|
|
17
|
+
* with children, lay them out with `OTPInputSlots`, or with `OTPInputGroup`, `OTPInputSlot` and `OTPInputSeparator`.
|
|
18
|
+
*/
|
|
19
|
+
export function OTPInput({ look, size = "md", mask, pop, shake, groups, maxLength = 6, children, ...props }) {
|
|
20
|
+
const slots = children ?? _jsx(OTPInputSlots, { groups: groups ?? [maxLength] });
|
|
21
|
+
return (_jsx(MaskContext.Provider, { value: maskOf(mask), children: _jsx(SdkOTPInput, { maxLength: maxLength, "data-look": look, "data-size": size, "data-pop": onOff(pop), "data-shake": onOff(shake), ...props, children: slots }) }));
|
|
22
|
+
}
|
|
23
|
+
function SlotChar({ state }) {
|
|
24
|
+
const mask = useContext(MaskContext);
|
|
25
|
+
if (state.char === null) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
/* Keyed by the character, so a new one mounts afresh and pops in again. */
|
|
29
|
+
return (_jsx("span", { "data-slot": "otp-input-char", children: mask ?? state.char }, `${state.index}:${state.char}`));
|
|
30
|
+
}
|
|
31
|
+
/** One character of the code. Without children it shows the character, masked when the input says so. */
|
|
32
|
+
export function OTPInputSlot({ children, ...props }) {
|
|
33
|
+
return (_jsx(SdkOTPInputSlot, { ...props, children: children ?? ((state) => _jsx(SlotChar, { state: state })) }));
|
|
34
|
+
}
|
|
35
|
+
function startOf(groups, at) {
|
|
36
|
+
return groups.slice(0, at).reduce((sum, count) => sum + count, 0);
|
|
37
|
+
}
|
|
38
|
+
/** The slots and separators for a code split into groups, so you don't write each slot out. */
|
|
39
|
+
export function OTPInputSlots({ groups, separator }) {
|
|
40
|
+
return (_jsx(_Fragment, { children: groups.map((count, at) => {
|
|
41
|
+
const start = startOf(groups, at);
|
|
42
|
+
return (_jsxs(Fragment, { children: [at > 0 ? _jsx(OTPInputSeparator, { children: separator }) : null, _jsx(OTPInputGroup, { children: Array.from({ length: count }, (_, offset) => (_jsx(OTPInputSlot, { index: start + offset }, start + offset))) })] }, start));
|
|
43
|
+
}) }));
|
|
44
|
+
}
|
package/dist/popover/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { createPopoverController,
|
|
1
|
+
export { createPopoverController, PopoverArrow, PopoverClose, PopoverContent, PopoverDescription, PopoverShortcut, PopoverTitle, PopoverTrigger, type PopoverApi, type PopoverContentProps, type PopoverContentState, type PopoverController, type PopoverDismissReason, type PopoverFinalFocus, type PopoverInitialFocus, type PopoverOpenChangeReason, type PopoverOptions, type PopoverPayloadChangeReason, type PopoverProps, type PopoverTriggerProps, type PopoverTriggerState } from "@ui-sdk/react/popover";
|
|
2
|
+
export { Popover } from "./popover";
|
package/dist/popover/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { createPopoverController,
|
|
1
|
+
export { createPopoverController, PopoverArrow, PopoverClose, PopoverContent, PopoverDescription, PopoverShortcut, PopoverTitle, PopoverTrigger } from "@ui-sdk/react/popover";
|
|
2
|
+
export { Popover } from "./popover";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Popover as SdkPopover } from "@ui-sdk/react/popover";
|
|
3
|
+
import { useSettledClose } from "../motion/settle-close";
|
|
4
|
+
/** The ui-sdk popover, whose close isn't stretched by infinite animations inside it. */
|
|
5
|
+
export function Popover(props) {
|
|
6
|
+
useSettledClose();
|
|
7
|
+
return _jsx(SdkPopover, { ...props });
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "bun:test";
|
|
3
|
+
import { renderToString } from "react-dom/server";
|
|
4
|
+
import { Avatar } from "./avatar";
|
|
5
|
+
import { Drawer, DrawerContent, DrawerTitle, DrawerTrigger } from "./drawer";
|
|
6
|
+
import { FileDropzone, FilePreview } from "./file-input";
|
|
7
|
+
import { OTPInput } from "./otp-input";
|
|
8
|
+
import { Skeleton, SkeletonGroup, SkeletonText } from "./skeleton";
|
|
9
|
+
import { Tabs, TabsList, TabsPanel, TabsTab } from "./tabs";
|
|
10
|
+
/*
|
|
11
|
+
* Bun runs these with no DOM, as a server does: a component that reads `window` or `document`, or makes a
|
|
12
|
+
* browser-only value, while it renders fails here before it fails an app's server.
|
|
13
|
+
*/
|
|
14
|
+
function tabsShowTheChosenTab() {
|
|
15
|
+
const html = renderToString(_jsxs(Tabs, { defaultValue: "screens", children: [_jsxs(TabsList, { "aria-label": "Sections", children: [_jsx(TabsTab, { value: "screens", children: "Screens" }), _jsx(TabsTab, { value: "campaigns", children: "Campaigns" })] }), _jsx(TabsPanel, { value: "screens", children: "Twelve screens" }), _jsx(TabsPanel, { value: "campaigns", children: "Three campaigns" })] }));
|
|
16
|
+
expect(html).toMatch(/aria-selected="true"[^>]*>Screens</u);
|
|
17
|
+
expect(html).toContain("Twelve screens");
|
|
18
|
+
}
|
|
19
|
+
function aClosedDrawerIsItsTrigger() {
|
|
20
|
+
const html = renderToString(_jsxs(Drawer, { children: [_jsx(DrawerTrigger, { children: "Basket" }), _jsx(DrawerContent, { children: _jsx(DrawerTitle, { children: "Your basket" }) })] }));
|
|
21
|
+
expect(html).toContain(">Basket</button>");
|
|
22
|
+
expect(html).not.toContain("Your basket");
|
|
23
|
+
}
|
|
24
|
+
function aCodeHasASlotPerCharacter() {
|
|
25
|
+
const html = renderToString(_jsx(OTPInput, { "aria-label": "Code", maxLength: 6 }));
|
|
26
|
+
expect(html.match(/data-slot="otp-input-slot"/gu)).toHaveLength(6);
|
|
27
|
+
}
|
|
28
|
+
function anAvatarIsItsInitials() {
|
|
29
|
+
const html = renderToString(_jsx(Avatar, { name: "Ana Maria Silva", src: "/ana.jpg" }));
|
|
30
|
+
expect(html).toContain('aria-label="Ana Maria Silva"');
|
|
31
|
+
expect(html).toContain(">AS<");
|
|
32
|
+
}
|
|
33
|
+
function aLoadingGroupHasItsStatus() {
|
|
34
|
+
const html = renderToString(_jsxs(SkeletonGroup, { label: "Loading the profile", children: [_jsx(Skeleton, { shape: "circle", width: 48 }), _jsx(SkeletonText, { lines: 2 })] }));
|
|
35
|
+
expect(html).toMatch(/role="status"[^>]*>Loading the profile</u);
|
|
36
|
+
expect(html.match(/data-slot="skeleton"/gu)).toHaveLength(3);
|
|
37
|
+
}
|
|
38
|
+
function aDropZoneHasItsWordsAndButton() {
|
|
39
|
+
const html = renderToString(_jsx(FileDropzone, { multiple: true, title: "Drop your ads here" }));
|
|
40
|
+
expect(html).toContain("Drop your ads here");
|
|
41
|
+
expect(html).toMatch(/data-slot="file-input-trigger"[^>]*>Browse files</u);
|
|
42
|
+
}
|
|
43
|
+
function aPictureIsItsBadge() {
|
|
44
|
+
const picture = new File(["a"], "storefront.png", { type: "image/png" });
|
|
45
|
+
const html = renderToString(_jsx(FilePreview, { file: picture }));
|
|
46
|
+
expect(html).toContain(">PNG<");
|
|
47
|
+
expect(html).not.toContain("blob:");
|
|
48
|
+
}
|
|
49
|
+
describe("server render", () => {
|
|
50
|
+
it("renders tabs with the chosen tab selected and its panel", tabsShowTheChosenTab);
|
|
51
|
+
it("renders a closed drawer as its trigger alone", aClosedDrawerIsItsTrigger);
|
|
52
|
+
it("renders a code input with a slot for each character", aCodeHasASlotPerCharacter);
|
|
53
|
+
it("renders an avatar as its initials, named for the person", anAvatarIsItsInitials);
|
|
54
|
+
it("renders a loading group with its status and placeholders", aLoadingGroupHasItsStatus);
|
|
55
|
+
it("renders a drop zone with its words and button", aDropZoneHasItsWordsAndButton);
|
|
56
|
+
it("renders a picture's preview as its badge, with no object URL", aPictureIsItsBadge);
|
|
57
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Skeleton, SkeletonGroup, SkeletonText, type SkeletonAnimation, type SkeletonGroupProps, type SkeletonProps, type SkeletonShape, type SkeletonTextProps } from "./skeleton";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Skeleton, SkeletonGroup, SkeletonText } from "./skeleton";
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
@import "../motion/motion.css";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Loading placeholders. The shimmer sweeps a band of light along the line's direction, timed from the spin token;
|
|
5
|
+
* reduced and still motion swap it for a slow pulse, a fade, which reduced motion keeps.
|
|
6
|
+
*/
|
|
7
|
+
@layer kumiko {
|
|
8
|
+
:where(:root) {
|
|
9
|
+
--kumiko-skeleton-bg: color-mix(in oklab, CanvasText 9%, transparent);
|
|
10
|
+
--kumiko-skeleton-shine: color-mix(in oklab, CanvasText 16%, transparent);
|
|
11
|
+
--kumiko-skeleton-radius: 0.375rem;
|
|
12
|
+
--kumiko-skeleton-text-radius: 0.25rem;
|
|
13
|
+
--kumiko-skeleton-text-height: 0.7em;
|
|
14
|
+
--kumiko-skeleton-text-gap: 0;
|
|
15
|
+
--kumiko-skeleton-size: 1rem;
|
|
16
|
+
--kumiko-skeleton-band: 40%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:where([data-slot="skeleton"]) {
|
|
20
|
+
--_skeleton-sweep: calc(var(--kumiko-spin-duration) * 2);
|
|
21
|
+
--_skeleton-pulse: calc(var(--kumiko-fade-duration) * 12);
|
|
22
|
+
|
|
23
|
+
display: block;
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
inline-size: 100%;
|
|
26
|
+
block-size: var(--kumiko-skeleton-size);
|
|
27
|
+
border-radius: var(--kumiko-skeleton-radius);
|
|
28
|
+
background-color: var(--kumiko-skeleton-bg);
|
|
29
|
+
background-image: linear-gradient(
|
|
30
|
+
90deg,
|
|
31
|
+
transparent calc(50% - var(--kumiko-skeleton-band) / 2),
|
|
32
|
+
var(--kumiko-skeleton-shine) 50%,
|
|
33
|
+
transparent calc(50% + var(--kumiko-skeleton-band) / 2)
|
|
34
|
+
);
|
|
35
|
+
background-repeat: no-repeat;
|
|
36
|
+
background-size: 300% 100%;
|
|
37
|
+
animation: kumiko-skeleton-sweep var(--_skeleton-sweep) ease-in-out infinite;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@keyframes kumiko-skeleton-sweep {
|
|
41
|
+
from {
|
|
42
|
+
background-position: 100% 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
to {
|
|
46
|
+
background-position: 0 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* In right-to-left text the band sweeps the other way, from the start of the line. */
|
|
51
|
+
:where([data-slot="skeleton"]:dir(rtl)) {
|
|
52
|
+
animation-direction: reverse;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:where([data-slot="skeleton"][data-shape="circle"]) {
|
|
56
|
+
flex: none;
|
|
57
|
+
inline-size: var(--kumiko-skeleton-size);
|
|
58
|
+
aspect-ratio: 1;
|
|
59
|
+
block-size: auto;
|
|
60
|
+
border-radius: 50%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* A line of text: a bar as tall as the text's letters, centred in a line box of the text's line height. */
|
|
64
|
+
:where([data-slot="skeleton"][data-shape="text"]) {
|
|
65
|
+
block-size: var(--kumiko-skeleton-text-height);
|
|
66
|
+
margin-block: calc((1lh - var(--kumiko-skeleton-text-height)) / 2);
|
|
67
|
+
border-radius: var(--kumiko-skeleton-text-radius);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
:where([data-slot="skeleton-text"]) {
|
|
71
|
+
display: grid;
|
|
72
|
+
gap: var(--kumiko-skeleton-text-gap);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Pulse: the shine fades in and out over the whole block instead of sweeping. */
|
|
76
|
+
:where(
|
|
77
|
+
[data-slot="skeleton"]:is(
|
|
78
|
+
[data-animation="pulse"],
|
|
79
|
+
:not([data-animation]):is([data-kumiko-skeleton~="pulse"] *)
|
|
80
|
+
)
|
|
81
|
+
) {
|
|
82
|
+
background-image: none;
|
|
83
|
+
animation: kumiko-skeleton-pulse var(--_skeleton-pulse) ease-in-out infinite;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@keyframes kumiko-skeleton-pulse {
|
|
87
|
+
50% {
|
|
88
|
+
background-color: var(--kumiko-skeleton-shine);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:where(
|
|
93
|
+
[data-slot="skeleton"]:is(
|
|
94
|
+
[data-animation="still"],
|
|
95
|
+
:not([data-animation]):is([data-kumiko-skeleton~="still"] *)
|
|
96
|
+
)
|
|
97
|
+
) {
|
|
98
|
+
background-image: none;
|
|
99
|
+
animation: none;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* A sweep is movement: reduced and still motion pulse instead, slowly. A still skeleton stays still. */
|
|
103
|
+
@media (prefers-reduced-motion: reduce) {
|
|
104
|
+
:where(
|
|
105
|
+
[data-slot="skeleton"]:not([data-animation="still"]):not(
|
|
106
|
+
:not([data-animation]):is([data-kumiko-skeleton~="still"] *)
|
|
107
|
+
)
|
|
108
|
+
) {
|
|
109
|
+
background-image: none;
|
|
110
|
+
animation: kumiko-skeleton-pulse calc(var(--_skeleton-pulse) * 1.5) ease-in-out infinite;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
:where(
|
|
115
|
+
[data-kumiko-motion="still"]
|
|
116
|
+
[data-slot="skeleton"]:not([data-animation="still"]):not(
|
|
117
|
+
:not([data-animation]):is([data-kumiko-skeleton~="still"] *)
|
|
118
|
+
)
|
|
119
|
+
) {
|
|
120
|
+
background-image: none;
|
|
121
|
+
animation: kumiko-skeleton-pulse calc(var(--_skeleton-pulse) * 1.5) ease-in-out infinite;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* The status a group announces is for screen readers only. */
|
|
125
|
+
:where([data-slot="skeleton-status"]) {
|
|
126
|
+
position: absolute;
|
|
127
|
+
inline-size: 1px;
|
|
128
|
+
block-size: 1px;
|
|
129
|
+
margin: -1px;
|
|
130
|
+
padding: 0;
|
|
131
|
+
overflow: hidden;
|
|
132
|
+
border: 0;
|
|
133
|
+
white-space: nowrap;
|
|
134
|
+
clip-path: inset(50%);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@media (forced-colors: active) {
|
|
138
|
+
:where([data-slot="skeleton"]) {
|
|
139
|
+
background: GrayText;
|
|
140
|
+
forced-color-adjust: none;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|