@alulore/kumiko 0.14.2 → 0.15.0
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/alert/alert.css +483 -0
- package/dist/alert/alert.d.ts +51 -0
- package/dist/alert/alert.js +40 -0
- package/dist/alert/index.d.ts +1 -0
- package/dist/alert/index.js +1 -0
- package/dist/card/card.css +727 -0
- package/dist/card/card.d.ts +62 -0
- package/dist/card/card.js +48 -0
- package/dist/card/index.d.ts +2 -0
- package/dist/card/index.js +2 -0
- package/dist/card/item-card.d.ts +84 -0
- package/dist/card/item-card.js +73 -0
- package/dist/list-row/index.d.ts +1 -0
- package/dist/list-row/index.js +1 -0
- package/dist/list-row/list-row-motion.d.ts +10 -0
- package/dist/list-row/list-row-motion.js +141 -0
- package/dist/list-row/list-row.css +403 -0
- package/dist/list-row/list-row.d.ts +64 -0
- package/dist/list-row/list-row.js +54 -0
- package/package.json +28 -1
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
@import "../motion/motion.css";
|
|
2
|
+
|
|
3
|
+
@layer kumiko {
|
|
4
|
+
:where(:root) {
|
|
5
|
+
--kumiko-touch-target: 2.75rem;
|
|
6
|
+
--kumiko-list-row-gap: 0.625rem;
|
|
7
|
+
--kumiko-list-row-padding-block: 0.4375rem;
|
|
8
|
+
--kumiko-list-row-padding-inline: 0.75rem;
|
|
9
|
+
--kumiko-list-row-touch-height: 3.5rem;
|
|
10
|
+
--kumiko-list-row-radius: 0.875rem;
|
|
11
|
+
--kumiko-list-row-font-size: 0.875rem;
|
|
12
|
+
--kumiko-list-row-font-weight: 500;
|
|
13
|
+
--kumiko-list-row-current-bold-weight: 700;
|
|
14
|
+
--kumiko-list-row-description-size: 0.75rem;
|
|
15
|
+
--kumiko-list-row-icon-size: 1rem;
|
|
16
|
+
--kumiko-list-row-bg: transparent;
|
|
17
|
+
--kumiko-list-row-fg: CanvasText;
|
|
18
|
+
--kumiko-list-row-quiet-fg: color-mix(in oklab, CanvasText 60%, transparent);
|
|
19
|
+
--kumiko-list-row-border: color-mix(in oklab, CanvasText 25%, transparent);
|
|
20
|
+
--kumiko-list-row-hover-bg: color-mix(in oklab, CanvasText 8%, transparent);
|
|
21
|
+
--kumiko-list-row-grow-share: 0.4;
|
|
22
|
+
--kumiko-list-row-selected-bg: color-mix(in oklab, Highlight 22%, transparent);
|
|
23
|
+
--kumiko-list-row-selected-hover-bg: color-mix(in oklab, Highlight 30%, transparent);
|
|
24
|
+
--kumiko-list-row-current-bg: Highlight;
|
|
25
|
+
--kumiko-list-row-current-fg: HighlightText;
|
|
26
|
+
--kumiko-list-row-current-tint-bg: color-mix(in oklab, Highlight 16%, transparent);
|
|
27
|
+
--kumiko-list-row-current-tint-fg: CanvasText;
|
|
28
|
+
--kumiko-list-row-bar-color: Highlight;
|
|
29
|
+
--kumiko-list-row-bar-width: 3px;
|
|
30
|
+
--kumiko-list-row-press-shade: color-mix(in oklab, CanvasText 14%, transparent);
|
|
31
|
+
--kumiko-list-row-focus-ring: Highlight;
|
|
32
|
+
--kumiko-list-row-disabled-opacity: 0.5;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* The list holds the gliders, so rows measure their place from it. */
|
|
36
|
+
[data-slot="list-row-list"] {
|
|
37
|
+
position: relative;
|
|
38
|
+
min-inline-size: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[data-slot="list-row"] {
|
|
42
|
+
/* Each look sets these, so the rules below stay short. */
|
|
43
|
+
--_hover-bg: var(--kumiko-list-row-hover-bg);
|
|
44
|
+
--_hover-scale: calc(
|
|
45
|
+
1 + (var(--kumiko-hover-scale) - 1) * var(--kumiko-list-row-grow-share)
|
|
46
|
+
);
|
|
47
|
+
--_press-scale: var(--kumiko-press-scale);
|
|
48
|
+
--_press-shade: transparent;
|
|
49
|
+
--_cur-bg: var(--kumiko-list-row-current-bg);
|
|
50
|
+
--_cur-fg: var(--kumiko-list-row-current-fg);
|
|
51
|
+
--_cur-weight: var(--kumiko-list-row-font-weight);
|
|
52
|
+
--_bar: 0px;
|
|
53
|
+
|
|
54
|
+
position: relative;
|
|
55
|
+
display: flex;
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
gap: var(--kumiko-list-row-gap);
|
|
58
|
+
align-items: center;
|
|
59
|
+
inline-size: 100%;
|
|
60
|
+
min-inline-size: 0;
|
|
61
|
+
padding: var(--kumiko-list-row-padding-block) var(--kumiko-list-row-padding-inline);
|
|
62
|
+
border: 0;
|
|
63
|
+
border-radius: var(--kumiko-list-row-radius);
|
|
64
|
+
background: var(--kumiko-list-row-bg);
|
|
65
|
+
color: var(--kumiko-list-row-fg);
|
|
66
|
+
font: inherit;
|
|
67
|
+
font-size: var(--kumiko-list-row-font-size);
|
|
68
|
+
font-weight: var(--kumiko-list-row-font-weight);
|
|
69
|
+
text-align: start;
|
|
70
|
+
text-decoration: none;
|
|
71
|
+
cursor: var(--kumiko-press-cursor, pointer);
|
|
72
|
+
user-select: none;
|
|
73
|
+
transition:
|
|
74
|
+
background-color var(--kumiko-fade-duration) var(--kumiko-fade-ease),
|
|
75
|
+
color var(--kumiko-fade-duration) var(--kumiko-fade-ease),
|
|
76
|
+
scale var(--kumiko-lift-duration) var(--kumiko-lift-ease);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[data-slot="list-row"][data-size="touch"] {
|
|
80
|
+
min-block-size: var(--kumiko-list-row-touch-height);
|
|
81
|
+
padding-block: calc(var(--kumiko-list-row-padding-block) * 1.4);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
[data-slot="list-row"][data-bordered] {
|
|
85
|
+
border: 1px solid var(--kumiko-list-row-border);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* A static row is information: no pointer, no hover, no press, and not dimmed. */
|
|
89
|
+
[data-slot="list-row"][data-static] {
|
|
90
|
+
cursor: default;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Option 13, hover: a wash that grows slightly is the default. Wash keeps the fill only, none turns both off. */
|
|
94
|
+
[data-slot="list-row"]:is(
|
|
95
|
+
[data-hover="wash"],
|
|
96
|
+
:not([data-hover]):is(
|
|
97
|
+
[data-kumiko-list-row~="hover-wash"],
|
|
98
|
+
[data-kumiko-list-row~="hover-wash"] *
|
|
99
|
+
)
|
|
100
|
+
) {
|
|
101
|
+
--_hover-scale: 1;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
[data-slot="list-row"]:is(
|
|
105
|
+
[data-hover="none"],
|
|
106
|
+
:not([data-hover]):is(
|
|
107
|
+
[data-kumiko-list-row~="hover-none"],
|
|
108
|
+
[data-kumiko-list-row~="hover-none"] *
|
|
109
|
+
)
|
|
110
|
+
) {
|
|
111
|
+
--_hover-bg: transparent;
|
|
112
|
+
--_hover-scale: 1;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* Option 14, current row: solid accent fill is the default; bar and bold use a tint. */
|
|
116
|
+
[data-slot="list-row"]:is(
|
|
117
|
+
[data-current-look="bar"],
|
|
118
|
+
:not([data-current-look]):is(
|
|
119
|
+
[data-kumiko-list-row~="current-bar"],
|
|
120
|
+
[data-kumiko-list-row~="current-bar"] *
|
|
121
|
+
)
|
|
122
|
+
) {
|
|
123
|
+
--_cur-bg: var(--kumiko-list-row-current-tint-bg);
|
|
124
|
+
--_cur-fg: var(--kumiko-list-row-current-tint-fg);
|
|
125
|
+
--_bar: var(--kumiko-list-row-bar-width);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
[data-slot="list-row"]:is(
|
|
129
|
+
[data-current-look="bold"],
|
|
130
|
+
:not([data-current-look]):is(
|
|
131
|
+
[data-kumiko-list-row~="current-bold"],
|
|
132
|
+
[data-kumiko-list-row~="current-bold"] *
|
|
133
|
+
)
|
|
134
|
+
) {
|
|
135
|
+
--_cur-bg: var(--kumiko-list-row-current-tint-bg);
|
|
136
|
+
--_cur-fg: var(--kumiko-list-row-current-tint-fg);
|
|
137
|
+
--_cur-weight: var(--kumiko-list-row-current-bold-weight);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* Option 16, press: squash is the default; dark only shades the fill; none turns both off. */
|
|
141
|
+
[data-slot="list-row"]:is(
|
|
142
|
+
[data-press="dark"],
|
|
143
|
+
:not([data-press]):is(
|
|
144
|
+
[data-kumiko-list-row~="press-dark"],
|
|
145
|
+
[data-kumiko-list-row~="press-dark"] *
|
|
146
|
+
)
|
|
147
|
+
) {
|
|
148
|
+
--_press-scale: 1;
|
|
149
|
+
--_press-shade: var(--kumiko-list-row-press-shade);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
[data-slot="list-row"]:is(
|
|
153
|
+
[data-press="none"],
|
|
154
|
+
:not([data-press]):is(
|
|
155
|
+
[data-kumiko-list-row~="press-none"],
|
|
156
|
+
[data-kumiko-list-row~="press-none"] *
|
|
157
|
+
)
|
|
158
|
+
) {
|
|
159
|
+
--_press-scale: 1;
|
|
160
|
+
--_press-shade: transparent;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
[data-slot="list-row-icon"] {
|
|
164
|
+
display: inline-grid;
|
|
165
|
+
flex: none;
|
|
166
|
+
place-items: center;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
[data-slot="list-row-icon"] > svg {
|
|
170
|
+
inline-size: var(--kumiko-list-row-icon-size);
|
|
171
|
+
block-size: var(--kumiko-list-row-icon-size);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
[data-slot="list-row-label"] {
|
|
175
|
+
flex: 1;
|
|
176
|
+
min-inline-size: 0;
|
|
177
|
+
overflow: hidden;
|
|
178
|
+
text-overflow: ellipsis;
|
|
179
|
+
white-space: nowrap;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
[data-slot="list-row-text"] {
|
|
183
|
+
display: flex;
|
|
184
|
+
flex: 1;
|
|
185
|
+
flex-direction: column;
|
|
186
|
+
min-inline-size: 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
[data-slot="list-row-text"] > [data-slot="list-row-label"] {
|
|
190
|
+
flex: none;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
[data-slot="list-row-description"] {
|
|
194
|
+
overflow: hidden;
|
|
195
|
+
color: var(--kumiko-list-row-quiet-fg);
|
|
196
|
+
font-size: var(--kumiko-list-row-description-size);
|
|
197
|
+
font-weight: normal;
|
|
198
|
+
text-overflow: ellipsis;
|
|
199
|
+
white-space: nowrap;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
[data-slot="list-row-trailing"] {
|
|
203
|
+
display: inline-flex;
|
|
204
|
+
flex: none;
|
|
205
|
+
gap: 0.375rem;
|
|
206
|
+
align-items: center;
|
|
207
|
+
color: var(--kumiko-list-row-quiet-fg);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
[data-slot="list-row"][data-selected] {
|
|
211
|
+
background: var(--kumiko-list-row-selected-bg);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
[data-slot="list-row"][data-current] {
|
|
215
|
+
background: var(--_cur-bg);
|
|
216
|
+
color: var(--_cur-fg);
|
|
217
|
+
font-weight: var(--_cur-weight);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
[data-slot="list-row"][data-current] [data-slot="list-row-description"],
|
|
221
|
+
[data-slot="list-row"][data-current] [data-slot="list-row-trailing"] {
|
|
222
|
+
color: inherit;
|
|
223
|
+
opacity: 0.8;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* The bar sits on the leading edge of the current row. */
|
|
227
|
+
[data-slot="list-row"]::before {
|
|
228
|
+
content: "";
|
|
229
|
+
position: absolute;
|
|
230
|
+
inset-block: 25%;
|
|
231
|
+
inset-inline-start: 0.1875rem;
|
|
232
|
+
inline-size: 0;
|
|
233
|
+
border-radius: 999px;
|
|
234
|
+
background: var(--kumiko-list-row-bar-color);
|
|
235
|
+
transition: inline-size var(--kumiko-move-duration) var(--kumiko-move-ease);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
[data-slot="list-row"][data-current]::before {
|
|
239
|
+
inline-size: var(--_bar);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* Pressing: a squash, or a shade over the fill. */
|
|
243
|
+
[data-slot="list-row"]:not([data-static], :disabled):active {
|
|
244
|
+
background-image: linear-gradient(var(--_press-shade), var(--_press-shade));
|
|
245
|
+
scale: var(--_press-scale);
|
|
246
|
+
transition-duration:
|
|
247
|
+
var(--kumiko-fade-duration), var(--kumiko-fade-duration), var(--kumiko-press-duration);
|
|
248
|
+
transition-timing-function:
|
|
249
|
+
var(--kumiko-fade-ease), var(--kumiko-fade-ease), var(--kumiko-press-ease);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
[data-slot="list-row"]:disabled {
|
|
253
|
+
opacity: var(--kumiko-list-row-disabled-opacity);
|
|
254
|
+
cursor: not-allowed;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
[data-slot="list-row"]:focus-visible {
|
|
258
|
+
outline: 2px solid var(--kumiko-list-row-focus-ring);
|
|
259
|
+
outline-offset: 2px;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
@media (hover: hover) and (pointer: fine) {
|
|
263
|
+
[data-slot="list-row"]:not([data-current], [data-static], :disabled):hover {
|
|
264
|
+
background: var(--_hover-bg);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
[data-slot="list-row"][data-selected]:not([data-current], [data-static], :disabled):hover {
|
|
268
|
+
background: var(--kumiko-list-row-selected-hover-bg);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
[data-slot="list-row"]:not([data-static], :disabled):hover:not(:active) {
|
|
272
|
+
scale: var(--_hover-scale);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/* On a finger, an invisible area around the row reaches the touch target. */
|
|
277
|
+
@media (pointer: coarse) {
|
|
278
|
+
[data-slot="list-row"]:not([data-static])::after {
|
|
279
|
+
content: "";
|
|
280
|
+
position: absolute;
|
|
281
|
+
inset-inline: 0;
|
|
282
|
+
inset-block-start: 50%;
|
|
283
|
+
block-size: max(100%, var(--kumiko-touch-target));
|
|
284
|
+
translate: 0 -50%;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/* Option 15, glide: one highlight slides between rows, and the hover wash trails the pointer. */
|
|
289
|
+
[data-slot="list-row-glide"] {
|
|
290
|
+
display: none;
|
|
291
|
+
position: absolute;
|
|
292
|
+
top: 0;
|
|
293
|
+
left: 0;
|
|
294
|
+
inline-size: var(--_w, 0);
|
|
295
|
+
block-size: var(--_h, 0);
|
|
296
|
+
translate: var(--_x, 0) var(--_y, 0);
|
|
297
|
+
border-radius: var(--_r, 0);
|
|
298
|
+
background: var(--_bg, transparent);
|
|
299
|
+
opacity: 0;
|
|
300
|
+
pointer-events: none;
|
|
301
|
+
transition:
|
|
302
|
+
opacity var(--kumiko-fade-duration) var(--kumiko-fade-ease),
|
|
303
|
+
background-color var(--kumiko-fade-duration) var(--kumiko-fade-ease);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
[data-slot="list-row-glide"][data-visible] {
|
|
307
|
+
opacity: 1;
|
|
308
|
+
transition:
|
|
309
|
+
translate var(--kumiko-move-duration) var(--kumiko-move-ease),
|
|
310
|
+
inline-size var(--kumiko-move-duration) var(--kumiko-move-ease),
|
|
311
|
+
block-size var(--kumiko-move-duration) var(--kumiko-move-ease),
|
|
312
|
+
opacity var(--kumiko-fade-duration) var(--kumiko-fade-ease),
|
|
313
|
+
background-color var(--kumiko-fade-duration) var(--kumiko-fade-ease);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
[data-slot="list-row-glide"][data-kind="current"]::before {
|
|
317
|
+
content: "";
|
|
318
|
+
position: absolute;
|
|
319
|
+
inset-block: 25%;
|
|
320
|
+
inset-inline-start: 0.1875rem;
|
|
321
|
+
inline-size: var(--_bar, 0);
|
|
322
|
+
border-radius: 999px;
|
|
323
|
+
background: var(--kumiko-list-row-bar-color);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
[data-kumiko-list-row~="glide"] [data-slot="list-row-glide"] {
|
|
327
|
+
display: block;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
[data-kumiko-list-row~="hover-none"] [data-slot="list-row-glide"][data-kind="hover"] {
|
|
331
|
+
display: none;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/* The rows hand their fills to the gliders, so the fill is not painted twice. */
|
|
335
|
+
[data-kumiko-list-row~="glide"] [data-slot="list-row"][data-current] {
|
|
336
|
+
background: transparent;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
[data-kumiko-list-row~="glide"] [data-slot="list-row"][data-current]::before {
|
|
340
|
+
display: none;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
@media (hover: hover) and (pointer: fine) {
|
|
344
|
+
[data-kumiko-list-row~="glide"] [data-slot="list-row"]:not([data-static], :disabled):hover {
|
|
345
|
+
scale: none;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
[data-kumiko-list-row~="glide"]
|
|
349
|
+
[data-slot="list-row"]:not([data-current], [data-static], :disabled):hover {
|
|
350
|
+
background: transparent;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
[data-kumiko-list-row~="glide"]
|
|
354
|
+
[data-slot="list-row"][data-selected]:not(
|
|
355
|
+
[data-current],
|
|
356
|
+
[data-static],
|
|
357
|
+
:disabled
|
|
358
|
+
):hover {
|
|
359
|
+
background: var(--kumiko-list-row-selected-bg);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/* Forced colours: the current row takes the selection colours, and borders stay. */
|
|
364
|
+
@media (forced-colors: active) {
|
|
365
|
+
[data-slot="list-row"] {
|
|
366
|
+
background: Canvas;
|
|
367
|
+
color: CanvasText;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
[data-slot="list-row"][data-bordered] {
|
|
371
|
+
border-color: ButtonText;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
[data-slot="list-row"][data-current],
|
|
375
|
+
[data-kumiko-list-row~="glide"] [data-slot="list-row"][data-current] {
|
|
376
|
+
background: Highlight;
|
|
377
|
+
color: HighlightText;
|
|
378
|
+
forced-color-adjust: none;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
[data-slot="list-row"]::before,
|
|
382
|
+
[data-slot="list-row-glide"][data-kind="current"]::before {
|
|
383
|
+
background: HighlightText;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
[data-slot="list-row-glide"][data-kind="current"] {
|
|
387
|
+
background: Highlight;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
[data-slot="list-row-glide"][data-kind="hover"] {
|
|
391
|
+
outline: 1px solid Highlight;
|
|
392
|
+
background: transparent;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
[data-slot="list-row"][data-selected] {
|
|
396
|
+
outline: 1px dashed Highlight;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
[data-slot="list-row"]:focus-visible {
|
|
400
|
+
outline-color: Highlight;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
2
|
+
/** How a hovered row looks: a wash fill, a wash fill that also grows a little, or nothing. */
|
|
3
|
+
export type RowHover = "wash" | "grow" | "none";
|
|
4
|
+
/** How the current row looks: a solid accent fill, a tint with an accent bar, or a tint with a bolder label. */
|
|
5
|
+
export type CurrentLook = "fill" | "bar" | "bold";
|
|
6
|
+
/** How a pressed row looks: it squashes, its fill darkens, or nothing. */
|
|
7
|
+
export type RowPress = "squash" | "dark" | "none";
|
|
8
|
+
/** How tall a row is. `touch` is a comfortable finger-sized row. */
|
|
9
|
+
export type RowSize = "default" | "touch";
|
|
10
|
+
interface RowLook {
|
|
11
|
+
/** How a hovered row looks: a wash that grows slightly, a wash only, or nothing. Words: `hover-grow`, `hover-wash`, `hover-none`. @defaultValue "grow" */
|
|
12
|
+
hover?: RowHover;
|
|
13
|
+
/** How the current row looks. Words: `current-fill`, `current-bar`, `current-bold`. @defaultValue "fill" */
|
|
14
|
+
currentLook?: CurrentLook;
|
|
15
|
+
/** How a pressed row looks. Words: `press-squash`, `press-dark`, `press-none`. @defaultValue "squash" */
|
|
16
|
+
press?: RowPress;
|
|
17
|
+
}
|
|
18
|
+
interface RowParts {
|
|
19
|
+
/** A small icon before the label. It is hidden from screen readers. */
|
|
20
|
+
icon?: ReactNode;
|
|
21
|
+
/** Something after the label, such as a count. */
|
|
22
|
+
trailing?: ReactNode;
|
|
23
|
+
/** A quieter second line under the label. */
|
|
24
|
+
description?: ReactNode;
|
|
25
|
+
/** Draws a thin border round the row. */
|
|
26
|
+
bordered?: boolean;
|
|
27
|
+
/** Marks the row the app is on: `aria-current` and the current look. */
|
|
28
|
+
current?: boolean;
|
|
29
|
+
/** @defaultValue "default" */
|
|
30
|
+
size?: RowSize;
|
|
31
|
+
}
|
|
32
|
+
export type ListRowProps = Omit<ComponentProps<"button">, "children"> & RowParts & RowLook & {
|
|
33
|
+
/** The row is the one child, such as a link, and gets the row's look and parts. */
|
|
34
|
+
asChild?: boolean;
|
|
35
|
+
/** Marks a chosen row with a tint. */
|
|
36
|
+
selected?: boolean;
|
|
37
|
+
children?: ReactNode;
|
|
38
|
+
};
|
|
39
|
+
export type InfoRowProps = Omit<ComponentProps<"div">, "children"> & RowParts & Pick<RowLook, "currentLook"> & {
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
};
|
|
42
|
+
/** An info row: the same layout as a list row, but static. It never looks clickable. */
|
|
43
|
+
export declare function InfoRow({ icon, trailing, description, bordered, current, size, currentLook, children, ...props }: InfoRowProps): React.JSX.Element;
|
|
44
|
+
/**
|
|
45
|
+
* A row in a list: a button with an icon, label, description and trailing part. With `asChild` the one child
|
|
46
|
+
* is the row and brings its own content, so `icon`, `trailing` and `description` are not drawn.
|
|
47
|
+
*/
|
|
48
|
+
export declare function ListRow({ asChild, icon, trailing, description, selected, current, bordered, size, hover, currentLook, press, children, ...props }: ListRowProps): React.JSX.Element;
|
|
49
|
+
export type RowListProps = ComponentProps<"div"> & RowLook & {
|
|
50
|
+
/** The current highlight glides from row to row, and the hover wash trails the pointer. Words: `glide`, `no-glide`. @defaultValue false */
|
|
51
|
+
glide?: boolean;
|
|
52
|
+
/** One Tab stop for the list; the arrow keys, Home and End move between rows. Words: `roving`, `no-roving`. @defaultValue true */
|
|
53
|
+
roving?: boolean;
|
|
54
|
+
/** Extra looks as words, such as "hover-grow current-bar". */
|
|
55
|
+
"data-kumiko-list-row"?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* A list of rows. It sets the looks for every row inside as words on `data-kumiko-list-row`, and adds two
|
|
59
|
+
* options only a container can: `glide`, where the current highlight slides from row to row and the hover
|
|
60
|
+
* wash trails the pointer, and `roving`, where the list is one Tab stop and the arrow keys move between rows.
|
|
61
|
+
* It is a plain group: name it with `aria-label` or give it a role of your own.
|
|
62
|
+
*/
|
|
63
|
+
export declare function RowList({ hover, currentLook, press, glide, roving, children, ...props }: RowListProps): React.JSX.Element;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { renderElement } from "@ui-sdk/react/primitive";
|
|
3
|
+
import { Children, isValidElement, useRef } from "react";
|
|
4
|
+
import { useListHandlers, useListSync } from "./list-row-motion";
|
|
5
|
+
function Parts({ icon, trailing, description, children }) {
|
|
6
|
+
return (_jsxs(_Fragment, { children: [icon ? (_jsx("span", { "data-slot": "list-row-icon", "aria-hidden": "true", children: icon })) : null, description ? (_jsxs("span", { "data-slot": "list-row-text", children: [_jsx("span", { "data-slot": "list-row-label", children: children }), _jsx("span", { "data-slot": "list-row-description", children: description })] })) : (_jsx("span", { "data-slot": "list-row-label", children: children })), trailing ? _jsx("span", { "data-slot": "list-row-trailing", children: trailing }) : null] }));
|
|
7
|
+
}
|
|
8
|
+
/** An info row: the same layout as a list row, but static. It never looks clickable. */
|
|
9
|
+
export function InfoRow({ icon, trailing, description, bordered, current, size = "default", currentLook, children, ...props }) {
|
|
10
|
+
return (_jsx("div", { ...props, "data-slot": "list-row", "data-static": "", "data-bordered": bordered ? "" : undefined, "data-current": current ? "" : undefined, "data-current-look": currentLook, "data-size": size === "default" ? undefined : size, children: _jsx(Parts, { icon: icon, trailing: trailing, description: description, children: children }) }));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A row in a list: a button with an icon, label, description and trailing part. With `asChild` the one child
|
|
14
|
+
* is the row and brings its own content, so `icon`, `trailing` and `description` are not drawn.
|
|
15
|
+
*/
|
|
16
|
+
export function ListRow({ asChild = false, icon, trailing, description, selected, current, bordered, size = "default", hover, currentLook, press, children, ...props }) {
|
|
17
|
+
const own = {
|
|
18
|
+
"aria-current": current ? "true" : undefined,
|
|
19
|
+
...props,
|
|
20
|
+
"data-slot": "list-row",
|
|
21
|
+
"data-bordered": bordered ? "" : undefined,
|
|
22
|
+
"data-size": size === "default" ? undefined : size,
|
|
23
|
+
"data-selected": selected ? "" : undefined,
|
|
24
|
+
"data-current": current ? "" : undefined,
|
|
25
|
+
"data-hover": hover,
|
|
26
|
+
"data-current-look": currentLook,
|
|
27
|
+
"data-press": press
|
|
28
|
+
};
|
|
29
|
+
const child = asChild ? Children.only(children) : null;
|
|
30
|
+
if (isValidElement(child)) {
|
|
31
|
+
return renderElement("button", own, child);
|
|
32
|
+
}
|
|
33
|
+
return (_jsx("button", { type: "button", ...own, children: _jsx(Parts, { icon: icon, trailing: trailing, description: description, children: children }) }));
|
|
34
|
+
}
|
|
35
|
+
function words(...list) {
|
|
36
|
+
const text = list.filter(Boolean).join(" ");
|
|
37
|
+
return text === "" ? undefined : text;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A list of rows. It sets the looks for every row inside as words on `data-kumiko-list-row`, and adds two
|
|
41
|
+
* options only a container can: `glide`, where the current highlight slides from row to row and the hover
|
|
42
|
+
* wash trails the pointer, and `roving`, where the list is one Tab stop and the arrow keys move between rows.
|
|
43
|
+
* It is a plain group: name it with `aria-label` or give it a role of your own.
|
|
44
|
+
*/
|
|
45
|
+
export function RowList({ hover, currentLook, press, glide, roving, children, ...props }) {
|
|
46
|
+
const ref = useRef(null);
|
|
47
|
+
const currentGlide = useRef(null);
|
|
48
|
+
const hoverGlide = useRef(null);
|
|
49
|
+
const stop = useRef(null);
|
|
50
|
+
const word = words(props["data-kumiko-list-row"], hover && `hover-${hover}`, currentLook && `current-${currentLook}`, press && `press-${press}`, glide !== undefined && (glide ? "glide" : "no-glide"), roving !== undefined && (roving ? "roving" : "no-roving"));
|
|
51
|
+
useListSync(ref, currentGlide, stop);
|
|
52
|
+
const handlers = useListHandlers(props, ref, hoverGlide, stop);
|
|
53
|
+
return (_jsxs("div", { ...props, ...handlers, ref: ref, "data-slot": "list-row-list", "data-kumiko-list-row": word, children: [_jsx("span", { "data-slot": "list-row-glide", "data-kind": "hover", "aria-hidden": "true", ref: hoverGlide }), _jsx("span", { "data-slot": "list-row-glide", "data-kind": "current", "aria-hidden": "true", ref: currentGlide }), children] }));
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alulore/kumiko",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Polished, cozy React components with gentle motion, built on ui-sdk. Every look and behaviour can be switched with props and CSS tokens.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -169,6 +169,15 @@
|
|
|
169
169
|
"source": "./src/badge/badge.css",
|
|
170
170
|
"default": "./dist/badge/badge.css"
|
|
171
171
|
},
|
|
172
|
+
"./alert": {
|
|
173
|
+
"source": "./src/alert/index.ts",
|
|
174
|
+
"types": "./dist/alert/index.d.ts",
|
|
175
|
+
"default": "./dist/alert/index.js"
|
|
176
|
+
},
|
|
177
|
+
"./alert.css": {
|
|
178
|
+
"source": "./src/alert/alert.css",
|
|
179
|
+
"default": "./dist/alert/alert.css"
|
|
180
|
+
},
|
|
172
181
|
"./chip": {
|
|
173
182
|
"source": "./src/chip/index.ts",
|
|
174
183
|
"types": "./dist/chip/index.d.ts",
|
|
@@ -178,6 +187,24 @@
|
|
|
178
187
|
"source": "./src/chip/chip.css",
|
|
179
188
|
"default": "./dist/chip/chip.css"
|
|
180
189
|
},
|
|
190
|
+
"./card": {
|
|
191
|
+
"source": "./src/card/index.ts",
|
|
192
|
+
"types": "./dist/card/index.d.ts",
|
|
193
|
+
"default": "./dist/card/index.js"
|
|
194
|
+
},
|
|
195
|
+
"./card.css": {
|
|
196
|
+
"source": "./src/card/card.css",
|
|
197
|
+
"default": "./dist/card/card.css"
|
|
198
|
+
},
|
|
199
|
+
"./list-row": {
|
|
200
|
+
"source": "./src/list-row/index.ts",
|
|
201
|
+
"types": "./dist/list-row/index.d.ts",
|
|
202
|
+
"default": "./dist/list-row/index.js"
|
|
203
|
+
},
|
|
204
|
+
"./list-row.css": {
|
|
205
|
+
"source": "./src/list-row/list-row.css",
|
|
206
|
+
"default": "./dist/list-row/list-row.css"
|
|
207
|
+
},
|
|
181
208
|
"./kbd": {
|
|
182
209
|
"source": "./src/kbd/index.ts",
|
|
183
210
|
"types": "./dist/kbd/index.d.ts",
|