@nocoo/basalt 3.0.0 → 3.2.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/ai/DESIGN.md +157 -39
- package/ai/INTEGRATION.md +83 -8
- package/ai/USAGE.md +2 -2
- package/ai/registry.json +302 -79
- package/dist/charts/config.d.ts +1 -1
- package/dist/charts/config.js +1 -1
- package/dist/charts/config.js.map +1 -1
- package/dist/charts/heatmap-matrix.js +2 -2
- package/dist/charts/heatmap-matrix.js.map +1 -1
- package/dist/charts/sparkline.js +1 -1
- package/dist/charts/sparkline.js.map +1 -1
- package/dist/charts/stat-card.js +1 -1
- package/dist/charts/stat-card.js.map +1 -1
- package/dist/components/alert-dialog.js +4 -4
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/approval-card.js +5 -6
- package/dist/components/approval-card.js.map +1 -1
- package/dist/components/avatar.js +1 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/chat-bubble.js +1 -1
- package/dist/components/chat-bubble.js.map +1 -1
- package/dist/components/chat-header.js +1 -1
- package/dist/components/chat-header.js.map +1 -1
- package/dist/components/chat-inbox.js +1 -1
- package/dist/components/chat-inbox.js.map +1 -1
- package/dist/components/chat-markdown.js +1 -1
- package/dist/components/chat-markdown.js.map +1 -1
- package/dist/components/chat-message.js +1 -1
- package/dist/components/chat-message.js.map +1 -1
- package/dist/components/code.js +4 -3
- package/dist/components/code.js.map +1 -1
- package/dist/components/context-cards.js +5 -5
- package/dist/components/context-cards.js.map +1 -1
- package/dist/components/data-table.d.ts +7 -1
- package/dist/components/data-table.js +127 -132
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/dialog.js +3 -3
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/diff-table.js +20 -15
- package/dist/components/diff-table.js.map +1 -1
- package/dist/components/input-area.js +1 -1
- package/dist/components/input-area.js.map +1 -1
- package/dist/components/layer-card.d.ts +6 -4
- package/dist/components/layer-card.js +60 -71
- package/dist/components/layer-card.js.map +1 -1
- package/dist/components/loader.js +1 -1
- package/dist/components/loader.js.map +1 -1
- package/dist/components/page-header.d.ts +2 -2
- package/dist/components/page-header.js +7 -7
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/recommendation-card.js +2 -2
- package/dist/components/recommendation-card.js.map +1 -1
- package/dist/components/section-rule.js +1 -1
- package/dist/components/section-rule.js.map +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/sheet.js +3 -3
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/sidebar.js +19 -16
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/skeleton-line.js +1 -1
- package/dist/components/skeleton-line.js.map +1 -1
- package/dist/components/stat-strip.js +1 -1
- package/dist/components/stat-strip.js.map +1 -1
- package/dist/components/table.d.ts +41 -2
- package/dist/components/table.js +44 -15
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/tag-badge.js +1 -1
- package/dist/components/tag-badge.js.map +1 -1
- package/dist/components/text.js +2 -2
- package/dist/components/text.js.map +1 -1
- package/dist/components/thinking.js +1 -1
- package/dist/components/thinking.js.map +1 -1
- package/dist/components/tool-chips.js +2 -2
- package/dist/components/tool-chips.js.map +1 -1
- package/dist/styles/standalone.css +145 -89
- package/dist/styles/tailwind.css +2 -0
- package/dist/styles/tokens.css +84 -39
- package/dist/utils/use-hover-highlight.js +38 -36
- package/dist/utils/use-hover-highlight.js.map +1 -1
- package/package.json +28 -28
package/dist/styles/tokens.css
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
--basalt-space-md: 0.375rem;
|
|
5
5
|
--basalt-space-lg: 0.5rem;
|
|
6
6
|
--basalt-space-default: var(--basalt-space-lg);
|
|
7
|
-
--basalt-text-xs: 0.
|
|
7
|
+
--basalt-text-xs: 0.75rem;
|
|
8
8
|
--basalt-text-sm: 0.75rem;
|
|
9
|
-
--basalt-text-code: 0.
|
|
9
|
+
--basalt-text-code: 0.875rem;
|
|
10
10
|
--basalt-text-base: 0.875rem;
|
|
11
|
-
--basalt-text-lg:
|
|
11
|
+
--basalt-text-lg: 1.125rem;
|
|
12
12
|
--basalt-text-xl: 1.125rem;
|
|
13
|
-
--basalt-text-2xl: 1.
|
|
13
|
+
--basalt-text-2xl: 1.125rem;
|
|
14
14
|
--basalt-text-3xl: 1.5rem;
|
|
15
|
-
--basalt-text-4xl: 1.
|
|
15
|
+
--basalt-text-4xl: 1.5rem;
|
|
16
16
|
--basalt-text-5xl: 2.25rem;
|
|
17
17
|
--basalt-text-6xl: 3rem;
|
|
18
18
|
--basalt-text-7xl: 3.75rem;
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
--basalt-leading-inline: calc(16 / 12);
|
|
26
26
|
--basalt-leading-action: calc(24 / 14);
|
|
27
27
|
--basalt-leading-action-sm: 1.5;
|
|
28
|
-
--basalt-leading-action-lg:
|
|
28
|
+
--basalt-leading-action-lg: calc(22 / 14);
|
|
29
29
|
--basalt-leading-banner: calc(22 / 14);
|
|
30
30
|
--basalt-radius-sm: 0.25rem;
|
|
31
31
|
--basalt-radius-md: 0.5rem;
|
|
@@ -82,15 +82,15 @@
|
|
|
82
82
|
--basalt-size-icon-display: 1.5rem;
|
|
83
83
|
--basalt-size-touch: 2.75rem;
|
|
84
84
|
--basalt-size-menu-row: var(--basalt-size-control);
|
|
85
|
-
--basalt-size-table-row: 2.
|
|
85
|
+
--basalt-size-table-row: 2.5rem;
|
|
86
86
|
--basalt-size-check: 1rem;
|
|
87
87
|
--basalt-size-check-sm: 0.75rem;
|
|
88
88
|
--basalt-size-textarea: 5rem;
|
|
89
89
|
--basalt-size-textarea-sm: 4rem;
|
|
90
90
|
--basalt-size-textarea-lg: 6rem;
|
|
91
|
-
--basalt-space-control-x:
|
|
92
|
-
--basalt-space-control-x-sm:
|
|
93
|
-
--basalt-space-control-x-lg:
|
|
91
|
+
--basalt-space-control-x: 0.75rem;
|
|
92
|
+
--basalt-space-control-x-sm: 0.625rem;
|
|
93
|
+
--basalt-space-control-x-lg: 1rem;
|
|
94
94
|
--basalt-space-control-y: var(--basalt-space-sm);
|
|
95
95
|
--basalt-space-control-gap: var(--basalt-space-lg);
|
|
96
96
|
--basalt-space-menu-inset: var(--basalt-space-lg);
|
|
@@ -105,11 +105,12 @@
|
|
|
105
105
|
--basalt-space-layout-lg: 1.5rem;
|
|
106
106
|
--basalt-space-layout-xl: 2rem;
|
|
107
107
|
--basalt-space-field-gap: var(--basalt-space-lg);
|
|
108
|
-
--basalt-space-table-x:
|
|
109
|
-
--basalt-space-table-y: var(--basalt-space-
|
|
108
|
+
--basalt-space-table-x: 0.75rem;
|
|
109
|
+
--basalt-space-table-y: var(--basalt-space-lg);
|
|
110
110
|
--basalt-space-overlay: var(--basalt-space-lg);
|
|
111
111
|
--basalt-space-panel-x: var(--basalt-space-card);
|
|
112
112
|
--basalt-space-panel-y: var(--basalt-space-card-sm);
|
|
113
|
+
--basalt-space-table-edge: var(--basalt-space-panel-x);
|
|
113
114
|
--basalt-space-content-gap: var(--basalt-space-lg);
|
|
114
115
|
--basalt-space-row-x: var(--basalt-space-lg);
|
|
115
116
|
--basalt-space-row-y: var(--basalt-space-md);
|
|
@@ -158,11 +159,13 @@
|
|
|
158
159
|
--basalt-input: 220 13% 88%;
|
|
159
160
|
--basalt-ring: var(--basalt-primary);
|
|
160
161
|
--basalt-control-fill: hsl(var(--basalt-secondary));
|
|
161
|
-
--basalt-
|
|
162
|
-
--basalt-
|
|
162
|
+
--basalt-surface-current: var(--basalt-card);
|
|
163
|
+
--basalt-surface-elevated: var(--basalt-secondary);
|
|
164
|
+
--basalt-hover-weight: 18%;
|
|
165
|
+
--basalt-hover: color-mix(
|
|
163
166
|
in srgb,
|
|
164
|
-
hsl(var(--basalt-primary))
|
|
165
|
-
hsl(var(--basalt-
|
|
167
|
+
hsl(var(--basalt-primary)) 18%,
|
|
168
|
+
hsl(var(--basalt-surface-elevated))
|
|
166
169
|
);
|
|
167
170
|
--basalt-selected: 0 0% 100%;
|
|
168
171
|
--basalt-selected-foreground: var(--basalt-foreground);
|
|
@@ -197,13 +200,13 @@
|
|
|
197
200
|
--basalt-chart-yellow: 49 100% 69%;
|
|
198
201
|
--basalt-chart-pearl: 215 12% 48%;
|
|
199
202
|
--basalt-chart-1: var(--basalt-chart-blue);
|
|
200
|
-
--basalt-chart-2: var(--basalt-chart-
|
|
201
|
-
--basalt-chart-3:
|
|
202
|
-
--basalt-chart-4:
|
|
203
|
+
--basalt-chart-2: var(--basalt-chart-pink);
|
|
204
|
+
--basalt-chart-3: 182 38% 48%;
|
|
205
|
+
--basalt-chart-4: 280 32% 62%;
|
|
203
206
|
--basalt-chart-5: var(--basalt-chart-green);
|
|
204
|
-
--basalt-chart-6:
|
|
207
|
+
--basalt-chart-6: 27 54% 62%;
|
|
205
208
|
--basalt-chart-7: var(--basalt-chart-yellow);
|
|
206
|
-
--basalt-chart-8:
|
|
209
|
+
--basalt-chart-8: 237 36% 62%;
|
|
207
210
|
--basalt-chart-9: var(--basalt-chart-pink);
|
|
208
211
|
--basalt-chart-10: var(--basalt-chart-pink);
|
|
209
212
|
--basalt-chart-11: var(--basalt-chart-pink);
|
|
@@ -233,6 +236,7 @@
|
|
|
233
236
|
--basalt-accent-10: 280 53% 71%;
|
|
234
237
|
--basalt-accent-11: 237 66% 69%;
|
|
235
238
|
--basalt-accent-12: 210 20% 87%;
|
|
239
|
+
--basalt-success: var(--basalt-tag-success-foreground);
|
|
236
240
|
--basalt-badge-green: 113 60% 30%;
|
|
237
241
|
--basalt-badge-green-foreground: 0 0% 100%;
|
|
238
242
|
--basalt-badge-teal: 182 62% 30%;
|
|
@@ -287,6 +291,7 @@
|
|
|
287
291
|
--basalt-danger-tint: 0 40% 16%;
|
|
288
292
|
--basalt-info-foreground: 0 0% 10%;
|
|
289
293
|
--basalt-warning-foreground: 0 0% 10%;
|
|
294
|
+
--basalt-success: var(--basalt-tag-success-foreground);
|
|
290
295
|
--basalt-badge-green: 113 55% 62%;
|
|
291
296
|
--basalt-badge-green-foreground: 0 0% 10%;
|
|
292
297
|
--basalt-badge-teal: var(--basalt-accent-3);
|
|
@@ -297,11 +302,13 @@
|
|
|
297
302
|
--basalt-input: 0 0% 18%;
|
|
298
303
|
--basalt-ring: var(--basalt-primary);
|
|
299
304
|
--basalt-control-fill: hsl(var(--basalt-secondary));
|
|
300
|
-
--basalt-
|
|
301
|
-
--basalt-
|
|
305
|
+
--basalt-surface-current: var(--basalt-card);
|
|
306
|
+
--basalt-surface-elevated: var(--basalt-secondary);
|
|
307
|
+
--basalt-hover-weight: 18%;
|
|
308
|
+
--basalt-hover: color-mix(
|
|
302
309
|
in srgb,
|
|
303
|
-
hsl(var(--basalt-primary))
|
|
304
|
-
hsl(var(--basalt-
|
|
310
|
+
hsl(var(--basalt-primary)) 18%,
|
|
311
|
+
hsl(var(--basalt-surface-elevated))
|
|
305
312
|
);
|
|
306
313
|
--basalt-selected: 0 0% 22%;
|
|
307
314
|
--basalt-selected-foreground: var(--basalt-foreground);
|
|
@@ -323,13 +330,13 @@
|
|
|
323
330
|
--basalt-chart-yellow: 49 100% 73%;
|
|
324
331
|
--basalt-chart-pearl: 210 20% 86%;
|
|
325
332
|
--basalt-chart-1: var(--basalt-chart-blue);
|
|
326
|
-
--basalt-chart-2: var(--basalt-chart-
|
|
327
|
-
--basalt-chart-3:
|
|
328
|
-
--basalt-chart-4:
|
|
333
|
+
--basalt-chart-2: var(--basalt-chart-pink);
|
|
334
|
+
--basalt-chart-3: 182 38% 64%;
|
|
335
|
+
--basalt-chart-4: 280 32% 74%;
|
|
329
336
|
--basalt-chart-5: var(--basalt-chart-green);
|
|
330
|
-
--basalt-chart-6:
|
|
337
|
+
--basalt-chart-6: 27 54% 72%;
|
|
331
338
|
--basalt-chart-7: var(--basalt-chart-yellow);
|
|
332
|
-
--basalt-chart-8:
|
|
339
|
+
--basalt-chart-8: 237 36% 74%;
|
|
333
340
|
--basalt-chart-9: var(--basalt-chart-pink);
|
|
334
341
|
--basalt-chart-10: var(--basalt-chart-pink);
|
|
335
342
|
--basalt-chart-11: var(--basalt-chart-pink);
|
|
@@ -381,13 +388,22 @@
|
|
|
381
388
|
|
|
382
389
|
[data-basalt-surface-root] {
|
|
383
390
|
background: hsl(var(--basalt-card));
|
|
384
|
-
--basalt-
|
|
391
|
+
--basalt-surface-current: var(--basalt-card);
|
|
392
|
+
--basalt-surface-elevated: var(--basalt-secondary);
|
|
393
|
+
--basalt-control-fill: hsl(var(--basalt-secondary));
|
|
385
394
|
--basalt-zebra-fill: hsl(var(--basalt-secondary));
|
|
386
395
|
}
|
|
387
396
|
|
|
388
397
|
[data-basalt-surface-root] [data-basalt-surface] {
|
|
389
398
|
background: hsl(var(--basalt-secondary));
|
|
390
|
-
--basalt-
|
|
399
|
+
--basalt-surface-current: var(--basalt-secondary);
|
|
400
|
+
--basalt-surface-elevated: var(--basalt-bright);
|
|
401
|
+
--basalt-control-fill: hsl(var(--basalt-bright));
|
|
402
|
+
--basalt-hover: color-mix(
|
|
403
|
+
in srgb,
|
|
404
|
+
hsl(var(--basalt-primary)) var(--basalt-hover-weight),
|
|
405
|
+
hsl(var(--basalt-surface-elevated))
|
|
406
|
+
);
|
|
391
407
|
--basalt-primary-hover: color-mix(
|
|
392
408
|
in srgb,
|
|
393
409
|
hsl(var(--basalt-primary)) 90%,
|
|
@@ -403,6 +419,7 @@
|
|
|
403
419
|
|
|
404
420
|
[data-basalt-surface-root] [data-basalt-surface] [data-basalt-surface] {
|
|
405
421
|
background: hsl(var(--basalt-bright));
|
|
422
|
+
--basalt-surface-current: var(--basalt-bright);
|
|
406
423
|
--basalt-control-fill: hsl(var(--basalt-bright));
|
|
407
424
|
--basalt-zebra-fill: transparent;
|
|
408
425
|
}
|
|
@@ -415,14 +432,27 @@
|
|
|
415
432
|
|
|
416
433
|
[data-basalt-surface]:not([data-basalt-surface-root] *):not([data-basalt-surface] *) {
|
|
417
434
|
background: hsl(var(--basalt-card));
|
|
418
|
-
--basalt-
|
|
435
|
+
--basalt-surface-current: var(--basalt-card);
|
|
436
|
+
--basalt-surface-elevated: var(--basalt-bright);
|
|
437
|
+
--basalt-control-fill: hsl(var(--basalt-bright));
|
|
438
|
+
--basalt-hover: color-mix(
|
|
439
|
+
in srgb,
|
|
440
|
+
hsl(var(--basalt-primary)) var(--basalt-hover-weight),
|
|
441
|
+
hsl(var(--basalt-surface-elevated))
|
|
442
|
+
);
|
|
419
443
|
--basalt-zebra-fill: hsl(var(--basalt-secondary));
|
|
420
444
|
}
|
|
421
445
|
|
|
422
446
|
/* biome-ignore lint/style/noDescendingSpecificity: Rootless surface trees cannot overlap a surface-root tree. */
|
|
423
447
|
[data-basalt-surface]:not([data-basalt-surface-root] *) [data-basalt-surface] {
|
|
424
448
|
background: hsl(var(--basalt-secondary));
|
|
425
|
-
--basalt-
|
|
449
|
+
--basalt-surface-current: var(--basalt-secondary);
|
|
450
|
+
--basalt-control-fill: hsl(var(--basalt-bright));
|
|
451
|
+
--basalt-hover: color-mix(
|
|
452
|
+
in srgb,
|
|
453
|
+
hsl(var(--basalt-primary)) var(--basalt-hover-weight),
|
|
454
|
+
hsl(var(--basalt-surface-elevated))
|
|
455
|
+
);
|
|
426
456
|
--basalt-primary-hover: color-mix(
|
|
427
457
|
in srgb,
|
|
428
458
|
hsl(var(--basalt-primary)) 90%,
|
|
@@ -440,6 +470,7 @@
|
|
|
440
470
|
[data-basalt-surface]
|
|
441
471
|
[data-basalt-surface] {
|
|
442
472
|
background: hsl(var(--basalt-bright));
|
|
473
|
+
--basalt-surface-current: var(--basalt-bright);
|
|
443
474
|
--basalt-control-fill: hsl(var(--basalt-bright));
|
|
444
475
|
--basalt-zebra-fill: transparent;
|
|
445
476
|
}
|
|
@@ -453,6 +484,11 @@
|
|
|
453
484
|
--basalt-zebra-fill: transparent;
|
|
454
485
|
}
|
|
455
486
|
|
|
487
|
+
[data-basalt-table] tbody tr:not(:last-child),
|
|
488
|
+
[data-basalt-table] tbody tr:not(:last-child) > td {
|
|
489
|
+
border-bottom: 1px solid hsl(var(--basalt-border) / 0.5);
|
|
490
|
+
}
|
|
491
|
+
|
|
456
492
|
[data-basalt-table] tbody tr[aria-selected="true"] td {
|
|
457
493
|
background: hsl(var(--basalt-selected));
|
|
458
494
|
color: hsl(var(--basalt-selected-foreground));
|
|
@@ -462,8 +498,16 @@
|
|
|
462
498
|
background: var(--basalt-hover);
|
|
463
499
|
}
|
|
464
500
|
|
|
465
|
-
[data-basalt-table] tbody tr:nth-child(even)
|
|
466
|
-
background: var(--basalt-
|
|
501
|
+
[data-basalt-table][data-striped="true"] tbody tr:nth-child(even) {
|
|
502
|
+
background-color: hsl(var(--basalt-surface-current));
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
[data-basalt-table-container][data-edge="attached"] :where(th, td):first-child {
|
|
506
|
+
padding-inline-start: var(--basalt-space-card);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
[data-basalt-table-container][data-edge="attached"] :where(th, td):last-child {
|
|
510
|
+
padding-inline-end: var(--basalt-space-card);
|
|
467
511
|
}
|
|
468
512
|
|
|
469
513
|
[data-basalt-table]
|
|
@@ -517,7 +561,7 @@
|
|
|
517
561
|
.basalt-action-lg {
|
|
518
562
|
padding-block: var(--basalt-space-lg);
|
|
519
563
|
padding-inline: var(--basalt-space-control-x-lg);
|
|
520
|
-
font-size: var(--basalt-text-
|
|
564
|
+
font-size: var(--basalt-text-base);
|
|
521
565
|
line-height: var(--basalt-leading-action-lg);
|
|
522
566
|
}
|
|
523
567
|
.basalt-action-icon {
|
|
@@ -614,8 +658,9 @@
|
|
|
614
658
|
height: var(--basalt-hover-height, 0px);
|
|
615
659
|
transform: translate(var(--basalt-hover-x, 0px), var(--basalt-hover-y, 0px));
|
|
616
660
|
border-radius: var(--basalt-radius-md);
|
|
617
|
-
background:
|
|
661
|
+
background: var(--basalt-hover);
|
|
618
662
|
opacity: 0;
|
|
663
|
+
transition: none;
|
|
619
664
|
}
|
|
620
665
|
.basalt-hover-list[data-hover-visible="true"]::before {
|
|
621
666
|
opacity: 1;
|
|
@@ -677,7 +722,7 @@
|
|
|
677
722
|
width: var(--basalt-command-width);
|
|
678
723
|
height: var(--basalt-command-height);
|
|
679
724
|
border-radius: var(--basalt-radius-md);
|
|
680
|
-
background:
|
|
725
|
+
background: var(--basalt-hover);
|
|
681
726
|
}
|
|
682
727
|
|
|
683
728
|
.basalt-command-list[data-basalt-command-animated="true"]::before {
|
|
@@ -6,53 +6,55 @@ var n = "[data-basalt-hover-item]", r = "[data-highlighted], [data-hover-active=
|
|
|
6
6
|
function i(i, { restoreOnPointerLeave: a = !0 } = {}) {
|
|
7
7
|
return t((t) => {
|
|
8
8
|
if (e(i, t), !t) return;
|
|
9
|
-
let o = null, s = !1, c =
|
|
10
|
-
|
|
11
|
-
}),
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
for (let e of t.querySelectorAll(`${n}:is(${r})`)) if (
|
|
15
|
-
|
|
9
|
+
let o = null, s = !1, c = !1, l = null, u = null, d = null, f = null, p = !0, m = 0, h = "", g = !0, _ = (e) => e && t.contains(e) && e.matches(n) && e.closest(".basalt-hover-list") === t && !e.closest("[hidden], [disabled], [aria-disabled=\"true\"], [data-disabled=\"\"], [data-disabled=\"true\"]") ? e : null, v = (e) => _(e instanceof Element ? e.closest(n) : null), y = new ResizeObserver(() => {
|
|
10
|
+
g = !0, x();
|
|
11
|
+
}), b = () => {
|
|
12
|
+
if (m = 0, p) {
|
|
13
|
+
f = null, d = null;
|
|
14
|
+
for (let e of t.querySelectorAll(`${n}:is(${r})`)) if (_(e) && (d ||= e, e.matches("[data-highlighted], [data-hover-active=\"true\"]"))) {
|
|
15
|
+
f = e;
|
|
16
16
|
break;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
p = !1;
|
|
19
19
|
}
|
|
20
|
-
let e =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
let e = c;
|
|
21
|
+
c = !1, e && (t.dataset.hoverAnimated = "false");
|
|
22
|
+
let i = s ? null : a ? _(f) ?? _(o) ?? _(l) ?? _(d) : _(o);
|
|
23
|
+
if (i === u && !g) return;
|
|
24
|
+
i !== u && (u && y.unobserve(u), i && y.observe(i));
|
|
25
|
+
let v = i?.offsetWidth ?? 0, b = i?.offsetHeight ?? 0;
|
|
26
|
+
if (!i || !v || !b) {
|
|
27
|
+
a || (t.dataset.hoverAnimated = "false"), t.dataset.hoverVisible = "false", u = null, h = "", g = !1;
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
28
|
-
let
|
|
29
|
-
for (let
|
|
30
|
-
for (let
|
|
31
|
-
let
|
|
32
|
-
|
|
30
|
+
let x = 0, S = 0;
|
|
31
|
+
for (let e = i; e && e !== t; e = e.offsetParent) x += e.offsetLeft, S += e.offsetTop;
|
|
32
|
+
for (let e = i.parentElement; e && e !== t; e = e.parentElement) x -= e.scrollLeft, S -= e.scrollTop;
|
|
33
|
+
let C = `${x},${S},${v},${b}`;
|
|
34
|
+
C !== h && (t.dataset.hoverAnimated = u && u !== i && !g && !e ? "true" : "false", t.style.setProperty("--basalt-hover-x", `${x}px`), t.style.setProperty("--basalt-hover-y", `${S}px`), t.style.setProperty("--basalt-hover-width", `${v}px`), t.style.setProperty("--basalt-hover-height", `${b}px`), h = C), t.dataset.hoverVisible = "true", u = i, g = !1;
|
|
33
35
|
};
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
+
function x() {
|
|
37
|
+
m ||= requestAnimationFrame(b);
|
|
36
38
|
}
|
|
37
|
-
let
|
|
39
|
+
let S = (e) => {
|
|
38
40
|
if (e.pointerType === "touch") return;
|
|
39
41
|
s = !1;
|
|
40
|
-
let t =
|
|
41
|
-
t !== o && (o = t,
|
|
42
|
-
},
|
|
43
|
-
o = null, s = !a,
|
|
44
|
-
}, C = (e) => {
|
|
45
|
-
s = !1, c = _(e.target), o = null, b();
|
|
42
|
+
let t = v(e.target);
|
|
43
|
+
t !== o && (!a && (!t || !o) && (c = !0), o = t, x());
|
|
44
|
+
}, C = () => {
|
|
45
|
+
o = null, s = !a, a || (c = !0), x();
|
|
46
46
|
}, w = (e) => {
|
|
47
|
-
|
|
47
|
+
l = v(e.target), a && (s = !1, o = null, x());
|
|
48
48
|
}, T = (e) => {
|
|
49
|
-
|
|
49
|
+
l = v(e.relatedTarget), a && x();
|
|
50
50
|
}, E = (e) => {
|
|
51
|
-
|
|
52
|
-
}, D =
|
|
53
|
-
|
|
51
|
+
e.target instanceof Element && (t.contains(e.target) || t.id && e.target.getAttribute("aria-controls") === t.id) && a && (o = null, s = !1, x());
|
|
52
|
+
}, D = (e) => {
|
|
53
|
+
(e.target !== t || e.type === "scroll") && (g = !0, x());
|
|
54
|
+
}, O = new MutationObserver((e) => {
|
|
55
|
+
p = !0, e.some((e) => e.type === "childList" || e.attributeName === "hidden") && (g = !0), x();
|
|
54
56
|
});
|
|
55
|
-
return
|
|
57
|
+
return O.observe(t, {
|
|
56
58
|
subtree: !0,
|
|
57
59
|
childList: !0,
|
|
58
60
|
attributes: !0,
|
|
@@ -69,8 +71,8 @@ function i(i, { restoreOnPointerLeave: a = !0 } = {}) {
|
|
|
69
71
|
"data-disabled",
|
|
70
72
|
"hidden"
|
|
71
73
|
]
|
|
72
|
-
}),
|
|
73
|
-
cancelAnimationFrame(
|
|
74
|
+
}), y.observe(t), t.addEventListener("pointerover", S), t.addEventListener("pointerleave", C), t.addEventListener("focusin", w), t.addEventListener("focusout", T), t.ownerDocument.addEventListener("keydown", E), t.addEventListener("scroll", D, !0), t.addEventListener("animationend", D), t.addEventListener("transitionend", D), x(), () => {
|
|
75
|
+
cancelAnimationFrame(m), y.disconnect(), O.disconnect(), t.removeEventListener("pointerover", S), t.removeEventListener("pointerleave", C), t.removeEventListener("focusin", w), t.removeEventListener("focusout", T), t.ownerDocument.removeEventListener("keydown", E), t.removeEventListener("scroll", D, !0), t.removeEventListener("animationend", D), t.removeEventListener("transitionend", D), e(i, null);
|
|
74
76
|
};
|
|
75
77
|
}, [i, a]);
|
|
76
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-hover-highlight.js","names":["ROW","ACTIVE","useHoverHighlight","useCallback","assignRef","ref","root","hovered","pointerExited","focused","previous","selected","active","selectionDirty","frame","geometry","layoutChanged","eligible","node","row","target","resize","schedule","update","item","width","height","x","next","over","event","leave","restoreOnPointerLeave","focus","blur","keyboard","layout","mutations","records","record"],"sources":["../../src/utils/use-hover-highlight.ts"],"sourcesContent":["import { type Ref, useCallback } from \"react\";\nimport { assignRef } from \"./selection-indicator\";\n\nconst ROW = \"[data-basalt-hover-item]\";\nconst ACTIVE =\n\t'[data-highlighted], [data-hover-active=\"true\"], [aria-selected=\"true\"], [data-state=\"checked\"], [data-hover-selected=\"true\"], [data-selected=\"true\"]';\n\nexport function useHoverHighlight(\n\tref?: Ref<HTMLElement | null>,\n\t{ restoreOnPointerLeave = true }: { restoreOnPointerLeave?: boolean } = {},\n) {\n\treturn useCallback(\n\t\t(root: HTMLElement | null) => {\n\t\t\tassignRef(ref, root);\n\t\t\tif (!root) return;\n\t\t\tlet hovered: HTMLElement | null = null;\n\t\t\tlet pointerExited = false;\n\t\t\tlet focused: HTMLElement | null = null;\n\t\t\tlet previous: HTMLElement | null = null;\n\t\t\tlet selected: HTMLElement | null = null;\n\t\t\tlet active: HTMLElement | null = null;\n\t\t\tlet selectionDirty = true;\n\t\t\tlet frame = 0;\n\t\t\tlet geometry = \"\";\n\t\t\tlet layoutChanged = true;\n\t\t\tconst eligible = (node: HTMLElement | null) =>\n\t\t\t\tnode &&\n\t\t\t\troot.contains(node) &&\n\t\t\t\tnode.matches(ROW) &&\n\t\t\t\tnode.closest(\".basalt-hover-list\") === root &&\n\t\t\t\t!node.closest(\n\t\t\t\t\t'[hidden], [disabled], [aria-disabled=\"true\"], [data-disabled=\"\"], [data-disabled=\"true\"]',\n\t\t\t\t)\n\t\t\t\t\t? node\n\t\t\t\t\t: null;\n\t\t\tconst row = (target: EventTarget | null) =>\n\t\t\t\teligible(target instanceof Element ? target.closest<HTMLElement>(ROW) : null);\n\t\t\tconst resize = new ResizeObserver(() => {\n\t\t\t\tlayoutChanged = true;\n\t\t\t\tschedule();\n\t\t\t});\n\t\t\tconst update = () => {\n\t\t\t\tframe = 0;\n\t\t\t\tif (selectionDirty) {\n\t\t\t\t\tactive = null;\n\t\t\t\t\tselected = null;\n\t\t\t\t\tfor (const node of root.querySelectorAll<HTMLElement>(`${ROW}:is(${ACTIVE})`)) {\n\t\t\t\t\t\tif (!eligible(node)) continue;\n\t\t\t\t\t\tif (!selected) selected = node;\n\t\t\t\t\t\tif (node.matches('[data-highlighted], [data-hover-active=\"true\"]')) {\n\t\t\t\t\t\t\tactive = node;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tselectionDirty = false;\n\t\t\t\t}\n\t\t\t\tconst item = pointerExited\n\t\t\t\t\t? null\n\t\t\t\t\t: (eligible(active) ?? eligible(hovered) ?? eligible(focused) ?? eligible(selected));\n\t\t\t\tif (item === previous && !layoutChanged) return;\n\t\t\t\tif (item !== previous) {\n\t\t\t\t\tif (previous) resize.unobserve(previous);\n\t\t\t\t\tif (item) resize.observe(item);\n\t\t\t\t}\n\t\t\t\tconst width = item?.offsetWidth ?? 0;\n\t\t\t\tconst height = item?.offsetHeight ?? 0;\n\t\t\t\tif (!item || !width || !height) {\n\t\t\t\t\tif (pointerExited) root.dataset.hoverAnimated = \"true\";\n\t\t\t\t\troot.dataset.hoverVisible = \"false\";\n\t\t\t\t\tprevious = null;\n\t\t\t\t\tgeometry = \"\";\n\t\t\t\t\tlayoutChanged = false;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet x = 0,\n\t\t\t\t\ty = 0;\n\t\t\t\tfor (\n\t\t\t\t\tlet node: HTMLElement | null = item;\n\t\t\t\t\tnode && node !== root;\n\t\t\t\t\tnode = node.offsetParent as HTMLElement | null\n\t\t\t\t) {\n\t\t\t\t\tx += node.offsetLeft;\n\t\t\t\t\ty += node.offsetTop;\n\t\t\t\t}\n\t\t\t\tfor (let node = item.parentElement; node && node !== root; node = node.parentElement) {\n\t\t\t\t\tx -= node.scrollLeft;\n\t\t\t\t\ty -= node.scrollTop;\n\t\t\t\t}\n\t\t\t\tconst next = `${x},${y},${width},${height}`;\n\t\t\t\tif (next !== geometry) {\n\t\t\t\t\troot.dataset.hoverAnimated =\n\t\t\t\t\t\tprevious && previous !== item && !layoutChanged ? \"true\" : \"false\";\n\t\t\t\t\troot.style.setProperty(\"--basalt-hover-x\", `${x}px`);\n\t\t\t\t\troot.style.setProperty(\"--basalt-hover-y\", `${y}px`);\n\t\t\t\t\troot.style.setProperty(\"--basalt-hover-width\", `${width}px`);\n\t\t\t\t\troot.style.setProperty(\"--basalt-hover-height\", `${height}px`);\n\t\t\t\t\tgeometry = next;\n\t\t\t\t}\n\t\t\t\troot.dataset.hoverVisible = \"true\";\n\t\t\t\tprevious = item;\n\t\t\t\tlayoutChanged = false;\n\t\t\t};\n\t\t\tfunction schedule() {\n\t\t\t\tif (!frame) frame = requestAnimationFrame(update);\n\t\t\t}\n\t\t\tconst over = (event: PointerEvent) => {\n\t\t\t\tif (event.pointerType === \"touch\") return;\n\t\t\t\tpointerExited = false;\n\t\t\t\tconst next = row(event.target);\n\t\t\t\tif (next !== hovered) {\n\t\t\t\t\thovered = next;\n\t\t\t\t\tschedule();\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst leave = () => {\n\t\t\t\thovered = null;\n\t\t\t\tpointerExited = !restoreOnPointerLeave;\n\t\t\t\tschedule();\n\t\t\t};\n\t\t\tconst focus = (event: FocusEvent) => {\n\t\t\t\tpointerExited = false;\n\t\t\t\tfocused = row(event.target);\n\t\t\t\thovered = null;\n\t\t\t\tschedule();\n\t\t\t};\n\t\t\tconst blur = (event: FocusEvent) => {\n\t\t\t\tfocused = row(event.relatedTarget);\n\t\t\t\tschedule();\n\t\t\t};\n\t\t\tconst keyboard = (event: KeyboardEvent) => {\n\t\t\t\tif (\n\t\t\t\t\t!(event.target instanceof Element) ||\n\t\t\t\t\t(!root.contains(event.target) &&\n\t\t\t\t\t\t(!root.id || event.target.getAttribute(\"aria-controls\") !== root.id))\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\thovered = null;\n\t\t\t\tpointerExited = false;\n\t\t\t\tschedule();\n\t\t\t};\n\t\t\tconst layout = (event: Event) => {\n\t\t\t\t// Our pseudo-element transition cannot change row geometry.\n\t\t\t\tif (event.target === root && event.type !== \"scroll\") return;\n\t\t\t\tlayoutChanged = true;\n\t\t\t\tschedule();\n\t\t\t};\n\t\t\tconst mutations = new MutationObserver((records) => {\n\t\t\t\tselectionDirty = true;\n\t\t\t\tif (\n\t\t\t\t\trecords.some((record) => record.type === \"childList\" || record.attributeName === \"hidden\")\n\t\t\t\t)\n\t\t\t\t\tlayoutChanged = true;\n\t\t\t\tschedule();\n\t\t\t});\n\t\t\tmutations.observe(root, {\n\t\t\t\tsubtree: true,\n\t\t\t\tchildList: true,\n\t\t\t\tattributes: true,\n\t\t\t\tattributeFilter: [\n\t\t\t\t\t\"data-basalt-hover-item\",\n\t\t\t\t\t\"data-highlighted\",\n\t\t\t\t\t\"data-state\",\n\t\t\t\t\t\"aria-selected\",\n\t\t\t\t\t\"data-selected\",\n\t\t\t\t\t\"data-hover-active\",\n\t\t\t\t\t\"data-hover-selected\",\n\t\t\t\t\t\"disabled\",\n\t\t\t\t\t\"aria-disabled\",\n\t\t\t\t\t\"data-disabled\",\n\t\t\t\t\t\"hidden\",\n\t\t\t\t],\n\t\t\t});\n\t\t\tresize.observe(root);\n\t\t\troot.addEventListener(\"pointerover\", over);\n\t\t\troot.addEventListener(\"pointerleave\", leave);\n\t\t\troot.addEventListener(\"focusin\", focus);\n\t\t\troot.addEventListener(\"focusout\", blur);\n\t\t\troot.ownerDocument.addEventListener(\"keydown\", keyboard);\n\t\t\troot.addEventListener(\"scroll\", layout, true);\n\t\t\troot.addEventListener(\"animationend\", layout);\n\t\t\troot.addEventListener(\"transitionend\", layout);\n\t\t\tschedule();\n\t\t\treturn () => {\n\t\t\t\tcancelAnimationFrame(frame);\n\t\t\t\tresize.disconnect();\n\t\t\t\tmutations.disconnect();\n\t\t\t\troot.removeEventListener(\"pointerover\", over);\n\t\t\t\troot.removeEventListener(\"pointerleave\", leave);\n\t\t\t\troot.removeEventListener(\"focusin\", focus);\n\t\t\t\troot.removeEventListener(\"focusout\", blur);\n\t\t\t\troot.ownerDocument.removeEventListener(\"keydown\", keyboard);\n\t\t\t\troot.removeEventListener(\"scroll\", layout, true);\n\t\t\t\troot.removeEventListener(\"animationend\", layout);\n\t\t\t\troot.removeEventListener(\"transitionend\", layout);\n\t\t\t\tassignRef(ref, null);\n\t\t\t};\n\t\t},\n\t\t[ref, restoreOnPointerLeave],\n\t);\n}\n"],"mappings":";;;;AAGA,IAAMA,IAAM,4BACNC,IACL;AAED,SAAgBC,EACf,GACA,EAAE,2BAAwB,OAA8C,CAAC,GACxE;CACD,OAAOC,GACL,MAA6B;EAE7B,IADAC,EAAUC,GAAKC,CAAI,GACf,CAACA,GAAM;EACX,IAAIC,IAA8B,MAC9BC,IAAgB,IAChBC,IAA8B,MAC9BC,IAA+B,MAC/BC,IAA+B,MAC/BC,IAA6B,MAC7BC,IAAiB,IACjBC,IAAQ,GACRC,IAAW,IACXC,IAAgB,IACdC,KAAY,MACjBC,KACAZ,EAAK,SAASY,CAAI,KAClBA,EAAK,QAAQlB,CAAG,KAChBkB,EAAK,QAAQ,oBAAoB,MAAMZ,KACvC,CAACY,EAAK,QACL,gGACD,IACGA,IACA,MACEC,KAAO,MACZF,EAASG,aAAkB,UAAUA,EAAO,QAAqBpB,CAAG,IAAI,IAAI,GACvEqB,IAAS,IAAI,qBAAqB;GAEvC,AADA,IAAgB,IAChBC,EAAS;EACV,CAAC,GACKC,UAAe;GAE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IACA;IACA;GACD;EACD,CAAC,GACDe,EAAO,QAAQf,CAAI,GACnBA,EAAK,iBAAiB,eAAeuB,CAAI,GACzCvB,EAAK,iBAAiB,gBAAgByB,CAAK,GAC3CzB,EAAK,iBAAiB,WAAW2B,CAAK,GACtC3B,EAAK,iBAAiB,YAAY4B,CAAI,GACtC5B,EAAK,cAAc,iBAAiB,WAAW6B,CAAQ,GACvD7B,EAAK,iBAAiB,UAAU8B,GAAQ,EAAI,GAC5C9B,EAAK,iBAAiB,gBAAgB8B,CAAM,GAC5C9B,EAAK,iBAAiB,iBAAiB8B,CAAM,GAC7Cd,EAAS,SACI;GAYZ,AAXA,qBAAqBR,CAAK,GAC1BO,EAAO,WAAW,GAClBgB,EAAU,WAAW,GACrB/B,EAAK,oBAAoB,eAAeuB,CAAI,GAC5CvB,EAAK,oBAAoB,gBAAgByB,CAAK,GAC9CzB,EAAK,oBAAoB,WAAW2B,CAAK,GACzC3B,EAAK,oBAAoB,YAAY4B,CAAI,GACzC5B,EAAK,cAAc,oBAAoB,WAAW6B,CAAQ,GAC1D7B,EAAK,oBAAoB,UAAU8B,GAAQ,EAAI,GAC/C9B,EAAK,oBAAoB,gBAAgB8B,CAAM,GAC/C9B,EAAK,oBAAoB,iBAAiB8B,CAAM,GAChDhC,EAAUC,GAAK,IAAI;EACpB;CACD,GACA,CAACA,GAAK2B,CAAqB,CAC5B;AACD"}
|
|
1
|
+
{"version":3,"file":"use-hover-highlight.js","names":["ROW","ACTIVE","useHoverHighlight","useCallback","assignRef","ref","root","hovered","pointerExited","sequenceBroken","focused","previous","selected","active","selectionDirty","frame","geometry","layoutChanged","eligible","node","row","target","resize","schedule","update","broken","item","restoreOnPointerLeave","width","height","y","next","over","event","leave","focus","blur","keyboard","layout","mutations","records","record"],"sources":["../../src/utils/use-hover-highlight.ts"],"sourcesContent":["import { type Ref, useCallback } from \"react\";\nimport { assignRef } from \"./selection-indicator\";\n\nconst ROW = \"[data-basalt-hover-item]\";\nconst ACTIVE =\n\t'[data-highlighted], [data-hover-active=\"true\"], [aria-selected=\"true\"], [data-state=\"checked\"], [data-hover-selected=\"true\"], [data-selected=\"true\"]';\n\nexport function useHoverHighlight(\n\tref?: Ref<HTMLElement | null>,\n\t{ restoreOnPointerLeave = true }: { restoreOnPointerLeave?: boolean } = {},\n) {\n\treturn useCallback(\n\t\t(root: HTMLElement | null) => {\n\t\t\tassignRef(ref, root);\n\t\t\tif (!root) return;\n\t\t\tlet hovered: HTMLElement | null = null;\n\t\t\tlet pointerExited = false;\n\t\t\tlet sequenceBroken = false;\n\t\t\tlet focused: HTMLElement | null = null;\n\t\t\tlet previous: HTMLElement | null = null;\n\t\t\tlet selected: HTMLElement | null = null;\n\t\t\tlet active: HTMLElement | null = null;\n\t\t\tlet selectionDirty = true;\n\t\t\tlet frame = 0;\n\t\t\tlet geometry = \"\";\n\t\t\tlet layoutChanged = true;\n\t\t\tconst eligible = (node: HTMLElement | null) =>\n\t\t\t\tnode &&\n\t\t\t\troot.contains(node) &&\n\t\t\t\tnode.matches(ROW) &&\n\t\t\t\tnode.closest(\".basalt-hover-list\") === root &&\n\t\t\t\t!node.closest(\n\t\t\t\t\t'[hidden], [disabled], [aria-disabled=\"true\"], [data-disabled=\"\"], [data-disabled=\"true\"]',\n\t\t\t\t)\n\t\t\t\t\t? node\n\t\t\t\t\t: null;\n\t\t\tconst row = (target: EventTarget | null) =>\n\t\t\t\teligible(target instanceof Element ? target.closest<HTMLElement>(ROW) : null);\n\t\t\tconst resize = new ResizeObserver(() => {\n\t\t\t\tlayoutChanged = true;\n\t\t\t\tschedule();\n\t\t\t});\n\t\t\tconst update = () => {\n\t\t\t\tframe = 0;\n\t\t\t\tif (selectionDirty) {\n\t\t\t\t\tactive = null;\n\t\t\t\t\tselected = null;\n\t\t\t\t\tfor (const node of root.querySelectorAll<HTMLElement>(`${ROW}:is(${ACTIVE})`)) {\n\t\t\t\t\t\tif (!eligible(node)) continue;\n\t\t\t\t\t\tif (!selected) selected = node;\n\t\t\t\t\t\tif (node.matches('[data-highlighted], [data-hover-active=\"true\"]')) {\n\t\t\t\t\t\t\tactive = node;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tselectionDirty = false;\n\t\t\t\t}\n\t\t\t\tconst broken = sequenceBroken;\n\t\t\t\tsequenceBroken = false;\n\t\t\t\tif (broken) root.dataset.hoverAnimated = \"false\";\n\t\t\t\tconst item = pointerExited\n\t\t\t\t\t? null\n\t\t\t\t\t: restoreOnPointerLeave\n\t\t\t\t\t\t? (eligible(active) ?? eligible(hovered) ?? eligible(focused) ?? eligible(selected))\n\t\t\t\t\t\t: eligible(hovered);\n\t\t\t\tif (item === previous && !layoutChanged) return;\n\t\t\t\tif (item !== previous) {\n\t\t\t\t\tif (previous) resize.unobserve(previous);\n\t\t\t\t\tif (item) resize.observe(item);\n\t\t\t\t}\n\t\t\t\tconst width = item?.offsetWidth ?? 0;\n\t\t\t\tconst height = item?.offsetHeight ?? 0;\n\t\t\t\tif (!item || !width || !height) {\n\t\t\t\t\tif (!restoreOnPointerLeave) root.dataset.hoverAnimated = \"false\";\n\t\t\t\t\troot.dataset.hoverVisible = \"false\";\n\t\t\t\t\tprevious = null;\n\t\t\t\t\tgeometry = \"\";\n\t\t\t\t\tlayoutChanged = false;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet x = 0,\n\t\t\t\t\ty = 0;\n\t\t\t\tfor (\n\t\t\t\t\tlet node: HTMLElement | null = item;\n\t\t\t\t\tnode && node !== root;\n\t\t\t\t\tnode = node.offsetParent as HTMLElement | null\n\t\t\t\t) {\n\t\t\t\t\tx += node.offsetLeft;\n\t\t\t\t\ty += node.offsetTop;\n\t\t\t\t}\n\t\t\t\tfor (let node = item.parentElement; node && node !== root; node = node.parentElement) {\n\t\t\t\t\tx -= node.scrollLeft;\n\t\t\t\t\ty -= node.scrollTop;\n\t\t\t\t}\n\t\t\t\tconst next = `${x},${y},${width},${height}`;\n\t\t\t\tif (next !== geometry) {\n\t\t\t\t\troot.dataset.hoverAnimated =\n\t\t\t\t\t\tprevious && previous !== item && !layoutChanged && !broken ? \"true\" : \"false\";\n\t\t\t\t\troot.style.setProperty(\"--basalt-hover-x\", `${x}px`);\n\t\t\t\t\troot.style.setProperty(\"--basalt-hover-y\", `${y}px`);\n\t\t\t\t\troot.style.setProperty(\"--basalt-hover-width\", `${width}px`);\n\t\t\t\t\troot.style.setProperty(\"--basalt-hover-height\", `${height}px`);\n\t\t\t\t\tgeometry = next;\n\t\t\t\t}\n\t\t\t\troot.dataset.hoverVisible = \"true\";\n\t\t\t\tprevious = item;\n\t\t\t\tlayoutChanged = false;\n\t\t\t};\n\t\t\tfunction schedule() {\n\t\t\t\tif (!frame) frame = requestAnimationFrame(update);\n\t\t\t}\n\t\t\tconst over = (event: PointerEvent) => {\n\t\t\t\tif (event.pointerType === \"touch\") return;\n\t\t\t\tpointerExited = false;\n\t\t\t\tconst next = row(event.target);\n\t\t\t\tif (next !== hovered) {\n\t\t\t\t\tif (!restoreOnPointerLeave && (!next || !hovered)) sequenceBroken = true;\n\t\t\t\t\thovered = next;\n\t\t\t\t\tschedule();\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst leave = () => {\n\t\t\t\thovered = null;\n\t\t\t\tpointerExited = !restoreOnPointerLeave;\n\t\t\t\tif (!restoreOnPointerLeave) sequenceBroken = true;\n\t\t\t\tschedule();\n\t\t\t};\n\t\t\tconst focus = (event: FocusEvent) => {\n\t\t\t\tfocused = row(event.target);\n\t\t\t\tif (!restoreOnPointerLeave) return;\n\t\t\t\tpointerExited = false;\n\t\t\t\thovered = null;\n\t\t\t\tschedule();\n\t\t\t};\n\t\t\tconst blur = (event: FocusEvent) => {\n\t\t\t\tfocused = row(event.relatedTarget);\n\t\t\t\tif (!restoreOnPointerLeave) return;\n\t\t\t\tschedule();\n\t\t\t};\n\t\t\tconst keyboard = (event: KeyboardEvent) => {\n\t\t\t\tif (\n\t\t\t\t\t!(event.target instanceof Element) ||\n\t\t\t\t\t(!root.contains(event.target) &&\n\t\t\t\t\t\t(!root.id || event.target.getAttribute(\"aria-controls\") !== root.id))\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tif (!restoreOnPointerLeave) return;\n\t\t\t\thovered = null;\n\t\t\t\tpointerExited = false;\n\t\t\t\tschedule();\n\t\t\t};\n\t\t\tconst layout = (event: Event) => {\n\t\t\t\t// Our pseudo-element transition cannot change row geometry.\n\t\t\t\tif (event.target === root && event.type !== \"scroll\") return;\n\t\t\t\tlayoutChanged = true;\n\t\t\t\tschedule();\n\t\t\t};\n\t\t\tconst mutations = new MutationObserver((records) => {\n\t\t\t\tselectionDirty = true;\n\t\t\t\tif (\n\t\t\t\t\trecords.some((record) => record.type === \"childList\" || record.attributeName === \"hidden\")\n\t\t\t\t)\n\t\t\t\t\tlayoutChanged = true;\n\t\t\t\tschedule();\n\t\t\t});\n\t\t\tmutations.observe(root, {\n\t\t\t\tsubtree: true,\n\t\t\t\tchildList: true,\n\t\t\t\tattributes: true,\n\t\t\t\tattributeFilter: [\n\t\t\t\t\t\"data-basalt-hover-item\",\n\t\t\t\t\t\"data-highlighted\",\n\t\t\t\t\t\"data-state\",\n\t\t\t\t\t\"aria-selected\",\n\t\t\t\t\t\"data-selected\",\n\t\t\t\t\t\"data-hover-active\",\n\t\t\t\t\t\"data-hover-selected\",\n\t\t\t\t\t\"disabled\",\n\t\t\t\t\t\"aria-disabled\",\n\t\t\t\t\t\"data-disabled\",\n\t\t\t\t\t\"hidden\",\n\t\t\t\t],\n\t\t\t});\n\t\t\tresize.observe(root);\n\t\t\troot.addEventListener(\"pointerover\", over);\n\t\t\troot.addEventListener(\"pointerleave\", leave);\n\t\t\troot.addEventListener(\"focusin\", focus);\n\t\t\troot.addEventListener(\"focusout\", blur);\n\t\t\troot.ownerDocument.addEventListener(\"keydown\", keyboard);\n\t\t\troot.addEventListener(\"scroll\", layout, true);\n\t\t\troot.addEventListener(\"animationend\", layout);\n\t\t\troot.addEventListener(\"transitionend\", layout);\n\t\t\tschedule();\n\t\t\treturn () => {\n\t\t\t\tcancelAnimationFrame(frame);\n\t\t\t\tresize.disconnect();\n\t\t\t\tmutations.disconnect();\n\t\t\t\troot.removeEventListener(\"pointerover\", over);\n\t\t\t\troot.removeEventListener(\"pointerleave\", leave);\n\t\t\t\troot.removeEventListener(\"focusin\", focus);\n\t\t\t\troot.removeEventListener(\"focusout\", blur);\n\t\t\t\troot.ownerDocument.removeEventListener(\"keydown\", keyboard);\n\t\t\t\troot.removeEventListener(\"scroll\", layout, true);\n\t\t\t\troot.removeEventListener(\"animationend\", layout);\n\t\t\t\troot.removeEventListener(\"transitionend\", layout);\n\t\t\t\tassignRef(ref, null);\n\t\t\t};\n\t\t},\n\t\t[ref, restoreOnPointerLeave],\n\t);\n}\n"],"mappings":";;;;AAGA,IAAMA,IAAM,4BACNC,IACL;AAED,SAAgBC,EACf,GACA,EAAE,2BAAwB,OAA8C,CAAC,GACxE;CACD,OAAOC,GACL,MAA6B;EAE7B,IADAC,EAAUC,GAAKC,CAAI,GACf,CAACA,GAAM;EACX,IAAIC,IAA8B,MAC9BC,IAAgB,IAChBC,IAAiB,IACjBC,IAA8B,MAC9BC,IAA+B,MAC/BC,IAA+B,MAC/BC,IAA6B,MAC7BC,IAAiB,IACjBC,IAAQ,GACRC,IAAW,IACXC,IAAgB,IACdC,KAAY,MACjBC,KACAb,EAAK,SAASa,CAAI,KAClBA,EAAK,QAAQnB,CAAG,KAChBmB,EAAK,QAAQ,oBAAoB,MAAMb,KACvC,CAACa,EAAK,QACL,gGACD,IACGA,IACA,MACEC,KAAO,MACZF,EAASG,aAAkB,UAAUA,EAAO,QAAqBrB,CAAG,IAAI,IAAI,GACvEsB,IAAS,IAAI,qBAAqB;GAEvC,AADA,IAAgB,IAChBC,EAAS;EACV,CAAC,GACKC,UAAe;GAEpB,IADA,IAAQ,GACJV,GAAgB;IAEnB,AADA,IAAS,MACT,IAAW;IACX,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EAAS;EACV,CAAC;EA6BD,OA5BAgB,EAAU,QAAQjC,GAAM;GACvB,SAAS;GACT,WAAW;GACX,YAAY;GACZ,iBAAiB;IAChB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACD;EACD,CAAC,GACDgB,EAAO,QAAQhB,CAAI,GACnBA,EAAK,iBAAiB,eAAe0B,CAAI,GACzC1B,EAAK,iBAAiB,gBAAgB4B,CAAK,GAC3C5B,EAAK,iBAAiB,WAAW6B,CAAK,GACtC7B,EAAK,iBAAiB,YAAY8B,CAAI,GACtC9B,EAAK,cAAc,iBAAiB,WAAW+B,CAAQ,GACvD/B,EAAK,iBAAiB,UAAUgC,GAAQ,EAAI,GAC5ChC,EAAK,iBAAiB,gBAAgBgC,CAAM,GAC5ChC,EAAK,iBAAiB,iBAAiBgC,CAAM,GAC7Cf,EAAS,SACI;GAYZ,AAXA,qBAAqBR,CAAK,GAC1BO,EAAO,WAAW,GAClBiB,EAAU,WAAW,GACrBjC,EAAK,oBAAoB,eAAe0B,CAAI,GAC5C1B,EAAK,oBAAoB,gBAAgB4B,CAAK,GAC9C5B,EAAK,oBAAoB,WAAW6B,CAAK,GACzC7B,EAAK,oBAAoB,YAAY8B,CAAI,GACzC9B,EAAK,cAAc,oBAAoB,WAAW+B,CAAQ,GAC1D/B,EAAK,oBAAoB,UAAUgC,GAAQ,EAAI,GAC/ChC,EAAK,oBAAoB,gBAAgBgC,CAAM,GAC/ChC,EAAK,oBAAoB,iBAAiBgC,CAAM,GAChDlC,EAAUC,GAAK,IAAI;EACpB;CACD,GACA,CAACA,GAAKsB,CAAqB,CAC5B;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocoo/basalt",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -52,36 +52,36 @@
|
|
|
52
52
|
"./styles/standalone": "./dist/styles/standalone.css"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@radix-ui/react-accordion": "1.
|
|
56
|
-
"@radix-ui/react-alert-dialog": "1.1
|
|
57
|
-
"@radix-ui/react-avatar": "1.
|
|
58
|
-
"@radix-ui/react-checkbox": "1.
|
|
59
|
-
"@radix-ui/react-collapsible": "1.1
|
|
60
|
-
"@radix-ui/react-context-menu": "2.
|
|
61
|
-
"@radix-ui/react-dialog": "1.1
|
|
62
|
-
"@radix-ui/react-dropdown-menu": "2.1
|
|
63
|
-
"@radix-ui/react-hover-card": "1.1
|
|
64
|
-
"@radix-ui/react-label": "2.1.
|
|
65
|
-
"@radix-ui/react-menubar": "1.1
|
|
66
|
-
"@radix-ui/react-navigation-menu": "1.
|
|
67
|
-
"@radix-ui/react-popover": "1.1
|
|
68
|
-
"@radix-ui/react-progress": "1.1
|
|
69
|
-
"@radix-ui/react-radio-group": "1.
|
|
70
|
-
"@radix-ui/react-scroll-area": "1.
|
|
71
|
-
"@radix-ui/react-select": "2.
|
|
72
|
-
"@radix-ui/react-separator": "1.
|
|
73
|
-
"@radix-ui/react-slider": "1.
|
|
74
|
-
"@radix-ui/react-slot": "1.
|
|
75
|
-
"@radix-ui/react-switch": "1.
|
|
76
|
-
"@radix-ui/react-tabs": "1.1
|
|
77
|
-
"@radix-ui/react-toggle": "1.1
|
|
78
|
-
"@radix-ui/react-toggle-group": "1.1
|
|
79
|
-
"@radix-ui/react-tooltip": "1.
|
|
55
|
+
"@radix-ui/react-accordion": "1.3.1",
|
|
56
|
+
"@radix-ui/react-alert-dialog": "1.2.1",
|
|
57
|
+
"@radix-ui/react-avatar": "1.3.1",
|
|
58
|
+
"@radix-ui/react-checkbox": "1.4.1",
|
|
59
|
+
"@radix-ui/react-collapsible": "1.2.1",
|
|
60
|
+
"@radix-ui/react-context-menu": "2.4.1",
|
|
61
|
+
"@radix-ui/react-dialog": "1.3.1",
|
|
62
|
+
"@radix-ui/react-dropdown-menu": "2.2.1",
|
|
63
|
+
"@radix-ui/react-hover-card": "1.2.1",
|
|
64
|
+
"@radix-ui/react-label": "2.1.17",
|
|
65
|
+
"@radix-ui/react-menubar": "1.2.1",
|
|
66
|
+
"@radix-ui/react-navigation-menu": "1.4.1",
|
|
67
|
+
"@radix-ui/react-popover": "1.3.1",
|
|
68
|
+
"@radix-ui/react-progress": "1.2.1",
|
|
69
|
+
"@radix-ui/react-radio-group": "1.5.1",
|
|
70
|
+
"@radix-ui/react-scroll-area": "1.4.0",
|
|
71
|
+
"@radix-ui/react-select": "2.4.1",
|
|
72
|
+
"@radix-ui/react-separator": "1.2.0",
|
|
73
|
+
"@radix-ui/react-slider": "1.6.1",
|
|
74
|
+
"@radix-ui/react-slot": "1.5.0",
|
|
75
|
+
"@radix-ui/react-switch": "1.4.1",
|
|
76
|
+
"@radix-ui/react-tabs": "1.2.1",
|
|
77
|
+
"@radix-ui/react-toggle": "1.2.1",
|
|
78
|
+
"@radix-ui/react-toggle-group": "1.2.1",
|
|
79
|
+
"@radix-ui/react-tooltip": "1.4.1",
|
|
80
80
|
"class-variance-authority": "^0.7.1",
|
|
81
81
|
"clsx": "^2.1.1",
|
|
82
82
|
"cmdk": "^1.1.1",
|
|
83
|
-
"entities": "8.
|
|
84
|
-
"marked": "18.
|
|
83
|
+
"entities": "8.1.0",
|
|
84
|
+
"marked": "18.1.1",
|
|
85
85
|
"sonner": "2.0.8",
|
|
86
86
|
"tailwind-merge": "3.7.0"
|
|
87
87
|
},
|