@42-central/ui-react 0.18.2 → 0.19.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-YXE4B6X3.js → chunk-2NNZHVKD.js} +3 -3
- package/dist/{chunk-YXE4B6X3.js.map → chunk-2NNZHVKD.js.map} +1 -1
- package/dist/{chunk-5JHDSVEZ.js → chunk-4NNGTNPV.js} +10 -8
- package/dist/chunk-4NNGTNPV.js.map +1 -0
- package/dist/{chunk-7NZSTCJO.js → chunk-57BTVRRB.js} +4 -9
- package/dist/chunk-57BTVRRB.js.map +1 -0
- package/dist/{chunk-S2HWWR2H.js → chunk-64T6Z7BA.js} +3 -3
- package/dist/{chunk-S2HWWR2H.js.map → chunk-64T6Z7BA.js.map} +1 -1
- package/dist/{chunk-MI2WZRK3.js → chunk-A6MYJTJI.js} +4 -4
- package/dist/{chunk-MI2WZRK3.js.map → chunk-A6MYJTJI.js.map} +1 -1
- package/dist/{chunk-RQL7FVCS.js → chunk-BTFBBNRW.js} +11 -6
- package/dist/chunk-BTFBBNRW.js.map +1 -0
- package/dist/{chunk-OWG4BCQR.js → chunk-CYWMES5P.js} +4 -4
- package/dist/{chunk-OWG4BCQR.js.map → chunk-CYWMES5P.js.map} +1 -1
- package/dist/{chunk-YBJB7FGE.js → chunk-CZEKZ5HR.js} +6 -6
- package/dist/chunk-CZEKZ5HR.js.map +1 -0
- package/dist/{chunk-HAQJQFE6.js → chunk-DBTJEBMO.js} +11 -4
- package/dist/{chunk-HAQJQFE6.js.map → chunk-DBTJEBMO.js.map} +1 -1
- package/dist/{chunk-AE7QTLJ5.js → chunk-FAOBC4IS.js} +4 -4
- package/dist/{chunk-AE7QTLJ5.js.map → chunk-FAOBC4IS.js.map} +1 -1
- package/dist/{chunk-NF5JM2YO.js → chunk-FOMR74VE.js} +3 -3
- package/dist/{chunk-NF5JM2YO.js.map → chunk-FOMR74VE.js.map} +1 -1
- package/dist/{chunk-FZIHZT5R.js → chunk-GCGX4FEF.js} +16 -10
- package/dist/chunk-GCGX4FEF.js.map +1 -0
- package/dist/{chunk-B2YJKRNQ.js → chunk-HCYULRWT.js} +13 -9
- package/dist/chunk-HCYULRWT.js.map +1 -0
- package/dist/{chunk-B2LCHXUB.js → chunk-INJUILCN.js} +9 -4
- package/dist/chunk-INJUILCN.js.map +1 -0
- package/dist/{chunk-ZDXQ64A7.js → chunk-K5UWVH6P.js} +5 -5
- package/dist/{chunk-ZDXQ64A7.js.map → chunk-K5UWVH6P.js.map} +1 -1
- package/dist/{chunk-6GDMSENK.js → chunk-LM6F6DLR.js} +3 -24
- package/dist/chunk-LM6F6DLR.js.map +1 -0
- package/dist/{chunk-KHMFNH3X.js → chunk-MQO42HZL.js} +7 -7
- package/dist/chunk-MQO42HZL.js.map +1 -0
- package/dist/chunk-OC7I2CTA.js +8 -0
- package/dist/chunk-OC7I2CTA.js.map +1 -0
- package/dist/{chunk-O23Y5ML4.js → chunk-OGJFDNIS.js} +249 -231
- package/dist/chunk-OGJFDNIS.js.map +1 -0
- package/dist/{chunk-6OLTJYSX.js → chunk-PINENGML.js} +12 -5
- package/dist/chunk-PINENGML.js.map +1 -0
- package/dist/{chunk-NSDM3FEB.js → chunk-PS2PZFXH.js} +5 -3
- package/dist/chunk-PS2PZFXH.js.map +1 -0
- package/dist/{chunk-RAUOFTUH.js → chunk-QIDAXFKK.js} +4 -4
- package/dist/{chunk-RAUOFTUH.js.map → chunk-QIDAXFKK.js.map} +1 -1
- package/dist/{chunk-S7N4LGLZ.js → chunk-RIP5G47F.js} +4 -4
- package/dist/{chunk-S7N4LGLZ.js.map → chunk-RIP5G47F.js.map} +1 -1
- package/dist/{chunk-Z2Z5EXVT.js → chunk-RKYXG6X7.js} +3 -3
- package/dist/{chunk-Z2Z5EXVT.js.map → chunk-RKYXG6X7.js.map} +1 -1
- package/dist/{chunk-WQN64ZHG.js → chunk-SVKU3GUN.js} +10 -6
- package/dist/chunk-SVKU3GUN.js.map +1 -0
- package/dist/{chunk-FHG54IT5.js → chunk-TBTSEPGP.js} +13 -4
- package/dist/chunk-TBTSEPGP.js.map +1 -0
- package/dist/{chunk-HT5JAHR3.js → chunk-UJZIF2BA.js} +20 -9
- package/dist/chunk-UJZIF2BA.js.map +1 -0
- package/dist/{chunk-UHNRAI6V.js → chunk-VZBUQNLX.js} +68 -29
- package/dist/chunk-VZBUQNLX.js.map +1 -0
- package/dist/{chunk-JITF6I7N.js → chunk-WJOHNCYY.js} +11 -4
- package/dist/{chunk-JITF6I7N.js.map → chunk-WJOHNCYY.js.map} +1 -1
- package/dist/{chunk-EBREIC3L.js → chunk-YQHOKMSV.js} +26 -8
- package/dist/chunk-YQHOKMSV.js.map +1 -0
- package/dist/{chunk-WHKKN3ZK.js → chunk-YW6Q6ERX.js} +10 -8
- package/dist/chunk-YW6Q6ERX.js.map +1 -0
- package/dist/{chunk-PH354ECN.js → chunk-Z43YWH4R.js} +13 -4
- package/dist/chunk-Z43YWH4R.js.map +1 -0
- package/dist/{chunk-5OQLFX47.js → chunk-Z6RPMRFH.js} +3 -3
- package/dist/{chunk-5OQLFX47.js.map → chunk-Z6RPMRFH.js.map} +1 -1
- package/dist/{chunk-TCWYBVIL.js → chunk-ZB5VMGKB.js} +10 -7
- package/dist/chunk-ZB5VMGKB.js.map +1 -0
- package/dist/colors.css +15 -10
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/action-icon/index.js +3 -3
- package/dist/components/alert/index.js +3 -3
- package/dist/components/app-shell/index.js +4 -4
- package/dist/components/autocomplete/autocomplete.d.ts +8 -1
- package/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/dist/components/autocomplete/index.d.ts +1 -1
- package/dist/components/autocomplete/index.d.ts.map +1 -1
- package/dist/components/autocomplete/index.js +10 -7
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/badge/index.js +1 -1
- package/dist/components/button/index.js +3 -3
- package/dist/components/button-multi-select/index.js +5 -5
- package/dist/components/button-select/index.js +5 -5
- package/dist/components/calendar/calendar-zone-sync.d.ts +41 -0
- package/dist/components/calendar/calendar-zone-sync.d.ts.map +1 -0
- package/dist/components/calendar/calendar.d.ts +6 -5
- package/dist/components/calendar/calendar.d.ts.map +1 -1
- package/dist/components/calendar/index.js +8 -5
- package/dist/components/chart/chart.d.ts +17 -10
- package/dist/components/chart/chart.d.ts.map +1 -1
- package/dist/components/chart/index.js +50 -7
- package/dist/components/chart/index.js.map +1 -1
- package/dist/components/chart/styles.css +100 -0
- package/dist/components/checkbox/index.js +4 -4
- package/dist/components/choice-card-group/index.d.ts.map +1 -1
- package/dist/components/choice-card-group/index.js +4 -3
- package/dist/components/circular-progress/circular-progress.d.ts.map +1 -1
- package/dist/components/circular-progress/index.js.map +1 -1
- package/dist/components/clipboard/clipboard.d.ts.map +1 -1
- package/dist/components/clipboard/copy.d.ts.map +1 -1
- package/dist/components/clipboard/index.js +5 -5
- package/dist/components/clipboard/index.js.map +1 -1
- package/dist/components/code-block/chrome.js +4 -4
- package/dist/components/code-block/index.js +5 -5
- package/dist/components/combobox/combobox.d.ts +20 -1
- package/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/index.d.ts +1 -1
- package/dist/components/combobox/index.d.ts.map +1 -1
- package/dist/components/combobox/index.js +4 -4
- package/dist/components/combobox-list/combobox-list.d.ts +8 -1
- package/dist/components/combobox-list/combobox-list.d.ts.map +1 -1
- package/dist/components/combobox-list/index.d.ts +1 -1
- package/dist/components/combobox-list/index.d.ts.map +1 -1
- package/dist/components/combobox-list/index.js +5 -5
- package/dist/components/data-table/data-table-filter/data-table-date-filter.d.ts.map +1 -1
- package/dist/components/data-table/data-table-filter/data-table-number-filter.d.ts +4 -1
- package/dist/components/data-table/data-table-filter/data-table-number-filter.d.ts.map +1 -1
- package/dist/components/data-table/data-table-filter/data-table-select-filter.d.ts +4 -1
- package/dist/components/data-table/data-table-filter/data-table-select-filter.d.ts.map +1 -1
- package/dist/components/data-table/data-table-filter/index.d.ts +5 -1
- package/dist/components/data-table/data-table-filter/index.d.ts.map +1 -1
- package/dist/components/data-table/data-table-header-cell.d.ts +11 -15
- package/dist/components/data-table/data-table-header-cell.d.ts.map +1 -1
- package/dist/components/data-table/data-table-meta.d.ts +2 -2
- package/dist/components/data-table/data-table-meta.d.ts.map +1 -1
- package/dist/components/data-table/data-table-pagination.d.ts +3 -0
- package/dist/components/data-table/data-table-pagination.d.ts.map +1 -1
- package/dist/components/data-table/data-table-stack.d.ts +5 -2
- package/dist/components/data-table/data-table-stack.d.ts.map +1 -1
- package/dist/components/data-table/data-table-toolbar.d.ts +3 -1
- package/dist/components/data-table/data-table-toolbar.d.ts.map +1 -1
- package/dist/components/data-table/data-table-translations.d.ts +68 -0
- package/dist/components/data-table/data-table-translations.d.ts.map +1 -0
- package/dist/components/data-table/data-table.d.ts +5 -8
- package/dist/components/data-table/data-table.d.ts.map +1 -1
- package/dist/components/data-table/index.d.ts +2 -1
- package/dist/components/data-table/index.d.ts.map +1 -1
- package/dist/components/data-table/index.js +162 -79
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/date-picker/date-picker.d.ts +13 -9
- package/dist/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/components/date-picker/index.js +16 -15
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/drawer/drawer.d.ts +9 -1
- package/dist/components/drawer/drawer.d.ts.map +1 -1
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/index.d.ts.map +1 -1
- package/dist/components/drawer/index.js +4 -4
- package/dist/components/field/field.d.ts +9 -2
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/index.js +1 -1
- package/dist/components/file-upload/file-upload.d.ts +13 -2
- package/dist/components/file-upload/file-upload.d.ts.map +1 -1
- package/dist/components/file-upload/index.d.ts +1 -1
- package/dist/components/file-upload/index.d.ts.map +1 -1
- package/dist/components/file-upload/index.js +16 -7
- package/dist/components/file-upload/index.js.map +1 -1
- package/dist/components/hover-card/index.js +1 -1
- package/dist/components/input/index.js +2 -2
- package/dist/components/kbd/index.js +1 -1
- package/dist/components/menu/index.js +2 -2
- package/dist/components/modal/index.d.ts +1 -1
- package/dist/components/modal/index.d.ts.map +1 -1
- package/dist/components/modal/index.js +4 -4
- package/dist/components/modal/modal.d.ts +9 -1
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/multi-combobox-list/index.d.ts +1 -1
- package/dist/components/multi-combobox-list/index.d.ts.map +1 -1
- package/dist/components/multi-combobox-list/index.js +7 -5
- package/dist/components/multi-combobox-list/multi-combobox-list.d.ts +8 -1
- package/dist/components/multi-combobox-list/multi-combobox-list.d.ts.map +1 -1
- package/dist/components/multi-select/index.d.ts +1 -1
- package/dist/components/multi-select/index.d.ts.map +1 -1
- package/dist/components/multi-select/index.js +20 -9
- package/dist/components/multi-select/index.js.map +1 -1
- package/dist/components/multi-select/multi-select.d.ts +11 -1
- package/dist/components/multi-select/multi-select.d.ts.map +1 -1
- package/dist/components/nav-link/index.d.ts +1 -1
- package/dist/components/nav-link/index.d.ts.map +1 -1
- package/dist/components/nav-link/index.js +2 -2
- package/dist/components/nav-link/nav-link.d.ts +12 -0
- package/dist/components/nav-link/nav-link.d.ts.map +1 -1
- package/dist/components/nav-link/navigation.d.ts +3 -1
- package/dist/components/nav-link/navigation.d.ts.map +1 -1
- package/dist/components/nav-link/tanstack.js +2 -2
- package/dist/components/notification/create-notifier.d.ts +12 -1
- package/dist/components/notification/create-notifier.d.ts.map +1 -1
- package/dist/components/notification/index.d.ts +2 -2
- package/dist/components/notification/index.d.ts.map +1 -1
- package/dist/components/notification/index.js +9 -6
- package/dist/components/notification/index.js.map +1 -1
- package/dist/components/notification/notification.d.ts +14 -1
- package/dist/components/notification/notification.d.ts.map +1 -1
- package/dist/components/number-input/index.d.ts +1 -1
- package/dist/components/number-input/index.d.ts.map +1 -1
- package/dist/components/number-input/index.js +4 -4
- package/dist/components/number-input/number-input.d.ts +20 -2
- package/dist/components/number-input/number-input.d.ts.map +1 -1
- package/dist/components/overlays/index.js +6 -6
- package/dist/components/password-input/index.d.ts +1 -1
- package/dist/components/password-input/index.d.ts.map +1 -1
- package/dist/components/password-input/index.js +68 -7
- package/dist/components/password-input/index.js.map +1 -1
- package/dist/components/password-input/password-input.d.ts +45 -6
- package/dist/components/password-input/password-input.d.ts.map +1 -1
- package/dist/components/pill/index.js +2 -2
- package/dist/components/pills-input/index.js +5 -5
- package/dist/components/pin-input/index.js +2 -2
- package/dist/components/popover/index.js +1 -1
- package/dist/components/popover/popover.d.ts +0 -10
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/progress/index.js.map +1 -1
- package/dist/components/progress/progress.d.ts.map +1 -1
- package/dist/components/radio-group/index.js +3 -3
- package/dist/components/rating/index.js +2 -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 +60 -48
- package/dist/components/schedule/index.js.map +1 -1
- package/dist/components/schedule/now-cursor-line.d.ts +10 -5
- package/dist/components/schedule/now-cursor-line.d.ts.map +1 -1
- package/dist/components/schedule/schedule-dates.d.ts +11 -26
- package/dist/components/schedule/schedule-dates.d.ts.map +1 -1
- package/dist/components/schedule/schedule-event-chip.d.ts +4 -1
- package/dist/components/schedule/schedule-event-chip.d.ts.map +1 -1
- package/dist/components/schedule/schedule-event-details.d.ts +3 -2
- package/dist/components/schedule/schedule-event-details.d.ts.map +1 -1
- package/dist/components/schedule/schedule-geometry.d.ts +20 -21
- package/dist/components/schedule/schedule-geometry.d.ts.map +1 -1
- package/dist/components/schedule/schedule-grid-gesture.d.ts +5 -9
- package/dist/components/schedule/schedule-grid-gesture.d.ts.map +1 -1
- package/dist/components/schedule/schedule-segments.d.ts +2 -3
- package/dist/components/schedule/schedule-segments.d.ts.map +1 -1
- package/dist/components/schedule/schedule-timed-grid.d.ts.map +1 -1
- package/dist/components/schedule/use-event-resize.d.ts.map +1 -1
- package/dist/components/segment-group/index.js +4 -3
- package/dist/components/segment-group/segment-group.d.ts +3 -2
- package/dist/components/segment-group/segment-group.d.ts.map +1 -1
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/index.d.ts.map +1 -1
- package/dist/components/select/index.js +6 -4
- package/dist/components/select/select.d.ts +12 -2
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/slider/index.js +2 -2
- package/dist/components/spinner/index.js +1 -1
- package/dist/components/spinner/spinner.d.ts.map +1 -1
- package/dist/components/switch/index.js +2 -2
- package/dist/components/table/index.js +1 -1
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/tabs/index.js +4 -3
- package/dist/components/tabs/tabs.d.ts +3 -1
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tags-input/index.d.ts +1 -1
- package/dist/components/tags-input/index.d.ts.map +1 -1
- package/dist/components/tags-input/index.js +9 -7
- package/dist/components/tags-input/index.js.map +1 -1
- package/dist/components/tags-input/tags-input.d.ts +9 -2
- 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 +2 -2
- package/dist/components/theme-icon/index.js +2 -2
- package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
- package/dist/components/time-input/index.js +24 -8
- package/dist/components/time-input/index.js.map +1 -1
- package/dist/components/time-input/time-input.d.ts.map +1 -1
- package/dist/components/time-input/time-row.d.ts +16 -3
- package/dist/components/time-input/time-row.d.ts.map +1 -1
- package/dist/components/timeline/index.js +11 -3
- package/dist/components/timeline/index.js.map +1 -1
- package/dist/components/timeline/timeline.d.ts.map +1 -1
- package/dist/components/tooltip/index.js +2 -2
- package/dist/components/tree-multi-select/index.d.ts +1 -1
- package/dist/components/tree-multi-select/index.d.ts.map +1 -1
- package/dist/components/tree-multi-select/index.js +62 -44
- package/dist/components/tree-multi-select/index.js.map +1 -1
- package/dist/components/tree-multi-select/tree-multi-select.d.ts +10 -1
- package/dist/components/tree-multi-select/tree-multi-select.d.ts.map +1 -1
- package/dist/components/tree-select/index.d.ts +1 -1
- package/dist/components/tree-select/index.d.ts.map +1 -1
- package/dist/components/tree-select/index.js +45 -15
- package/dist/components/tree-select/index.js.map +1 -1
- package/dist/components/tree-select/tree-select.d.ts +10 -1
- package/dist/components/tree-select/tree-select.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/date-value.d.ts +14 -1
- package/dist/lib/date-value.d.ts.map +1 -1
- package/dist/lib/focus-styles.d.ts +13 -5
- package/dist/lib/focus-styles.d.ts.map +1 -1
- package/dist/theme.css +24 -2
- package/package.json +1 -1
- package/src/colors.css +15 -10
- package/src/components/autocomplete/autocomplete.test.tsx +32 -0
- package/src/components/autocomplete/autocomplete.tsx +17 -5
- package/src/components/autocomplete/index.ts +5 -1
- package/src/components/button/button.test.tsx +6 -0
- package/src/components/calendar/calendar-zone-sync.tsx +79 -0
- package/src/components/calendar/calendar.test.tsx +134 -14
- package/src/components/calendar/calendar.tsx +36 -22
- package/src/components/chart/chart.test.tsx +115 -8
- package/src/components/chart/chart.tsx +115 -25
- package/src/components/chart/styles.css +100 -0
- package/src/components/choice-card-group/index.ts +2 -0
- package/src/components/circular-progress/circular-progress.tsx +2 -0
- package/src/components/clipboard/clipboard.test.tsx +54 -22
- package/src/components/clipboard/clipboard.tsx +2 -0
- package/src/components/clipboard/copy.tsx +2 -0
- package/src/components/clipboard/index.ts +3 -3
- package/src/components/combobox/combobox.test.tsx +22 -0
- package/src/components/combobox/combobox.tsx +20 -0
- package/src/components/combobox/index.ts +1 -0
- package/src/components/combobox-list/combobox-list.test.tsx +19 -0
- package/src/components/combobox-list/combobox-list.tsx +16 -2
- package/src/components/combobox-list/index.ts +5 -1
- package/src/components/data-table/data-table-filter/data-table-date-filter.tsx +5 -4
- package/src/components/data-table/data-table-filter/data-table-number-filter.tsx +16 -2
- package/src/components/data-table/data-table-filter/data-table-select-filter.tsx +9 -1
- package/src/components/data-table/data-table-filter/index.tsx +15 -1
- package/src/components/data-table/data-table-filter.test.tsx +33 -0
- package/src/components/data-table/data-table-header-cell.tsx +37 -22
- package/src/components/data-table/data-table-meta.ts +2 -2
- package/src/components/data-table/data-table-pagination.tsx +6 -0
- package/src/components/data-table/data-table-stack.tsx +26 -14
- package/src/components/data-table/data-table-toolbar.tsx +4 -1
- package/src/components/data-table/data-table-translations.ts +105 -0
- package/src/components/data-table/data-table.test.tsx +121 -0
- package/src/components/data-table/data-table.tsx +37 -17
- package/src/components/data-table/index.ts +9 -1
- package/src/components/date-picker/date-picker.test.tsx +197 -5
- package/src/components/date-picker/date-picker.tsx +42 -16
- package/src/components/drawer/drawer.tsx +14 -1
- package/src/components/drawer/index.ts +1 -0
- package/src/components/field/field.tsx +29 -3
- package/src/components/file-upload/file-upload.test.tsx +21 -0
- package/src/components/file-upload/file-upload.tsx +26 -3
- package/src/components/file-upload/index.ts +1 -1
- package/src/components/modal/index.ts +1 -0
- package/src/components/modal/modal-translations.test.tsx +27 -0
- package/src/components/modal/modal.tsx +14 -1
- package/src/components/multi-combobox-list/index.ts +5 -1
- package/src/components/multi-combobox-list/multi-combobox-list.test.tsx +19 -0
- package/src/components/multi-combobox-list/multi-combobox-list.tsx +26 -4
- package/src/components/multi-select/index.ts +1 -1
- package/src/components/multi-select/multi-select.test.tsx +38 -0
- package/src/components/multi-select/multi-select.tsx +28 -4
- package/src/components/nav-link/index.ts +6 -1
- package/src/components/nav-link/nav-link.test.tsx +16 -0
- package/src/components/nav-link/nav-link.tsx +19 -1
- package/src/components/nav-link/navigation.test.tsx +18 -0
- package/src/components/nav-link/navigation.tsx +8 -4
- package/src/components/notification/create-notifier.tsx +20 -4
- package/src/components/notification/index.ts +7 -1
- package/src/components/notification/notification.test.tsx +49 -0
- package/src/components/notification/notification.tsx +39 -5
- package/src/components/number-input/index.ts +1 -1
- package/src/components/number-input/number-input.test.tsx +37 -0
- package/src/components/number-input/number-input.tsx +33 -4
- package/src/components/password-input/index.ts +5 -1
- package/src/components/password-input/password-input.test.tsx +201 -4
- package/src/components/password-input/password-input.tsx +162 -13
- package/src/components/popover/popover.tsx +0 -29
- package/src/components/progress/index.ts +3 -3
- package/src/components/progress/progress.tsx +2 -0
- package/src/components/rating/rating.tsx +2 -0
- package/src/components/schedule/now-cursor-line.test.tsx +56 -28
- package/src/components/schedule/now-cursor-line.tsx +30 -16
- package/src/components/schedule/schedule-agenda-view.test.tsx +1 -1
- package/src/components/schedule/schedule-dates.test.ts +19 -0
- package/src/components/schedule/schedule-dates.ts +16 -30
- package/src/components/schedule/schedule-details-popover.test.tsx +77 -6
- package/src/components/schedule/schedule-event-chip.tsx +17 -6
- package/src/components/schedule/schedule-event-details.test.tsx +38 -0
- package/src/components/schedule/schedule-event-details.tsx +7 -5
- package/src/components/schedule/schedule-geometry.test.ts +21 -18
- package/src/components/schedule/schedule-geometry.ts +37 -24
- package/src/components/schedule/schedule-grid-gesture.ts +5 -9
- package/src/components/schedule/schedule-segments.ts +2 -3
- package/src/components/schedule/schedule-timed-grid.tsx +43 -20
- package/src/components/schedule/schedule.test.tsx +34 -11
- package/src/components/schedule/use-event-resize.ts +6 -13
- package/src/components/segment-group/segment-group.test.tsx +23 -0
- package/src/components/segment-group/segment-group.tsx +13 -7
- package/src/components/select/index.ts +1 -1
- package/src/components/select/select.test.tsx +32 -0
- package/src/components/select/select.tsx +15 -1
- package/src/components/spinner/spinner.test.tsx +26 -0
- package/src/components/spinner/spinner.tsx +4 -1
- package/src/components/table/table.test.tsx +13 -0
- package/src/components/table/table.tsx +9 -5
- package/src/components/tabs/tabs.test.tsx +11 -0
- package/src/components/tabs/tabs.tsx +6 -4
- package/src/components/tags-input/index.ts +1 -1
- package/src/components/tags-input/tags-input.test.tsx +28 -0
- package/src/components/tags-input/tags-input.tsx +17 -1
- package/src/components/theme-icon/theme-icon.tsx +8 -3
- package/src/components/time-input/time-input.test.tsx +75 -0
- package/src/components/time-input/time-input.tsx +27 -3
- package/src/components/time-input/time-row.tsx +27 -3
- package/src/components/timeline/timeline.test.tsx +4 -1
- package/src/components/timeline/timeline.tsx +11 -3
- package/src/components/tree-multi-select/index.ts +5 -1
- package/src/components/tree-multi-select/tree-multi-select.test.tsx +72 -0
- package/src/components/tree-multi-select/tree-multi-select.tsx +156 -115
- package/src/components/tree-select/index.ts +1 -1
- package/src/components/tree-select/tree-select.test.tsx +69 -0
- package/src/components/tree-select/tree-select.tsx +128 -74
- package/src/lib/date-value.test.ts +19 -0
- package/src/lib/date-value.ts +21 -5
- package/src/lib/focus-styles.test.ts +21 -2
- package/src/lib/focus-styles.ts +24 -5
- package/src/theme.css +24 -2
- package/src/use-client-barrels.test.ts +80 -0
- package/dist/chunk-5JHDSVEZ.js.map +0 -1
- package/dist/chunk-6GDMSENK.js.map +0 -1
- package/dist/chunk-6OLTJYSX.js.map +0 -1
- package/dist/chunk-7NZSTCJO.js.map +0 -1
- package/dist/chunk-B2LCHXUB.js.map +0 -1
- package/dist/chunk-B2YJKRNQ.js.map +0 -1
- package/dist/chunk-EBREIC3L.js.map +0 -1
- package/dist/chunk-FHG54IT5.js.map +0 -1
- package/dist/chunk-FZIHZT5R.js.map +0 -1
- package/dist/chunk-HT5JAHR3.js.map +0 -1
- package/dist/chunk-KHMFNH3X.js.map +0 -1
- package/dist/chunk-NSDM3FEB.js.map +0 -1
- package/dist/chunk-O23Y5ML4.js.map +0 -1
- package/dist/chunk-PH354ECN.js.map +0 -1
- package/dist/chunk-RQL7FVCS.js.map +0 -1
- package/dist/chunk-TCWYBVIL.js.map +0 -1
- package/dist/chunk-UHNRAI6V.js.map +0 -1
- package/dist/chunk-WHKKN3ZK.js.map +0 -1
- package/dist/chunk-WQN64ZHG.js.map +0 -1
- package/dist/chunk-YBJB7FGE.js.map +0 -1
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
import { useFieldContext } from "@ark-ui/react/field"
|
|
3
4
|
import { cva } from "class-variance-authority"
|
|
4
5
|
import {
|
|
6
|
+
type ComponentProps,
|
|
5
7
|
type FocusEvent,
|
|
6
8
|
Fragment,
|
|
7
9
|
type ReactNode,
|
|
8
10
|
type Ref,
|
|
9
11
|
useEffect,
|
|
12
|
+
useId,
|
|
10
13
|
useMemo,
|
|
11
14
|
useRef,
|
|
12
15
|
useState,
|
|
13
16
|
} from "react"
|
|
14
17
|
import { cn } from "../../lib/cn"
|
|
15
18
|
import type { Color } from "../../lib/colors"
|
|
19
|
+
import { focusStyles } from "../../lib/focus-styles"
|
|
16
20
|
import { props } from "../../lib/props"
|
|
17
21
|
import type { ClearSectionMode } from "../../lib/select-data"
|
|
18
22
|
import type { WithTestId } from "../../lib/test-id"
|
|
@@ -28,7 +32,8 @@ import {
|
|
|
28
32
|
type TreeValue,
|
|
29
33
|
} from "../../lib/tree-data"
|
|
30
34
|
import { useUncontrolled } from "../../lib/use-uncontrolled"
|
|
31
|
-
import
|
|
35
|
+
import type { ComboboxTranslations } from "../combobox/combobox"
|
|
36
|
+
import { type FieldProps, FieldShell, fieldA11yProps } from "../field/field"
|
|
32
37
|
import {
|
|
33
38
|
type InputSize,
|
|
34
39
|
type InputVariant,
|
|
@@ -90,7 +95,10 @@ const treeLeafRow = cn(
|
|
|
90
95
|
"hover:bg-black/5 dark:hover:bg-white/8",
|
|
91
96
|
"data-active:bg-black/5 dark:data-active:bg-white/8",
|
|
92
97
|
"data-disabled:pointer-events-none data-disabled:opacity-50",
|
|
93
|
-
|
|
98
|
+
// Palette, not brand: the focused row is also the active one, and brand-500
|
|
99
|
+
// measured 2.73:1 against that light fill. `--c-text` (the popover's
|
|
100
|
+
// `data-color`, neutral by default) clears it in both themes.
|
|
101
|
+
focusStyles({ ring: "palette", offset: false, inset: true }),
|
|
94
102
|
)
|
|
95
103
|
|
|
96
104
|
/** A branch row — organizational only: a non-focusable `treeitem` present for
|
|
@@ -159,8 +167,49 @@ export type TreeSelectProps<Data extends TreeSelectData = TreeNodeData[]> = Pick
|
|
|
159
167
|
ref?: Ref<HTMLDivElement>
|
|
160
168
|
className?: string
|
|
161
169
|
classNames?: TreeSelectClassNames
|
|
170
|
+
/** Overrides the clear button's (`clearTriggerLabel`, default `"Clear"`) and the search
|
|
171
|
+
* field's (`searchLabel`, default `"Search"`) accessible names. A partial override keeps the
|
|
172
|
+
* other default. */
|
|
173
|
+
translations?: TreeSelectTranslations
|
|
162
174
|
}
|
|
163
175
|
|
|
176
|
+
/** The combobox family's `clearTriggerLabel`, plus the popover search field's `searchLabel`. */
|
|
177
|
+
export type TreeSelectTranslations = Pick<ComboboxTranslations, "clearTriggerLabel"> & {
|
|
178
|
+
searchLabel?: string
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const TREE_SELECT_DEFAULT_TRANSLATIONS = {
|
|
182
|
+
clearTriggerLabel: "Clear",
|
|
183
|
+
searchLabel: "Search",
|
|
184
|
+
} as const satisfies TreeSelectTranslations
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The real, focusable `<div role="combobox">`, split out so it reads the
|
|
188
|
+
* `Field` context from *inside* the wrapping `FieldShell` — `TreeSelect` itself
|
|
189
|
+
* renders that shell, so calling `useFieldContext()` at its own top level
|
|
190
|
+
* would run too early. `Popover.Trigger` stamps its own id on the element, so
|
|
191
|
+
* the `<label for>` never reaches it: the name comes from `aria-labelledby`.
|
|
192
|
+
*/
|
|
193
|
+
const TreeSelectTrigger = ({
|
|
194
|
+
open,
|
|
195
|
+
disabled,
|
|
196
|
+
...rest
|
|
197
|
+
}: Omit<ComponentProps<"div">, "role" | "tabIndex"> & { open: boolean; disabled?: boolean }) => {
|
|
198
|
+
const field = useFieldContext()
|
|
199
|
+
return (
|
|
200
|
+
<Popover.Trigger asChild>
|
|
201
|
+
<div
|
|
202
|
+
role="combobox"
|
|
203
|
+
aria-expanded={open}
|
|
204
|
+
aria-haspopup="tree"
|
|
205
|
+
tabIndex={disabled ? -1 : 0}
|
|
206
|
+
{...fieldA11yProps(field)}
|
|
207
|
+
{...rest}
|
|
208
|
+
/>
|
|
209
|
+
</Popover.Trigger>
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
|
|
164
213
|
export const TreeSelect = <const Data extends TreeSelectData = TreeNodeData[]>({
|
|
165
214
|
data,
|
|
166
215
|
value: valueProp,
|
|
@@ -191,7 +240,9 @@ export const TreeSelect = <const Data extends TreeSelectData = TreeNodeData[]>({
|
|
|
191
240
|
className,
|
|
192
241
|
classNames,
|
|
193
242
|
testId,
|
|
243
|
+
translations,
|
|
194
244
|
}: TreeSelectProps<Data>) => {
|
|
245
|
+
const resolvedTranslations = { ...TREE_SELECT_DEFAULT_TRANSLATIONS, ...translations }
|
|
195
246
|
const [value, setValue] = useUncontrolled<TreeValue<Data> | null>({
|
|
196
247
|
value: valueProp,
|
|
197
248
|
defaultValue: defaultValue ?? null,
|
|
@@ -199,6 +250,7 @@ export const TreeSelect = <const Data extends TreeSelectData = TreeNodeData[]>({
|
|
|
199
250
|
finalValue: null,
|
|
200
251
|
})
|
|
201
252
|
const [open, setOpen] = useState(false)
|
|
253
|
+
const treeId = useId()
|
|
202
254
|
const [search, setSearch] = useState("")
|
|
203
255
|
|
|
204
256
|
// Red state is driven independently of the `Field` error slot so a form
|
|
@@ -495,79 +547,80 @@ export const TreeSelect = <const Data extends TreeSelectData = TreeNodeData[]>({
|
|
|
495
547
|
autoFocus={false}
|
|
496
548
|
width="target"
|
|
497
549
|
>
|
|
498
|
-
<
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
<span className="min-w-0 flex-1 truncate text-start">
|
|
539
|
-
{value != null ? (
|
|
540
|
-
(labelMap.get(value) ?? value)
|
|
541
|
-
) : (
|
|
542
|
-
<span className={placeholderColor}>{placeholder}</span>
|
|
543
|
-
)}
|
|
550
|
+
<TreeSelectTrigger
|
|
551
|
+
ref={ref}
|
|
552
|
+
open={open}
|
|
553
|
+
disabled={disabled}
|
|
554
|
+
// Ark points this at the popover's dialog wrapper; point it at the
|
|
555
|
+
// tree itself instead. The content stays mounted while closed, so the
|
|
556
|
+
// (hidden) tree is a valid target then too, as in the APG combobox.
|
|
557
|
+
// With no tree (search matched nothing), Ark's own target stands.
|
|
558
|
+
aria-controls={flat.length > 0 ? treeId : undefined}
|
|
559
|
+
aria-invalid={isInvalid || undefined}
|
|
560
|
+
data-color={color}
|
|
561
|
+
{...props({
|
|
562
|
+
"data-disabled": disabled,
|
|
563
|
+
"data-readonly": readOnly,
|
|
564
|
+
"data-invalid": isInvalid,
|
|
565
|
+
"data-with-start-slot": startSlot != null,
|
|
566
|
+
// The trigger always ends in a chevron (and optional clear).
|
|
567
|
+
"data-with-end-slot": true,
|
|
568
|
+
// The shell IS the tabbable/focusable element here (no separate
|
|
569
|
+
// inner control to route to), so `testId` lands directly on it.
|
|
570
|
+
"data-testid": testId,
|
|
571
|
+
})}
|
|
572
|
+
onBlur={onBlur}
|
|
573
|
+
onKeyDown={(event) => {
|
|
574
|
+
if (disabled || readOnly) return
|
|
575
|
+
if (event.key === "Enter" || event.key === " " || event.key === "ArrowDown") {
|
|
576
|
+
event.preventDefault()
|
|
577
|
+
setOpen(true)
|
|
578
|
+
}
|
|
579
|
+
}}
|
|
580
|
+
className={cn(
|
|
581
|
+
inputShell({ size, variant }),
|
|
582
|
+
"cursor-pointer",
|
|
583
|
+
className,
|
|
584
|
+
classNames?.trigger,
|
|
585
|
+
)}
|
|
586
|
+
>
|
|
587
|
+
{startSlot != null && (
|
|
588
|
+
<span className={inputSlot} aria-hidden>
|
|
589
|
+
{startSlot}
|
|
544
590
|
</span>
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
{
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
onPointerDown={(event) => {
|
|
552
|
-
event.preventDefault()
|
|
553
|
-
event.stopPropagation()
|
|
554
|
-
}}
|
|
555
|
-
onClick={(event) => {
|
|
556
|
-
event.stopPropagation()
|
|
557
|
-
setValue(null)
|
|
558
|
-
}}
|
|
559
|
-
className={popoverClearTrigger}
|
|
560
|
-
>
|
|
561
|
-
<CloseIcon />
|
|
562
|
-
</button>
|
|
563
|
-
)}
|
|
564
|
-
{(clearSectionMode === "both" || !showClear) && (
|
|
565
|
-
<span aria-hidden data-chevron className={cn(popoverChevron, open && "rotate-180")}>
|
|
566
|
-
<ChevronIcon />
|
|
567
|
-
</span>
|
|
591
|
+
)}
|
|
592
|
+
<span className="min-w-0 flex-1 truncate text-start">
|
|
593
|
+
{value != null ? (
|
|
594
|
+
(labelMap.get(value) ?? value)
|
|
595
|
+
) : (
|
|
596
|
+
<span className={placeholderColor}>{placeholder}</span>
|
|
568
597
|
)}
|
|
569
|
-
</
|
|
570
|
-
|
|
598
|
+
</span>
|
|
599
|
+
|
|
600
|
+
{endSlot != null && <span className={inputSlot}>{endSlot}</span>}
|
|
601
|
+
{showClear && (
|
|
602
|
+
<button
|
|
603
|
+
type="button"
|
|
604
|
+
aria-label={resolvedTranslations.clearTriggerLabel}
|
|
605
|
+
onPointerDown={(event) => {
|
|
606
|
+
event.preventDefault()
|
|
607
|
+
event.stopPropagation()
|
|
608
|
+
}}
|
|
609
|
+
onClick={(event) => {
|
|
610
|
+
event.stopPropagation()
|
|
611
|
+
setValue(null)
|
|
612
|
+
}}
|
|
613
|
+
className={popoverClearTrigger}
|
|
614
|
+
>
|
|
615
|
+
<CloseIcon />
|
|
616
|
+
</button>
|
|
617
|
+
)}
|
|
618
|
+
{(clearSectionMode === "both" || !showClear) && (
|
|
619
|
+
<span aria-hidden data-chevron className={cn(popoverChevron, open && "rotate-180")}>
|
|
620
|
+
<ChevronIcon />
|
|
621
|
+
</span>
|
|
622
|
+
)}
|
|
623
|
+
</TreeSelectTrigger>
|
|
571
624
|
|
|
572
625
|
<Popover.Content data-color={color} className={classNames?.popover}>
|
|
573
626
|
{searchable && (
|
|
@@ -579,7 +632,7 @@ export const TreeSelect = <const Data extends TreeSelectData = TreeNodeData[]>({
|
|
|
579
632
|
onChange={(event) => setSearch(event.target.value)}
|
|
580
633
|
onKeyDown={onSearchKeyDown}
|
|
581
634
|
placeholder={searchPlaceholder}
|
|
582
|
-
aria-label=
|
|
635
|
+
aria-label={resolvedTranslations.searchLabel}
|
|
583
636
|
className={cn(inputControlClasses, "text-sm", classNames?.search)}
|
|
584
637
|
/>
|
|
585
638
|
</Popover.Header>
|
|
@@ -590,6 +643,7 @@ export const TreeSelect = <const Data extends TreeSelectData = TreeNodeData[]>({
|
|
|
590
643
|
<div className={popoverEmpty}>{empty}</div>
|
|
591
644
|
) : (
|
|
592
645
|
<div
|
|
646
|
+
id={treeId}
|
|
593
647
|
role="tree"
|
|
594
648
|
aria-orientation="vertical"
|
|
595
649
|
onKeyDown={onTreeKeyDown}
|
|
@@ -3,6 +3,7 @@ import { describe, expect, it } from "vitest"
|
|
|
3
3
|
import {
|
|
4
4
|
calendarValueToDate,
|
|
5
5
|
type DateRangeValue,
|
|
6
|
+
dateToArkValue,
|
|
6
7
|
dateToCalendarValue,
|
|
7
8
|
fromArkValues,
|
|
8
9
|
toArkValues,
|
|
@@ -41,6 +42,24 @@ describe("dateToCalendarValue / calendarValueToDate", () => {
|
|
|
41
42
|
})
|
|
42
43
|
})
|
|
43
44
|
|
|
45
|
+
describe("dateToArkValue", () => {
|
|
46
|
+
it("holds the wall-clock date and time in the zone, with no zone of its own", () => {
|
|
47
|
+
const instant = new Date("2026-06-15T02:30:00.000Z")
|
|
48
|
+
const value = dateToArkValue(instant, "America/New_York")
|
|
49
|
+
expect("timeZone" in value).toBe(false)
|
|
50
|
+
expect(value.toString()).toBe("2026-06-14T22:30:00")
|
|
51
|
+
expect(calendarValueToDate(value, "America/New_York").getTime()).toBe(instant.getTime())
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it("re-reads as another instant in another zone, which is why a zone change converts it", () => {
|
|
55
|
+
const instant = new Date("2026-06-15T02:30:00.000Z")
|
|
56
|
+
const value = dateToArkValue(instant, "America/New_York")
|
|
57
|
+
expect(calendarValueToDate(value, "Europe/Paris").getTime()).not.toBe(instant.getTime())
|
|
58
|
+
const moved = dateToArkValue(calendarValueToDate(value, "America/New_York"), "Europe/Paris")
|
|
59
|
+
expect(moved.toString()).toBe("2026-06-15T04:30:00")
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
44
63
|
describe("toArkValues", () => {
|
|
45
64
|
it("undefined stays uncontrolled", () => {
|
|
46
65
|
expect(toArkValues(undefined, "UTC")).toBeUndefined()
|
package/src/lib/date-value.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DateValue, fromDate } from "@internationalized/date"
|
|
1
|
+
import { type DateValue, fromDate, toCalendarDateTime } from "@internationalized/date"
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The `Date ↔ DateValue` boundary (RFC §4/§13, `docs/rfcs/date-picker.md`) — the one place a
|
|
@@ -23,6 +23,22 @@ export function dateToCalendarValue(date: Date, timeZone: string): DateValue {
|
|
|
23
23
|
return fromDate(date, timeZone)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Convert a native `Date` instant to the value handed to Ark's machine: the wall-clock date and
|
|
28
|
+
* time it reads as in `timeZone`, as a zone-free `CalendarDateTime`.
|
|
29
|
+
*
|
|
30
|
+
* Not a `ZonedDateTime`, although that is what `dateToCalendarValue` returns, because Ark copies
|
|
31
|
+
* the zone of whatever it is handed into everything it derives from it: the focused day, the
|
|
32
|
+
* visible month, and through those every grid cell, and a pick keeps the zone of the cell it came
|
|
33
|
+
* from. So when the component's zone changes (`timeZone="auto"` after hydration, or the app's
|
|
34
|
+
* `IntlProvider`), the grid would go on producing picks in the *old* zone. Kept zone-free, the
|
|
35
|
+
* machine only ever holds wall-clock values, and the one zone that turns them back into instants
|
|
36
|
+
* is the component's current one, passed to `calendarValueToDate`.
|
|
37
|
+
*/
|
|
38
|
+
export function dateToArkValue(date: Date, timeZone: string): DateValue {
|
|
39
|
+
return toCalendarDateTime(fromDate(date, timeZone))
|
|
40
|
+
}
|
|
41
|
+
|
|
26
42
|
/**
|
|
27
43
|
* Convert Ark's `DateValue` back to a native `Date`. A `ZonedDateTime` (what `dateToCalendarValue`
|
|
28
44
|
* produces) already carries its own zone/offset — its `toDate()` takes no argument and would
|
|
@@ -36,7 +52,7 @@ export function calendarValueToDate(value: DateValue, timeZone: string): Date {
|
|
|
36
52
|
}
|
|
37
53
|
|
|
38
54
|
/**
|
|
39
|
-
* Wrap a public value into Ark's array contract
|
|
55
|
+
* Wrap a public value into Ark's array contract, each `Date` through `dateToArkValue`. `undefined` stays uncontrolled (Ark's own
|
|
40
56
|
* default takes over); `null` — or an all-null range — clears to `[]`; a single `Date` becomes a
|
|
41
57
|
* one-element array; a range pushes only its defined ends, so a mid-selection range
|
|
42
58
|
* (`{ start, end: null }`) naturally comes out length 1.
|
|
@@ -47,10 +63,10 @@ export function toArkValues(
|
|
|
47
63
|
): DateValue[] | undefined {
|
|
48
64
|
if (value === undefined) return undefined
|
|
49
65
|
if (value === null) return []
|
|
50
|
-
if (value instanceof Date) return [
|
|
66
|
+
if (value instanceof Date) return [dateToArkValue(value, timeZone)]
|
|
51
67
|
const values: DateValue[] = []
|
|
52
|
-
if (value.start !== null) values.push(
|
|
53
|
-
if (value.end !== null) values.push(
|
|
68
|
+
if (value.start !== null) values.push(dateToArkValue(value.start, timeZone))
|
|
69
|
+
if (value.end !== null) values.push(dateToArkValue(value.end, timeZone))
|
|
54
70
|
return values
|
|
55
71
|
}
|
|
56
72
|
|
|
@@ -7,10 +7,13 @@ import { type FocusRing, type FocusSource, focusStyles } from "./focus-styles"
|
|
|
7
7
|
const SOURCES: FocusSource[] = ["focus-visible", "data-focus-visible"]
|
|
8
8
|
const RINGS: FocusRing[] = ["brand", "palette"]
|
|
9
9
|
const OFFSETS = [true, false]
|
|
10
|
+
const INSETS = [false, true]
|
|
10
11
|
|
|
11
|
-
/** Every reachable combination of the
|
|
12
|
+
/** Every reachable combination of the four axes. */
|
|
12
13
|
const MATRIX = SOURCES.flatMap((source) =>
|
|
13
|
-
RINGS.flatMap((ring) =>
|
|
14
|
+
RINGS.flatMap((ring) =>
|
|
15
|
+
OFFSETS.flatMap((offset) => INSETS.map((inset) => ({ source, ring, offset, inset }))),
|
|
16
|
+
),
|
|
14
17
|
)
|
|
15
18
|
|
|
16
19
|
/** A ring *color* or *width* class, excluding `ring-offset-*` and `ring-inset`. */
|
|
@@ -34,6 +37,22 @@ describe("focusStyles", () => {
|
|
|
34
37
|
)
|
|
35
38
|
})
|
|
36
39
|
|
|
40
|
+
// Tree rows stack flush inside a scroller, so their ring sits inside the edge.
|
|
41
|
+
it("emits the documented string for an inset ring", () => {
|
|
42
|
+
expect(focusStyles({ offset: false, inset: true })).toBe(
|
|
43
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-inset",
|
|
44
|
+
)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it("adds ring-inset only when asked, keyed off the requested source", () => {
|
|
48
|
+
for (const options of MATRIX) {
|
|
49
|
+
const insets = tokensOf(focusStyles(options)).filter((token) => token.endsWith("ring-inset"))
|
|
50
|
+
expect(insets, JSON.stringify(options)).toEqual(
|
|
51
|
+
options.inset ? [`${options.source}:ring-inset`] : [],
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
37
56
|
// Tailwind v4 scans the *built* JS for whole class literals. A class only
|
|
38
57
|
// ever produced by concatenation is never generated, and the ring vanishes in
|
|
39
58
|
// consumer builds with no error anywhere. Nothing else catches this.
|
package/src/lib/focus-styles.ts
CHANGED
|
@@ -68,6 +68,15 @@ const FOCUS_OFFSET: Record<FocusSource, string> = {
|
|
|
68
68
|
"data-focus-visible:ring-offset-2 data-focus-visible:ring-offset-brand-50 dark:data-focus-visible:ring-offset-brand-950",
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* The inset modifier, per source. Kept as whole literals for the same Tailwind
|
|
73
|
+
* scanning reason as `FOCUS_RING`.
|
|
74
|
+
*/
|
|
75
|
+
const FOCUS_INSET: Record<FocusSource, string> = {
|
|
76
|
+
"focus-visible": "focus-visible:ring-inset",
|
|
77
|
+
"data-focus-visible": "data-focus-visible:ring-inset",
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
export type FocusStylesOptions = {
|
|
72
81
|
/**
|
|
73
82
|
* Where the focused state lives — the CSS pseudo-class (default), or Zag's
|
|
@@ -88,6 +97,14 @@ export type FocusStylesOptions = {
|
|
|
88
97
|
* mismatched hole and you want to supply your own `ring-offset-*` colors.
|
|
89
98
|
*/
|
|
90
99
|
offset?: boolean
|
|
100
|
+
/**
|
|
101
|
+
* Draw the ring *inside* the element's edge instead of around it. For rows
|
|
102
|
+
* stacked flush in a scroller (`TreeSelect`'s tree): an outer ring would be
|
|
103
|
+
* clipped by the scroller's edge and painted under by the next row. Pair it
|
|
104
|
+
* with `offset: false` — an inset gap would sit inside the row, in the page
|
|
105
|
+
* color rather than the surface's.
|
|
106
|
+
*/
|
|
107
|
+
inset?: boolean
|
|
91
108
|
}
|
|
92
109
|
|
|
93
110
|
/**
|
|
@@ -105,7 +122,7 @@ export type FocusStylesOptions = {
|
|
|
105
122
|
* <button type="button" className={cn(focusStyles(), "rounded-full")}>…</button>
|
|
106
123
|
* ```
|
|
107
124
|
*
|
|
108
|
-
*
|
|
125
|
+
* Four axes, and only four. Width and alpha are deliberately *not* options:
|
|
109
126
|
* the point of a single ring is that a keyboard user never has to re-learn what
|
|
110
127
|
* "focused" looks like, so every ring the kit draws is 2px and fully opaque.
|
|
111
128
|
*
|
|
@@ -116,6 +133,9 @@ export type FocusStylesOptions = {
|
|
|
116
133
|
* button get the same ring. `ring: "palette"` is the exception, for a control
|
|
117
134
|
* nested inside a surface that already carries the palette.
|
|
118
135
|
*
|
|
136
|
+
* `inset: true` moves the ring inside the element's edge, for rows stacked flush
|
|
137
|
+
* in a scroller (`TreeSelect`, `TreeMultiSelect`).
|
|
138
|
+
*
|
|
119
139
|
* `offset: true` means *the gap is the page background*. An element on any
|
|
120
140
|
* other surface — a tinted table header, a colored chip — passes
|
|
121
141
|
* `offset: false` and supplies its own `ring-offset-*` pair matched to that
|
|
@@ -125,9 +145,6 @@ export type FocusStylesOptions = {
|
|
|
125
145
|
* - a ring on a **pseudo-element** rather than the element itself (`Schedule`'s
|
|
126
146
|
* resize grip, `DataTable`'s column-resize handle) — it outlines the small
|
|
127
147
|
* visible mark, not the oversized hit box, and has its own shape and offset;
|
|
128
|
-
* - a ring whose color comes from **`currentColor`** (`Notification`'s actions,
|
|
129
|
-
* which inherit the status hue);
|
|
130
|
-
* - **`ring-inset`** rows inside a scroller (`TreeSelect`, `TreeMultiSelect`);
|
|
131
148
|
* - the **shell** idiom — accent border plus a soft halo on a wrapper whose
|
|
132
149
|
* focus lives on a descendant (`Input`'s chrome, `SegmentGroup`'s tray);
|
|
133
150
|
* - a bare `focus:outline-none` with no ring at all, on overlay surfaces that
|
|
@@ -142,4 +159,6 @@ export const focusStyles = ({
|
|
|
142
159
|
source = "focus-visible",
|
|
143
160
|
ring = "brand",
|
|
144
161
|
offset = true,
|
|
145
|
-
|
|
162
|
+
inset = false,
|
|
163
|
+
}: FocusStylesOptions = {}): string =>
|
|
164
|
+
cn(FOCUS_RING[source][ring], offset && FOCUS_OFFSET[source], inset && FOCUS_INSET[source])
|
package/src/theme.css
CHANGED
|
@@ -392,6 +392,29 @@ body {
|
|
|
392
392
|
color: var(--color-gray-dark-50);
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
+
/* Default border color: the kit's hairline. Tailwind v4 dropped v3's default
|
|
396
|
+
border color, so a bare `border` (a Timeline bullet's edge, Schedule's
|
|
397
|
+
time-column divider) paints in `currentColor`: near-black on a white dot,
|
|
398
|
+
a hard white line on dark surfaces. The docs never showed it because
|
|
399
|
+
Fumadocs adds the same kind of rule; any app without Fumadocs did. Layered
|
|
400
|
+
in `base`, under every utility, so a component that sets its own border
|
|
401
|
+
color keeps it. */
|
|
402
|
+
:root {
|
|
403
|
+
--default-border-color: color-mix(in srgb, var(--color-brand-900) 20%, transparent);
|
|
404
|
+
}
|
|
405
|
+
[data-theme="dark"] {
|
|
406
|
+
--default-border-color: color-mix(in srgb, white 15%, transparent);
|
|
407
|
+
}
|
|
408
|
+
@layer base {
|
|
409
|
+
*,
|
|
410
|
+
::after,
|
|
411
|
+
::before,
|
|
412
|
+
::backdrop,
|
|
413
|
+
::file-selector-button {
|
|
414
|
+
border-color: var(--default-border-color, currentColor);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
395
418
|
@keyframes fade-in {
|
|
396
419
|
from {
|
|
397
420
|
opacity: 0;
|
|
@@ -1185,8 +1208,7 @@ body {
|
|
|
1185
1208
|
==========================================
|
|
1186
1209
|
This kit has no dedicated "page background" token — the `body` rule above
|
|
1187
1210
|
only ever sets text color. `Indicator`'s `withBorder` (and, elsewhere,
|
|
1188
|
-
`AvatarGroup`'s cutout border / `
|
|
1189
|
-
gradient border) all need *some* guess at the surrounding surface color so
|
|
1211
|
+
`AvatarGroup`'s cutout border / `Badge`'s gradient border) all need *some* guess at the surrounding surface color so
|
|
1190
1212
|
the ring reads as a seamless cutout rather than a mismatched outline, so
|
|
1191
1213
|
light=white / dark=gray-dark-900 is that guess — a plausible default for
|
|
1192
1214
|
an unstyled page, in both themes.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs"
|
|
2
|
+
import { join, relative, resolve } from "node:path"
|
|
3
|
+
import { describe, expect, it } from "vitest"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* tsup.config.ts decides which dist entries get a `"use client"` banner by
|
|
7
|
+
* reading only the leading directive of each component's barrel `index.ts`,
|
|
8
|
+
* never the files it re-exports. A barrel that forgets the directive therefore
|
|
9
|
+
* ships a client component as a server module, and a React Server Component
|
|
10
|
+
* importing it fails with "Functions cannot be passed to Client Components".
|
|
11
|
+
*
|
|
12
|
+
* So: when any non-test file in a component folder is `"use client"`, its
|
|
13
|
+
* barrel must be too (code-style.md: the directive goes on interactive leaves
|
|
14
|
+
* AND on the barrel).
|
|
15
|
+
*/
|
|
16
|
+
const pkg = resolve(__dirname, "..")
|
|
17
|
+
const componentsDir = resolve(__dirname, "components")
|
|
18
|
+
|
|
19
|
+
// Same check tsup.config.ts runs on each entry.
|
|
20
|
+
const USE_CLIENT_PATTERN = /^\s*(['"])use client\1\s*;?/
|
|
21
|
+
const isClient = (file: string) => USE_CLIENT_PATTERN.test(readFileSync(file, "utf8").slice(0, 200))
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Barrels that are deliberately NOT `"use client"`, with the reason. Each one
|
|
25
|
+
* must still have client leaves — otherwise the entry is stale and must go.
|
|
26
|
+
*/
|
|
27
|
+
const SERVER_BARRELS: Record<string, string> = {
|
|
28
|
+
"code-block":
|
|
29
|
+
"The barrel composes the client `CodeBlock` with the async Server Component " +
|
|
30
|
+
"`CodeBlock.Static`, which a client module cannot import. Its client-only " +
|
|
31
|
+
"chrome ships as its own `code-block/chrome` entry, which earns its own " +
|
|
32
|
+
"banner (see code-block/index.ts and tsup.config.ts).",
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const isSource = (name: string) => /\.tsx?$/.test(name) && !/\.(test|stories)\.tsx?$/.test(name)
|
|
36
|
+
|
|
37
|
+
const components = readdirSync(componentsDir, { withFileTypes: true })
|
|
38
|
+
.filter((entry) => entry.isDirectory() && existsSync(join(componentsDir, entry.name, "index.ts")))
|
|
39
|
+
.map(({ name }) => {
|
|
40
|
+
const dir = join(componentsDir, name)
|
|
41
|
+
const barrel = join(dir, "index.ts")
|
|
42
|
+
const clientLeaves = readdirSync(dir, { recursive: true, encoding: "utf8" })
|
|
43
|
+
.filter(isSource)
|
|
44
|
+
.map((file) => join(dir, file))
|
|
45
|
+
.filter((file) => file !== barrel && isClient(file))
|
|
46
|
+
.map((file) => relative(dir, file))
|
|
47
|
+
return { name, barrel, clientLeaves, barrelIsClient: isClient(barrel) }
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
describe('"use client" on component barrels', () => {
|
|
51
|
+
it("finds the component folders", () => {
|
|
52
|
+
expect(components.length).toBeGreaterThan(10)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it.each(components.filter(({ name }) => !(name in SERVER_BARRELS)))(
|
|
56
|
+
"$name: barrel is client when a leaf is",
|
|
57
|
+
({ barrel, clientLeaves, barrelIsClient }) => {
|
|
58
|
+
if (clientLeaves.length === 0 || barrelIsClient) return
|
|
59
|
+
expect.fail(
|
|
60
|
+
`${relative(pkg, barrel)} has no "use client" directive, but ${clientLeaves.join(", ")} ` +
|
|
61
|
+
`${clientLeaves.length === 1 ? "is" : "are"} client. tsup only reads the barrel to ` +
|
|
62
|
+
`classify the entry, so the dist file would ship without the directive. ` +
|
|
63
|
+
`Fix: add "use client" as the first line of ${relative(pkg, barrel)}.`,
|
|
64
|
+
)
|
|
65
|
+
},
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
it.each(Object.entries(SERVER_BARRELS))("%s: server barrel exception is still needed", (name) => {
|
|
69
|
+
const component = components.find((c) => c.name === name)
|
|
70
|
+
expect(component, `remove "${name}" from SERVER_BARRELS: the folder is gone`).toBeDefined()
|
|
71
|
+
expect(
|
|
72
|
+
component?.barrelIsClient,
|
|
73
|
+
`remove "${name}" from SERVER_BARRELS: its barrel is now "use client"`,
|
|
74
|
+
).toBe(false)
|
|
75
|
+
expect(
|
|
76
|
+
component?.clientLeaves.length,
|
|
77
|
+
`remove "${name}" from SERVER_BARRELS: it has no client leaves left`,
|
|
78
|
+
).toBeGreaterThan(0)
|
|
79
|
+
})
|
|
80
|
+
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/nav-link/nav-link.tsx","../src/components/nav-link/navigation.tsx"],"names":["jsx","Fragment"],"mappings":";;;;;;;;;AAsCA,IAAM,UAAA,GAAa,GAAA;AAAA,EACjB;AAAA,IACE,iGAAA;AAAA,IACA,gCAAA;AAAA,IACA,wCAAA;AAAA,IACA,WAAA,EAAY;AAAA,IACZ;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,IAAA,EAAM,mFAAA;AAAA,QACN,KAAA,EAAO;AAAA;AACT,KACF;AAAA,IACA,eAAA,EAAiB,EAAE,OAAA,EAAS,KAAA;AAAM;AAEtC,CAAA;AAEA,IAAM,aAAA,GAAgB,EAAA;AAAA,EACpB,+GAAA;AAAA,EACA,gEAAA;AAAA,EACA,WAAA;AACF,CAAA;AAEA,IAAM,OAAA,GAAU,CAAC,IAAA,qBACf,GAAA;AAAA,EAAC,MAAA;AAAA,EAAA;AAAA,IACC,aAAA,EAAY,MAAA;AAAA,IACZ,YAAA,EAAY,OAAO,MAAA,GAAS,QAAA;AAAA,IAC5B,SAAA,EAAU,wFAAA;AAAA,IAEV,8BAAC,WAAA,EAAA,EAAY;AAAA;AACf,CAAA;AAmCF,SAAS,WAAA,CAAY;AAAA,EACnB,KAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA,EAAiB;AACf,EAAA,MAAM,CAAC,MAAA,EAAQ,OAAO,CAAA,GAAI,eAAA,CAAyB;AAAA,IACjD,KAAA,EAAO,IAAA;AAAA,IACP,YAAA,EAAc,WAAA;AAAA,IACd,UAAA,EAAY,KAAA;AAAA,IACZ,QAAA,EAAU;AAAA,GACX,CAAA;AACD,EAAA,MAAM,cAAc,QAAA,IAAY,IAAA;AAChC,EAAA,MAAM,SAAS,WAAA,IAAe,IAAA;AAC9B,EAAA,MAAM,IAAA,GAAO,gBAAA,CAAiB,aAAa,CAAA,IAAK,GAAA;AAEhD,EAAA,MAAM,0BACJ,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,IAAA,SAAA;AAAA,oBACD,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,yBAAA,EAA2B,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,IAChD;AAAA,GAAA,EACH,CAAA;AAGF,EAAA,MAAM,YAAA,GAAe,GAAG,UAAA,CAAW,EAAE,SAAS,CAAA,EAAG,UAAA,EAAY,GAAA,EAAK,SAAS,CAAA;AAE3E,EAAA,4BACG,KAAA,EAAA,EACC,QAAA,EAAA;AAAA,oBAAA,IAAA,CAAC,KAAA,EAAA,EAAI,WAAU,0BAAA,EACZ,QAAA,EAAA;AAAA,MAAA,MAAA,mBACC,GAAA;AAAA,QAAC,IAAA;AAAA,QAAA;AAAA,UACE,GAAG,WAAA;AAAA,UACJ,cAAA,EAAc,UAAU,MAAA,GAAS,MAAA;AAAA,UACjC,iBAAe,QAAA,IAAY,MAAA;AAAA,UAC3B,SAAA,EAAW,YAAA;AAAA,UAEV,QAAA,EAAA;AAAA;AAAA,OACH,mBAEA,IAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAK,QAAA;AAAA,UACL,cAAA,EAAc,UAAU,MAAA,GAAS,MAAA;AAAA,UACjC,iBAAe,QAAA,IAAY,MAAA;AAAA,UAC3B,eAAA,EAAe,cAAc,MAAA,GAAS,MAAA;AAAA,UACtC,QAAA;AAAA,UACA,OAAA,EAAS,MAAM,WAAA,IAAe,OAAA,CAAQ,CAAC,MAAM,CAAA;AAAA,UAC7C,SAAA,EAAW,YAAA;AAAA,UAEV,QAAA,EAAA;AAAA,YAAA,OAAA;AAAA,YACA,WAAA,IAAe,QAAQ,MAAM;AAAA;AAAA;AAAA,OAChC;AAAA,MAED,eAAe,MAAA,oBACd,GAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAK,QAAA;AAAA,UACL,eAAA,EAAe,MAAA;AAAA,UACf,YAAA,EAAY,SAAS,UAAA,GAAa,QAAA;AAAA,UAClC,OAAA,EAAS,MAAM,OAAA,CAAQ,CAAC,MAAM,CAAA;AAAA,UAC9B,SAAA,EAAW,aAAA;AAAA,UAEV,kBAAQ,MAAM;AAAA;AAAA;AACjB,KAAA,EAEJ,CAAA;AAAA,IACC,WAAA,oBACC,GAAA,CAAC,QAAA,EAAA,EAAS,IAAA,EAAM,MAAA,EACd,QAAA,kBAAA,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,SAAA,EAAW,EAAA;AAAA,UACT,kFAAA;AAAA,UACA,UAAA,EAAY;AAAA,SACd;AAAA,QAEC;AAAA;AAAA,KACH,EACF;AAAA,GAAA,EAEJ,CAAA;AAEJ;AAUO,SAAS,QAAQ,KAAA,EAAgC;AACtD,EAAA,uBAAO,GAAA,CAAC,WAAA,EAAA,EAAa,GAAG,KAAA,EAAO,CAAA;AACjC;AC7JA,IAAM,UAAA,GAAa,CACjB,IAAA,EACA,GAAA,EACA,kCAEAA,GAAAA;AAAA,EAAC,OAAA;AAAA,EAAA;AAAA,IAEC,OAAO,IAAA,CAAK,KAAA;AAAA,IACZ,WAAW,IAAA,CAAK,SAAA;AAAA,IAChB,SAAS,IAAA,CAAK,OAAA;AAAA,IACd,SAAS,IAAA,CAAK,OAAA;AAAA,IACd,UAAU,IAAA,CAAK,QAAA;AAAA,IACf,MAAM,IAAA,CAAK,IAAA;AAAA,IACX,aAAa,IAAA,CAAK,WAAA;AAAA,IAClB,cAAc,IAAA,CAAK,YAAA;AAAA,IACnB,aAAa,IAAA,CAAK,WAAA;AAAA,IAClB,aAAA;AAAA,IACA,YAAY,IAAA,CAAK,UAAA;AAAA,IAEhB,QAAA,EAAA,IAAA,CAAK,SAAS,IAAA,CAAK,KAAA,CAAM,SAAS,CAAA,GAC/B,IAAA,CAAK,MAAM,GAAA,CAAI,CAAC,OAAO,CAAA,KAAM,UAAA,CAAW,OAAO,CAAA,EAAG,GAAG,IAAI,CAAC,CAAA,CAAA,EAAI,aAAa,CAAC,CAAA,GAC5E;AAAA,GAAA;AAAA,EAfC;AAgBP,CAAA;AAGF,SAAS,cAAA,CAAe,EAAE,IAAA,EAAM,aAAA,EAAc,EAAoB;AAChE,EAAA,uBAAOA,GAAAA,CAAAC,QAAAA,EAAA,EAAG,QAAA,EAAA,IAAA,CAAK,IAAI,CAAC,IAAA,EAAM,CAAA,KAAM,UAAA,CAAW,MAAM,CAAA,IAAA,EAAO,CAAC,CAAA,CAAA,EAAI,aAAa,CAAC,CAAA,EAAE,CAAA;AAC/E;AAIO,SAAS,WAAW,KAAA,EAAmC;AAC5D,EAAA,uBAAOD,GAAAA,CAAC,cAAA,EAAA,EAAgB,GAAG,KAAA,EAAO,CAAA;AACpC","file":"chunk-5JHDSVEZ.js","sourcesContent":["\"use client\"\n\nimport { cva } from \"class-variance-authority\"\nimport type { ElementType, ReactNode } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { useLinkComponent } from \"../../lib/link-component\"\nimport { useUncontrolled } from \"../../lib/use-uncontrolled\"\nimport { Collapse } from \"../collapse/collapse\"\nimport { ChevronIcon } from \"../popover/icons\"\n\n/**\n * NavLink — a single sidebar/nav row: leading `startSlot`, `label`, trailing\n * `endSlot`, current-page treatment, and self-nesting via `children` for\n * arbitrary-depth sub-navigation (each nested `<NavLink>` renders indented,\n * revealed with `Collapse` when the parent is `open`).\n *\n * Router-agnostic: pass whatever the target link needs as `linkOptions` (a\n * plain `{ href }` for a bare `<a>`, or a framework router's own shape, e.g.\n * TanStack Router's `{ to, params }`) — it's spread verbatim onto whatever\n * renders the link. `linkComponent` picks what that is; if omitted, it falls\n * back to the app-wide `<LinkComponentProvider>` (see `lib/link-component`),\n * then to a plain `<a>`. Generic over `linkOptions`'s shape so a router's own\n * type-safety utilities can validate/autocomplete it — see\n * `nav-link/tanstack.tsx` for a TanStack Router–typed wrapper built this way.\n *\n * A row with no `linkOptions` (a pure category / toggle heading) renders as a\n * `<button>` instead of a link. A row with both `linkOptions` and nested\n * children renders the link and its expand/collapse toggle as two separate\n * controls (a link nested inside a button, or vice versa, isn't valid HTML).\n *\n * <NavLink label=\"Dashboard\" startSlot={<Home />} linkOptions={{ href: \"/dashboard\" }} />\n * <NavLink label=\"Settings\" startSlot={<Settings />} defaultOpen>\n * <NavLink label=\"Profile\" linkOptions={{ href: \"/settings/profile\" }} />\n * <NavLink label=\"Security\" linkOptions={{ href: \"/settings/security\" }} />\n * </NavLink>\n */\n\nconst navLinkRow = cva(\n [\n \"flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md px-2.5 py-2 text-start text-sm\",\n \"outline-none transition-colors\",\n \"hover:bg-black/5 dark:hover:bg-white/8\",\n focusStyles(),\n \"aria-disabled:pointer-events-none aria-disabled:opacity-50\",\n ],\n {\n variants: {\n current: {\n true: \"bg-black/5 font-medium text-gray-light-900 dark:bg-white/8 dark:text-gray-dark-25\",\n false: \"text-gray-light-700 dark:text-gray-dark-200\",\n },\n },\n defaultVariants: { current: false },\n },\n)\n\nconst chevronButton = cn(\n \"flex shrink-0 cursor-pointer items-center justify-center rounded-md p-2 text-gray-light-500 transition-colors\",\n \"hover:bg-black/5 dark:text-gray-dark-400 dark:hover:bg-white/8\",\n focusStyles(),\n)\n\nconst chevron = (open: boolean) => (\n <span\n aria-hidden=\"true\"\n data-state={open ? \"open\" : \"closed\"}\n className=\"ms-auto flex shrink-0 transition-transform data-[state=open]:rotate-180 [&_svg]:size-4\"\n >\n <ChevronIcon />\n </span>\n)\n\nexport type NavLinkClassNames = {\n /** The link/button row itself. */\n row?: string\n /** The indented container holding nested `<NavLink>` children. */\n items?: string\n}\n\nexport type NavLinkProps<TOptions = unknown> = {\n label: ReactNode\n /** Leading slot (icon, avatar, etc). */\n startSlot?: ReactNode\n /** Trailing slot (e.g. a count or status badge). */\n endSlot?: ReactNode\n /** Marks this as the active/current page. */\n current?: boolean\n disabled?: boolean\n /** Whether nested `children` are revealed. Uncontrolled by default. */\n open?: boolean\n defaultOpen?: boolean\n onOpenChange?: (open: boolean) => void\n /** The router's own link options — e.g. `{ href: \"/x\" }` for a plain `<a>`,\n * or `{ to: \"/x\", params: {...} }` for TanStack Router. Omit for a pure\n * category/toggle row with no link of its own. */\n linkOptions?: TOptions\n /** Overrides the `<LinkComponentProvider>` for this row only. */\n linkComponent?: ElementType\n classNames?: NavLinkClassNames\n className?: string\n /** Nested `<NavLink>` elements, revealed when `open`. */\n children?: ReactNode\n}\n\nfunction NavLinkImpl({\n label,\n startSlot,\n endSlot,\n current,\n disabled,\n open,\n defaultOpen,\n onOpenChange,\n linkOptions,\n linkComponent,\n classNames,\n className,\n children,\n}: NavLinkProps) {\n const [isOpen, setOpen] = useUncontrolled<boolean>({\n value: open,\n defaultValue: defaultOpen,\n finalValue: false,\n onChange: onOpenChange,\n })\n const hasChildren = children != null\n const isLink = linkOptions != null\n const Comp = useLinkComponent(linkComponent) ?? \"a\"\n\n const content = (\n <>\n {startSlot}\n <span className=\"min-w-0 flex-1 truncate\">{label}</span>\n {endSlot}\n </>\n )\n\n const rowClassName = cn(navLinkRow({ current }), classNames?.row, className)\n\n return (\n <div>\n <div className=\"flex items-stretch gap-1\">\n {isLink ? (\n <Comp\n {...linkOptions}\n aria-current={current ? \"page\" : undefined}\n aria-disabled={disabled || undefined}\n className={rowClassName}\n >\n {content}\n </Comp>\n ) : (\n <button\n type=\"button\"\n aria-current={current ? \"page\" : undefined}\n aria-disabled={disabled || undefined}\n aria-expanded={hasChildren ? isOpen : undefined}\n disabled={disabled}\n onClick={() => hasChildren && setOpen(!isOpen)}\n className={rowClassName}\n >\n {content}\n {hasChildren && chevron(isOpen)}\n </button>\n )}\n {hasChildren && isLink && (\n <button\n type=\"button\"\n aria-expanded={isOpen}\n aria-label={isOpen ? \"Collapse\" : \"Expand\"}\n onClick={() => setOpen(!isOpen)}\n className={chevronButton}\n >\n {chevron(isOpen)}\n </button>\n )}\n </div>\n {hasChildren && (\n <Collapse open={isOpen}>\n <div\n className={cn(\n \"ms-4.5 space-y-0.5 border-s border-brand-900/20 ps-2 pt-0.5 dark:border-white/15\",\n classNames?.items,\n )}\n >\n {children}\n </div>\n </Collapse>\n )}\n </div>\n )\n}\n\n/**\n * `NavLink<TOptions>` — generic so a router's own type-safety utility (e.g.\n * TanStack Router's `ValidateLinkOptions`) can validate `linkOptions` when\n * explicitly parameterized. The implementation itself stays untyped/loose\n * (the generic can't be forwarded through the JSX body); see\n * TanStack Router's own documented pattern for this exact split.\n */\nexport function NavLink<TOptions = unknown>(props: NavLinkProps<TOptions>): ReactNode\nexport function NavLink(props: NavLinkProps): ReactNode {\n return <NavLinkImpl {...props} />\n}\n","\"use client\"\n\nimport type { ElementType, ReactNode } from \"react\"\nimport { NavLink, type NavLinkClassNames } from \"./nav-link\"\n\n/**\n * `Navigation` — the `data`-driven convenience wrapper over `NavLink` (same\n * relationship as `menu-data.tsx` to `menu.tsx`): pass a `data` array, get a\n * fully wired, arbitrarily-nested nav tree.\n *\n * <Navigation\n * data={[\n * { label: \"Dashboard\", startSlot: <Home />, linkOptions: { href: \"/dashboard\" } },\n * { label: \"Settings\", startSlot: <Settings />, items: [\n * { label: \"Profile\", linkOptions: { href: \"/settings/profile\" } },\n * { label: \"Security\", linkOptions: { href: \"/settings/security\" } },\n * ]},\n * ]}\n * />\n *\n * Generic over the same `TOptions` as `NavLink` — parameterize it (e.g. with\n * `TanStackLinkOptions` from `nav-link/tanstack`) to get a router's own\n * type-safety utilities validating every entry's `linkOptions`.\n */\nexport type NavigationItem<TOptions = unknown> = {\n label: ReactNode\n startSlot?: ReactNode\n endSlot?: ReactNode\n current?: boolean\n disabled?: boolean\n open?: boolean\n defaultOpen?: boolean\n onOpenChange?: (open: boolean) => void\n linkOptions?: TOptions\n classNames?: NavLinkClassNames\n /** Nested entries — an item with `items` renders its children indented,\n * revealed on expand/collapse. Recursive: nests to any depth. */\n items?: readonly NavigationItem<TOptions>[]\n}\n\nexport type NavigationProps<TOptions = unknown> = {\n /** The nav entries, in order. */\n data: readonly NavigationItem<TOptions>[]\n /** Overrides the app-wide `<LinkComponentProvider>` for every generated row. */\n linkComponent?: ElementType\n}\n\nconst renderItem = (\n item: NavigationItem,\n key: string,\n linkComponent: ElementType | undefined,\n): ReactNode => (\n <NavLink\n key={key}\n label={item.label}\n startSlot={item.startSlot}\n endSlot={item.endSlot}\n current={item.current}\n disabled={item.disabled}\n open={item.open}\n defaultOpen={item.defaultOpen}\n onOpenChange={item.onOpenChange}\n linkOptions={item.linkOptions}\n linkComponent={linkComponent}\n classNames={item.classNames}\n >\n {item.items && item.items.length > 0\n ? item.items.map((child, i) => renderItem(child, `${key}.${i}`, linkComponent))\n : undefined}\n </NavLink>\n)\n\nfunction NavigationImpl({ data, linkComponent }: NavigationProps) {\n return <>{data.map((item, i) => renderItem(item, `nav-${i}`, linkComponent))}</>\n}\n\n/** Generic for the same reason as `NavLink` — see its doc comment. */\nexport function Navigation<TOptions = unknown>(props: NavigationProps<TOptions>): ReactNode\nexport function Navigation(props: NavigationProps): ReactNode {\n return <NavigationImpl {...props} />\n}\n"]}
|