@vertz/ui-primitives 0.2.41 → 0.2.43
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/shared/chunk-06m8prfg.js +52 -0
- package/dist/shared/chunk-0n9jj8xr.js +24 -0
- package/dist/shared/chunk-1ben27xq.js +317 -0
- package/dist/shared/chunk-1j2mj0sa.js +45 -0
- package/dist/shared/chunk-250hj18f.js +243 -0
- package/dist/shared/chunk-2h4m9c71.js +38 -0
- package/dist/shared/chunk-2sbx20hv.js +128 -0
- package/dist/shared/chunk-2ye674gr.js +70 -0
- package/dist/shared/chunk-34d8385y.js +15 -0
- package/dist/shared/chunk-4d7bm8h0.js +113 -0
- package/dist/shared/chunk-4zjgxr7x.js +157 -0
- package/dist/shared/chunk-5c150wvr.js +140 -0
- package/dist/shared/chunk-5gycdypd.js +58 -0
- package/dist/shared/chunk-6mm7fhp8.js +105 -0
- package/dist/shared/chunk-6zmnqvh6.js +109 -0
- package/dist/shared/{chunk-yy3ft5mb.js → chunk-7amn5d71.js} +2 -2
- package/dist/shared/chunk-7pbff2hg.js +118 -0
- package/dist/shared/chunk-7zpjshwz.js +194 -0
- package/dist/shared/chunk-993ff51d.js +155 -0
- package/dist/shared/chunk-9pdt5aw7.js +24 -0
- package/dist/shared/chunk-a71m4xkv.js +106 -0
- package/dist/shared/chunk-aj8m39pk.js +127 -0
- package/dist/shared/chunk-ajawpc05.js +305 -0
- package/dist/shared/chunk-b7mzwqhj.js +125 -0
- package/dist/shared/chunk-bb887de4.js +200 -0
- package/dist/shared/chunk-bfsmbrxc.js +111 -0
- package/dist/shared/chunk-c2f63m5n.js +56 -0
- package/dist/shared/chunk-c5r3s5km.js +263 -0
- package/dist/shared/chunk-caba5bhd.js +427 -0
- package/dist/shared/chunk-crym07yc.js +264 -0
- package/dist/shared/{chunk-5964gmv0.js → chunk-csjtyvam.js} +62 -88
- package/dist/shared/chunk-d6rtejz3.js +128 -0
- package/dist/shared/chunk-dvaf0bmq.js +140 -0
- package/dist/shared/chunk-dwkv9ya6.js +22 -0
- package/dist/shared/chunk-e0ckxrjg.js +41 -0
- package/dist/shared/chunk-ennxcymj.js +225 -0
- package/dist/shared/{chunk-1jd1n0dt.js → chunk-ey38de46.js} +19 -47
- package/dist/shared/chunk-f0v1gs5e.js +52 -0
- package/dist/shared/chunk-f86rsf84.js +231 -0
- package/dist/shared/{chunk-3sahbk4d.js → chunk-fdse46x5.js} +6 -1
- package/dist/shared/chunk-gj4hrssn.js +135 -0
- package/dist/shared/chunk-gyvq4gk9.js +24 -0
- package/dist/shared/chunk-hbnps9sq.js +229 -0
- package/dist/shared/{chunk-fhss32ya.js → chunk-hdmpyeq9.js} +43 -132
- package/dist/shared/chunk-hgnkd4he.js +256 -0
- package/dist/shared/chunk-hpcyffm7.js +185 -0
- package/dist/shared/chunk-hpmvwx0h.js +99 -0
- package/dist/shared/chunk-hz0e504p.js +69 -0
- package/dist/shared/chunk-hzk4wfq9.js +43 -0
- package/dist/shared/chunk-j7znzkpa.js +48 -0
- package/dist/shared/chunk-j9kxgrnn.js +167 -0
- package/dist/shared/chunk-jetwnv0w.js +130 -0
- package/dist/shared/chunk-jjdg26c1.js +155 -0
- package/dist/shared/chunk-k0m4yh86.js +123 -0
- package/dist/shared/chunk-k43q9cjr.js +82 -0
- package/dist/shared/chunk-k9k8tbr5.js +119 -0
- package/dist/shared/chunk-meaj7br1.js +232 -0
- package/dist/shared/chunk-mgj0n08k.js +34 -0
- package/dist/shared/chunk-mjz4rp6c.js +46 -0
- package/dist/shared/chunk-n4rr5gme.js +239 -0
- package/dist/shared/chunk-nk55etpp.js +65 -0
- package/dist/shared/chunk-nkh1ks3k.js +264 -0
- package/dist/shared/chunk-pgvpvbpe.js +26 -0
- package/dist/shared/chunk-pma8gnv7.js +178 -0
- package/dist/shared/chunk-q7xv6xze.js +131 -0
- package/dist/shared/chunk-qey801nq.js +22 -0
- package/dist/shared/chunk-s6b4c3tj.js +58 -0
- package/dist/shared/chunk-sq27a4h0.js +36 -0
- package/dist/shared/chunk-taa5pj15.js +103 -0
- package/dist/shared/chunk-tc5rpvyx.js +127 -0
- package/dist/shared/chunk-tescm0b3.js +192 -0
- package/dist/shared/chunk-tkftdwnq.js +71 -0
- package/dist/shared/chunk-tqhnjcfp.js +116 -0
- package/dist/shared/chunk-vfknb5ht.js +183 -0
- package/dist/shared/chunk-vsc369w3.js +185 -0
- package/dist/shared/chunk-whq9s8v5.js +301 -0
- package/dist/shared/{chunk-hze1f32t.js → chunk-wrqddgaj.js} +1 -1
- package/dist/shared/chunk-yzbmkx4r.js +155 -0
- package/dist/shared/chunk-zaen0ajc.js +347 -0
- package/dist/src/accordion/accordion-composed.js +1 -1
- package/dist/src/accordion/accordion.js +1 -1
- package/dist/src/alert/alert-composed.js +1 -1
- package/dist/src/alert-dialog/alert-dialog-composed.js +1 -1
- package/dist/src/alert-dialog/alert-dialog.js +1 -1
- package/dist/src/avatar/avatar-composed.js +1 -1
- package/dist/src/badge/badge-composed.js +1 -1
- package/dist/src/badge/badge.js +1 -1
- package/dist/src/breadcrumb/breadcrumb-composed.js +1 -1
- package/dist/src/button/button-composed.js +1 -1
- package/dist/src/button/button.js +1 -1
- package/dist/src/calendar/calendar-composed.js +1 -1
- package/dist/src/calendar/calendar.js +1 -1
- package/dist/src/card/card-composed.js +1 -1
- package/dist/src/carousel/carousel-composed.js +1 -1
- package/dist/src/carousel/carousel.js +1 -1
- package/dist/src/checkbox/checkbox-composed.js +1 -1
- package/dist/src/checkbox/checkbox.js +1 -1
- package/dist/src/collapsible/collapsible-composed.js +1 -1
- package/dist/src/collapsible/collapsible.js +1 -1
- package/dist/src/combobox/combobox-composed.js +1 -1
- package/dist/src/combobox/combobox.js +1 -1
- package/dist/src/command/command-composed.js +1 -1
- package/dist/src/command/command.js +1 -1
- package/dist/src/composed/with-styles.js +1 -1
- package/dist/src/context-menu/context-menu-composed.js +1 -1
- package/dist/src/context-menu/context-menu.js +1 -1
- package/dist/src/date-picker/date-picker-composed.js +1 -1
- package/dist/src/date-picker/date-picker.js +1 -1
- package/dist/src/dialog/dialog-composed.js +1 -1
- package/dist/src/dialog/dialog-stack-parts.js +1 -1
- package/dist/src/dialog/dialog.js +1 -1
- package/dist/src/dropdown-menu/dropdown-menu-composed.js +1 -1
- package/dist/src/dropdown-menu/dropdown-menu.js +1 -1
- package/dist/src/empty-state/empty-state-composed.js +1 -1
- package/dist/src/form-group/form-group-composed.js +1 -1
- package/dist/src/hover-card/hover-card-composed.js +1 -1
- package/dist/src/hover-card/hover-card.js +1 -1
- package/dist/src/input/input-composed.js +1 -1
- package/dist/src/label/label-composed.js +1 -1
- package/dist/src/list/list-composed.js +1 -1
- package/dist/src/menu/menu-composed.js +1 -1
- package/dist/src/menu/menu.js +1 -1
- package/dist/src/menubar/menubar-composed.js +1 -1
- package/dist/src/menubar/menubar.js +1 -1
- package/dist/src/navigation-menu/navigation-menu-composed.js +1 -1
- package/dist/src/navigation-menu/navigation-menu.js +1 -1
- package/dist/src/pagination/pagination-composed.js +1 -1
- package/dist/src/popover/popover-composed.js +1 -1
- package/dist/src/popover/popover.js +1 -1
- package/dist/src/progress/progress-composed.js +1 -1
- package/dist/src/progress/progress.js +1 -1
- package/dist/src/radio/radio-composed.js +1 -1
- package/dist/src/radio/radio.js +1 -1
- package/dist/src/resizable-panel/resizable-panel-composed.js +1 -1
- package/dist/src/resizable-panel/resizable-panel.js +1 -1
- package/dist/src/scroll-area/scroll-area-composed.js +1 -1
- package/dist/src/scroll-area/scroll-area.js +1 -1
- package/dist/src/select/select-composed.js +1 -1
- package/dist/src/select/select.js +1 -1
- package/dist/src/separator/separator-composed.js +1 -1
- package/dist/src/sheet/sheet-composed.js +1 -1
- package/dist/src/sheet/sheet.js +1 -1
- package/dist/src/skeleton/skeleton-composed.js +1 -1
- package/dist/src/slider/slider-composed.js +1 -1
- package/dist/src/slider/slider.js +1 -1
- package/dist/src/switch/switch-composed.js +1 -1
- package/dist/src/switch/switch.js +1 -1
- package/dist/src/table/table-composed.js +1 -1
- package/dist/src/tabs/tabs-composed.js +1 -1
- package/dist/src/tabs/tabs.js +1 -1
- package/dist/src/textarea/textarea-composed.js +1 -1
- package/dist/src/toast/toast.js +1 -1
- package/dist/src/toggle/toggle-composed.js +1 -1
- package/dist/src/toggle/toggle.js +1 -1
- package/dist/src/toggle-group/toggle-group-composed.js +1 -1
- package/dist/src/toggle-group/toggle-group.js +1 -1
- package/dist/src/tooltip/tooltip-composed.js +1 -1
- package/dist/src/tooltip/tooltip.js +1 -1
- package/package.json +3 -3
- package/dist/shared/chunk-144kbnmx.js +0 -95
- package/dist/shared/chunk-1ewxfgsa.js +0 -167
- package/dist/shared/chunk-1hm0mbke.js +0 -258
- package/dist/shared/chunk-22rt6ws9.js +0 -69
- package/dist/shared/chunk-2ssqz188.js +0 -162
- package/dist/shared/chunk-33he7ay9.js +0 -218
- package/dist/shared/chunk-3jack97k.js +0 -509
- package/dist/shared/chunk-75pegjs7.js +0 -26
- package/dist/shared/chunk-862x7dja.js +0 -398
- package/dist/shared/chunk-8pk1pn5h.js +0 -215
- package/dist/shared/chunk-8t0nm721.js +0 -152
- package/dist/shared/chunk-94twh4s4.js +0 -28
- package/dist/shared/chunk-9yb26c0w.js +0 -232
- package/dist/shared/chunk-a82r2pnq.js +0 -67
- package/dist/shared/chunk-axpbdpgx.js +0 -177
- package/dist/shared/chunk-b3j6mym6.js +0 -203
- package/dist/shared/chunk-b4zzg457.js +0 -410
- package/dist/shared/chunk-b9qxfcsy.js +0 -60
- package/dist/shared/chunk-bc2qqkhr.js +0 -194
- package/dist/shared/chunk-bv12nkdm.js +0 -149
- package/dist/shared/chunk-bvxc1ww4.js +0 -164
- package/dist/shared/chunk-czv0kqj4.js +0 -107
- package/dist/shared/chunk-d83ag07h.js +0 -189
- package/dist/shared/chunk-de18ashk.js +0 -134
- package/dist/shared/chunk-dvk4h36t.js +0 -140
- package/dist/shared/chunk-dxvnerw2.js +0 -353
- package/dist/shared/chunk-e399pzdq.js +0 -241
- package/dist/shared/chunk-e4qha9as.js +0 -180
- package/dist/shared/chunk-eb2d9v6k.js +0 -68
- package/dist/shared/chunk-ect26sp5.js +0 -353
- package/dist/shared/chunk-ev367pq3.js +0 -102
- package/dist/shared/chunk-fjykbv0v.js +0 -214
- package/dist/shared/chunk-gdddk6nh.js +0 -96
- package/dist/shared/chunk-ghkw5bjq.js +0 -55
- package/dist/shared/chunk-hfjtkytb.js +0 -310
- package/dist/shared/chunk-hpvjfj0j.js +0 -31
- package/dist/shared/chunk-jpyjk616.js +0 -52
- package/dist/shared/chunk-k6d53tne.js +0 -206
- package/dist/shared/chunk-knzg86am.js +0 -168
- package/dist/shared/chunk-ktbf6xrt.js +0 -179
- package/dist/shared/chunk-m8y2p66x.js +0 -252
- package/dist/shared/chunk-metxdt5x.js +0 -28
- package/dist/shared/chunk-mgae1d93.js +0 -157
- package/dist/shared/chunk-mtx2cfbx.js +0 -175
- package/dist/shared/chunk-n436p5cb.js +0 -260
- package/dist/shared/chunk-nj420k31.js +0 -54
- package/dist/shared/chunk-nsmvdxgp.js +0 -213
- package/dist/shared/chunk-pcms04vq.js +0 -162
- package/dist/shared/chunk-pqskzq8t.js +0 -79
- package/dist/shared/chunk-pwr60kyd.js +0 -321
- package/dist/shared/chunk-pzknpa1y.js +0 -327
- package/dist/shared/chunk-q77y3rg4.js +0 -189
- package/dist/shared/chunk-qhnany7w.js +0 -179
- package/dist/shared/chunk-rdr0rtpr.js +0 -131
- package/dist/shared/chunk-rj52ty6r.js +0 -147
- package/dist/shared/chunk-rnqc7735.js +0 -125
- package/dist/shared/chunk-rtk30950.js +0 -202
- package/dist/shared/chunk-s0xgd8vg.js +0 -266
- package/dist/shared/chunk-s415735j.js +0 -357
- package/dist/shared/chunk-s62e7jf4.js +0 -30
- package/dist/shared/chunk-snd8e6r8.js +0 -418
- package/dist/shared/chunk-spng4yb9.js +0 -73
- package/dist/shared/chunk-t887wwjc.js +0 -168
- package/dist/shared/chunk-tn0m98j8.js +0 -42
- package/dist/shared/chunk-v0b5pkcq.js +0 -30
- package/dist/shared/chunk-v5tj7veh.js +0 -284
- package/dist/shared/chunk-vkscwzpr.js +0 -294
- package/dist/shared/chunk-vv187snj.js +0 -112
- package/dist/shared/chunk-xv4wd0kf.js +0 -293
- package/dist/shared/chunk-y1hpsqzy.js +0 -185
- package/dist/shared/chunk-yfzddvxc.js +0 -71
- package/dist/shared/chunk-yzgzx2dh.js +0 -311
- package/dist/shared/chunk-z5j7ztf2.js +0 -467
|
@@ -3,8 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-q7xbcj9q.js";
|
|
4
4
|
|
|
5
5
|
// src/list/list-composed.tsx
|
|
6
|
-
import {
|
|
7
|
-
import { __append, __attr, __child, __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __pushMountFrame } from "@vertz/ui/internals";
|
|
6
|
+
import { jsxDEV as jsxDEV_7x81h0kn } from "@vertz/ui/jsx-dev-runtime";
|
|
8
7
|
import { createContext, ListAnimationContext, onMount, ref, useContext } from "@vertz/ui";
|
|
9
8
|
var ListContext = createContext(undefined, "@vertz/ui-primitives::ListContext");
|
|
10
9
|
function useListContext(subComponent) {
|
|
@@ -14,54 +13,22 @@ function useListContext(subComponent) {
|
|
|
14
13
|
}
|
|
15
14
|
return ctx;
|
|
16
15
|
}
|
|
17
|
-
function ListItem(
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
const __v = ctx.sortable ? "" : undefined;
|
|
26
|
-
if (__v != null && __v !== false)
|
|
27
|
-
__el0.setAttribute("data-sortable-item", __v === true ? "" : __v);
|
|
28
|
-
}
|
|
29
|
-
__enterChildren(__el0);
|
|
30
|
-
__append(__el0, __child(() => __props.children));
|
|
31
|
-
__exitChildren();
|
|
32
|
-
return __el0;
|
|
33
|
-
})();
|
|
34
|
-
__flushMountFrame();
|
|
35
|
-
return __mfResult0;
|
|
36
|
-
} catch (__mfErr) {
|
|
37
|
-
__discardMountFrame(__mfDepth);
|
|
38
|
-
throw __mfErr;
|
|
39
|
-
}
|
|
16
|
+
function ListItem({ children, className, class: classProp }) {
|
|
17
|
+
const ctx = useListContext("Item");
|
|
18
|
+
return jsxDEV_7x81h0kn("li", {
|
|
19
|
+
class: cn(ctx.classes?.item, className ?? classProp),
|
|
20
|
+
"data-sortable-item": ctx.sortable ? "" : undefined,
|
|
21
|
+
children
|
|
22
|
+
}, undefined, false, undefined, this);
|
|
40
23
|
}
|
|
41
|
-
function ListDragHandle(
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const __v = ctx.sortable ? "" : undefined;
|
|
50
|
-
if (__v != null && __v !== false)
|
|
51
|
-
__el0.setAttribute("data-sortable", __v === true ? "" : __v);
|
|
52
|
-
}
|
|
53
|
-
__attr(__el0, "class", () => cn(ctx.classes?.dragHandle, __props.className ?? __props.class));
|
|
54
|
-
__enterChildren(__el0);
|
|
55
|
-
__append(__el0, __child(() => __props.children));
|
|
56
|
-
__exitChildren();
|
|
57
|
-
return __el0;
|
|
58
|
-
})();
|
|
59
|
-
__flushMountFrame();
|
|
60
|
-
return __mfResult0;
|
|
61
|
-
} catch (__mfErr) {
|
|
62
|
-
__discardMountFrame(__mfDepth);
|
|
63
|
-
throw __mfErr;
|
|
64
|
-
}
|
|
24
|
+
function ListDragHandle({ children, className, class: classProp }) {
|
|
25
|
+
const ctx = useListContext("DragHandle");
|
|
26
|
+
return jsxDEV_7x81h0kn("div", {
|
|
27
|
+
"data-list-drag-handle": "",
|
|
28
|
+
"data-sortable": ctx.sortable ? "" : undefined,
|
|
29
|
+
class: cn(ctx.classes?.dragHandle, className ?? classProp),
|
|
30
|
+
children
|
|
31
|
+
}, undefined, false, undefined, this);
|
|
65
32
|
}
|
|
66
33
|
var DEFAULT_DURATION = 200;
|
|
67
34
|
var DEFAULT_EASING = "ease-out";
|
|
@@ -155,8 +122,17 @@ function createAnimationHooks(animate) {
|
|
|
155
122
|
el.style.paddingTop = "0";
|
|
156
123
|
el.style.paddingBottom = "0";
|
|
157
124
|
el.style.opacity = "0";
|
|
158
|
-
|
|
159
|
-
|
|
125
|
+
let exitDone = false;
|
|
126
|
+
let safetyTimer;
|
|
127
|
+
const safeDone = () => {
|
|
128
|
+
if (exitDone)
|
|
129
|
+
return;
|
|
130
|
+
exitDone = true;
|
|
131
|
+
clearTimeout(safetyTimer);
|
|
132
|
+
done();
|
|
133
|
+
};
|
|
134
|
+
el.addEventListener("transitionend", safeDone, { once: true });
|
|
135
|
+
safetyTimer = setTimeout(safeDone, duration + 50);
|
|
160
136
|
} else {
|
|
161
137
|
done();
|
|
162
138
|
}
|
|
@@ -362,44 +338,42 @@ function setupDragSort(ulEl, getSortable, getOnReorder, getAnimate) {
|
|
|
362
338
|
document.addEventListener("pointerup", onUp);
|
|
363
339
|
});
|
|
364
340
|
}
|
|
365
|
-
function ComposedListRoot(
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
const __el0 = __element("ul");
|
|
390
|
-
ulRef.current = __el0;
|
|
391
|
-
__attr(__el0, "class", () => cn(__props.classes?.root, __props.className ?? __props.class));
|
|
392
|
-
__enterChildren(__el0);
|
|
393
|
-
__append(__el0, __child(() => __props.children));
|
|
394
|
-
__exitChildren();
|
|
395
|
-
return __el0;
|
|
396
|
-
})() }) });
|
|
397
|
-
__flushMountFrame();
|
|
398
|
-
return __mfResult0;
|
|
399
|
-
} catch (__mfErr) {
|
|
400
|
-
__discardMountFrame(__mfDepth);
|
|
401
|
-
throw __mfErr;
|
|
341
|
+
function ComposedListRoot({
|
|
342
|
+
children,
|
|
343
|
+
classes,
|
|
344
|
+
className,
|
|
345
|
+
class: classProp,
|
|
346
|
+
animate = false,
|
|
347
|
+
sortable = false,
|
|
348
|
+
onReorder
|
|
349
|
+
}) {
|
|
350
|
+
const ctx = {
|
|
351
|
+
classes,
|
|
352
|
+
animate,
|
|
353
|
+
sortable,
|
|
354
|
+
onReorder
|
|
355
|
+
};
|
|
356
|
+
const animHooks = animate ? createAnimationHooks(animate) : undefined;
|
|
357
|
+
const ulRef = ref();
|
|
358
|
+
if (sortable) {
|
|
359
|
+
onMount(() => {
|
|
360
|
+
const ul = ulRef.current;
|
|
361
|
+
if (ul) {
|
|
362
|
+
setupDragSort(ul, () => sortable, () => onReorder, () => animate);
|
|
363
|
+
}
|
|
364
|
+
});
|
|
402
365
|
}
|
|
366
|
+
return jsxDEV_7x81h0kn(ListContext.Provider, {
|
|
367
|
+
value: ctx,
|
|
368
|
+
children: jsxDEV_7x81h0kn(ListAnimationContext.Provider, {
|
|
369
|
+
value: animHooks,
|
|
370
|
+
children: jsxDEV_7x81h0kn("ul", {
|
|
371
|
+
ref: ulRef,
|
|
372
|
+
class: cn(classes?.root, className ?? classProp),
|
|
373
|
+
children
|
|
374
|
+
}, undefined, false, undefined, this)
|
|
375
|
+
}, undefined, false, undefined, this)
|
|
376
|
+
}, undefined, false, undefined, this);
|
|
403
377
|
}
|
|
404
378
|
function reorder(arr, from, to) {
|
|
405
379
|
const result = [...arr];
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-q7xbcj9q.js";
|
|
4
|
+
import {
|
|
5
|
+
uniqueId
|
|
6
|
+
} from "./chunk-8y1jf6xr.js";
|
|
7
|
+
import {
|
|
8
|
+
Keys,
|
|
9
|
+
isKey
|
|
10
|
+
} from "./chunk-7867pr13.js";
|
|
11
|
+
|
|
12
|
+
// src/toggle-group/toggle-group-composed.tsx
|
|
13
|
+
import { jsxDEV as jsxDEV_7x81h0kn } from "@vertz/ui/jsx-dev-runtime";
|
|
14
|
+
import { createContext, useContext } from "@vertz/ui";
|
|
15
|
+
var ToggleGroupContext = createContext(undefined, "@vertz/ui-primitives::ToggleGroupContext");
|
|
16
|
+
function useToggleGroupContext(componentName) {
|
|
17
|
+
const ctx = useContext(ToggleGroupContext);
|
|
18
|
+
if (!ctx) {
|
|
19
|
+
throw new Error(`<ToggleGroup.${componentName}> must be used inside <ToggleGroup>. ` + "Ensure it is a direct or nested child of the ToggleGroup root component.");
|
|
20
|
+
}
|
|
21
|
+
return ctx;
|
|
22
|
+
}
|
|
23
|
+
function ToggleGroupItem({ value, children }) {
|
|
24
|
+
const ctx = useToggleGroupContext("Item");
|
|
25
|
+
const isOn = ctx.selectedValues.includes(value);
|
|
26
|
+
const isFirst = ctx.claimFirstItem();
|
|
27
|
+
return jsxDEV_7x81h0kn("button", {
|
|
28
|
+
type: "button",
|
|
29
|
+
"data-togglegroup-item": "",
|
|
30
|
+
"data-value": value,
|
|
31
|
+
"aria-pressed": isOn ? "true" : "false",
|
|
32
|
+
"data-state": isOn ? "on" : "off",
|
|
33
|
+
disabled: ctx.disabled,
|
|
34
|
+
"aria-disabled": ctx.disabled ? "true" : undefined,
|
|
35
|
+
tabindex: isFirst ? "0" : "-1",
|
|
36
|
+
class: cn(ctx.classes?.item),
|
|
37
|
+
onClick: () => ctx.toggle(value),
|
|
38
|
+
children
|
|
39
|
+
}, undefined, false, undefined, this);
|
|
40
|
+
}
|
|
41
|
+
function ComposedToggleGroupRoot({
|
|
42
|
+
children,
|
|
43
|
+
classes,
|
|
44
|
+
type = "single",
|
|
45
|
+
defaultValue = [],
|
|
46
|
+
orientation = "horizontal",
|
|
47
|
+
disabled = false,
|
|
48
|
+
onValueChange
|
|
49
|
+
}) {
|
|
50
|
+
let selectedValues = [...defaultValue];
|
|
51
|
+
function toggle(itemValue) {
|
|
52
|
+
if (disabled)
|
|
53
|
+
return;
|
|
54
|
+
const current = [...selectedValues];
|
|
55
|
+
const idx = current.indexOf(itemValue);
|
|
56
|
+
if (type === "single") {
|
|
57
|
+
if (idx >= 0) {
|
|
58
|
+
current.length = 0;
|
|
59
|
+
} else {
|
|
60
|
+
current.length = 0;
|
|
61
|
+
current.push(itemValue);
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
if (idx >= 0) {
|
|
65
|
+
current.splice(idx, 1);
|
|
66
|
+
} else {
|
|
67
|
+
current.push(itemValue);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
selectedValues = current;
|
|
71
|
+
onValueChange?.(current);
|
|
72
|
+
}
|
|
73
|
+
const _state = { firstItemClaimed: false };
|
|
74
|
+
const ctx = {
|
|
75
|
+
selectedValues,
|
|
76
|
+
classes,
|
|
77
|
+
disabled,
|
|
78
|
+
toggle,
|
|
79
|
+
claimFirstItem: () => {
|
|
80
|
+
if (_state.firstItemClaimed)
|
|
81
|
+
return false;
|
|
82
|
+
_state.firstItemClaimed = true;
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return jsxDEV_7x81h0kn(ToggleGroupContext.Provider, {
|
|
87
|
+
value: ctx,
|
|
88
|
+
children: jsxDEV_7x81h0kn("div", {
|
|
89
|
+
role: "group",
|
|
90
|
+
id: uniqueId("toggle-group"),
|
|
91
|
+
"data-orientation": orientation,
|
|
92
|
+
"data-togglegroup-root": "",
|
|
93
|
+
class: cn(classes?.root),
|
|
94
|
+
onKeydown: (event) => {
|
|
95
|
+
if (!isKey(event, Keys.ArrowLeft, Keys.ArrowRight, Keys.ArrowUp, Keys.ArrowDown, Keys.Home, Keys.End)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
const root = event.currentTarget;
|
|
100
|
+
const items = [...root.querySelectorAll("[data-togglegroup-item]")];
|
|
101
|
+
const currentIdx = items.indexOf(document.activeElement);
|
|
102
|
+
if (currentIdx < 0)
|
|
103
|
+
return;
|
|
104
|
+
const len = items.length;
|
|
105
|
+
let nextIdx;
|
|
106
|
+
if (isKey(event, Keys.ArrowRight, Keys.ArrowDown)) {
|
|
107
|
+
nextIdx = (currentIdx + 1) % len;
|
|
108
|
+
} else if (isKey(event, Keys.ArrowLeft, Keys.ArrowUp)) {
|
|
109
|
+
nextIdx = (currentIdx - 1 + len) % len;
|
|
110
|
+
} else if (isKey(event, Keys.Home)) {
|
|
111
|
+
nextIdx = 0;
|
|
112
|
+
} else if (isKey(event, Keys.End)) {
|
|
113
|
+
nextIdx = len - 1;
|
|
114
|
+
} else {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
items.forEach((el, j) => el.setAttribute("tabindex", j === nextIdx ? "0" : "-1"));
|
|
118
|
+
items[nextIdx]?.focus();
|
|
119
|
+
},
|
|
120
|
+
children
|
|
121
|
+
}, undefined, false, undefined, this)
|
|
122
|
+
}, undefined, false, undefined, this);
|
|
123
|
+
}
|
|
124
|
+
var ComposedToggleGroup = Object.assign(ComposedToggleGroupRoot, {
|
|
125
|
+
Item: ToggleGroupItem
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export { ComposedToggleGroup };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-q7xbcj9q.js";
|
|
4
|
+
import {
|
|
5
|
+
uniqueId
|
|
6
|
+
} from "./chunk-8y1jf6xr.js";
|
|
7
|
+
import {
|
|
8
|
+
Keys,
|
|
9
|
+
isKey
|
|
10
|
+
} from "./chunk-7867pr13.js";
|
|
11
|
+
import {
|
|
12
|
+
setValueRange
|
|
13
|
+
} from "./chunk-vevfhpc9.js";
|
|
14
|
+
|
|
15
|
+
// src/slider/slider-composed.tsx
|
|
16
|
+
import { jsxDEV as jsxDEV_7x81h0kn } from "@vertz/ui/jsx-dev-runtime";
|
|
17
|
+
import { ref } from "@vertz/ui";
|
|
18
|
+
function ComposedSliderRoot({
|
|
19
|
+
classes,
|
|
20
|
+
defaultValue = 0,
|
|
21
|
+
min = 0,
|
|
22
|
+
max = 100,
|
|
23
|
+
step = 1,
|
|
24
|
+
disabled = false,
|
|
25
|
+
onValueChange
|
|
26
|
+
}) {
|
|
27
|
+
let currentValue = defaultValue;
|
|
28
|
+
const thumbRef = ref();
|
|
29
|
+
const fillRef = ref();
|
|
30
|
+
const trackRef = ref();
|
|
31
|
+
function clamp(val) {
|
|
32
|
+
return Math.min(max, Math.max(min, val));
|
|
33
|
+
}
|
|
34
|
+
function updatePosition(pct) {
|
|
35
|
+
const thumb = thumbRef.current;
|
|
36
|
+
const fill = fillRef.current;
|
|
37
|
+
if (thumb)
|
|
38
|
+
thumb.style.left = `${pct}%`;
|
|
39
|
+
if (fill)
|
|
40
|
+
fill.style.width = `${pct}%`;
|
|
41
|
+
}
|
|
42
|
+
function setValue(val) {
|
|
43
|
+
if (disabled)
|
|
44
|
+
return;
|
|
45
|
+
const clamped = clamp(val);
|
|
46
|
+
currentValue = clamped;
|
|
47
|
+
const thumb = thumbRef.current;
|
|
48
|
+
if (thumb)
|
|
49
|
+
setValueRange(thumb, clamped, min, max);
|
|
50
|
+
const pct = (clamped - min) / (max - min) * 100;
|
|
51
|
+
updatePosition(pct);
|
|
52
|
+
onValueChange?.(clamped);
|
|
53
|
+
}
|
|
54
|
+
function valueFromPointer(event) {
|
|
55
|
+
const track = trackRef.current;
|
|
56
|
+
if (!track)
|
|
57
|
+
return min;
|
|
58
|
+
const rect = track.getBoundingClientRect();
|
|
59
|
+
const pct = Math.max(0, Math.min(1, (event.clientX - rect.left) / rect.width));
|
|
60
|
+
const raw = min + pct * (max - min);
|
|
61
|
+
return Math.round(raw / step) * step;
|
|
62
|
+
}
|
|
63
|
+
const initialPct = (defaultValue - min) / (max - min) * 100;
|
|
64
|
+
return jsxDEV_7x81h0kn("div", {
|
|
65
|
+
id: uniqueId("slider"),
|
|
66
|
+
"data-state": disabled ? "disabled" : "active",
|
|
67
|
+
class: cn(classes?.root),
|
|
68
|
+
onPointerdown: (event) => {
|
|
69
|
+
if (disabled)
|
|
70
|
+
return;
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
setValue(valueFromPointer(event));
|
|
73
|
+
thumbRef.current?.focus();
|
|
74
|
+
function onMove(e) {
|
|
75
|
+
setValue(valueFromPointer(e));
|
|
76
|
+
}
|
|
77
|
+
function onUp() {
|
|
78
|
+
document.removeEventListener("pointermove", onMove);
|
|
79
|
+
document.removeEventListener("pointerup", onUp);
|
|
80
|
+
}
|
|
81
|
+
document.addEventListener("pointermove", onMove);
|
|
82
|
+
document.addEventListener("pointerup", onUp);
|
|
83
|
+
},
|
|
84
|
+
children: jsxDEV_7x81h0kn("div", {
|
|
85
|
+
ref: trackRef,
|
|
86
|
+
"data-part": "track",
|
|
87
|
+
style: { position: "relative" },
|
|
88
|
+
class: cn(classes?.track),
|
|
89
|
+
children: [
|
|
90
|
+
jsxDEV_7x81h0kn("div", {
|
|
91
|
+
ref: fillRef,
|
|
92
|
+
"data-part": "fill",
|
|
93
|
+
style: {
|
|
94
|
+
position: "absolute",
|
|
95
|
+
height: "100%",
|
|
96
|
+
borderRadius: "inherit",
|
|
97
|
+
width: `${initialPct}%`
|
|
98
|
+
},
|
|
99
|
+
class: cn(classes?.range)
|
|
100
|
+
}, undefined, false, undefined, this),
|
|
101
|
+
jsxDEV_7x81h0kn("div", {
|
|
102
|
+
ref: thumbRef,
|
|
103
|
+
role: "slider",
|
|
104
|
+
tabindex: disabled ? "-1" : "0",
|
|
105
|
+
"data-part": "thumb",
|
|
106
|
+
"aria-valuenow": String(defaultValue),
|
|
107
|
+
"aria-valuemin": String(min),
|
|
108
|
+
"aria-valuemax": String(max),
|
|
109
|
+
"aria-disabled": disabled ? "true" : undefined,
|
|
110
|
+
style: {
|
|
111
|
+
position: "absolute",
|
|
112
|
+
transform: "translate(-50%, -50%)",
|
|
113
|
+
left: `${initialPct}%`
|
|
114
|
+
},
|
|
115
|
+
class: cn(classes?.thumb),
|
|
116
|
+
onKeydown: (event) => {
|
|
117
|
+
if (disabled)
|
|
118
|
+
return;
|
|
119
|
+
if (isKey(event, Keys.ArrowRight, Keys.ArrowUp)) {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
setValue(currentValue + step);
|
|
122
|
+
} else if (isKey(event, Keys.ArrowLeft, Keys.ArrowDown)) {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
setValue(currentValue - step);
|
|
125
|
+
} else if (isKey(event, Keys.Home)) {
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
setValue(min);
|
|
128
|
+
} else if (isKey(event, Keys.End)) {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
setValue(max);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}, undefined, false, undefined, this)
|
|
134
|
+
]
|
|
135
|
+
}, undefined, true, undefined, this)
|
|
136
|
+
}, undefined, false, undefined, this);
|
|
137
|
+
}
|
|
138
|
+
var ComposedSlider = ComposedSliderRoot;
|
|
139
|
+
|
|
140
|
+
export { ComposedSlider };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-q7xbcj9q.js";
|
|
4
|
+
|
|
5
|
+
// src/label/label-composed.tsx
|
|
6
|
+
import { jsxDEV as jsxDEV_7x81h0kn } from "@vertz/ui/jsx-dev-runtime";
|
|
7
|
+
function ComposedLabelRoot({
|
|
8
|
+
classes,
|
|
9
|
+
className,
|
|
10
|
+
class: classProp,
|
|
11
|
+
for: htmlFor,
|
|
12
|
+
children
|
|
13
|
+
}) {
|
|
14
|
+
return jsxDEV_7x81h0kn("label", {
|
|
15
|
+
class: cn(classes?.base, className ?? classProp),
|
|
16
|
+
for: htmlFor,
|
|
17
|
+
children
|
|
18
|
+
}, undefined, false, undefined, this);
|
|
19
|
+
}
|
|
20
|
+
var ComposedLabel = ComposedLabelRoot;
|
|
21
|
+
|
|
22
|
+
export { ComposedLabel };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-q7xbcj9q.js";
|
|
4
|
+
import {
|
|
5
|
+
uniqueId
|
|
6
|
+
} from "./chunk-8y1jf6xr.js";
|
|
7
|
+
|
|
8
|
+
// src/progress/progress-composed.tsx
|
|
9
|
+
import { jsxDEV as jsxDEV_7x81h0kn } from "@vertz/ui/jsx-dev-runtime";
|
|
10
|
+
function dataStateFor(pct) {
|
|
11
|
+
if (pct >= 100)
|
|
12
|
+
return "complete";
|
|
13
|
+
if (pct > 0)
|
|
14
|
+
return "loading";
|
|
15
|
+
return "idle";
|
|
16
|
+
}
|
|
17
|
+
function ComposedProgressRoot({
|
|
18
|
+
classes,
|
|
19
|
+
defaultValue = 0,
|
|
20
|
+
min = 0,
|
|
21
|
+
max = 100
|
|
22
|
+
}) {
|
|
23
|
+
const pct = (defaultValue - min) / (max - min) * 100;
|
|
24
|
+
return jsxDEV_7x81h0kn("div", {
|
|
25
|
+
role: "progressbar",
|
|
26
|
+
id: uniqueId("progress"),
|
|
27
|
+
"aria-valuenow": String(defaultValue),
|
|
28
|
+
"aria-valuemin": String(min),
|
|
29
|
+
"aria-valuemax": String(max),
|
|
30
|
+
"data-state": dataStateFor(pct),
|
|
31
|
+
class: cn(classes?.root),
|
|
32
|
+
children: jsxDEV_7x81h0kn("div", {
|
|
33
|
+
"data-part": "indicator",
|
|
34
|
+
style: { width: `${pct}%` },
|
|
35
|
+
class: cn(classes?.indicator)
|
|
36
|
+
}, undefined, false, undefined, this)
|
|
37
|
+
}, undefined, false, undefined, this);
|
|
38
|
+
}
|
|
39
|
+
var ComposedProgress = ComposedProgressRoot;
|
|
40
|
+
|
|
41
|
+
export { ComposedProgress };
|