@stevederico/skateboard-ui 3.12.0 → 4.1.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/CHANGELOG.md +25 -0
- package/README.md +37 -31
- package/dist/components/core/Command.js +33 -7
- package/dist/shadcn/ui/accordion.d.ts +1 -6
- package/dist/shadcn/ui/accordion.js +3 -17
- package/dist/shadcn/ui/alert-dialog.d.ts +1 -18
- package/dist/shadcn/ui/alert-dialog.js +3 -43
- package/dist/shadcn/ui/alert.d.ts +1 -13
- package/dist/shadcn/ui/alert.js +3 -28
- package/dist/shadcn/ui/aspect-ratio.d.ts +1 -4
- package/dist/shadcn/ui/aspect-ratio.js +3 -8
- package/dist/shadcn/ui/avatar.d.ts +1 -11
- package/dist/shadcn/ui/avatar.js +3 -24
- package/dist/shadcn/ui/badge.d.ts +1 -14
- package/dist/shadcn/ui/badge.js +3 -33
- package/dist/shadcn/ui/breadcrumb.d.ts +1 -10
- package/dist/shadcn/ui/breadcrumb.js +3 -37
- package/dist/shadcn/ui/button-group.d.ts +1 -13
- package/dist/shadcn/ui/button-group.js +3 -36
- package/dist/shadcn/ui/button.d.ts +1 -34
- package/dist/shadcn/ui/button.js +3 -53
- package/dist/shadcn/ui/calendar.d.ts +1 -13
- package/dist/shadcn/ui/calendar.js +3 -75
- package/dist/shadcn/ui/card.d.ts +1 -11
- package/dist/shadcn/ui/card.js +3 -25
- package/dist/shadcn/ui/checkbox.d.ts +1 -3
- package/dist/shadcn/ui/checkbox.js +3 -9
- package/dist/shadcn/ui/collapsible.d.ts +1 -5
- package/dist/shadcn/ui/collapsible.js +3 -13
- package/dist/shadcn/ui/command.d.ts +1 -19
- package/dist/shadcn/ui/command.js +3 -35
- package/dist/shadcn/ui/context-menu.d.ts +1 -29
- package/dist/shadcn/ui/context-menu.js +3 -52
- package/dist/shadcn/ui/dialog.d.ts +1 -17
- package/dist/shadcn/ui/dialog.js +3 -38
- package/dist/shadcn/ui/drawer.d.ts +1 -13
- package/dist/shadcn/ui/drawer.js +3 -196
- package/dist/shadcn/ui/dropdown-menu.d.ts +1 -29
- package/dist/shadcn/ui/dropdown-menu.js +3 -52
- package/dist/shadcn/ui/empty.d.ts +1 -14
- package/dist/shadcn/ui/empty.js +3 -33
- package/dist/shadcn/ui/field.d.ts +1 -28
- package/dist/shadcn/ui/field.js +3 -68
- package/dist/shadcn/ui/hover-card.d.ts +1 -5
- package/dist/shadcn/ui/hover-card.js +3 -14
- package/dist/shadcn/ui/input-group.d.ts +1 -28
- package/dist/shadcn/ui/input-group.js +3 -58
- package/dist/shadcn/ui/input.d.ts +1 -3
- package/dist/shadcn/ui/input.js +3 -8
- package/dist/shadcn/ui/item.d.ts +1 -34
- package/dist/shadcn/ui/item.js +3 -79
- package/dist/shadcn/ui/kbd.d.ts +1 -3
- package/dist/shadcn/ui/kbd.js +3 -9
- package/dist/shadcn/ui/label.d.ts +1 -3
- package/dist/shadcn/ui/label.js +3 -8
- package/dist/shadcn/ui/menubar.d.ts +1 -29
- package/dist/shadcn/ui/menubar.js +3 -57
- package/dist/shadcn/ui/navigation-menu.d.ts +1 -13
- package/dist/shadcn/ui/navigation-menu.js +3 -31
- package/dist/shadcn/ui/pagination.d.ts +1 -17
- package/dist/shadcn/ui/pagination.js +3 -27
- package/dist/shadcn/ui/popover.d.ts +1 -9
- package/dist/shadcn/ui/popover.js +3 -24
- package/dist/shadcn/ui/progress.d.ts +1 -7
- package/dist/shadcn/ui/progress.js +3 -20
- package/dist/shadcn/ui/radio-group.d.ts +1 -5
- package/dist/shadcn/ui/radio-group.js +3 -12
- package/dist/shadcn/ui/scroll-area.d.ts +1 -5
- package/dist/shadcn/ui/scroll-area.js +3 -12
- package/dist/shadcn/ui/select.d.ts +1 -15
- package/dist/shadcn/ui/select.js +3 -35
- package/dist/shadcn/ui/separator.d.ts +1 -3
- package/dist/shadcn/ui/separator.js +3 -8
- package/dist/shadcn/ui/sheet.d.ts +1 -14
- package/dist/shadcn/ui/sheet.js +3 -38
- package/dist/shadcn/ui/sidebar.d.ts +1 -70
- package/dist/shadcn/ui/sidebar.js +3 -256
- package/dist/shadcn/ui/skeleton.d.ts +1 -2
- package/dist/shadcn/ui/skeleton.js +3 -6
- package/dist/shadcn/ui/slider.d.ts +1 -3
- package/dist/shadcn/ui/slider.js +3 -12
- package/dist/shadcn/ui/spinner.d.ts +1 -2
- package/dist/shadcn/ui/spinner.js +3 -7
- package/dist/shadcn/ui/switch.d.ts +1 -5
- package/dist/shadcn/ui/switch.js +3 -8
- package/dist/shadcn/ui/table.d.ts +1 -10
- package/dist/shadcn/ui/table.js +3 -29
- package/dist/shadcn/ui/tabs.d.ts +1 -13
- package/dist/shadcn/ui/tabs.js +3 -29
- package/dist/shadcn/ui/textarea.d.ts +1 -3
- package/dist/shadcn/ui/textarea.js +3 -7
- package/dist/shadcn/ui/toggle-group.d.ts +1 -11
- package/dist/shadcn/ui/toggle-group.js +3 -25
- package/dist/shadcn/ui/toggle.d.ts +1 -15
- package/dist/shadcn/ui/toggle.js +3 -26
- package/dist/shadcn/ui/tooltip.d.ts +1 -6
- package/dist/shadcn/ui/tooltip.js +3 -17
- package/dist/ui/accordion.d.ts +21 -0
- package/dist/ui/accordion.js +67 -0
- package/dist/ui/alert-dialog.d.ts +32 -0
- package/dist/ui/alert-dialog.js +102 -0
- package/dist/ui/alert.d.ts +13 -0
- package/dist/ui/alert.js +28 -0
- package/dist/ui/aspect-ratio.d.ts +5 -0
- package/dist/ui/aspect-ratio.js +9 -0
- package/dist/ui/avatar.d.ts +14 -0
- package/dist/ui/avatar.js +49 -0
- package/dist/ui/badge.d.ts +22 -0
- package/dist/ui/badge.js +26 -0
- package/dist/ui/breadcrumb.d.ts +13 -0
- package/dist/ui/breadcrumb.js +29 -0
- package/dist/ui/button-group.d.ts +21 -0
- package/dist/ui/button-group.js +29 -0
- package/dist/ui/button.d.ts +38 -0
- package/dist/ui/button.js +49 -0
- package/dist/ui/calendar.d.ts +13 -0
- package/dist/ui/calendar.js +75 -0
- package/dist/ui/card.d.ts +11 -0
- package/dist/ui/card.js +25 -0
- package/dist/ui/checkbox.d.ts +17 -0
- package/dist/ui/checkbox.js +25 -0
- package/dist/ui/collapsible.d.ts +11 -0
- package/dist/ui/collapsible.js +40 -0
- package/dist/ui/command.d.ts +19 -0
- package/dist/ui/command.js +35 -0
- package/dist/ui/context-menu.d.ts +53 -0
- package/dist/ui/context-menu.js +372 -0
- package/dist/ui/dialog.d.ts +40 -0
- package/dist/ui/dialog.js +109 -0
- package/dist/ui/drawer.d.ts +36 -0
- package/dist/ui/drawer.js +243 -0
- package/dist/ui/dropdown-menu.d.ts +61 -0
- package/dist/ui/dropdown-menu.js +347 -0
- package/dist/ui/empty.d.ts +14 -0
- package/dist/ui/empty.js +33 -0
- package/dist/ui/field.d.ts +28 -0
- package/dist/ui/field.js +68 -0
- package/dist/ui/hover-card.d.ts +32 -0
- package/dist/ui/hover-card.js +119 -0
- package/dist/ui/input-group.d.ts +28 -0
- package/dist/ui/input-group.js +58 -0
- package/dist/ui/input.d.ts +3 -0
- package/dist/ui/input.js +7 -0
- package/dist/ui/item.d.ts +41 -0
- package/dist/ui/item.js +69 -0
- package/dist/ui/kbd.d.ts +4 -0
- package/dist/ui/kbd.js +10 -0
- package/dist/ui/label.d.ts +3 -0
- package/dist/ui/label.js +8 -0
- package/dist/ui/menubar.d.ts +59 -0
- package/dist/ui/menubar.js +397 -0
- package/dist/ui/navigation-menu.d.ts +24 -0
- package/dist/ui/navigation-menu.js +203 -0
- package/dist/ui/pagination.d.ts +17 -0
- package/dist/ui/pagination.js +36 -0
- package/dist/ui/popover.d.ts +25 -0
- package/dist/ui/popover.js +126 -0
- package/dist/ui/portal.d.ts +7 -0
- package/dist/ui/portal.js +12 -0
- package/dist/ui/progress.d.ts +15 -0
- package/dist/ui/progress.js +36 -0
- package/dist/ui/radio-group.d.ts +17 -0
- package/dist/ui/radio-group.js +66 -0
- package/dist/ui/scroll-area.d.ts +9 -0
- package/dist/ui/scroll-area.js +72 -0
- package/dist/ui/select.d.ts +37 -0
- package/dist/ui/select.js +226 -0
- package/dist/ui/separator.d.ts +14 -0
- package/dist/ui/separator.js +13 -0
- package/dist/ui/sheet.d.ts +31 -0
- package/dist/ui/sheet.js +121 -0
- package/dist/ui/sidebar.d.ts +86 -0
- package/dist/ui/sidebar.js +211 -0
- package/dist/ui/skeleton.d.ts +3 -0
- package/dist/ui/skeleton.js +7 -0
- package/dist/ui/slider.d.ts +18 -0
- package/dist/ui/slider.js +94 -0
- package/dist/ui/slot.d.ts +27 -0
- package/dist/ui/slot.js +62 -0
- package/dist/ui/spinner.d.ts +3 -0
- package/dist/ui/spinner.js +8 -0
- package/dist/ui/switch.d.ts +17 -0
- package/dist/ui/switch.js +23 -0
- package/dist/ui/table.d.ts +10 -0
- package/dist/ui/table.js +29 -0
- package/dist/ui/tabs.d.ts +29 -0
- package/dist/ui/tabs.js +96 -0
- package/dist/ui/textarea.d.ts +3 -0
- package/dist/ui/textarea.js +7 -0
- package/dist/ui/toggle-group.d.ts +23 -0
- package/dist/ui/toggle-group.js +52 -0
- package/dist/ui/toggle.d.ts +25 -0
- package/dist/ui/toggle.js +41 -0
- package/dist/ui/tooltip.d.ts +25 -0
- package/dist/ui/tooltip.js +90 -0
- package/dist/ui/use-controllable-state.d.ts +10 -0
- package/dist/ui/use-controllable-state.js +17 -0
- package/dist/ui/use-dismiss.d.ts +10 -0
- package/dist/ui/use-dismiss.js +51 -0
- package/dist/ui/use-floating.d.ts +42 -0
- package/dist/ui/use-floating.js +136 -0
- package/dist/ui/use-presence.d.ts +8 -0
- package/dist/ui/use-presence.js +48 -0
- package/dist/ui/use-typeahead.d.ts +19 -0
- package/dist/ui/use-typeahead.js +64 -0
- package/package.json +6 -1
- package/dist/shadcn/lib/base-ui/LICENSE +0 -21
- package/dist/shadcn/lib/base-ui/_chunk-000kmre8.js +0 -150
- package/dist/shadcn/lib/base-ui/_chunk-1vw45v38.js +0 -64
- package/dist/shadcn/lib/base-ui/_chunk-23rx7haq.js +0 -81
- package/dist/shadcn/lib/base-ui/_chunk-242gh8ph.js +0 -230
- package/dist/shadcn/lib/base-ui/_chunk-26cc610z.js +0 -6
- package/dist/shadcn/lib/base-ui/_chunk-2z044bba.js +0 -5890
- package/dist/shadcn/lib/base-ui/_chunk-3cpd1vjz.js +0 -13
- package/dist/shadcn/lib/base-ui/_chunk-3enq1vat.js +0 -82
- package/dist/shadcn/lib/base-ui/_chunk-3xpke33f.js +0 -23
- package/dist/shadcn/lib/base-ui/_chunk-451nqgsa.js +0 -6
- package/dist/shadcn/lib/base-ui/_chunk-4maf6pas.js +0 -11
- package/dist/shadcn/lib/base-ui/_chunk-4zhfq4d3.js +0 -16
- package/dist/shadcn/lib/base-ui/_chunk-5gaqyne5.js +0 -21
- package/dist/shadcn/lib/base-ui/_chunk-5tt5hk59.js +0 -4
- package/dist/shadcn/lib/base-ui/_chunk-5tze5c8q.js +0 -13
- package/dist/shadcn/lib/base-ui/_chunk-5xmdvndx.js +0 -225
- package/dist/shadcn/lib/base-ui/_chunk-6adaer33.js +0 -435
- package/dist/shadcn/lib/base-ui/_chunk-6ejf1z1r.js +0 -9
- package/dist/shadcn/lib/base-ui/_chunk-6kqramh9.js +0 -27
- package/dist/shadcn/lib/base-ui/_chunk-7b9dc493.js +0 -14
- package/dist/shadcn/lib/base-ui/_chunk-8a9vv8am.js +0 -89
- package/dist/shadcn/lib/base-ui/_chunk-8ctgmf06.js +0 -129
- package/dist/shadcn/lib/base-ui/_chunk-8ganmsbg.js +0 -54
- package/dist/shadcn/lib/base-ui/_chunk-8xaqxgck.js +0 -15
- package/dist/shadcn/lib/base-ui/_chunk-95tf2rxq.js +0 -62
- package/dist/shadcn/lib/base-ui/_chunk-9x63vfqj.js +0 -70
- package/dist/shadcn/lib/base-ui/_chunk-ase0ydtt.js +0 -9
- package/dist/shadcn/lib/base-ui/_chunk-b0nc8wq7.js +0 -34
- package/dist/shadcn/lib/base-ui/_chunk-b5ya6xds.js +0 -10
- package/dist/shadcn/lib/base-ui/_chunk-b6dkjkbw.js +0 -43
- package/dist/shadcn/lib/base-ui/_chunk-c2bz952e.js +0 -19
- package/dist/shadcn/lib/base-ui/_chunk-cdgfsr3q.js +0 -15
- package/dist/shadcn/lib/base-ui/_chunk-cdj8cpx5.js +0 -347
- package/dist/shadcn/lib/base-ui/_chunk-cgptgywc.js +0 -104
- package/dist/shadcn/lib/base-ui/_chunk-cwvtvwc7.js +0 -35
- package/dist/shadcn/lib/base-ui/_chunk-dan0mva4.js +0 -23
- package/dist/shadcn/lib/base-ui/_chunk-dzvjwv25.js +0 -0
- package/dist/shadcn/lib/base-ui/_chunk-e13rsb6b.js +0 -184
- package/dist/shadcn/lib/base-ui/_chunk-e56mpvk1.js +0 -118
- package/dist/shadcn/lib/base-ui/_chunk-e6k2ecs7.js +0 -48
- package/dist/shadcn/lib/base-ui/_chunk-ebyxgtb4.js +0 -29
- package/dist/shadcn/lib/base-ui/_chunk-f2wttwrf.js +0 -39
- package/dist/shadcn/lib/base-ui/_chunk-fdzctasg.js +0 -38
- package/dist/shadcn/lib/base-ui/_chunk-ffpjy0ta.js +0 -39
- package/dist/shadcn/lib/base-ui/_chunk-fqry7pew.js +0 -603
- package/dist/shadcn/lib/base-ui/_chunk-ghn1tzt8.js +0 -84
- package/dist/shadcn/lib/base-ui/_chunk-gy0bpkmx.js +0 -12
- package/dist/shadcn/lib/base-ui/_chunk-hm5h9vsk.js +0 -16
- package/dist/shadcn/lib/base-ui/_chunk-htdj1jps.js +0 -833
- package/dist/shadcn/lib/base-ui/_chunk-j29xjete.js +0 -146
- package/dist/shadcn/lib/base-ui/_chunk-j3qkyd10.js +0 -50
- package/dist/shadcn/lib/base-ui/_chunk-ktvsd5k6.js +0 -2386
- package/dist/shadcn/lib/base-ui/_chunk-kw8nnq00.js +0 -546
- package/dist/shadcn/lib/base-ui/_chunk-m307wpdj.js +0 -18
- package/dist/shadcn/lib/base-ui/_chunk-mnd0j7v9.js +0 -15
- package/dist/shadcn/lib/base-ui/_chunk-n11h505c.js +0 -32
- package/dist/shadcn/lib/base-ui/_chunk-p0e2qacz.js +0 -26
- package/dist/shadcn/lib/base-ui/_chunk-pv7b791x.js +0 -106
- package/dist/shadcn/lib/base-ui/_chunk-q5cg71p7.js +0 -83
- package/dist/shadcn/lib/base-ui/_chunk-qbezxj1g.js +0 -385
- package/dist/shadcn/lib/base-ui/_chunk-qmsqz6nt.js +0 -15
- package/dist/shadcn/lib/base-ui/_chunk-rrh8rt4v.js +0 -65
- package/dist/shadcn/lib/base-ui/_chunk-s5pwkz8v.js +0 -25
- package/dist/shadcn/lib/base-ui/_chunk-svxv97ph.js +0 -218
- package/dist/shadcn/lib/base-ui/_chunk-t7ppm3t0.js +0 -68
- package/dist/shadcn/lib/base-ui/_chunk-vg16xxmb.js +0 -52
- package/dist/shadcn/lib/base-ui/_chunk-vgkfmtbe.js +0 -21
- package/dist/shadcn/lib/base-ui/_chunk-watha94s.js +0 -14
- package/dist/shadcn/lib/base-ui/_chunk-wdqynnjf.js +0 -35
- package/dist/shadcn/lib/base-ui/_chunk-wx2nxg0p.js +0 -15
- package/dist/shadcn/lib/base-ui/_chunk-x11e1k9r.js +0 -0
- package/dist/shadcn/lib/base-ui/_chunk-x8xehj6d.js +0 -302
- package/dist/shadcn/lib/base-ui/_chunk-xcqbtm2f.js +0 -28
- package/dist/shadcn/lib/base-ui/_chunk-ytnp24gq.js +0 -328
- package/dist/shadcn/lib/base-ui/_chunk-yzr7eg4b.js +0 -6
- package/dist/shadcn/lib/base-ui/_chunk-zk4mtm9m.js +0 -9
- package/dist/shadcn/lib/base-ui/accordion.d.ts +0 -447
- package/dist/shadcn/lib/base-ui/accordion.js +0 -630
- package/dist/shadcn/lib/base-ui/alert-dialog.d.ts +0 -1467
- package/dist/shadcn/lib/base-ui/alert-dialog.js +0 -98
- package/dist/shadcn/lib/base-ui/avatar.d.ts +0 -123
- package/dist/shadcn/lib/base-ui/avatar.js +0 -235
- package/dist/shadcn/lib/base-ui/button.d.ts +0 -84
- package/dist/shadcn/lib/base-ui/button.js +0 -51
- package/dist/shadcn/lib/base-ui/checkbox.d.ts +0 -341
- package/dist/shadcn/lib/base-ui/checkbox.js +0 -501
- package/dist/shadcn/lib/base-ui/collapsible.d.ts +0 -291
- package/dist/shadcn/lib/base-ui/collapsible.js +0 -264
- package/dist/shadcn/lib/base-ui/context-menu.d.ts +0 -2213
- package/dist/shadcn/lib/base-ui/context-menu.js +0 -323
- package/dist/shadcn/lib/base-ui/dialog.d.ts +0 -1448
- package/dist/shadcn/lib/base-ui/dialog.js +0 -79
- package/dist/shadcn/lib/base-ui/input.d.ts +0 -506
- package/dist/shadcn/lib/base-ui/input.js +0 -1027
- package/dist/shadcn/lib/base-ui/menu.d.ts +0 -2275
- package/dist/shadcn/lib/base-ui/menu.js +0 -60
- package/dist/shadcn/lib/base-ui/menubar.d.ts +0 -48
- package/dist/shadcn/lib/base-ui/menubar.js +0 -156
- package/dist/shadcn/lib/base-ui/merge-props.d.ts +0 -70
- package/dist/shadcn/lib/base-ui/merge-props.js +0 -15
- package/dist/shadcn/lib/base-ui/navigation-menu.d.ts +0 -825
- package/dist/shadcn/lib/base-ui/navigation-menu.js +0 -1849
- package/dist/shadcn/lib/base-ui/popover.d.ts +0 -1743
- package/dist/shadcn/lib/base-ui/popover.js +0 -1089
- package/dist/shadcn/lib/base-ui/preview-card.d.ts +0 -1608
- package/dist/shadcn/lib/base-ui/preview-card.js +0 -919
- package/dist/shadcn/lib/base-ui/progress.d.ts +0 -172
- package/dist/shadcn/lib/base-ui/progress.js +0 -272
- package/dist/shadcn/lib/base-ui/radio-group.d.ts +0 -260
- package/dist/shadcn/lib/base-ui/radio-group.js +0 -239
- package/dist/shadcn/lib/base-ui/radio.d.ts +0 -176
- package/dist/shadcn/lib/base-ui/radio.js +0 -387
- package/dist/shadcn/lib/base-ui/scroll-area.d.ts +0 -241
- package/dist/shadcn/lib/base-ui/scroll-area.js +0 -1055
- package/dist/shadcn/lib/base-ui/select.d.ts +0 -1266
- package/dist/shadcn/lib/base-ui/select.js +0 -2450
- package/dist/shadcn/lib/base-ui/separator.d.ts +0 -76
- package/dist/shadcn/lib/base-ui/separator.js +0 -11
- package/dist/shadcn/lib/base-ui/slider.d.ts +0 -551
- package/dist/shadcn/lib/base-ui/slider.js +0 -1583
- package/dist/shadcn/lib/base-ui/switch.d.ts +0 -313
- package/dist/shadcn/lib/base-ui/switch.js +0 -326
- package/dist/shadcn/lib/base-ui/tabs.d.ts +0 -406
- package/dist/shadcn/lib/base-ui/tabs.js +0 -915
- package/dist/shadcn/lib/base-ui/toggle-group.d.ts +0 -235
- package/dist/shadcn/lib/base-ui/toggle-group.js +0 -145
- package/dist/shadcn/lib/base-ui/toggle.d.ts +0 -224
- package/dist/shadcn/lib/base-ui/toggle.js +0 -127
- package/dist/shadcn/lib/base-ui/tooltip.d.ts +0 -1656
- package/dist/shadcn/lib/base-ui/tooltip.js +0 -920
- package/dist/shadcn/lib/base-ui/use-render.d.ts +0 -87
- package/dist/shadcn/lib/base-ui/use-render.js +0 -15
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Keep an element mounted through its CSS exit animation. When `open` flips to
|
|
4
|
+
* false the element stays rendered (so `data-closed:animate-out` can play) until
|
|
5
|
+
* its animations finish, then unmounts. Falls back to a timeout if there are
|
|
6
|
+
* none. Returns `[mounted, ref]` — attach `ref` to the animated element.
|
|
7
|
+
*/
|
|
8
|
+
export declare function usePresence<T extends HTMLElement = HTMLElement>(open: boolean): [boolean, React.RefObject<T | null>];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Keep an element mounted through its CSS exit animation. When `open` flips to
|
|
5
|
+
* false the element stays rendered (so `data-closed:animate-out` can play) until
|
|
6
|
+
* its animations finish, then unmounts. Falls back to a timeout if there are
|
|
7
|
+
* none. Returns `[mounted, ref]` — attach `ref` to the animated element.
|
|
8
|
+
*/
|
|
9
|
+
export function usePresence(open) {
|
|
10
|
+
const ref = React.useRef(null);
|
|
11
|
+
const [mounted, setMounted] = React.useState(open);
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
if (open) {
|
|
14
|
+
setMounted(true);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const node = ref.current;
|
|
18
|
+
if (!node) {
|
|
19
|
+
setMounted(false);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
let cancelled = false;
|
|
23
|
+
let fallback = 0;
|
|
24
|
+
const finish = () => {
|
|
25
|
+
if (!cancelled)
|
|
26
|
+
setMounted(false);
|
|
27
|
+
};
|
|
28
|
+
// Let the data-closed classes apply and animations register, then wait for
|
|
29
|
+
// the actual animations to finish (no short timeout racing them — that would
|
|
30
|
+
// cut off any exit animation longer than the timeout). A generous backstop
|
|
31
|
+
// only guards against animations that never settle.
|
|
32
|
+
const raf = requestAnimationFrame(() => {
|
|
33
|
+
const anims = node.getAnimations?.() ?? [];
|
|
34
|
+
if (anims.length === 0) {
|
|
35
|
+
finish();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
Promise.allSettled(anims.map((a) => a.finished)).then(finish);
|
|
39
|
+
fallback = window.setTimeout(finish, 2000);
|
|
40
|
+
});
|
|
41
|
+
return () => {
|
|
42
|
+
cancelled = true;
|
|
43
|
+
window.clearTimeout(fallback);
|
|
44
|
+
cancelAnimationFrame(raf);
|
|
45
|
+
};
|
|
46
|
+
}, [open]);
|
|
47
|
+
return [mounted, ref];
|
|
48
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WAI-ARIA typeahead for listbox/menu widgets. Collects printable keystrokes
|
|
4
|
+
* into a buffer that resets after a short pause, then resolves the item whose
|
|
5
|
+
* label matches the buffer (prefix match). Repeating a single character cycles
|
|
6
|
+
* through the items starting with it. The caller owns the items and decides how
|
|
7
|
+
* to focus/activate the returned match.
|
|
8
|
+
*
|
|
9
|
+
* Usage inside a keydown handler, after handling Arrow/Home/End/Enter/Escape/Tab:
|
|
10
|
+
* const match = onTypeaheadKeyDown(e, items, currentIndex)
|
|
11
|
+
* if (match) { e.preventDefault(); match.focus() }
|
|
12
|
+
*
|
|
13
|
+
* @returns `onTypeaheadKeyDown(event, items, activeIndex)` → matched element or null.
|
|
14
|
+
* `items` must be the enabled item elements in DOM order; `activeIndex` is the
|
|
15
|
+
* index of the currently focused item within `items` (-1 if none).
|
|
16
|
+
*/
|
|
17
|
+
export declare function useTypeahead(): {
|
|
18
|
+
onTypeaheadKeyDown: (event: React.KeyboardEvent, items: HTMLElement[], activeIndex: number) => HTMLElement | null;
|
|
19
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
// How long a typeahead buffer survives between keystrokes before resetting, per
|
|
4
|
+
// the WAI-ARIA typeahead pattern (a short pause starts a fresh search).
|
|
5
|
+
const RESET_MS = 500;
|
|
6
|
+
/** The visible, trimmed, lower-cased label of an item, used for prefix matching. */
|
|
7
|
+
function labelOf(el) {
|
|
8
|
+
return (el.textContent ?? "").trim().toLowerCase();
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* WAI-ARIA typeahead for listbox/menu widgets. Collects printable keystrokes
|
|
12
|
+
* into a buffer that resets after a short pause, then resolves the item whose
|
|
13
|
+
* label matches the buffer (prefix match). Repeating a single character cycles
|
|
14
|
+
* through the items starting with it. The caller owns the items and decides how
|
|
15
|
+
* to focus/activate the returned match.
|
|
16
|
+
*
|
|
17
|
+
* Usage inside a keydown handler, after handling Arrow/Home/End/Enter/Escape/Tab:
|
|
18
|
+
* const match = onTypeaheadKeyDown(e, items, currentIndex)
|
|
19
|
+
* if (match) { e.preventDefault(); match.focus() }
|
|
20
|
+
*
|
|
21
|
+
* @returns `onTypeaheadKeyDown(event, items, activeIndex)` → matched element or null.
|
|
22
|
+
* `items` must be the enabled item elements in DOM order; `activeIndex` is the
|
|
23
|
+
* index of the currently focused item within `items` (-1 if none).
|
|
24
|
+
*/
|
|
25
|
+
export function useTypeahead() {
|
|
26
|
+
const bufferRef = React.useRef("");
|
|
27
|
+
const timerRef = React.useRef(0);
|
|
28
|
+
React.useEffect(() => () => window.clearTimeout(timerRef.current), []);
|
|
29
|
+
const onTypeaheadKeyDown = React.useCallback((event, items, activeIndex) => {
|
|
30
|
+
const key = event.key;
|
|
31
|
+
// Single printable char only. Space is reserved for activation, and any
|
|
32
|
+
// modifier combo (Ctrl/Meta/Alt) is a command, not text.
|
|
33
|
+
if (key.length !== 1 ||
|
|
34
|
+
key === " " ||
|
|
35
|
+
event.ctrlKey ||
|
|
36
|
+
event.metaKey ||
|
|
37
|
+
event.altKey)
|
|
38
|
+
return null;
|
|
39
|
+
window.clearTimeout(timerRef.current);
|
|
40
|
+
timerRef.current = window.setTimeout(() => {
|
|
41
|
+
bufferRef.current = "";
|
|
42
|
+
}, RESET_MS);
|
|
43
|
+
const prev = bufferRef.current;
|
|
44
|
+
bufferRef.current += key.toLowerCase();
|
|
45
|
+
const buffer = bufferRef.current;
|
|
46
|
+
// A repeated single character cycles through items starting with it rather
|
|
47
|
+
// than searching for the literal repetition (e.g. "aa" → next "a…" item).
|
|
48
|
+
const allSame = buffer.length > 1 && [...buffer].every((c) => c === buffer[0]);
|
|
49
|
+
const query = allSame ? buffer[0] : buffer;
|
|
50
|
+
const n = items.length;
|
|
51
|
+
if (n === 0)
|
|
52
|
+
return null;
|
|
53
|
+
// Extending an in-progress match keeps resolving from the current item;
|
|
54
|
+
// a fresh search or a cycle advances past it.
|
|
55
|
+
const start = allSame || prev === "" ? Math.max(0, activeIndex) + 1 : Math.max(0, activeIndex);
|
|
56
|
+
for (let i = 0; i < n; i++) {
|
|
57
|
+
const item = items[(start + i) % n];
|
|
58
|
+
if (labelOf(item).startsWith(query))
|
|
59
|
+
return item;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}, []);
|
|
63
|
+
return { onTypeaheadKeyDown };
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stevederico/skateboard-ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -148,6 +148,11 @@
|
|
|
148
148
|
"import": "./dist/shadcn/ui/*.js",
|
|
149
149
|
"default": "./dist/shadcn/ui/*.js"
|
|
150
150
|
},
|
|
151
|
+
"./ui/*": {
|
|
152
|
+
"types": "./dist/ui/*.d.ts",
|
|
153
|
+
"import": "./dist/ui/*.js",
|
|
154
|
+
"default": "./dist/ui/*.js"
|
|
155
|
+
},
|
|
151
156
|
"./shadcn/lib/utils": {
|
|
152
157
|
"types": "./dist/shadcn/lib/utils.d.ts",
|
|
153
158
|
"import": "./dist/shadcn/lib/utils.js",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 Material-UI SAS
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
// node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
|
|
2
|
-
function hasWindow() {
|
|
3
|
-
return typeof window !== "undefined";
|
|
4
|
-
}
|
|
5
|
-
function getNodeName(node) {
|
|
6
|
-
if (isNode(node)) {
|
|
7
|
-
return (node.nodeName || "").toLowerCase();
|
|
8
|
-
}
|
|
9
|
-
return "#document";
|
|
10
|
-
}
|
|
11
|
-
function getWindow(node) {
|
|
12
|
-
var _node$ownerDocument;
|
|
13
|
-
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? undefined : _node$ownerDocument.defaultView) || window;
|
|
14
|
-
}
|
|
15
|
-
function getDocumentElement(node) {
|
|
16
|
-
var _ref;
|
|
17
|
-
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? undefined : _ref.documentElement;
|
|
18
|
-
}
|
|
19
|
-
function isNode(value) {
|
|
20
|
-
if (!hasWindow()) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
24
|
-
}
|
|
25
|
-
function isElement(value) {
|
|
26
|
-
if (!hasWindow()) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
30
|
-
}
|
|
31
|
-
function isHTMLElement(value) {
|
|
32
|
-
if (!hasWindow()) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
36
|
-
}
|
|
37
|
-
function isShadowRoot(value) {
|
|
38
|
-
if (!hasWindow() || typeof ShadowRoot === "undefined") {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
42
|
-
}
|
|
43
|
-
function isOverflowElement(element) {
|
|
44
|
-
const {
|
|
45
|
-
overflow,
|
|
46
|
-
overflowX,
|
|
47
|
-
overflowY,
|
|
48
|
-
display
|
|
49
|
-
} = getComputedStyle(element);
|
|
50
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
|
|
51
|
-
}
|
|
52
|
-
function isTableElement(element) {
|
|
53
|
-
return /^(table|td|th)$/.test(getNodeName(element));
|
|
54
|
-
}
|
|
55
|
-
function isTopLayer(element) {
|
|
56
|
-
try {
|
|
57
|
-
if (element.matches(":popover-open")) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
} catch (_e) {}
|
|
61
|
-
try {
|
|
62
|
-
return element.matches(":modal");
|
|
63
|
-
} catch (_e) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
|
|
68
|
-
var containRe = /paint|layout|strict|content/;
|
|
69
|
-
var isNotNone = (value) => !!value && value !== "none";
|
|
70
|
-
var isWebKitValue;
|
|
71
|
-
function isContainingBlock(elementOrCss) {
|
|
72
|
-
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
|
73
|
-
return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || "");
|
|
74
|
-
}
|
|
75
|
-
function getContainingBlock(element) {
|
|
76
|
-
let currentNode = getParentNode(element);
|
|
77
|
-
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
78
|
-
if (isContainingBlock(currentNode)) {
|
|
79
|
-
return currentNode;
|
|
80
|
-
} else if (isTopLayer(currentNode)) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
currentNode = getParentNode(currentNode);
|
|
84
|
-
}
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
function isWebKit() {
|
|
88
|
-
if (isWebKitValue == null) {
|
|
89
|
-
isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
|
|
90
|
-
}
|
|
91
|
-
return isWebKitValue;
|
|
92
|
-
}
|
|
93
|
-
function isLastTraversableNode(node) {
|
|
94
|
-
return /^(html|body|#document)$/.test(getNodeName(node));
|
|
95
|
-
}
|
|
96
|
-
function getComputedStyle(element) {
|
|
97
|
-
return getWindow(element).getComputedStyle(element);
|
|
98
|
-
}
|
|
99
|
-
function getNodeScroll(element) {
|
|
100
|
-
if (isElement(element)) {
|
|
101
|
-
return {
|
|
102
|
-
scrollLeft: element.scrollLeft,
|
|
103
|
-
scrollTop: element.scrollTop
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
scrollLeft: element.scrollX,
|
|
108
|
-
scrollTop: element.scrollY
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function getParentNode(node) {
|
|
112
|
-
if (getNodeName(node) === "html") {
|
|
113
|
-
return node;
|
|
114
|
-
}
|
|
115
|
-
const result = node.assignedSlot || node.parentNode || isShadowRoot(node) && node.host || getDocumentElement(node);
|
|
116
|
-
return isShadowRoot(result) ? result.host : result;
|
|
117
|
-
}
|
|
118
|
-
function getNearestOverflowAncestor(node) {
|
|
119
|
-
const parentNode = getParentNode(node);
|
|
120
|
-
if (isLastTraversableNode(parentNode)) {
|
|
121
|
-
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
122
|
-
}
|
|
123
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
124
|
-
return parentNode;
|
|
125
|
-
}
|
|
126
|
-
return getNearestOverflowAncestor(parentNode);
|
|
127
|
-
}
|
|
128
|
-
function getOverflowAncestors(node, list, traverseIframes) {
|
|
129
|
-
var _node$ownerDocument2;
|
|
130
|
-
if (list === undefined) {
|
|
131
|
-
list = [];
|
|
132
|
-
}
|
|
133
|
-
if (traverseIframes === undefined) {
|
|
134
|
-
traverseIframes = true;
|
|
135
|
-
}
|
|
136
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
137
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? undefined : _node$ownerDocument2.body);
|
|
138
|
-
const win = getWindow(scrollableAncestor);
|
|
139
|
-
if (isBody) {
|
|
140
|
-
const frameElement = getFrameElement(win);
|
|
141
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
142
|
-
} else {
|
|
143
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function getFrameElement(win) {
|
|
147
|
-
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export { getNodeName, getWindow, getDocumentElement, isNode, isElement, isHTMLElement, isShadowRoot, isOverflowElement, isTableElement, isTopLayer, isContainingBlock, getContainingBlock, isWebKit, isLastTraversableNode, getComputedStyle, getNodeScroll, getParentNode, getOverflowAncestors, getFrameElement };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__commonJS
|
|
3
|
-
} from "./_chunk-svxv97ph.js";
|
|
4
|
-
|
|
5
|
-
// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
|
|
6
|
-
import * as React from "react";
|
|
7
|
-
var require_use_sync_external_store_shim_development = __commonJS((exports) => {
|
|
8
|
-
(function() {
|
|
9
|
-
function is(x, y) {
|
|
10
|
-
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
|
|
11
|
-
}
|
|
12
|
-
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
13
|
-
didWarnOld18Alpha || React.startTransition === undefined || (didWarnOld18Alpha = true, console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
|
|
14
|
-
var value = getSnapshot();
|
|
15
|
-
if (!didWarnUncachedGetSnapshot) {
|
|
16
|
-
var cachedValue = getSnapshot();
|
|
17
|
-
objectIs(value, cachedValue) || (console.error("The result of getSnapshot should be cached to avoid an infinite loop"), didWarnUncachedGetSnapshot = true);
|
|
18
|
-
}
|
|
19
|
-
cachedValue = useState2({
|
|
20
|
-
inst: { value, getSnapshot }
|
|
21
|
-
});
|
|
22
|
-
var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
|
|
23
|
-
useLayoutEffect2(function() {
|
|
24
|
-
inst.value = value;
|
|
25
|
-
inst.getSnapshot = getSnapshot;
|
|
26
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
27
|
-
}, [subscribe, value, getSnapshot]);
|
|
28
|
-
useEffect2(function() {
|
|
29
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
30
|
-
return subscribe(function() {
|
|
31
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
32
|
-
});
|
|
33
|
-
}, [subscribe]);
|
|
34
|
-
useDebugValue2(value);
|
|
35
|
-
return value;
|
|
36
|
-
}
|
|
37
|
-
function checkIfSnapshotChanged(inst) {
|
|
38
|
-
var latestGetSnapshot = inst.getSnapshot;
|
|
39
|
-
inst = inst.value;
|
|
40
|
-
try {
|
|
41
|
-
var nextValue = latestGetSnapshot();
|
|
42
|
-
return !objectIs(inst, nextValue);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
48
|
-
return getSnapshot();
|
|
49
|
-
}
|
|
50
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
51
|
-
var objectIs = typeof Object.is === "function" ? Object.is : is, useState2 = React.useState, useEffect2 = React.useEffect, useLayoutEffect2 = React.useLayoutEffect, useDebugValue2 = React.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = typeof window === "undefined" || typeof window.document === "undefined" || typeof window.document.createElement === "undefined" ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
|
52
|
-
exports.useSyncExternalStore = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
|
|
53
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
54
|
-
})();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// node_modules/use-sync-external-store/shim/index.js
|
|
58
|
-
var require_shim = __commonJS((exports, module) => {
|
|
59
|
-
if (false) {} else {
|
|
60
|
-
module.exports = require_use_sync_external_store_shim_development();
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
export { require_shim };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useLabelableContext
|
|
3
|
-
} from "./_chunk-8ctgmf06.js";
|
|
4
|
-
import {
|
|
5
|
-
useBaseUiId
|
|
6
|
-
} from "./_chunk-wdqynnjf.js";
|
|
7
|
-
import {
|
|
8
|
-
isElement
|
|
9
|
-
} from "./_chunk-000kmre8.js";
|
|
10
|
-
import {
|
|
11
|
-
useStableCallback
|
|
12
|
-
} from "./_chunk-cwvtvwc7.js";
|
|
13
|
-
import {
|
|
14
|
-
useIsoLayoutEffect
|
|
15
|
-
} from "./_chunk-5tze5c8q.js";
|
|
16
|
-
import {
|
|
17
|
-
NOOP,
|
|
18
|
-
useRefWithInit
|
|
19
|
-
} from "./_chunk-x8xehj6d.js";
|
|
20
|
-
|
|
21
|
-
// node_modules/@base-ui/react/esm/internals/labelable-provider/useLabelableId.js
|
|
22
|
-
import * as React from "react";
|
|
23
|
-
"use client";
|
|
24
|
-
function useLabelableId(params = {}) {
|
|
25
|
-
const {
|
|
26
|
-
id,
|
|
27
|
-
implicit = false,
|
|
28
|
-
controlRef
|
|
29
|
-
} = params;
|
|
30
|
-
const {
|
|
31
|
-
controlId,
|
|
32
|
-
registerControlId
|
|
33
|
-
} = useLabelableContext();
|
|
34
|
-
const defaultId = useBaseUiId(id);
|
|
35
|
-
const controlIdForEffect = implicit ? controlId : undefined;
|
|
36
|
-
const controlSourceRef = useRefWithInit(() => Symbol("labelable-control"));
|
|
37
|
-
const hasRegisteredRef = React.useRef(false);
|
|
38
|
-
const hadExplicitIdRef = React.useRef(id != null);
|
|
39
|
-
const unregisterControlId = useStableCallback(() => {
|
|
40
|
-
if (!hasRegisteredRef.current || registerControlId === NOOP) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
hasRegisteredRef.current = false;
|
|
44
|
-
registerControlId(controlSourceRef.current, undefined);
|
|
45
|
-
});
|
|
46
|
-
useIsoLayoutEffect(() => {
|
|
47
|
-
if (registerControlId === NOOP) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
let nextId;
|
|
51
|
-
if (implicit) {
|
|
52
|
-
const elem = controlRef?.current;
|
|
53
|
-
if (isElement(elem) && elem.closest("label") != null) {
|
|
54
|
-
nextId = id ?? null;
|
|
55
|
-
} else {
|
|
56
|
-
nextId = controlIdForEffect ?? defaultId;
|
|
57
|
-
}
|
|
58
|
-
} else if (id != null) {
|
|
59
|
-
hadExplicitIdRef.current = true;
|
|
60
|
-
nextId = id;
|
|
61
|
-
} else if (hadExplicitIdRef.current) {
|
|
62
|
-
nextId = defaultId;
|
|
63
|
-
} else {
|
|
64
|
-
unregisterControlId();
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (nextId === undefined) {
|
|
68
|
-
unregisterControlId();
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
hasRegisteredRef.current = true;
|
|
72
|
-
registerControlId(controlSourceRef.current, nextId);
|
|
73
|
-
return;
|
|
74
|
-
}, [id, controlRef, controlIdForEffect, registerControlId, implicit, defaultId, controlSourceRef, unregisterControlId]);
|
|
75
|
-
React.useEffect(() => {
|
|
76
|
-
return unregisterControlId;
|
|
77
|
-
}, [unregisterControlId]);
|
|
78
|
-
return controlId ?? defaultId;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export { useLabelableId };
|