@sprawlify/primitives 0.0.1
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/anatomy.cjs +3 -0
- package/dist/anatomy.d.cts +2 -0
- package/dist/anatomy.d.mts +2 -0
- package/dist/anatomy.mjs +3 -0
- package/dist/aria-hidden-DqYx0f_y.mjs +177 -0
- package/dist/aria-hidden-DtLU6hSU.cjs +182 -0
- package/dist/aria-hidden.cjs +4 -0
- package/dist/aria-hidden.d.cts +16 -0
- package/dist/aria-hidden.d.mts +16 -0
- package/dist/aria-hidden.mjs +4 -0
- package/dist/auto-resize-D3qHtFy1.mjs +114 -0
- package/dist/auto-resize-xzlPFDyD.cjs +125 -0
- package/dist/auto-resize.cjs +5 -0
- package/dist/auto-resize.d.cts +17 -0
- package/dist/auto-resize.d.mts +17 -0
- package/dist/auto-resize.mjs +4 -0
- package/dist/chunk-CbDLau6x.cjs +34 -0
- package/dist/collection-8XqaNHs_.mjs +1279 -0
- package/dist/collection-DIoIDISa.cjs +1326 -0
- package/dist/collection.cjs +11 -0
- package/dist/collection.d.cts +5 -0
- package/dist/collection.d.mts +5 -0
- package/dist/collection.mjs +4 -0
- package/dist/color-BkAP1Tkd.d.mts +60 -0
- package/dist/color-VKewNv2e.d.cts +60 -0
- package/dist/color-utils-Cc5GVXZh.mjs +657 -0
- package/dist/color-utils-LER_6Zwu.cjs +680 -0
- package/dist/color-utils.cjs +7 -0
- package/dist/color-utils.d.cts +19 -0
- package/dist/color-utils.d.mts +19 -0
- package/dist/color-utils.mjs +4 -0
- package/dist/core-30pJjyC2.d.mts +49 -0
- package/dist/core-CQFbMdTl.cjs +176 -0
- package/dist/core-CefBjbst.d.cts +49 -0
- package/dist/core-DCFNMTZF.mjs +129 -0
- package/dist/core.cjs +12 -0
- package/dist/core.d.cts +3 -0
- package/dist/core.d.mts +3 -0
- package/dist/core.mjs +5 -0
- package/dist/create-anatomy-B3XYc-qG.d.mts +70 -0
- package/dist/create-anatomy-BGQ8pv8J.d.cts +70 -0
- package/dist/create-anatomy-BbDZbHpC.mjs +39 -0
- package/dist/create-anatomy-CDsIFUXg.cjs +45 -0
- package/dist/create-props-BnF_vl-E.mjs +5 -0
- package/dist/create-props-YKy7JIKj.cjs +11 -0
- package/dist/data-url-C3ITPVRX.d.cts +10 -0
- package/dist/data-url-DLwZ9M77.d.mts +10 -0
- package/dist/date-utils-D2xPHa_I.cjs +738 -0
- package/dist/date-utils-wEa1hhpc.mjs +474 -0
- package/dist/date-utils.cjs +46 -0
- package/dist/date-utils.d.cts +101 -0
- package/dist/date-utils.d.mts +2 -0
- package/dist/date-utils.mjs +3 -0
- package/dist/defineProperty-BoUOT9Ie.cjs +49 -0
- package/dist/defineProperty-DrXfyjd4.mjs +43 -0
- package/dist/dismissable-CTfKZ4OG.cjs +282 -0
- package/dist/dismissable-DDrx0xnH.mjs +271 -0
- package/dist/dismissable-layer-C7pZU2wi.d.cts +39 -0
- package/dist/dismissable-layer-t_b0fk-p.d.mts +39 -0
- package/dist/dismissable.cjs +7 -0
- package/dist/dismissable.d.cts +3 -0
- package/dist/dismissable.d.mts +3 -0
- package/dist/dismissable.mjs +6 -0
- package/dist/dom-query-CWZdWUGp.cjs +2141 -0
- package/dist/dom-query-DFCRhyj1.mjs +1374 -0
- package/dist/dom-query.cjs +130 -0
- package/dist/dom-query.d.cts +307 -0
- package/dist/dom-query.d.mts +307 -0
- package/dist/dom-query.mjs +3 -0
- package/dist/file-utils.cjs +220 -0
- package/dist/file-utils.d.cts +51 -0
- package/dist/file-utils.d.mts +51 -0
- package/dist/file-utils.mjs +210 -0
- package/dist/focus-trap-D-bypQEJ.mjs +485 -0
- package/dist/focus-trap-D4i52S9A.cjs +496 -0
- package/dist/focus-trap.cjs +5 -0
- package/dist/focus-trap.d.cts +88 -0
- package/dist/focus-trap.d.mts +88 -0
- package/dist/focus-trap.mjs +4 -0
- package/dist/focus-visible-DYTWdWpa.cjs +210 -0
- package/dist/focus-visible-irppYatv.mjs +175 -0
- package/dist/focus-visible.cjs +9 -0
- package/dist/focus-visible.d.cts +31 -0
- package/dist/focus-visible.d.mts +31 -0
- package/dist/focus-visible.mjs +4 -0
- package/dist/functions-BOkTDEFM.d.cts +15 -0
- package/dist/functions-IZtWcC8Q.d.mts +15 -0
- package/dist/highlight-word.cjs +100 -0
- package/dist/highlight-word.d.cts +24 -0
- package/dist/highlight-word.d.mts +24 -0
- package/dist/highlight-word.mjs +99 -0
- package/dist/hotkeys.cjs +758 -0
- package/dist/hotkeys.d.cts +130 -0
- package/dist/hotkeys.d.mts +130 -0
- package/dist/hotkeys.mjs +754 -0
- package/dist/i18n-utils.cjs +450 -0
- package/dist/i18n-utils.d.cts +61 -0
- package/dist/i18n-utils.d.mts +61 -0
- package/dist/i18n-utils.mjs +440 -0
- package/dist/index-BkzYij2j.d.mts +25 -0
- package/dist/index-Bqw3r34-.d.cts +1383 -0
- package/dist/index-C0MKXQmE.d.mts +1383 -0
- package/dist/index-C9-feK5c.d.cts +25 -0
- package/dist/index-CD5FN7kY.d.mts +114 -0
- package/dist/index-CJji6wHl.d.cts +15 -0
- package/dist/index-CNi5FkPe.d.mts +15 -0
- package/dist/index-D96rs8B0.d.mts +115 -0
- package/dist/index.cjs +0 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -0
- package/dist/interact-outside-BplxR9cR.mjs +200 -0
- package/dist/interact-outside-C8-oFBpB.cjs +205 -0
- package/dist/interact-outside.cjs +5 -0
- package/dist/interact-outside.d.cts +2 -0
- package/dist/interact-outside.d.mts +2 -0
- package/dist/interact-outside.mjs +5 -0
- package/dist/json-tree-utils.cjs +1512 -0
- package/dist/json-tree-utils.d.cts +117 -0
- package/dist/json-tree-utils.d.mts +117 -0
- package/dist/json-tree-utils.mjs +1463 -0
- package/dist/list-collection-BIMJGQjn.d.cts +61 -0
- package/dist/list-collection-Db3eixRU.d.mts +61 -0
- package/dist/live-region-CcZPGo89.cjs +52 -0
- package/dist/live-region-CnPh21WH.mjs +46 -0
- package/dist/live-region.cjs +3 -0
- package/dist/live-region.d.cts +2 -0
- package/dist/live-region.d.mts +2 -0
- package/dist/live-region.mjs +3 -0
- package/dist/machines/accordion/index.cjs +328 -0
- package/dist/machines/accordion/index.d.cts +83 -0
- package/dist/machines/accordion/index.d.mts +83 -0
- package/dist/machines/accordion/index.mjs +322 -0
- package/dist/machines/async-list/index.cjs +311 -0
- package/dist/machines/async-list/index.d.cts +89 -0
- package/dist/machines/async-list/index.d.mts +89 -0
- package/dist/machines/async-list/index.mjs +310 -0
- package/dist/machines/avatar/index.cjs +169 -0
- package/dist/machines/avatar/index.d.cts +63 -0
- package/dist/machines/avatar/index.d.mts +63 -0
- package/dist/machines/avatar/index.mjs +165 -0
- package/dist/machines/bottom-sheet/index.cjs +676 -0
- package/dist/machines/bottom-sheet/index.d.cts +239 -0
- package/dist/machines/bottom-sheet/index.d.mts +239 -0
- package/dist/machines/bottom-sheet/index.mjs +672 -0
- package/dist/machines/carousel/index.cjs +859 -0
- package/dist/machines/carousel/index.d.cts +146 -0
- package/dist/machines/carousel/index.d.mts +146 -0
- package/dist/machines/carousel/index.mjs +851 -0
- package/dist/machines/checkbox/index.cjs +316 -0
- package/dist/machines/checkbox/index.d.cts +81 -0
- package/dist/machines/checkbox/index.d.mts +81 -0
- package/dist/machines/checkbox/index.mjs +312 -0
- package/dist/machines/clipboard/index.cjs +225 -0
- package/dist/machines/clipboard/index.d.cts +68 -0
- package/dist/machines/clipboard/index.d.mts +68 -0
- package/dist/machines/clipboard/index.mjs +219 -0
- package/dist/machines/collapsible/index.cjs +362 -0
- package/dist/machines/collapsible/index.d.cts +82 -0
- package/dist/machines/collapsible/index.d.mts +82 -0
- package/dist/machines/collapsible/index.mjs +358 -0
- package/dist/machines/color-picker/index.cjs +1529 -0
- package/dist/machines/color-picker/index.d.cts +205 -0
- package/dist/machines/color-picker/index.d.mts +205 -0
- package/dist/machines/color-picker/index.mjs +1514 -0
- package/dist/machines/combobox/index.cjs +1593 -0
- package/dist/machines/combobox/index.d.cts +214 -0
- package/dist/machines/combobox/index.d.mts +214 -0
- package/dist/machines/combobox/index.mjs +1582 -0
- package/dist/machines/date-picker/index.cjs +2177 -0
- package/dist/machines/date-picker/index.d.cts +350 -0
- package/dist/machines/date-picker/index.d.mts +350 -0
- package/dist/machines/date-picker/index.mjs +2161 -0
- package/dist/machines/dialog/index.cjs +325 -0
- package/dist/machines/dialog/index.d.cts +80 -0
- package/dist/machines/dialog/index.d.mts +80 -0
- package/dist/machines/dialog/index.mjs +321 -0
- package/dist/machines/editable/index.cjs +551 -0
- package/dist/machines/editable/index.d.cts +114 -0
- package/dist/machines/editable/index.d.mts +114 -0
- package/dist/machines/editable/index.mjs +547 -0
- package/dist/machines/floating-panel/index.cjs +995 -0
- package/dist/machines/floating-panel/index.d.cts +147 -0
- package/dist/machines/floating-panel/index.d.mts +147 -0
- package/dist/machines/floating-panel/index.mjs +988 -0
- package/dist/machines/hover-card/index.cjs +383 -0
- package/dist/machines/hover-card/index.d.cts +69 -0
- package/dist/machines/hover-card/index.d.mts +69 -0
- package/dist/machines/hover-card/index.mjs +379 -0
- package/dist/machines/image-cropper/index.cjs +1995 -0
- package/dist/machines/image-cropper/index.d.cts +182 -0
- package/dist/machines/image-cropper/index.d.mts +182 -0
- package/dist/machines/image-cropper/index.mjs +1990 -0
- package/dist/machines/listbox/index.cjs +794 -0
- package/dist/machines/listbox/index.d.cts +168 -0
- package/dist/machines/listbox/index.d.mts +168 -0
- package/dist/machines/listbox/index.mjs +782 -0
- package/dist/machines/marquee/index.cjs +395 -0
- package/dist/machines/marquee/index.d.cts +102 -0
- package/dist/machines/marquee/index.d.mts +102 -0
- package/dist/machines/marquee/index.mjs +391 -0
- package/dist/machines/menu/index.cjs +1298 -0
- package/dist/machines/menu/index.d.cts +175 -0
- package/dist/machines/menu/index.d.mts +175 -0
- package/dist/machines/menu/index.mjs +1286 -0
- package/dist/machines/navigation-menu/index.cjs +861 -0
- package/dist/machines/navigation-menu/index.d.cts +127 -0
- package/dist/machines/navigation-menu/index.d.mts +127 -0
- package/dist/machines/navigation-menu/index.mjs +857 -0
- package/dist/machines/number-input/index.cjs +996 -0
- package/dist/machines/number-input/index.d.cts +134 -0
- package/dist/machines/number-input/index.d.mts +134 -0
- package/dist/machines/number-input/index.mjs +991 -0
- package/dist/machines/pagination/index.cjs +419 -0
- package/dist/machines/pagination/index.d.cts +139 -0
- package/dist/machines/pagination/index.d.mts +139 -0
- package/dist/machines/pagination/index.mjs +411 -0
- package/dist/machines/password-input/index.cjs +228 -0
- package/dist/machines/password-input/index.d.cts +71 -0
- package/dist/machines/password-input/index.d.mts +71 -0
- package/dist/machines/password-input/index.mjs +224 -0
- package/dist/machines/pin-input/index.cjs +523 -0
- package/dist/machines/pin-input/index.d.cts +105 -0
- package/dist/machines/pin-input/index.d.mts +105 -0
- package/dist/machines/pin-input/index.mjs +519 -0
- package/dist/machines/popover/index.cjs +430 -0
- package/dist/machines/popover/index.d.cts +88 -0
- package/dist/machines/popover/index.d.mts +88 -0
- package/dist/machines/popover/index.mjs +426 -0
- package/dist/machines/presence/index.cjs +192 -0
- package/dist/machines/presence/index.d.cts +44 -0
- package/dist/machines/presence/index.d.mts +44 -0
- package/dist/machines/presence/index.mjs +190 -0
- package/dist/machines/progress/index.cjs +288 -0
- package/dist/machines/progress/index.d.cts +96 -0
- package/dist/machines/progress/index.d.mts +96 -0
- package/dist/machines/progress/index.mjs +284 -0
- package/dist/machines/qr-code/index.cjs +172 -0
- package/dist/machines/qr-code/index.d.cts +70 -0
- package/dist/machines/qr-code/index.d.mts +70 -0
- package/dist/machines/qr-code/index.mjs +167 -0
- package/dist/machines/radio-group/index.cjs +436 -0
- package/dist/machines/radio-group/index.d.cts +106 -0
- package/dist/machines/radio-group/index.d.mts +106 -0
- package/dist/machines/radio-group/index.mjs +430 -0
- package/dist/machines/rating-group/index.cjs +405 -0
- package/dist/machines/rating-group/index.d.cts +101 -0
- package/dist/machines/rating-group/index.d.mts +101 -0
- package/dist/machines/rating-group/index.mjs +399 -0
- package/dist/machines/scroll-area/index.cjs +857 -0
- package/dist/machines/scroll-area/index.d.cts +159 -0
- package/dist/machines/scroll-area/index.d.mts +159 -0
- package/dist/machines/scroll-area/index.mjs +853 -0
- package/dist/machines/select/index.cjs +1165 -0
- package/dist/machines/select/index.d.cts +183 -0
- package/dist/machines/select/index.d.mts +183 -0
- package/dist/machines/select/index.mjs +1154 -0
- package/dist/machines/signature-pad/index.cjs +334 -0
- package/dist/machines/signature-pad/index.d.cts +108 -0
- package/dist/machines/signature-pad/index.d.mts +108 -0
- package/dist/machines/signature-pad/index.mjs +328 -0
- package/dist/machines/slider/index.cjs +957 -0
- package/dist/machines/slider/index.d.cts +149 -0
- package/dist/machines/slider/index.d.mts +149 -0
- package/dist/machines/slider/index.mjs +949 -0
- package/dist/machines/splitter/index.cjs +1112 -0
- package/dist/machines/splitter/index.d.cts +155 -0
- package/dist/machines/splitter/index.d.mts +155 -0
- package/dist/machines/splitter/index.mjs +1103 -0
- package/dist/machines/steps/index.cjs +289 -0
- package/dist/machines/steps/index.d.cts +97 -0
- package/dist/machines/steps/index.d.mts +97 -0
- package/dist/machines/steps/index.mjs +285 -0
- package/dist/machines/switch/index.cjs +305 -0
- package/dist/machines/switch/index.d.cts +80 -0
- package/dist/machines/switch/index.d.mts +80 -0
- package/dist/machines/switch/index.mjs +301 -0
- package/dist/machines/tabs/index.cjs +508 -0
- package/dist/machines/tabs/index.d.cts +111 -0
- package/dist/machines/tabs/index.d.mts +111 -0
- package/dist/machines/tabs/index.mjs +500 -0
- package/dist/machines/tags-input/index.cjs +1127 -0
- package/dist/machines/tags-input/index.d.cts +179 -0
- package/dist/machines/tags-input/index.d.mts +179 -0
- package/dist/machines/tags-input/index.mjs +1121 -0
- package/dist/machines/timer/index.cjs +329 -0
- package/dist/machines/timer/index.d.cts +98 -0
- package/dist/machines/timer/index.d.mts +98 -0
- package/dist/machines/timer/index.mjs +324 -0
- package/dist/machines/toast/index.cjs +1155 -0
- package/dist/machines/toast/index.d.cts +195 -0
- package/dist/machines/toast/index.d.mts +195 -0
- package/dist/machines/toast/index.mjs +1151 -0
- package/dist/machines/toggle/index.cjs +103 -0
- package/dist/machines/toggle/index.d.cts +46 -0
- package/dist/machines/toggle/index.d.mts +46 -0
- package/dist/machines/toggle/index.mjs +99 -0
- package/dist/machines/toggle-group/index.cjs +328 -0
- package/dist/machines/toggle-group/index.d.cts +81 -0
- package/dist/machines/toggle-group/index.d.mts +81 -0
- package/dist/machines/toggle-group/index.mjs +322 -0
- package/dist/machines/tooltip/index.cjs +516 -0
- package/dist/machines/tooltip/index.d.cts +71 -0
- package/dist/machines/tooltip/index.d.mts +71 -0
- package/dist/machines/tooltip/index.mjs +512 -0
- package/dist/machines/tour/index.cjs +1108 -0
- package/dist/machines/tour/index.d.cts +206 -0
- package/dist/machines/tour/index.d.mts +206 -0
- package/dist/machines/tour/index.mjs +1101 -0
- package/dist/machines/tree-view/index.cjs +1271 -0
- package/dist/machines/tree-view/index.d.cts +215 -0
- package/dist/machines/tree-view/index.d.mts +215 -0
- package/dist/machines/tree-view/index.mjs +1263 -0
- package/dist/node-BctU8GXk.d.mts +24 -0
- package/dist/node-CSsuPZVZ.d.cts +24 -0
- package/dist/popper-BPJeAtcA.mjs +349 -0
- package/dist/popper-D0FAW_p7.cjs +373 -0
- package/dist/popper.cjs +8 -0
- package/dist/popper.d.cts +74 -0
- package/dist/popper.d.mts +2 -0
- package/dist/popper.mjs +5 -0
- package/dist/raf-BnlYUlDi.d.mts +15 -0
- package/dist/raf-Cd2FGy0z.d.cts +15 -0
- package/dist/rect-utils-0ellN0a_.mjs +854 -0
- package/dist/rect-utils-DKLRhP8G.cjs +1147 -0
- package/dist/rect-utils.cjs +51 -0
- package/dist/rect-utils.d.cts +198 -0
- package/dist/rect-utils.d.mts +198 -0
- package/dist/rect-utils.mjs +3 -0
- package/dist/remove-scroll-Lrfv79X_.mjs +58 -0
- package/dist/remove-scroll-Uvzg1L9r.cjs +63 -0
- package/dist/remove-scroll.cjs +0 -0
- package/dist/remove-scroll.d.cts +1 -0
- package/dist/remove-scroll.d.mts +1 -0
- package/dist/remove-scroll.mjs +1 -0
- package/dist/scroll-snap-CrTmQRzA.mjs +152 -0
- package/dist/scroll-snap-zyiZLv7W.cjs +175 -0
- package/dist/scroll-snap.cjs +7 -0
- package/dist/scroll-snap.d.cts +14 -0
- package/dist/scroll-snap.d.mts +14 -0
- package/dist/scroll-snap.mjs +4 -0
- package/dist/selection-BIhSzkF7.d.mts +50 -0
- package/dist/selection-CS1GBp8e.d.cts +50 -0
- package/dist/store-BZcXv49B.cjs +305 -0
- package/dist/store-DEojWy9H.mjs +263 -0
- package/dist/store.cjs +9 -0
- package/dist/store.d.cts +26 -0
- package/dist/store.d.mts +26 -0
- package/dist/store.mjs +3 -0
- package/dist/stringify-state.cjs +49 -0
- package/dist/stringify-state.d.cts +8 -0
- package/dist/stringify-state.d.mts +8 -0
- package/dist/stringify-state.mjs +46 -0
- package/dist/tree-collection-BwU5WhGQ.d.mts +78 -0
- package/dist/tree-collection-DP_eznnI.d.cts +78 -0
- package/dist/typeahead-BdNwVP09.d.cts +45 -0
- package/dist/typeahead-XN6lZ7G9.d.mts +45 -0
- package/dist/types-BivBkYg9.d.cts +57 -0
- package/dist/types-Bl_6JtPQ.d.mts +57 -0
- package/dist/types-CPUMVt7c.d.mts +54 -0
- package/dist/types-CT_W6HWr.d.cts +54 -0
- package/dist/types-DDTcG99l.d.mts +201 -0
- package/dist/types-DejIu60O.d.cts +201 -0
- package/dist/types-DiIdKZ3K.d.cts +45 -0
- package/dist/types-GxLIgJib.d.cts +17 -0
- package/dist/types.cjs +15 -0
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +14 -0
- package/dist/utils-BZyrxWWR.mjs +525 -0
- package/dist/utils-_6frwjgJ.cjs +1040 -0
- package/dist/utils.cjs +88 -0
- package/dist/utils.d.cts +144 -0
- package/dist/utils.d.mts +144 -0
- package/dist/utils.mjs +3 -0
- package/dist/wait-for-CMjPsqWk.d.cts +10 -0
- package/dist/wait-for-D2nkdD4z.d.mts +10 -0
- package/package.json +399 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { n as AnatomyInstance } from "../../create-anatomy-B3XYc-qG.mjs";
|
|
2
|
+
import { p as Machine, u as EventObject, y as Service } from "../../types-DDTcG99l.mjs";
|
|
3
|
+
import { b as NormalizeProps, g as RequiredBy, m as Rect, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-C0MKXQmE.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/machines/tabs/tabs.anatomy.d.ts
|
|
6
|
+
declare const anatomy: AnatomyInstance<"root" | "trigger" | "content" | "indicator" | "list">;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/machines/tabs/tabs.types.d.ts
|
|
9
|
+
interface ValueChangeDetails {
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
12
|
+
interface FocusChangeDetails {
|
|
13
|
+
focusedValue: string;
|
|
14
|
+
}
|
|
15
|
+
interface NavigateDetails {
|
|
16
|
+
value: string;
|
|
17
|
+
node: HTMLAnchorElement;
|
|
18
|
+
href: string;
|
|
19
|
+
}
|
|
20
|
+
interface IntlTranslations {
|
|
21
|
+
listLabel?: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
type ElementIds = Partial<{
|
|
24
|
+
root: string;
|
|
25
|
+
trigger: (value: string) => string;
|
|
26
|
+
list: string;
|
|
27
|
+
content: (value: string) => string;
|
|
28
|
+
indicator: string;
|
|
29
|
+
}>;
|
|
30
|
+
interface TabsProps extends DirectionProperty, CommonProperties {
|
|
31
|
+
ids?: ElementIds | undefined;
|
|
32
|
+
translations?: IntlTranslations | undefined;
|
|
33
|
+
loopFocus?: boolean | undefined;
|
|
34
|
+
value?: string | null | undefined;
|
|
35
|
+
defaultValue?: string | null | undefined;
|
|
36
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
37
|
+
activationMode?: "manual" | "automatic" | undefined;
|
|
38
|
+
onValueChange?: ((details: ValueChangeDetails) => void) | undefined;
|
|
39
|
+
onFocusChange?: ((details: FocusChangeDetails) => void) | undefined;
|
|
40
|
+
composite?: boolean | undefined;
|
|
41
|
+
deselectable?: boolean | undefined;
|
|
42
|
+
navigate?: ((details: NavigateDetails) => void) | null | undefined;
|
|
43
|
+
}
|
|
44
|
+
type PropsWithDefault = "orientation" | "activationMode" | "loopFocus";
|
|
45
|
+
type TabsSchema = {
|
|
46
|
+
state: "idle" | "focused";
|
|
47
|
+
props: RequiredBy<TabsProps, PropsWithDefault>;
|
|
48
|
+
context: {
|
|
49
|
+
ssr: boolean;
|
|
50
|
+
value: string | null;
|
|
51
|
+
focusedValue: string | null;
|
|
52
|
+
indicatorRect: Rect | null;
|
|
53
|
+
};
|
|
54
|
+
refs: {
|
|
55
|
+
indicatorCleanup: VoidFunction | null | undefined;
|
|
56
|
+
};
|
|
57
|
+
computed: {
|
|
58
|
+
focused: boolean;
|
|
59
|
+
};
|
|
60
|
+
action: string;
|
|
61
|
+
guard: string;
|
|
62
|
+
effect: string;
|
|
63
|
+
event: EventObject;
|
|
64
|
+
};
|
|
65
|
+
type TabsService = Service<TabsSchema>;
|
|
66
|
+
type TabsMachine = Machine<TabsSchema>;
|
|
67
|
+
interface TriggerProps {
|
|
68
|
+
value: string;
|
|
69
|
+
disabled?: boolean | undefined;
|
|
70
|
+
}
|
|
71
|
+
interface TriggerState {
|
|
72
|
+
selected: boolean;
|
|
73
|
+
focused: boolean;
|
|
74
|
+
disabled: boolean;
|
|
75
|
+
}
|
|
76
|
+
interface ContentProps {
|
|
77
|
+
value: string;
|
|
78
|
+
}
|
|
79
|
+
interface TabsApi<T extends PropTypes = PropTypes> {
|
|
80
|
+
value: string | null;
|
|
81
|
+
focusedValue: string | null;
|
|
82
|
+
setValue: (value: string) => void;
|
|
83
|
+
clearValue: VoidFunction;
|
|
84
|
+
setIndicatorRect: (value: string) => void;
|
|
85
|
+
syncTabIndex: VoidFunction;
|
|
86
|
+
focus: VoidFunction;
|
|
87
|
+
selectNext: (fromValue?: string) => void;
|
|
88
|
+
selectPrev: (fromValue?: string) => void;
|
|
89
|
+
getTriggerState: (props: TriggerProps) => TriggerState;
|
|
90
|
+
getRootProps: () => T["element"];
|
|
91
|
+
getListProps: () => T["element"];
|
|
92
|
+
getTriggerProps: (props: TriggerProps) => T["button"];
|
|
93
|
+
getContentProps: (props: ContentProps) => T["element"];
|
|
94
|
+
getIndicatorProps: () => T["element"];
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/machines/tabs/tabs.connect.d.ts
|
|
98
|
+
declare function connect<T extends PropTypes>(service: Service<TabsSchema>, normalize: NormalizeProps<T>): TabsApi<T>;
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/machines/tabs/tabs.machine.d.ts
|
|
101
|
+
declare const machine: Machine<TabsSchema>;
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/machines/tabs/tabs.props.d.ts
|
|
104
|
+
declare const props: (keyof TabsProps)[];
|
|
105
|
+
declare const splitProps: <Props extends Partial<TabsProps>>(props: Props) => [Partial<TabsProps>, Omit<Props, keyof TabsProps>];
|
|
106
|
+
declare const triggerProps: (keyof TriggerProps)[];
|
|
107
|
+
declare const splitTriggerProps: <Props extends TriggerProps>(props: Props) => [TriggerProps, Omit<Props, keyof TriggerProps>];
|
|
108
|
+
declare const contentProps: "value"[];
|
|
109
|
+
declare const splitContentProps: <Props extends ContentProps>(props: Props) => [ContentProps, Omit<Props, "value">];
|
|
110
|
+
//#endregion
|
|
111
|
+
export { type TabsApi as Api, type ContentProps, type ElementIds, type FocusChangeDetails, type IntlTranslations, type TabsMachine as Machine, type NavigateDetails, type TabsProps as Props, type TabsService as Service, type TriggerProps, type TriggerState, type ValueChangeDetails, anatomy, connect, contentProps, machine, props, splitContentProps, splitProps, splitTriggerProps, triggerProps };
|
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
import { t as createAnatomy } from "../../create-anatomy-BbDZbHpC.mjs";
|
|
2
|
+
import { I as clickIfLink, J as getFocusables, Rt as isSafari, S as queryAll, U as raf, Xt as contains, an as isAnchorElement, b as prevById, ft as getEventTarget, lt as getEventKey, mt as isComposingEvent, p as resizeObserverBorderBox, v as itemById, vn as dataAttr, xt as isOpeningInNewTab, y as nextById } from "../../dom-query-DFCRhyj1.mjs";
|
|
3
|
+
import { Ct as last, H as toPx, W as callAll, _t as first, dt as isEqual, u as createSplitProps } from "../../utils-BZyrxWWR.mjs";
|
|
4
|
+
import { o as setup } from "../../core-DCFNMTZF.mjs";
|
|
5
|
+
import { t as createProps } from "../../create-props-BnF_vl-E.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/machines/tabs/tabs.anatomy.ts
|
|
8
|
+
const anatomy = createAnatomy("tabs").parts("root", "list", "trigger", "content", "indicator");
|
|
9
|
+
const parts = anatomy.build();
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/machines/tabs/tabs.dom.ts
|
|
13
|
+
const getRootId = (ctx) => ctx.ids?.root ?? `tabs:${ctx.id}`;
|
|
14
|
+
const getListId = (ctx) => ctx.ids?.list ?? `tabs:${ctx.id}:list`;
|
|
15
|
+
const getContentId = (ctx, value) => ctx.ids?.content?.(value) ?? `tabs:${ctx.id}:content:${value}`;
|
|
16
|
+
const getTriggerId = (ctx, value) => ctx.ids?.trigger?.(value) ?? `tabs:${ctx.id}:trigger:${value}`;
|
|
17
|
+
const getIndicatorId = (ctx) => ctx.ids?.indicator ?? `tabs:${ctx.id}:indicator`;
|
|
18
|
+
const getListEl = (ctx) => ctx.getById(getListId(ctx));
|
|
19
|
+
const getContentEl = (ctx, value) => ctx.getById(getContentId(ctx, value));
|
|
20
|
+
const getTriggerEl = (ctx, value) => value != null ? ctx.getById(getTriggerId(ctx, value)) : null;
|
|
21
|
+
const getIndicatorEl = (ctx) => ctx.getById(getIndicatorId(ctx));
|
|
22
|
+
const getElements = (ctx) => {
|
|
23
|
+
const selector = `[role=tab][data-ownedby='${CSS.escape(getListId(ctx))}']:not([disabled])`;
|
|
24
|
+
return queryAll(getListEl(ctx), selector);
|
|
25
|
+
};
|
|
26
|
+
const getFirstTriggerEl = (ctx) => first(getElements(ctx));
|
|
27
|
+
const getLastTriggerEl = (ctx) => last(getElements(ctx));
|
|
28
|
+
const getNextTriggerEl = (ctx, opts) => nextById(getElements(ctx), getTriggerId(ctx, opts.value), opts.loopFocus);
|
|
29
|
+
const getPrevTriggerEl = (ctx, opts) => prevById(getElements(ctx), getTriggerId(ctx, opts.value), opts.loopFocus);
|
|
30
|
+
const getOffsetRect = (el) => ({
|
|
31
|
+
x: el?.offsetLeft ?? 0,
|
|
32
|
+
y: el?.offsetTop ?? 0,
|
|
33
|
+
width: el?.offsetWidth ?? 0,
|
|
34
|
+
height: el?.offsetHeight ?? 0
|
|
35
|
+
});
|
|
36
|
+
const getRectByValue = (ctx, value) => {
|
|
37
|
+
return getOffsetRect(itemById(getElements(ctx), getTriggerId(ctx, value)));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/machines/tabs/tabs.connect.ts
|
|
42
|
+
function connect(service, normalize) {
|
|
43
|
+
const { state, send, context, prop, scope } = service;
|
|
44
|
+
const translations = prop("translations");
|
|
45
|
+
const focused = state.matches("focused");
|
|
46
|
+
const isVertical = prop("orientation") === "vertical";
|
|
47
|
+
const isHorizontal = prop("orientation") === "horizontal";
|
|
48
|
+
const composite = prop("composite");
|
|
49
|
+
function getTriggerState(props$1) {
|
|
50
|
+
return {
|
|
51
|
+
selected: context.get("value") === props$1.value,
|
|
52
|
+
focused: context.get("focusedValue") === props$1.value,
|
|
53
|
+
disabled: !!props$1.disabled
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
value: context.get("value"),
|
|
58
|
+
focusedValue: context.get("focusedValue"),
|
|
59
|
+
setValue(value) {
|
|
60
|
+
send({
|
|
61
|
+
type: "SET_VALUE",
|
|
62
|
+
value
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
clearValue() {
|
|
66
|
+
send({ type: "CLEAR_VALUE" });
|
|
67
|
+
},
|
|
68
|
+
setIndicatorRect(value) {
|
|
69
|
+
send({
|
|
70
|
+
type: "SET_INDICATOR_RECT",
|
|
71
|
+
id: getTriggerId(scope, value)
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
syncTabIndex() {
|
|
75
|
+
send({ type: "SYNC_TAB_INDEX" });
|
|
76
|
+
},
|
|
77
|
+
selectNext(fromValue) {
|
|
78
|
+
send({
|
|
79
|
+
type: "TAB_FOCUS",
|
|
80
|
+
value: fromValue,
|
|
81
|
+
src: "selectNext"
|
|
82
|
+
});
|
|
83
|
+
send({
|
|
84
|
+
type: "ARROW_NEXT",
|
|
85
|
+
src: "selectNext"
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
selectPrev(fromValue) {
|
|
89
|
+
send({
|
|
90
|
+
type: "TAB_FOCUS",
|
|
91
|
+
value: fromValue,
|
|
92
|
+
src: "selectPrev"
|
|
93
|
+
});
|
|
94
|
+
send({
|
|
95
|
+
type: "ARROW_PREV",
|
|
96
|
+
src: "selectPrev"
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
focus() {
|
|
100
|
+
const value = context.get("value");
|
|
101
|
+
if (!value) return;
|
|
102
|
+
getTriggerEl(scope, value)?.focus();
|
|
103
|
+
},
|
|
104
|
+
getRootProps() {
|
|
105
|
+
return normalize.element({
|
|
106
|
+
...parts.root.attrs,
|
|
107
|
+
id: getRootId(scope),
|
|
108
|
+
"data-orientation": prop("orientation"),
|
|
109
|
+
"data-focus": dataAttr(focused),
|
|
110
|
+
dir: prop("dir")
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
getListProps() {
|
|
114
|
+
return normalize.element({
|
|
115
|
+
...parts.list.attrs,
|
|
116
|
+
id: getListId(scope),
|
|
117
|
+
role: "tablist",
|
|
118
|
+
dir: prop("dir"),
|
|
119
|
+
"data-focus": dataAttr(focused),
|
|
120
|
+
"aria-orientation": prop("orientation"),
|
|
121
|
+
"data-orientation": prop("orientation"),
|
|
122
|
+
"aria-label": translations?.listLabel,
|
|
123
|
+
onKeyDown(event) {
|
|
124
|
+
if (event.defaultPrevented) return;
|
|
125
|
+
if (isComposingEvent(event)) return;
|
|
126
|
+
if (!contains(event.currentTarget, getEventTarget(event))) return;
|
|
127
|
+
const exec = {
|
|
128
|
+
ArrowDown() {
|
|
129
|
+
if (isHorizontal) return;
|
|
130
|
+
send({
|
|
131
|
+
type: "ARROW_NEXT",
|
|
132
|
+
key: "ArrowDown"
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
ArrowUp() {
|
|
136
|
+
if (isHorizontal) return;
|
|
137
|
+
send({
|
|
138
|
+
type: "ARROW_PREV",
|
|
139
|
+
key: "ArrowUp"
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
ArrowLeft() {
|
|
143
|
+
if (isVertical) return;
|
|
144
|
+
send({
|
|
145
|
+
type: "ARROW_PREV",
|
|
146
|
+
key: "ArrowLeft"
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
ArrowRight() {
|
|
150
|
+
if (isVertical) return;
|
|
151
|
+
send({
|
|
152
|
+
type: "ARROW_NEXT",
|
|
153
|
+
key: "ArrowRight"
|
|
154
|
+
});
|
|
155
|
+
},
|
|
156
|
+
Home() {
|
|
157
|
+
send({ type: "HOME" });
|
|
158
|
+
},
|
|
159
|
+
End() {
|
|
160
|
+
send({ type: "END" });
|
|
161
|
+
}
|
|
162
|
+
}[getEventKey(event, {
|
|
163
|
+
dir: prop("dir"),
|
|
164
|
+
orientation: prop("orientation")
|
|
165
|
+
})];
|
|
166
|
+
if (exec) {
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
exec(event);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
getTriggerState,
|
|
175
|
+
getTriggerProps(props$1) {
|
|
176
|
+
const { value, disabled } = props$1;
|
|
177
|
+
const triggerState = getTriggerState(props$1);
|
|
178
|
+
return normalize.button({
|
|
179
|
+
...parts.trigger.attrs,
|
|
180
|
+
role: "tab",
|
|
181
|
+
type: "button",
|
|
182
|
+
disabled,
|
|
183
|
+
dir: prop("dir"),
|
|
184
|
+
"data-orientation": prop("orientation"),
|
|
185
|
+
"data-disabled": dataAttr(disabled),
|
|
186
|
+
"aria-disabled": disabled,
|
|
187
|
+
"data-value": value,
|
|
188
|
+
"aria-selected": triggerState.selected,
|
|
189
|
+
"data-selected": dataAttr(triggerState.selected),
|
|
190
|
+
"data-focus": dataAttr(triggerState.focused),
|
|
191
|
+
"aria-controls": triggerState.selected ? getContentId(scope, value) : void 0,
|
|
192
|
+
"data-ownedby": getListId(scope),
|
|
193
|
+
"data-ssr": dataAttr(context.get("ssr")),
|
|
194
|
+
id: getTriggerId(scope, value),
|
|
195
|
+
tabIndex: triggerState.selected && composite ? 0 : -1,
|
|
196
|
+
onFocus() {
|
|
197
|
+
send({
|
|
198
|
+
type: "TAB_FOCUS",
|
|
199
|
+
value
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
onBlur(event) {
|
|
203
|
+
if (event.relatedTarget?.getAttribute("role") !== "tab") send({ type: "TAB_BLUR" });
|
|
204
|
+
},
|
|
205
|
+
onClick(event) {
|
|
206
|
+
if (event.defaultPrevented) return;
|
|
207
|
+
if (isOpeningInNewTab(event)) return;
|
|
208
|
+
if (disabled) return;
|
|
209
|
+
if (isSafari()) event.currentTarget.focus();
|
|
210
|
+
send({
|
|
211
|
+
type: "TAB_CLICK",
|
|
212
|
+
value
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
getContentProps(props$1) {
|
|
218
|
+
const { value } = props$1;
|
|
219
|
+
const selected = context.get("value") === value;
|
|
220
|
+
return normalize.element({
|
|
221
|
+
...parts.content.attrs,
|
|
222
|
+
dir: prop("dir"),
|
|
223
|
+
id: getContentId(scope, value),
|
|
224
|
+
tabIndex: composite ? 0 : -1,
|
|
225
|
+
"aria-labelledby": getTriggerId(scope, value),
|
|
226
|
+
role: "tabpanel",
|
|
227
|
+
"data-ownedby": getListId(scope),
|
|
228
|
+
"data-selected": dataAttr(selected),
|
|
229
|
+
"data-orientation": prop("orientation"),
|
|
230
|
+
hidden: !selected
|
|
231
|
+
});
|
|
232
|
+
},
|
|
233
|
+
getIndicatorProps() {
|
|
234
|
+
const rect = context.get("indicatorRect");
|
|
235
|
+
const rectIsEmpty = rect == null || rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0;
|
|
236
|
+
return normalize.element({
|
|
237
|
+
id: getIndicatorId(scope),
|
|
238
|
+
...parts.indicator.attrs,
|
|
239
|
+
dir: prop("dir"),
|
|
240
|
+
"data-orientation": prop("orientation"),
|
|
241
|
+
hidden: rectIsEmpty,
|
|
242
|
+
style: {
|
|
243
|
+
"--transition-property": "left, right, top, bottom, width, height",
|
|
244
|
+
"--left": toPx(rect?.x),
|
|
245
|
+
"--top": toPx(rect?.y),
|
|
246
|
+
"--width": toPx(rect?.width),
|
|
247
|
+
"--height": toPx(rect?.height),
|
|
248
|
+
position: "absolute",
|
|
249
|
+
willChange: "var(--transition-property)",
|
|
250
|
+
transitionProperty: "var(--transition-property)",
|
|
251
|
+
transitionDuration: "var(--transition-duration, 150ms)",
|
|
252
|
+
transitionTimingFunction: "var(--transition-timing-function)",
|
|
253
|
+
[isHorizontal ? "left" : "top"]: isHorizontal ? "var(--left)" : "var(--top)"
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/machines/tabs/tabs.machine.ts
|
|
262
|
+
const { createMachine } = setup();
|
|
263
|
+
const machine = createMachine({
|
|
264
|
+
props({ props: props$1 }) {
|
|
265
|
+
return {
|
|
266
|
+
dir: "ltr",
|
|
267
|
+
orientation: "horizontal",
|
|
268
|
+
activationMode: "automatic",
|
|
269
|
+
loopFocus: true,
|
|
270
|
+
composite: true,
|
|
271
|
+
navigate(details) {
|
|
272
|
+
clickIfLink(details.node);
|
|
273
|
+
},
|
|
274
|
+
defaultValue: null,
|
|
275
|
+
...props$1
|
|
276
|
+
};
|
|
277
|
+
},
|
|
278
|
+
initialState() {
|
|
279
|
+
return "idle";
|
|
280
|
+
},
|
|
281
|
+
context({ prop, bindable }) {
|
|
282
|
+
return {
|
|
283
|
+
value: bindable(() => ({
|
|
284
|
+
defaultValue: prop("defaultValue"),
|
|
285
|
+
value: prop("value"),
|
|
286
|
+
onChange(value) {
|
|
287
|
+
prop("onValueChange")?.({ value });
|
|
288
|
+
}
|
|
289
|
+
})),
|
|
290
|
+
focusedValue: bindable(() => ({
|
|
291
|
+
defaultValue: prop("value") || prop("defaultValue"),
|
|
292
|
+
sync: true,
|
|
293
|
+
onChange(value) {
|
|
294
|
+
prop("onFocusChange")?.({ focusedValue: value });
|
|
295
|
+
}
|
|
296
|
+
})),
|
|
297
|
+
ssr: bindable(() => ({ defaultValue: true })),
|
|
298
|
+
indicatorRect: bindable(() => ({ defaultValue: null }))
|
|
299
|
+
};
|
|
300
|
+
},
|
|
301
|
+
watch({ context, prop, track, action }) {
|
|
302
|
+
track([() => context.get("value")], () => {
|
|
303
|
+
action([
|
|
304
|
+
"syncIndicatorRect",
|
|
305
|
+
"syncTabIndex",
|
|
306
|
+
"navigateIfNeeded"
|
|
307
|
+
]);
|
|
308
|
+
});
|
|
309
|
+
track([() => prop("dir"), () => prop("orientation")], () => {
|
|
310
|
+
action(["syncIndicatorRect"]);
|
|
311
|
+
});
|
|
312
|
+
},
|
|
313
|
+
on: {
|
|
314
|
+
SET_VALUE: { actions: ["setValue"] },
|
|
315
|
+
CLEAR_VALUE: { actions: ["clearValue"] },
|
|
316
|
+
SET_INDICATOR_RECT: { actions: ["setIndicatorRect"] },
|
|
317
|
+
SYNC_TAB_INDEX: { actions: ["syncTabIndex"] }
|
|
318
|
+
},
|
|
319
|
+
entry: [
|
|
320
|
+
"syncIndicatorRect",
|
|
321
|
+
"syncTabIndex",
|
|
322
|
+
"syncSsr"
|
|
323
|
+
],
|
|
324
|
+
exit: ["cleanupObserver"],
|
|
325
|
+
states: {
|
|
326
|
+
idle: { on: {
|
|
327
|
+
TAB_FOCUS: {
|
|
328
|
+
target: "focused",
|
|
329
|
+
actions: ["setFocusedValue"]
|
|
330
|
+
},
|
|
331
|
+
TAB_CLICK: {
|
|
332
|
+
target: "focused",
|
|
333
|
+
actions: ["setFocusedValue", "setValue"]
|
|
334
|
+
}
|
|
335
|
+
} },
|
|
336
|
+
focused: { on: {
|
|
337
|
+
TAB_CLICK: { actions: ["setFocusedValue", "setValue"] },
|
|
338
|
+
ARROW_PREV: [{
|
|
339
|
+
guard: "selectOnFocus",
|
|
340
|
+
actions: ["focusPrevTab", "selectFocusedTab"]
|
|
341
|
+
}, { actions: ["focusPrevTab"] }],
|
|
342
|
+
ARROW_NEXT: [{
|
|
343
|
+
guard: "selectOnFocus",
|
|
344
|
+
actions: ["focusNextTab", "selectFocusedTab"]
|
|
345
|
+
}, { actions: ["focusNextTab"] }],
|
|
346
|
+
HOME: [{
|
|
347
|
+
guard: "selectOnFocus",
|
|
348
|
+
actions: ["focusFirstTab", "selectFocusedTab"]
|
|
349
|
+
}, { actions: ["focusFirstTab"] }],
|
|
350
|
+
END: [{
|
|
351
|
+
guard: "selectOnFocus",
|
|
352
|
+
actions: ["focusLastTab", "selectFocusedTab"]
|
|
353
|
+
}, { actions: ["focusLastTab"] }],
|
|
354
|
+
TAB_FOCUS: { actions: ["setFocusedValue"] },
|
|
355
|
+
TAB_BLUR: {
|
|
356
|
+
target: "idle",
|
|
357
|
+
actions: ["clearFocusedValue"]
|
|
358
|
+
}
|
|
359
|
+
} }
|
|
360
|
+
},
|
|
361
|
+
implementations: {
|
|
362
|
+
guards: { selectOnFocus: ({ prop }) => prop("activationMode") === "automatic" },
|
|
363
|
+
actions: {
|
|
364
|
+
selectFocusedTab({ context, prop }) {
|
|
365
|
+
raf(() => {
|
|
366
|
+
const focusedValue = context.get("focusedValue");
|
|
367
|
+
if (!focusedValue) return;
|
|
368
|
+
const value = prop("deselectable") && context.get("value") === focusedValue ? null : focusedValue;
|
|
369
|
+
context.set("value", value);
|
|
370
|
+
});
|
|
371
|
+
},
|
|
372
|
+
setFocusedValue({ context, event, flush }) {
|
|
373
|
+
if (event.value == null) return;
|
|
374
|
+
flush(() => {
|
|
375
|
+
context.set("focusedValue", event.value);
|
|
376
|
+
});
|
|
377
|
+
},
|
|
378
|
+
clearFocusedValue({ context }) {
|
|
379
|
+
context.set("focusedValue", null);
|
|
380
|
+
},
|
|
381
|
+
setValue({ context, event, prop }) {
|
|
382
|
+
const nullable = prop("deselectable") && context.get("value") === context.get("focusedValue");
|
|
383
|
+
context.set("value", nullable ? null : event.value);
|
|
384
|
+
},
|
|
385
|
+
clearValue({ context }) {
|
|
386
|
+
context.set("value", null);
|
|
387
|
+
},
|
|
388
|
+
focusFirstTab({ scope }) {
|
|
389
|
+
raf(() => {
|
|
390
|
+
getFirstTriggerEl(scope)?.focus();
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
focusLastTab({ scope }) {
|
|
394
|
+
raf(() => {
|
|
395
|
+
getLastTriggerEl(scope)?.focus();
|
|
396
|
+
});
|
|
397
|
+
},
|
|
398
|
+
focusNextTab({ context, prop, scope, event }) {
|
|
399
|
+
const focusedValue = event.value ?? context.get("focusedValue");
|
|
400
|
+
if (!focusedValue) return;
|
|
401
|
+
const triggerEl = getNextTriggerEl(scope, {
|
|
402
|
+
value: focusedValue,
|
|
403
|
+
loopFocus: prop("loopFocus")
|
|
404
|
+
});
|
|
405
|
+
raf(() => {
|
|
406
|
+
if (prop("composite")) triggerEl?.focus();
|
|
407
|
+
else if (triggerEl?.dataset.value != null) context.set("focusedValue", triggerEl.dataset.value);
|
|
408
|
+
});
|
|
409
|
+
},
|
|
410
|
+
focusPrevTab({ context, prop, scope, event }) {
|
|
411
|
+
const focusedValue = event.value ?? context.get("focusedValue");
|
|
412
|
+
if (!focusedValue) return;
|
|
413
|
+
const triggerEl = getPrevTriggerEl(scope, {
|
|
414
|
+
value: focusedValue,
|
|
415
|
+
loopFocus: prop("loopFocus")
|
|
416
|
+
});
|
|
417
|
+
raf(() => {
|
|
418
|
+
if (prop("composite")) triggerEl?.focus();
|
|
419
|
+
else if (triggerEl?.dataset.value != null) context.set("focusedValue", triggerEl.dataset.value);
|
|
420
|
+
});
|
|
421
|
+
},
|
|
422
|
+
syncTabIndex({ context, scope }) {
|
|
423
|
+
raf(() => {
|
|
424
|
+
const value = context.get("value");
|
|
425
|
+
if (!value) return;
|
|
426
|
+
const contentEl = getContentEl(scope, value);
|
|
427
|
+
if (!contentEl) return;
|
|
428
|
+
if (getFocusables(contentEl).length > 0) contentEl.removeAttribute("tabindex");
|
|
429
|
+
else contentEl.setAttribute("tabindex", "0");
|
|
430
|
+
});
|
|
431
|
+
},
|
|
432
|
+
cleanupObserver({ refs }) {
|
|
433
|
+
const cleanup = refs.get("indicatorCleanup");
|
|
434
|
+
if (cleanup) cleanup();
|
|
435
|
+
},
|
|
436
|
+
setIndicatorRect({ context, event, scope }) {
|
|
437
|
+
const value = event.id ?? context.get("value");
|
|
438
|
+
if (!getIndicatorEl(scope)) return;
|
|
439
|
+
if (!value) return;
|
|
440
|
+
if (!getTriggerEl(scope, value)) return;
|
|
441
|
+
context.set("indicatorRect", getRectByValue(scope, value));
|
|
442
|
+
},
|
|
443
|
+
syncSsr({ context }) {
|
|
444
|
+
context.set("ssr", false);
|
|
445
|
+
},
|
|
446
|
+
syncIndicatorRect({ context, refs, scope }) {
|
|
447
|
+
const cleanup = refs.get("indicatorCleanup");
|
|
448
|
+
if (cleanup) cleanup();
|
|
449
|
+
if (!getIndicatorEl(scope)) return;
|
|
450
|
+
const exec = () => {
|
|
451
|
+
const triggerEl = getTriggerEl(scope, context.get("value"));
|
|
452
|
+
if (!triggerEl) return;
|
|
453
|
+
const rect = getOffsetRect(triggerEl);
|
|
454
|
+
context.set("indicatorRect", (prev) => isEqual(prev, rect) ? prev : rect);
|
|
455
|
+
};
|
|
456
|
+
exec();
|
|
457
|
+
const indicatorCleanup = callAll(...getElements(scope).map((el) => resizeObserverBorderBox.observe(el, exec)));
|
|
458
|
+
refs.set("indicatorCleanup", indicatorCleanup);
|
|
459
|
+
},
|
|
460
|
+
navigateIfNeeded({ context, prop, scope }) {
|
|
461
|
+
const value = context.get("value");
|
|
462
|
+
if (!value) return;
|
|
463
|
+
const triggerEl = getTriggerEl(scope, value);
|
|
464
|
+
if (isAnchorElement(triggerEl)) prop("navigate")?.({
|
|
465
|
+
value,
|
|
466
|
+
node: triggerEl,
|
|
467
|
+
href: triggerEl.href
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
//#endregion
|
|
475
|
+
//#region src/machines/tabs/tabs.props.ts
|
|
476
|
+
const props = createProps()([
|
|
477
|
+
"activationMode",
|
|
478
|
+
"composite",
|
|
479
|
+
"deselectable",
|
|
480
|
+
"dir",
|
|
481
|
+
"getRootNode",
|
|
482
|
+
"id",
|
|
483
|
+
"ids",
|
|
484
|
+
"loopFocus",
|
|
485
|
+
"navigate",
|
|
486
|
+
"onFocusChange",
|
|
487
|
+
"onValueChange",
|
|
488
|
+
"orientation",
|
|
489
|
+
"translations",
|
|
490
|
+
"value",
|
|
491
|
+
"defaultValue"
|
|
492
|
+
]);
|
|
493
|
+
const splitProps = createSplitProps(props);
|
|
494
|
+
const triggerProps = createProps()(["disabled", "value"]);
|
|
495
|
+
const splitTriggerProps = createSplitProps(triggerProps);
|
|
496
|
+
const contentProps = createProps()(["value"]);
|
|
497
|
+
const splitContentProps = createSplitProps(contentProps);
|
|
498
|
+
|
|
499
|
+
//#endregion
|
|
500
|
+
export { anatomy, connect, contentProps, machine, props, splitContentProps, splitProps, splitTriggerProps, triggerProps };
|