@42-central/ui-react 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-YWTOW7PZ.js → chunk-276RL7FX.js} +10 -10
- package/dist/{chunk-YWTOW7PZ.js.map → chunk-276RL7FX.js.map} +1 -1
- package/dist/{chunk-FUNTJZX7.js → chunk-2CL3FKEY.js} +3 -3
- package/dist/{chunk-FUNTJZX7.js.map → chunk-2CL3FKEY.js.map} +1 -1
- package/dist/{chunk-YPFSRZ3T.js → chunk-2NTCQIRP.js} +5 -5
- package/dist/{chunk-YPFSRZ3T.js.map → chunk-2NTCQIRP.js.map} +1 -1
- package/dist/{chunk-D3JYDAUZ.js → chunk-2TZU4LSX.js} +4 -4
- package/dist/{chunk-D3JYDAUZ.js.map → chunk-2TZU4LSX.js.map} +1 -1
- package/dist/{chunk-DJLNGWMM.js → chunk-6IRMKF5T.js} +3 -3
- package/dist/{chunk-DJLNGWMM.js.map → chunk-6IRMKF5T.js.map} +1 -1
- package/dist/{chunk-DT6LKNZF.js → chunk-7247WBTV.js} +5 -4
- package/dist/chunk-7247WBTV.js.map +1 -0
- package/dist/{chunk-F2FSHVO5.js → chunk-7B44J3CF.js} +7 -7
- package/dist/{chunk-F2FSHVO5.js.map → chunk-7B44J3CF.js.map} +1 -1
- package/dist/{chunk-6VYGK3Q3.js → chunk-7E7JNWOC.js} +16 -21
- package/dist/chunk-7E7JNWOC.js.map +1 -0
- package/dist/{chunk-7AQ4MN4M.js → chunk-7OGZT7U2.js} +14 -6
- package/dist/chunk-7OGZT7U2.js.map +1 -0
- package/dist/{chunk-UAYENYS2.js → chunk-AKXALCUN.js} +3 -3
- package/dist/{chunk-UAYENYS2.js.map → chunk-AKXALCUN.js.map} +1 -1
- package/dist/{chunk-BE2LWUHY.js → chunk-BMEJBY6H.js} +5 -3
- package/dist/chunk-BMEJBY6H.js.map +1 -0
- package/dist/{chunk-DHJB4UJD.js → chunk-DMI4KS32.js} +5 -5
- package/dist/{chunk-DHJB4UJD.js.map → chunk-DMI4KS32.js.map} +1 -1
- package/dist/{chunk-FB2G4LNH.js → chunk-DSZF2TW6.js} +7 -7
- package/dist/{chunk-FB2G4LNH.js.map → chunk-DSZF2TW6.js.map} +1 -1
- package/dist/{chunk-N66NC6QK.js → chunk-E3XLWMEB.js} +3 -3
- package/dist/{chunk-N66NC6QK.js.map → chunk-E3XLWMEB.js.map} +1 -1
- package/dist/{chunk-MXAACRWE.js → chunk-E52Z2FKU.js} +5 -5
- package/dist/{chunk-MXAACRWE.js.map → chunk-E52Z2FKU.js.map} +1 -1
- package/dist/chunk-F374BNL4.js +129 -0
- package/dist/chunk-F374BNL4.js.map +1 -0
- package/dist/{chunk-3L5GLI67.js → chunk-I4B3N3UX.js} +3 -3
- package/dist/{chunk-3L5GLI67.js.map → chunk-I4B3N3UX.js.map} +1 -1
- package/dist/{chunk-IPYHTCFL.js → chunk-IUK7OJXZ.js} +3 -3
- package/dist/{chunk-IPYHTCFL.js.map → chunk-IUK7OJXZ.js.map} +1 -1
- package/dist/{chunk-HRNWWL3Y.js → chunk-J2NW7JID.js} +61 -29
- package/dist/chunk-J2NW7JID.js.map +1 -0
- package/dist/{chunk-MRAJ45IM.js → chunk-JDPVD2YE.js} +5 -5
- package/dist/{chunk-MRAJ45IM.js.map → chunk-JDPVD2YE.js.map} +1 -1
- package/dist/{chunk-SZEOTXRZ.js → chunk-JFB6O7IY.js} +5 -5
- package/dist/{chunk-SZEOTXRZ.js.map → chunk-JFB6O7IY.js.map} +1 -1
- package/dist/{chunk-2MXWEIMD.js → chunk-KKLCHLCZ.js} +12 -11
- package/dist/chunk-KKLCHLCZ.js.map +1 -0
- package/dist/{chunk-6N6J2DOE.js → chunk-LIZWCWED.js} +3 -3
- package/dist/{chunk-6N6J2DOE.js.map → chunk-LIZWCWED.js.map} +1 -1
- package/dist/chunk-LJVIZNPE.js +9 -0
- package/dist/chunk-LJVIZNPE.js.map +1 -0
- package/dist/{chunk-HQPU73WV.js → chunk-LYGOFMXJ.js} +3 -3
- package/dist/{chunk-HQPU73WV.js.map → chunk-LYGOFMXJ.js.map} +1 -1
- package/dist/{chunk-JVG5ISPT.js → chunk-N42EFOML.js} +4 -4
- package/dist/{chunk-JVG5ISPT.js.map → chunk-N42EFOML.js.map} +1 -1
- package/dist/{chunk-C4NFRSOR.js → chunk-NF2PBGD3.js} +38 -25
- package/dist/chunk-NF2PBGD3.js.map +1 -0
- package/dist/{chunk-DA4QII2N.js → chunk-NLSJ6T7V.js} +4 -4
- package/dist/{chunk-DA4QII2N.js.map → chunk-NLSJ6T7V.js.map} +1 -1
- package/dist/{chunk-UT3TOV2Q.js → chunk-OVT2KZHY.js} +3 -3
- package/dist/{chunk-UT3TOV2Q.js.map → chunk-OVT2KZHY.js.map} +1 -1
- package/dist/{chunk-MW42XVPD.js → chunk-PBSVX5DB.js} +15 -5
- package/dist/chunk-PBSVX5DB.js.map +1 -0
- package/dist/{chunk-SVKN5ZHX.js → chunk-PEHFWGTT.js} +16 -13
- package/dist/chunk-PEHFWGTT.js.map +1 -0
- package/dist/{chunk-J44FJ7PH.js → chunk-PFZMB3US.js} +4 -4
- package/dist/{chunk-J44FJ7PH.js.map → chunk-PFZMB3US.js.map} +1 -1
- package/dist/{chunk-IRNF274I.js → chunk-PT22KEVD.js} +5 -5
- package/dist/{chunk-IRNF274I.js.map → chunk-PT22KEVD.js.map} +1 -1
- package/dist/{chunk-OZMSXYBX.js → chunk-QEAF57ZQ.js} +4 -4
- package/dist/{chunk-OZMSXYBX.js.map → chunk-QEAF57ZQ.js.map} +1 -1
- package/dist/{chunk-SWVUXEBT.js → chunk-SCXXJDKQ.js} +3 -3
- package/dist/{chunk-SWVUXEBT.js.map → chunk-SCXXJDKQ.js.map} +1 -1
- package/dist/{chunk-E5H3YWZV.js → chunk-SOUDKESO.js} +15 -8
- package/dist/chunk-SOUDKESO.js.map +1 -0
- package/dist/{chunk-4FEOMQYR.js → chunk-THGJLR5S.js} +6 -6
- package/dist/{chunk-4FEOMQYR.js.map → chunk-THGJLR5S.js.map} +1 -1
- package/dist/{chunk-TCFB23JT.js → chunk-WERJ44ZN.js} +3 -3
- package/dist/{chunk-TCFB23JT.js.map → chunk-WERJ44ZN.js.map} +1 -1
- package/dist/{chunk-QNKD2SQM.js → chunk-X3YIHN2U.js} +5 -5
- package/dist/{chunk-QNKD2SQM.js.map → chunk-X3YIHN2U.js.map} +1 -1
- package/dist/{chunk-VD6PB3VA.js → chunk-X6DESK37.js} +12 -3
- package/dist/chunk-X6DESK37.js.map +1 -0
- package/dist/{chunk-47LEAR6G.js → chunk-Y2G47ARQ.js} +6 -6
- package/dist/{chunk-47LEAR6G.js.map → chunk-Y2G47ARQ.js.map} +1 -1
- package/dist/{chunk-O7LS6OZR.js → chunk-YMVUQ2L7.js} +4 -4
- package/dist/{chunk-O7LS6OZR.js.map → chunk-YMVUQ2L7.js.map} +1 -1
- package/dist/{chunk-F342ZT7O.js → chunk-ZVECQBGG.js} +13 -7
- package/dist/chunk-ZVECQBGG.js.map +1 -0
- package/dist/components/action-icon/action-icon.d.ts.map +1 -1
- package/dist/components/action-icon/index.js +1 -1
- package/dist/components/alert/index.js +1 -1
- package/dist/components/ambient-background/index.js +14 -26
- package/dist/components/ambient-background/index.js.map +1 -1
- package/dist/components/ambient-background/starfield.d.ts.map +1 -1
- package/dist/components/app-shell/app-shell.d.ts +55 -10
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/index.d.ts +1 -1
- package/dist/components/app-shell/index.d.ts.map +1 -1
- package/dist/components/app-shell/index.js +300 -39
- package/dist/components/app-shell/index.js.map +1 -1
- package/dist/components/autocomplete/index.js +5 -5
- package/dist/components/avatar/avatar.d.ts +1 -1
- package/dist/components/avatar/avatar.d.ts.map +1 -1
- package/dist/components/avatar/index.js +12 -3
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge/index.js +1 -1
- package/dist/components/button/index.js +1 -1
- package/dist/components/button-group/button-group.d.ts +10 -2
- package/dist/components/button-group/button-group.d.ts.map +1 -1
- package/dist/components/button-group/index.js +1 -1
- package/dist/components/button-multi-select/index.js +4 -4
- package/dist/components/button-select/button-select-control.d.ts +4 -1
- package/dist/components/button-select/button-select-control.d.ts.map +1 -1
- package/dist/components/button-select/button-select.d.ts +4 -1
- package/dist/components/button-select/button-select.d.ts.map +1 -1
- package/dist/components/button-select/index.js +4 -4
- package/dist/components/calendar/index.js +4 -4
- package/dist/components/calendar-heatmap/index.js +2 -2
- package/dist/components/camera/index.js +12 -12
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/index.js +1 -1
- package/dist/components/carousel/index.js +2 -2
- package/dist/components/checkbox/checkbox.d.ts +3 -2
- package/dist/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/index.js +2 -2
- package/dist/components/choice-card-group/index.js +2 -2
- package/dist/components/choice-card-group/index.js.map +1 -1
- package/dist/components/clipboard/index.js +3 -3
- package/dist/components/code-block/chrome.js +3 -3
- package/dist/components/code-block/code-block.d.ts +6 -3
- package/dist/components/code-block/code-block.d.ts.map +1 -1
- package/dist/components/code-block/highlighter.d.ts +16 -15
- package/dist/components/code-block/highlighter.d.ts.map +1 -1
- package/dist/components/code-block/index.d.ts +2 -1
- package/dist/components/code-block/index.d.ts.map +1 -1
- package/dist/components/code-block/index.js +85 -14
- package/dist/components/code-block/index.js.map +1 -1
- package/dist/components/code-block/languages.d.ts +61 -0
- package/dist/components/code-block/languages.d.ts.map +1 -0
- package/dist/components/code-block/static.d.ts +2 -1
- package/dist/components/code-block/static.d.ts.map +1 -1
- package/dist/components/code-block/static.js +99 -10
- package/dist/components/code-block/static.js.map +1 -1
- package/dist/components/combobox/index.js +5 -5
- package/dist/components/combobox-list/index.js +7 -7
- package/dist/components/compare/index.js +2 -2
- package/dist/components/data-table/index.js +32 -32
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/date-picker/index.js +14 -14
- package/dist/components/download-button/index.js +2 -2
- package/dist/components/drawer/index.js +5 -5
- package/dist/components/field/field.d.ts +3 -0
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/index.js +1 -1
- package/dist/components/file-item/index.js +5 -5
- package/dist/components/file-preview/index.js +5 -5
- package/dist/components/file-trigger/index.js +2 -2
- package/dist/components/file-upload/index.js +6 -6
- package/dist/components/gallery/index.js +2 -2
- package/dist/components/geodesic/badge-frame.d.ts +13 -1
- package/dist/components/geodesic/badge-frame.d.ts.map +1 -1
- package/dist/components/geodesic/exam-badge.d.ts +4 -1
- package/dist/components/geodesic/exam-badge.d.ts.map +1 -1
- package/dist/components/geodesic/geometry.d.ts +14 -9
- package/dist/components/geodesic/geometry.d.ts.map +1 -1
- package/dist/components/geodesic/index.js +62 -23
- package/dist/components/geodesic/index.js.map +1 -1
- package/dist/components/geodesic/status.d.ts +8 -6
- package/dist/components/geodesic/status.d.ts.map +1 -1
- package/dist/components/geodesic/styles.css +15 -2
- package/dist/components/hover-card/index.js +2 -2
- package/dist/components/image-cropper/index.js +7 -7
- package/dist/components/indicator/index.js +24 -9
- package/dist/components/indicator/index.js.map +1 -1
- package/dist/components/indicator/indicator.d.ts +15 -6
- package/dist/components/indicator/indicator.d.ts.map +1 -1
- package/dist/components/input/index.js +2 -2
- package/dist/components/kbd/index.js +3 -3
- package/dist/components/kbd/kbd.d.ts.map +1 -1
- package/dist/components/lightbox/index.js +8 -8
- package/dist/components/menu/index.js +4 -4
- package/dist/components/modal/index.js +5 -5
- package/dist/components/multi-combobox-list/index.js +7 -7
- package/dist/components/multi-select/index.js +8 -8
- package/dist/components/nav-link/index.js +5 -1
- package/dist/components/nav-link/nav-link.d.ts.map +1 -1
- package/dist/components/nav-link/tanstack.js +5 -1
- package/dist/components/nav-link/tanstack.js.map +1 -1
- package/dist/components/number-input/index.js +5 -5
- package/dist/components/overlays/index.js +7 -7
- package/dist/components/password-input/index.js +3 -3
- package/dist/components/photo-capture/index.js +16 -16
- package/dist/components/pills-input/index.js +5 -5
- package/dist/components/pin-input/index.js +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/radio-group/index.js +1 -1
- package/dist/components/rating/index.js +1 -1
- package/dist/components/schedule/index.js +7 -7
- package/dist/components/segment-group/index.js +4 -4
- package/dist/components/segment-group/segment-group.d.ts +6 -1
- package/dist/components/segment-group/segment-group.d.ts.map +1 -1
- package/dist/components/select/index.js +6 -6
- package/dist/components/slider/index.js +2 -2
- package/dist/components/spotlight/index.js +11 -11
- package/dist/components/switch/index.js +14 -19
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/switch.d.ts +1 -0
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/table/index.js +1 -1
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/tabs/index.js +3 -3
- package/dist/components/tabs/tabs-data.d.ts +4 -1
- package/dist/components/tabs/tabs-data.d.ts.map +1 -1
- package/dist/components/tabs/tabs.d.ts +4 -1
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tags-input/index.js +7 -7
- package/dist/components/text-input/index.js +2 -2
- package/dist/components/textarea/index.js +2 -2
- package/dist/components/theme-icon/index.js +1 -1
- package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
- package/dist/components/time-input/index.js +9 -9
- package/dist/components/tree-multi-select/index.js +8 -8
- package/dist/components/tree-select/index.js +5 -5
- package/dist/index.js +4 -4
- package/dist/lib/sidebar-rail.d.ts +21 -0
- package/dist/lib/sidebar-rail.d.ts.map +1 -0
- package/dist/theme.css +35 -35
- package/package.json +1 -1
- package/src/as-child.contract.test.tsx +6 -0
- package/src/components/action-icon/action-icon.tsx +3 -1
- package/src/components/ambient-background/starfield.tsx +18 -43
- package/src/components/app-shell/app-shell.test.tsx +430 -5
- package/src/components/app-shell/app-shell.tsx +484 -24
- package/src/components/app-shell/index.ts +2 -0
- package/src/components/avatar/avatar.test.tsx +12 -0
- package/src/components/avatar/avatar.tsx +9 -0
- package/src/components/badge/badge.tsx +11 -6
- package/src/components/button/button.tsx +1 -1
- package/src/components/button-group/button-group.test.tsx +24 -0
- package/src/components/button-group/button-group.tsx +21 -4
- package/src/components/button-multi-select/button-multi-select.test.tsx +15 -0
- package/src/components/button-select/button-select-control.tsx +5 -0
- package/src/components/button-select/button-select.test.tsx +25 -0
- package/src/components/button-select/button-select.tsx +13 -2
- package/src/components/card/card.tsx +10 -9
- package/src/components/checkbox/checkbox.test.tsx +17 -9
- package/src/components/checkbox/checkbox.tsx +26 -27
- package/src/components/choice-card-group/choice-card-group.tsx +3 -3
- package/src/components/code-block/code-block.tsx +7 -4
- package/src/components/code-block/highlighter.test.ts +79 -1
- package/src/components/code-block/highlighter.ts +76 -30
- package/src/components/code-block/index.ts +2 -0
- package/src/components/code-block/languages.ts +63 -0
- package/src/components/code-block/static.tsx +2 -1
- package/src/components/data-table/data-table-pagination.tsx +5 -5
- package/src/components/data-table/data-table-stack.tsx +2 -2
- package/src/components/field/field.tsx +14 -0
- package/src/components/geodesic/badge-frame.tsx +67 -13
- package/src/components/geodesic/exam-badge.tsx +8 -4
- package/src/components/geodesic/geometry.ts +8 -6
- package/src/components/geodesic/status.test.ts +11 -2
- package/src/components/geodesic/status.ts +11 -7
- package/src/components/geodesic/styles.css +15 -2
- package/src/components/indicator/indicator.test.tsx +45 -0
- package/src/components/indicator/indicator.tsx +40 -13
- package/src/components/kbd/kbd.tsx +2 -1
- package/src/components/nav-link/nav-link.test.tsx +121 -1
- package/src/components/nav-link/nav-link.tsx +78 -29
- package/src/components/segment-group/segment-group.test.tsx +22 -0
- package/src/components/segment-group/segment-group.tsx +35 -19
- package/src/components/switch/switch.test.tsx +15 -0
- package/src/components/switch/switch.tsx +27 -27
- package/src/components/table/table.test.tsx +1 -1
- package/src/components/table/table.tsx +14 -11
- package/src/components/tabs/tabs-data.tsx +5 -1
- package/src/components/tabs/tabs.test.tsx +28 -0
- package/src/components/tabs/tabs.tsx +14 -4
- package/src/components/theme-icon/theme-icon.tsx +46 -12
- package/src/lib/sidebar-rail.ts +24 -0
- package/src/theme.css +35 -35
- package/src/theme.test.ts +0 -1
- package/dist/chunk-2MXWEIMD.js.map +0 -1
- package/dist/chunk-6VYGK3Q3.js.map +0 -1
- package/dist/chunk-7AQ4MN4M.js.map +0 -1
- package/dist/chunk-7CNDZZZ6.js +0 -95
- package/dist/chunk-7CNDZZZ6.js.map +0 -1
- package/dist/chunk-BE2LWUHY.js.map +0 -1
- package/dist/chunk-C4NFRSOR.js.map +0 -1
- package/dist/chunk-DT6LKNZF.js.map +0 -1
- package/dist/chunk-E5H3YWZV.js.map +0 -1
- package/dist/chunk-F342ZT7O.js.map +0 -1
- package/dist/chunk-HRNWWL3Y.js.map +0 -1
- package/dist/chunk-MW42XVPD.js.map +0 -1
- package/dist/chunk-SVKN5ZHX.js.map +0 -1
- package/dist/chunk-VD6PB3VA.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/use-hotkey.ts"],"names":[],"mappings":";;;;;AAsCA,IAAM,QAAA,GAAoD;AAAA,EACxD,GAAA,EAAK,KAAA;AAAA,EACL,IAAA,EAAM,MAAA;AAAA,EACN,GAAA,EAAK,MAAA;AAAA,EACL,OAAA,EAAS,MAAA;AAAA,EACT,IAAA,EAAM,MAAA;AAAA,EACN,OAAA,EAAS,MAAA;AAAA,EACT,GAAA,EAAK,KAAA;AAAA,EACL,MAAA,EAAQ,KAAA;AAAA,EACR,KAAA,EAAO;AACT,CAAA;AAGA,IAAM,YAAA,GAAgD;AAAA,EACpD,IAAA,EAAM,MAAA;AAAA,EACN,IAAA,EAAM,SAAA;AAAA,EACN,GAAA,EAAK,KAAA;AAAA,EACL,KAAA,EAAO;AACT,CAAA;AAGO,IAAM,kBAAkB,MAAe;AAC5C,EAAA,IAAI,OAAO,SAAA,KAAc,WAAA,EAAa,OAAO,KAAA;AAC7C,EAAA,MAAM,GAAA,GAA6D,SA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I,CAAC,OAAA,CAAQ,KAAK,CAAA,EAAG;AACrB,MAAA,KAAA,CAAM,cAAA,EAAe;AACrB,MAAA,IAAI,KAAA,CAAM,MAAA,IAAU,CAAC,MAAA,EAAQ;AAC7B,MAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,IACf,CAAA;AACA,IAAA,MAAA,CAAO,gBAAA,CAAiB,MAAM,KAAK,CAAA;AACnC,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,QAAA,CAAS,gBAAA,CAAiB,eAAe,aAAa,CAAA;AACtD,MAAA,QAAA,CAAS,gBAAA,CAAiB,cAAc,YAAY,CAAA;AAAA,IACtD;AACA,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,MAAM,KAAK,CAAA;AACtC,MAAA,QAAA,CAAS,mBAAA,CAAoB,eAAe,aAAa,CAAA;AACzD,MAAA,QAAA,CAAS,mBAAA,CAAoB,cAAc,YAAY,CAAA;AAAA,IACzD,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,SAAA,EAAW,MAAA,EAAQ,KAAA,EAAO,OAAO,KAAA,EAAO,MAAA,EAAQ,IAAA,EAAM,OAAO,CAAC,CAAA;AACpE;AAEA,IAAM,cAAA,GAAiB,MAAM,MAAM;AAAC,CAAA;AAM7B,IAAM,mBAAmB,MAC9B,oBAAA,CAAqB,cAAA,EAAgB,eAAA,EAAiB,MAAM,KAAK","file":"chunk-FUNTJZX7.js","sourcesContent":["\"use client\"\n\nimport {\n ArrowBigUp,\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowRightToLine,\n ArrowUp,\n ChevronUp,\n Command,\n CornerDownLeft,\n Delete,\n type LucideIcon,\n Option,\n} from \"lucide-react\"\nimport { type RefObject, useEffect, useEffectEvent, useSyncExternalStore } from \"react\"\nimport { devWarn } from \"./dev-warn\"\nimport { useLayerCovered } from \"./overlay-layer\"\n\n/**\n * A small, platform-aware keyboard shortcut matcher: `\"mod+k\"`, `\"shift+mod+p\"`,\n * `\"alt+/\"`.\n *\n * - `mod` is ⌘ on Apple platforms and Ctrl elsewhere, the usual convention for\n * app shortcuts. `meta` / `cmd` and `ctrl` name one key explicitly.\n * - The last part is the key, compared case-insensitively with `event.key`, so\n * it follows the user's keyboard layout. The space bar is `space`. Modifiers must match exactly:\n * `mod+k` doesn't fire on ⌘⇧K.\n * - The key can be a modifier itself (`\"alt\"`, for hold-to-peek): its own flag\n * is then ignored, since pressing ⌥ sets `altKey` and releasing it clears it.\n * - An event fired while an IME is composing is ignored.\n * - A part that names no modifier (`\"ctl+k\"`) makes the hotkey match nothing,\n * rather than silently dropping it and firing on a bare `k`.\n */\n\ntype Modifiers = { meta: boolean; ctrl: boolean; alt: boolean; shift: boolean }\n\nconst MODIFIER: Record<string, keyof Modifiers | \"mod\"> = {\n mod: \"mod\",\n meta: \"meta\",\n cmd: \"meta\",\n command: \"meta\",\n ctrl: \"ctrl\",\n control: \"ctrl\",\n alt: \"alt\",\n option: \"alt\",\n shift: \"shift\",\n}\n\n/** A modifier as the key itself, spelled the way `event.key` spells it. */\nconst MODIFIER_KEY: Record<keyof Modifiers, string> = {\n meta: \"meta\",\n ctrl: \"control\",\n alt: \"alt\",\n shift: \"shift\",\n}\n\n/** Whether the user agent is an Apple platform (macOS, iOS, iPadOS): `mod` is ⌘ there. */\nexport const isApplePlatform = (): boolean => {\n if (typeof navigator === \"undefined\") return false\n const nav: Navigator & { userAgentData?: { platform?: string } } = navigator\n return /mac|iphone|ipad|ipod/i.test(nav.userAgentData?.platform ?? nav.platform ?? \"\")\n}\n\nexport type ParsedHotkey = Modifiers & {\n key: string\n /** Modifier parts that name no known modifier — a typo like `ctl`. */\n unknown: string[]\n}\n\ntype HotkeyEvent = Pick<\n KeyboardEvent,\n \"key\" | \"metaKey\" | \"ctrlKey\" | \"altKey\" | \"shiftKey\" | \"isComposing\"\n>\n\nconst resolveModifier = (part: string, apple: boolean): keyof Modifiers | undefined => {\n const modifier = MODIFIER[part]\n return modifier === \"mod\" ? (apple ? \"meta\" : \"ctrl\") : modifier\n}\n\n/** Parse a hotkey once: its key and the exact modifiers it needs. */\nexport const parseHotkey = (hotkey: string, apple = isApplePlatform()): ParsedHotkey => {\n const parts = hotkey\n .toLowerCase()\n .split(\"+\")\n .map((part) => part.trim())\n // A trailing \"+\" names the plus key itself: \"mod++\".\n const last = hotkey.endsWith(\"+\") ? \"+\" : (parts.at(-1) ?? \"\")\n const named = parts.slice(0, hotkey.endsWith(\"+\") ? -2 : -1)\n // A modifier as the key (`\"alt\"`, `\"mod\"`) is spelled as `event.key` has it.\n const self = resolveModifier(last, apple)\n const modifiers = named.map((part) => resolveModifier(part, apple))\n return {\n key: self ? MODIFIER_KEY[self] : last,\n meta: modifiers.includes(\"meta\"),\n ctrl: modifiers.includes(\"ctrl\"),\n alt: modifiers.includes(\"alt\"),\n shift: modifiers.includes(\"shift\"),\n unknown: named.filter((part) => MODIFIER[part] === undefined),\n }\n}\n\n/** Whether `event` is the already-parsed hotkey. */\nconst matchParsed = (parsed: ParsedHotkey, event: HotkeyEvent): boolean => {\n // `event.key` is a literal \" \" for the space bar, which a hotkey spells `space`.\n const key = event.key === \" \" ? \"space\" : event.key.toLowerCase()\n // Pressing a modifier sets its own flag (and releasing it clears it), so a\n // modifier that is the key itself is checked by `key` alone.\n const flag = (modifier: keyof Modifiers, pressed: boolean) =>\n key === MODIFIER_KEY[modifier] || pressed === parsed[modifier]\n return (\n !event.isComposing &&\n parsed.unknown.length === 0 &&\n key === parsed.key &&\n flag(\"meta\", event.metaKey) &&\n flag(\"ctrl\", event.ctrlKey) &&\n flag(\"alt\", event.altKey) &&\n flag(\"shift\", event.shiftKey)\n )\n}\n\n/** Whether `event` is `hotkey`. See the module doc for the rules. */\nexport const matchHotkey = (\n hotkey: string,\n event: HotkeyEvent,\n apple = isApplePlatform(),\n): boolean => matchParsed(parseHotkey(hotkey, apple), event)\n\n/**\n * The words a key cap reads as, keyed by the English string each replaces:\n * the word a cap shows (`ctrl`, `escape`) or the name it is spoken by (`command`,\n * `up`). Apple and the other platforms name some keys differently, so each\n * spelling has its own key: `return` / `enter`, `option` / `alt`, `delete`\n * (⌫ on a Mac) / `backspace`. `KEY_LABEL` says which key uses which; these\n * only replace the strings. `Intl` has no display names for keys, so these are\n * plain translations, English by default (`KBD_DEFAULT_TRANSLATIONS`).\n */\nexport type KbdTranslations = {\n /** ⌘, spoken on Apple. */\n command: string\n /** The Meta (Windows) key's word, off Apple. */\n meta: string\n /** ⌃, spoken on Apple. */\n control: string\n /** Ctrl's word, off Apple. \"Strg\" on a German keyboard. */\n ctrl: string\n /** ⌥, spoken on Apple. */\n option: string\n /** Alt's word, off Apple. */\n alt: string\n /** ⇧, spoken on every platform. */\n shift: string\n /** ↵, spoken on Apple. */\n return: string\n /** ↵, spoken off Apple. \"Entrée\" in French. */\n enter: string\n /** ⌫, spoken on Apple. */\n delete: string\n /** ⌫'s word, off Apple. \"Rücktaste\" in German, \"Retour arrière\" in French. */\n backspace: string\n /** ⌦, spoken on Apple. */\n forwardDelete: string\n /** ⌦'s word, off Apple. \"Suppr\" on a French keyboard, \"Entf\" on a German one. */\n del: string\n /** ⇥, spoken on every platform. */\n tab: string\n /** The arrows, spoken on every platform. */\n up: string\n down: string\n left: string\n right: string\n /** Esc's word, on every platform. \"Échap\" on a French keyboard. */\n escape: string\n /** The space bar's word, on every platform. */\n space: string\n /** Page Up and Page Down's words, on every platform. */\n pageUp: string\n pageDown: string\n}\n\n/** The English key words: what `<Kbd hotkey>`, `hotkeyKeys` and `formatHotkey`\n * read as without `translations`, and the base a partial override is merged onto. */\nexport const KBD_DEFAULT_TRANSLATIONS = {\n command: \"Command\",\n meta: \"Meta\",\n control: \"Control\",\n ctrl: \"Ctrl\",\n option: \"Option\",\n alt: \"Alt\",\n shift: \"Shift\",\n return: \"Return\",\n enter: \"Enter\",\n delete: \"Delete\",\n backspace: \"Backspace\",\n forwardDelete: \"Forward Delete\",\n del: \"Del\",\n tab: \"Tab\",\n up: \"Up Arrow\",\n down: \"Down Arrow\",\n left: \"Left Arrow\",\n right: \"Right Arrow\",\n escape: \"Esc\",\n space: \"Space\",\n pageUp: \"PgUp\",\n pageDown: \"PgDn\",\n} as const satisfies KbdTranslations\n\ntype KeyWord = keyof KbdTranslations\n\n/**\n * How a key reads on a key cap. One entry per key that doesn't read as typed:\n *\n * - `glyph`: the symbol Apple writes (⌘, ⇧, ↵), spoken there as `name` (a\n * bare `⌘` has no reliable spoken form).\n * - `text`: the word Windows and Linux write (`Ctrl`, `Shift`, `Enter`),\n * spoken there as itself.\n * - `icon`: what a `<Kbd>` cap draws for the key on every platform, so\n * Shift is the same arrow on a Mac and on a PC.\n * - `appleIcon`: an icon drawn on Apple only: the symbols only Apple uses\n * (⌘ ⌥ ⌃), and ⌫. Elsewhere those keys stay words: there is no honest icon\n * for Ctrl, Alt or the Windows key, and ⌫ reads as the Left Arrow there,\n * where the keyboard prints \"Backspace\".\n *\n * `text` and `name` are `KbdTranslations` keys, so a translation replaces the\n * word and never the key data. Apple platforms take the glyph and fall back to\n * the text; elsewhere it is the reverse, so a key with only a glyph (the\n * arrows) is a symbol everywhere and one with only a text (`Esc`) is a word\n * everywhere. Anything not listed is shown as typed, its first letter\n * upper-cased.\n */\ntype KeyLabel = {\n glyph?: string\n text?: KeyWord\n icon?: LucideIcon\n appleIcon?: LucideIcon\n name?: KeyWord\n}\n\nconst KEY_LABEL: Record<string, KeyLabel> = {\n meta: { glyph: \"⌘\", appleIcon: Command, name: \"command\", text: \"meta\" },\n control: { glyph: \"⌃\", appleIcon: ChevronUp, name: \"control\", text: \"ctrl\" },\n alt: { glyph: \"⌥\", appleIcon: Option, name: \"option\", text: \"alt\" },\n shift: { glyph: \"⇧\", icon: ArrowBigUp, name: \"shift\", text: \"shift\" },\n enter: { glyph: \"↵\", icon: CornerDownLeft, name: \"return\", text: \"enter\" },\n // An icon on Apple only: elsewhere ⌫ reads as ← (the Left Arrow), and the key\n // is printed \"Backspace\" on those keyboards.\n backspace: { glyph: \"⌫\", appleIcon: Delete, name: \"delete\", text: \"backspace\" },\n delete: { glyph: \"⌦\", name: \"forwardDelete\", text: \"del\" },\n tab: { glyph: \"⇥\", icon: ArrowRightToLine, name: \"tab\", text: \"tab\" },\n arrowup: { glyph: \"↑\", icon: ArrowUp, name: \"up\" },\n arrowdown: { glyph: \"↓\", icon: ArrowDown, name: \"down\" },\n arrowleft: { glyph: \"←\", icon: ArrowLeft, name: \"left\" },\n arrowright: { glyph: \"→\", icon: ArrowRight, name: \"right\" },\n // macOS menus spell these out too.\n escape: { text: \"escape\" },\n esc: { text: \"escape\" },\n space: { text: \"space\" },\n pageup: { text: \"pageUp\" },\n pagedown: { text: \"pageDown\" },\n}\n\n/** Apple's order for modifier glyphs (⌃⌥⇧⌘), used on every platform. */\nconst MODIFIER_ORDER: (keyof Modifiers)[] = [\"ctrl\", \"alt\", \"shift\", \"meta\"]\n\n/**\n * One key cap of a hotkey: the text it reads as (`label`), and, when the\n * key is drawn rather than written, the `icon` to draw (none for a glyph\n * with no icon, like ⌦) and the `name` to speak.\n * `id` tells caps apart (`\"ctrl\"`, `\"shift\"`, …, `\"key\"` for the last).\n */\nexport type HotkeyCap = { id: string; label: string; icon?: LucideIcon; name?: string }\n\nconst keyCap = (\n id: string,\n key: string,\n apple: boolean,\n translations: Partial<KbdTranslations> | undefined,\n): HotkeyCap => {\n const entry = KEY_LABEL[key]\n // Merged per key; a key set to `undefined` keeps its English word.\n const word = (of?: KeyWord) => of && (translations?.[of] ?? KBD_DEFAULT_TRANSLATIONS[of])\n const text = word(entry?.text)\n const spoken = word(entry?.name)\n const label =\n (apple ? (entry?.glyph ?? text) : (text ?? entry?.glyph)) ??\n key.charAt(0).toUpperCase() + key.slice(1)\n const icon = apple ? (entry?.appleIcon ?? entry?.icon) : entry?.icon\n // Spoken the platform's way: Apple's key names there (\"Return\"), the\n // word elsewhere (\"Enter\"), the arrows' names on both.\n const name = apple ? spoken : (text ?? spoken)\n // An icon, or Apple's glyph where it has none (⌦), is drawn and spoken by\n // name; a word reads as itself.\n const drawn = icon !== undefined || (label === entry?.glyph && apple)\n return drawn && name ? { id, label, name, ...(icon && { icon }) } : { id, label }\n}\n\n/**\n * The caps of a hotkey, modifiers first in Apple's order. What `<Kbd hotkey>`\n * renders; `hotkeyKeys` is its text. `translations` replaces the English key\n * words per key (see `KbdTranslations`).\n */\nexport const hotkeyCaps = (\n hotkey: string,\n apple = isApplePlatform(),\n translations?: Partial<KbdTranslations>,\n): HotkeyCap[] => {\n const parsed = parseHotkey(hotkey, apple)\n return [\n ...MODIFIER_ORDER.filter((modifier) => parsed[modifier]).map((modifier) =>\n keyCap(modifier, MODIFIER_KEY[modifier], apple, translations),\n ),\n keyCap(\"key\", parsed.key, apple, translations),\n ]\n}\n\n/**\n * The keys of a hotkey, one label per key cap, the way the platform writes\n * them: `\"mod+k\"` is `[\"⌘\", \"K\"]` on Apple platforms and `[\"Ctrl\", \"K\"]`\n * elsewhere, `\"shift+mod+p\"` is `[\"⇧\", \"⌘\", \"P\"]` / `[\"Ctrl\", \"Shift\", \"P\"]`.\n * Modifiers come in Apple's order (⌃⌥⇧⌘) whatever order the string names\n * them in. Render one `<kbd>` per label, or let `<Kbd hotkey>` do it.\n *\n * `apple` defaults to the current platform, which a server can't know: while\n * rendering, pass `useApplePlatform()` so the server markup and the first\n * client render agree. `translations` is `<Kbd>`'s, so the text and the caps\n * read the same: `{ ctrl: \"Strg\" }` gives `[\"Strg\", \"K\"]`.\n */\nexport const hotkeyKeys = (\n hotkey: string,\n apple = isApplePlatform(),\n translations?: Partial<KbdTranslations>,\n): string[] => hotkeyCaps(hotkey, apple, translations).map((cap) => cap.label)\n\n/**\n * The label for a hotkey as one string, for plain-text places (a `title`, a\n * tooltip, a menu's text): `hotkeyKeys` joined, the Apple way with no space\n * (`⌘K`, `⇧⌘P`) and with a space elsewhere (`Ctrl K`, `Ctrl Shift P`).\n * On screen, prefer `<Kbd hotkey>`, which draws one cap per key.\n *\n * `apple` defaults to the current platform, which a server can't know: while\n * rendering, pass `useApplePlatform()` so the server markup and the first\n * client render agree. `translations` is `<Kbd>`'s (`{ ctrl: \"Strg\" }` gives\n * `Strg K`).\n */\nexport const formatHotkey = (\n hotkey: string,\n apple = isApplePlatform(),\n translations?: Partial<KbdTranslations>,\n): string => hotkeyKeys(hotkey, apple, translations).join(apple ? \"\" : \" \")\n\n/** Input types where keys are commands, not text. */\nconst NON_TEXT_INPUTS = [\n \"checkbox\",\n \"radio\",\n \"range\",\n \"button\",\n \"submit\",\n \"reset\",\n \"color\",\n \"file\",\n \"image\",\n \"hidden\",\n]\n\n/** Where a keystroke types text rather than issuing a command: a text-like\n * `input`, a `textarea`, or a `contenteditable`. Not a checkbox, radio,\n * slider or file input, nor a `select` or a button: keys there are commands. */\nconst TEXT_FIELD = [\n \"textarea\",\n '[contenteditable]:not([contenteditable=\"false\"])',\n `input${NON_TEXT_INPUTS.map((type) => `:not([type=\"${type}\"])`).join(\"\")}`,\n].join(\", \")\n\nconst inTextField = (target: EventTarget | null): boolean =>\n target instanceof Element && target.closest(TEXT_FIELD) !== null\n\ntype Inputs = \"allow\" | \"ignore\" | \"only\"\n\n/** Whether `inputs` lets an event through, given whether it came from a text field. */\nconst INPUTS: Record<Inputs, (typing: boolean) => boolean> = {\n allow: () => true,\n ignore: (typing) => !typing,\n only: (typing) => typing,\n}\n\n/** The boolean form, kept from before the three modes. */\nconst LEGACY_INPUTS: Record<\"true\" | \"false\", Inputs> = { true: \"allow\", false: \"ignore\" }\n\n/** Can't type a character: it holds ⌘/Ctrl/Alt, or is a modifier itself. */\nconst chorded = (hotkey: ParsedHotkey): boolean =>\n hotkey.meta || hotkey.ctrl || hotkey.alt || Object.values(MODIFIER_KEY).includes(hotkey.key)\n\n/** The mode `inputs` resolves to for one hotkey. */\nconst inputMode = (inputs: HotkeyOptions[\"inputs\"], hotkey: ParsedHotkey): Inputs =>\n typeof inputs === \"boolean\"\n ? LEGACY_INPUTS[`${inputs}`]\n : (inputs ?? (chorded(hotkey) ? \"allow\" : \"ignore\"))\n\n/** A scope that can't take part right now: inert (a closed Collapse) or\n * hidden (an inactive Tabs panel), itself or through an ancestor. */\nconst unavailable = (scope: Element): boolean => scope.closest(\"[inert], [hidden]\") !== null\n\n/** The default `when`: skip what a component already handled. */\nconst unhandled = (event: KeyboardEvent): boolean => !event.defaultPrevented\n\nexport type HotkeyOptions = {\n /**\n * Whether the hotkey fires while typing in a text field (a text `input`,\n * `textarea` or `contenteditable`; buttons, sliders, checkboxes and selects\n * are not text fields):\n *\n * - `\"allow\"` (or `true`): anywhere, e.g. ⌘K.\n * - `\"ignore\"` (or `false`): not while typing, e.g. `/` or `?`, which would\n * otherwise swallow the character being typed (WCAG 2.1.4).\n * - `\"only\"`: only while typing, e.g. ⌘↵ to submit, Esc to clear.\n *\n * Defaults to `\"allow\"` for a hotkey holding ⌘/Ctrl/Alt (or a bare\n * modifier), which typing can't produce, and `\"ignore\"` for a bare key or a\n * `shift+` one, which would type a character. With an array, each hotkey\n * gets its own default.\n */\n inputs?: Inputs | boolean\n /** Fire only while focus is inside this element. A scope that is `inert`\n * or `hidden` (or inside one) counts as outside. */\n scope?: RefObject<Element | null>\n /** With `scope`: the pointer resting on the scope counts as being inside\n * it, no focus needed (hover a row, press `e` to archive it).\n * @default false */\n hover?: boolean\n /**\n * Yield while an overlay (Modal, Drawer, Popover, a picker's list) is open\n * above the component that bound the hotkey. A page's `j`/`k` go quiet\n * under a Modal; a Modal's own hotkey fires while it is on top and goes\n * quiet when something opens from it. Pass `false` for a hotkey that must\n * also reach the overlay it opened, like a toggle (Spotlight's ⌘K).\n * @default true\n */\n layer?: boolean\n /**\n * Also fire on the keydowns a held key auto-repeats. Off by default: a held\n * key firing an action thirty times a second (toggling fullscreen, opening\n * and closing a panel, deleting rows) is the costly surprise, while the\n * hotkeys that want it (`j`/`k` to move through a list) are few and opt in\n * with one word. A skipped repeat still has its default prevented, so a\n * held ⌘S doesn't fall through to the browser's Save dialog.\n * @default false\n */\n repeat?: boolean\n /** Fire on `keydown`, or on `keyup` for hold-and-release: a `keydown` and a\n * `keyup` hotkey on `\"alt\"` show hints while ⌥ is held.\n * @default \"keydown\" */\n event?: \"keydown\" | \"keyup\"\n /**\n * The last word on whether a matched event fires, after every option above.\n * Covers what they don't, such as yielding to a focused button or slider.\n *\n * It replaces the default, which skips an event a component already\n * handled (`event.defaultPrevented`: Select's ↵, zag's Esc). Keep that\n * check in yours unless the hotkey should run even then:\n *\n * when: (event) => !event.defaultPrevented && !isSlider(event.target)\n * when: () => true // also fire on handled events\n */\n when?: (event: KeyboardEvent) => boolean\n}\n\n/**\n * Call `handler` when one of `keys` is pressed. `false` (or `undefined`) binds\n * nothing. The matched event's default is prevented, so the browser's own\n * shortcut on the same keys doesn't also run.\n *\n * By default it fires anywhere in the document, except: in a text field for a\n * bare-key hotkey (`/`, `?`; a ⌘/Ctrl/Alt one fires there too), while an\n * overlay is open above the component that bound it, on a held key's\n * repeats, or on an event a component already handled. The options narrow or\n * widen that; see `HotkeyOptions`. A hotkey with an unknown modifier binds\n * nothing and warns in development.\n *\n * useHotkey(\"mod+k\", () => spotlight.toggle(), { layer: false })\n * useHotkey(\"/\", () => search.focus(), { inputs: \"ignore\" })\n * useHotkey([\"j\", \"arrowdown\"], next, { scope: list, repeat: true })\n */\nexport function useHotkey(\n keys: string | string[] | false | undefined,\n handler: (event: KeyboardEvent) => void,\n {\n inputs,\n scope,\n hover = false,\n layer = true,\n repeat = false,\n event: type = \"keydown\",\n when = unhandled,\n }: HotkeyOptions = {},\n): void {\n const onMatch = useEffectEvent(handler)\n const allowed = useEffectEvent(when)\n const covered = useLayerCovered()\n // One string for the deps, so an inline array doesn't rebind every render.\n // A newline can't be part of a hotkey.\n const signature = keys ? [keys].flat().join(\"\\n\") : \"\"\n useEffect(() => {\n if (!signature) return\n const hotkeys = signature.split(\"\\n\")\n const parsed = hotkeys.map((hotkey) => parseHotkey(hotkey))\n const unknown = parsed.flatMap((hotkey) => hotkey.unknown)\n if (unknown.length > 0) {\n devWarn(\n `useHotkey(\"${hotkeys.join('\", \"')}\"): unknown modifier ${unknown.map((part) => `\"${part}\"`).join(\", \")}, so nothing is bound. Use mod, meta (cmd, command), ctrl (control), alt (option) or shift, joined with \"+\", the key last: \"mod+shift+k\".`,\n )\n return\n }\n // The element under the pointer, for `hover`.\n let pointed: EventTarget | null = null\n const onPointerOver = (event: PointerEvent) => {\n pointed = event.target\n }\n const onPointerOut = (event: PointerEvent) => {\n // Out of the window: nothing is hovered any more.\n if (event.relatedTarget === null) pointed = null\n }\n const inScope = (event: KeyboardEvent): boolean => {\n if (!scope) return true\n const element = scope.current\n if (!element || unavailable(element)) return false\n const inside = (target: EventTarget | null) =>\n target instanceof Node && element.contains(target)\n return inside(event.target) || (hover && inside(pointed))\n }\n const onKey = (event: KeyboardEvent) => {\n const matched = parsed.find((hotkey) => matchParsed(hotkey, event))\n if (!matched) return\n if (layer && covered()) return\n if (!INPUTS[inputMode(inputs, matched)](inTextField(event.target))) return\n if (!inScope(event)) return\n if (!allowed(event)) return\n event.preventDefault()\n if (event.repeat && !repeat) return\n onMatch(event)\n }\n window.addEventListener(type, onKey)\n if (hover) {\n document.addEventListener(\"pointerover\", onPointerOver)\n document.addEventListener(\"pointerout\", onPointerOut)\n }\n return () => {\n window.removeEventListener(type, onKey)\n document.removeEventListener(\"pointerover\", onPointerOver)\n document.removeEventListener(\"pointerout\", onPointerOut)\n }\n }, [signature, inputs, scope, hover, layer, repeat, type, covered])\n}\n\nconst noSubscription = () => () => {}\n\n/**\n * Whether `mod` is ⌘ for this user, to label a shortcut hint (`⌘` vs `Ctrl`).\n * `false` during SSR and hydration, so the markup can't mismatch.\n */\nexport const useApplePlatform = (): boolean =>\n useSyncExternalStore(noSubscription, isApplePlatform, () => false)\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/use-hotkey.ts"],"names":[],"mappings":";;;;;AAsCA,IAAM,QAAA,GAAoD;AAAA,EACxD,GAAA,EAAK,KAAA;A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CAAC,CAAA;AACpE;AAEA,IAAM,cAAA,GAAiB,MAAM,MAAM;AAAC,CAAA;AAM7B,IAAM,mBAAmB,MAC9B,oBAAA,CAAqB,cAAA,EAAgB,eAAA,EAAiB,MAAM,KAAK","file":"chunk-2CL3FKEY.js","sourcesContent":["\"use client\"\n\nimport {\n ArrowBigUp,\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowRightToLine,\n ArrowUp,\n ChevronUp,\n Command,\n CornerDownLeft,\n Delete,\n type LucideIcon,\n Option,\n} from \"lucide-react\"\nimport { type RefObject, useEffect, useEffectEvent, useSyncExternalStore } from \"react\"\nimport { devWarn } from \"./dev-warn\"\nimport { useLayerCovered } from \"./overlay-layer\"\n\n/**\n * A small, platform-aware keyboard shortcut matcher: `\"mod+k\"`, `\"shift+mod+p\"`,\n * `\"alt+/\"`.\n *\n * - `mod` is ⌘ on Apple platforms and Ctrl elsewhere, the usual convention for\n * app shortcuts. `meta` / `cmd` and `ctrl` name one key explicitly.\n * - The last part is the key, compared case-insensitively with `event.key`, so\n * it follows the user's keyboard layout. The space bar is `space`. Modifiers must match exactly:\n * `mod+k` doesn't fire on ⌘⇧K.\n * - The key can be a modifier itself (`\"alt\"`, for hold-to-peek): its own flag\n * is then ignored, since pressing ⌥ sets `altKey` and releasing it clears it.\n * - An event fired while an IME is composing is ignored.\n * - A part that names no modifier (`\"ctl+k\"`) makes the hotkey match nothing,\n * rather than silently dropping it and firing on a bare `k`.\n */\n\ntype Modifiers = { meta: boolean; ctrl: boolean; alt: boolean; shift: boolean }\n\nconst MODIFIER: Record<string, keyof Modifiers | \"mod\"> = {\n mod: \"mod\",\n meta: \"meta\",\n cmd: \"meta\",\n command: \"meta\",\n ctrl: \"ctrl\",\n control: \"ctrl\",\n alt: \"alt\",\n option: \"alt\",\n shift: \"shift\",\n}\n\n/** A modifier as the key itself, spelled the way `event.key` spells it. */\nconst MODIFIER_KEY: Record<keyof Modifiers, string> = {\n meta: \"meta\",\n ctrl: \"control\",\n alt: \"alt\",\n shift: \"shift\",\n}\n\n/** Whether the user agent is an Apple platform (macOS, iOS, iPadOS): `mod` is ⌘ there. */\nexport const isApplePlatform = (): boolean => {\n if (typeof navigator === \"undefined\") return false\n const nav: Navigator & { userAgentData?: { platform?: string } } = navigator\n return /mac|iphone|ipad|ipod/i.test(nav.userAgentData?.platform ?? nav.platform ?? \"\")\n}\n\nexport type ParsedHotkey = Modifiers & {\n key: string\n /** Modifier parts that name no known modifier — a typo like `ctl`. */\n unknown: string[]\n}\n\ntype HotkeyEvent = Pick<\n KeyboardEvent,\n \"key\" | \"metaKey\" | \"ctrlKey\" | \"altKey\" | \"shiftKey\" | \"isComposing\"\n>\n\nconst resolveModifier = (part: string, apple: boolean): keyof Modifiers | undefined => {\n const modifier = MODIFIER[part]\n return modifier === \"mod\" ? (apple ? \"meta\" : \"ctrl\") : modifier\n}\n\n/** Parse a hotkey once: its key and the exact modifiers it needs. */\nexport const parseHotkey = (hotkey: string, apple = isApplePlatform()): ParsedHotkey => {\n const parts = hotkey\n .toLowerCase()\n .split(\"+\")\n .map((part) => part.trim())\n // A trailing \"+\" names the plus key itself: \"mod++\".\n const last = hotkey.endsWith(\"+\") ? \"+\" : (parts.at(-1) ?? \"\")\n const named = parts.slice(0, hotkey.endsWith(\"+\") ? -2 : -1)\n // A modifier as the key (`\"alt\"`, `\"mod\"`) is spelled as `event.key` has it.\n const self = resolveModifier(last, apple)\n const modifiers = named.map((part) => resolveModifier(part, apple))\n return {\n key: self ? MODIFIER_KEY[self] : last,\n meta: modifiers.includes(\"meta\"),\n ctrl: modifiers.includes(\"ctrl\"),\n alt: modifiers.includes(\"alt\"),\n shift: modifiers.includes(\"shift\"),\n unknown: named.filter((part) => MODIFIER[part] === undefined),\n }\n}\n\n/** Whether `event` is the already-parsed hotkey. */\nconst matchParsed = (parsed: ParsedHotkey, event: HotkeyEvent): boolean => {\n // `event.key` is a literal \" \" for the space bar, which a hotkey spells `space`.\n const key = event.key === \" \" ? \"space\" : event.key.toLowerCase()\n // Pressing a modifier sets its own flag (and releasing it clears it), so a\n // modifier that is the key itself is checked by `key` alone.\n const flag = (modifier: keyof Modifiers, pressed: boolean) =>\n key === MODIFIER_KEY[modifier] || pressed === parsed[modifier]\n return (\n !event.isComposing &&\n parsed.unknown.length === 0 &&\n key === parsed.key &&\n flag(\"meta\", event.metaKey) &&\n flag(\"ctrl\", event.ctrlKey) &&\n flag(\"alt\", event.altKey) &&\n flag(\"shift\", event.shiftKey)\n )\n}\n\n/** Whether `event` is `hotkey`. See the module doc for the rules. */\nexport const matchHotkey = (\n hotkey: string,\n event: HotkeyEvent,\n apple = isApplePlatform(),\n): boolean => matchParsed(parseHotkey(hotkey, apple), event)\n\n/**\n * The words a key cap reads as, keyed by the English string each replaces:\n * the word a cap shows (`ctrl`, `escape`) or the name it is spoken by (`command`,\n * `up`). Apple and the other platforms name some keys differently, so each\n * spelling has its own key: `return` / `enter`, `option` / `alt`, `delete`\n * (⌫ on a Mac) / `backspace`. `KEY_LABEL` says which key uses which; these\n * only replace the strings. `Intl` has no display names for keys, so these are\n * plain translations, English by default (`KBD_DEFAULT_TRANSLATIONS`).\n */\nexport type KbdTranslations = {\n /** ⌘, spoken on Apple. */\n command: string\n /** The Meta (Windows) key's word, off Apple. */\n meta: string\n /** ⌃, spoken on Apple. */\n control: string\n /** Ctrl's word, off Apple. \"Strg\" on a German keyboard. */\n ctrl: string\n /** ⌥, spoken on Apple. */\n option: string\n /** Alt's word, off Apple. */\n alt: string\n /** ⇧, spoken on every platform. */\n shift: string\n /** ↵, spoken on Apple. */\n return: string\n /** ↵, spoken off Apple. \"Entrée\" in French. */\n enter: string\n /** ⌫, spoken on Apple. */\n delete: string\n /** ⌫'s word, off Apple. \"Rücktaste\" in German, \"Retour arrière\" in French. */\n backspace: string\n /** ⌦, spoken on Apple. */\n forwardDelete: string\n /** ⌦'s word, off Apple. \"Suppr\" on a French keyboard, \"Entf\" on a German one. */\n del: string\n /** ⇥, spoken on every platform. */\n tab: string\n /** The arrows, spoken on every platform. */\n up: string\n down: string\n left: string\n right: string\n /** Esc's word, on every platform. \"Échap\" on a French keyboard. */\n escape: string\n /** The space bar's word, on every platform. */\n space: string\n /** Page Up and Page Down's words, on every platform. */\n pageUp: string\n pageDown: string\n}\n\n/** The English key words: what `<Kbd hotkey>`, `hotkeyKeys` and `formatHotkey`\n * read as without `translations`, and the base a partial override is merged onto. */\nexport const KBD_DEFAULT_TRANSLATIONS = {\n command: \"Command\",\n meta: \"Meta\",\n control: \"Control\",\n ctrl: \"Ctrl\",\n option: \"Option\",\n alt: \"Alt\",\n shift: \"Shift\",\n return: \"Return\",\n enter: \"Enter\",\n delete: \"Delete\",\n backspace: \"Backspace\",\n forwardDelete: \"Forward Delete\",\n del: \"Del\",\n tab: \"Tab\",\n up: \"Up Arrow\",\n down: \"Down Arrow\",\n left: \"Left Arrow\",\n right: \"Right Arrow\",\n escape: \"Esc\",\n space: \"Space\",\n pageUp: \"PgUp\",\n pageDown: \"PgDn\",\n} as const satisfies KbdTranslations\n\ntype KeyWord = keyof KbdTranslations\n\n/**\n * How a key reads on a key cap. One entry per key that doesn't read as typed:\n *\n * - `glyph`: the symbol Apple writes (⌘, ⇧, ↵), spoken there as `name` (a\n * bare `⌘` has no reliable spoken form).\n * - `text`: the word Windows and Linux write (`Ctrl`, `Shift`, `Enter`),\n * spoken there as itself.\n * - `icon`: what a `<Kbd>` cap draws for the key on every platform, so\n * Shift is the same arrow on a Mac and on a PC.\n * - `appleIcon`: an icon drawn on Apple only: the symbols only Apple uses\n * (⌘ ⌥ ⌃), and ⌫. Elsewhere those keys stay words: there is no honest icon\n * for Ctrl, Alt or the Windows key, and ⌫ reads as the Left Arrow there,\n * where the keyboard prints \"Backspace\".\n *\n * `text` and `name` are `KbdTranslations` keys, so a translation replaces the\n * word and never the key data. Apple platforms take the glyph and fall back to\n * the text; elsewhere it is the reverse, so a key with only a glyph (the\n * arrows) is a symbol everywhere and one with only a text (`Esc`) is a word\n * everywhere. Anything not listed is shown as typed, its first letter\n * upper-cased.\n */\ntype KeyLabel = {\n glyph?: string\n text?: KeyWord\n icon?: LucideIcon\n appleIcon?: LucideIcon\n name?: KeyWord\n}\n\nconst KEY_LABEL: Record<string, KeyLabel> = {\n meta: { glyph: \"⌘\", appleIcon: Command, name: \"command\", text: \"meta\" },\n control: { glyph: \"⌃\", appleIcon: ChevronUp, name: \"control\", text: \"ctrl\" },\n alt: { glyph: \"⌥\", appleIcon: Option, name: \"option\", text: \"alt\" },\n shift: { glyph: \"⇧\", icon: ArrowBigUp, name: \"shift\", text: \"shift\" },\n enter: { glyph: \"↵\", icon: CornerDownLeft, name: \"return\", text: \"enter\" },\n // An icon on Apple only: elsewhere ⌫ reads as ← (the Left Arrow), and the key\n // is printed \"Backspace\" on those keyboards.\n backspace: { glyph: \"⌫\", appleIcon: Delete, name: \"delete\", text: \"backspace\" },\n delete: { glyph: \"⌦\", name: \"forwardDelete\", text: \"del\" },\n tab: { glyph: \"⇥\", icon: ArrowRightToLine, name: \"tab\", text: \"tab\" },\n arrowup: { glyph: \"↑\", icon: ArrowUp, name: \"up\" },\n arrowdown: { glyph: \"↓\", icon: ArrowDown, name: \"down\" },\n arrowleft: { glyph: \"←\", icon: ArrowLeft, name: \"left\" },\n arrowright: { glyph: \"→\", icon: ArrowRight, name: \"right\" },\n // macOS menus spell these out too.\n escape: { text: \"escape\" },\n esc: { text: \"escape\" },\n space: { text: \"space\" },\n pageup: { text: \"pageUp\" },\n pagedown: { text: \"pageDown\" },\n}\n\n/** Apple's order for modifier glyphs (⌃⌥⇧⌘), used on every platform. */\nconst MODIFIER_ORDER: (keyof Modifiers)[] = [\"ctrl\", \"alt\", \"shift\", \"meta\"]\n\n/**\n * One key cap of a hotkey: the text it reads as (`label`), and, when the\n * key is drawn rather than written, the `icon` to draw (none for a glyph\n * with no icon, like ⌦) and the `name` to speak.\n * `id` tells caps apart (`\"ctrl\"`, `\"shift\"`, …, `\"key\"` for the last).\n */\nexport type HotkeyCap = { id: string; label: string; icon?: LucideIcon; name?: string }\n\nconst keyCap = (\n id: string,\n key: string,\n apple: boolean,\n translations: Partial<KbdTranslations> | undefined,\n): HotkeyCap => {\n const entry = KEY_LABEL[key]\n // Merged per key; a key set to `undefined` keeps its English word.\n const word = (of?: KeyWord) => of && (translations?.[of] ?? KBD_DEFAULT_TRANSLATIONS[of])\n const text = word(entry?.text)\n const spoken = word(entry?.name)\n const label =\n (apple ? (entry?.glyph ?? text) : (text ?? entry?.glyph)) ??\n key.charAt(0).toUpperCase() + key.slice(1)\n const icon = apple ? (entry?.appleIcon ?? entry?.icon) : entry?.icon\n // Spoken the platform's way: Apple's key names there (\"Return\"), the\n // word elsewhere (\"Enter\"), the arrows' names on both.\n const name = apple ? spoken : (text ?? spoken)\n // An icon, or Apple's glyph where it has none (⌦), is drawn and spoken by\n // name; a word reads as itself.\n const drawn = icon !== undefined || (label === entry?.glyph && apple)\n return drawn && name ? { id, label, name, ...(icon && { icon }) } : { id, label }\n}\n\n/**\n * The caps of a hotkey, modifiers first in Apple's order. What `<Kbd hotkey>`\n * renders; `hotkeyKeys` is its text. `translations` replaces the English key\n * words per key (see `KbdTranslations`).\n */\nexport const hotkeyCaps = (\n hotkey: string,\n apple = isApplePlatform(),\n translations?: Partial<KbdTranslations>,\n): HotkeyCap[] => {\n const parsed = parseHotkey(hotkey, apple)\n return [\n ...MODIFIER_ORDER.filter((modifier) => parsed[modifier]).map((modifier) =>\n keyCap(modifier, MODIFIER_KEY[modifier], apple, translations),\n ),\n keyCap(\"key\", parsed.key, apple, translations),\n ]\n}\n\n/**\n * The keys of a hotkey, one label per key cap, the way the platform writes\n * them: `\"mod+k\"` is `[\"⌘\", \"K\"]` on Apple platforms and `[\"Ctrl\", \"K\"]`\n * elsewhere, `\"shift+mod+p\"` is `[\"⇧\", \"⌘\", \"P\"]` / `[\"Ctrl\", \"Shift\", \"P\"]`.\n * Modifiers come in Apple's order (⌃⌥⇧⌘) whatever order the string names\n * them in. Render one `<kbd>` per label, or let `<Kbd hotkey>` do it.\n *\n * `apple` defaults to the current platform, which a server can't know: while\n * rendering, pass `useApplePlatform()` so the server markup and the first\n * client render agree. `translations` is `<Kbd>`'s, so the text and the caps\n * read the same: `{ ctrl: \"Strg\" }` gives `[\"Strg\", \"K\"]`.\n */\nexport const hotkeyKeys = (\n hotkey: string,\n apple = isApplePlatform(),\n translations?: Partial<KbdTranslations>,\n): string[] => hotkeyCaps(hotkey, apple, translations).map((cap) => cap.label)\n\n/**\n * The label for a hotkey as one string, for plain-text places (a `title`, a\n * tooltip, a menu's text): `hotkeyKeys` joined, the Apple way with no space\n * (`⌘K`, `⇧⌘P`) and with a space elsewhere (`Ctrl K`, `Ctrl Shift P`).\n * On screen, prefer `<Kbd hotkey>`, which draws one cap per key.\n *\n * `apple` defaults to the current platform, which a server can't know: while\n * rendering, pass `useApplePlatform()` so the server markup and the first\n * client render agree. `translations` is `<Kbd>`'s (`{ ctrl: \"Strg\" }` gives\n * `Strg K`).\n */\nexport const formatHotkey = (\n hotkey: string,\n apple = isApplePlatform(),\n translations?: Partial<KbdTranslations>,\n): string => hotkeyKeys(hotkey, apple, translations).join(apple ? \"\" : \" \")\n\n/** Input types where keys are commands, not text. */\nconst NON_TEXT_INPUTS = [\n \"checkbox\",\n \"radio\",\n \"range\",\n \"button\",\n \"submit\",\n \"reset\",\n \"color\",\n \"file\",\n \"image\",\n \"hidden\",\n]\n\n/** Where a keystroke types text rather than issuing a command: a text-like\n * `input`, a `textarea`, or a `contenteditable`. Not a checkbox, radio,\n * slider or file input, nor a `select` or a button: keys there are commands. */\nconst TEXT_FIELD = [\n \"textarea\",\n '[contenteditable]:not([contenteditable=\"false\"])',\n `input${NON_TEXT_INPUTS.map((type) => `:not([type=\"${type}\"])`).join(\"\")}`,\n].join(\", \")\n\nconst inTextField = (target: EventTarget | null): boolean =>\n target instanceof Element && target.closest(TEXT_FIELD) !== null\n\ntype Inputs = \"allow\" | \"ignore\" | \"only\"\n\n/** Whether `inputs` lets an event through, given whether it came from a text field. */\nconst INPUTS: Record<Inputs, (typing: boolean) => boolean> = {\n allow: () => true,\n ignore: (typing) => !typing,\n only: (typing) => typing,\n}\n\n/** The boolean form, kept from before the three modes. */\nconst LEGACY_INPUTS: Record<\"true\" | \"false\", Inputs> = { true: \"allow\", false: \"ignore\" }\n\n/** Can't type a character: it holds ⌘/Ctrl/Alt, or is a modifier itself. */\nconst chorded = (hotkey: ParsedHotkey): boolean =>\n hotkey.meta || hotkey.ctrl || hotkey.alt || Object.values(MODIFIER_KEY).includes(hotkey.key)\n\n/** The mode `inputs` resolves to for one hotkey. */\nconst inputMode = (inputs: HotkeyOptions[\"inputs\"], hotkey: ParsedHotkey): Inputs =>\n typeof inputs === \"boolean\"\n ? LEGACY_INPUTS[`${inputs}`]\n : (inputs ?? (chorded(hotkey) ? \"allow\" : \"ignore\"))\n\n/** A scope that can't take part right now: inert (a closed Collapse) or\n * hidden (an inactive Tabs panel), itself or through an ancestor. */\nconst unavailable = (scope: Element): boolean => scope.closest(\"[inert], [hidden]\") !== null\n\n/** The default `when`: skip what a component already handled. */\nconst unhandled = (event: KeyboardEvent): boolean => !event.defaultPrevented\n\nexport type HotkeyOptions = {\n /**\n * Whether the hotkey fires while typing in a text field (a text `input`,\n * `textarea` or `contenteditable`; buttons, sliders, checkboxes and selects\n * are not text fields):\n *\n * - `\"allow\"` (or `true`): anywhere, e.g. ⌘K.\n * - `\"ignore\"` (or `false`): not while typing, e.g. `/` or `?`, which would\n * otherwise swallow the character being typed (WCAG 2.1.4).\n * - `\"only\"`: only while typing, e.g. ⌘↵ to submit, Esc to clear.\n *\n * Defaults to `\"allow\"` for a hotkey holding ⌘/Ctrl/Alt (or a bare\n * modifier), which typing can't produce, and `\"ignore\"` for a bare key or a\n * `shift+` one, which would type a character. With an array, each hotkey\n * gets its own default.\n */\n inputs?: Inputs | boolean\n /** Fire only while focus is inside this element. A scope that is `inert`\n * or `hidden` (or inside one) counts as outside. */\n scope?: RefObject<Element | null>\n /** With `scope`: the pointer resting on the scope counts as being inside\n * it, no focus needed (hover a row, press `e` to archive it).\n * @default false */\n hover?: boolean\n /**\n * Yield while an overlay (Modal, Drawer, Popover, a picker's list) is open\n * above the component that bound the hotkey. A page's `j`/`k` go quiet\n * under a Modal; a Modal's own hotkey fires while it is on top and goes\n * quiet when something opens from it. Pass `false` for a hotkey that must\n * also reach the overlay it opened, like a toggle (Spotlight's ⌘K).\n * @default true\n */\n layer?: boolean\n /**\n * Also fire on the keydowns a held key auto-repeats. Off by default: a held\n * key firing an action thirty times a second (toggling fullscreen, opening\n * and closing a panel, deleting rows) is the costly surprise, while the\n * hotkeys that want it (`j`/`k` to move through a list) are few and opt in\n * with one word. A skipped repeat still has its default prevented, so a\n * held ⌘S doesn't fall through to the browser's Save dialog.\n * @default false\n */\n repeat?: boolean\n /** Fire on `keydown`, or on `keyup` for hold-and-release: a `keydown` and a\n * `keyup` hotkey on `\"alt\"` show hints while ⌥ is held.\n * @default \"keydown\" */\n event?: \"keydown\" | \"keyup\"\n /**\n * The last word on whether a matched event fires, after every option above.\n * Covers what they don't, such as yielding to a focused button or slider.\n *\n * It replaces the default, which skips an event a component already\n * handled (`event.defaultPrevented`: Select's ↵, zag's Esc). Keep that\n * check in yours unless the hotkey should run even then:\n *\n * when: (event) => !event.defaultPrevented && !isSlider(event.target)\n * when: () => true // also fire on handled events\n */\n when?: (event: KeyboardEvent) => boolean\n}\n\n/**\n * Call `handler` when one of `keys` is pressed. `false` (or `undefined`) binds\n * nothing. The matched event's default is prevented, so the browser's own\n * shortcut on the same keys doesn't also run.\n *\n * By default it fires anywhere in the document, except: in a text field for a\n * bare-key hotkey (`/`, `?`; a ⌘/Ctrl/Alt one fires there too), while an\n * overlay is open above the component that bound it, on a held key's\n * repeats, or on an event a component already handled. The options narrow or\n * widen that; see `HotkeyOptions`. A hotkey with an unknown modifier binds\n * nothing and warns in development.\n *\n * useHotkey(\"mod+k\", () => spotlight.toggle(), { layer: false })\n * useHotkey(\"/\", () => search.focus(), { inputs: \"ignore\" })\n * useHotkey([\"j\", \"arrowdown\"], next, { scope: list, repeat: true })\n */\nexport function useHotkey(\n keys: string | string[] | false | undefined,\n handler: (event: KeyboardEvent) => void,\n {\n inputs,\n scope,\n hover = false,\n layer = true,\n repeat = false,\n event: type = \"keydown\",\n when = unhandled,\n }: HotkeyOptions = {},\n): void {\n const onMatch = useEffectEvent(handler)\n const allowed = useEffectEvent(when)\n const covered = useLayerCovered()\n // One string for the deps, so an inline array doesn't rebind every render.\n // A newline can't be part of a hotkey.\n const signature = keys ? [keys].flat().join(\"\\n\") : \"\"\n useEffect(() => {\n if (!signature) return\n const hotkeys = signature.split(\"\\n\")\n const parsed = hotkeys.map((hotkey) => parseHotkey(hotkey))\n const unknown = parsed.flatMap((hotkey) => hotkey.unknown)\n if (unknown.length > 0) {\n devWarn(\n `useHotkey(\"${hotkeys.join('\", \"')}\"): unknown modifier ${unknown.map((part) => `\"${part}\"`).join(\", \")}, so nothing is bound. Use mod, meta (cmd, command), ctrl (control), alt (option) or shift, joined with \"+\", the key last: \"mod+shift+k\".`,\n )\n return\n }\n // The element under the pointer, for `hover`.\n let pointed: EventTarget | null = null\n const onPointerOver = (event: PointerEvent) => {\n pointed = event.target\n }\n const onPointerOut = (event: PointerEvent) => {\n // Out of the window: nothing is hovered any more.\n if (event.relatedTarget === null) pointed = null\n }\n const inScope = (event: KeyboardEvent): boolean => {\n if (!scope) return true\n const element = scope.current\n if (!element || unavailable(element)) return false\n const inside = (target: EventTarget | null) =>\n target instanceof Node && element.contains(target)\n return inside(event.target) || (hover && inside(pointed))\n }\n const onKey = (event: KeyboardEvent) => {\n const matched = parsed.find((hotkey) => matchParsed(hotkey, event))\n if (!matched) return\n if (layer && covered()) return\n if (!INPUTS[inputMode(inputs, matched)](inTextField(event.target))) return\n if (!inScope(event)) return\n if (!allowed(event)) return\n event.preventDefault()\n if (event.repeat && !repeat) return\n onMatch(event)\n }\n window.addEventListener(type, onKey)\n if (hover) {\n document.addEventListener(\"pointerover\", onPointerOver)\n document.addEventListener(\"pointerout\", onPointerOut)\n }\n return () => {\n window.removeEventListener(type, onKey)\n document.removeEventListener(\"pointerover\", onPointerOver)\n document.removeEventListener(\"pointerout\", onPointerOut)\n }\n }, [signature, inputs, scope, hover, layer, repeat, type, covered])\n}\n\nconst noSubscription = () => () => {}\n\n/**\n * Whether `mod` is ⌘ for this user, to label a shortcut hint (`⌘` vs `Ctrl`).\n * `false` during SSR and hydration, so the markup can't mismatch.\n */\nexport const useApplePlatform = (): boolean =>\n useSyncExternalStore(noSubscription, isApplePlatform, () => false)\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { inputSlot, inputShell, inputControlClasses } from './chunk-
|
|
2
|
-
import { scrollHighlightedIntoView, popoverChevron, popoverClearTrigger, popoverList, popoverContent, popoverIndicator, popoverOption, popoverGroupLabel, popoverEmpty } from './chunk-
|
|
3
|
-
import { useOverlayContainer } from './chunk-7P32XCEU.js';
|
|
1
|
+
import { inputSlot, inputShell, inputControlClasses } from './chunk-I4B3N3UX.js';
|
|
2
|
+
import { scrollHighlightedIntoView, popoverChevron, popoverClearTrigger, popoverList, popoverContent, popoverIndicator, popoverOption, popoverGroupLabel, popoverEmpty } from './chunk-E3XLWMEB.js';
|
|
4
3
|
import { useNestedLayer } from './chunk-H7WOMZXO.js';
|
|
4
|
+
import { useOverlayContainer } from './chunk-7P32XCEU.js';
|
|
5
5
|
import { ChevronIcon, CloseIcon, CheckIcon } from './chunk-6YNLRQ25.js';
|
|
6
6
|
import { composeChildren } from './chunk-R5LYFTHA.js';
|
|
7
7
|
import { props } from './chunk-WYCMIIRR.js';
|
|
@@ -181,5 +181,5 @@ var Combobox = {
|
|
|
181
181
|
};
|
|
182
182
|
|
|
183
183
|
export { COMBOBOX_DEFAULT_TRANSLATIONS, Combobox, resolveComboboxTranslations };
|
|
184
|
-
//# sourceMappingURL=chunk-
|
|
185
|
-
//# sourceMappingURL=chunk-
|
|
184
|
+
//# sourceMappingURL=chunk-2NTCQIRP.js.map
|
|
185
|
+
//# sourceMappingURL=chunk-2NTCQIRP.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/combobox/combobox.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;;;;AAuEA,IAAM,uBAAuB,aAAA,CAA6B;AAAA,EACxD,IAAA,EAAM,IAAA;AAAA,EACN,OAAA,EAAS;AACX,CAAC,CAAA;AAUM,IAAM,6BAAA,GAAgC;AAAA,EAC3C,YAAA,EAAc,cAAA;AAAA,EACd,iBAAA,EAAmB;AACrB;AAGO,IAAM,2BAAA,GAA8B,CAAC,SAAA,KAC1C,SAAA,GAAY,EAAE,GAAG,6BAAA,EAA+B,GAAG,SAAA,EAAU,GAAI;AAiBnE,IAAM,OAAO,CAAoD;AAAA,EAC/D,IAAA,GAAO,IAAA;AAAA,EACP,OAAA,GAAU,SAAA;AAAA,EACV,WAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,GAAG;AACL,CAAA,qBACE,GAAA,CAAC,qBAAqB,QAAA,EAArB,EAA8B,OAAO,EAAE,IAAA,EAAM,SAAQ,EACpD,QAAA,kBAAA,GAAA;AAAA,EAACA,UAAA,CAAI,IAAA;AAAA,EAAJ;AAAA,IAEC,WAAA,EAAa,EAAE,SAAA,EAAW,IAAA,EAAM,GAAG,WAAA,EAAY;AAAA,IAK/C,eAAA,EAAiB,yBAAA;AAAA,IACjB,SAAA,EAAW,EAAA,CAAG,QAAA,EAAU,SAAS,CAAA;AAAA,IAEjC,YAAA,EAAc,4BAA4B,YAAY,CAAA;AAAA,IACrD,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,IAClC,GAAG,IAAA;AAAA,IAEH;AAAA;AACH,CAAA,EACF,CAAA;AAWF,IAAM,UAAU,CAAC;AAAA,EACf,SAAA;AAAA,EACA,OAAA;AAAA,E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-ui/react/combobox\"\nimport { Portal } from \"@ark-ui/react/portal\"\nimport {\n type ComponentProps,\n type ComponentPropsWithoutRef,\n createContext,\n type ReactNode,\n useContext,\n} from \"react\"\nimport { composeChildren, type NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { useOverlayContainer } from \"../../lib/overlay-container\"\nimport { useNestedLayer } from \"../../lib/overlay-layer\"\nimport { props } from \"../../lib/props\"\nimport type { ItemRenderState } from \"../../lib/select-data\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport {\n type InputSize,\n type InputVariant,\n inputControlClasses,\n inputShell,\n inputSlot,\n} from \"../input/input\"\nimport { CheckIcon, ChevronIcon, CloseIcon } from \"../popover/icons\"\nimport {\n popoverChevron,\n popoverClearTrigger,\n popoverContent,\n popoverEmpty,\n popoverGroupLabel,\n popoverIndicator,\n popoverList,\n popoverOption,\n scrollHighlightedIntoView,\n} from \"../popover/popover\"\n\n/**\n * Combobox — the kit's composable search-select primitive, a thin styled layer\n * over Ark UI's Combobox parts. It's the engine `Autocomplete` and `MultiSelect`\n * build on, and the escape hatch when the data-driven components don't fit.\n *\n * Compose the parts yourself, Ark-style — pass a `collection`\n * (`createListCollection`, re-exported here), filter it on input change, and\n * render `Combobox.Item`s from it:\n *\n * const collection = createListCollection({ items });\n * <Combobox.Root collection={collection} onInputValueChange={...}>\n * <Combobox.Control>\n * <Combobox.Input />\n * <Combobox.Trigger />\n * </Combobox.Control>\n * <Combobox.Content>\n * {items.map((i) => <Combobox.Item key={i.value} item={i}>{i.label}</Combobox.Item>)}\n * <Combobox.Empty>Nothing found</Combobox.Empty>\n * </Combobox.Content>\n * </Combobox.Root>\n *\n * `Content` is the floating popover panel (Portal + Positioner + card chrome) —\n * the right choice behind a `Trigger`. For a combobox that renders permanently\n * open inside a container you already own (no trigger of its own — see\n * `ComboboxList` / `MultiComboboxList`), use `Panel` instead: same `Ark.Content`\n * + `Ark.List` wiring, no Portal/Positioner/card chrome.\n *\n * `size` / `variant` / `color` set once on `Root` flow to the control and\n * options through context. Ark owns the state machine: filtering contract,\n * keyboard nav, `multiple`, custom values, RTL, and Field wiring.\n */\n\ntype ComboboxStyle = { size: InputSize; variant: InputVariant }\nconst ComboboxStyleContext = createContext<ComboboxStyle>({\n size: \"md\",\n variant: \"default\",\n})\n\n/** The combobox family's wording — Ark's own Combobox `translations` type, derived structurally\n * rather than imported by name (`IntlTranslations` lives in `@zag-js/combobox`, a transitive\n * dependency). `triggerLabel` names the chevron toggle, `clearTriggerLabel` the clear (×)\n * button. Shared by `Combobox`, `Autocomplete`, `MultiSelect`, `ComboboxList` and\n * `MultiComboboxList`, so one translation pack covers the family. */\nexport type ComboboxTranslations = NonNullable<Ark.RootProps<Ark.CollectionItem>[\"translations\"]>\n\n/** The family's English defaults — the kit's own wording, not zag's (\"Toggle suggestions\"). */\nexport const COMBOBOX_DEFAULT_TRANSLATIONS = {\n triggerLabel: \"Show options\",\n clearTriggerLabel: \"Clear value\",\n} as const satisfies ComboboxTranslations\n\n/** Shallow per-key merge over `COMBOBOX_DEFAULT_TRANSLATIONS`. */\nexport const resolveComboboxTranslations = (overrides?: ComboboxTranslations) =>\n overrides ? { ...COMBOBOX_DEFAULT_TRANSLATIONS, ...overrides } : COMBOBOX_DEFAULT_TRANSLATIONS\n\nexport type ComboboxRootProps<T extends Ark.CollectionItem = Ark.CollectionItem> = Omit<\n Ark.RootProps<T>,\n \"color\" | \"className\"\n> &\n WithTestId & {\n /** Control + option sizing. Flows to the parts via context. */\n size?: InputSize\n /** Control shell treatment. */\n variant?: InputVariant\n /** Focus-ring accent for the control. */\n className?: string\n }\n\n// Generic over the collection item type (like Ark's Root) so a typed\n// `ListCollection<T>` flows through without widening to `unknown`.\nconst Root = <T extends Ark.CollectionItem = Ark.CollectionItem>({\n size = \"md\",\n variant = \"default\",\n positioning,\n className,\n children,\n testId,\n translations,\n ...rest\n}: ComboboxRootProps<T>) => (\n <ComboboxStyleContext.Provider value={{ size, variant }}>\n <Ark.Root\n // Match the popover width to the control by default; callers can override.\n positioning={{ sameWidth: true, ...positioning }}\n // The popover's Content is an `overflow-hidden` clip wrapper, so the\n // machine's native auto-scroll (which needs Content to be scrollable) is a\n // no-op; route scrolling to the inner List scroller instead. Callers in\n // `rest` can still override.\n scrollToIndexFn={scrollHighlightedIntoView}\n className={cn(\"w-full\", className)}\n // The kit's English wording over zag's; a partial override keeps the other key.\n translations={resolveComboboxTranslations(translations)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {children}\n </Ark.Root>\n </ComboboxStyleContext.Provider>\n)\n\nexport type ComboboxControlProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Control>> &\n WithTestId & {\n /** Inline-start adornment (icon, label). */\n startSlot?: ReactNode\n /** Inline-end adornment — rendered before the composed Trigger / ClearTrigger. */\n endSlot?: ReactNode\n }\n\nconst Control = ({\n startSlot,\n endSlot,\n className,\n children,\n testId,\n asChild: _asChild,\n ...rest\n}: ComboboxControlProps) => {\n const { size, variant } = useContext(ComboboxStyleContext)\n return (\n <Ark.Control\n {...props({\n \"data-with-start-slot\": startSlot != null,\n // The composed Trigger / ClearTrigger always sits at the end.\n \"data-with-end-slot\": true,\n \"data-testid\": testId,\n })}\n className={cn(inputShell({ size, variant }), className)}\n {...rest}\n >\n {startSlot != null && (\n <span className={inputSlot} aria-hidden>\n {startSlot}\n </span>\n )}\n {children}\n {endSlot != null && <span className={inputSlot}>{endSlot}</span>}\n </Ark.Control>\n )\n}\n\n// `ComponentProps` (not `…WithoutRef`) so a caller's `ref` reaches the underlying\n// `<input>` — it's the focus target for the form-control contract (focus-on-error).\nconst Input = ({ className, testId, ...rest }: ComponentProps<typeof Ark.Input> & WithTestId) => (\n <Ark.Input\n className={cn(inputControlClasses, className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nconst Trigger = ({\n className,\n children,\n asChild,\n ...rest\n}: ComponentPropsWithoutRef<typeof Ark.Trigger>) => (\n <Ark.Trigger\n className={cn(\n popoverChevron,\n \"inline-flex cursor-pointer items-center justify-center rounded-sm\",\n \"data-[state=open]:rotate-180 disabled:cursor-not-allowed\",\n className,\n )}\n asChild={asChild}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => own ?? <ChevronIcon />)}\n </Ark.Trigger>\n)\n\nconst ClearTrigger = ({\n className,\n children,\n asChild,\n ...rest\n}: ComponentPropsWithoutRef<typeof Ark.ClearTrigger>) => (\n // zag marks the combobox clear control `tabIndex={-1}`; surface it in the tab\n // order so keyboard users can reach it (matching Select's clear and the tree\n // clears). A caller can still override via `tabIndex` in `rest`.\n <Ark.ClearTrigger\n tabIndex={0}\n className={cn(popoverClearTrigger, className)}\n asChild={asChild}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => own ?? <CloseIcon />)}\n </Ark.ClearTrigger>\n)\n\nconst Content = ({\n className,\n children,\n withPaddingTop = true,\n withinPortal = true,\n container,\n asChild: _asChild,\n ...rest\n}: NoAsChild<ComponentPropsWithoutRef<typeof Ark.Content>> & {\n withPaddingTop?: boolean\n /** Render the panel in a Portal so it escapes clipping ancestors.\n * Default `true`. */\n withinPortal?: boolean\n /** Portal target. Defaults to the enclosing `Modal`/`Drawer` when there is\n * one (so the panel stays above it), else `document.body`. */\n container?: HTMLElement | null\n}) => {\n const portalContainer = useOverlayContainer(container)\n // Holds an enclosing Modal/Drawer/Popover open while the list is; see `lib/overlay-layer.tsx`.\n useNestedLayer(useComboboxContext().open)\n return (\n <Portal disabled={!withinPortal} container={portalContainer}>\n <Ark.Positioner>\n <Ark.Content className={cn(popoverContent, className)} {...rest}>\n <Ark.List className={popoverList({ withPaddingTop })}>{children}</Ark.List>\n </Ark.Content>\n </Ark.Positioner>\n </Portal>\n )\n}\n\n/**\n * Inline alternative to `Content` — no `Portal`, no `Positioner`, no floating\n * chrome. For a combobox meant to render permanently open inside a container\n * the caller already owns (e.g. another `Popover`'s body), where the floating\n * machinery would just be dead weight and the wrong chrome (a card inside a\n * card). `getContentProps` doesn't require a Positioner to work — it's a plain\n * `hidden`-toggled element — so `Ark.Content` renders inline in normal flow.\n */\nconst Panel = ({\n className,\n children,\n withPaddingTop = true,\n asChild: _asChild,\n ...rest\n}: NoAsChild<ComponentPropsWithoutRef<typeof Ark.Content>> & { withPaddingTop?: boolean }) => {\n return (\n <Ark.Content {...rest}>\n <Ark.List className={cn(popoverList({ withPaddingTop }), className)}>{children}</Ark.List>\n </Ark.Content>\n )\n}\n\nexport type ComboboxItemProps = NoAsChild<\n Omit<ComponentPropsWithoutRef<typeof Ark.Item>, \"children\">\n> &\n WithTestId & {\n /**\n * Option content. A plain node renders as the label (the kit adds the check\n * indicator); a function takes over the whole row, receiving the item's live\n * state so it can draw its own affordance.\n */\n children?: ReactNode | ((state: ItemRenderState) => ReactNode)\n }\n\nconst Item = ({ className, children, testId, asChild: _asChild, ...rest }: ComboboxItemProps) => {\n const { size } = useContext(ComboboxStyleContext)\n return (\n <Ark.Item\n className={cn(popoverOption({ size }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {typeof children === \"function\" ? (\n <Ark.ItemContext>\n {(ctx) => children({ selected: ctx.selected, highlighted: ctx.highlighted })}\n </Ark.ItemContext>\n ) : (\n <>\n <Ark.ItemText>{children}</Ark.ItemText>\n <Ark.ItemIndicator className={popoverIndicator}>\n <CheckIcon />\n </Ark.ItemIndicator>\n </>\n )}\n </Ark.Item>\n )\n}\n\nexport type ComboboxGroupProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.ItemGroup>> &\n WithTestId & {\n /** Group heading rendered above the options. */\n label?: ReactNode\n }\n\nconst Group = ({\n label,\n className,\n children,\n testId,\n asChild: _asChild,\n ...rest\n}: ComboboxGroupProps) => (\n <Ark.ItemGroup className={className} {...props({ \"data-testid\": testId })} {...rest}>\n {label != null && (\n <Ark.ItemGroupLabel className={popoverGroupLabel}>{label}</Ark.ItemGroupLabel>\n )}\n {children}\n </Ark.ItemGroup>\n)\n\nconst Empty = ({ className, ...rest }: ComponentPropsWithoutRef<typeof Ark.Empty>) => (\n <Ark.Empty className={cn(popoverEmpty, className)} {...rest} />\n)\n\n/**\n * Composable parts namespace (Ark-style). `Context` is Ark's render-prop access\n * to the live machine api (e.g. to map over the filtered collection).\n */\nexport const Combobox = {\n Root,\n Control,\n Input,\n Trigger,\n ClearTrigger,\n Content,\n Panel,\n Item,\n Group,\n Empty,\n Context: Ark.Context,\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/combobox/combobox.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;;;;AAuEA,IAAM,uBAAuB,aAAA,CAA6B;AAAA,EACxD,IAAA,EAAM,IAAA;AAAA,EACN,OAAA,EAAS;AACX,CAAC,CAAA;AAUM,IAAM,6BAAA,GAAgC;AAAA,EAC3C,YAAA,EAAc,cAAA;AAAA,EACd,iBAAA,EAAmB;AACrB;AAGO,IAAM,2BAAA,GAA8B,CAAC,SAAA,KAC1C,SAAA,GAAY,EAAE,GAAG,6BAAA,EAA+B,GAAG,SAAA,EAAU,GAAI;AAiBnE,IAAM,OAAO,CAAoD;AAAA,EAC/D,IAAA,GAAO,IAAA;AAAA,EACP,OAAA,GAAU,SAAA;AAAA,EACV,WAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,GAAG;AACL,CAAA,qBACE,GAAA,CAAC,qBAAqB,QAAA,EAArB,EAA8B,OAAO,EAAE,IAAA,EAAM,SAAQ,EACpD,QAAA,kBAAA,GAAA;AAAA,EAACA,UAAA,CAAI,IAAA;AAAA,EAAJ;AAAA,IAEC,WAAA,EAAa,EAAE,SAAA,EAAW,IAAA,EAAM,GAAG,WAAA,EAAY;AAAA,IAK/C,eAAA,EAAiB,yBAAA;AAAA,IACjB,SAAA,EAAW,EAAA,CAAG,QAAA,EAAU,SAAS,CAAA;AAAA,IAEjC,YAAA,EAAc,4BAA4B,YAAY,CAAA;AAAA,IACrD,GAAG,KAAA,CAAM,EAAE,aA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A,IAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,SAASA,UAAA,CAAI;AACf","file":"chunk-2NTCQIRP.js","sourcesContent":["\"use client\"\n\nimport { Combobox as Ark, useComboboxContext } from \"@ark-ui/react/combobox\"\nimport { Portal } from \"@ark-ui/react/portal\"\nimport {\n type ComponentProps,\n type ComponentPropsWithoutRef,\n createContext,\n type ReactNode,\n useContext,\n} from \"react\"\nimport { composeChildren, type NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { useOverlayContainer } from \"../../lib/overlay-container\"\nimport { useNestedLayer } from \"../../lib/overlay-layer\"\nimport { props } from \"../../lib/props\"\nimport type { ItemRenderState } from \"../../lib/select-data\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport {\n type InputSize,\n type InputVariant,\n inputControlClasses,\n inputShell,\n inputSlot,\n} from \"../input/input\"\nimport { CheckIcon, ChevronIcon, CloseIcon } from \"../popover/icons\"\nimport {\n popoverChevron,\n popoverClearTrigger,\n popoverContent,\n popoverEmpty,\n popoverGroupLabel,\n popoverIndicator,\n popoverList,\n popoverOption,\n scrollHighlightedIntoView,\n} from \"../popover/popover\"\n\n/**\n * Combobox — the kit's composable search-select primitive, a thin styled layer\n * over Ark UI's Combobox parts. It's the engine `Autocomplete` and `MultiSelect`\n * build on, and the escape hatch when the data-driven components don't fit.\n *\n * Compose the parts yourself, Ark-style — pass a `collection`\n * (`createListCollection`, re-exported here), filter it on input change, and\n * render `Combobox.Item`s from it:\n *\n * const collection = createListCollection({ items });\n * <Combobox.Root collection={collection} onInputValueChange={...}>\n * <Combobox.Control>\n * <Combobox.Input />\n * <Combobox.Trigger />\n * </Combobox.Control>\n * <Combobox.Content>\n * {items.map((i) => <Combobox.Item key={i.value} item={i}>{i.label}</Combobox.Item>)}\n * <Combobox.Empty>Nothing found</Combobox.Empty>\n * </Combobox.Content>\n * </Combobox.Root>\n *\n * `Content` is the floating popover panel (Portal + Positioner + card chrome) —\n * the right choice behind a `Trigger`. For a combobox that renders permanently\n * open inside a container you already own (no trigger of its own — see\n * `ComboboxList` / `MultiComboboxList`), use `Panel` instead: same `Ark.Content`\n * + `Ark.List` wiring, no Portal/Positioner/card chrome.\n *\n * `size` / `variant` / `color` set once on `Root` flow to the control and\n * options through context. Ark owns the state machine: filtering contract,\n * keyboard nav, `multiple`, custom values, RTL, and Field wiring.\n */\n\ntype ComboboxStyle = { size: InputSize; variant: InputVariant }\nconst ComboboxStyleContext = createContext<ComboboxStyle>({\n size: \"md\",\n variant: \"default\",\n})\n\n/** The combobox family's wording — Ark's own Combobox `translations` type, derived structurally\n * rather than imported by name (`IntlTranslations` lives in `@zag-js/combobox`, a transitive\n * dependency). `triggerLabel` names the chevron toggle, `clearTriggerLabel` the clear (×)\n * button. Shared by `Combobox`, `Autocomplete`, `MultiSelect`, `ComboboxList` and\n * `MultiComboboxList`, so one translation pack covers the family. */\nexport type ComboboxTranslations = NonNullable<Ark.RootProps<Ark.CollectionItem>[\"translations\"]>\n\n/** The family's English defaults — the kit's own wording, not zag's (\"Toggle suggestions\"). */\nexport const COMBOBOX_DEFAULT_TRANSLATIONS = {\n triggerLabel: \"Show options\",\n clearTriggerLabel: \"Clear value\",\n} as const satisfies ComboboxTranslations\n\n/** Shallow per-key merge over `COMBOBOX_DEFAULT_TRANSLATIONS`. */\nexport const resolveComboboxTranslations = (overrides?: ComboboxTranslations) =>\n overrides ? { ...COMBOBOX_DEFAULT_TRANSLATIONS, ...overrides } : COMBOBOX_DEFAULT_TRANSLATIONS\n\nexport type ComboboxRootProps<T extends Ark.CollectionItem = Ark.CollectionItem> = Omit<\n Ark.RootProps<T>,\n \"color\" | \"className\"\n> &\n WithTestId & {\n /** Control + option sizing. Flows to the parts via context. */\n size?: InputSize\n /** Control shell treatment. */\n variant?: InputVariant\n /** Focus-ring accent for the control. */\n className?: string\n }\n\n// Generic over the collection item type (like Ark's Root) so a typed\n// `ListCollection<T>` flows through without widening to `unknown`.\nconst Root = <T extends Ark.CollectionItem = Ark.CollectionItem>({\n size = \"md\",\n variant = \"default\",\n positioning,\n className,\n children,\n testId,\n translations,\n ...rest\n}: ComboboxRootProps<T>) => (\n <ComboboxStyleContext.Provider value={{ size, variant }}>\n <Ark.Root\n // Match the popover width to the control by default; callers can override.\n positioning={{ sameWidth: true, ...positioning }}\n // The popover's Content is an `overflow-hidden` clip wrapper, so the\n // machine's native auto-scroll (which needs Content to be scrollable) is a\n // no-op; route scrolling to the inner List scroller instead. Callers in\n // `rest` can still override.\n scrollToIndexFn={scrollHighlightedIntoView}\n className={cn(\"w-full\", className)}\n // The kit's English wording over zag's; a partial override keeps the other key.\n translations={resolveComboboxTranslations(translations)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {children}\n </Ark.Root>\n </ComboboxStyleContext.Provider>\n)\n\nexport type ComboboxControlProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Control>> &\n WithTestId & {\n /** Inline-start adornment (icon, label). */\n startSlot?: ReactNode\n /** Inline-end adornment — rendered before the composed Trigger / ClearTrigger. */\n endSlot?: ReactNode\n }\n\nconst Control = ({\n startSlot,\n endSlot,\n className,\n children,\n testId,\n asChild: _asChild,\n ...rest\n}: ComboboxControlProps) => {\n const { size, variant } = useContext(ComboboxStyleContext)\n return (\n <Ark.Control\n {...props({\n \"data-with-start-slot\": startSlot != null,\n // The composed Trigger / ClearTrigger always sits at the end.\n \"data-with-end-slot\": true,\n \"data-testid\": testId,\n })}\n className={cn(inputShell({ size, variant }), className)}\n {...rest}\n >\n {startSlot != null && (\n <span className={inputSlot} aria-hidden>\n {startSlot}\n </span>\n )}\n {children}\n {endSlot != null && <span className={inputSlot}>{endSlot}</span>}\n </Ark.Control>\n )\n}\n\n// `ComponentProps` (not `…WithoutRef`) so a caller's `ref` reaches the underlying\n// `<input>` — it's the focus target for the form-control contract (focus-on-error).\nconst Input = ({ className, testId, ...rest }: ComponentProps<typeof Ark.Input> & WithTestId) => (\n <Ark.Input\n className={cn(inputControlClasses, className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nconst Trigger = ({\n className,\n children,\n asChild,\n ...rest\n}: ComponentPropsWithoutRef<typeof Ark.Trigger>) => (\n <Ark.Trigger\n className={cn(\n popoverChevron,\n \"inline-flex cursor-pointer items-center justify-center rounded-sm\",\n \"data-[state=open]:rotate-180 disabled:cursor-not-allowed\",\n className,\n )}\n asChild={asChild}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => own ?? <ChevronIcon />)}\n </Ark.Trigger>\n)\n\nconst ClearTrigger = ({\n className,\n children,\n asChild,\n ...rest\n}: ComponentPropsWithoutRef<typeof Ark.ClearTrigger>) => (\n // zag marks the combobox clear control `tabIndex={-1}`; surface it in the tab\n // order so keyboard users can reach it (matching Select's clear and the tree\n // clears). A caller can still override via `tabIndex` in `rest`.\n <Ark.ClearTrigger\n tabIndex={0}\n className={cn(popoverClearTrigger, className)}\n asChild={asChild}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => own ?? <CloseIcon />)}\n </Ark.ClearTrigger>\n)\n\nconst Content = ({\n className,\n children,\n withPaddingTop = true,\n withinPortal = true,\n container,\n asChild: _asChild,\n ...rest\n}: NoAsChild<ComponentPropsWithoutRef<typeof Ark.Content>> & {\n withPaddingTop?: boolean\n /** Render the panel in a Portal so it escapes clipping ancestors.\n * Default `true`. */\n withinPortal?: boolean\n /** Portal target. Defaults to the enclosing `Modal`/`Drawer` when there is\n * one (so the panel stays above it), else `document.body`. */\n container?: HTMLElement | null\n}) => {\n const portalContainer = useOverlayContainer(container)\n // Holds an enclosing Modal/Drawer/Popover open while the list is; see `lib/overlay-layer.tsx`.\n useNestedLayer(useComboboxContext().open)\n return (\n <Portal disabled={!withinPortal} container={portalContainer}>\n <Ark.Positioner>\n <Ark.Content className={cn(popoverContent, className)} {...rest}>\n <Ark.List className={popoverList({ withPaddingTop })}>{children}</Ark.List>\n </Ark.Content>\n </Ark.Positioner>\n </Portal>\n )\n}\n\n/**\n * Inline alternative to `Content` — no `Portal`, no `Positioner`, no floating\n * chrome. For a combobox meant to render permanently open inside a container\n * the caller already owns (e.g. another `Popover`'s body), where the floating\n * machinery would just be dead weight and the wrong chrome (a card inside a\n * card). `getContentProps` doesn't require a Positioner to work — it's a plain\n * `hidden`-toggled element — so `Ark.Content` renders inline in normal flow.\n */\nconst Panel = ({\n className,\n children,\n withPaddingTop = true,\n asChild: _asChild,\n ...rest\n}: NoAsChild<ComponentPropsWithoutRef<typeof Ark.Content>> & { withPaddingTop?: boolean }) => {\n return (\n <Ark.Content {...rest}>\n <Ark.List className={cn(popoverList({ withPaddingTop }), className)}>{children}</Ark.List>\n </Ark.Content>\n )\n}\n\nexport type ComboboxItemProps = NoAsChild<\n Omit<ComponentPropsWithoutRef<typeof Ark.Item>, \"children\">\n> &\n WithTestId & {\n /**\n * Option content. A plain node renders as the label (the kit adds the check\n * indicator); a function takes over the whole row, receiving the item's live\n * state so it can draw its own affordance.\n */\n children?: ReactNode | ((state: ItemRenderState) => ReactNode)\n }\n\nconst Item = ({ className, children, testId, asChild: _asChild, ...rest }: ComboboxItemProps) => {\n const { size } = useContext(ComboboxStyleContext)\n return (\n <Ark.Item\n className={cn(popoverOption({ size }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {typeof children === \"function\" ? (\n <Ark.ItemContext>\n {(ctx) => children({ selected: ctx.selected, highlighted: ctx.highlighted })}\n </Ark.ItemContext>\n ) : (\n <>\n <Ark.ItemText>{children}</Ark.ItemText>\n <Ark.ItemIndicator className={popoverIndicator}>\n <CheckIcon />\n </Ark.ItemIndicator>\n </>\n )}\n </Ark.Item>\n )\n}\n\nexport type ComboboxGroupProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.ItemGroup>> &\n WithTestId & {\n /** Group heading rendered above the options. */\n label?: ReactNode\n }\n\nconst Group = ({\n label,\n className,\n children,\n testId,\n asChild: _asChild,\n ...rest\n}: ComboboxGroupProps) => (\n <Ark.ItemGroup className={className} {...props({ \"data-testid\": testId })} {...rest}>\n {label != null && (\n <Ark.ItemGroupLabel className={popoverGroupLabel}>{label}</Ark.ItemGroupLabel>\n )}\n {children}\n </Ark.ItemGroup>\n)\n\nconst Empty = ({ className, ...rest }: ComponentPropsWithoutRef<typeof Ark.Empty>) => (\n <Ark.Empty className={cn(popoverEmpty, className)} {...rest} />\n)\n\n/**\n * Composable parts namespace (Ark-style). `Context` is Ark's render-prop access\n * to the live machine api (e.g. to map over the filtered collection).\n */\nexport const Combobox = {\n Root,\n Control,\n Input,\n Trigger,\n ClearTrigger,\n Content,\n Panel,\n Item,\n Group,\n Empty,\n Context: Ark.Context,\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SegmentGroup } from './chunk-
|
|
2
|
-
import { NumberInput } from './chunk-
|
|
1
|
+
import { SegmentGroup } from './chunk-NF2PBGD3.js';
|
|
2
|
+
import { NumberInput } from './chunk-DMI4KS32.js';
|
|
3
3
|
import { cn } from './chunk-4ASNIDV7.js';
|
|
4
4
|
import { useLocaleContext } from '@ark-ui/react/locale';
|
|
5
5
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
@@ -246,5 +246,5 @@ var TimeRow = ({
|
|
|
246
246
|
};
|
|
247
247
|
|
|
248
248
|
export { TimeRow, dayPeriodLabels, fromDisplayHour, is12Hour, resolveHourCycle, timeRowMinWidth, toDisplayHour };
|
|
249
|
-
//# sourceMappingURL=chunk-
|
|
250
|
-
//# sourceMappingURL=chunk-
|
|
249
|
+
//# sourceMappingURL=chunk-2TZU4LSX.js.map
|
|
250
|
+
//# sourceMappingURL=chunk-2TZU4LSX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/time-input/hour-cycle.ts","../src/components/time-input/time-row.tsx"],"names":[],"mappings":";;;;;;;AAQO,IAAM,mBAAmB,CAAC;AAAA,EAC/B,MAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,KAIiB;AACf,EAAA,IAAI,W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,aAAa,EAAA,EAAG;AAAA,gBACtC,EAAE,KAAA,EAAO,IAAA,EAAM,KAAA,EAAO,aAAa,EAAA;AAAG,eACxC;AAAA,cACA,OAAO,CAAA,CAAE,MAAA;AAAA,cACT,KAAA,EAAO,MAAA;AAAA,cACP,QAAA,EAAU,CAAC,KAAA,KAAU,cAAA,CAAe,KAAoB,CAAA;AAAA,cAGxD,IAAA;AAAA,cACA,QAAA;AAAA,cACA,QAAA;AAAA,cACA,OAAA;AAAA,cACA,WAAW,UAAA,EAAY,MAAA;AAAA,cAOvB,UAAA,EAAY,EAAE,KAAA,EAAO,iBAAA,EAAmB,OAAO,SAAA;AAAU;AAAA;AAC3D;AAAA;AAAA;AAEJ;AAEJ","file":"chunk-D3JYDAUZ.js","sourcesContent":["export type HourCycle = \"h11\" | \"h12\" | \"h23\" | \"h24\"\n\n/**\n * Resolve 12h vs 24h display (Req #6): an explicit `hourCycle` wins, then\n * `format`, else the locale's own convention via `Intl.DateTimeFormat`. Shared\n * by `TimeInput` and `DatePicker`'s embedded time panel so both pick the same\n * cycle for the same locale.\n */\nexport const resolveHourCycle = ({\n locale,\n format,\n hourCycle,\n}: {\n locale: string\n format?: 12 | 24\n hourCycle?: HourCycle\n}): HourCycle => {\n if (hourCycle) return hourCycle\n if (format !== undefined) return format === 12 ? \"h12\" : \"h23\"\n return Intl.DateTimeFormat(locale, { hour: \"numeric\" }).resolvedOptions().hourCycle as HourCycle\n}\n\n/** Whether a resolved cycle displays 12 hours + AM/PM (`h11`/`h12`) rather than all 24. */\nexport const is12Hour = (cycle: HourCycle): boolean => cycle === \"h11\" || cycle === \"h12\"\n\n/** The hours each cycle displays: `h11` 0–11, `h12` 1–12, `h23` 0–23, `h24` 1–24. In the two\n * cycles that start at 1, midnight (and, for `h12`, noon) reads as the top of the range. */\nexport const HOUR_RANGES: Record<HourCycle, { min: number; max: number }> = {\n h11: { min: 0, max: 11 },\n h12: { min: 1, max: 12 },\n h23: { min: 0, max: 23 },\n h24: { min: 1, max: 24 },\n}\n\n/** Convert a stored 24h hour (`0`–`23`) to the hour `cycle` displays, plus its period in the\n * 12-hour cycles (`null` otherwise) — e.g. midnight is `12` AM in `h12`, `0` AM in `h11`, `0` in\n * `h23` and `24` in `h24`. */\nexport const toDisplayHour = (\n hour24: number,\n cycle: HourCycle,\n): { hour: number; period: \"AM\" | \"PM\" | null } => {\n const twelveHour = is12Hour(cycle)\n const hour = twelveHour ? hour24 % 12 : hour24\n return {\n hour: hour === 0 && HOUR_RANGES[cycle].min === 1 ? HOUR_RANGES[cycle].max : hour,\n period: twelveHour ? (hour24 < 12 ? \"AM\" : \"PM\") : null,\n }\n}\n\n/** The inverse of `toDisplayHour`: a displayed hour (+ period in the 12-hour cycles) back to a\n * stored 24h hour. A missing hour reads as the start of its half of the day — midnight, or noon\n * once PM is picked — and a missing period as AM. */\nexport const fromDisplayHour = (\n hour: number | null,\n period: \"AM\" | \"PM\" | null,\n cycle: HourCycle,\n): number => {\n const offset = is12Hour(cycle) && period === \"PM\" ? 12 : 0\n if (hour === null) return offset\n return is12Hour(cycle) ? (hour % 12) + offset : hour % 24\n}\n\n/** Locale-correct AM/PM display strings (e.g. \"AM\"/\"PM\" en-US, \"午前\"/\"午後\" ja-JP), read via\n * `Intl.DateTimeFormat`'s own `dayPeriod` part rather than a hardcoded English literal. Keyed by\n * the same `\"AM\" | \"PM\"` domain value `toDisplayHour`/`fromDisplayHour` use throughout, so this only ever\n * changes what's *displayed*, never what's stored/serialized. */\nexport const dayPeriodLabels = (locale: string): Record<\"AM\" | \"PM\", string> => {\n const dayPeriod = (hour: number) =>\n new Intl.DateTimeFormat(locale, { hour: \"numeric\", hour12: true })\n .formatToParts(new Date(2000, 0, 1, hour))\n .find((part) => part.type === \"dayPeriod\")?.value ?? (hour < 12 ? \"AM\" : \"PM\")\n return { AM: dayPeriod(9), PM: dayPeriod(21) }\n}\n\n/** Locale-correct narrow unit abbreviations for the Hour/Minute/Second suffix (e.g. \"h\"/\"m\"/\"s\"\n * en-US, \"h\"/\"min\"/\"s\" fr-FR), read via `Intl.NumberFormat`'s own unit formatting rather than\n * hardcoded English literals. */\nconst UNIT_FALLBACK = { hour: \"h\", minute: \"m\", second: \"s\" } as const\n\nexport const timeUnitLabels = (\n locale: string,\n): { hour: string; minute: string; second: string } => {\n const unit = (u: \"hour\" | \"minute\" | \"second\") =>\n new Intl.NumberFormat(locale, { style: \"unit\", unit: u, unitDisplay: \"narrow\" })\n .formatToParts(1)\n .find((part) => part.type === \"unit\")?.value ?? UNIT_FALLBACK[u]\n return { hour: unit(\"hour\"), minute: unit(\"minute\"), second: unit(\"second\") }\n}\n","\"use client\"\n\nimport { useLocaleContext } from \"@ark-ui/react/locale\"\nimport type { FocusEvent, KeyboardEvent, Ref } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { InputVariant } from \"../input/input\"\nimport { NumberInput, type NumberInputTranslations } from \"../number-input/number-input\"\nimport { SegmentGroup } from \"../segment-group/segment-group\"\nimport {\n dayPeriodLabels,\n HOUR_RANGES,\n type HourCycle,\n is12Hour,\n timeUnitLabels,\n} from \"./hour-cycle\"\n\n/**\n * The HOUR/MINUTE (+ SECOND) + AM/PM row — the piece `TimeInput` wraps with\n * state, and `DatePicker`'s embedded time panel wraps with `api.setTime()`\n * (one implementation, two call sites). Operates entirely in *display* units\n * (the cycle's own hours — 0–11, 1–12, 0–23 or 1–24) — the always-24h stored `hour` conversion\n * happens at the caller's boundary, not here.\n */\n\ntype TimeRowClassNames = {\n hour?: string\n minute?: string\n second?: string\n period?: string\n}\n\n/** Overrides the sr-only accessible names for Hour/Minute/Second/Period — English by default.\n * Arbitrary microcopy with no locale-derivation path (unlike AM/PM and the unit suffixes,\n * which read from `Intl` instead). `incrementLabel`/`decrementLabel` are `NumberInput`'s own\n * keys, forwarded to each field's steppers (defaults `\"Increment\"` / `\"Decrement\"`). */\nexport type TimeRowTranslations = Pick<\n NumberInputTranslations,\n \"incrementLabel\" | \"decrementLabel\"\n> & {\n /** The whole row's group name when nothing visible labels it. Default `\"Time\"`. */\n time?: string\n hour?: string\n minute?: string\n second?: string\n period?: string\n}\n\n/** The row's English accessible names, merged once under `translations`. `NumberInput` keeps\n * its own stepper defaults. */\nconst TIME_ROW_DEFAULT_TRANSLATIONS = {\n time: \"Time\",\n hour: \"Hour\",\n minute: \"Minute\",\n second: \"Second\",\n period: \"Period\",\n} as const satisfies TimeRowTranslations\n\n/** Starting *and floor* size for the Hour/Minute/Second fields, per `size` — `flex-1`'s basis so\n * each field still grows to fill the row, plus an equal `min-width` so it never shrinks back\n * below that. Without the `min-width`, the field's inner `<input>` has `min-w-0` (needed so the\n * value can shrink instead of forcing the row to overflow when it's genuinely too narrow), which\n * otherwise lets `flex-1` starve it arbitrarily close to zero — that's exactly how the `<input>`\n * was measured shrinking to ~11px in a too-narrow `DatePicker` popover column, clipping the\n * 2-digit value. A too-narrow row now genuinely overflows (or wraps, if a wrapping ancestor\n * provides one) instead of silently clipping — the honest failure mode; `DatePicker`'s own\n * column-width fix (`timeRowMinWidth` below) is what actually prevents hitting it in practice.\n *\n * Calibrated against a real measurement, minus `shellGap`'s own per-size pixel value (6/6/8/10/12px\n * for xs/sm/md/lg/xl) — `NumberInput`'s value↔suffix pair no longer carries that gap (glued\n * together in their own nested row, see its own comment), so each field's true minimum content\n * width shrank by exactly that much. */\nexport const TIME_FIELD_BASIS_PX: Record<Size, number> = { xs: 64, sm: 72, md: 78, lg: 86, xl: 100 }\n/** The same widths as Tailwind classes, written out in full: Tailwind finds classes by scanning\n * source text (a consumer's build scans the shipped `dist`), so a class assembled from a template\n * literal is never generated. `time-row.test.ts` keeps these in step with `TIME_FIELD_BASIS_PX`. */\nexport const timeFieldBasis: Record<Size, string> = {\n xs: \"basis-[64px] min-w-[64px]\",\n sm: \"basis-[72px] min-w-[72px]\",\n md: \"basis-[78px] min-w-[78px]\",\n lg: \"basis-[86px] min-w-[86px]\",\n xl: \"basis-[100px] min-w-[100px]\",\n}\n\n/** The row's own gap between Hour/Minute/Second/Period (`gap-2` below) — flat across `size`,\n * unlike each field's *internal* value↔suffix↔steppers gap (`shellGap`, size-dependent). */\nconst ROW_GAP_PX = 8\n\n/** The AM/PM toggle's own natural (unstretched — it's `shrink-0`, not `flex-1`) rendered width\n * per `size`, measured directly rather than estimated. It wraps onto its own line below\n * Hour/Minute (the row's `flex-wrap` below) instead of forcing the whole row wider, so this\n * only matters for `timeRowMinWidth` as a floor *in case* it's ever wider than Hour+Minute\n * themselves — not as an unconditional addition to their combined width (see below). */\nconst PERIOD_WIDTH_PX: Record<Size, number> = { xs: 60, sm: 74, md: 88, lg: 110, xl: 133 }\n\n/** The row's own minimum rendered width for a given configuration. `DatePicker` uses this (see\n * its own `calendarColumnWidth` comment) to keep its popover column at least as wide as the\n * embedded time row needs, instead of only ever sizing off the calendar grid — otherwise the\n * row's `flex-1` + `min-w-0` fields silently shrink below their content size to fit.\n *\n * This is deliberately just Hour/Minute/[Second] at their basis plus the gaps *between* them —\n * not the AM/PM toggle's width added on top. The toggle wraps onto its own line (the row's\n * `flex-wrap` below) rather than forcing the row wider, so at a single narrow month it drops\n * below Hour/Minute instead of pushing the popover past the calendar's own width — the row only\n * needs to be as wide as the toggle itself in the (currently never hit — Hour+Minute together\n * are wider than the toggle at every size) case where that's the larger requirement. */\nexport const timeRowMinWidth = (\n size: Size,\n hourCycle: HourCycle,\n withSeconds: boolean | undefined,\n): number => {\n const fieldCount = 2 + (withSeconds ? 1 : 0)\n const fieldsWidth = fieldCount * TIME_FIELD_BASIS_PX[size] + (fieldCount - 1) * ROW_GAP_PX\n return is12Hour(hourCycle) ? Math.max(fieldsWidth, PERIOD_WIDTH_PX[size]) : fieldsWidth\n}\n\n/** ArrowLeft/ArrowRight at the edge of a field's text moves to the neighbouring field — caret at\n * its far side, so the motion reads as one continuous caret across the row — and from the last\n * number field \"next\" lands on the AM/PM toggle's checked (or first) radio. Inside the toggle the\n * arrows stay the radio group's own (switching AM/PM); Shift+Tab leaves it. `dir=\"rtl\"` mirrors\n * the keys, since the row's visual order is mirrored too. Anything else — a modifier, a\n * selection, a caret mid-text — keeps the native caret movement. */\nconst moveAcrossFields = (event: KeyboardEvent<HTMLDivElement>, dir: \"ltr\" | \"rtl\") => {\n if (event.key !== \"ArrowLeft\" && event.key !== \"ArrowRight\") return\n if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return\n const input = event.target\n if (!(input instanceof HTMLInputElement) || input.type !== \"text\") return\n const { selectionStart, selectionEnd, value } = input\n if (selectionStart !== selectionEnd) return\n const forward = (event.key === \"ArrowRight\") !== (dir === \"rtl\")\n if (forward ? selectionEnd !== value.length : selectionStart !== 0) return\n\n const row = event.currentTarget\n const fields = [...row.querySelectorAll<HTMLInputElement>('input[type=\"text\"]:not(:disabled)')]\n const next =\n fields[fields.indexOf(input) + (forward ? 1 : -1)] ??\n (forward\n ? (row.querySelector<HTMLInputElement>('input[type=\"radio\"]:checked:not(:disabled)') ??\n row.querySelector<HTMLInputElement>('input[type=\"radio\"]:not(:disabled)'))\n : null)\n if (!next) return\n event.preventDefault()\n next.focus()\n if (next.type === \"text\") {\n const caret = forward ? 0 : next.value.length\n next.setSelectionRange(caret, caret)\n }\n}\n\nexport type TimeRowProps = {\n hour: number | null\n minute: number | null\n second?: number | null\n onHourChange: (hour: number | null) => void\n onMinuteChange: (minute: number | null) => void\n onSecondChange?: (second: number | null) => void\n period: \"AM\" | \"PM\" | null\n onPeriodChange: (period: \"AM\" | \"PM\") => void\n hourCycle: HourCycle\n minuteStep?: number\n withSeconds?: boolean\n /** Placeholder shown in each empty Hour/Minute/Second field. Default `\"--\"`. */\n placeholder?: string\n /** Resolves the locale-correct AM/PM labels + Hour/Minute/Second unit suffixes via `Intl`.\n * Falls back to `useLocaleContext()` when omitted. */\n locale?: string\n /** Overrides the sr-only Hour/Minute/Second/Period accessible names. English by default. */\n translations?: TimeRowTranslations\n size?: Size\n variant?: InputVariant\n disabled?: boolean\n readOnly?: boolean\n invalid?: boolean\n /** Lands on the hour field's `<input>` for focus-on-error. */\n ref?: Ref<HTMLInputElement>\n /** Forwarded to the hour field's `<input>`; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void\n /** Names the row's `role=\"group\"` directly when no visible label points at it. Defaults to\n * `translations.time` (`\"Time\"`), so the group is never anonymous. */\n \"aria-label\"?: string\n /** Names the row's `role=\"group\"` from a visible label, e.g. `TimeInput`'s field label or\n * `DatePicker`'s \"Start time\" / \"End time\". Without a name a screen reader enters the group\n * hearing only \"Hour\". */\n \"aria-labelledby\"?: string\n /** Helper / error text read after the group's name. */\n \"aria-describedby\"?: string\n className?: string\n classNames?: TimeRowClassNames\n}\n\nexport const TimeRow = ({\n hour,\n minute,\n second,\n onHourChange,\n onMinuteChange,\n onSecondChange,\n period,\n onPeriodChange,\n hourCycle,\n minuteStep = 1,\n withSeconds,\n placeholder = \"--\",\n locale,\n translations,\n size = \"md\",\n variant = \"default\",\n disabled,\n readOnly,\n invalid,\n ref,\n onBlur,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n className,\n classNames,\n}: TimeRowProps) => {\n const { locale: contextLocale, dir } = useLocaleContext()\n const resolvedLocale = locale ?? contextLocale\n const twelveHour = is12Hour(hourCycle)\n const units = timeUnitLabels(resolvedLocale)\n const periodLabels = twelveHour ? dayPeriodLabels(resolvedLocale) : null\n const t = { ...TIME_ROW_DEFAULT_TRANSLATIONS, ...translations }\n\n return (\n // `flex-wrap`: at a single narrow month under `DatePicker`, Hour/Minute/[Second] fit the\n // calendar's own width but the AM/PM toggle doesn't (see `timeRowMinWidth`'s comment) — this\n // drops it to its own line there instead of forcing the whole popover wider than the\n // calendar to fit it on the same line. No visual change wherever there's already enough\n // width (every other context) — wrapping only kicks in once it's genuinely too narrow.\n // `role=\"group\"`: Hour/Minute/[Second]/Period are the parts of one time value — and the\n // row owns keyboard behaviour across them (`moveAcrossFields`), which a bare `<div>` can't.\n // biome-ignore lint/a11y/useSemanticElements: a `<fieldset>` brings UA border/padding/`min-inline-size` that fight this wrapping flex row, for the same `group` semantics\n <div\n role=\"group\"\n aria-label={ariaLabelledBy ? undefined : (ariaLabel ?? t.time)}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n className={cn(\"flex flex-wrap items-end gap-2\", className)}\n onKeyDown={(event) => moveAcrossFields(event, dir)}\n >\n <NumberInput\n ref={ref}\n onBlur={onBlur}\n label={t.hour}\n placeholder={placeholder}\n value={hour}\n onChange={onHourChange}\n min={HOUR_RANGES[hourCycle].min}\n max={HOUR_RANGES[hourCycle].max}\n step={1}\n wrap\n formatOptions={{ minimumIntegerDigits: 2 }}\n size={size}\n variant={variant}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n // \"Hour\" stays the accessible name (sr-only keeps it in the a11y tree,\n // just visually hidden) — the unit suffix is a decorative stand-in,\n // right next to the value once it's right-aligned (`text-end`).\n translations={t}\n suffix={units.hour}\n className={classNames?.hour}\n classNames={{\n field: cn(\"flex-1\", timeFieldBasis[size]),\n label: \"sr-only\",\n input: \"text-end\",\n }}\n />\n <NumberInput\n label={t.minute}\n placeholder={placeholder}\n value={minute}\n onChange={onMinuteChange}\n min={0}\n max={59}\n step={minuteStep}\n wrap\n formatOptions={{ minimumIntegerDigits: 2 }}\n size={size}\n variant={variant}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n translations={t}\n suffix={units.minute}\n className={classNames?.minute}\n classNames={{\n field: cn(\"flex-1\", timeFieldBasis[size]),\n label: \"sr-only\",\n input: \"text-end\",\n }}\n />\n {withSeconds && (\n <NumberInput\n label={t.second}\n placeholder={placeholder}\n value={second ?? null}\n onChange={onSecondChange}\n min={0}\n max={59}\n step={1}\n wrap\n formatOptions={{ minimumIntegerDigits: 2 }}\n size={size}\n variant={variant}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n translations={t}\n suffix={units.second}\n className={classNames?.second}\n classNames={{\n field: cn(\"flex-1\", timeFieldBasis[size]),\n label: \"sr-only\",\n input: \"text-end\",\n }}\n />\n )}\n {twelveHour && periodLabels && (\n <SegmentGroup\n data={[\n { value: \"AM\", label: periodLabels.AM },\n { value: \"PM\", label: periodLabels.PM },\n ]}\n label={t.period}\n value={period}\n onChange={(value) => onPeriodChange(value as \"AM\" | \"PM\")}\n // `SegmentGroup`'s sizes match `NumberInput`'s box height exactly, so\n // the AM/PM toggle sits flush with the Hour/Minute fields.\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n className={classNames?.period}\n // Unlike Hour/Minute/Second, the AM/PM toggle has a fixed, small set of labels — it\n // doesn't need (or look right) stretching to share the row's leftover width. `w-auto`\n // cancels the Field wrapper's own default `w-full` (which would otherwise still set its\n // flex-basis to the full row width even without `flex-1`); `shrink-0` keeps it stable.\n // \"Period\" keeps the accessible name (sr-only) but no visible label or suffix — the\n // segment control itself already shows \"AM\"/\"PM\", self-descriptive.\n classNames={{ field: \"w-auto shrink-0\", label: \"sr-only\" }}\n />\n )}\n </div>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/time-input/hour-cycle.ts","../src/components/time-input/time-row.tsx"],"names":[],"mappings":";;;;;;;AAQO,IAAM,mBAAmB,CAAC;AAAA,EAC/B,MAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,KAIiB;AACf,EAAA,IAAI,WAAW,OAAO,SAAA;AACtB,EAAA,IAAI,MAAA,KAAW,MAAA,EAAW,OAAO,MAAA,KAAW,KAAK,KAAA,GAAQ,KAAA;AACzD,EAAA,OAAO,IAAA,CAAK,eAAe,MAAA,EAAQ,EAAE,MAAM,SAAA,EAAW,CAAA,CAAE,eAAA,EAAgB,CAAE,SAAA;AAC5E;AAGO,IAAM,QAAA,GAAW,CAAC,KAAA,KAA8B,KAAA,KAAU,SAAS,KAAA,KAAU;AAI7E,IAAM,WAAA,GAA+D;AAAA,EAC1E,G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AAA,cAOvB,UAAA,EAAY,EAAE,KAAA,EAAO,iBAAA,EAAmB,OAAO,SAAA;AAAU;AAAA;AAC3D;AAAA;AAAA;AAEJ;AAEJ","file":"chunk-2TZU4LSX.js","sourcesContent":["export type HourCycle = \"h11\" | \"h12\" | \"h23\" | \"h24\"\n\n/**\n * Resolve 12h vs 24h display (Req #6): an explicit `hourCycle` wins, then\n * `format`, else the locale's own convention via `Intl.DateTimeFormat`. Shared\n * by `TimeInput` and `DatePicker`'s embedded time panel so both pick the same\n * cycle for the same locale.\n */\nexport const resolveHourCycle = ({\n locale,\n format,\n hourCycle,\n}: {\n locale: string\n format?: 12 | 24\n hourCycle?: HourCycle\n}): HourCycle => {\n if (hourCycle) return hourCycle\n if (format !== undefined) return format === 12 ? \"h12\" : \"h23\"\n return Intl.DateTimeFormat(locale, { hour: \"numeric\" }).resolvedOptions().hourCycle as HourCycle\n}\n\n/** Whether a resolved cycle displays 12 hours + AM/PM (`h11`/`h12`) rather than all 24. */\nexport const is12Hour = (cycle: HourCycle): boolean => cycle === \"h11\" || cycle === \"h12\"\n\n/** The hours each cycle displays: `h11` 0–11, `h12` 1–12, `h23` 0–23, `h24` 1–24. In the two\n * cycles that start at 1, midnight (and, for `h12`, noon) reads as the top of the range. */\nexport const HOUR_RANGES: Record<HourCycle, { min: number; max: number }> = {\n h11: { min: 0, max: 11 },\n h12: { min: 1, max: 12 },\n h23: { min: 0, max: 23 },\n h24: { min: 1, max: 24 },\n}\n\n/** Convert a stored 24h hour (`0`–`23`) to the hour `cycle` displays, plus its period in the\n * 12-hour cycles (`null` otherwise) — e.g. midnight is `12` AM in `h12`, `0` AM in `h11`, `0` in\n * `h23` and `24` in `h24`. */\nexport const toDisplayHour = (\n hour24: number,\n cycle: HourCycle,\n): { hour: number; period: \"AM\" | \"PM\" | null } => {\n const twelveHour = is12Hour(cycle)\n const hour = twelveHour ? hour24 % 12 : hour24\n return {\n hour: hour === 0 && HOUR_RANGES[cycle].min === 1 ? HOUR_RANGES[cycle].max : hour,\n period: twelveHour ? (hour24 < 12 ? \"AM\" : \"PM\") : null,\n }\n}\n\n/** The inverse of `toDisplayHour`: a displayed hour (+ period in the 12-hour cycles) back to a\n * stored 24h hour. A missing hour reads as the start of its half of the day — midnight, or noon\n * once PM is picked — and a missing period as AM. */\nexport const fromDisplayHour = (\n hour: number | null,\n period: \"AM\" | \"PM\" | null,\n cycle: HourCycle,\n): number => {\n const offset = is12Hour(cycle) && period === \"PM\" ? 12 : 0\n if (hour === null) return offset\n return is12Hour(cycle) ? (hour % 12) + offset : hour % 24\n}\n\n/** Locale-correct AM/PM display strings (e.g. \"AM\"/\"PM\" en-US, \"午前\"/\"午後\" ja-JP), read via\n * `Intl.DateTimeFormat`'s own `dayPeriod` part rather than a hardcoded English literal. Keyed by\n * the same `\"AM\" | \"PM\"` domain value `toDisplayHour`/`fromDisplayHour` use throughout, so this only ever\n * changes what's *displayed*, never what's stored/serialized. */\nexport const dayPeriodLabels = (locale: string): Record<\"AM\" | \"PM\", string> => {\n const dayPeriod = (hour: number) =>\n new Intl.DateTimeFormat(locale, { hour: \"numeric\", hour12: true })\n .formatToParts(new Date(2000, 0, 1, hour))\n .find((part) => part.type === \"dayPeriod\")?.value ?? (hour < 12 ? \"AM\" : \"PM\")\n return { AM: dayPeriod(9), PM: dayPeriod(21) }\n}\n\n/** Locale-correct narrow unit abbreviations for the Hour/Minute/Second suffix (e.g. \"h\"/\"m\"/\"s\"\n * en-US, \"h\"/\"min\"/\"s\" fr-FR), read via `Intl.NumberFormat`'s own unit formatting rather than\n * hardcoded English literals. */\nconst UNIT_FALLBACK = { hour: \"h\", minute: \"m\", second: \"s\" } as const\n\nexport const timeUnitLabels = (\n locale: string,\n): { hour: string; minute: string; second: string } => {\n const unit = (u: \"hour\" | \"minute\" | \"second\") =>\n new Intl.NumberFormat(locale, { style: \"unit\", unit: u, unitDisplay: \"narrow\" })\n .formatToParts(1)\n .find((part) => part.type === \"unit\")?.value ?? UNIT_FALLBACK[u]\n return { hour: unit(\"hour\"), minute: unit(\"minute\"), second: unit(\"second\") }\n}\n","\"use client\"\n\nimport { useLocaleContext } from \"@ark-ui/react/locale\"\nimport type { FocusEvent, KeyboardEvent, Ref } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { InputVariant } from \"../input/input\"\nimport { NumberInput, type NumberInputTranslations } from \"../number-input/number-input\"\nimport { SegmentGroup } from \"../segment-group/segment-group\"\nimport {\n dayPeriodLabels,\n HOUR_RANGES,\n type HourCycle,\n is12Hour,\n timeUnitLabels,\n} from \"./hour-cycle\"\n\n/**\n * The HOUR/MINUTE (+ SECOND) + AM/PM row — the piece `TimeInput` wraps with\n * state, and `DatePicker`'s embedded time panel wraps with `api.setTime()`\n * (one implementation, two call sites). Operates entirely in *display* units\n * (the cycle's own hours — 0–11, 1–12, 0–23 or 1–24) — the always-24h stored `hour` conversion\n * happens at the caller's boundary, not here.\n */\n\ntype TimeRowClassNames = {\n hour?: string\n minute?: string\n second?: string\n period?: string\n}\n\n/** Overrides the sr-only accessible names for Hour/Minute/Second/Period — English by default.\n * Arbitrary microcopy with no locale-derivation path (unlike AM/PM and the unit suffixes,\n * which read from `Intl` instead). `incrementLabel`/`decrementLabel` are `NumberInput`'s own\n * keys, forwarded to each field's steppers (defaults `\"Increment\"` / `\"Decrement\"`). */\nexport type TimeRowTranslations = Pick<\n NumberInputTranslations,\n \"incrementLabel\" | \"decrementLabel\"\n> & {\n /** The whole row's group name when nothing visible labels it. Default `\"Time\"`. */\n time?: string\n hour?: string\n minute?: string\n second?: string\n period?: string\n}\n\n/** The row's English accessible names, merged once under `translations`. `NumberInput` keeps\n * its own stepper defaults. */\nconst TIME_ROW_DEFAULT_TRANSLATIONS = {\n time: \"Time\",\n hour: \"Hour\",\n minute: \"Minute\",\n second: \"Second\",\n period: \"Period\",\n} as const satisfies TimeRowTranslations\n\n/** Starting *and floor* size for the Hour/Minute/Second fields, per `size` — `flex-1`'s basis so\n * each field still grows to fill the row, plus an equal `min-width` so it never shrinks back\n * below that. Without the `min-width`, the field's inner `<input>` has `min-w-0` (needed so the\n * value can shrink instead of forcing the row to overflow when it's genuinely too narrow), which\n * otherwise lets `flex-1` starve it arbitrarily close to zero — that's exactly how the `<input>`\n * was measured shrinking to ~11px in a too-narrow `DatePicker` popover column, clipping the\n * 2-digit value. A too-narrow row now genuinely overflows (or wraps, if a wrapping ancestor\n * provides one) instead of silently clipping — the honest failure mode; `DatePicker`'s own\n * column-width fix (`timeRowMinWidth` below) is what actually prevents hitting it in practice.\n *\n * Calibrated against a real measurement, minus `shellGap`'s own per-size pixel value (6/6/8/10/12px\n * for xs/sm/md/lg/xl) — `NumberInput`'s value↔suffix pair no longer carries that gap (glued\n * together in their own nested row, see its own comment), so each field's true minimum content\n * width shrank by exactly that much. */\nexport const TIME_FIELD_BASIS_PX: Record<Size, number> = { xs: 64, sm: 72, md: 78, lg: 86, xl: 100 }\n/** The same widths as Tailwind classes, written out in full: Tailwind finds classes by scanning\n * source text (a consumer's build scans the shipped `dist`), so a class assembled from a template\n * literal is never generated. `time-row.test.ts` keeps these in step with `TIME_FIELD_BASIS_PX`. */\nexport const timeFieldBasis: Record<Size, string> = {\n xs: \"basis-[64px] min-w-[64px]\",\n sm: \"basis-[72px] min-w-[72px]\",\n md: \"basis-[78px] min-w-[78px]\",\n lg: \"basis-[86px] min-w-[86px]\",\n xl: \"basis-[100px] min-w-[100px]\",\n}\n\n/** The row's own gap between Hour/Minute/Second/Period (`gap-2` below) — flat across `size`,\n * unlike each field's *internal* value↔suffix↔steppers gap (`shellGap`, size-dependent). */\nconst ROW_GAP_PX = 8\n\n/** The AM/PM toggle's own natural (unstretched — it's `shrink-0`, not `flex-1`) rendered width\n * per `size`, measured directly rather than estimated. It wraps onto its own line below\n * Hour/Minute (the row's `flex-wrap` below) instead of forcing the whole row wider, so this\n * only matters for `timeRowMinWidth` as a floor *in case* it's ever wider than Hour+Minute\n * themselves — not as an unconditional addition to their combined width (see below). */\nconst PERIOD_WIDTH_PX: Record<Size, number> = { xs: 60, sm: 74, md: 88, lg: 110, xl: 133 }\n\n/** The row's own minimum rendered width for a given configuration. `DatePicker` uses this (see\n * its own `calendarColumnWidth` comment) to keep its popover column at least as wide as the\n * embedded time row needs, instead of only ever sizing off the calendar grid — otherwise the\n * row's `flex-1` + `min-w-0` fields silently shrink below their content size to fit.\n *\n * This is deliberately just Hour/Minute/[Second] at their basis plus the gaps *between* them —\n * not the AM/PM toggle's width added on top. The toggle wraps onto its own line (the row's\n * `flex-wrap` below) rather than forcing the row wider, so at a single narrow month it drops\n * below Hour/Minute instead of pushing the popover past the calendar's own width — the row only\n * needs to be as wide as the toggle itself in the (currently never hit — Hour+Minute together\n * are wider than the toggle at every size) case where that's the larger requirement. */\nexport const timeRowMinWidth = (\n size: Size,\n hourCycle: HourCycle,\n withSeconds: boolean | undefined,\n): number => {\n const fieldCount = 2 + (withSeconds ? 1 : 0)\n const fieldsWidth = fieldCount * TIME_FIELD_BASIS_PX[size] + (fieldCount - 1) * ROW_GAP_PX\n return is12Hour(hourCycle) ? Math.max(fieldsWidth, PERIOD_WIDTH_PX[size]) : fieldsWidth\n}\n\n/** ArrowLeft/ArrowRight at the edge of a field's text moves to the neighbouring field — caret at\n * its far side, so the motion reads as one continuous caret across the row — and from the last\n * number field \"next\" lands on the AM/PM toggle's checked (or first) radio. Inside the toggle the\n * arrows stay the radio group's own (switching AM/PM); Shift+Tab leaves it. `dir=\"rtl\"` mirrors\n * the keys, since the row's visual order is mirrored too. Anything else — a modifier, a\n * selection, a caret mid-text — keeps the native caret movement. */\nconst moveAcrossFields = (event: KeyboardEvent<HTMLDivElement>, dir: \"ltr\" | \"rtl\") => {\n if (event.key !== \"ArrowLeft\" && event.key !== \"ArrowRight\") return\n if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return\n const input = event.target\n if (!(input instanceof HTMLInputElement) || input.type !== \"text\") return\n const { selectionStart, selectionEnd, value } = input\n if (selectionStart !== selectionEnd) return\n const forward = (event.key === \"ArrowRight\") !== (dir === \"rtl\")\n if (forward ? selectionEnd !== value.length : selectionStart !== 0) return\n\n const row = event.currentTarget\n const fields = [...row.querySelectorAll<HTMLInputElement>('input[type=\"text\"]:not(:disabled)')]\n const next =\n fields[fields.indexOf(input) + (forward ? 1 : -1)] ??\n (forward\n ? (row.querySelector<HTMLInputElement>('input[type=\"radio\"]:checked:not(:disabled)') ??\n row.querySelector<HTMLInputElement>('input[type=\"radio\"]:not(:disabled)'))\n : null)\n if (!next) return\n event.preventDefault()\n next.focus()\n if (next.type === \"text\") {\n const caret = forward ? 0 : next.value.length\n next.setSelectionRange(caret, caret)\n }\n}\n\nexport type TimeRowProps = {\n hour: number | null\n minute: number | null\n second?: number | null\n onHourChange: (hour: number | null) => void\n onMinuteChange: (minute: number | null) => void\n onSecondChange?: (second: number | null) => void\n period: \"AM\" | \"PM\" | null\n onPeriodChange: (period: \"AM\" | \"PM\") => void\n hourCycle: HourCycle\n minuteStep?: number\n withSeconds?: boolean\n /** Placeholder shown in each empty Hour/Minute/Second field. Default `\"--\"`. */\n placeholder?: string\n /** Resolves the locale-correct AM/PM labels + Hour/Minute/Second unit suffixes via `Intl`.\n * Falls back to `useLocaleContext()` when omitted. */\n locale?: string\n /** Overrides the sr-only Hour/Minute/Second/Period accessible names. English by default. */\n translations?: TimeRowTranslations\n size?: Size\n variant?: InputVariant\n disabled?: boolean\n readOnly?: boolean\n invalid?: boolean\n /** Lands on the hour field's `<input>` for focus-on-error. */\n ref?: Ref<HTMLInputElement>\n /** Forwarded to the hour field's `<input>`; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void\n /** Names the row's `role=\"group\"` directly when no visible label points at it. Defaults to\n * `translations.time` (`\"Time\"`), so the group is never anonymous. */\n \"aria-label\"?: string\n /** Names the row's `role=\"group\"` from a visible label, e.g. `TimeInput`'s field label or\n * `DatePicker`'s \"Start time\" / \"End time\". Without a name a screen reader enters the group\n * hearing only \"Hour\". */\n \"aria-labelledby\"?: string\n /** Helper / error text read after the group's name. */\n \"aria-describedby\"?: string\n className?: string\n classNames?: TimeRowClassNames\n}\n\nexport const TimeRow = ({\n hour,\n minute,\n second,\n onHourChange,\n onMinuteChange,\n onSecondChange,\n period,\n onPeriodChange,\n hourCycle,\n minuteStep = 1,\n withSeconds,\n placeholder = \"--\",\n locale,\n translations,\n size = \"md\",\n variant = \"default\",\n disabled,\n readOnly,\n invalid,\n ref,\n onBlur,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n className,\n classNames,\n}: TimeRowProps) => {\n const { locale: contextLocale, dir } = useLocaleContext()\n const resolvedLocale = locale ?? contextLocale\n const twelveHour = is12Hour(hourCycle)\n const units = timeUnitLabels(resolvedLocale)\n const periodLabels = twelveHour ? dayPeriodLabels(resolvedLocale) : null\n const t = { ...TIME_ROW_DEFAULT_TRANSLATIONS, ...translations }\n\n return (\n // `flex-wrap`: at a single narrow month under `DatePicker`, Hour/Minute/[Second] fit the\n // calendar's own width but the AM/PM toggle doesn't (see `timeRowMinWidth`'s comment) — this\n // drops it to its own line there instead of forcing the whole popover wider than the\n // calendar to fit it on the same line. No visual change wherever there's already enough\n // width (every other context) — wrapping only kicks in once it's genuinely too narrow.\n // `role=\"group\"`: Hour/Minute/[Second]/Period are the parts of one time value — and the\n // row owns keyboard behaviour across them (`moveAcrossFields`), which a bare `<div>` can't.\n // biome-ignore lint/a11y/useSemanticElements: a `<fieldset>` brings UA border/padding/`min-inline-size` that fight this wrapping flex row, for the same `group` semantics\n <div\n role=\"group\"\n aria-label={ariaLabelledBy ? undefined : (ariaLabel ?? t.time)}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n className={cn(\"flex flex-wrap items-end gap-2\", className)}\n onKeyDown={(event) => moveAcrossFields(event, dir)}\n >\n <NumberInput\n ref={ref}\n onBlur={onBlur}\n label={t.hour}\n placeholder={placeholder}\n value={hour}\n onChange={onHourChange}\n min={HOUR_RANGES[hourCycle].min}\n max={HOUR_RANGES[hourCycle].max}\n step={1}\n wrap\n formatOptions={{ minimumIntegerDigits: 2 }}\n size={size}\n variant={variant}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n // \"Hour\" stays the accessible name (sr-only keeps it in the a11y tree,\n // just visually hidden) — the unit suffix is a decorative stand-in,\n // right next to the value once it's right-aligned (`text-end`).\n translations={t}\n suffix={units.hour}\n className={classNames?.hour}\n classNames={{\n field: cn(\"flex-1\", timeFieldBasis[size]),\n label: \"sr-only\",\n input: \"text-end\",\n }}\n />\n <NumberInput\n label={t.minute}\n placeholder={placeholder}\n value={minute}\n onChange={onMinuteChange}\n min={0}\n max={59}\n step={minuteStep}\n wrap\n formatOptions={{ minimumIntegerDigits: 2 }}\n size={size}\n variant={variant}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n translations={t}\n suffix={units.minute}\n className={classNames?.minute}\n classNames={{\n field: cn(\"flex-1\", timeFieldBasis[size]),\n label: \"sr-only\",\n input: \"text-end\",\n }}\n />\n {withSeconds && (\n <NumberInput\n label={t.second}\n placeholder={placeholder}\n value={second ?? null}\n onChange={onSecondChange}\n min={0}\n max={59}\n step={1}\n wrap\n formatOptions={{ minimumIntegerDigits: 2 }}\n size={size}\n variant={variant}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n translations={t}\n suffix={units.second}\n className={classNames?.second}\n classNames={{\n field: cn(\"flex-1\", timeFieldBasis[size]),\n label: \"sr-only\",\n input: \"text-end\",\n }}\n />\n )}\n {twelveHour && periodLabels && (\n <SegmentGroup\n data={[\n { value: \"AM\", label: periodLabels.AM },\n { value: \"PM\", label: periodLabels.PM },\n ]}\n label={t.period}\n value={period}\n onChange={(value) => onPeriodChange(value as \"AM\" | \"PM\")}\n // `SegmentGroup`'s sizes match `NumberInput`'s box height exactly, so\n // the AM/PM toggle sits flush with the Hour/Minute fields.\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n className={classNames?.period}\n // Unlike Hour/Minute/Second, the AM/PM toggle has a fixed, small set of labels — it\n // doesn't need (or look right) stretching to share the row's leftover width. `w-auto`\n // cancels the Field wrapper's own default `w-full` (which would otherwise still set its\n // flex-basis to the full row width even without `flex-1`); `shrink-0` keeps it stable.\n // \"Period\" keeps the accessible name (sr-only) but no visible label or suffix — the\n // segment control itself already shows \"AM\"/\"PM\", self-descriptive.\n classNames={{ field: \"w-auto shrink-0\", label: \"sr-only\" }}\n />\n )}\n </div>\n )\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button } from './chunk-
|
|
1
|
+
import { Button } from './chunk-SCXXJDKQ.js';
|
|
2
2
|
import { saveFile } from './chunk-EIBDLRAR.js';
|
|
3
3
|
import { mergeIcons, iconStroke } from './chunk-XXOR34T4.js';
|
|
4
4
|
import { Spinner } from './chunk-D2QIPQ74.js';
|
|
@@ -136,5 +136,5 @@ var DownloadButton = ({
|
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
export { DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS, DownloadButton };
|
|
139
|
-
//# sourceMappingURL=chunk-
|
|
140
|
-
//# sourceMappingURL=chunk-
|
|
139
|
+
//# sourceMappingURL=chunk-6IRMKF5T.js.map
|
|
140
|
+
//# sourceMappingURL=chunk-6IRMKF5T.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/download-button/download-button.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAkEO,IAAM,oCAAA,GAA6E;AAAA,EACxF,KAAA,EAAO,UAAA;AAAA,EACP,OAAA,EAAS,0BAAA;AAAA,EACT,OAAO,CAAC,IAAA,KAAU,IAAA,GAAO,CAAA,EAAG,IAAI,CAAA,uBAAA,CAAA,GAA4B;AAC9D;AAIA,IAAM,aAAA,GAA2D;AAAA,EAC/D,QAAA,kBAAU,GAAA,CAAC,QAAA,EAAA,E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CAAA,CAAE,KAAA;AAAA,UACd,wBAAQ,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAW,YAAE,OAAA,EAAQ;AAAA;AAAA;AAAA,KAChD;AAAA,oBAEF,GAAA,CAAC,MAAA,EAAA,EAAK,IAAA,EAAK,QAAA,EAAS,SAAA,EAAW,cAAc,YAAA,EAAW,iBAAA,EAAkB,WAAA,EAAU,QAAA,EACjF,QAAA,EAAA,OAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-DJLNGWMM.js","sourcesContent":["\"use client\"\n\nimport { ark } from \"@ark-ui/react\"\nimport { Download } from \"lucide-react\"\nimport { type MouseEvent, type ReactNode, useEffect, useRef, useState } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { props } from \"../../lib/props\"\nimport { saveFile } from \"../../lib/save-file\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * DownloadButton — a button that saves a file: a Blob you already have, a\n * URL, or whatever a function of yours resolves to (an authenticated fetch,\n * a presign call, a generated CSV). The kit makes no request itself.\n *\n * - **While a function's promise is pending** the button is busy: a\n * spinner, `aria-busy`, and re-clicks are ignored, so a double click\n * saves one file. It stays enabled and focused, unlike Button's\n * `loading`, which sets `disabled` and drops keyboard focus.\n * - **On failure**, a polite status region says so (`translations.error`)\n * and `onError` gets the error. Nothing is announced on success: the\n * browser's own download UI is the feedback.\n * - **Unmounting mid-fetch** aborts: the function's `signal` fires and\n * nothing is saved afterwards.\n * - Renders a kit `Button` by default. With `asChild`, only the behaviour\n * goes onto your element (an `ActionIcon` in a row's actions), and its\n * content is swapped for the spinner while busy.\n *\n * Built on `saveFile` (`lib/save-file.ts`) rather than Ark's\n * `DownloadTrigger`: Ark's trigger has no pending state, drops a rejected\n * promise, can't be aborted, and reads a string as the file's *contents*\n * rather than a URL.\n *\n * ```tsx\n * <DownloadButton\n * name=\"transcript.pdf\"\n * data={({ signal }) => api.get(`/transcripts/${id}`, { signal }).then((r) => r.blob())}\n * onError={() => notify.error(\"Couldn't download the transcript\")}\n * />\n * ```\n */\n\n/** What can be saved: a Blob (or File), or a URL. */\nexport type DownloadData = Blob | string\n\n/** Resolves the file on click. `signal` aborts when the button unmounts first. */\nexport type DownloadLoader = (context: {\n signal: AbortSignal\n}) => DownloadData | Promise<DownloadData>\n\n/** What `data` takes: the value itself, or a function that resolves it on click. */\nexport type DownloadSource = DownloadData | DownloadLoader\n\nexport type DownloadButtonTranslations = {\n /** The default label, when there are no `children`. @default \"Download\" */\n label?: string\n /** Added to the button's name while `data` is resolving. @default \"Preparing download…\" */\n loading?: string\n /** What the status region says when the download fails.\n * @default (name) => name ? `${name} couldn't be downloaded` : \"The download failed\" */\n error?: (name: string | undefined) => string\n}\n\nexport const DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS: Required<DownloadButtonTranslations> = {\n label: \"Download\",\n loading: \"Preparing download…\",\n error: (name) => (name ? `${name} couldn't be downloaded` : \"The download failed\"),\n}\n\nexport type DownloadButtonIconSlot = \"download\"\n\nconst DEFAULT_ICONS: Record<DownloadButtonIconSlot, ReactNode> = {\n download: <Download className={iconStroke} />,\n}\n\nexport type DownloadButtonProps = Omit<\n ButtonProps,\n \"type\" | \"name\" | \"loading\" | \"startSlot\" | \"onError\"\n> & {\n /** The file: a Blob, a URL, or a function resolving one on click (passed an abort `signal`). */\n data: DownloadSource\n /** The file name. Ignored by browsers for a cross-origin URL; see `saveFile`. */\n name?: string\n /** The MIME type, for a Blob without one. */\n type?: string\n /** Fires when `data` rejects or the save throws. */\n onError?: (error: unknown) => void\n /** Fires once the file has been handed to the browser. */\n onDone?: () => void\n translations?: DownloadButtonTranslations\n /** `download`, the leading icon. `null` renders none. Not shown under `asChild`. */\n icons?: IconMap<DownloadButtonIconSlot>\n}\n\n/** Tailwind's `sr-only`, fixed rather than absolute: it is rendered beside the\n * button, outside any box of ours, and a fixed box can't stretch a scroller. */\nconst statusRegion =\n \"fixed size-px -m-px p-0 overflow-hidden whitespace-nowrap border-0 [clip-path:inset(50%)]\"\n\n/** Calls the loader now, inside the click, and treats a synchronous throw as a rejection. */\nconst started = (load: DownloadLoader, signal: AbortSignal): Promise<DownloadData> => {\n try {\n return Promise.resolve(load({ signal }))\n } catch (error) {\n return Promise.reject(error)\n }\n}\n\nexport const DownloadButton = ({\n data,\n name,\n type,\n onError,\n onDone,\n translations,\n icons,\n asChild,\n children,\n testId,\n onClick,\n variant,\n size,\n color,\n endSlot,\n disabled,\n className,\n ...rest\n}: DownloadButtonProps) => {\n const t = { ...DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS, ...translations }\n const icon = mergeIcons(DEFAULT_ICONS, icons)\n const [busy, setBusy] = useState(false)\n const [failure, setFailure] = useState(\"\")\n // The run in flight, if any: the re-click guard and the unmount abort. A\n // ref, so two clicks in one frame can't both read a stale `busy`.\n const running = useRef<AbortController | null>(null)\n\n useEffect(() => () => running.current?.abort(), [])\n\n const fail = (error: unknown) => {\n setFailure(t.error(name))\n onError?.(error)\n }\n\n // `onDone` sits outside the try, so a throw in the caller's own callback\n // isn't announced as a failed download.\n const save = (value: DownloadData) => {\n try {\n saveFile(value, name, { type })\n } catch (error) {\n return fail(error)\n }\n onDone?.()\n }\n\n const resolve = async (load: DownloadLoader) => {\n const controller = new AbortController()\n running.current = controller\n setBusy(true)\n const outcome = await started(load, controller.signal).then(\n (value) => ({ value }),\n (error: unknown) => ({ error }),\n )\n running.current = null\n // Unmounted meanwhile: nothing to save, and no state left to update.\n if (controller.signal.aborted) return\n setBusy(false)\n if (\"error\" in outcome) fail(outcome.error)\n else save(outcome.value)\n }\n\n // `onClick` runs first, so a caller can `preventDefault()` to stop the save\n // (a confirm step). A value is saved inside the click itself; a function's\n // promise is awaited, and the save follows when it settles.\n const download = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || disabled || running.current) return\n // An `asChild` link would also follow its own href.\n event.preventDefault()\n setFailure(\"\")\n if (typeof data === \"function\") void resolve(data)\n else save(data)\n }\n\n const trigger = {\n \"data-scope\": \"download-button\",\n \"data-part\": \"trigger\",\n onClick: download,\n ...props({\n \"aria-busy\": busy,\n \"data-loading\": busy,\n \"data-testid\": testId,\n \"data-disabled\": disabled,\n }),\n ...rest,\n }\n\n return (\n <>\n {asChild ? (\n // Only behaviour is merged onto the child: Button's styling would\n // fight an ActionIcon's own. While busy the spinner stands in for the\n // child's content (its icon); its name stays the child's own label.\n <ark.button\n asChild\n disabled={disabled}\n {...props({ \"aria-disabled\": disabled })}\n className={className}\n {...trigger}\n >\n {withAsChildContent(children, (own) => (busy ? <Spinner label={t.loading} /> : own))}\n </ark.button>\n ) : (\n <Button\n variant={variant}\n size={size}\n color={color}\n startSlot={busy ? <Spinner label={null} /> : icon.download}\n endSlot={endSlot}\n disabled={disabled}\n // `relative` holds the sr-only loading text inside the button.\n className={cn(\"relative\", className)}\n {...trigger}\n >\n {children ?? t.label}\n {busy && <span className=\"sr-only\">{t.loading}</span>}\n </Button>\n )}\n <span role=\"status\" className={statusRegion} data-scope=\"download-button\" data-part=\"status\">\n {failure}\n </span>\n </>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/download-button/download-button.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAkEO,IAAM,oCAAA,GAA6E;AAAA,EACxF,KAAA,EAAO,UAAA;AAAA,EACP,OAAA,EAAS,0BAAA;AAAA,EACT,OAAO,CAAC,IAAA,KAAU,IAAA,GAAO,CAAA,EAAG,IAAI,CAAA,uBAAA,CAAA,GAA4B;AAC9D;AAIA,IAAM,aAAA,GAA2D;AAAA,EAC/D,QAAA,kBAAU,GAAA,CAAC,QAAA,EAAA,EAAS,SAAA,EAAW,UAAA,EAAY;AAC7C,CAAA;AAuBA,IAAM,YAAA,GACJ,2FAAA;AAGF,IAAM,OAAA,GA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E,OAAA,EAAQ;AAAA;AAAA;AAAA,KAChD;AAAA,oBAEF,GAAA,CAAC,MAAA,EAAA,EAAK,IAAA,EAAK,QAAA,EAAS,SAAA,EAAW,cAAc,YAAA,EAAW,iBAAA,EAAkB,WAAA,EAAU,QAAA,EACjF,QAAA,EAAA,OAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-6IRMKF5T.js","sourcesContent":["\"use client\"\n\nimport { ark } from \"@ark-ui/react\"\nimport { Download } from \"lucide-react\"\nimport { type MouseEvent, type ReactNode, useEffect, useRef, useState } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { props } from \"../../lib/props\"\nimport { saveFile } from \"../../lib/save-file\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * DownloadButton — a button that saves a file: a Blob you already have, a\n * URL, or whatever a function of yours resolves to (an authenticated fetch,\n * a presign call, a generated CSV). The kit makes no request itself.\n *\n * - **While a function's promise is pending** the button is busy: a\n * spinner, `aria-busy`, and re-clicks are ignored, so a double click\n * saves one file. It stays enabled and focused, unlike Button's\n * `loading`, which sets `disabled` and drops keyboard focus.\n * - **On failure**, a polite status region says so (`translations.error`)\n * and `onError` gets the error. Nothing is announced on success: the\n * browser's own download UI is the feedback.\n * - **Unmounting mid-fetch** aborts: the function's `signal` fires and\n * nothing is saved afterwards.\n * - Renders a kit `Button` by default. With `asChild`, only the behaviour\n * goes onto your element (an `ActionIcon` in a row's actions), and its\n * content is swapped for the spinner while busy.\n *\n * Built on `saveFile` (`lib/save-file.ts`) rather than Ark's\n * `DownloadTrigger`: Ark's trigger has no pending state, drops a rejected\n * promise, can't be aborted, and reads a string as the file's *contents*\n * rather than a URL.\n *\n * ```tsx\n * <DownloadButton\n * name=\"transcript.pdf\"\n * data={({ signal }) => api.get(`/transcripts/${id}`, { signal }).then((r) => r.blob())}\n * onError={() => notify.error(\"Couldn't download the transcript\")}\n * />\n * ```\n */\n\n/** What can be saved: a Blob (or File), or a URL. */\nexport type DownloadData = Blob | string\n\n/** Resolves the file on click. `signal` aborts when the button unmounts first. */\nexport type DownloadLoader = (context: {\n signal: AbortSignal\n}) => DownloadData | Promise<DownloadData>\n\n/** What `data` takes: the value itself, or a function that resolves it on click. */\nexport type DownloadSource = DownloadData | DownloadLoader\n\nexport type DownloadButtonTranslations = {\n /** The default label, when there are no `children`. @default \"Download\" */\n label?: string\n /** Added to the button's name while `data` is resolving. @default \"Preparing download…\" */\n loading?: string\n /** What the status region says when the download fails.\n * @default (name) => name ? `${name} couldn't be downloaded` : \"The download failed\" */\n error?: (name: string | undefined) => string\n}\n\nexport const DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS: Required<DownloadButtonTranslations> = {\n label: \"Download\",\n loading: \"Preparing download…\",\n error: (name) => (name ? `${name} couldn't be downloaded` : \"The download failed\"),\n}\n\nexport type DownloadButtonIconSlot = \"download\"\n\nconst DEFAULT_ICONS: Record<DownloadButtonIconSlot, ReactNode> = {\n download: <Download className={iconStroke} />,\n}\n\nexport type DownloadButtonProps = Omit<\n ButtonProps,\n \"type\" | \"name\" | \"loading\" | \"startSlot\" | \"onError\"\n> & {\n /** The file: a Blob, a URL, or a function resolving one on click (passed an abort `signal`). */\n data: DownloadSource\n /** The file name. Ignored by browsers for a cross-origin URL; see `saveFile`. */\n name?: string\n /** The MIME type, for a Blob without one. */\n type?: string\n /** Fires when `data` rejects or the save throws. */\n onError?: (error: unknown) => void\n /** Fires once the file has been handed to the browser. */\n onDone?: () => void\n translations?: DownloadButtonTranslations\n /** `download`, the leading icon. `null` renders none. Not shown under `asChild`. */\n icons?: IconMap<DownloadButtonIconSlot>\n}\n\n/** Tailwind's `sr-only`, fixed rather than absolute: it is rendered beside the\n * button, outside any box of ours, and a fixed box can't stretch a scroller. */\nconst statusRegion =\n \"fixed size-px -m-px p-0 overflow-hidden whitespace-nowrap border-0 [clip-path:inset(50%)]\"\n\n/** Calls the loader now, inside the click, and treats a synchronous throw as a rejection. */\nconst started = (load: DownloadLoader, signal: AbortSignal): Promise<DownloadData> => {\n try {\n return Promise.resolve(load({ signal }))\n } catch (error) {\n return Promise.reject(error)\n }\n}\n\nexport const DownloadButton = ({\n data,\n name,\n type,\n onError,\n onDone,\n translations,\n icons,\n asChild,\n children,\n testId,\n onClick,\n variant,\n size,\n color,\n endSlot,\n disabled,\n className,\n ...rest\n}: DownloadButtonProps) => {\n const t = { ...DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS, ...translations }\n const icon = mergeIcons(DEFAULT_ICONS, icons)\n const [busy, setBusy] = useState(false)\n const [failure, setFailure] = useState(\"\")\n // The run in flight, if any: the re-click guard and the unmount abort. A\n // ref, so two clicks in one frame can't both read a stale `busy`.\n const running = useRef<AbortController | null>(null)\n\n useEffect(() => () => running.current?.abort(), [])\n\n const fail = (error: unknown) => {\n setFailure(t.error(name))\n onError?.(error)\n }\n\n // `onDone` sits outside the try, so a throw in the caller's own callback\n // isn't announced as a failed download.\n const save = (value: DownloadData) => {\n try {\n saveFile(value, name, { type })\n } catch (error) {\n return fail(error)\n }\n onDone?.()\n }\n\n const resolve = async (load: DownloadLoader) => {\n const controller = new AbortController()\n running.current = controller\n setBusy(true)\n const outcome = await started(load, controller.signal).then(\n (value) => ({ value }),\n (error: unknown) => ({ error }),\n )\n running.current = null\n // Unmounted meanwhile: nothing to save, and no state left to update.\n if (controller.signal.aborted) return\n setBusy(false)\n if (\"error\" in outcome) fail(outcome.error)\n else save(outcome.value)\n }\n\n // `onClick` runs first, so a caller can `preventDefault()` to stop the save\n // (a confirm step). A value is saved inside the click itself; a function's\n // promise is awaited, and the save follows when it settles.\n const download = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || disabled || running.current) return\n // An `asChild` link would also follow its own href.\n event.preventDefault()\n setFailure(\"\")\n if (typeof data === \"function\") void resolve(data)\n else save(data)\n }\n\n const trigger = {\n \"data-scope\": \"download-button\",\n \"data-part\": \"trigger\",\n onClick: download,\n ...props({\n \"aria-busy\": busy,\n \"data-loading\": busy,\n \"data-testid\": testId,\n \"data-disabled\": disabled,\n }),\n ...rest,\n }\n\n return (\n <>\n {asChild ? (\n // Only behaviour is merged onto the child: Button's styling would\n // fight an ActionIcon's own. While busy the spinner stands in for the\n // child's content (its icon); its name stays the child's own label.\n <ark.button\n asChild\n disabled={disabled}\n {...props({ \"aria-disabled\": disabled })}\n className={className}\n {...trigger}\n >\n {withAsChildContent(children, (own) => (busy ? <Spinner label={t.loading} /> : own))}\n </ark.button>\n ) : (\n <Button\n variant={variant}\n size={size}\n color={color}\n startSlot={busy ? <Spinner label={null} /> : icon.download}\n endSlot={endSlot}\n disabled={disabled}\n // `relative` holds the sr-only loading text inside the button.\n className={cn(\"relative\", className)}\n {...trigger}\n >\n {children ?? t.label}\n {busy && <span className=\"sr-only\">{t.loading}</span>}\n </Button>\n )}\n <span role=\"status\" className={statusRegion} data-scope=\"download-button\" data-part=\"status\">\n {failure}\n </span>\n </>\n )\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useApplePlatform, hotkeyCaps } from './chunk-
|
|
1
|
+
import { useApplePlatform, hotkeyCaps } from './chunk-2CL3FKEY.js';
|
|
2
2
|
import { composeChildren } from './chunk-R5LYFTHA.js';
|
|
3
3
|
import { props } from './chunk-WYCMIIRR.js';
|
|
4
4
|
import { focusStyles } from './chunk-C6NVU4F7.js';
|
|
@@ -34,7 +34,8 @@ var kbdVariants = cva(
|
|
|
34
34
|
variant: {
|
|
35
35
|
filled: "bg-(--c-solid) text-(--c-on-solid)",
|
|
36
36
|
light: "bg-(--c-soft) text-(--c-text)",
|
|
37
|
-
outline:
|
|
37
|
+
// Button's outline edge: the colour at 35%.
|
|
38
|
+
outline: "bg-transparent text-(--c-text) border-(--c-solid)/35",
|
|
38
39
|
subtle: "bg-transparent text-(--c-text)",
|
|
39
40
|
// The key cap sits on the kit's translucent surface recipe — a 3%/4%
|
|
40
41
|
// overlay plus the hairline `border-brand-900/20 dark:border-white/15`,
|
|
@@ -144,5 +145,5 @@ var Kbd = (allProps) => {
|
|
|
144
145
|
};
|
|
145
146
|
|
|
146
147
|
export { Kbd };
|
|
147
|
-
//# sourceMappingURL=chunk-
|
|
148
|
-
//# sourceMappingURL=chunk-
|
|
148
|
+
//# sourceMappingURL=chunk-7247WBTV.js.map
|
|
149
|
+
//# sourceMappingURL=chunk-7247WBTV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/kbd/kbd.tsx"],"names":[],"mappings":";;;;;;;;;AAmDA,IAAM,WAAA,GAAc,GAAA;AAAA,EAClB;AAAA,IACE,+CAAA;AAAA,IACA,+BAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,oCAAA;AAAA,IACA,sCAAA;AAAA,IACA,8CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,mEAAA;AAAA;AAAA;AAAA,IAGA,4BAAA;AAAA;AAAA;AAAA,IAGA,WAAA;AAAY,GACd;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,MAAA,EAAQ,oCAAA;AAAA,QACR,KAAA,EAAO,+BAAA;AAAA;AAAA,QAEP,OAAA,EAAS,sDAAA;AAAA,QACT,MAAA,EAAQ,gCAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAYR,OAAA,EAAS;AAAA,UACP,kDAAA;AAAA,UACA,2CAAA;AAAA,UACA,yDAAA;AAAA,UACA;AAAA;AACF,OACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAUA,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,4CAAA;AAAA,QACJ,EAAA,EAAI,6CAAA;AAAA,QACJ,EAAA,EAAI;AAAA;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;AAAA,MAGC,GAAA,EAAI,KAAA;AAAA,MACJ,YAAA,EAAY,KAAA;AAAA,MACX,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,MAClC,GAAG,IAAA;AAAA,MACJ,OAAA;AAAA,MACA,SAAA,EAAW,EAAA,CAAG,QAAA,EAAU,SAAS,CAAA;AAAA,MAEhC,QAAA,EAAA,eAAA,CAAgB,OAAA,EAAS,QAAA,EAAU,MAAM,IAAI;AAAA;AAAA,GAChD;AAEJ,CAAA;AAEO,IAAM,GAAA,GAAM,CAAC,QAAA,KAAuB;AACzC,EAAA,IAAI,SAAS,MAAA,KAAW,MAAA,yBAAkB,GAAA,CAAC,QAAA,EAAA,EAAU,GAAG,QAAA,EAAU,CAAA;AAClE,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA,EAAQ,OAAA;AAAA,IACR,YAAA,EAAc,aAAA;AAAA,IACd,GAAG;AAAA,GACL,GAAI,QAAA;AACJ,EAAA,uBACE,GAAA;AAAA,IAAC,GAAA,CAAI,GAAA;AAAA,IAAJ;AAAA,MACC,YAAA,EAAY,KAAA;AAAA,MACX,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,MAClC,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,GAAG,WAAA,CAAY,EAAE,SAAS,IAAA,EAAM,GAAG,SAAS;AAAA;AAAA,GACzD;AAEJ","file":"chunk-7247WBTV.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport type { ReactElement } from \"react\"\nimport { composeChildren } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { hotkeyCaps, type KbdTranslations, useApplePlatform } from \"../../lib/use-hotkey\"\n\n/**\n * Kbd — a keyboard-key / shortcut indicator (`<kbd>`).\n *\n * A client component only for `hotkey`, whose keys depend on the platform\n * (`[⌘] [K]` vs `[Ctrl] [K]`). It borrows Button's (variant × color) system so\n * a shortcut hint speaks the same accent language as the action it labels — but\n * unlike Button it is non-interactive: no hover treatment, no click handling,\n * just a key cap.\n *\n * The shape axis is the exact set Button exposes (filled / light / outline /\n * subtle / default), wired through the same `--c-*` slot vars — `color` routes\n * via a `data-color` attribute resolved in `colors.css`, so the cva matrix\n * enumerates variants only, never (variant × color) pairs. The default\n * treatment is the `default` variant: a neutral, bordered key-cap surface that\n * reads as a physical key regardless of `color` (pairing `default` with a color\n * is a no-op, mirroring Button/Badge).\n *\n * Sizing keeps single-character keys square via a per-size `min-w` equal to the\n * height, while wider labels (`Enter`, `Esc`, `⌘N`) grow horizontally. Padding\n * is symmetric, so a key reads the same in RTL.\n *\n * `asChild` (from `HTMLArkProps`) renders the single child as the root with\n * Kbd's styling merged in — e.g. `<Kbd asChild><a href=\"…\">⌘K</a></Kbd>`. The\n * kit's focus ring (`focusStyles`) comes along with it, so a Kbd composed onto\n * a real control is keyboard-visible without the caller restyling anything; on\n * a plain `<kbd>` those classes never match.\n *\n * `hotkey` draws a key combination the way the HTML spec marks one up: an\n * outer `<kbd>` for the whole combination holding one inner `<kbd>` per key,\n * with no `+` between them. The outer one is an unstyled inline-flex row;\n * each key is a full cap (`variant` / `size` / `color` apply to every cap),\n * so `\"mod+k\"` is two square caps. The rest of the props (`className`,\n * `testId`, `asChild`, `aria-*`, …) land on the outer `<kbd>`, which is the\n * element a layout positions; `color` is set there too and every cap reads\n * its slot vars from it. The words the caps show and speak (\"Ctrl\", \"Esc\",\n * \"Command\", \"Up Arrow\") are English unless `translations` replaces them, per\n * key (`KbdTranslations`); `formatHotkey` takes the same object.\n */\nconst kbdVariants = cva(\n [\n \"inline-flex items-center justify-center gap-1\",\n \"whitespace-nowrap select-none\",\n // Regular weight, not medium: the mono face (Kode Mono) has no ⌘ ⇧ ⌥ ↵\n // glyphs, so they fall back to a system font — and a 500 weight makes that\n // fallback resolve to its *bold* face (Menlo Bold), a heavy blot next to\n // the regular letters around it.\n \"font-mono font-normal leading-none\",\n \"rounded-md border border-transparent\",\n \"[&_svg]:shrink-0 [&_svg]:pointer-events-none\",\n // A 1.5px stroke at every size: the icon is sized by CSS, so a stroke in\n // viewBox units would thin out at `size-3`. `non-scaling-stroke` keeps it in\n // screen pixels (lucide's `absoluteStrokeWidth` ignores CSS sizing).\n \"[&_svg]:stroke-[1.5] [&_svg_*]:[vector-effect:non-scaling-stroke]\",\n // A lone icon is narrower than the cap is tall, but the side padding\n // would push it past `min-w`: drop the padding so the cap stays square.\n \"has-[>svg:only-child]:px-0\",\n // Inert on the default non-focusable <kbd>; applies once `asChild`\n // renders Kbd onto a real <button>/<a>. See `focusStyles`.\n focusStyles(),\n ],\n {\n variants: {\n variant: {\n filled: \"bg-(--c-solid) text-(--c-on-solid)\",\n light: \"bg-(--c-soft) text-(--c-text)\",\n // Button's outline edge: the colour at 35%.\n outline: \"bg-transparent text-(--c-text) border-(--c-solid)/35\",\n subtle: \"bg-transparent text-(--c-text)\",\n // The key cap sits on the kit's translucent surface recipe — a 3%/4%\n // overlay plus the hairline `border-brand-900/20 dark:border-white/15`,\n // the same pair `Input`'s default shell, `Card`, `Tabs` and\n // `ChoiceCardGroup` use. An opaque gray step can only ever be right on\n // the one background it was picked against, and a `Kbd` is most often\n // inlined into a Button, a Menu row or a tinted panel. Light mode\n // darkens (`bg-black/3`) because `bg-white/4` on a near-white page is\n // invisible; dark mode lightens. A 1px inset shade along the bottom\n // edge is the key-cap depth cue — the lip of a physical key — without\n // adding height. The label is the kit's secondary text, not full\n // contrast: a shortcut hint annotates the action, it is not the action.\n default: [\n \"bg-black/3 text-brand-900/70 border-brand-900/20\",\n \"shadow-[inset_0_-1px_0_0_rgb(0_0_0/0.08)]\",\n \"dark:bg-white/4 dark:text-white/80 dark:border-white/15\",\n \"dark:shadow-[inset_0_-1px_0_0_rgb(0_0_0/0.35)]\",\n ],\n },\n // Type is one Tailwind step per size (12 / 14 / 16px), the scale of\n // the text a key sits beside — a 10px label left ⌘ and ↵ unreadable.\n //\n // A single character must fit `min-w` (= height) to stay square. Kode\n // Mono advances 0.6em per glyph, so glyph + 2 × padding + 2 × 1px border:\n // sm: 7.2 + 2 × 5 + 2 = 19.2 ≤ 20 (px-1.5 gave 21.2: one px too wide)\n // md: 8.4 + 2 × 6 + 2 = 22.4 ≤ 24\n // lg: 9.6 + 2 × 8 + 2 = 27.6 ≤ 28\n // Re-check these sums after a font, type step or padding change.\n size: {\n sm: \"h-5 min-w-5 px-1.25 text-xs [&_svg]:size-3\",\n md: \"h-6 min-w-6 px-1.5 text-sm [&_svg]:size-3.5\",\n lg: \"h-7 min-w-7 px-2 text-base [&_svg]:size-4\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n },\n)\n\nexport type KbdVariant = NonNullable<VariantProps<typeof kbdVariants>[\"variant\"]>\nexport type KbdSize = NonNullable<VariantProps<typeof kbdVariants>[\"size\"]>\n\n/** The outer `<kbd>` of a `hotkey` combination: a row of caps, unstyled itself.\n * `align-middle` sits it on the text it annotates the way a lone cap does. */\nconst kbdGroup = \"inline-flex items-center gap-0.5 align-middle\"\n\n/** With `hotkey`: the key words, merged per key onto `KBD_DEFAULT_TRANSLATIONS`. */\ntype KbdHotkeyTranslations = {\n /** The words the caps read as and are spoken by, merged per key onto the English\n * `KBD_DEFAULT_TRANSLATIONS`: `{ ctrl: \"Strg\", enter: \"Eingabe\" }`. Pass the same\n * object to `formatHotkey` / `hotkeyKeys` so plain text reads the same. */\n translations?: Partial<KbdTranslations>\n}\n\ntype KbdHotkeyProps =\n | { hotkey?: undefined; translations?: undefined }\n | (KbdHotkeyTranslations & {\n /** A `useHotkey` string to draw, one cap per key, the way the visitor's\n * platform writes it: `\"mod+k\"` is `[⌘] [K]` on Apple platforms and\n * `[Ctrl] [K]` elsewhere (see `hotkeyKeys`). A key with an icon (Shift,\n * Enter, Tab, the arrows, and ⌘ ⌥ ⌃ ⌫ on Apple) is drawn as one, with a\n * spoken name; Ctrl, Alt, Esc, Space (and Backspace off Apple) stay\n * words. Server-rendered as the non-Apple caps, then corrected on\n * hydration. The caps are the content, so it takes no children. */\n hotkey: string\n asChild?: false\n children?: never\n })\n | (KbdHotkeyTranslations & {\n hotkey: string\n /** With `hotkey`: the single child becomes the outer `<kbd>` of the\n * combination, the caps rendered inside it. */\n asChild: true\n children: ReactElement\n })\n\nexport type KbdProps = HTMLArkProps<\"kbd\"> &\n VariantProps<typeof kbdVariants> &\n WithTestId & {\n /** Accent palette. Re-exported as `Color` from `@42/ui-react`. */\n color?: Color\n } & KbdHotkeyProps\n\ntype KbdComboProps = KbdProps & { hotkey: string }\n\n/** `<Kbd hotkey>`: the combination's outer `<kbd>`, one cap per key inside. */\nconst KbdCombo = ({\n className,\n variant,\n size,\n color,\n testId,\n hotkey,\n translations,\n asChild,\n children,\n ...rest\n}: KbdComboProps) => {\n const apple = useApplePlatform()\n const caps = hotkeyCaps(hotkey, apple, translations).map(({ id, label, icon: Icon, name }) => (\n // A symbol is drawn (an icon, or the glyph where there is none) and its\n // name spoken: an svg says nothing, and `⌘` alone reads inconsistently.\n // `relative` holds the absolutely positioned `sr-only` inside the cap.\n // An icon cap drops its side padding to stay square, as a lone icon does\n // (the `sr-only` name beside the svg keeps `:only-child` from matching).\n <kbd\n key={id}\n className={cn(kbdVariants({ variant, size }), name && \"relative\", Icon && \"px-0\")}\n >\n {name ? (\n <>\n {Icon ? <Icon aria-hidden /> : <span aria-hidden>{label}</span>}\n <span className=\"sr-only\">{name}</span>\n </>\n ) : (\n label\n )}\n </kbd>\n ))\n return (\n <ark.kbd\n // A combination reads left to right in either direction, like the\n // single string it replaces.\n dir=\"ltr\"\n data-color={color}\n {...props({ \"data-testid\": testId })}\n {...rest}\n asChild={asChild}\n className={cn(kbdGroup, className)}\n >\n {composeChildren(asChild, children, () => caps)}\n </ark.kbd>\n )\n}\n\nexport const Kbd = (allProps: KbdProps) => {\n if (allProps.hotkey !== undefined) return <KbdCombo {...allProps} />\n const {\n className,\n variant,\n size,\n color,\n testId,\n hotkey: _hotkey,\n translations: _translations,\n ...rest\n } = allProps\n return (\n <ark.kbd\n data-color={color}\n {...props({ \"data-testid\": testId })}\n {...rest}\n className={cn(kbdVariants({ variant, size }), className)}\n />\n )\n}\n"]}
|