@42-central/ui-react 0.29.1 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-X6DESK37.js → chunk-2RRTT4AF.js} +17 -5
- package/dist/chunk-2RRTT4AF.js.map +1 -0
- package/dist/{chunk-TUP7WXQE.js → chunk-322I2RSV.js} +9 -6
- package/dist/chunk-322I2RSV.js.map +1 -0
- package/dist/{chunk-ISX3AM32.js → chunk-37SRSNLJ.js} +4 -4
- package/dist/{chunk-ISX3AM32.js.map → chunk-37SRSNLJ.js.map} +1 -1
- package/dist/{chunk-L5GH7LLD.js → chunk-3MFWUG5O.js} +4 -4
- package/dist/{chunk-L5GH7LLD.js.map → chunk-3MFWUG5O.js.map} +1 -1
- package/dist/{chunk-FQJNQW3G.js → chunk-3XQEOJCE.js} +8 -5
- package/dist/chunk-3XQEOJCE.js.map +1 -0
- package/dist/{chunk-JKFPRQB2.js → chunk-4LSZ5JWF.js} +3 -3
- package/dist/{chunk-JKFPRQB2.js.map → chunk-4LSZ5JWF.js.map} +1 -1
- package/dist/{chunk-V2QZG4IT.js → chunk-5HWFYYHW.js} +27 -9
- package/dist/chunk-5HWFYYHW.js.map +1 -0
- package/dist/{chunk-GEZYGBXY.js → chunk-6MVFCS46.js} +99 -42
- package/dist/chunk-6MVFCS46.js.map +1 -0
- package/dist/{chunk-NNPSBC7O.js → chunk-6WZSUS3U.js} +10 -9
- package/dist/chunk-6WZSUS3U.js.map +1 -0
- package/dist/chunk-6YRGP6PS.js +138 -0
- package/dist/chunk-6YRGP6PS.js.map +1 -0
- package/dist/{chunk-B5YHYI7E.js → chunk-ALANKV5Y.js} +23 -6
- package/dist/chunk-ALANKV5Y.js.map +1 -0
- package/dist/{chunk-IA6DCC3N.js → chunk-AUQPNDE5.js} +23 -13
- package/dist/chunk-AUQPNDE5.js.map +1 -0
- package/dist/{chunk-AKXALCUN.js → chunk-D7SW2E24.js} +4 -4
- package/dist/chunk-D7SW2E24.js.map +1 -0
- package/dist/{chunk-OXR7BXZA.js → chunk-DQIYYDFD.js} +4 -3
- package/dist/chunk-DQIYYDFD.js.map +1 -0
- package/dist/{chunk-HMNXNKDA.js → chunk-FCBYUN6F.js} +4 -4
- package/dist/{chunk-HMNXNKDA.js.map → chunk-FCBYUN6F.js.map} +1 -1
- package/dist/{chunk-2W7H43WL.js → chunk-FED6SJWM.js} +23 -14
- package/dist/chunk-FED6SJWM.js.map +1 -0
- package/dist/{chunk-7E7JNWOC.js → chunk-FEPIHXVI.js} +6 -5
- package/dist/chunk-FEPIHXVI.js.map +1 -0
- package/dist/{chunk-Y57NW6G7.js → chunk-G3YOSG3U.js} +4 -4
- package/dist/{chunk-Y57NW6G7.js.map → chunk-G3YOSG3U.js.map} +1 -1
- package/dist/chunk-GZN5CXMR.js +100 -0
- package/dist/chunk-GZN5CXMR.js.map +1 -0
- package/dist/{chunk-HCHGERDB.js → chunk-HCSZPBWV.js} +17 -115
- package/dist/chunk-HCSZPBWV.js.map +1 -0
- package/dist/{chunk-I4B3N3UX.js → chunk-HTVICHT4.js} +12 -7
- package/dist/chunk-HTVICHT4.js.map +1 -0
- package/dist/chunk-I7TC2C3I.js +163 -0
- package/dist/chunk-I7TC2C3I.js.map +1 -0
- package/dist/{chunk-7FPSQBWB.js → chunk-IBXYLO2J.js} +14 -13
- package/dist/chunk-IBXYLO2J.js.map +1 -0
- package/dist/{chunk-7KFUFAVP.js → chunk-IRYG6B5A.js} +9 -8
- package/dist/chunk-IRYG6B5A.js.map +1 -0
- package/dist/{chunk-2RQLPN4U.js → chunk-JCNEW4WJ.js} +8 -8
- package/dist/{chunk-2RQLPN4U.js.map → chunk-JCNEW4WJ.js.map} +1 -1
- package/dist/{chunk-SP6LCCTZ.js → chunk-KZDMVOL6.js} +35 -8
- package/dist/chunk-KZDMVOL6.js.map +1 -0
- package/dist/chunk-LR5U6TZZ.js +169 -0
- package/dist/chunk-LR5U6TZZ.js.map +1 -0
- package/dist/{chunk-MQHD3EJE.js → chunk-LZHZJWVM.js} +6 -4
- package/dist/chunk-LZHZJWVM.js.map +1 -0
- package/dist/{chunk-5EOMSWNO.js → chunk-MAM2X3MW.js} +5 -5
- package/dist/{chunk-5EOMSWNO.js.map → chunk-MAM2X3MW.js.map} +1 -1
- package/dist/{chunk-FSPS7TVD.js → chunk-MCMS4NMO.js} +5 -5
- package/dist/{chunk-FSPS7TVD.js.map → chunk-MCMS4NMO.js.map} +1 -1
- package/dist/{chunk-ZB5VMGKB.js → chunk-MV5DIE2T.js} +15 -4
- package/dist/chunk-MV5DIE2T.js.map +1 -0
- package/dist/chunk-NDI4HLQE.js +41 -0
- package/dist/chunk-NDI4HLQE.js.map +1 -0
- package/dist/{chunk-B4GNSSHU.js → chunk-NLJEQZQQ.js} +3 -3
- package/dist/{chunk-B4GNSSHU.js.map → chunk-NLJEQZQQ.js.map} +1 -1
- package/dist/{chunk-SBZJGFZ6.js → chunk-QHT4DCXE.js} +8 -7
- package/dist/chunk-QHT4DCXE.js.map +1 -0
- package/dist/{chunk-I4IJOLNA.js → chunk-RMUBCTEF.js} +5 -5
- package/dist/{chunk-I4IJOLNA.js.map → chunk-RMUBCTEF.js.map} +1 -1
- package/dist/{chunk-G3AD3NJG.js → chunk-RNTDM3RP.js} +9 -5
- package/dist/chunk-RNTDM3RP.js.map +1 -0
- package/dist/chunk-RPFN6ETQ.js +509 -0
- package/dist/chunk-RPFN6ETQ.js.map +1 -0
- package/dist/{chunk-HWBFRDX7.js → chunk-SI7C3W5M.js} +28 -9
- package/dist/chunk-SI7C3W5M.js.map +1 -0
- package/dist/chunk-TPOV3OCC.js +234 -0
- package/dist/chunk-TPOV3OCC.js.map +1 -0
- package/dist/{chunk-IANYMDKH.js → chunk-UBQ54W46.js} +4 -4
- package/dist/chunk-UBQ54W46.js.map +1 -0
- package/dist/{chunk-QVOBLRCM.js → chunk-UIKQ4X6W.js} +3 -3
- package/dist/{chunk-QVOBLRCM.js.map → chunk-UIKQ4X6W.js.map} +1 -1
- package/dist/chunk-UOWQH53N.js +70 -0
- package/dist/chunk-UOWQH53N.js.map +1 -0
- package/dist/{chunk-QRNQQIQM.js → chunk-WJUY6YWF.js} +52 -20
- package/dist/chunk-WJUY6YWF.js.map +1 -0
- package/dist/{chunk-3KARNPW4.js → chunk-WKIUMLRT.js} +3 -3
- package/dist/{chunk-3KARNPW4.js.map → chunk-WKIUMLRT.js.map} +1 -1
- package/dist/chunk-X6RB74JN.js +37 -0
- package/dist/chunk-X6RB74JN.js.map +1 -0
- package/dist/chunk-XQ6L2CM5.js +83 -0
- package/dist/chunk-XQ6L2CM5.js.map +1 -0
- package/dist/{chunk-RKCUXOU2.js → chunk-YUVKROMA.js} +44 -7
- package/dist/chunk-YUVKROMA.js.map +1 -0
- package/dist/components/action-icon/action-icon.d.ts +9 -2
- package/dist/components/action-icon/action-icon.d.ts.map +1 -1
- package/dist/components/action-icon/index.js +5 -1
- package/dist/components/alert/index.js +4 -4
- package/dist/components/anchor/anchor.d.ts +45 -0
- package/dist/components/anchor/anchor.d.ts.map +1 -0
- package/dist/components/anchor/index.d.ts +2 -0
- package/dist/components/anchor/index.d.ts.map +1 -0
- package/dist/components/anchor/index.js +11 -0
- package/dist/components/anchor/index.js.map +1 -0
- package/dist/components/app-shell/app-shell.d.ts +10 -6
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/index.js +23 -24
- package/dist/components/app-shell/index.js.map +1 -1
- package/dist/components/autocomplete/autocomplete.d.ts +1 -1
- package/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/dist/components/autocomplete/index.js +15 -9
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/avatar/index.js +1 -1
- package/dist/components/breadcrumb/breadcrumb.d.ts +5 -1
- package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
- package/dist/components/breadcrumb/index.js +12 -0
- package/dist/components/breadcrumb/index.js.map +1 -1
- package/dist/components/button/button.d.ts +15 -2
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/index.js +5 -1
- package/dist/components/button-multi-select/index.js +6 -4
- package/dist/components/button-multi-select/index.js.map +1 -1
- package/dist/components/button-select/button-select-control.d.ts.map +1 -1
- package/dist/components/button-select/button-select.d.ts +2 -2
- package/dist/components/button-select/button-select.d.ts.map +1 -1
- package/dist/components/button-select/index.js +6 -4
- package/dist/components/button-select/index.js.map +1 -1
- package/dist/components/calendar/aliases.d.ts +16 -0
- package/dist/components/calendar/aliases.d.ts.map +1 -0
- package/dist/components/calendar/calendar-body.d.ts +11 -1
- package/dist/components/calendar/calendar-body.d.ts.map +1 -1
- package/dist/components/calendar/calendar.d.ts +8 -4
- package/dist/components/calendar/calendar.d.ts.map +1 -1
- package/dist/components/calendar/index.d.ts +2 -1
- package/dist/components/calendar/index.d.ts.map +1 -1
- package/dist/components/calendar/index.js +15 -5
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/calendar-heatmap/calendar-heatmap.d.ts.map +1 -1
- package/dist/components/calendar-heatmap/index.js +85 -73
- package/dist/components/calendar-heatmap/index.js.map +1 -1
- package/dist/components/camera/index.js +16 -14
- package/dist/components/carousel/index.js +3 -3
- 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/circular-progress/circular-progress.d.ts +22 -11
- package/dist/components/circular-progress/circular-progress.d.ts.map +1 -1
- package/dist/components/circular-progress/index.d.ts +1 -1
- package/dist/components/circular-progress/index.d.ts.map +1 -1
- package/dist/components/circular-progress/index.js +68 -49
- package/dist/components/circular-progress/index.js.map +1 -1
- package/dist/components/clipboard/index.js +7 -3
- package/dist/components/clipboard/index.js.map +1 -1
- package/dist/components/code/code.d.ts +10 -0
- package/dist/components/code/code.d.ts.map +1 -1
- package/dist/components/code/index.js +1 -0
- package/dist/components/code/index.js.map +1 -1
- package/dist/components/code-block/chrome.js +10 -6
- package/dist/components/code-block/index.js +10 -7
- package/dist/components/code-block/index.js.map +1 -1
- package/dist/components/combobox/combobox.d.ts +5 -3
- package/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/index.js +12 -7
- package/dist/components/combobox-list/combobox-list.d.ts +1 -1
- package/dist/components/combobox-list/combobox-list.d.ts.map +1 -1
- package/dist/components/combobox-list/index.js +14 -9
- package/dist/components/compare/index.js +1 -1
- package/dist/components/data-list/data-list.d.ts +96 -0
- package/dist/components/data-list/data-list.d.ts.map +1 -0
- package/dist/components/data-list/index.d.ts +2 -0
- package/dist/components/data-list/index.d.ts.map +1 -0
- package/dist/components/data-list/index.js +147 -0
- package/dist/components/data-list/index.js.map +1 -0
- package/dist/components/data-table/data-table-group.d.ts.map +1 -1
- package/dist/components/data-table/data-table-placeholder.d.ts +12 -1
- package/dist/components/data-table/data-table-placeholder.d.ts.map +1 -1
- package/dist/components/data-table/data-table-stack.d.ts.map +1 -1
- package/dist/components/data-table/data-table.d.ts +5 -2
- package/dist/components/data-table/data-table.d.ts.map +1 -1
- package/dist/components/data-table/index.js +163 -168
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/date-picker/aliases.d.ts +16 -0
- package/dist/components/date-picker/aliases.d.ts.map +1 -1
- package/dist/components/date-picker/date-picker.d.ts +22 -8
- package/dist/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/components/date-picker/index.d.ts +2 -2
- package/dist/components/date-picker/index.d.ts.map +1 -1
- package/dist/components/date-picker/index.js +34 -28
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/download-button/index.js +6 -2
- package/dist/components/drawer/drawer.d.ts +7 -4
- package/dist/components/drawer/drawer.d.ts.map +1 -1
- package/dist/components/drawer/index.js +11 -6
- package/dist/components/empty-state/empty-state.d.ts +57 -0
- package/dist/components/empty-state/empty-state.d.ts.map +1 -0
- package/dist/components/empty-state/index.d.ts +2 -0
- package/dist/components/empty-state/index.d.ts.map +1 -0
- package/dist/components/empty-state/index.js +8 -0
- package/dist/components/empty-state/index.js.map +1 -0
- package/dist/components/field/field.d.ts +20 -0
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/index.js +1 -1
- package/dist/components/fieldset/fieldset.d.ts +103 -0
- package/dist/components/fieldset/fieldset.d.ts.map +1 -0
- package/dist/components/fieldset/index.d.ts +2 -0
- package/dist/components/fieldset/index.d.ts.map +1 -0
- package/dist/components/fieldset/index.js +150 -0
- package/dist/components/fieldset/index.js.map +1 -0
- package/dist/components/file-item/index.js +10 -7
- package/dist/components/file-preview/file-preview.d.ts.map +1 -1
- package/dist/components/file-preview/index.js +10 -18
- package/dist/components/file-preview/index.js.map +1 -1
- package/dist/components/file-trigger/index.js +6 -2
- package/dist/components/file-upload/file-upload.d.ts.map +1 -1
- package/dist/components/file-upload/index.js +18 -14
- package/dist/components/file-upload/index.js.map +1 -1
- package/dist/components/gallery/index.js +3 -3
- package/dist/components/geodesic/a11y.d.ts +3 -3
- package/dist/components/geodesic/a11y.d.ts.map +1 -1
- package/dist/components/hover-card/hover-card.d.ts.map +1 -1
- package/dist/components/hover-card/index.js +10 -3
- package/dist/components/hover-card/index.js.map +1 -1
- package/dist/components/image/index.js +3 -3
- package/dist/components/image-cropper/index.js +9 -6
- package/dist/components/input/index.js +2 -2
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/kbd/index.js +3 -3
- package/dist/components/kbd/kbd.d.ts +4 -0
- package/dist/components/kbd/kbd.d.ts.map +1 -1
- package/dist/components/lightbox/index.js +13 -11
- package/dist/components/lightbox/index.js.map +1 -1
- package/dist/components/menu/index.js +9 -5
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/menu/menu.d.ts.map +1 -1
- package/dist/components/modal/index.js +11 -6
- package/dist/components/modal/modal.d.ts +10 -4
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/multi-combobox-list/index.js +13 -9
- package/dist/components/multi-combobox-list/multi-combobox-list.d.ts +1 -1
- package/dist/components/multi-combobox-list/multi-combobox-list.d.ts.map +1 -1
- package/dist/components/multi-select/index.js +13 -10
- package/dist/components/multi-select/index.js.map +1 -1
- package/dist/components/multi-select/multi-select.d.ts +1 -1
- package/dist/components/multi-select/multi-select.d.ts.map +1 -1
- package/dist/components/nav-link/index.js +4 -4
- package/dist/components/nav-link/tanstack.js +4 -4
- package/dist/components/notification/index.js +6 -6
- package/dist/components/notification/index.js.map +1 -1
- package/dist/components/number-input/index.js +11 -7
- package/dist/components/number-input/number-input.d.ts +1 -1
- package/dist/components/number-input/number-input.d.ts.map +1 -1
- package/dist/components/overlays/dialog-parts.d.ts +10 -1
- package/dist/components/overlays/dialog-parts.d.ts.map +1 -1
- package/dist/components/overlays/index.js +13 -8
- package/dist/components/overlays/index.js.map +1 -1
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.d.ts.map +1 -0
- package/dist/components/pagination/index.js +362 -0
- package/dist/components/pagination/index.js.map +1 -0
- package/dist/components/pagination/pagination.d.ts +147 -0
- package/dist/components/pagination/pagination.d.ts.map +1 -0
- package/dist/components/password-input/index.js +6 -5
- package/dist/components/password-input/index.js.map +1 -1
- package/dist/components/password-input/password-input.d.ts +1 -1
- package/dist/components/password-input/password-input.d.ts.map +1 -1
- package/dist/components/phone-input/index.js +14 -11
- package/dist/components/phone-input/index.js.map +1 -1
- package/dist/components/phone-input/phone-input.d.ts +1 -1
- package/dist/components/phone-input/phone-input.d.ts.map +1 -1
- package/dist/components/photo-capture/index.js +19 -17
- package/dist/components/photo-capture/index.js.map +1 -1
- package/dist/components/pills-input/index.js +4 -4
- package/dist/components/pills-input/pills-input.d.ts +1 -1
- package/dist/components/pills-input/pills-input.d.ts.map +1 -1
- package/dist/components/pin-input/index.js +6 -5
- package/dist/components/pin-input/index.js.map +1 -1
- package/dist/components/pin-input/pin-input.d.ts.map +1 -1
- package/dist/components/popover/index.js +7 -2
- package/dist/components/popover/popover.d.ts +41 -16
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/progress/index.d.ts +1 -1
- package/dist/components/progress/index.d.ts.map +1 -1
- package/dist/components/progress/index.js +4 -1
- package/dist/components/progress/progress.d.ts +22 -14
- package/dist/components/progress/progress.d.ts.map +1 -1
- package/dist/components/prose/index.d.ts +2 -0
- package/dist/components/prose/index.d.ts.map +1 -0
- package/dist/components/prose/index.js +17 -0
- package/dist/components/prose/index.js.map +1 -0
- package/dist/components/prose/prose.d.ts +49 -0
- package/dist/components/prose/prose.d.ts.map +1 -0
- package/dist/components/prose/styles.css +593 -0
- package/dist/components/radio-group/index.js +9 -3
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/radio-group/radio-group.d.ts.map +1 -1
- package/dist/components/rating/index.js +3 -2
- package/dist/components/rating/index.js.map +1 -1
- package/dist/components/rating/rating.d.ts.map +1 -1
- package/dist/components/schedule/index.js +10 -8
- package/dist/components/schedule/index.js.map +1 -1
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/index.d.ts.map +1 -0
- package/dist/components/scroll-area/index.js +10 -0
- package/dist/components/scroll-area/index.js.map +1 -0
- package/dist/components/scroll-area/scroll-area.d.ts +150 -0
- package/dist/components/scroll-area/scroll-area.d.ts.map +1 -0
- package/dist/components/segment-group/index.js +2 -2
- package/dist/components/segment-group/segment-group.d.ts.map +1 -1
- package/dist/components/select/index.js +12 -8
- package/dist/components/select/select.d.ts +1 -1
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/slider/index.js +2 -2
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/splitter/index.d.ts +2 -0
- package/dist/components/splitter/index.d.ts.map +1 -0
- package/dist/components/splitter/index.js +373 -0
- package/dist/components/splitter/index.js.map +1 -0
- package/dist/components/splitter/splitter.d.ts +159 -0
- package/dist/components/splitter/splitter.d.ts.map +1 -0
- package/dist/components/spotlight/index.js +23 -22
- package/dist/components/spotlight/index.js.map +1 -1
- package/dist/components/spotlight/spotlight.d.ts.map +1 -1
- package/dist/components/steps/index.d.ts +4 -0
- package/dist/components/steps/index.d.ts.map +1 -0
- package/dist/components/steps/index.js +478 -0
- package/dist/components/steps/index.js.map +1 -0
- package/dist/components/steps/steps-data.d.ts +78 -0
- package/dist/components/steps/steps-data.d.ts.map +1 -0
- package/dist/components/steps/steps.d.ts +183 -0
- package/dist/components/steps/steps.d.ts.map +1 -0
- package/dist/components/switch/index.js +4 -3
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/table-of-contents/index.d.ts +2 -0
- package/dist/components/table-of-contents/index.d.ts.map +1 -0
- package/dist/components/table-of-contents/index.js +471 -0
- package/dist/components/table-of-contents/index.js.map +1 -0
- package/dist/components/table-of-contents/table-of-contents.d.ts +173 -0
- package/dist/components/table-of-contents/table-of-contents.d.ts.map +1 -0
- package/dist/components/tags-input/index.js +12 -9
- package/dist/components/tags-input/index.js.map +1 -1
- package/dist/components/tags-input/tags-input.d.ts +1 -1
- package/dist/components/tags-input/tags-input.d.ts.map +1 -1
- package/dist/components/text-input/index.js +2 -2
- package/dist/components/textarea/index.js +8 -6
- package/dist/components/textarea/index.js.map +1 -1
- package/dist/components/textarea/textarea.d.ts.map +1 -1
- package/dist/components/time-input/index.js +11 -9
- package/dist/components/time-input/index.js.map +1 -1
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts +3 -8
- package/dist/components/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/tour/conditions.d.ts +83 -0
- package/dist/components/tour/conditions.d.ts.map +1 -0
- package/dist/components/tour/create-tours.d.ts +49 -0
- package/dist/components/tour/create-tours.d.ts.map +1 -0
- package/dist/components/tour/index.d.ts +6 -0
- package/dist/components/tour/index.d.ts.map +1 -0
- package/dist/components/tour/index.js +1449 -0
- package/dist/components/tour/index.js.map +1 -0
- package/dist/components/tour/runtime.d.ts +57 -0
- package/dist/components/tour/runtime.d.ts.map +1 -0
- package/dist/components/tour/storage.d.ts +14 -0
- package/dist/components/tour/storage.d.ts.map +1 -0
- package/dist/components/tour/store.d.ts +62 -0
- package/dist/components/tour/store.d.ts.map +1 -0
- package/dist/components/tour/tour.d.ts +77 -0
- package/dist/components/tour/tour.d.ts.map +1 -0
- package/dist/components/tour/types.d.ts +680 -0
- package/dist/components/tour/types.d.ts.map +1 -0
- package/dist/components/tree/index.d.ts +3 -0
- package/dist/components/tree/index.d.ts.map +1 -0
- package/dist/components/tree/index.js +457 -0
- package/dist/components/tree/index.js.map +1 -0
- package/dist/components/tree/tree-row.d.ts +72 -0
- package/dist/components/tree/tree-row.d.ts.map +1 -0
- package/dist/components/tree/tree.d.ts +193 -0
- package/dist/components/tree/tree.d.ts.map +1 -0
- package/dist/components/tree-multi-select/index.js +31 -54
- package/dist/components/tree-multi-select/index.js.map +1 -1
- package/dist/components/tree-multi-select/tree-multi-select.d.ts +16 -1
- package/dist/components/tree-multi-select/tree-multi-select.d.ts.map +1 -1
- package/dist/components/tree-select/index.js +30 -24
- package/dist/components/tree-select/index.js.map +1 -1
- package/dist/components/tree-select/tree-popover.d.ts +20 -31
- package/dist/components/tree-select/tree-popover.d.ts.map +1 -1
- package/dist/components/tree-select/tree-select.d.ts +1 -1
- package/dist/components/tree-select/tree-select.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/lib/date-predicates.d.ts +7 -5
- package/dist/lib/date-predicates.d.ts.map +1 -1
- package/dist/lib/date-value.d.ts +20 -0
- package/dist/lib/date-value.d.ts.map +1 -1
- package/dist/lib/floating-arrow.d.ts +53 -0
- package/dist/lib/floating-arrow.d.ts.map +1 -0
- package/dist/lib/focus-return.d.ts +53 -0
- package/dist/lib/focus-return.d.ts.map +1 -0
- package/dist/lib/meter.d.ts +104 -0
- package/dist/lib/meter.d.ts.map +1 -0
- package/dist/lib/overlay-layer.d.ts +26 -8
- package/dist/lib/overlay-layer.d.ts.map +1 -1
- package/dist/lib/pressed.d.ts +92 -0
- package/dist/lib/pressed.d.ts.map +1 -0
- package/dist/lib/tree-data.d.ts +18 -2
- package/dist/lib/tree-data.d.ts.map +1 -1
- package/dist/lib/use-pagination.d.ts +102 -0
- package/dist/lib/use-pagination.d.ts.map +1 -0
- package/dist/lib/use-scroll-spy.d.ts +126 -0
- package/dist/lib/use-scroll-spy.d.ts.map +1 -0
- package/dist/theme.css +39 -3
- package/package.json +1 -1
- package/src/as-child.contract.test.tsx +283 -1
- package/src/components/action-icon/action-icon.tsx +34 -4
- package/src/components/anchor/anchor.test.tsx +232 -0
- package/src/components/anchor/anchor.tsx +187 -0
- package/src/components/anchor/index.ts +12 -0
- package/src/components/app-shell/app-shell.test.tsx +15 -7
- package/src/components/app-shell/app-shell.tsx +27 -20
- package/src/components/autocomplete/autocomplete.tsx +11 -3
- package/src/components/breadcrumb/breadcrumb.test.tsx +24 -0
- package/src/components/breadcrumb/breadcrumb.tsx +20 -1
- package/src/components/button/button-pressed.test.tsx +202 -0
- package/src/components/button/button.tsx +48 -6
- package/src/components/button-select/button-select-control.tsx +2 -2
- package/src/components/button-select/button-select.tsx +22 -2
- package/src/components/calendar/aliases.tsx +28 -0
- package/src/components/calendar/calendar-body.tsx +310 -210
- package/src/components/calendar/calendar.tsx +43 -12
- package/src/components/calendar/index.ts +7 -1
- package/src/components/calendar/month-year-calendar.test.tsx +106 -0
- package/src/components/calendar-heatmap/calendar-heatmap.tsx +88 -73
- package/src/components/checkbox/checkbox.tsx +7 -2
- package/src/components/choice-card-group/choice-card-group.tsx +2 -2
- package/src/components/circular-progress/circular-progress.test.tsx +35 -0
- package/src/components/circular-progress/circular-progress.tsx +116 -59
- package/src/components/circular-progress/index.ts +1 -0
- package/src/components/code/code.test.tsx +16 -0
- package/src/components/code/code.tsx +11 -0
- package/src/components/combobox/combobox.tsx +63 -28
- package/src/components/combobox-list/combobox-list.tsx +11 -3
- package/src/components/data-list/data-list.test.tsx +149 -0
- package/src/components/data-list/data-list.tsx +268 -0
- package/src/components/data-list/index.ts +9 -0
- package/src/components/data-table/data-table-group.test.tsx +16 -0
- package/src/components/data-table/data-table-group.tsx +15 -2
- package/src/components/data-table/data-table-placeholder.tsx +28 -36
- package/src/components/data-table/data-table-stack.tsx +33 -39
- package/src/components/data-table/data-table.test.tsx +31 -0
- package/src/components/data-table/data-table.tsx +41 -42
- package/src/components/date-picker/aliases.tsx +28 -0
- package/src/components/date-picker/date-picker.test.tsx +29 -0
- package/src/components/date-picker/date-picker.tsx +164 -45
- package/src/components/date-picker/index.ts +5 -1
- package/src/components/date-picker/month-year-picker.test.tsx +362 -0
- package/src/components/drawer/drawer.test.tsx +41 -0
- package/src/components/drawer/drawer.tsx +7 -1
- package/src/components/empty-state/empty-state.test.tsx +109 -0
- package/src/components/empty-state/empty-state.tsx +180 -0
- package/src/components/empty-state/index.ts +9 -0
- package/src/components/field/field.tsx +35 -1
- package/src/components/fieldset/fieldset.test.tsx +352 -0
- package/src/components/fieldset/fieldset.tsx +268 -0
- package/src/components/fieldset/index.ts +11 -0
- package/src/components/file-preview/file-preview.test.tsx +2 -1
- package/src/components/file-preview/file-preview.tsx +7 -13
- package/src/components/file-upload/file-upload.tsx +14 -5
- package/src/components/hover-card/hover-card.tsx +5 -1
- package/src/components/input/input.tsx +12 -5
- package/src/components/kbd/kbd.test.tsx +13 -0
- package/src/components/kbd/kbd.tsx +6 -0
- package/src/components/menu/menu.tsx +6 -2
- package/src/components/modal/modal.test.tsx +41 -0
- package/src/components/modal/modal.tsx +17 -9
- package/src/components/multi-combobox-list/multi-combobox-list.tsx +11 -3
- package/src/components/multi-select/multi-select.tsx +11 -3
- package/src/components/notification/create-notifier.tsx +1 -1
- package/src/components/number-input/number-input.tsx +12 -3
- package/src/components/overlays/dialog-parts.tsx +42 -5
- package/src/components/pagination/index.ts +19 -0
- package/src/components/pagination/pagination.test.tsx +187 -0
- package/src/components/pagination/pagination.tsx +563 -0
- package/src/components/password-input/password-input.tsx +12 -3
- package/src/components/phone-input/phone-input.tsx +12 -3
- package/src/components/pills-input/pills-input.tsx +7 -2
- package/src/components/pin-input/pin-input.tsx +13 -4
- package/src/components/popover/popover.tsx +87 -17
- package/src/components/progress/index.ts +1 -0
- package/src/components/progress/progress.test.tsx +102 -0
- package/src/components/progress/progress.tsx +116 -62
- package/src/components/prose/index.ts +1 -0
- package/src/components/prose/prose.test.tsx +90 -0
- package/src/components/prose/prose.tsx +60 -0
- package/src/components/prose/styles.css +593 -0
- package/src/components/radio-group/radio-group.tsx +8 -3
- package/src/components/rating/rating.tsx +5 -2
- package/src/components/scroll-area/index.ts +18 -0
- package/src/components/scroll-area/scroll-area.test.tsx +184 -0
- package/src/components/scroll-area/scroll-area.tsx +448 -0
- package/src/components/segment-group/segment-group.tsx +2 -2
- package/src/components/select/select.tsx +37 -18
- package/src/components/slider/slider.tsx +2 -2
- package/src/components/splitter/index.ts +15 -0
- package/src/components/splitter/splitter.test.tsx +244 -0
- package/src/components/splitter/splitter.tsx +625 -0
- package/src/components/spotlight/spotlight.test.tsx +34 -26
- package/src/components/spotlight/spotlight.tsx +7 -9
- package/src/components/steps/index.ts +21 -0
- package/src/components/steps/steps-data.tsx +179 -0
- package/src/components/steps/steps.test.tsx +235 -0
- package/src/components/steps/steps.tsx +686 -0
- package/src/components/switch/switch.tsx +7 -2
- package/src/components/table-of-contents/index.ts +17 -0
- package/src/components/table-of-contents/table-of-contents.test.tsx +289 -0
- package/src/components/table-of-contents/table-of-contents.tsx +708 -0
- package/src/components/tags-input/tags-input.tsx +12 -3
- package/src/components/textarea/textarea.tsx +15 -5
- package/src/components/tooltip/tooltip.tsx +8 -17
- package/src/components/tour/conditions.test.ts +527 -0
- package/src/components/tour/conditions.ts +445 -0
- package/src/components/tour/create-tours.tsx +150 -0
- package/src/components/tour/index.ts +86 -0
- package/src/components/tour/runtime.ts +187 -0
- package/src/components/tour/storage.test.ts +68 -0
- package/src/components/tour/storage.ts +44 -0
- package/src/components/tour/store.test.tsx +784 -0
- package/src/components/tour/store.ts +661 -0
- package/src/components/tour/tour.test.tsx +318 -0
- package/src/components/tour/tour.tsx +773 -0
- package/src/components/tour/tour.types.test.ts +185 -0
- package/src/components/tour/types.ts +904 -0
- package/src/components/tree/index.ts +24 -0
- package/src/components/tree/tree-row.tsx +179 -0
- package/src/components/tree/tree.test.tsx +296 -0
- package/src/components/tree/tree.tsx +796 -0
- package/src/components/tree-multi-select/tree-multi-select.tsx +29 -58
- package/src/components/tree-select/tree-popover.tsx +26 -107
- package/src/components/tree-select/tree-select.tsx +24 -16
- package/src/icon-stroke.test.tsx +2 -0
- package/src/index.ts +16 -0
- package/src/lib/date-predicates.test.ts +46 -0
- package/src/lib/date-predicates.ts +44 -24
- package/src/lib/date-value.test.ts +24 -1
- package/src/lib/date-value.ts +42 -1
- package/src/lib/floating-arrow.tsx +73 -0
- package/src/lib/focus-return.test.tsx +143 -0
- package/src/lib/focus-return.ts +106 -0
- package/src/lib/meter.test.ts +40 -0
- package/src/lib/meter.ts +159 -0
- package/src/lib/overlay-layer.test.tsx +47 -1
- package/src/lib/overlay-layer.tsx +65 -8
- package/src/lib/pressed.ts +130 -0
- package/src/lib/tree-data.ts +42 -2
- package/src/lib/use-pagination.test.ts +105 -0
- package/src/lib/use-pagination.ts +179 -0
- package/src/lib/use-scroll-spy.test.tsx +238 -0
- package/src/lib/use-scroll-spy.ts +336 -0
- package/src/theme.css +39 -3
- package/src/theme.test.ts +29 -1
- package/src/visually-hidden-containment.test.tsx +9 -0
- package/dist/chunk-2W7H43WL.js.map +0 -1
- package/dist/chunk-7E7JNWOC.js.map +0 -1
- package/dist/chunk-7FPSQBWB.js.map +0 -1
- package/dist/chunk-7KFUFAVP.js.map +0 -1
- package/dist/chunk-AKXALCUN.js.map +0 -1
- package/dist/chunk-B5YHYI7E.js.map +0 -1
- package/dist/chunk-FQJNQW3G.js.map +0 -1
- package/dist/chunk-G3AD3NJG.js.map +0 -1
- package/dist/chunk-GEZYGBXY.js.map +0 -1
- package/dist/chunk-HCHGERDB.js.map +0 -1
- package/dist/chunk-HWBFRDX7.js.map +0 -1
- package/dist/chunk-I4B3N3UX.js.map +0 -1
- package/dist/chunk-IA6DCC3N.js.map +0 -1
- package/dist/chunk-IANYMDKH.js.map +0 -1
- package/dist/chunk-MQHD3EJE.js.map +0 -1
- package/dist/chunk-NNPSBC7O.js.map +0 -1
- package/dist/chunk-OXR7BXZA.js.map +0 -1
- package/dist/chunk-QKSLDQM2.js +0 -120
- package/dist/chunk-QKSLDQM2.js.map +0 -1
- package/dist/chunk-QRNQQIQM.js.map +0 -1
- package/dist/chunk-RKCUXOU2.js.map +0 -1
- package/dist/chunk-S5CQRCTF.js +0 -426
- package/dist/chunk-S5CQRCTF.js.map +0 -1
- package/dist/chunk-SBZJGFZ6.js.map +0 -1
- package/dist/chunk-SP6LCCTZ.js.map +0 -1
- package/dist/chunk-TUP7WXQE.js.map +0 -1
- package/dist/chunk-V2QZG4IT.js.map +0 -1
- package/dist/chunk-X6DESK37.js.map +0 -1
- package/dist/chunk-ZB5VMGKB.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/choice-card-group/choice-card-group.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmMA,IAAM,UAAA,GAAa,GAAA;AAAA,EACjB;AAAA,IACE,sIAAA;AAAA,IACA,YAAA;AAAA,IACA,kBAAA,CAAmB,OAAA;AAAA,IACnB,yCAAA;AAAA,IACA,sDAAA;AAAA;AAAA;AAAA,IAGA,WAAA,CAAY,EAAE,MAAA,EAAQ,oBAAA,EAAsB,CAAA;AAAA;AAAA,IAE5C,+DAAA;AAAA;AAAA,IAEA,2DAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA;AAAA,MAER,OAAA,EAAS;AAAA;AAAA,QAEP,OAAA,EAAS,8EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMT,MAAA,EAAQ;AA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AAA;AAAA,YAClB,SAAA,EAAW,UAAU,IAAI,CAAA;AAAA,YAEzB,QAAA,EAAA;AAAA,8BAAA,GAAA,CAAC,eAAA,EAAA,EAAgB,IAAA,EAAY,IAAA,EAAY,SAAA,EAAsB,OAAA,EAAkB,CAAA;AAAA,8BACjF,GAAA,CAAC,UAAA,CAAW,eAAA,EAAX,EAA2B;AAAA;AAAA,WAAA;AAAA,UAPvB,IAAA,CAAK;AAAA,SAQZ;AAAA,MAEJ,CAAC;AAAA;AAAA,GACH;AAGF,EAAA,uBACE,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,WAAA;AAAA,MACA,KAAA;AAAA,MACA,QAAA;AAAA,MACA,QAAA;AAAA,MACA,IAAA;AAAA,MACA,WAAW,UAAA,EAAY,KAAA;AAAA,MAEvB,SAAA,EAAS,IAAA;AAAA,MAER,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"index.js","sourcesContent":["\"use client\"\n\nimport { Checkbox, CheckboxGroup } from \"@ark-ui/react/checkbox\"\nimport { useFieldContext } from \"@ark-ui/react/field\"\nimport { RadioGroup } from \"@ark-ui/react/radio-group\"\nimport { cva } from \"class-variance-authority\"\nimport {\n type ComponentProps,\n type FocusEvent,\n type KeyboardEvent,\n type ReactNode,\n type Ref,\n useId,\n} from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { FlatValueOf } from \"../../lib/select-data\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES, TYPOGRAPHY_SHADE_CLASSES } from \"../../lib/typography-size\"\nimport { type ControlIndicatorVariant, controlIndicator } from \"../checkbox/control\"\nimport { FieldShell, fieldA11yProps } from \"../field/field\"\nimport { CheckIcon } from \"../popover/icons\"\n\n/**\n * ChoiceCardGroup — a data-driven set of **selectable cards**, the richer cousin\n * of `RadioGroup` / `Checkbox`. Each option is a bordered card with a title, an\n * optional helper line, and an optional leading icon / avatar / misc slot;\n * selecting one tints its border and fill with the active palette. The group's\n * `label` / `description` / `error` / `required` live around it via the shared\n * `Field` scaffold, so it is accessible and complete on its own — exactly like\n * the rest of the form family (and implementing the kit's value-based\n * `FormControlProps` contract).\n *\n * One prop, `multiple`, switches the selection semantics — and the machine under\n * the hood:\n *\n * - **single** (default): Ark UI's `RadioGroup`. The value is a `string | null`\n * and each card shows a **radio** circle.\n * - **multi** (`multiple`): Ark UI's `CheckboxGroup`. The value is a `string[]`\n * and each card shows a **checkbox** tick.\n *\n * Arrow keys move focus between cards in both modes — native for the radio\n * path (grouped `<input type=\"radio\">`), hand-rolled for the checkbox path\n * (standalone checkboxes have no such native grouping). Only single mode\n * selects as focus moves; multi mode still needs `Space` / a click to toggle.\n *\n * In both modes `onChange` hands you the next value directly (a value, not a DOM\n * event), `name` wires the hidden inputs into native form submission, and `ref` /\n * `onBlur` land on the group root for focus-on-error. `invalid` is OR'd with\n * `error != null`, so a form library can flip the red state independently of the\n * message.\n *\n * - `data` accept bare strings (`value === label`) or\n * `{ value, label, description?, icon?, disabled? }` objects, mixed freely.\n * - `icon` is the leading **start** slot — any node (icon, avatar, …). When an\n * item has one, that card lays the icon at the start and pushes the selection\n * indicator to the **end**; otherwise the indicator sits at the start.\n * - `renderItem` is an escape hatch that replaces a card's text block with your\n * own content, handed the item and its live `{ checked, disabled }` state.\n *\n * The card reuses the family's shared `controlIndicator` surface for its tick /\n * dot (`variant`: `default` monochrome or `filled` palette-colored), so a card's\n * checkbox matches a bare `Checkbox` pixel-for-pixel. The selected card's tint\n * and the focus ring ride the `--c-solid` / `--c-soft` slot vars off `data-color`,\n * so every kit color works for free; `invalid` overrides to red.\n */\n\n/** A single option: a bare string (used as both value + label) or an explicit object. */\nexport type ChoiceCardItem =\n | string\n | {\n value: string\n label: ReactNode\n /** Helper line under the card's title. */\n description?: ReactNode\n /** Leading start slot — icon / avatar / misc. Moves the indicator to the card's end. */\n icon?: ReactNode\n disabled?: boolean\n /** `data-testid` on the rendered card. Defaults to `` `item-${value}` ``. */\n testId?: string\n }\n\n/** A fully resolved option (a bare string is normalized to `{ value, label }`). */\ntype NormalizedItem = {\n value: string\n label: ReactNode\n description?: ReactNode\n icon?: ReactNode\n disabled?: boolean\n testId: string\n}\n\n/** Live state handed to `renderItem` alongside the item. */\nexport type ChoiceCardRenderState = { checked: boolean; disabled: boolean }\n\n/**\n * Render a card's content yourself. Receives the (normalized) item and its live\n * `{ checked, disabled }` state, and replaces the default title + description\n * block; the card keeps its surface, icon slot, indicator, and selection wiring.\n * In an RSC tree the function must live in a `\"use client\"` module.\n */\nexport type RenderChoiceCard = (item: NormalizedItem, state: ChoiceCardRenderState) => ReactNode\n\ntype ChoiceCardClassNames = {\n field?: string\n root?: string\n item?: string\n control?: string\n label?: string\n description?: string\n}\n\nexport type ChoiceCardGroupData = ReadonlyArray<ChoiceCardItem>\n\n/** The value union `data` narrows to — literal option values for a `const`-typed\n * `data` array, or plain `string` for a dynamically-built one. */\nexport type ChoiceCardGroupValue<Data extends ChoiceCardGroupData> = FlatValueOf<Data>\n\ntype ChoiceCardGroupBaseProps<Data extends ChoiceCardGroupData> = WithTestId & {\n /** The options. Bare strings are normalized to `{ value, label }`. */\n data: Data\n /** Stacking direction of the cards. */\n orientation?: \"horizontal\" | \"vertical\"\n /** Replace a card's text block with your own content (with its live state). */\n renderItem?: RenderChoiceCard\n /** Field label above the group. */\n label?: ReactNode\n /** Helper text above the group. */\n description?: ReactNode\n /** Error message below the group; its presence sets the invalid state. */\n error?: ReactNode\n /** Required flag (and, with a label, the red asterisk). */\n required?: boolean\n /** Red invalid state, OR'd with `error != null`. */\n invalid?: boolean\n /** Dims and blocks interaction. */\n disabled?: boolean\n /** Keeps full contrast but blocks edits. */\n readOnly?: boolean\n size?: Size\n /** Indicator fill: `default` (monochrome) or `filled` (palette-colored). */\n variant?: ControlIndicatorVariant\n color?: Color\n /** Field name for native form submission. */\n name?: string\n /** Explicit id for label association. */\n id?: string\n /** Lands on the group root for focus-on-error. */\n ref?: Ref<HTMLDivElement>\n /** Forwarded to the group root; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLDivElement>) => void\n className?: string\n classNames?: ChoiceCardClassNames\n}\n\n/** Single-select (radio): value is a `string | null`. */\ntype SingleSelection<Data extends ChoiceCardGroupData> = {\n multiple?: false\n value?: ChoiceCardGroupValue<Data> | null\n defaultValue?: ChoiceCardGroupValue<Data> | null\n onChange?: (value: ChoiceCardGroupValue<Data> | null) => void\n}\n\n/** Multi-select (checkbox): value is a `string[]`. */\ntype MultiSelection<Data extends ChoiceCardGroupData> = {\n multiple: true\n value?: ChoiceCardGroupValue<Data>[]\n defaultValue?: ChoiceCardGroupValue<Data>[]\n onChange?: (value: ChoiceCardGroupValue<Data>[]) => void\n}\n\nexport type ChoiceCardGroupProps<Data extends ChoiceCardGroupData = ChoiceCardItem[]> =\n ChoiceCardGroupBaseProps<Data> & (SingleSelection<Data> | MultiSelection<Data>)\n\n/**\n * The card surface. Neutral at rest on the kit's translucent surface — the same\n * `bg-white/4` + `border-brand-900/20 dark:border-white/8` recipe as `Card`\n * (Figma's `border-primary`, the card hairline): a fixed opaque\n * gray fill can vanish or over-assert depending on the host background, so the\n * fill carries no ground of its own. The selected treatment follows the\n * `variant`, mirroring `Checkbox` / `RadioGroup`:\n * `default` stays palette-independent (a strong neutral border — the mark itself\n * fills monochrome), while `filled` tints the border + a half-strength soft fill\n * off the active palette, leaving the colored mark to carry the palette. The focus ring is the kit's standard brand ring in both, again like\n * the rest of the selection family (the inner indicator's own ring is suppressed\n * so only the card rings).\n *\n * The red / disabled affordances cover both paths: the multi cards carry their\n * own `data-invalid` / `data-disabled` (set on each `Checkbox.Root`), while the\n * radio cards inherit them from the group root (`group-data-*`), since Ark only\n * flags the `RadioGroup` root, not its items.\n */\nconst choiceCard = cva(\n [\n \"relative flex w-full cursor-pointer rounded-card border text-start select-none transition-[background-color,border-color,box-shadow]\",\n \"bg-white/4\",\n TEXT_COLOR_CLASSES.primary,\n \"border-brand-900/20 dark:border-white/8\",\n \"hover:border-brand-900/30 dark:hover:border-white/25\",\n // Keyboard focus ring on the whole card — the kit's standard brand ring,\n // matching Checkbox / Radio regardless of palette.\n focusStyles({ source: \"data-focus-visible\" }),\n // Invalid wins over the palette: red border (per-card or group-level).\n \"data-invalid:border-red-500 group-data-invalid:border-red-500\",\n // Disabled affordances (per-card item or group-level).\n \"data-disabled:cursor-not-allowed data-disabled:opacity-60\",\n \"group-data-disabled:cursor-not-allowed group-data-disabled:opacity-60\",\n ],\n {\n variants: {\n // Selected treatment, mirroring the indicator's own `variant`.\n variant: {\n // Palette-independent: a strong neutral border (the mark fills dark).\n default: \"data-[state=checked]:border-brand-950 dark:data-[state=checked]:border-white\",\n // Palette-tinted, kept quiet: a translucent `--c-solid` edge + the soft\n // fill at half strength off the root's `data-color`; the filled mark\n // carries the palette. A full `--c-soft` slab with an opaque edge drowned\n // the rest of a form in warm palettes, and a `--c-soft-hover` edge was\n // too faint — the checked card read weaker than the unchecked ones.\n filled: \"data-[state=checked]:border-(--c-solid)/45 data-[state=checked]:bg-(--c-soft)/50\",\n },\n size: {\n xs: \"gap-2 p-2\",\n sm: \"gap-2.5 p-2.5\",\n md: \"gap-3 p-3\",\n lg: \"gap-3.5 p-4\",\n xl: \"gap-4 p-5\",\n },\n // Center a single-line card; top-align once a description makes it taller.\n // In `start`, `ChoiceCardInner` also centres the indicator on the label's\n // first line (see `capLine`), since the trimmed label is only a cap tall.\n align: { center: \"items-center\", start: \"items-start\" },\n },\n defaultVariants: { variant: \"default\", size: \"md\", align: \"center\" },\n },\n)\n\n/** The card title's font size per card size — shared with `capLine`, whose `1cap` must resolve against it. */\nconst labelTextSize = {\n xs: \"text-xs\",\n sm: \"text-sm\",\n md: \"text-sm\",\n lg: \"text-md\",\n xl: \"text-lg\",\n} as const satisfies Record<Size, string>\n\nconst cardLabel = cva(\"font-medium text-trim\", {\n variants: { size: labelTextSize },\n defaultVariants: { size: \"md\" },\n})\n\n/**\n * A box exactly one label cap-height tall that centres the indicator in it. The\n * title is `text-trim`'d to its cap height, so a top-aligned indicator (taller\n * than a cap) would sit low; centring it in a `1cap` line puts its middle on\n * the middle of the title's first line, whatever the title wraps to. The box\n * overflows evenly into the card's padding. Gated on `text-box-trim` support:\n * where the title keeps its full leading (Firefox), the box keeps its natural\n * height and the indicator stays top-aligned, as before.\n */\nconst capLine = (size: Size) =>\n cn(labelTextSize[size], \"flex shrink-0 items-center supports-[text-box-trim:trim-both]:h-[1cap]\")\n\nconst cardDescription = cva(TYPOGRAPHY_SHADE_CLASSES.muted, {\n variants: {\n size: { xs: \"text-xs\", sm: \"text-xs\", md: \"text-xs\", lg: \"text-sm\", xl: \"text-sm\" },\n },\n defaultVariants: { size: \"md\" },\n})\n\nconst cardIcon = cva(\n [\"inline-flex shrink-0 items-center justify-center\", TEXT_COLOR_CLASSES.secondary],\n {\n variants: {\n size: {\n xs: \"[&_svg]:size-4\",\n sm: \"[&_svg]:size-4.5\",\n md: \"[&_svg]:size-5\",\n lg: \"[&_svg]:size-6\",\n xl: \"[&_svg]:size-7\",\n },\n },\n defaultVariants: { size: \"md\" },\n },\n)\n\n/** Suppress the shared indicator's own focus ring — the card rings instead. */\nconst noIndicatorRing = \"data-focus-visible:ring-0\"\n\nconst normalize = (item: ChoiceCardItem): NormalizedItem =>\n typeof item === \"string\"\n ? { value: item, label: item, testId: `item-${item}` }\n : { ...item, testId: item.testId ?? `item-${item.value}` }\n\n/**\n * Arrow keys move focus between checkbox cards — matching `RadioGroup`'s\n * native roving focus, which standalone checkboxes have no equivalent for.\n */\nconst onCardArrowKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const dir = { ArrowDown: 1, ArrowRight: 1, ArrowUp: -1, ArrowLeft: -1 }[event.key]\n if (!dir) return\n const cards = Array.from(\n event.currentTarget.querySelectorAll<HTMLInputElement>(\"input[type=checkbox]:not(:disabled)\"),\n )\n const at = cards.indexOf(document.activeElement as HTMLInputElement)\n if (at === -1) return\n event.preventDefault()\n cards[(at + dir + cards.length) % cards.length]?.focus()\n}\n\n/**\n * The two group roots, split out so they read the `Field` context from *inside* `FieldShell`.\n * Neither Ark root takes a Field's label: `RadioGroup` only reads a `Fieldset` (and otherwise\n * points `aria-labelledby` at its never-rendered `RadioGroup.Label`), and `CheckboxGroup` is a bare\n * `role=\"group\"` div. `fieldA11yProps` names the group by the field's `label` and describes it by\n * its `description`, or by its `error` once invalid.\n */\nconst RadioCardsRoot = (rootProps: ComponentProps<typeof RadioGroup.Root>) => (\n <RadioGroup.Root {...fieldA11yProps(useFieldContext())} {...rootProps} />\n)\n\nconst CheckboxCardsRoot = (rootProps: ComponentProps<typeof CheckboxGroup>) => (\n <CheckboxGroup {...fieldA11yProps(useFieldContext())} {...rootProps} />\n)\n\n/**\n * Lay out one card: with a leading `icon`, the order is icon → text → indicator\n * (pushed to the end by the text's `flex-1`); without one, indicator → text.\n * A top-aligned card (one with a description) wraps the indicator in a\n * `capLine` so it centres on the title's first line.\n */\nconst ChoiceCardInner = ({\n item,\n size,\n indicator: control,\n content,\n}: {\n item: NormalizedItem\n size: Size\n indicator: ReactNode\n content: ReactNode\n}) => {\n const text = <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">{content}</span>\n const indicator =\n item.description != null ? <span className={capLine(size)}>{control}</span> : control\n return item.icon != null ? (\n <>\n <span className={cardIcon({ size })} aria-hidden>\n {item.icon}\n </span>\n {text}\n {indicator}\n </>\n ) : (\n <>\n {indicator}\n {text}\n </>\n )\n}\n\nconst defaultContent = (item: NormalizedItem, size: Size, classNames?: ChoiceCardClassNames) => (\n <>\n <span className={cn(cardLabel({ size }), classNames?.label)}>{item.label}</span>\n {item.description != null && (\n <span className={cn(cardDescription({ size }), classNames?.description)}>\n {item.description}\n </span>\n )}\n </>\n)\n\nexport const ChoiceCardGroup = <const Data extends ChoiceCardGroupData = ChoiceCardItem[]>(\n groupProps: ChoiceCardGroupProps<Data>,\n) => {\n // Kept whole, not destructured: `multiple` is the union's discriminant, and narrowing on it\n // types `value` / `defaultValue` / `onChange` per branch without casts.\n const selection: SingleSelection<Data> | MultiSelection<Data> = groupProps\n const {\n data,\n orientation = \"vertical\",\n renderItem,\n label,\n description,\n error,\n required,\n invalid,\n disabled,\n readOnly,\n size = \"md\",\n variant = \"default\",\n color,\n name,\n id,\n ref,\n onBlur,\n className,\n classNames,\n testId,\n } = groupProps\n // Red state is driven independently of the `Field` error slot so a form\n // library can flip it from `fieldState.invalid` (see FormControlProps).\n const isInvalid = invalid || error != null\n const normalized = data.map(normalize)\n // Ark reports plain strings; every one it can report is a card's value, so this guard\n // narrows Ark's `string` back to `data`'s value union instead of asserting it.\n const isValue = (candidate: string): candidate is ChoiceCardGroupValue<Data> =>\n normalized.some((item) => item.value === candidate)\n // Base for per-card ids. Each multi card is its own Ark Checkbox machine; left\n // to inherit the shared `Field` context they'd all take the *same* control id,\n // so every card's <label> would point at the first input (clicking any card\n // toggled only the first). A unique `ids.hiddenInput` per card fixes that.\n const reactId = useId()\n\n // `group` lets the radio cards read the root's `data-invalid` / `data-disabled`.\n const rootClass = cn(\n \"group flex w-full gap-2\",\n orientation === \"horizontal\" ? \"flex-row flex-wrap\" : \"flex-col\",\n className,\n classNames?.root,\n )\n\n // `cn`, not cva's `className`: cva only concatenates, so a consumer's\n // `data-[state=checked]:border-*` would lose to the variant's on stylesheet order.\n const itemClass = (item: NormalizedItem) =>\n cn(\n choiceCard({ variant, size, align: item.description != null ? \"start\" : \"center\" }),\n classNames?.item,\n )\n\n const group = selection.multiple ? (\n <CheckboxCardsRoot\n value={selection.value}\n defaultValue={selection.defaultValue}\n onValueChange={(next) => selection.onChange?.(next.filter(isValue))}\n disabled={disabled}\n readOnly={readOnly}\n invalid={isInvalid}\n name={name}\n id={id}\n ref={ref}\n onBlur={onBlur}\n onKeyDown={onCardArrowKeyDown}\n data-color={color}\n {...props({ \"data-testid\": testId })}\n className={rootClass}\n >\n {normalized.map((item, index) => {\n const indicator = (\n <Checkbox.Control\n className={cn(\n controlIndicator({ size, variant }),\n noIndicatorRing,\n classNames?.control,\n )}\n >\n <Checkbox.Indicator>\n <CheckIcon />\n </Checkbox.Indicator>\n </Checkbox.Control>\n )\n const content = renderItem ? (\n <Checkbox.Context>\n {(api) =>\n renderItem(item, { checked: api.checked === true, disabled: Boolean(api.disabled) })\n }\n </Checkbox.Context>\n ) : (\n defaultContent(item, size, classNames)\n )\n return (\n <Checkbox.Root\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n invalid={isInvalid}\n ids={{ hiddenInput: `${reactId}-${index}` }}\n data-testid={item.testId}\n className={itemClass(item)}\n >\n <ChoiceCardInner item={item} size={size} indicator={indicator} content={content} />\n <Checkbox.HiddenInput />\n </Checkbox.Root>\n )\n })}\n </CheckboxCardsRoot>\n ) : (\n <RadioCardsRoot\n value={selection.value}\n defaultValue={selection.defaultValue}\n onValueChange={({ value }) =>\n selection.onChange?.(value != null && isValue(value) ? value : null)\n }\n invalid={isInvalid}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n name={name}\n id={id}\n ref={ref}\n onBlur={onBlur}\n orientation={orientation}\n data-color={color}\n {...props({ \"data-testid\": testId })}\n className={rootClass}\n >\n {normalized.map((item) => {\n const indicator = (\n <RadioGroup.ItemControl\n className={cn(\n controlIndicator({ size, variant }),\n \"rounded-full\",\n noIndicatorRing,\n classNames?.control,\n )}\n >\n {/* The inner dot reads its own checked state from the item context —\n a bare `<span>` can't see the control's `data-[state]`. */}\n <RadioGroup.ItemContext>\n {(s) =>\n s.checked ? (\n <span className=\"size-[50%] rounded-full bg-brand-50 dark:bg-brand-950\" />\n ) : null\n }\n </RadioGroup.ItemContext>\n </RadioGroup.ItemControl>\n )\n const content = renderItem ? (\n <RadioGroup.ItemContext>\n {(s) => renderItem(item, { checked: s.checked, disabled: Boolean(s.disabled) })}\n </RadioGroup.ItemContext>\n ) : (\n defaultContent(item, size, classNames)\n )\n return (\n <RadioGroup.Item\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n data-testid={item.testId}\n className={itemClass(item)}\n >\n <ChoiceCardInner item={item} size={size} indicator={indicator} content={content} />\n <RadioGroup.ItemHiddenInput />\n </RadioGroup.Item>\n )\n })}\n </RadioCardsRoot>\n )\n\n return (\n <FieldShell\n label={label}\n description={description}\n error={error}\n required={required}\n disabled={disabled}\n size={size}\n className={classNames?.field}\n // A group of cards: nothing carries the label's `for` id; the root's `aria-labelledby` names it.\n composite\n >\n {group}\n </FieldShell>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/choice-card-group/choice-card-group.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmMA,IAAM,UAAA,GAAa,GAAA;AAAA,EACjB;AAAA,IACE,sIAAA;AAAA,IACA,YAAA;AAAA,IACA,kBAAA,CAAmB,OAAA;AAAA,IACnB,yCAAA;AAAA,IACA,sDAAA;AAAA;AAAA;AAAA,IAGA,WAAA,CAAY,EAAE,MAAA,EAAQ,oBAAA,EAAsB,CAAA;AAAA;AAAA,IAE5C,+DAAA;AAAA;AAAA,IAEA,2DAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA;AAAA,MAER,OAAA,EAAS;AAAA;AAAA,QAEP,OAAA,EAAS,8EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMT,MAAA,EAAQ;AAAA,OACV;AAAA,MACA,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,WAAA;AAAA,QACJ,EAAA,EAAI,eAAA;AAAA,QACJ,EAAA,EAAI,WAAA;AAAA,QACJ,EAAA,EAAI,aAAA;AAAA,QACJ,EAAA,EAAI;AAAA,OACN;AAAA;AAAA;AAAA;AAAA,MAIA,KAAA,EAAO,EAAE,MAAA,EAAQ,cAAA,EAAgB,OAAO,aAAA;AAAc,KACxD;AAAA,IACA,iB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K;AAAA,SAQZ;AAAA,MAEJ,CAAC;AAAA;AAAA,GACH;AAGF,EAAA,uBACE,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,WAAA;AAAA,MACA,KAAA;AAAA,MACA,QAAA;AAAA,MACA,QAAA;AAAA,MACA,IAAA;AAAA,MACA,WAAW,UAAA,EAAY,KAAA;AAAA,MAEvB,SAAA,EAAS,IAAA;AAAA,MAER,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"index.js","sourcesContent":["\"use client\"\n\nimport { Checkbox, CheckboxGroup } from \"@ark-ui/react/checkbox\"\nimport { useFieldContext } from \"@ark-ui/react/field\"\nimport { RadioGroup } from \"@ark-ui/react/radio-group\"\nimport { cva } from \"class-variance-authority\"\nimport {\n type ComponentProps,\n type FocusEvent,\n type KeyboardEvent,\n type ReactNode,\n type Ref,\n useId,\n} from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { FlatValueOf } from \"../../lib/select-data\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES, TYPOGRAPHY_SHADE_CLASSES } from \"../../lib/typography-size\"\nimport { type ControlIndicatorVariant, controlIndicator } from \"../checkbox/control\"\nimport { FieldShell, fieldA11yProps, useInheritedInvalid } from \"../field/field\"\nimport { CheckIcon } from \"../popover/icons\"\n\n/**\n * ChoiceCardGroup — a data-driven set of **selectable cards**, the richer cousin\n * of `RadioGroup` / `Checkbox`. Each option is a bordered card with a title, an\n * optional helper line, and an optional leading icon / avatar / misc slot;\n * selecting one tints its border and fill with the active palette. The group's\n * `label` / `description` / `error` / `required` live around it via the shared\n * `Field` scaffold, so it is accessible and complete on its own — exactly like\n * the rest of the form family (and implementing the kit's value-based\n * `FormControlProps` contract).\n *\n * One prop, `multiple`, switches the selection semantics — and the machine under\n * the hood:\n *\n * - **single** (default): Ark UI's `RadioGroup`. The value is a `string | null`\n * and each card shows a **radio** circle.\n * - **multi** (`multiple`): Ark UI's `CheckboxGroup`. The value is a `string[]`\n * and each card shows a **checkbox** tick.\n *\n * Arrow keys move focus between cards in both modes — native for the radio\n * path (grouped `<input type=\"radio\">`), hand-rolled for the checkbox path\n * (standalone checkboxes have no such native grouping). Only single mode\n * selects as focus moves; multi mode still needs `Space` / a click to toggle.\n *\n * In both modes `onChange` hands you the next value directly (a value, not a DOM\n * event), `name` wires the hidden inputs into native form submission, and `ref` /\n * `onBlur` land on the group root for focus-on-error. `invalid` is OR'd with\n * `error != null`, so a form library can flip the red state independently of the\n * message.\n *\n * - `data` accept bare strings (`value === label`) or\n * `{ value, label, description?, icon?, disabled? }` objects, mixed freely.\n * - `icon` is the leading **start** slot — any node (icon, avatar, …). When an\n * item has one, that card lays the icon at the start and pushes the selection\n * indicator to the **end**; otherwise the indicator sits at the start.\n * - `renderItem` is an escape hatch that replaces a card's text block with your\n * own content, handed the item and its live `{ checked, disabled }` state.\n *\n * The card reuses the family's shared `controlIndicator` surface for its tick /\n * dot (`variant`: `default` monochrome or `filled` palette-colored), so a card's\n * checkbox matches a bare `Checkbox` pixel-for-pixel. The selected card's tint\n * and the focus ring ride the `--c-solid` / `--c-soft` slot vars off `data-color`,\n * so every kit color works for free; `invalid` overrides to red.\n */\n\n/** A single option: a bare string (used as both value + label) or an explicit object. */\nexport type ChoiceCardItem =\n | string\n | {\n value: string\n label: ReactNode\n /** Helper line under the card's title. */\n description?: ReactNode\n /** Leading start slot — icon / avatar / misc. Moves the indicator to the card's end. */\n icon?: ReactNode\n disabled?: boolean\n /** `data-testid` on the rendered card. Defaults to `` `item-${value}` ``. */\n testId?: string\n }\n\n/** A fully resolved option (a bare string is normalized to `{ value, label }`). */\ntype NormalizedItem = {\n value: string\n label: ReactNode\n description?: ReactNode\n icon?: ReactNode\n disabled?: boolean\n testId: string\n}\n\n/** Live state handed to `renderItem` alongside the item. */\nexport type ChoiceCardRenderState = { checked: boolean; disabled: boolean }\n\n/**\n * Render a card's content yourself. Receives the (normalized) item and its live\n * `{ checked, disabled }` state, and replaces the default title + description\n * block; the card keeps its surface, icon slot, indicator, and selection wiring.\n * In an RSC tree the function must live in a `\"use client\"` module.\n */\nexport type RenderChoiceCard = (item: NormalizedItem, state: ChoiceCardRenderState) => ReactNode\n\ntype ChoiceCardClassNames = {\n field?: string\n root?: string\n item?: string\n control?: string\n label?: string\n description?: string\n}\n\nexport type ChoiceCardGroupData = ReadonlyArray<ChoiceCardItem>\n\n/** The value union `data` narrows to — literal option values for a `const`-typed\n * `data` array, or plain `string` for a dynamically-built one. */\nexport type ChoiceCardGroupValue<Data extends ChoiceCardGroupData> = FlatValueOf<Data>\n\ntype ChoiceCardGroupBaseProps<Data extends ChoiceCardGroupData> = WithTestId & {\n /** The options. Bare strings are normalized to `{ value, label }`. */\n data: Data\n /** Stacking direction of the cards. */\n orientation?: \"horizontal\" | \"vertical\"\n /** Replace a card's text block with your own content (with its live state). */\n renderItem?: RenderChoiceCard\n /** Field label above the group. */\n label?: ReactNode\n /** Helper text above the group. */\n description?: ReactNode\n /** Error message below the group; its presence sets the invalid state. */\n error?: ReactNode\n /** Required flag (and, with a label, the red asterisk). */\n required?: boolean\n /** Red invalid state, OR'd with `error != null`. */\n invalid?: boolean\n /** Dims and blocks interaction. */\n disabled?: boolean\n /** Keeps full contrast but blocks edits. */\n readOnly?: boolean\n size?: Size\n /** Indicator fill: `default` (monochrome) or `filled` (palette-colored). */\n variant?: ControlIndicatorVariant\n color?: Color\n /** Field name for native form submission. */\n name?: string\n /** Explicit id for label association. */\n id?: string\n /** Lands on the group root for focus-on-error. */\n ref?: Ref<HTMLDivElement>\n /** Forwarded to the group root; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLDivElement>) => void\n className?: string\n classNames?: ChoiceCardClassNames\n}\n\n/** Single-select (radio): value is a `string | null`. */\ntype SingleSelection<Data extends ChoiceCardGroupData> = {\n multiple?: false\n value?: ChoiceCardGroupValue<Data> | null\n defaultValue?: ChoiceCardGroupValue<Data> | null\n onChange?: (value: ChoiceCardGroupValue<Data> | null) => void\n}\n\n/** Multi-select (checkbox): value is a `string[]`. */\ntype MultiSelection<Data extends ChoiceCardGroupData> = {\n multiple: true\n value?: ChoiceCardGroupValue<Data>[]\n defaultValue?: ChoiceCardGroupValue<Data>[]\n onChange?: (value: ChoiceCardGroupValue<Data>[]) => void\n}\n\nexport type ChoiceCardGroupProps<Data extends ChoiceCardGroupData = ChoiceCardItem[]> =\n ChoiceCardGroupBaseProps<Data> & (SingleSelection<Data> | MultiSelection<Data>)\n\n/**\n * The card surface. Neutral at rest on the kit's translucent surface — the same\n * `bg-white/4` + `border-brand-900/20 dark:border-white/8` recipe as `Card`\n * (Figma's `border-primary`, the card hairline): a fixed opaque\n * gray fill can vanish or over-assert depending on the host background, so the\n * fill carries no ground of its own. The selected treatment follows the\n * `variant`, mirroring `Checkbox` / `RadioGroup`:\n * `default` stays palette-independent (a strong neutral border — the mark itself\n * fills monochrome), while `filled` tints the border + a half-strength soft fill\n * off the active palette, leaving the colored mark to carry the palette. The focus ring is the kit's standard brand ring in both, again like\n * the rest of the selection family (the inner indicator's own ring is suppressed\n * so only the card rings).\n *\n * The red / disabled affordances cover both paths: the multi cards carry their\n * own `data-invalid` / `data-disabled` (set on each `Checkbox.Root`), while the\n * radio cards inherit them from the group root (`group-data-*`), since Ark only\n * flags the `RadioGroup` root, not its items.\n */\nconst choiceCard = cva(\n [\n \"relative flex w-full cursor-pointer rounded-card border text-start select-none transition-[background-color,border-color,box-shadow]\",\n \"bg-white/4\",\n TEXT_COLOR_CLASSES.primary,\n \"border-brand-900/20 dark:border-white/8\",\n \"hover:border-brand-900/30 dark:hover:border-white/25\",\n // Keyboard focus ring on the whole card — the kit's standard brand ring,\n // matching Checkbox / Radio regardless of palette.\n focusStyles({ source: \"data-focus-visible\" }),\n // Invalid wins over the palette: red border (per-card or group-level).\n \"data-invalid:border-red-500 group-data-invalid:border-red-500\",\n // Disabled affordances (per-card item or group-level).\n \"data-disabled:cursor-not-allowed data-disabled:opacity-60\",\n \"group-data-disabled:cursor-not-allowed group-data-disabled:opacity-60\",\n ],\n {\n variants: {\n // Selected treatment, mirroring the indicator's own `variant`.\n variant: {\n // Palette-independent: a strong neutral border (the mark fills dark).\n default: \"data-[state=checked]:border-brand-950 dark:data-[state=checked]:border-white\",\n // Palette-tinted, kept quiet: a translucent `--c-solid` edge + the soft\n // fill at half strength off the root's `data-color`; the filled mark\n // carries the palette. A full `--c-soft` slab with an opaque edge drowned\n // the rest of a form in warm palettes, and a `--c-soft-hover` edge was\n // too faint — the checked card read weaker than the unchecked ones.\n filled: \"data-[state=checked]:border-(--c-solid)/45 data-[state=checked]:bg-(--c-soft)/50\",\n },\n size: {\n xs: \"gap-2 p-2\",\n sm: \"gap-2.5 p-2.5\",\n md: \"gap-3 p-3\",\n lg: \"gap-3.5 p-4\",\n xl: \"gap-4 p-5\",\n },\n // Center a single-line card; top-align once a description makes it taller.\n // In `start`, `ChoiceCardInner` also centres the indicator on the label's\n // first line (see `capLine`), since the trimmed label is only a cap tall.\n align: { center: \"items-center\", start: \"items-start\" },\n },\n defaultVariants: { variant: \"default\", size: \"md\", align: \"center\" },\n },\n)\n\n/** The card title's font size per card size — shared with `capLine`, whose `1cap` must resolve against it. */\nconst labelTextSize = {\n xs: \"text-xs\",\n sm: \"text-sm\",\n md: \"text-sm\",\n lg: \"text-md\",\n xl: \"text-lg\",\n} as const satisfies Record<Size, string>\n\nconst cardLabel = cva(\"font-medium text-trim\", {\n variants: { size: labelTextSize },\n defaultVariants: { size: \"md\" },\n})\n\n/**\n * A box exactly one label cap-height tall that centres the indicator in it. The\n * title is `text-trim`'d to its cap height, so a top-aligned indicator (taller\n * than a cap) would sit low; centring it in a `1cap` line puts its middle on\n * the middle of the title's first line, whatever the title wraps to. The box\n * overflows evenly into the card's padding. Gated on `text-box-trim` support:\n * where the title keeps its full leading (Firefox), the box keeps its natural\n * height and the indicator stays top-aligned, as before.\n */\nconst capLine = (size: Size) =>\n cn(labelTextSize[size], \"flex shrink-0 items-center supports-[text-box-trim:trim-both]:h-[1cap]\")\n\nconst cardDescription = cva(TYPOGRAPHY_SHADE_CLASSES.muted, {\n variants: {\n size: { xs: \"text-xs\", sm: \"text-xs\", md: \"text-xs\", lg: \"text-sm\", xl: \"text-sm\" },\n },\n defaultVariants: { size: \"md\" },\n})\n\nconst cardIcon = cva(\n [\"inline-flex shrink-0 items-center justify-center\", TEXT_COLOR_CLASSES.secondary],\n {\n variants: {\n size: {\n xs: \"[&_svg]:size-4\",\n sm: \"[&_svg]:size-4.5\",\n md: \"[&_svg]:size-5\",\n lg: \"[&_svg]:size-6\",\n xl: \"[&_svg]:size-7\",\n },\n },\n defaultVariants: { size: \"md\" },\n },\n)\n\n/** Suppress the shared indicator's own focus ring — the card rings instead. */\nconst noIndicatorRing = \"data-focus-visible:ring-0\"\n\nconst normalize = (item: ChoiceCardItem): NormalizedItem =>\n typeof item === \"string\"\n ? { value: item, label: item, testId: `item-${item}` }\n : { ...item, testId: item.testId ?? `item-${item.value}` }\n\n/**\n * Arrow keys move focus between checkbox cards — matching `RadioGroup`'s\n * native roving focus, which standalone checkboxes have no equivalent for.\n */\nconst onCardArrowKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const dir = { ArrowDown: 1, ArrowRight: 1, ArrowUp: -1, ArrowLeft: -1 }[event.key]\n if (!dir) return\n const cards = Array.from(\n event.currentTarget.querySelectorAll<HTMLInputElement>(\"input[type=checkbox]:not(:disabled)\"),\n )\n const at = cards.indexOf(document.activeElement as HTMLInputElement)\n if (at === -1) return\n event.preventDefault()\n cards[(at + dir + cards.length) % cards.length]?.focus()\n}\n\n/**\n * The two group roots, split out so they read the `Field` context from *inside* `FieldShell`.\n * Neither Ark root takes a Field's label: `RadioGroup` only reads a `Fieldset` (and otherwise\n * points `aria-labelledby` at its never-rendered `RadioGroup.Label`), and `CheckboxGroup` is a bare\n * `role=\"group\"` div. `fieldA11yProps` names the group by the field's `label` and describes it by\n * its `description`, or by its `error` once invalid.\n */\nconst RadioCardsRoot = (rootProps: ComponentProps<typeof RadioGroup.Root>) => (\n <RadioGroup.Root {...fieldA11yProps(useFieldContext())} {...rootProps} />\n)\n\nconst CheckboxCardsRoot = (rootProps: ComponentProps<typeof CheckboxGroup>) => (\n <CheckboxGroup {...fieldA11yProps(useFieldContext())} {...rootProps} />\n)\n\n/**\n * Lay out one card: with a leading `icon`, the order is icon → text → indicator\n * (pushed to the end by the text's `flex-1`); without one, indicator → text.\n * A top-aligned card (one with a description) wraps the indicator in a\n * `capLine` so it centres on the title's first line.\n */\nconst ChoiceCardInner = ({\n item,\n size,\n indicator: control,\n content,\n}: {\n item: NormalizedItem\n size: Size\n indicator: ReactNode\n content: ReactNode\n}) => {\n const text = <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">{content}</span>\n const indicator =\n item.description != null ? <span className={capLine(size)}>{control}</span> : control\n return item.icon != null ? (\n <>\n <span className={cardIcon({ size })} aria-hidden>\n {item.icon}\n </span>\n {text}\n {indicator}\n </>\n ) : (\n <>\n {indicator}\n {text}\n </>\n )\n}\n\nconst defaultContent = (item: NormalizedItem, size: Size, classNames?: ChoiceCardClassNames) => (\n <>\n <span className={cn(cardLabel({ size }), classNames?.label)}>{item.label}</span>\n {item.description != null && (\n <span className={cn(cardDescription({ size }), classNames?.description)}>\n {item.description}\n </span>\n )}\n </>\n)\n\nexport const ChoiceCardGroup = <const Data extends ChoiceCardGroupData = ChoiceCardItem[]>(\n groupProps: ChoiceCardGroupProps<Data>,\n) => {\n // Kept whole, not destructured: `multiple` is the union's discriminant, and narrowing on it\n // types `value` / `defaultValue` / `onChange` per branch without casts.\n const selection: SingleSelection<Data> | MultiSelection<Data> = groupProps\n const {\n data,\n orientation = \"vertical\",\n renderItem,\n label,\n description,\n error,\n required,\n invalid,\n disabled,\n readOnly,\n size = \"md\",\n variant = \"default\",\n color,\n name,\n id,\n ref,\n onBlur,\n className,\n classNames,\n testId,\n } = groupProps\n // Red state is driven independently of the `Field` error slot so a form\n // library can flip it from `fieldState.invalid` (see FormControlProps).\n const isInvalid = useInheritedInvalid(invalid || error != null)\n const normalized = data.map(normalize)\n // Ark reports plain strings; every one it can report is a card's value, so this guard\n // narrows Ark's `string` back to `data`'s value union instead of asserting it.\n const isValue = (candidate: string): candidate is ChoiceCardGroupValue<Data> =>\n normalized.some((item) => item.value === candidate)\n // Base for per-card ids. Each multi card is its own Ark Checkbox machine; left\n // to inherit the shared `Field` context they'd all take the *same* control id,\n // so every card's <label> would point at the first input (clicking any card\n // toggled only the first). A unique `ids.hiddenInput` per card fixes that.\n const reactId = useId()\n\n // `group` lets the radio cards read the root's `data-invalid` / `data-disabled`.\n const rootClass = cn(\n \"group flex w-full gap-2\",\n orientation === \"horizontal\" ? \"flex-row flex-wrap\" : \"flex-col\",\n className,\n classNames?.root,\n )\n\n // `cn`, not cva's `className`: cva only concatenates, so a consumer's\n // `data-[state=checked]:border-*` would lose to the variant's on stylesheet order.\n const itemClass = (item: NormalizedItem) =>\n cn(\n choiceCard({ variant, size, align: item.description != null ? \"start\" : \"center\" }),\n classNames?.item,\n )\n\n const group = selection.multiple ? (\n <CheckboxCardsRoot\n value={selection.value}\n defaultValue={selection.defaultValue}\n onValueChange={(next) => selection.onChange?.(next.filter(isValue))}\n disabled={disabled}\n readOnly={readOnly}\n invalid={isInvalid}\n name={name}\n id={id}\n ref={ref}\n onBlur={onBlur}\n onKeyDown={onCardArrowKeyDown}\n data-color={color}\n {...props({ \"data-testid\": testId })}\n className={rootClass}\n >\n {normalized.map((item, index) => {\n const indicator = (\n <Checkbox.Control\n className={cn(\n controlIndicator({ size, variant }),\n noIndicatorRing,\n classNames?.control,\n )}\n >\n <Checkbox.Indicator>\n <CheckIcon />\n </Checkbox.Indicator>\n </Checkbox.Control>\n )\n const content = renderItem ? (\n <Checkbox.Context>\n {(api) =>\n renderItem(item, { checked: api.checked === true, disabled: Boolean(api.disabled) })\n }\n </Checkbox.Context>\n ) : (\n defaultContent(item, size, classNames)\n )\n return (\n <Checkbox.Root\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n invalid={isInvalid}\n ids={{ hiddenInput: `${reactId}-${index}` }}\n data-testid={item.testId}\n className={itemClass(item)}\n >\n <ChoiceCardInner item={item} size={size} indicator={indicator} content={content} />\n <Checkbox.HiddenInput />\n </Checkbox.Root>\n )\n })}\n </CheckboxCardsRoot>\n ) : (\n <RadioCardsRoot\n value={selection.value}\n defaultValue={selection.defaultValue}\n onValueChange={({ value }) =>\n selection.onChange?.(value != null && isValue(value) ? value : null)\n }\n invalid={isInvalid}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n name={name}\n id={id}\n ref={ref}\n onBlur={onBlur}\n orientation={orientation}\n data-color={color}\n {...props({ \"data-testid\": testId })}\n className={rootClass}\n >\n {normalized.map((item) => {\n const indicator = (\n <RadioGroup.ItemControl\n className={cn(\n controlIndicator({ size, variant }),\n \"rounded-full\",\n noIndicatorRing,\n classNames?.control,\n )}\n >\n {/* The inner dot reads its own checked state from the item context —\n a bare `<span>` can't see the control's `data-[state]`. */}\n <RadioGroup.ItemContext>\n {(s) =>\n s.checked ? (\n <span className=\"size-[50%] rounded-full bg-brand-50 dark:bg-brand-950\" />\n ) : null\n }\n </RadioGroup.ItemContext>\n </RadioGroup.ItemControl>\n )\n const content = renderItem ? (\n <RadioGroup.ItemContext>\n {(s) => renderItem(item, { checked: s.checked, disabled: Boolean(s.disabled) })}\n </RadioGroup.ItemContext>\n ) : (\n defaultContent(item, size, classNames)\n )\n return (\n <RadioGroup.Item\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n data-testid={item.testId}\n className={itemClass(item)}\n >\n <ChoiceCardInner item={item} size={size} indicator={indicator} content={content} />\n <RadioGroup.ItemHiddenInput />\n </RadioGroup.Item>\n )\n })}\n </RadioCardsRoot>\n )\n\n return (\n <FieldShell\n label={label}\n description={description}\n error={error}\n required={required}\n disabled={disabled}\n size={size}\n className={classNames?.field}\n // A group of cards: nothing carries the label's `for` id; the root's `aria-labelledby` names it.\n composite\n >\n {group}\n </FieldShell>\n )\n}\n"]}
|
|
@@ -4,6 +4,7 @@ import { type ComponentPropsWithoutRef, type CSSProperties, type ReactNode, type
|
|
|
4
4
|
import type { ForbidAsChild } from "../../lib/as-child";
|
|
5
5
|
import type { Color } from "../../lib/colors";
|
|
6
6
|
import type { GradientDir, GradientProps } from "../../lib/gradient";
|
|
7
|
+
import { type MeterProps } from "../../lib/meter";
|
|
7
8
|
import type { Size } from "../../lib/sizes";
|
|
8
9
|
import type { WithTestId } from "../../lib/test-id";
|
|
9
10
|
declare const circularRange: (props?: ({
|
|
@@ -11,6 +12,7 @@ declare const circularRange: (props?: ({
|
|
|
11
12
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
12
13
|
export type CircularProgressVariant = NonNullable<VariantProps<typeof circularRange>["variant"]>;
|
|
13
14
|
export type CircularProgressSize = Size;
|
|
15
|
+
export type { MeterZone } from "../../lib/meter";
|
|
14
16
|
export type { GradientDir, GradientProps };
|
|
15
17
|
type CircularProgressClassNames = {
|
|
16
18
|
root?: string;
|
|
@@ -20,17 +22,25 @@ type CircularProgressClassNames = {
|
|
|
20
22
|
label?: string;
|
|
21
23
|
};
|
|
22
24
|
type ArkRootProps = ComponentPropsWithoutRef<typeof Ark.Root>;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
/**
|
|
26
|
+
* `M` is `meter`'s literal type, inferred at the call site (see `MeterProps`).
|
|
27
|
+
* Left out, it is `boolean`: every prop available, `value` plain `number | null`,
|
|
28
|
+
* which is what a generic wrapper or an `Omit<CircularProgressProps, …>` should see.
|
|
29
|
+
*/
|
|
30
|
+
export type CircularProgressProps<M extends boolean = boolean> = Omit<ArkRootProps, "value" | "defaultValue" | "onValueChange" | "onChange" | "ref" | "className" | "children" | "asChild" | "locale" | "formatOptions" | "translations"> & ForbidAsChild & VariantProps<typeof circularRange> & WithTestId & MeterProps<M> & {
|
|
31
|
+
/** Locale the value text is formatted in: a BCP-47 tag, or `"auto"` for the
|
|
32
|
+
* visitor's. Defaults to the `IntlProvider`'s, then `en-US`. */
|
|
33
|
+
locale?: "auto" | (string & {});
|
|
34
|
+
/** `Intl.NumberFormat` options for the value text. Defaults to a percentage;
|
|
35
|
+
* `{ style: "unit", unit: "gigabyte" }` reads the raw value instead. */
|
|
36
|
+
formatOptions?: ArkRootProps["formatOptions"];
|
|
37
|
+
/** Overrides the value text. `value` receives `{ value, min, max, percent,
|
|
38
|
+
* formatter }` and returns what a screen reader says: "Level 7, 40% to 8". */
|
|
39
|
+
translations?: ArkRootProps["translations"];
|
|
30
40
|
size?: CircularProgressSize | number;
|
|
31
41
|
/** Stroke width in px, a tee-shirt size, or omitted for a per-size default. */
|
|
32
42
|
thickness?: CircularProgressSize | number;
|
|
33
|
-
/** Accent palette. Ignored when `variant="gradient"
|
|
43
|
+
/** Accent palette. Ignored when `variant="gradient"`, and by a meter's zones. */
|
|
34
44
|
color?: Color;
|
|
35
45
|
/**
|
|
36
46
|
* Gradient stops; only applied when `variant="gradient"`. `from` / `to` /
|
|
@@ -40,7 +50,7 @@ export type CircularProgressProps = Omit<ArkRootProps, "value" | "defaultValue"
|
|
|
40
50
|
gradient?: GradientProps;
|
|
41
51
|
/** Centered content, e.g. a percentage label. */
|
|
42
52
|
children?: ReactNode;
|
|
43
|
-
/** Lands on the ring `<svg>` — the `role="progressbar"` element. */
|
|
53
|
+
/** Lands on the ring `<svg>` — the `role="progressbar"` (or `"meter"`) element. */
|
|
44
54
|
ref?: Ref<SVGSVGElement>;
|
|
45
55
|
/** Names the ring. Lands on the `<svg>`, the `role="progressbar"` element, like the other
|
|
46
56
|
* `aria-*` naming props below; without one, Ark names it by its value ("40"). */
|
|
@@ -48,11 +58,12 @@ export type CircularProgressProps = Omit<ArkRootProps, "value" | "defaultValue"
|
|
|
48
58
|
/** Names the ring after a visible caption, by id. Wins over `aria-label`. */
|
|
49
59
|
"aria-labelledby"?: string;
|
|
50
60
|
"aria-describedby"?: string;
|
|
51
|
-
/** Read instead of the number: "Uploading", "3 of 8 files".
|
|
61
|
+
/** Read instead of the number: "Uploading", "3 of 8 files". A meter
|
|
62
|
+
* writes its formatted value here when unset. */
|
|
52
63
|
"aria-valuetext"?: string;
|
|
53
64
|
className?: string;
|
|
54
65
|
classNames?: CircularProgressClassNames;
|
|
55
66
|
style?: CSSProperties;
|
|
56
67
|
};
|
|
57
|
-
export declare const CircularProgress: ({ value, defaultValue, onChange, variant, size, thickness, color, gradient, min, max, children, ref, className, classNames, style, testId, asChild: _asChild, "aria-label": label, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-valuetext": valueText, ...rest }: CircularProgressProps) => import("react").JSX.Element;
|
|
68
|
+
export declare const CircularProgress: <M extends boolean = false>({ value, defaultValue, onChange, meter, low, high, optimum, locale, variant, size, thickness, color, gradient, min, max, children, ref, className, classNames, style, testId, asChild: _asChild, "aria-label": label, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-valuetext": valueText, ...rest }: CircularProgressProps<M>) => import("react").JSX.Element;
|
|
58
69
|
//# sourceMappingURL=circular-progress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circular-progress.d.ts","sourceRoot":"","sources":["../../../src/components/circular-progress/circular-progress.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,IAAI,GAAG,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,GAAG,EAET,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAo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C7E,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B;sDACkD;IAClD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,0BAA0B,CAAA;IACvC,KAAK,CAAC,EAAE,aAAa,CAAA;CACtB,CAAA;AAGH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,OAAO,GAAG,KAAK,gUA6BvD,qBAAqB,CAAC,CAAC,CAAC,gCAgG1B,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { CircularProgress, type CircularProgressProps, type CircularProgressSize, type CircularProgressVariant, type GradientDir, type GradientProps, } from "./circular-progress";
|
|
1
|
+
export { CircularProgress, type CircularProgressProps, type CircularProgressSize, type CircularProgressVariant, type GradientDir, type GradientProps, type MeterZone, } from "./circular-progress";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/circular-progress/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/circular-progress/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,GACf,MAAM,qBAAqB,CAAA"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { meterZone, METER_ZONE_COLORS, arkValue } from '../../chunk-X6RB74JN.js';
|
|
3
|
+
import { useLocale } from '../../chunk-OBSZ4NE2.js';
|
|
4
|
+
import '../../chunk-PQZSTI3R.js';
|
|
2
5
|
import { props } from '../../chunk-WYCMIIRR.js';
|
|
3
6
|
import { cn } from '../../chunk-4ASNIDV7.js';
|
|
4
7
|
import { Progress } from '@ark-ui/react/progress';
|
|
@@ -40,6 +43,11 @@ var CircularProgress = ({
|
|
|
40
43
|
value,
|
|
41
44
|
defaultValue,
|
|
42
45
|
onChange,
|
|
46
|
+
meter,
|
|
47
|
+
low,
|
|
48
|
+
high,
|
|
49
|
+
optimum,
|
|
50
|
+
locale,
|
|
43
51
|
variant,
|
|
44
52
|
size,
|
|
45
53
|
thickness,
|
|
@@ -63,14 +71,16 @@ var CircularProgress = ({
|
|
|
63
71
|
}) => {
|
|
64
72
|
const isGradient = variant === "gradient";
|
|
65
73
|
const gradientId = useId();
|
|
74
|
+
const resolvedLocale = useLocale(locale);
|
|
66
75
|
return /* @__PURE__ */ jsxs(
|
|
67
76
|
Progress.Root,
|
|
68
77
|
{
|
|
69
|
-
value,
|
|
70
|
-
defaultValue,
|
|
78
|
+
value: arkValue("CircularProgress", meter, value, min),
|
|
79
|
+
defaultValue: arkValue("CircularProgress", meter, defaultValue, min),
|
|
71
80
|
onValueChange: onChange ? ({ value: v }) => onChange(v) : void 0,
|
|
72
81
|
min,
|
|
73
82
|
max,
|
|
83
|
+
locale: resolvedLocale,
|
|
74
84
|
"data-color": !isGradient ? color : void 0,
|
|
75
85
|
className: cn("group/cprogress relative inline-flex", className, classNames?.root),
|
|
76
86
|
style: {
|
|
@@ -80,54 +90,63 @@ var CircularProgress = ({
|
|
|
80
90
|
},
|
|
81
91
|
...rest,
|
|
82
92
|
children: [
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"aria-label": label,
|
|
98
|
-
"aria-labelledby": labelledBy,
|
|
99
|
-
"aria-describedby": describedBy,
|
|
100
|
-
"aria-valuetext": valueText
|
|
101
|
-
}),
|
|
102
|
-
children: [
|
|
103
|
-
isGradient && /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "100%", y2: "100%", children: [
|
|
104
|
-
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: gradient?.from ?? "var(--color-purple-300)" }),
|
|
105
|
-
gradient?.via && /* @__PURE__ */ jsx("stop", { offset: "50%", stopColor: gradient.via }),
|
|
106
|
-
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: gradient?.to ?? "var(--color-pink-400)" })
|
|
107
|
-
] }) }),
|
|
108
|
-
/* @__PURE__ */ jsx(
|
|
109
|
-
Progress.CircleTrack,
|
|
110
|
-
{
|
|
111
|
-
className: cn("fill-none stroke-black/3 dark:stroke-white/4", classNames?.track)
|
|
112
|
-
}
|
|
93
|
+
/* @__PURE__ */ jsx(Progress.Context, { children: (api) => {
|
|
94
|
+
const zone = meter ? meterZone(api.value, { min, max, low, high, optimum }) : void 0;
|
|
95
|
+
return /* @__PURE__ */ jsxs(
|
|
96
|
+
Progress.Circle,
|
|
97
|
+
{
|
|
98
|
+
ref,
|
|
99
|
+
...meter ? { role: "meter" } : null,
|
|
100
|
+
className: cn(
|
|
101
|
+
// Ark's CircleRange already rotates the arc to start at 12 o'clock.
|
|
102
|
+
"block",
|
|
103
|
+
// Indeterminate: Ark drops the dash, so the range below pins a fixed
|
|
104
|
+
// arc; spin the whole ring. Gated under reduced motion in theme.css.
|
|
105
|
+
"group-data-[state=indeterminate]/cprogress:animate-progress-spin",
|
|
106
|
+
classNames?.circle
|
|
113
107
|
),
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
108
|
+
...props({
|
|
109
|
+
"data-testid": testId,
|
|
110
|
+
// The zone's palette lands on the ring, which the arc inherits from.
|
|
111
|
+
"data-color": zone && !isGradient ? METER_ZONE_COLORS[zone] : void 0,
|
|
112
|
+
"data-zone": zone,
|
|
113
|
+
"aria-label": label,
|
|
114
|
+
"aria-labelledby": labelledBy,
|
|
115
|
+
"aria-describedby": describedBy,
|
|
116
|
+
// A meter always says its value: Ark's locale-aware `valueAsString`, which
|
|
117
|
+
// `formatOptions` / `translations.value` shape, unless the caller wrote one.
|
|
118
|
+
"aria-valuetext": valueText ?? (meter ? api.valueAsString : void 0)
|
|
119
|
+
}),
|
|
120
|
+
children: [
|
|
121
|
+
isGradient && /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "100%", y2: "100%", children: [
|
|
122
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: gradient?.from ?? "var(--color-purple-300)" }),
|
|
123
|
+
gradient?.via && /* @__PURE__ */ jsx("stop", { offset: "50%", stopColor: gradient.via }),
|
|
124
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: gradient?.to ?? "var(--color-pink-400)" })
|
|
125
|
+
] }) }),
|
|
126
|
+
/* @__PURE__ */ jsx(
|
|
127
|
+
Progress.CircleTrack,
|
|
128
|
+
{
|
|
129
|
+
className: cn("fill-none stroke-black/3 dark:stroke-white/4", classNames?.track)
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
/* @__PURE__ */ jsx(
|
|
133
|
+
Progress.CircleRange,
|
|
134
|
+
{
|
|
135
|
+
strokeLinecap: "round",
|
|
136
|
+
className: cn(
|
|
137
|
+
circularRange({ variant }),
|
|
138
|
+
// Indeterminate: pin a fixed 25% arc (Ark omits the dash here).
|
|
139
|
+
"group-data-[state=indeterminate]/cprogress:[stroke-dasharray:calc(var(--circumference)*0.25)_var(--circumference)]",
|
|
140
|
+
"group-data-[state=indeterminate]/cprogress:[stroke-dashoffset:0]",
|
|
141
|
+
classNames?.range
|
|
142
|
+
),
|
|
143
|
+
style: isGradient ? { stroke: `url(#${gradientId})` } : void 0
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
} }),
|
|
131
150
|
children != null && /* @__PURE__ */ jsx(
|
|
132
151
|
"span",
|
|
133
152
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/circular-progress/circular-progress.tsx"],"names":["Ark"],"mappings":";;;;;;;AAyCA,IAAM,mBAAA,GAAyE;AAAA,EAC7E,EAAA,EAAI,EAAE,IAAA,EAAM,EAAA,EAAI,WAAW,CAAA,EAAE;AAAA,EAC7B,EAAA,EAAI,EAAE,IAAA,EAAM,EAAA,EAAI,WAAW,CAAA,EAAE;AAAA,EAC7B,EAAA,EAAI,EAAE,IAAA,EAAM,EAAA,EAAI,WAAW,CAAA,EAAE;AAAA,EAC7B,EAAA,EAAI,EAAE,IAAA,EAAM,EAAA,EAAI,WAAW,CAAA,EAAE;AAAA,EAC7B,EAAA,EAAI,EAAE,IAAA,EAAM,EAAA,EAAI,WAAW,CAAA;AAC7B,CAAA;AASA,IAAM,gBAAA,GAAmB,CACvB,KAAA,EACA,GAAA,EACA,YAAA,KACG;AACH,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,IAAI,SAAS,IAAA,EAAM,OAAO,mBAAA,CAAoB,KAAK,EAAE,GAAG,CAAA;AACxD,EAAA,MAAM,QAAA,GAAW,OAAO,YAAA,KAAiB,QAAA,GAAW,OAAQ,YAAA,IAAgB,IAAA;AAC5E,EAAA,OAAO,mBAAA,CAAoB,QAAQ,CAAA,CAAE,GAAG,CAAA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AC7D,MAAA,EAAA,EAAK,MAAA,EAAO,QAAO,SAAA,EAAW,QAAA,EAAU,MAAM,uBAAA,EAAyB;AAAA,eAAA,EAC1E,CAAA,EACF,CAAA;AAAA,8BAEF,GAAA;AAAA,gBAACA,QAAA,CAAI,WAAA;AAAA,gBAAJ;AAAA,kBACC,SAAA,EAAW,EAAA,CAAG,8CAAA,EAAgD,UAAA,EAAY,KAAK;AAAA;AAAA,eACjF;AAAA,8BACA,GAAA;AAAA,gBAACA,QAAA,CAAI,WAAA;AAAA,gBAAJ;AAAA,kBACC,aAAA,EAAc,OAAA;AAAA,kBACd,SAAA,EAAW,EAAA;AAAA,oBACT,aAAA,CAAc,EAAE,OAAA,EAAS,CAAA;AAAA;AAAA,oBAEzB,oHAAA;AAAA,oBACA,kEAAA;AAAA,oBACA,UAAA,EAAY;AAAA,mBACd;AAAA,kBACA,OAAO,UAAA,GAAa,EAAE,QAAQ,CAAA,KAAA,EAAQ,UAAU,KAAI,GAAI;AAAA;AAAA;AAC1D;AAAA;AAAA,SACF;AAAA,QAEC,YAAY,IAAA,oBACX,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAW,EAAA,CAAG,mDAAA,EAAqD,UAAA,EAAY,KAAK,CAAA;AAAA,YAEnF;AAAA;AAAA;AACH;AAAA;AAAA,GAEJ;AAEJ","file":"index.js","sourcesContent":["\"use client\"\n\nimport { Progress as Ark } from \"@ark-ui/react/progress\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport {\n type ComponentPropsWithoutRef,\n type CSSProperties,\n type ReactNode,\n type Ref,\n useId,\n} from \"react\"\nimport type { ForbidAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport type { GradientDir, GradientProps } from \"../../lib/gradient\"\nimport { props } from \"../../lib/props\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\n\n/**\n * CircularProgress — ring progress indicator on top of Ark UI's Progress state\n * machine (the circular counterpart of `Progress`). Ark owns the value/percent\n * math, the indeterminate flag, the `role=\"progressbar\"` + ARIA wiring, and the\n * SVG ring geometry (`Circle` → `CircleTrack` + `CircleRange`, sized by the\n * `--size` / `--thickness` vars we set on the root).\n *\n * The arc is a stroked SVG circle (`stroke-dasharray` driven by Ark), so it\n * clips by construction — no masking. The gradient is the circular equivalent\n * of the linear bar's track-spanning fill: an SVG gradient is fixed to the\n * ring's extent and the arc reveals it, so the complete `from`→`to` only shows\n * once the ring closes at 100%. `filled` strokes a single palette color\n * (`--c-solid`) instead.\n *\n * Name the ring with `aria-label` or `aria-labelledby` (and `aria-valuetext`\n * for a non-numeric reading): they land on the `role=\"progressbar\"` `<svg>`,\n * not the wrapping root, so assistive tech reads them with the value.\n *\n * Palette comes through the kit's `data-color` + slot-var system, so a new\n * color in `colors.css` works here for free.\n */\n\nconst CIRCULAR_DIMENSIONS: Record<Size, { size: number; thickness: number }> = {\n xs: { size: 24, thickness: 3 },\n sm: { size: 32, thickness: 3 },\n md: { size: 44, thickness: 4 },\n lg: { size: 60, thickness: 5 },\n xl: { size: 80, thickness: 6 },\n}\n\n/**\n * Resolves `size` / `thickness` to a px number: a raw number passes through\n * verbatim, a tee-shirt size looks up its own `key` from `CIRCULAR_DIMENSIONS`,\n * and `undefined` falls back through `fallbackSize` (itself defaulting to\n * `\"md\"` when that's a raw number, since a numeric `size` has no tee-shirt\n * dimensions of its own to fall back to for `thickness`).\n */\nconst resolveDimension = (\n value: CircularProgressSize | number | undefined,\n key: \"size\" | \"thickness\",\n fallbackSize: CircularProgressSize | number | undefined,\n) => {\n if (typeof value === \"number\") return value\n if (value != null) return CIRCULAR_DIMENSIONS[value][key]\n const fallback = typeof fallbackSize === \"number\" ? \"md\" : (fallbackSize ?? \"md\")\n return CIRCULAR_DIMENSIONS[fallback][key]\n}\n\nconst circularRange = cva(\n // Transition both the dash length and offset so toggling indeterminate morphs\n // the arc (value arc ↔ fixed 25% spinner arc) instead of snapping. The spin\n // itself lives on the <svg> (base rotation 0), so it starts seamlessly.\n [\"fill-none\", \"[transition:stroke-dasharray_300ms_ease,stroke-dashoffset_300ms_ease]\"],\n {\n variants: {\n // `gradient` strokes the SVG gradient (set inline); the palette variants\n // stroke a slot var.\n variant: {\n filled: \"stroke-(--c-solid)\",\n gradient: \"\",\n },\n },\n defaultVariants: { variant: \"filled\" },\n },\n)\n\nexport type CircularProgressVariant = NonNullable<VariantProps<typeof circularRange>[\"variant\"]>\nexport type CircularProgressSize = Size\n\nexport type { GradientDir, GradientProps }\n\ntype CircularProgressClassNames = {\n root?: string\n circle?: string\n track?: string\n range?: string\n label?: string\n}\n\ntype ArkRootProps = ComponentPropsWithoutRef<typeof Ark.Root>\n\nexport type CircularProgressProps = Omit<\n ArkRootProps,\n \"value\" | \"defaultValue\" | \"onValueChange\" | \"ref\" | \"className\" | \"children\" | \"asChild\"\n> &\n ForbidAsChild &\n VariantProps<typeof circularRange> &\n WithTestId & {\n /** Controlled value (0..max). Pass `null` for the indeterminate state. */\n value?: number | null\n /** Uncontrolled initial value. Pass `null` to start indeterminate. */\n defaultValue?: number | null\n /** Fires on every value change. */\n onChange?: (value: number | null) => void\n size?: CircularProgressSize | number\n /** Stroke width in px, a tee-shirt size, or omitted for a per-size default. */\n thickness?: CircularProgressSize | number\n /** Accent palette. Ignored when `variant=\"gradient\"`. */\n color?: Color\n /**\n * Gradient stops; only applied when `variant=\"gradient\"`. `from` / `to` /\n * `via` are CSS colors (default purple-300 → pink-400). `dir` is ignored —\n * the SVG sweep direction is fixed (top-left → bottom-right).\n */\n gradient?: GradientProps\n /** Centered content, e.g. a percentage label. */\n children?: ReactNode\n /** Lands on the ring `<svg>` — the `role=\"progressbar\"` element. */\n ref?: Ref<SVGSVGElement>\n /** Names the ring. Lands on the `<svg>`, the `role=\"progressbar\"` element, like the other\n * `aria-*` naming props below; without one, Ark names it by its value (\"40\"). */\n \"aria-label\"?: string\n /** Names the ring after a visible caption, by id. Wins over `aria-label`. */\n \"aria-labelledby\"?: string\n \"aria-describedby\"?: string\n /** Read instead of the number: \"Uploading\", \"3 of 8 files\". */\n \"aria-valuetext\"?: string\n className?: string\n classNames?: CircularProgressClassNames\n style?: CSSProperties\n }\n\nexport const CircularProgress = ({\n value,\n defaultValue,\n onChange,\n variant,\n size,\n thickness,\n color,\n gradient,\n min = 0,\n max = 100,\n children,\n ref,\n className,\n classNames,\n style,\n testId,\n asChild: _asChild,\n // The naming attributes describe the progressbar, which is the ring, not the root.\n \"aria-label\": label,\n \"aria-labelledby\": labelledBy,\n \"aria-describedby\": describedBy,\n \"aria-valuetext\": valueText,\n ...rest\n}: CircularProgressProps) => {\n const isGradient = variant === \"gradient\"\n const gradientId = useId()\n\n return (\n <Ark.Root\n // `undefined` → uncontrolled (Ark's own default). `null` → indeterminate.\n // The two must NOT be coalesced, so each is forwarded verbatim.\n value={value}\n defaultValue={defaultValue}\n onValueChange={onChange ? ({ value: v }) => onChange(v) : undefined}\n min={min}\n max={max}\n data-color={!isGradient ? color : undefined}\n className={cn(\"group/cprogress relative inline-flex\", className, classNames?.root)}\n style={\n {\n \"--size\": `${resolveDimension(size, \"size\", size)}px`,\n \"--thickness\": `${resolveDimension(thickness, \"thickness\", size)}px`,\n ...style,\n } as CSSProperties\n }\n {...rest}\n >\n <Ark.Circle\n ref={ref}\n className={cn(\n // Ark's CircleRange already rotates the arc to start at 12 o'clock.\n \"block\",\n // Indeterminate: Ark drops the dash, so the range below pins a fixed\n // arc; spin the whole ring. Gated under reduced motion in theme.css.\n \"group-data-[state=indeterminate]/cprogress:animate-progress-spin\",\n classNames?.circle,\n )}\n {...props({\n \"data-testid\": testId,\n \"aria-label\": label,\n \"aria-labelledby\": labelledBy,\n \"aria-describedby\": describedBy,\n \"aria-valuetext\": valueText,\n })}\n >\n {isGradient && (\n <defs>\n <linearGradient id={gradientId} x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"100%\">\n <stop offset=\"0%\" stopColor={gradient?.from ?? \"var(--color-purple-300)\"} />\n {gradient?.via && <stop offset=\"50%\" stopColor={gradient.via} />}\n <stop offset=\"100%\" stopColor={gradient?.to ?? \"var(--color-pink-400)\"} />\n </linearGradient>\n </defs>\n )}\n <Ark.CircleTrack\n className={cn(\"fill-none stroke-black/3 dark:stroke-white/4\", classNames?.track)}\n />\n <Ark.CircleRange\n strokeLinecap=\"round\"\n className={cn(\n circularRange({ variant }),\n // Indeterminate: pin a fixed 25% arc (Ark omits the dash here).\n \"group-data-[state=indeterminate]/cprogress:[stroke-dasharray:calc(var(--circumference)*0.25)_var(--circumference)]\",\n \"group-data-[state=indeterminate]/cprogress:[stroke-dashoffset:0]\",\n classNames?.range,\n )}\n style={isGradient ? { stroke: `url(#${gradientId})` } : undefined}\n />\n </Ark.Circle>\n\n {children != null && (\n <span\n className={cn(\"absolute inset-0 flex items-center justify-center\", classNames?.label)}\n >\n {children}\n </span>\n )}\n </Ark.Root>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/circular-progress/circular-progress.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;AAkDA,IAAM,mBAAA,GAAyE;AAAA,EAC7E,EAAA,EAAI,EAAE,IAAA,EAAM,EAAA,EAAI,WAAW,CAAA,EAAE;AAAA,EAC7B,EAAA,EAAI,EAAE,IAAA,EAAM,EAAA,EAAI,WAAW,CAAA,EAAE;AAAA,EAC7B,EAAA,EAAI,EAAE,IAAA,EAAM,EAAA,EAAI,WAAW,CAAA,EAAE;AAAA,EAC7B,EAAA,EAAI,EAAE,IAAA,EAAM,EAAA,EAAI,WAAW,CAAA,EAAE;AAAA,EAC7B,EAAA,EAAI,EAAE,IAAA,EAAM,EAAA,EAAI,WAAW,CAAA;AAC7B,CAAA;AASA,IAAM,gBAAA,GAAmB,CACvB,KAAA,EACA,GAAA,EACA,YAAA,KACG;AACH,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,IAAI,S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AA,oBACC,SAAA,EAAW,EAAA,CAAG,8CAAA,EAAgD,UAAA,EAAY,KAAK;AAAA;AAAA,iBACjF;AAAA,gCACA,GAAA;AAAA,kBAACA,QAAA,CAAI,WAAA;AAAA,kBAAJ;AAAA,oBACC,aAAA,EAAc,OAAA;AAAA,oBACd,SAAA,EAAW,EAAA;AAAA,sBACT,aAAA,CAAc,EAAE,OAAA,EAAS,CAAA;AAAA;AAAA,sBAEzB,oHAAA;AAAA,sBACA,kEAAA;AAAA,sBACA,UAAA,EAAY;AAAA,qBACd;AAAA,oBACA,OAAO,UAAA,GAAa,EAAE,QAAQ,CAAA,KAAA,EAAQ,UAAU,KAAI,GAAI;AAAA;AAAA;AAC1D;AAAA;AAAA,WACF;AAAA,QAEJ,CAAA,EACF,CAAA;AAAA,QAEC,YAAY,IAAA,oBACX,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAW,EAAA,CAAG,mDAAA,EAAqD,UAAA,EAAY,KAAK,CAAA;AAAA,YAEnF;AAAA;AAAA;AACH;AAAA;AAAA,GAEJ;AAEJ","file":"index.js","sourcesContent":["\"use client\"\n\nimport { Progress as Ark } from \"@ark-ui/react/progress\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport {\n type ComponentPropsWithoutRef,\n type CSSProperties,\n type ReactNode,\n type Ref,\n useId,\n} from \"react\"\nimport type { ForbidAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport type { GradientDir, GradientProps } from \"../../lib/gradient\"\nimport { useLocale } from \"../../lib/intl\"\nimport { arkValue, METER_ZONE_COLORS, type MeterProps, meterZone } from \"../../lib/meter\"\nimport { props } from \"../../lib/props\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\n\n/**\n * CircularProgress — ring progress indicator on top of Ark UI's Progress state\n * machine (the circular counterpart of `Progress`). Ark owns the value/percent\n * math, the indeterminate flag, the `role=\"progressbar\"` + ARIA wiring, and the\n * SVG ring geometry (`Circle` → `CircleTrack` + `CircleRange`, sized by the\n * `--size` / `--thickness` vars we set on the root).\n *\n * The arc is a stroked SVG circle (`stroke-dasharray` driven by Ark), so it\n * clips by construction — no masking. The gradient is the circular equivalent\n * of the linear bar's track-spanning fill: an SVG gradient is fixed to the\n * ring's extent and the arc reveals it, so the complete `from`→`to` only shows\n * once the ring closes at 100%. `filled` strokes a single palette color\n * (`--c-solid`) instead.\n *\n * Name the ring with `aria-label` or `aria-labelledby` (and `aria-valuetext`\n * for a non-numeric reading): they land on the `role=\"progressbar\"` `<svg>`,\n * not the wrapping root, so assistive tech reads them with the value.\n *\n * Pass `meter` for a measurement rather than a task (a skill score, a quota):\n * the `<svg>` becomes `role=\"meter\"` with a locale-formatted `aria-valuetext`,\n * can't be indeterminate, and optional `low` / `high` / `optimum` thresholds\n * colour the arc by zone, like HTML `<meter>` (see `lib/meter.ts`).\n *\n * <CircularProgress meter value={82} aria-label=\"Score\" low={40} high={70} optimum={100} />\n *\n * Palette comes through the kit's `data-color` + slot-var system, so a new\n * color in `colors.css` works here for free.\n */\n\nconst CIRCULAR_DIMENSIONS: Record<Size, { size: number; thickness: number }> = {\n xs: { size: 24, thickness: 3 },\n sm: { size: 32, thickness: 3 },\n md: { size: 44, thickness: 4 },\n lg: { size: 60, thickness: 5 },\n xl: { size: 80, thickness: 6 },\n}\n\n/**\n * Resolves `size` / `thickness` to a px number: a raw number passes through\n * verbatim, a tee-shirt size looks up its own `key` from `CIRCULAR_DIMENSIONS`,\n * and `undefined` falls back through `fallbackSize` (itself defaulting to\n * `\"md\"` when that's a raw number, since a numeric `size` has no tee-shirt\n * dimensions of its own to fall back to for `thickness`).\n */\nconst resolveDimension = (\n value: CircularProgressSize | number | undefined,\n key: \"size\" | \"thickness\",\n fallbackSize: CircularProgressSize | number | undefined,\n) => {\n if (typeof value === \"number\") return value\n if (value != null) return CIRCULAR_DIMENSIONS[value][key]\n const fallback = typeof fallbackSize === \"number\" ? \"md\" : (fallbackSize ?? \"md\")\n return CIRCULAR_DIMENSIONS[fallback][key]\n}\n\nconst circularRange = cva(\n // Transition both the dash length and offset so toggling indeterminate morphs\n // the arc (value arc ↔ fixed 25% spinner arc) instead of snapping. The spin\n // itself lives on the <svg> (base rotation 0), so it starts seamlessly.\n [\"fill-none\", \"[transition:stroke-dasharray_300ms_ease,stroke-dashoffset_300ms_ease]\"],\n {\n variants: {\n // `gradient` strokes the SVG gradient (set inline); the palette variants\n // stroke a slot var.\n variant: {\n filled: \"stroke-(--c-solid)\",\n gradient: \"\",\n },\n },\n defaultVariants: { variant: \"filled\" },\n },\n)\n\nexport type CircularProgressVariant = NonNullable<VariantProps<typeof circularRange>[\"variant\"]>\nexport type CircularProgressSize = Size\n\nexport type { MeterZone } from \"../../lib/meter\"\nexport type { GradientDir, GradientProps }\n\ntype CircularProgressClassNames = {\n root?: string\n circle?: string\n track?: string\n range?: string\n label?: string\n}\n\ntype ArkRootProps = ComponentPropsWithoutRef<typeof Ark.Root>\n\n/**\n * `M` is `meter`'s literal type, inferred at the call site (see `MeterProps`).\n * Left out, it is `boolean`: every prop available, `value` plain `number | null`,\n * which is what a generic wrapper or an `Omit<CircularProgressProps, …>` should see.\n */\nexport type CircularProgressProps<M extends boolean = boolean> = Omit<\n ArkRootProps,\n | \"value\"\n | \"defaultValue\"\n | \"onValueChange\"\n // The kit's own `onChange` reports the value; a div's change event never fires here.\n | \"onChange\"\n | \"ref\"\n | \"className\"\n | \"children\"\n | \"asChild\"\n | \"locale\"\n | \"formatOptions\"\n | \"translations\"\n> &\n ForbidAsChild &\n VariantProps<typeof circularRange> &\n WithTestId &\n MeterProps<M> & {\n /** Locale the value text is formatted in: a BCP-47 tag, or `\"auto\"` for the\n * visitor's. Defaults to the `IntlProvider`'s, then `en-US`. */\n locale?: \"auto\" | (string & {})\n /** `Intl.NumberFormat` options for the value text. Defaults to a percentage;\n * `{ style: \"unit\", unit: \"gigabyte\" }` reads the raw value instead. */\n formatOptions?: ArkRootProps[\"formatOptions\"]\n /** Overrides the value text. `value` receives `{ value, min, max, percent,\n * formatter }` and returns what a screen reader says: \"Level 7, 40% to 8\". */\n translations?: ArkRootProps[\"translations\"]\n size?: CircularProgressSize | number\n /** Stroke width in px, a tee-shirt size, or omitted for a per-size default. */\n thickness?: CircularProgressSize | number\n /** Accent palette. Ignored when `variant=\"gradient\"`, and by a meter's zones. */\n color?: Color\n /**\n * Gradient stops; only applied when `variant=\"gradient\"`. `from` / `to` /\n * `via` are CSS colors (default purple-300 → pink-400). `dir` is ignored —\n * the SVG sweep direction is fixed (top-left → bottom-right).\n */\n gradient?: GradientProps\n /** Centered content, e.g. a percentage label. */\n children?: ReactNode\n /** Lands on the ring `<svg>` — the `role=\"progressbar\"` (or `\"meter\"`) element. */\n ref?: Ref<SVGSVGElement>\n /** Names the ring. Lands on the `<svg>`, the `role=\"progressbar\"` element, like the other\n * `aria-*` naming props below; without one, Ark names it by its value (\"40\"). */\n \"aria-label\"?: string\n /** Names the ring after a visible caption, by id. Wins over `aria-label`. */\n \"aria-labelledby\"?: string\n \"aria-describedby\"?: string\n /** Read instead of the number: \"Uploading\", \"3 of 8 files\". A meter\n * writes its formatted value here when unset. */\n \"aria-valuetext\"?: string\n className?: string\n classNames?: CircularProgressClassNames\n style?: CSSProperties\n }\n\n// `M` defaults to `false`, not `boolean`, so a bar with no `meter` rejects thresholds.\nexport const CircularProgress = <M extends boolean = false>({\n value,\n defaultValue,\n onChange,\n meter,\n low,\n high,\n optimum,\n locale,\n variant,\n size,\n thickness,\n color,\n gradient,\n min = 0,\n max = 100,\n children,\n ref,\n className,\n classNames,\n style,\n testId,\n asChild: _asChild,\n // The naming attributes describe the progressbar, which is the ring, not the root.\n \"aria-label\": label,\n \"aria-labelledby\": labelledBy,\n \"aria-describedby\": describedBy,\n \"aria-valuetext\": valueText,\n ...rest\n}: CircularProgressProps<M>) => {\n const isGradient = variant === \"gradient\"\n const gradientId = useId()\n const resolvedLocale = useLocale(locale)\n\n return (\n <Ark.Root\n // `undefined` → uncontrolled (Ark's own default). `null` → indeterminate.\n // The two must NOT be coalesced, so each is forwarded verbatim.\n value={arkValue(\"CircularProgress\", meter, value, min)}\n defaultValue={arkValue(\"CircularProgress\", meter, defaultValue, min)}\n // A meter's value is never null, so its narrower `onChange` takes Ark's value as is.\n onValueChange={\n onChange ? ({ value: v }) => (onChange as (v: number | null) => void)(v) : undefined\n }\n min={min}\n max={max}\n locale={resolvedLocale}\n data-color={!isGradient ? color : undefined}\n className={cn(\"group/cprogress relative inline-flex\", className, classNames?.root)}\n style={\n {\n \"--size\": `${resolveDimension(size, \"size\", size)}px`,\n \"--thickness\": `${resolveDimension(thickness, \"thickness\", size)}px`,\n ...style,\n } as CSSProperties\n }\n {...rest}\n >\n <Ark.Context>\n {(api) => {\n // Meter zones read the machine's own value, so an uncontrolled meter is coloured too.\n const zone = meter ? meterZone(api.value, { min, max, low, high, optimum }) : undefined\n return (\n <Ark.Circle\n ref={ref}\n // Ark stamps `role=\"progressbar\"` here; a meter overrides it (local props win).\n {...(meter ? { role: \"meter\" } : null)}\n className={cn(\n // Ark's CircleRange already rotates the arc to start at 12 o'clock.\n \"block\",\n // Indeterminate: Ark drops the dash, so the range below pins a fixed\n // arc; spin the whole ring. Gated under reduced motion in theme.css.\n \"group-data-[state=indeterminate]/cprogress:animate-progress-spin\",\n classNames?.circle,\n )}\n {...props({\n \"data-testid\": testId,\n // The zone's palette lands on the ring, which the arc inherits from.\n \"data-color\": zone && !isGradient ? METER_ZONE_COLORS[zone] : undefined,\n \"data-zone\": zone,\n \"aria-label\": label,\n \"aria-labelledby\": labelledBy,\n \"aria-describedby\": describedBy,\n // A meter always says its value: Ark's locale-aware `valueAsString`, which\n // `formatOptions` / `translations.value` shape, unless the caller wrote one.\n \"aria-valuetext\": valueText ?? (meter ? api.valueAsString : undefined),\n })}\n >\n {isGradient && (\n <defs>\n <linearGradient id={gradientId} x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"100%\">\n <stop offset=\"0%\" stopColor={gradient?.from ?? \"var(--color-purple-300)\"} />\n {gradient?.via && <stop offset=\"50%\" stopColor={gradient.via} />}\n <stop offset=\"100%\" stopColor={gradient?.to ?? \"var(--color-pink-400)\"} />\n </linearGradient>\n </defs>\n )}\n <Ark.CircleTrack\n className={cn(\"fill-none stroke-black/3 dark:stroke-white/4\", classNames?.track)}\n />\n <Ark.CircleRange\n strokeLinecap=\"round\"\n className={cn(\n circularRange({ variant }),\n // Indeterminate: pin a fixed 25% arc (Ark omits the dash here).\n \"group-data-[state=indeterminate]/cprogress:[stroke-dasharray:calc(var(--circumference)*0.25)_var(--circumference)]\",\n \"group-data-[state=indeterminate]/cprogress:[stroke-dashoffset:0]\",\n classNames?.range,\n )}\n style={isGradient ? { stroke: `url(#${gradientId})` } : undefined}\n />\n </Ark.Circle>\n )\n }}\n </Ark.Context>\n\n {children != null && (\n <span\n className={cn(\"absolute inset-0 flex items-center justify-center\", classNames?.label)}\n >\n {children}\n </span>\n )}\n </Ark.Root>\n )\n}\n"]}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { InputBase, inputControlClasses } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import { ActionIcon } from '../../chunk-
|
|
2
|
+
import { InputBase, inputControlClasses } from '../../chunk-HTVICHT4.js';
|
|
3
|
+
import '../../chunk-2RRTT4AF.js';
|
|
4
|
+
import { ActionIcon } from '../../chunk-ALANKV5Y.js';
|
|
5
|
+
import '../../chunk-NDI4HLQE.js';
|
|
5
6
|
import '../../chunk-6B2GNPJP.js';
|
|
6
7
|
import { mergeIcons, iconStroke } from '../../chunk-XXOR34T4.js';
|
|
7
8
|
import '../../chunk-W3XX7BYT.js';
|
|
9
|
+
import '../../chunk-PQZSTI3R.js';
|
|
10
|
+
import '../../chunk-PMUCGFY5.js';
|
|
11
|
+
import '../../chunk-BUIHQJGE.js';
|
|
8
12
|
import { composeChildren } from '../../chunk-R5LYFTHA.js';
|
|
9
13
|
import { props } from '../../chunk-WYCMIIRR.js';
|
|
10
14
|
import '../../chunk-C6NVU4F7.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/clipboard/clipboard.tsx","../../../src/components/clipboard/copy.tsx"],"names":["Ark","jsx","useClipboardContext"],"mappings":";;;;;;;;;;;;;;;AAkDA,IAAM,cAAA,GAAiB,QAAA;AAIvB,IAAM,YAAA,GAAe,CAAC,EAAE,KAAA,EAAM,KAAyB;AACrD,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,mBAAA,EAAoB;AACvC,EAAA,uBACE,GAAA,CAAC,UAAK,IAAA,EAAK,QAAA,EAAS,WAAU,SAAA,EAC3B,QAAA,EAAA,MAAA,GAAS,QAAQ,EAAA,EACpB,CAAA;AAEJ,CAAA;AAuBA,IAAM,OAAO,CAAC;AAAA,EACZ,QAAA;AAAA,EACA,cAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG;AACL,CAAA,KAA0B;AACxB,EAAA,MAAM,EAAE,MAAA,GAAS,cAAA,EAAgB,GAAG,eAAA,EAAgB,GAAI,gBAAgB,EAAC;AACzE,EAAA,uBACE,GAAA;AAAA,IAACA,WAAA,CAAI,IAAA;AAAA,IAAJ;AAAA,MACC,eAAe,QAAA,GAAW,CAAC,YAAY,QAAA,CAAS,OAAA,CAAQ,KAAK,CAAA,GAAI,MAAA;AAAA,MACjE,gBAAgB,cAAA,GAAiB,CAAC,YAAY,cAAA,CAAe,OAAA,CAAQ,MAAM,CAAA,GAAI,MAAA;AAAA,MAC/E,YAAA,EAAc,eAAA;AAAA,MACd,OAAA;AAAA,MACA,SAAA,EAAW,EAAA,CAAG,UAAA,EAAY,SAAS,CAAA;AAAA,MAClC,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAA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AAA,EAAc,QACtE,QAAA,kBAAAA,GAAAA,CAAC,aAAA,EAAA,EAAc,KAAA,EAAO,UAAA,CAAW,aAAA,EAAe,KAAK,CAAA,EAAG,GAC1D,CAAA,EACF;AAAA;AAEJ","file":"index.js","sourcesContent":["\"use client\"\n\nimport { Clipboard as Ark, useClipboardContext } from \"@ark-ui/react/clipboard\"\nimport type { ComponentProps, ReactNode } from \"react\"\nimport { composeChildren } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { InputBase, type InputSize, type InputVariant, inputControlClasses } from \"../input/input\"\n\n/**\n * Clipboard — a styled compound over Ark UI's Clipboard machine, for the\n * \"read-only value + copy button\" field pattern (share links, API keys,\n * invite codes). `Object.assign`-free parts namespace only, no bare-invocation\n * convenience form — matches `Popover`'s shape, since a rich field like this\n * isn't a single-prop drop-in the way `Copy` (this package's simple icon-button\n * preset) is.\n *\n * <Clipboard.Root value={link}>\n * <Clipboard.Label>Share link</Clipboard.Label>\n * <Clipboard.Input>\n * <Clipboard.Trigger asChild>\n * <ActionIcon variant=\"subtle\" aria-label=\"Copy link\">\n * <Clipboard.Indicator copied={<CheckIcon />}>\n * <CopyIcon />\n * </Clipboard.Indicator>\n * </ActionIcon>\n * </Clipboard.Trigger>\n * </Clipboard.Input>\n * </Clipboard.Root>\n *\n * For the common \"just an icon button, no visible value\" case, reach for\n * `Copy` instead — it composes this same machine with `ActionIcon` internally.\n */\n\n/** Ark's own `translations` prop type, derived structurally rather than imported\n * by name — `IntlTranslations` lives in `@zag-js/clipboard`, a transitive\n * dependency of the `@ark-ui/react` peer dep, not one this package declares\n * itself (same derivation `Calendar` uses for its own translations type).\n * Ark's shape is already fully partial (a single optional `triggerLabel`) and\n * its machine merges it over its own English default, so `Root` forwards only\n * the keys the caller set. */\ntype ArkClipboardTranslations = NonNullable<ComponentProps<typeof Ark.Root>[\"translations\"]>\n\nexport type ClipboardTranslations = ArkClipboardTranslations & {\n /** Announced through a polite `role=\"status\"` region once the value is copied. Ark's\n * `triggerLabel` swap renames the focused button, which screen readers don't re-read. */\n copied?: string\n}\n\nconst DEFAULT_COPIED = \"Copied\"\n\n/** The live region behind the icon swap: always mounted (a region that appears\n * together with its text isn't announced), filled only while `copied`. */\nconst CopiedStatus = ({ label }: { label: string }) => {\n const { copied } = useClipboardContext()\n return (\n <span role=\"status\" className=\"sr-only\">\n {copied ? label : \"\"}\n </span>\n )\n}\n\nexport type ClipboardRootProps = Omit<\n ComponentProps<typeof Ark.Root>,\n \"onChange\" | \"onValueChange\" | \"onStatusChange\" | \"translations\"\n> &\n WithTestId & {\n /** Flattened from Ark's `onValueChange` — the next clipboard value. */\n onChange?: (value: string) => void\n /** Flattened from Ark's `onStatusChange` — fires `true` once the value is\n * copied. Ark's machine only emits this on copy, not on the automatic\n * revert to idle after `timeout` — read `Clipboard.Indicator` (or its\n * `copied` render prop) for the live state instead. */\n onCopiedChange?: (copied: boolean) => void\n /** Microcopy: Ark's `triggerLabel` (the trigger's name, copied or not) and `copied`\n * (the status announced on copy). English defaults; set only the keys you translate. */\n translations?: ClipboardTranslations\n }\n\n/** Owns open-ended clipboard state (value + copied/idle) and renders the real\n * `<div>` the rest of the compound reads context from, plus the visually\n * hidden status that announces a copy (positioned, so it can't escape a\n * scroller). */\nconst Root = ({\n onChange,\n onCopiedChange,\n testId,\n translations,\n asChild,\n className,\n children,\n ...rest\n}: ClipboardRootProps) => {\n const { copied = DEFAULT_COPIED, ...arkTranslations } = translations ?? {}\n return (\n <Ark.Root\n onValueChange={onChange ? (details) => onChange(details.value) : undefined}\n onStatusChange={onCopiedChange ? (details) => onCopiedChange(details.copied) : undefined}\n translations={arkTranslations}\n asChild={asChild}\n className={cn(\"relative\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {own}\n <CopiedStatus label={copied} />\n </>\n ))}\n </Ark.Root>\n )\n}\n\nexport type ClipboardInputProps = Omit<ComponentProps<typeof Ark.Input>, \"size\" | \"readOnly\"> &\n WithTestId & {\n /** Shell treatment — same scale as `Input`'s. */\n variant?: InputVariant\n /** Height step — same scale as `Input`'s. */\n size?: InputSize\n /** The copy `Trigger`, rendered as a real sibling of the input inside the\n * shell — pass it as `children`, not via a decorative `endSlot` (whose\n * wrapper is `aria-hidden` and would hide an interactive trigger from\n * assistive tech; see `PasswordInput`'s reveal toggle for the same call). */\n children?: ReactNode\n classNames?: { root?: string; input?: string }\n }\n\n/** The clipboard value, in the kit's shared `InputBase` shell — reused\n * directly (like `Input` / `PasswordInput` do), rather than through a\n * separate `Clipboard.Control` shell. `Clipboard.Control` (Ark's raw part,\n * re-exported below) stays available for consumers who want a different\n * layout and just need its `data-copied` attribute.\n *\n * Always read-only: Ark's own machine already sets `readOnly` on the real\n * `<input>` it renders; the `readOnly` given to `InputBase` here just mirrors\n * that onto the shell's own `data-readonly` hook. */\nconst Input = ({\n variant,\n size,\n className,\n classNames,\n children,\n testId,\n asChild,\n ...rest\n}: ClipboardInputProps) => (\n <InputBase variant={variant} size={size} readOnly className={cn(className, classNames?.root)}>\n {/* `children` is the trailing slot (usually the copy trigger), except under\n `asChild`, where the single child is the input element itself. */}\n <Ark.Input\n asChild={asChild}\n className={cn(inputControlClasses, classNames?.input)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {asChild ? children : undefined}\n </Ark.Input>\n {!asChild && children}\n </InputBase>\n)\n\nexport const Clipboard = {\n Root,\n /** Ark's raw `Label` part — a real `<label>`; unstyled by default, size/style\n * it like any other field label (or reuse `Field`'s own `fieldLabel`). */\n Label: Ark.Label,\n /** Ark's raw `Control` part — wraps `Input` (+ `Trigger`) when you want a\n * different shell than `InputBase`; carries `data-copied` for that case. */\n Control: Ark.Control,\n Input,\n /** Ark's raw `Trigger` part — a real `<button>`; `asChild` to swap in\n * `ActionIcon` or any other trigger element. */\n Trigger: Ark.Trigger,\n /** Ark's raw `Indicator` part — pass `copied={<CheckIcon />}` to swap content\n * once the value is copied, reverting once the state returns to idle. */\n Indicator: Ark.Indicator,\n /** Ark's raw `ValueText` part — renders the live value as plain (non-input)\n * text, for a read-only display that isn't a form control. */\n ValueText: Ark.ValueText,\n}\n","\"use client\"\n\nimport { useClipboardContext } from \"@ark-ui/react/clipboard\"\nimport { CheckIcon, CopyIcon } from \"lucide-react\"\nimport type { ReactNode } from \"react\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { ActionIcon, type ActionIconProps } from \"../action-icon/action-icon\"\nimport { Clipboard, type ClipboardTranslations } from \"./clipboard\"\n\nexport type CopyIconSlot = \"copy\" | \"copied\"\nexport type CopyIcons = IconMap<CopyIconSlot>\n\n/** The default icons: the copy glyph, and the check it swaps to once copied. */\nexport const DEFAULT_ICONS: Record<CopyIconSlot, ReactNode> = {\n copy: <CopyIcon className={iconStroke} />,\n copied: <CheckIcon className={iconStroke} />,\n}\n\n/** Reads the live `copied` flag off the enclosing `Clipboard.Root` — context,\n * not the one-shot `onStatusChange` callback, which never fires `false` on the\n * automatic revert to idle — and draws the matching icon. */\nconst CopyIndicator = ({ icons }: { icons: Record<CopyIconSlot, ReactNode> }) => {\n const { copied } = useClipboardContext()\n return copied ? icons.copied : icons.copy\n}\n\nexport type CopyRenderState = {\n /** Whether `value` was just copied to the clipboard — flips back to\n * `false` once `timeout` elapses. */\n copied: boolean\n /** Writes `value` to the clipboard — the exact same action `Clipboard.Trigger`\n * itself calls on click. Wire it to your own trigger's `onClick`; `Copy`\n * doesn't attach it for you. */\n copy: () => void\n}\n\n/** Reads `{ copied, copy }` off the enclosing `Clipboard.Root` context and hands\n * them straight to the render-prop `children` — no markup of its own, so the\n * consumer's returned JSX is the only thing rendered. `copy` is Ark's own\n * `copy()` action (`send({ type: \"COPY\" })`), so calling it behaves\n * identically to clicking the default `Clipboard.Trigger`: it writes `value`\n * to the clipboard, flips `copied`, fires `Root`'s `onCopiedChange`, and\n * reverts after `timeout`. */\nconst CopyRenderProp = ({ children }: { children: (state: CopyRenderState) => ReactNode }) => {\n const { copied, copy } = useClipboardContext()\n return children({ copied, copy })\n}\n\nexport type CopyProps = Pick<\n ActionIconProps,\n \"variant\" | \"size\" | \"radius\" | \"color\" | \"testId\"\n> & {\n /** The value copied to the clipboard on click. */\n value: string\n /** Ms before the copied state reverts to idle. Ark's own default (3000). */\n timeout?: number\n /** Fires `true` once the value is copied — flattened from Ark's\n * `onStatusChange`. Ark's machine only emits this on copy, never on the\n * automatic revert to idle after `timeout` (an upstream characteristic of\n * the machine, not a gap in this wrapper). */\n onCopiedChange?: (copied: boolean) => void\n /** Replaces the default icons: `copy`, and `copied` once the value is copied. A missing key\n * keeps its default; a function `children` renders its own trigger instead. */\n icons?: CopyIcons\n /** Microcopy: the button's `triggerLabel` and the `copied` status announced on copy. English\n * defaults; set only the keys you translate. */\n translations?: ClipboardTranslations\n /** Omit for the default rendering (an icon-button `ActionIcon` whose icon\n * swaps to a checkmark on copy). Pass a function instead to go fully\n * headless: `Copy` renders none of its own markup and instead calls this\n * with `{ copied, copy }`, letting you render whatever trigger you want —\n * your own button, a text link, a custom icon — wiring `copy` to its\n * `onClick` yourself. `copied` and `copy` still ride the same `timeout` /\n * `onCopiedChange` behavior as the default button.\n *\n * <Copy value={value}>\n * {({ copied, copy }) => (\n * <button type=\"button\" onClick={copy}>\n * {copied ? \"Copied!\" : \"Copy\"}\n * </button>\n * )}\n * </Copy>\n */\n children?: (state: CopyRenderState) => ReactNode\n}\n\n/**\n * Copy — a one-line preset: `Clipboard.Root` + `Clipboard.Trigger` wrapping this\n * kit's own `ActionIcon`. No visible input, just an icon button whose icon\n * swaps to a checkmark on copy and reverts to the copy icon after `timeout`.\n * `variant` / `size` / `radius` / `color` forward straight to `ActionIcon` — see\n * its own docs for that model.\n *\n * <Copy value=\"https://example.com/s/abc123\" />\n *\n * The accessible name comes from Ark's own `\"Copy to clipboard\"` /\n * `\"Copied to clipboard\"` translations, and a copy is announced as \"Copied\"\n * through a visually hidden status; both are overridable via `translations`.\n * `Copy` is a closed leaf preset — it owns its `ActionIcon` outright and\n * doesn't accept `asChild` or a custom `aria-label`; compose `Clipboard.Root` /\n * `Clipboard.Trigger` directly (see the `Clipboard` docs) for a different\n * trigger element.\n *\n * For anything else — a text link, a custom icon, your own button styling —\n * pass a function as `children` instead and go headless: `Copy` then renders\n * only the function's own return value, no `ActionIcon`/icon-swap markup of\n * its own, and hands you `{ copied, copy }` to build the trigger yourself.\n *\n * <Copy value=\"https://example.com/s/abc123\">\n * {({ copied, copy }) => (\n * <button type=\"button\" onClick={copy}>{copied ? \"Copied!\" : \"Copy\"}</button>\n * )}\n * </Copy>\n */\nexport const Copy = ({\n value,\n timeout,\n onCopiedChange,\n variant,\n size,\n radius,\n color,\n testId,\n icons,\n translations,\n children,\n}: CopyProps) => (\n <Clipboard.Root\n value={value}\n timeout={timeout}\n onCopiedChange={onCopiedChange}\n translations={translations}\n >\n {typeof children === \"function\" ? (\n <CopyRenderProp>{children}</CopyRenderProp>\n ) : (\n <Clipboard.Trigger asChild>\n <ActionIcon variant={variant} size={size} radius={radius} color={color} testId={testId}>\n <CopyIndicator icons={mergeIcons(DEFAULT_ICONS, icons)} />\n </ActionIcon>\n </Clipboard.Trigger>\n )}\n </Clipboard.Root>\n)\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/clipboard/clipboard.tsx","../../../src/components/clipboard/copy.tsx"],"names":["Ark","jsx","useClipboardContext"],"mappings":";;;;;;;;;;;;;;;;;;;AAkDA,IAAM,cAAA,GAAiB,QAAA;AAIvB,IAAM,YAAA,GAAe,CAAC,EAAE,KAAA,EAAM,KAAyB;AACrD,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,mBAAA,EAAoB;AACvC,EAAA,uBACE,GAAA,CAAC,UAAK,IAAA,EAAK,QAAA,EAAS,WAAU,SAAA,EAC3B,QAAA,EAAA,MAAA,GAAS,QAAQ,EAAA,EACpB,CAAA;AAEJ,CAAA;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mBAAAA,EAAoB;AAC7C,EAAA,OAAO,QAAA,CAAS,EAAE,MAAA,EAAQ,IAAA,EAAM,CAAA;AAClC,CAAA;AAoEO,IAAM,OAAO,CAAC;AAAA,EACnB,KAAA;AAAA,EACA,OAAA;AAAA,EACA,cAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF,CAAA,qBACED,GAAAA;AAAA,EAAC,SAAA,CAAU,IAAA;AAAA,EAAV;AAAA,IACC,KAAA;AAAA,IACA,OAAA;AAAA,IACA,cAAA;AAAA,IACA,YAAA;AAAA,IAEC,QAAA,EAAA,OAAO,QAAA,KAAa,UAAA,mBACnBA,IAAC,cAAA,EAAA,EAAgB,QAAA,EAAS,CAAA,mBAE1BA,GAAAA,CAAC,SAAA,CAAU,OAAA,EAAV,EAAkB,SAAO,IAAA,EACxB,QAAA,kBAAAA,GAAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAkB,IAAA,EAAY,MAAA,EAAgB,KAAA,EAAc,QACtE,QAAA,kBAAAA,GAAAA,CAAC,aAAA,EAAA,EAAc,KAAA,EAAO,UAAA,CAAW,aAAA,EAAe,KAAK,CAAA,EAAG,GAC1D,CAAA,EACF;AAAA;AAEJ","file":"index.js","sourcesContent":["\"use client\"\n\nimport { Clipboard as Ark, useClipboardContext } from \"@ark-ui/react/clipboard\"\nimport type { ComponentProps, ReactNode } from \"react\"\nimport { composeChildren } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { InputBase, type InputSize, type InputVariant, inputControlClasses } from \"../input/input\"\n\n/**\n * Clipboard — a styled compound over Ark UI's Clipboard machine, for the\n * \"read-only value + copy button\" field pattern (share links, API keys,\n * invite codes). `Object.assign`-free parts namespace only, no bare-invocation\n * convenience form — matches `Popover`'s shape, since a rich field like this\n * isn't a single-prop drop-in the way `Copy` (this package's simple icon-button\n * preset) is.\n *\n * <Clipboard.Root value={link}>\n * <Clipboard.Label>Share link</Clipboard.Label>\n * <Clipboard.Input>\n * <Clipboard.Trigger asChild>\n * <ActionIcon variant=\"subtle\" aria-label=\"Copy link\">\n * <Clipboard.Indicator copied={<CheckIcon />}>\n * <CopyIcon />\n * </Clipboard.Indicator>\n * </ActionIcon>\n * </Clipboard.Trigger>\n * </Clipboard.Input>\n * </Clipboard.Root>\n *\n * For the common \"just an icon button, no visible value\" case, reach for\n * `Copy` instead — it composes this same machine with `ActionIcon` internally.\n */\n\n/** Ark's own `translations` prop type, derived structurally rather than imported\n * by name — `IntlTranslations` lives in `@zag-js/clipboard`, a transitive\n * dependency of the `@ark-ui/react` peer dep, not one this package declares\n * itself (same derivation `Calendar` uses for its own translations type).\n * Ark's shape is already fully partial (a single optional `triggerLabel`) and\n * its machine merges it over its own English default, so `Root` forwards only\n * the keys the caller set. */\ntype ArkClipboardTranslations = NonNullable<ComponentProps<typeof Ark.Root>[\"translations\"]>\n\nexport type ClipboardTranslations = ArkClipboardTranslations & {\n /** Announced through a polite `role=\"status\"` region once the value is copied. Ark's\n * `triggerLabel` swap renames the focused button, which screen readers don't re-read. */\n copied?: string\n}\n\nconst DEFAULT_COPIED = \"Copied\"\n\n/** The live region behind the icon swap: always mounted (a region that appears\n * together with its text isn't announced), filled only while `copied`. */\nconst CopiedStatus = ({ label }: { label: string }) => {\n const { copied } = useClipboardContext()\n return (\n <span role=\"status\" className=\"sr-only\">\n {copied ? label : \"\"}\n </span>\n )\n}\n\nexport type ClipboardRootProps = Omit<\n ComponentProps<typeof Ark.Root>,\n \"onChange\" | \"onValueChange\" | \"onStatusChange\" | \"translations\"\n> &\n WithTestId & {\n /** Flattened from Ark's `onValueChange` — the next clipboard value. */\n onChange?: (value: string) => void\n /** Flattened from Ark's `onStatusChange` — fires `true` once the value is\n * copied. Ark's machine only emits this on copy, not on the automatic\n * revert to idle after `timeout` — read `Clipboard.Indicator` (or its\n * `copied` render prop) for the live state instead. */\n onCopiedChange?: (copied: boolean) => void\n /** Microcopy: Ark's `triggerLabel` (the trigger's name, copied or not) and `copied`\n * (the status announced on copy). English defaults; set only the keys you translate. */\n translations?: ClipboardTranslations\n }\n\n/** Owns open-ended clipboard state (value + copied/idle) and renders the real\n * `<div>` the rest of the compound reads context from, plus the visually\n * hidden status that announces a copy (positioned, so it can't escape a\n * scroller). */\nconst Root = ({\n onChange,\n onCopiedChange,\n testId,\n translations,\n asChild,\n className,\n children,\n ...rest\n}: ClipboardRootProps) => {\n const { copied = DEFAULT_COPIED, ...arkTranslations } = translations ?? {}\n return (\n <Ark.Root\n onValueChange={onChange ? (details) => onChange(details.value) : undefined}\n onStatusChange={onCopiedChange ? (details) => onCopiedChange(details.copied) : undefined}\n translations={arkTranslations}\n asChild={asChild}\n className={cn(\"relative\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {own}\n <CopiedStatus label={copied} />\n </>\n ))}\n </Ark.Root>\n )\n}\n\nexport type ClipboardInputProps = Omit<ComponentProps<typeof Ark.Input>, \"size\" | \"readOnly\"> &\n WithTestId & {\n /** Shell treatment — same scale as `Input`'s. */\n variant?: InputVariant\n /** Height step — same scale as `Input`'s. */\n size?: InputSize\n /** The copy `Trigger`, rendered as a real sibling of the input inside the\n * shell — pass it as `children`, not via a decorative `endSlot` (whose\n * wrapper is `aria-hidden` and would hide an interactive trigger from\n * assistive tech; see `PasswordInput`'s reveal toggle for the same call). */\n children?: ReactNode\n classNames?: { root?: string; input?: string }\n }\n\n/** The clipboard value, in the kit's shared `InputBase` shell — reused\n * directly (like `Input` / `PasswordInput` do), rather than through a\n * separate `Clipboard.Control` shell. `Clipboard.Control` (Ark's raw part,\n * re-exported below) stays available for consumers who want a different\n * layout and just need its `data-copied` attribute.\n *\n * Always read-only: Ark's own machine already sets `readOnly` on the real\n * `<input>` it renders; the `readOnly` given to `InputBase` here just mirrors\n * that onto the shell's own `data-readonly` hook. */\nconst Input = ({\n variant,\n size,\n className,\n classNames,\n children,\n testId,\n asChild,\n ...rest\n}: ClipboardInputProps) => (\n <InputBase variant={variant} size={size} readOnly className={cn(className, classNames?.root)}>\n {/* `children` is the trailing slot (usually the copy trigger), except under\n `asChild`, where the single child is the input element itself. */}\n <Ark.Input\n asChild={asChild}\n className={cn(inputControlClasses, classNames?.input)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {asChild ? children : undefined}\n </Ark.Input>\n {!asChild && children}\n </InputBase>\n)\n\nexport const Clipboard = {\n Root,\n /** Ark's raw `Label` part — a real `<label>`; unstyled by default, size/style\n * it like any other field label (or reuse `Field`'s own `fieldLabel`). */\n Label: Ark.Label,\n /** Ark's raw `Control` part — wraps `Input` (+ `Trigger`) when you want a\n * different shell than `InputBase`; carries `data-copied` for that case. */\n Control: Ark.Control,\n Input,\n /** Ark's raw `Trigger` part — a real `<button>`; `asChild` to swap in\n * `ActionIcon` or any other trigger element. */\n Trigger: Ark.Trigger,\n /** Ark's raw `Indicator` part — pass `copied={<CheckIcon />}` to swap content\n * once the value is copied, reverting once the state returns to idle. */\n Indicator: Ark.Indicator,\n /** Ark's raw `ValueText` part — renders the live value as plain (non-input)\n * text, for a read-only display that isn't a form control. */\n ValueText: Ark.ValueText,\n}\n","\"use client\"\n\nimport { useClipboardContext } from \"@ark-ui/react/clipboard\"\nimport { CheckIcon, CopyIcon } from \"lucide-react\"\nimport type { ReactNode } from \"react\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { ActionIcon, type ActionIconProps } from \"../action-icon/action-icon\"\nimport { Clipboard, type ClipboardTranslations } from \"./clipboard\"\n\nexport type CopyIconSlot = \"copy\" | \"copied\"\nexport type CopyIcons = IconMap<CopyIconSlot>\n\n/** The default icons: the copy glyph, and the check it swaps to once copied. */\nexport const DEFAULT_ICONS: Record<CopyIconSlot, ReactNode> = {\n copy: <CopyIcon className={iconStroke} />,\n copied: <CheckIcon className={iconStroke} />,\n}\n\n/** Reads the live `copied` flag off the enclosing `Clipboard.Root` — context,\n * not the one-shot `onStatusChange` callback, which never fires `false` on the\n * automatic revert to idle — and draws the matching icon. */\nconst CopyIndicator = ({ icons }: { icons: Record<CopyIconSlot, ReactNode> }) => {\n const { copied } = useClipboardContext()\n return copied ? icons.copied : icons.copy\n}\n\nexport type CopyRenderState = {\n /** Whether `value` was just copied to the clipboard — flips back to\n * `false` once `timeout` elapses. */\n copied: boolean\n /** Writes `value` to the clipboard — the exact same action `Clipboard.Trigger`\n * itself calls on click. Wire it to your own trigger's `onClick`; `Copy`\n * doesn't attach it for you. */\n copy: () => void\n}\n\n/** Reads `{ copied, copy }` off the enclosing `Clipboard.Root` context and hands\n * them straight to the render-prop `children` — no markup of its own, so the\n * consumer's returned JSX is the only thing rendered. `copy` is Ark's own\n * `copy()` action (`send({ type: \"COPY\" })`), so calling it behaves\n * identically to clicking the default `Clipboard.Trigger`: it writes `value`\n * to the clipboard, flips `copied`, fires `Root`'s `onCopiedChange`, and\n * reverts after `timeout`. */\nconst CopyRenderProp = ({ children }: { children: (state: CopyRenderState) => ReactNode }) => {\n const { copied, copy } = useClipboardContext()\n return children({ copied, copy })\n}\n\nexport type CopyProps = Pick<\n ActionIconProps,\n \"variant\" | \"size\" | \"radius\" | \"color\" | \"testId\"\n> & {\n /** The value copied to the clipboard on click. */\n value: string\n /** Ms before the copied state reverts to idle. Ark's own default (3000). */\n timeout?: number\n /** Fires `true` once the value is copied — flattened from Ark's\n * `onStatusChange`. Ark's machine only emits this on copy, never on the\n * automatic revert to idle after `timeout` (an upstream characteristic of\n * the machine, not a gap in this wrapper). */\n onCopiedChange?: (copied: boolean) => void\n /** Replaces the default icons: `copy`, and `copied` once the value is copied. A missing key\n * keeps its default; a function `children` renders its own trigger instead. */\n icons?: CopyIcons\n /** Microcopy: the button's `triggerLabel` and the `copied` status announced on copy. English\n * defaults; set only the keys you translate. */\n translations?: ClipboardTranslations\n /** Omit for the default rendering (an icon-button `ActionIcon` whose icon\n * swaps to a checkmark on copy). Pass a function instead to go fully\n * headless: `Copy` renders none of its own markup and instead calls this\n * with `{ copied, copy }`, letting you render whatever trigger you want —\n * your own button, a text link, a custom icon — wiring `copy` to its\n * `onClick` yourself. `copied` and `copy` still ride the same `timeout` /\n * `onCopiedChange` behavior as the default button.\n *\n * <Copy value={value}>\n * {({ copied, copy }) => (\n * <button type=\"button\" onClick={copy}>\n * {copied ? \"Copied!\" : \"Copy\"}\n * </button>\n * )}\n * </Copy>\n */\n children?: (state: CopyRenderState) => ReactNode\n}\n\n/**\n * Copy — a one-line preset: `Clipboard.Root` + `Clipboard.Trigger` wrapping this\n * kit's own `ActionIcon`. No visible input, just an icon button whose icon\n * swaps to a checkmark on copy and reverts to the copy icon after `timeout`.\n * `variant` / `size` / `radius` / `color` forward straight to `ActionIcon` — see\n * its own docs for that model.\n *\n * <Copy value=\"https://example.com/s/abc123\" />\n *\n * The accessible name comes from Ark's own `\"Copy to clipboard\"` /\n * `\"Copied to clipboard\"` translations, and a copy is announced as \"Copied\"\n * through a visually hidden status; both are overridable via `translations`.\n * `Copy` is a closed leaf preset — it owns its `ActionIcon` outright and\n * doesn't accept `asChild` or a custom `aria-label`; compose `Clipboard.Root` /\n * `Clipboard.Trigger` directly (see the `Clipboard` docs) for a different\n * trigger element.\n *\n * For anything else — a text link, a custom icon, your own button styling —\n * pass a function as `children` instead and go headless: `Copy` then renders\n * only the function's own return value, no `ActionIcon`/icon-swap markup of\n * its own, and hands you `{ copied, copy }` to build the trigger yourself.\n *\n * <Copy value=\"https://example.com/s/abc123\">\n * {({ copied, copy }) => (\n * <button type=\"button\" onClick={copy}>{copied ? \"Copied!\" : \"Copy\"}</button>\n * )}\n * </Copy>\n */\nexport const Copy = ({\n value,\n timeout,\n onCopiedChange,\n variant,\n size,\n radius,\n color,\n testId,\n icons,\n translations,\n children,\n}: CopyProps) => (\n <Clipboard.Root\n value={value}\n timeout={timeout}\n onCopiedChange={onCopiedChange}\n translations={translations}\n >\n {typeof children === \"function\" ? (\n <CopyRenderProp>{children}</CopyRenderProp>\n ) : (\n <Clipboard.Trigger asChild>\n <ActionIcon variant={variant} size={size} radius={radius} color={color} testId={testId}>\n <CopyIndicator icons={mergeIcons(DEFAULT_ICONS, icons)} />\n </ActionIcon>\n </Clipboard.Trigger>\n )}\n </Clipboard.Root>\n)\n"]}
|