@cognite/aura 0.3.5 → 1.46105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +264 -0
- package/DESIGN.md +638 -281
- package/LICENSE +21 -0
- package/README.md +21 -13
- package/dist/colors-deprecated.css +587 -0
- package/dist/colors.css +803 -830
- package/dist/components/index.d.ts +63 -57
- package/dist/components/index.js +62 -59
- package/dist/components/index.js.map +1 -0
- package/dist/components/ui/core/accordion/accordion.d.ts +19 -18
- package/dist/components/ui/core/accordion/accordion.js +99 -78
- package/dist/components/ui/core/accordion/accordion.js.map +1 -0
- package/dist/components/ui/core/action-toolbar/action-toolbar-motion.d.ts +8 -0
- package/dist/components/ui/core/action-toolbar/action-toolbar-motion.js +125 -0
- package/dist/components/ui/core/action-toolbar/action-toolbar-motion.js.map +1 -0
- package/dist/components/ui/core/action-toolbar/action-toolbar.d.ts +31 -31
- package/dist/components/ui/core/action-toolbar/action-toolbar.js +156 -106
- package/dist/components/ui/core/action-toolbar/action-toolbar.js.map +1 -0
- package/dist/components/ui/core/alert/alert.d.ts +25 -25
- package/dist/components/ui/core/alert/alert.js +181 -152
- package/dist/components/ui/core/alert/alert.js.map +1 -0
- package/dist/components/ui/core/avatar/avatar.d.ts +10 -9
- package/dist/components/ui/core/avatar/avatar.js +75 -65
- package/dist/components/ui/core/avatar/avatar.js.map +1 -0
- package/dist/components/ui/core/badge/badge.d.ts +13 -12
- package/dist/components/ui/core/badge/badge.js +88 -72
- package/dist/components/ui/core/badge/badge.js.map +1 -0
- package/dist/components/ui/core/banner/banner.d.ts +18 -18
- package/dist/components/ui/core/banner/banner.js +179 -142
- package/dist/components/ui/core/banner/banner.js.map +1 -0
- package/dist/components/ui/core/breadcrumb/breadcrumb.d.ts +12 -12
- package/dist/components/ui/core/breadcrumb/breadcrumb.js +139 -104
- package/dist/components/ui/core/breadcrumb/breadcrumb.js.map +1 -0
- package/dist/components/ui/core/button/button.d.ts +7 -7
- package/dist/components/ui/core/button/button.gallery.d.ts +2 -0
- package/dist/components/ui/core/button/button.gallery.js +76 -0
- package/dist/components/ui/core/button/button.gallery.js.map +1 -0
- package/dist/components/ui/core/button/button.js +57 -47
- package/dist/components/ui/core/button/button.js.map +1 -0
- package/dist/components/ui/core/button-group/button-group.d.ts +9 -9
- package/dist/components/ui/core/button-group/button-group.js +50 -40
- package/dist/components/ui/core/button-group/button-group.js.map +1 -0
- package/dist/components/ui/core/calendar/calendar-header.d.ts +7 -7
- package/dist/components/ui/core/calendar/calendar-header.js +102 -63
- package/dist/components/ui/core/calendar/calendar-header.js.map +1 -0
- package/dist/components/ui/core/calendar/calendar-utils.d.ts +30 -30
- package/dist/components/ui/core/calendar/calendar-utils.js +116 -39
- package/dist/components/ui/core/calendar/calendar-utils.js.map +1 -0
- package/dist/components/ui/core/calendar/calendar.d.ts +10 -10
- package/dist/components/ui/core/calendar/calendar.js +95 -66
- package/dist/components/ui/core/calendar/calendar.js.map +1 -0
- package/dist/components/ui/core/calendar/constants.js +3 -0
- package/dist/components/ui/core/calendar/constants.js.map +1 -0
- package/dist/components/ui/core/card/card.d.ts +20 -20
- package/dist/components/ui/core/card/card.js +133 -104
- package/dist/components/ui/core/card/card.js.map +1 -0
- package/dist/components/ui/core/chart/chart.d.ts +55 -53
- package/dist/components/ui/core/chart/chart.js +196 -116
- package/dist/components/ui/core/chart/chart.js.map +1 -0
- package/dist/components/ui/core/chart/index.d.ts +2 -2
- package/dist/components/ui/core/chart/index.js +3 -2
- package/dist/components/ui/core/chart/index.js.map +1 -0
- package/dist/components/ui/core/checkbox/checkbox.d.ts +9 -9
- package/dist/components/ui/core/checkbox/checkbox.js +88 -68
- package/dist/components/ui/core/checkbox/checkbox.js.map +1 -0
- package/dist/components/ui/core/checkbox/checkbox.metadata.d.ts +1 -1
- package/dist/components/ui/core/checkbox/checkbox.metadata.js +6 -7
- package/dist/components/ui/core/checkbox/checkbox.metadata.js.map +1 -0
- package/dist/components/ui/core/code-block/code-block.d.ts +19 -19
- package/dist/components/ui/core/code-block/code-block.js +259 -175
- package/dist/components/ui/core/code-block/code-block.js.map +1 -0
- package/dist/components/ui/core/collapsible/collapsible.d.ts +5 -5
- package/dist/components/ui/core/collapsible/collapsible.js +36 -30
- package/dist/components/ui/core/collapsible/collapsible.js.map +1 -0
- package/dist/components/ui/core/combobox/combobox.d.ts +13 -13
- package/dist/components/ui/core/combobox/combobox.js +89 -40
- package/dist/components/ui/core/combobox/combobox.js.map +1 -0
- package/dist/components/ui/core/command/command.d.ts +20 -18
- package/dist/components/ui/core/command/command.js +137 -85
- package/dist/components/ui/core/command/command.js.map +1 -0
- package/dist/components/ui/core/conversation/conversation.d.ts +14 -0
- package/dist/components/ui/core/conversation/conversation.js +51 -0
- package/dist/components/ui/core/conversation/conversation.js.map +1 -0
- package/dist/components/ui/core/count/count.d.ts +8 -6
- package/dist/components/ui/core/count/count.js +51 -21
- package/dist/components/ui/core/count/count.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid-cell.d.ts +7 -7
- package/dist/components/ui/core/data-grid/data-grid-cell.js +22 -22
- package/dist/components/ui/core/data-grid/data-grid-cell.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid-filter-clauses.d.ts +14 -0
- package/dist/components/ui/core/data-grid/data-grid-filter-clauses.js +36 -0
- package/dist/components/ui/core/data-grid/data-grid-filter-clauses.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid-filter-panel.d.ts +41 -0
- package/dist/components/ui/core/data-grid/data-grid-filter-panel.js +273 -0
- package/dist/components/ui/core/data-grid/data-grid-filter-panel.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid-footer.d.ts +6 -0
- package/dist/components/ui/core/data-grid/data-grid-footer.js +34 -0
- package/dist/components/ui/core/data-grid/data-grid-footer.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid-header-row.d.ts +10 -10
- package/dist/components/ui/core/data-grid/data-grid-header-row.js +69 -55
- package/dist/components/ui/core/data-grid/data-grid-header-row.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid-header.d.ts +11 -0
- package/dist/components/ui/core/data-grid/data-grid-header.js +67 -0
- package/dist/components/ui/core/data-grid/data-grid-header.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid-row.d.ts +15 -15
- package/dist/components/ui/core/data-grid/data-grid-row.js +104 -76
- package/dist/components/ui/core/data-grid/data-grid-row.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid.d.ts +85 -35
- package/dist/components/ui/core/data-grid/data-grid.fixtures.d.ts +7 -7
- package/dist/components/ui/core/data-grid/data-grid.fixtures.js +139 -0
- package/dist/components/ui/core/data-grid/data-grid.fixtures.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid.js +402 -132
- package/dist/components/ui/core/data-grid/data-grid.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid.utils.d.ts +3 -3
- package/dist/components/ui/core/data-grid/data-grid.utils.js +44 -33
- package/dist/components/ui/core/data-grid/data-grid.utils.js.map +1 -0
- package/dist/components/ui/core/data-grid/index.d.ts +4 -1
- package/dist/components/ui/core/data-grid/index.js +5 -2
- package/dist/components/ui/core/data-grid/index.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.d.ts +11 -13
- package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js +85 -61
- package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/index.d.ts +3 -3
- package/dist/components/ui/core/date-time-pickers/date-picker/index.js +3 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/index.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/types.d.ts +14 -14
- package/dist/components/ui/core/date-time-pickers/date-picker/types.js +3 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/types.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.d.ts +2 -2
- package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js +51 -36
- package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.d.ts +11 -13
- package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +89 -64
- package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/index.d.ts +3 -3
- package/dist/components/ui/core/date-time-pickers/date-range-picker/index.js +3 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/index.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +20 -20
- package/dist/components/ui/core/date-time-pickers/date-range-picker/types.js +3 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/types.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.d.ts +4 -4
- package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +95 -60
- package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-time-picker/date-time-picker.d.ts +15 -0
- package/dist/components/ui/core/date-time-pickers/date-time-picker/date-time-picker.js +120 -0
- package/dist/components/ui/core/date-time-pickers/date-time-picker/date-time-picker.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-time-picker/index.d.ts +3 -1
- package/dist/components/ui/core/date-time-pickers/date-time-picker/index.js +3 -0
- package/dist/components/ui/core/date-time-pickers/date-time-picker/index.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-time-picker/types.d.ts +25 -32
- package/dist/components/ui/core/date-time-pickers/date-time-picker/types.js +3 -0
- package/dist/components/ui/core/date-time-pickers/date-time-picker/types.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-time-picker/use-date-time-picker.d.ts +2 -2
- package/dist/components/ui/core/date-time-pickers/date-time-picker/use-date-time-picker.js +78 -0
- package/dist/components/ui/core/date-time-pickers/date-time-picker/use-date-time-picker.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.d.ts +13 -15
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +165 -119
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/index.d.ts +3 -3
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/index.js +3 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/index.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +37 -37
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.js +3 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.d.ts +3 -3
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +163 -104
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/index.d.ts +17 -12
- package/dist/components/ui/core/date-time-pickers/index.js +10 -6
- package/dist/components/ui/core/date-time-pickers/index.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.d.ts +5 -5
- package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.js +52 -42
- package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/constants.d.ts +6 -1
- package/dist/components/ui/core/date-time-pickers/shared/constants.js +23 -0
- package/dist/components/ui/core/date-time-pickers/shared/constants.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.d.ts +16 -15
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +87 -64
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.d.ts +10 -9
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.js +89 -38
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.d.ts +5 -5
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +34 -23
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.d.ts +23 -23
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.js +95 -52
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.d.ts +5 -5
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.js +22 -18
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.d.ts +19 -19
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.js +41 -24
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.d.ts +13 -13
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.js +33 -24
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.d.ts +5 -5
- package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.js +9 -4
- package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.d.ts +13 -9
- package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.js +22 -17
- package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/index.d.ts +2 -2
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/index.js +3 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/index.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.d.ts +13 -13
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js +49 -40
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.d.ts +7 -7
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.js +41 -34
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/index.d.ts +3 -3
- package/dist/components/ui/core/date-time-pickers/time-picker/index.js +3 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/index.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.d.ts +12 -14
- package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.js +99 -79
- package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/types.d.ts +20 -20
- package/dist/components/ui/core/date-time-pickers/time-picker/types.js +3 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/types.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.d.ts +2 -2
- package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.js +63 -41
- package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/time-range-picker/index.d.ts +3 -1
- package/dist/components/ui/core/date-time-pickers/time-range-picker/index.js +3 -0
- package/dist/components/ui/core/date-time-pickers/time-range-picker/index.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/time-range-picker/time-range-picker.d.ts +14 -0
- package/dist/components/ui/core/date-time-pickers/time-range-picker/time-range-picker.js +115 -0
- package/dist/components/ui/core/date-time-pickers/time-range-picker/time-range-picker.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/time-range-picker/types.d.ts +30 -36
- package/dist/components/ui/core/date-time-pickers/time-range-picker/types.js +3 -0
- package/dist/components/ui/core/date-time-pickers/time-range-picker/types.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/time-range-picker/use-time-range-picker.d.ts +2 -2
- package/dist/components/ui/core/date-time-pickers/time-range-picker/use-time-range-picker.js +145 -0
- package/dist/components/ui/core/date-time-pickers/time-range-picker/use-time-range-picker.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/utils/date-input.d.ts +56 -0
- package/dist/components/ui/core/date-time-pickers/utils/date-input.js +67 -0
- package/dist/components/ui/core/date-time-pickers/utils/date-input.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/utils/date-range-utils.d.ts +18 -18
- package/dist/components/ui/core/date-time-pickers/utils/date-range-utils.js +42 -0
- package/dist/components/ui/core/date-time-pickers/utils/date-range-utils.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/utils/format-utils.d.ts +31 -29
- package/dist/components/ui/core/date-time-pickers/utils/format-utils.js +56 -0
- package/dist/components/ui/core/date-time-pickers/utils/format-utils.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/utils/segment-utils.d.ts +21 -21
- package/dist/components/ui/core/date-time-pickers/utils/segment-utils.js +170 -0
- package/dist/components/ui/core/date-time-pickers/utils/segment-utils.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/utils/time-utils.d.ts +28 -28
- package/dist/components/ui/core/date-time-pickers/utils/time-utils.js +88 -7
- package/dist/components/ui/core/date-time-pickers/utils/time-utils.js.map +1 -0
- package/dist/components/ui/core/date-time-pickers/utils/time-validation.d.ts +17 -17
- package/dist/components/ui/core/date-time-pickers/utils/time-validation.js +43 -0
- package/dist/components/ui/core/date-time-pickers/utils/time-validation.js.map +1 -0
- package/dist/components/ui/core/dialog/dialog.d.ts +12 -9
- package/dist/components/ui/core/dialog/dialog.js +90 -82
- package/dist/components/ui/core/dialog/dialog.js.map +1 -0
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +22 -19
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +204 -149
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.js.map +1 -0
- package/dist/components/ui/core/empty-state/empty-state.context.d.ts +4 -4
- package/dist/components/ui/core/empty-state/empty-state.context.js +8 -5
- package/dist/components/ui/core/empty-state/empty-state.context.js.map +1 -0
- package/dist/components/ui/core/empty-state/empty-state.d.ts +14 -14
- package/dist/components/ui/core/empty-state/empty-state.js +96 -82
- package/dist/components/ui/core/empty-state/empty-state.js.map +1 -0
- package/dist/components/ui/core/helper-text/helper-text.d.ts +7 -7
- package/dist/components/ui/core/helper-text/helper-text.js +55 -36
- package/dist/components/ui/core/helper-text/helper-text.js.map +1 -0
- package/dist/components/ui/core/hover-card/hover-card.d.ts +7 -6
- package/dist/components/ui/core/hover-card/hover-card.js +56 -52
- package/dist/components/ui/core/hover-card/hover-card.js.map +1 -0
- package/dist/components/ui/core/inline-citation/inline-citation.d.ts +26 -25
- package/dist/components/ui/core/inline-citation/inline-citation.js +121 -97
- package/dist/components/ui/core/inline-citation/inline-citation.js.map +1 -0
- package/dist/components/ui/core/input/input.d.ts +2 -2
- package/dist/components/ui/core/input/input.js +15 -13
- package/dist/components/ui/core/input/input.js.map +1 -0
- package/dist/components/ui/core/input-group/input-group.d.ts +25 -14
- package/dist/components/ui/core/input-group/input-group.js +149 -76
- package/dist/components/ui/core/input-group/input-group.js.map +1 -0
- package/dist/components/ui/core/item/item.d.ts +20 -0
- package/dist/components/ui/core/item/item.js +93 -0
- package/dist/components/ui/core/item/item.js.map +1 -0
- package/dist/components/ui/core/kbd/kbd.d.ts +3 -3
- package/dist/components/ui/core/kbd/kbd.js +24 -20
- package/dist/components/ui/core/kbd/kbd.js.map +1 -0
- package/dist/components/ui/core/label/label.d.ts +3 -3
- package/dist/components/ui/core/label/label.js +33 -26
- package/dist/components/ui/core/label/label.js.map +1 -0
- package/dist/components/ui/core/loader/loader.d.ts +6 -6
- package/dist/components/ui/core/loader/loader.js +97 -80
- package/dist/components/ui/core/loader/loader.js.map +1 -0
- package/dist/components/ui/core/message/message-response-default-streamdown-controls.d.ts +9 -9
- package/dist/components/ui/core/message/message-response-default-streamdown-controls.js +19 -12
- package/dist/components/ui/core/message/message-response-default-streamdown-controls.js.map +1 -0
- package/dist/components/ui/core/message/message-response-math-plugin.d.ts +3 -0
- package/dist/components/ui/core/message/message-response-math-plugin.js +6 -0
- package/dist/components/ui/core/message/message-response-math-plugin.js.map +1 -0
- package/dist/components/ui/core/message/message.d.ts +27 -23
- package/dist/components/ui/core/message/message.js +453 -316
- package/dist/components/ui/core/message/message.js.map +1 -0
- package/dist/components/ui/core/overflow-list/overflow-list.d.ts +21 -0
- package/dist/components/ui/core/overflow-list/overflow-list.js +197 -0
- package/dist/components/ui/core/overflow-list/overflow-list.js.map +1 -0
- package/dist/components/ui/core/overflow-list/overflow-list.utils.d.ts +37 -35
- package/dist/components/ui/core/overflow-list/overflow-list.utils.js +206 -0
- package/dist/components/ui/core/overflow-list/overflow-list.utils.js.map +1 -0
- package/dist/components/ui/core/pagination/pagination-size-context.d.ts +2 -2
- package/dist/components/ui/core/pagination/pagination-size-context.js +6 -5
- package/dist/components/ui/core/pagination/pagination-size-context.js.map +1 -0
- package/dist/components/ui/core/pagination/pagination-teleport.d.ts +9 -9
- package/dist/components/ui/core/pagination/pagination-teleport.js +127 -84
- package/dist/components/ui/core/pagination/pagination-teleport.js.map +1 -0
- package/dist/components/ui/core/pagination/pagination-teleport.utils.js +6 -6
- package/dist/components/ui/core/pagination/pagination-teleport.utils.js.map +1 -0
- package/dist/components/ui/core/pagination/pagination.d.ts +39 -39
- package/dist/components/ui/core/pagination/pagination.js +294 -234
- package/dist/components/ui/core/pagination/pagination.js.map +1 -0
- package/dist/components/ui/core/popover/popover.d.ts +12 -11
- package/dist/components/ui/core/popover/popover.js +104 -89
- package/dist/components/ui/core/popover/popover.js.map +1 -0
- package/dist/components/ui/core/progress/progress.d.ts +9 -8
- package/dist/components/ui/core/progress/progress.js +50 -35
- package/dist/components/ui/core/progress/progress.js.map +1 -0
- package/dist/components/ui/core/prompt-input/prompt-input.d.ts +27 -27
- package/dist/components/ui/core/prompt-input/prompt-input.js +342 -271
- package/dist/components/ui/core/prompt-input/prompt-input.js.map +1 -0
- package/dist/components/ui/core/radio-group/radio-group.d.ts +12 -12
- package/dist/components/ui/core/radio-group/radio-group.js +88 -58
- package/dist/components/ui/core/radio-group/radio-group.js.map +1 -0
- package/dist/components/ui/core/reasoning/reasoning.d.ts +7 -7
- package/dist/components/ui/core/reasoning/reasoning.js +68 -56
- package/dist/components/ui/core/reasoning/reasoning.js.map +1 -0
- package/dist/components/ui/core/scroll-area/scroll-area.d.ts +4 -4
- package/dist/components/ui/core/scroll-area/scroll-area.js +50 -40
- package/dist/components/ui/core/scroll-area/scroll-area.js.map +1 -0
- package/dist/components/ui/core/search/search.d.ts +8 -8
- package/dist/components/ui/core/search/search.js +122 -76
- package/dist/components/ui/core/search/search.js.map +1 -0
- package/dist/components/ui/core/segmented-control/segmented-control.d.ts +10 -10
- package/dist/components/ui/core/segmented-control/segmented-control.js +203 -149
- package/dist/components/ui/core/segmented-control/segmented-control.js.map +1 -0
- package/dist/components/ui/core/select/select.d.ts +27 -26
- package/dist/components/ui/core/select/select.js +213 -168
- package/dist/components/ui/core/select/select.js.map +1 -0
- package/dist/components/ui/core/separator/separator.d.ts +2 -2
- package/dist/components/ui/core/separator/separator.js +13 -13
- package/dist/components/ui/core/separator/separator.js.map +1 -0
- package/dist/components/ui/core/shimmer/shimmer.d.ts +8 -8
- package/dist/components/ui/core/shimmer/shimmer.js +64 -40
- package/dist/components/ui/core/shimmer/shimmer.js.map +1 -0
- package/dist/components/ui/core/skeleton/skeleton.d.ts +2 -2
- package/dist/components/ui/core/skeleton/skeleton.js +13 -13
- package/dist/components/ui/core/skeleton/skeleton.js.map +1 -0
- package/dist/components/ui/core/slider/slider.d.ts +7 -7
- package/dist/components/ui/core/slider/slider.js +51 -39
- package/dist/components/ui/core/slider/slider.js.map +1 -0
- package/dist/components/ui/core/sonner-toast/sonner-toast.d.ts +2 -2
- package/dist/components/ui/core/sonner-toast/sonner-toast.js +67 -54
- package/dist/components/ui/core/sonner-toast/sonner-toast.js.map +1 -0
- package/dist/components/ui/core/sources/sources.d.ts +12 -12
- package/dist/components/ui/core/sources/sources.js +87 -58
- package/dist/components/ui/core/sources/sources.js.map +1 -0
- package/dist/components/ui/core/switch/switch.d.ts +9 -9
- package/dist/components/ui/core/switch/switch.js +83 -61
- package/dist/components/ui/core/switch/switch.js.map +1 -0
- package/dist/components/ui/core/switch/switch.metadata.d.ts +1 -1
- package/dist/components/ui/core/switch/switch.metadata.js +8 -0
- package/dist/components/ui/core/switch/switch.metadata.js.map +1 -0
- package/dist/components/ui/core/tabs/tabs.d.ts +20 -18
- package/dist/components/ui/core/tabs/tabs.js +176 -147
- package/dist/components/ui/core/tabs/tabs.js.map +1 -0
- package/dist/components/ui/core/tabs/tabs.utils.d.ts +1 -1
- package/dist/components/ui/core/tabs/tabs.utils.js +10 -6
- package/dist/components/ui/core/tabs/tabs.utils.js.map +1 -0
- package/dist/components/ui/core/textarea/textarea.d.ts +2 -2
- package/dist/components/ui/core/textarea/textarea.js +13 -13
- package/dist/components/ui/core/textarea/textarea.js.map +1 -0
- package/dist/components/ui/core/toggle/toggle.d.ts +9 -9
- package/dist/components/ui/core/toggle/toggle.js +60 -54
- package/dist/components/ui/core/toggle/toggle.js.map +1 -0
- package/dist/components/ui/core/tool/tool.d.ts +18 -18
- package/dist/components/ui/core/tool/tool.js +167 -126
- package/dist/components/ui/core/tool/tool.js.map +1 -0
- package/dist/components/ui/core/toolbar/toolbar.d.ts +37 -0
- package/dist/components/ui/core/toolbar/toolbar.js +171 -0
- package/dist/components/ui/core/toolbar/toolbar.js.map +1 -0
- package/dist/components/ui/core/tooltip/tooltip.d.ts +8 -7
- package/dist/components/ui/core/tooltip/tooltip.js +53 -46
- package/dist/components/ui/core/tooltip/tooltip.js.map +1 -0
- package/dist/components/ui/core/topbar/topbar.d.ts +26 -26
- package/dist/components/ui/core/topbar/topbar.js +160 -105
- package/dist/components/ui/core/topbar/topbar.js.map +1 -0
- package/dist/components/ui/core/tree/tree.d.ts +20 -0
- package/dist/components/ui/core/tree/tree.js +100 -0
- package/dist/components/ui/core/tree/tree.js.map +1 -0
- package/dist/eslint/index.d.ts +5 -5
- package/dist/eslint/index.js +9 -5
- package/dist/eslint/index.js.map +1 -0
- package/dist/eslint/no-overriding-styles.d.ts +1 -1
- package/dist/eslint/no-overriding-styles.js +341 -201
- package/dist/eslint/no-overriding-styles.js.map +1 -0
- package/dist/icons/index.d.ts +1 -1
- package/dist/icons/index.js +2 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/ai/types.d.ts +43 -43
- package/dist/lib/ai/types.js +3 -0
- package/dist/lib/ai/types.js.map +1 -0
- package/dist/lib/decorative-variant-classes.d.ts +53 -0
- package/dist/lib/decorative-variant-classes.js +58 -0
- package/dist/lib/decorative-variant-classes.js.map +1 -0
- package/dist/lib/highlight-code.d.ts +11 -8
- package/dist/lib/highlight-code.js +58 -40
- package/dist/lib/highlight-code.js.map +1 -0
- package/dist/lib/portal-container-context.d.ts +1 -1
- package/dist/lib/portal-container-context.js +8 -8
- package/dist/lib/portal-container-context.js.map +1 -0
- package/dist/lib/shared-theme-from-url.d.ts +13 -0
- package/dist/lib/shared-theme-from-url.js +61 -0
- package/dist/lib/shared-theme-from-url.js.map +1 -0
- package/dist/lib/style-scope.d.ts +2 -2
- package/dist/lib/style-scope.js +6 -6
- package/dist/lib/style-scope.js.map +1 -0
- package/dist/lib/theme-share-url.d.ts +31 -0
- package/dist/lib/theme-share-url.js +116 -0
- package/dist/lib/theme-share-url.js.map +1 -0
- package/dist/lib/types.d.ts +39 -39
- package/dist/lib/types.js +3 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/use-controllable-state.d.ts +4 -7
- package/dist/lib/use-controllable-state.js +34 -21
- package/dist/lib/use-controllable-state.js.map +1 -0
- package/dist/lib/utils.d.ts +63 -34
- package/dist/lib/utils.js +134 -32
- package/dist/lib/utils.js.map +1 -0
- package/dist/styles.css +2 -1
- package/dist/styles.source.css +24 -12
- package/dist/utils/assign-ref.d.ts +3 -0
- package/dist/utils/assign-ref.js +13 -0
- package/dist/utils/assign-ref.js.map +1 -0
- package/package.json +46 -11
- package/src/components/ui/core/button/button.md +93 -0
|
@@ -1,44 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { cva
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { cn } from "../../../../lib/utils.js";
|
|
6
|
+
import { Separator } from "../separator/separator.js";
|
|
7
|
+
const buttonGroupVariants = cva("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2", {
|
|
8
|
+
variants: {
|
|
9
|
+
orientation: {
|
|
10
|
+
horizontal: '[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none',
|
|
11
|
+
vertical: 'flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none'
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
orientation: 'horizontal'
|
|
16
|
+
}
|
|
14
17
|
});
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
function ButtonGroup({ className, orientation, ...props }) {
|
|
19
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
20
|
+
role: "group",
|
|
21
|
+
"data-slot": "button-group",
|
|
22
|
+
"data-orientation": orientation,
|
|
23
|
+
className: cn(buttonGroupVariants({
|
|
24
|
+
orientation
|
|
25
|
+
}), className),
|
|
26
|
+
...props
|
|
27
|
+
});
|
|
23
28
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
function ButtonGroupText({ className, render, children, ...props }) {
|
|
30
|
+
return useRender({
|
|
31
|
+
defaultTagName: 'div',
|
|
32
|
+
props: mergeProps({
|
|
33
|
+
className: cn("bg-muted-background flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", className)
|
|
34
|
+
}, {
|
|
35
|
+
...props,
|
|
36
|
+
children
|
|
37
|
+
}),
|
|
38
|
+
render,
|
|
39
|
+
state: {
|
|
40
|
+
slot: 'button-group-text'
|
|
41
|
+
}
|
|
42
|
+
});
|
|
34
43
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
function ButtonGroupSeparator({ className, orientation = 'vertical', ...props }) {
|
|
45
|
+
return /*#__PURE__*/ _jsx(Separator, {
|
|
46
|
+
"data-slot": "button-group-separator",
|
|
47
|
+
orientation: orientation,
|
|
48
|
+
className: cn('bg-muted-background relative m-0 self-stretch data-[orientation=vertical]:h-auto', className),
|
|
49
|
+
...props
|
|
50
|
+
});
|
|
42
51
|
}
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=button-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/button-group/button-group.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\n\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { useRender } from '@base-ui/react/use-render';\nimport { type VariantProps, cva } from 'class-variance-authority';\nimport type { ClassProp } from 'class-variance-authority/types';\n\nimport { cn } from '../../../../lib/utils';\nimport { Separator } from '../separator/separator';\n\nconst buttonGroupVariants: (\n props?:\n | ({\n orientation?: 'horizontal' | 'vertical' | null | undefined;\n } & ClassProp)\n | undefined\n) => string = cva(\n \"flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2\",\n {\n variants: {\n orientation: {\n horizontal:\n '[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none',\n vertical:\n 'flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none',\n },\n },\n defaultVariants: {\n orientation: 'horizontal',\n },\n }\n);\n\nfunction ButtonGroup({\n className,\n orientation,\n ...props\n}: ComponentProps<'div'> &\n VariantProps<typeof buttonGroupVariants>): ReactNode {\n return (\n <div\n role=\"group\"\n data-slot=\"button-group\"\n data-orientation={orientation}\n className={cn(buttonGroupVariants({ orientation }), className)}\n {...props}\n />\n );\n}\n\nfunction ButtonGroupText({\n className,\n render,\n children,\n ...props\n}: useRender.ComponentProps<'div'>): ReactNode {\n return useRender({\n defaultTagName: 'div',\n props: mergeProps<'div'>(\n {\n className: cn(\n \"bg-muted-background flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4\",\n className\n ),\n },\n { ...props, children }\n ),\n render,\n state: {\n slot: 'button-group-text',\n },\n });\n}\n\nfunction ButtonGroupSeparator({\n className,\n orientation = 'vertical',\n ...props\n}: ComponentProps<typeof Separator>): ReactNode {\n return (\n <Separator\n data-slot=\"button-group-separator\"\n orientation={orientation}\n className={cn(\n 'bg-muted-background relative m-0 self-stretch data-[orientation=vertical]:h-auto',\n className\n )}\n {...props}\n />\n );\n}\n\nexport {\n ButtonGroup,\n ButtonGroupSeparator,\n ButtonGroupText,\n buttonGroupVariants,\n};\n"],"names":["mergeProps","useRender","cva","cn","Separator","buttonGroupVariants","variants","orientation","horizontal","vertical","defaultVariants","ButtonGroup","className","props","div","role","data-slot","data-orientation","ButtonGroupText","render","children","defaultTagName","state","slot","ButtonGroupSeparator"],"mappings":";AAEA,SAASA,UAAU,QAAQ,6BAA6B;AACxD,SAASC,SAAS,QAAQ,4BAA4B;AACtD,SAA4BC,GAAG,QAAQ,2BAA2B;AAGlE,SAASC,EAAE,QAAQ,2BAAwB;AAC3C,SAASC,SAAS,QAAQ,4BAAyB;AAEnD,MAAMC,sBAMQH,IACZ,oSACA;IACEI,UAAU;QACRC,aAAa;YACXC,YACE;YACFC,UACE;QACJ;IACF;IACAC,iBAAiB;QACfH,aAAa;IACf;AACF;AAGF,SAASI,YAAY,EACnBC,SAAS,EACTL,WAAW,EACX,GAAGM,OAEqC;IACxC,qBACE,KAACC;QACCC,MAAK;QACLC,aAAU;QACVC,oBAAkBV;QAClBK,WAAWT,GAAGE,oBAAoB;YAAEE;QAAY,IAAIK;QACnD,GAAGC,KAAK;;AAGf;AAEA,SAASK,gBAAgB,EACvBN,SAAS,EACTO,MAAM,EACNC,QAAQ,EACR,GAAGP,OAC6B;IAChC,OAAOZ,UAAU;QACfoB,gBAAgB;QAChBR,OAAOb,WACL;YACEY,WAAWT,GACT,qKACAS;QAEJ,GACA;YAAE,GAAGC,KAAK;YAAEO;QAAS;QAEvBD;QACAG,OAAO;YACLC,MAAM;QACR;IACF;AACF;AAEA,SAASC,qBAAqB,EAC5BZ,SAAS,EACTL,cAAc,UAAU,EACxB,GAAGM,OAC8B;IACjC,qBACE,KAACT;QACCY,aAAU;QACVT,aAAaA;QACbK,WAAWT,GACT,oFACAS;QAED,GAAGC,KAAK;;AAGf;AAEA,SACEF,WAAW,EACXa,oBAAoB,EACpBN,eAAe,EACfb,mBAAmB,GACnB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { FC } from
|
|
2
|
-
import { Dayjs } from
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { Dayjs } from "dayjs";
|
|
3
3
|
export interface CalendarHeaderProps {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
displayedMonth: Dayjs;
|
|
5
|
+
onPrevMonth: () => void;
|
|
6
|
+
onNextMonth: () => void;
|
|
7
|
+
onMonthChange: (month: Dayjs) => void;
|
|
8
|
+
className?: string;
|
|
9
9
|
}
|
|
10
10
|
export declare const CalendarHeader: FC<CalendarHeaderProps>;
|
|
@@ -1,63 +1,102 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { IconChevronDown, IconChevronLeft, IconChevronRight } from "@tabler/icons-react";
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
|
+
import { cn } from "../../../../lib/utils.js";
|
|
5
|
+
import { Button } from "../button/button.js";
|
|
6
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../dropdown-menu/dropdown-menu.js";
|
|
7
|
+
const MONTHS = Array.from({
|
|
8
|
+
length: 12
|
|
9
|
+
}, (_, i)=>dayjs().month(i).format('MMMM'));
|
|
10
|
+
const YEAR_RANGE_START = dayjs().year() - 50;
|
|
11
|
+
const YEAR_RANGE_END = dayjs().year() + 10;
|
|
12
|
+
const YEARS = Array.from({
|
|
13
|
+
length: YEAR_RANGE_END - YEAR_RANGE_START + 1
|
|
14
|
+
}, (_, i)=>YEAR_RANGE_START + i);
|
|
15
|
+
// DropdownMenuItem unmounts on close and remounts on open, so a ref callback on
|
|
16
|
+
// the active item fires exactly when the list opens — scrolling it into view
|
|
17
|
+
// instead of always starting at the top of the (potentially 60-year-long) list.
|
|
18
|
+
const scrollSelectedItemIntoView = (node)=>{
|
|
19
|
+
node?.scrollIntoView?.({
|
|
20
|
+
block: 'center',
|
|
21
|
+
behavior: 'instant'
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const NavigationDropdown = ({ label, items, selectedValue, onSelect })=>/*#__PURE__*/ _jsxs(DropdownMenu, {
|
|
25
|
+
modal: false,
|
|
26
|
+
children: [
|
|
27
|
+
/*#__PURE__*/ _jsx(DropdownMenuTrigger, {
|
|
28
|
+
render: /*#__PURE__*/ _jsxs(Button, {
|
|
29
|
+
variant: "ghost",
|
|
30
|
+
size: "sm",
|
|
31
|
+
className: "h-7 px-2 gap-1 text-sm font-medium text-secondary-foreground",
|
|
32
|
+
children: [
|
|
33
|
+
label,
|
|
34
|
+
/*#__PURE__*/ _jsx(IconChevronDown, {
|
|
35
|
+
className: "size-4"
|
|
36
|
+
})
|
|
37
|
+
]
|
|
38
|
+
})
|
|
39
|
+
}),
|
|
40
|
+
/*#__PURE__*/ _jsx(DropdownMenuContent, {
|
|
41
|
+
className: "max-h-60 overflow-y-auto",
|
|
42
|
+
children: items.map(({ value, label: itemLabel })=>/*#__PURE__*/ _jsx(DropdownMenuItem, {
|
|
43
|
+
ref: value === selectedValue ? scrollSelectedItemIntoView : undefined,
|
|
44
|
+
onClick: ()=>onSelect(value),
|
|
45
|
+
children: itemLabel
|
|
46
|
+
}, value))
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
export const CalendarHeader = ({ displayedMonth, onPrevMonth, onNextMonth, onMonthChange, className })=>{
|
|
51
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
52
|
+
"data-slot": "calendar-header",
|
|
53
|
+
className: cn('flex items-center justify-between pt-1 w-full', className),
|
|
54
|
+
children: [
|
|
55
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
56
|
+
variant: "ghost",
|
|
57
|
+
size: "icon-sm",
|
|
58
|
+
className: "size-7 rounded-md text-secondary-foreground",
|
|
59
|
+
onClick: onPrevMonth,
|
|
60
|
+
"aria-label": "Previous month",
|
|
61
|
+
children: /*#__PURE__*/ _jsx(IconChevronLeft, {
|
|
62
|
+
className: "size-4"
|
|
63
|
+
})
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
66
|
+
className: "flex items-center gap-0.5",
|
|
67
|
+
children: [
|
|
68
|
+
/*#__PURE__*/ _jsx(NavigationDropdown, {
|
|
69
|
+
label: displayedMonth.format('MMMM'),
|
|
70
|
+
items: MONTHS.map((name, i)=>({
|
|
71
|
+
value: i,
|
|
72
|
+
label: name
|
|
73
|
+
})),
|
|
74
|
+
selectedValue: displayedMonth.month(),
|
|
75
|
+
onSelect: (i)=>onMonthChange(displayedMonth.date(1).month(i))
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ _jsx(NavigationDropdown, {
|
|
78
|
+
label: displayedMonth.format('YYYY'),
|
|
79
|
+
items: YEARS.map((y)=>({
|
|
80
|
+
value: y,
|
|
81
|
+
label: String(y)
|
|
82
|
+
})),
|
|
83
|
+
selectedValue: displayedMonth.year(),
|
|
84
|
+
onSelect: (y)=>onMonthChange(displayedMonth.date(1).year(y))
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
}),
|
|
88
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
89
|
+
variant: "ghost",
|
|
90
|
+
size: "icon-sm",
|
|
91
|
+
className: "size-7 rounded-md text-secondary-foreground",
|
|
92
|
+
onClick: onNextMonth,
|
|
93
|
+
"aria-label": "Next month",
|
|
94
|
+
children: /*#__PURE__*/ _jsx(IconChevronRight, {
|
|
95
|
+
className: "size-4"
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=calendar-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/calendar/calendar-header.tsx"],"sourcesContent":["import type { FC } from 'react';\n\nimport {\n IconChevronDown,\n IconChevronLeft,\n IconChevronRight,\n} from '@tabler/icons-react';\nimport type { Dayjs } from 'dayjs';\nimport dayjs from 'dayjs';\n\nimport { cn } from '../../../../lib/utils';\nimport { Button } from '../button/button';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from '../dropdown-menu/dropdown-menu';\n\nconst MONTHS = Array.from({ length: 12 }, (_: unknown, i: number) =>\n dayjs().month(i).format('MMMM')\n);\n\nconst YEAR_RANGE_START = dayjs().year() - 50;\nconst YEAR_RANGE_END = dayjs().year() + 10;\nconst YEARS = Array.from(\n { length: YEAR_RANGE_END - YEAR_RANGE_START + 1 },\n (_: unknown, i: number) => YEAR_RANGE_START + i\n);\n\ninterface NavigationDropdownItem {\n value: number;\n label: string;\n}\n\ninterface NavigationDropdownProps {\n label: string;\n items: NavigationDropdownItem[];\n selectedValue: number;\n onSelect: (value: number) => void;\n}\n\n// DropdownMenuItem unmounts on close and remounts on open, so a ref callback on\n// the active item fires exactly when the list opens — scrolling it into view\n// instead of always starting at the top of the (potentially 60-year-long) list.\nconst scrollSelectedItemIntoView = (node: HTMLElement | null) => {\n node?.scrollIntoView?.({ block: 'center', behavior: 'instant' });\n};\n\nconst NavigationDropdown: FC<NavigationDropdownProps> = ({\n label,\n items,\n selectedValue,\n onSelect,\n}) => (\n <DropdownMenu modal={false}>\n <DropdownMenuTrigger\n render={\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-7 px-2 gap-1 text-sm font-medium text-secondary-foreground\"\n >\n {label}\n <IconChevronDown className=\"size-4\" />\n </Button>\n }\n />\n <DropdownMenuContent className=\"max-h-60 overflow-y-auto\">\n {items.map(({ value, label: itemLabel }) => (\n <DropdownMenuItem\n key={value}\n ref={value === selectedValue ? scrollSelectedItemIntoView : undefined}\n onClick={() => onSelect(value)}\n >\n {itemLabel}\n </DropdownMenuItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n);\n\nexport interface CalendarHeaderProps {\n displayedMonth: Dayjs;\n onPrevMonth: () => void;\n onNextMonth: () => void;\n onMonthChange: (month: Dayjs) => void;\n className?: string;\n}\n\nexport const CalendarHeader: FC<CalendarHeaderProps> = ({\n displayedMonth,\n onPrevMonth,\n onNextMonth,\n onMonthChange,\n className,\n}) => {\n return (\n <div\n data-slot=\"calendar-header\"\n className={cn('flex items-center justify-between pt-1 w-full', className)}\n >\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"size-7 rounded-md text-secondary-foreground\"\n onClick={onPrevMonth}\n aria-label=\"Previous month\"\n >\n <IconChevronLeft className=\"size-4\" />\n </Button>\n <div className=\"flex items-center gap-0.5\">\n <NavigationDropdown\n label={displayedMonth.format('MMMM')}\n items={MONTHS.map((name, i) => ({ value: i, label: name }))}\n selectedValue={displayedMonth.month()}\n onSelect={(i) => onMonthChange(displayedMonth.date(1).month(i))}\n />\n <NavigationDropdown\n label={displayedMonth.format('YYYY')}\n items={YEARS.map((y) => ({ value: y, label: String(y) }))}\n selectedValue={displayedMonth.year()}\n onSelect={(y) => onMonthChange(displayedMonth.date(1).year(y))}\n />\n </div>\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"size-7 rounded-md text-secondary-foreground\"\n onClick={onNextMonth}\n aria-label=\"Next month\"\n >\n <IconChevronRight className=\"size-4\" />\n </Button>\n </div>\n );\n};\n"],"names":["IconChevronDown","IconChevronLeft","IconChevronRight","dayjs","cn","Button","DropdownMenu","DropdownMenuContent","DropdownMenuItem","DropdownMenuTrigger","MONTHS","Array","from","length","_","i","month","format","YEAR_RANGE_START","year","YEAR_RANGE_END","YEARS","scrollSelectedItemIntoView","node","scrollIntoView","block","behavior","NavigationDropdown","label","items","selectedValue","onSelect","modal","render","variant","size","className","map","value","itemLabel","ref","undefined","onClick","CalendarHeader","displayedMonth","onPrevMonth","onNextMonth","onMonthChange","div","data-slot","aria-label","name","date","y","String"],"mappings":";AAEA,SACEA,eAAe,EACfC,eAAe,EACfC,gBAAgB,QACX,sBAAsB;AAE7B,OAAOC,WAAW,QAAQ;AAE1B,SAASC,EAAE,QAAQ,2BAAwB;AAC3C,SAASC,MAAM,QAAQ,sBAAmB;AAC1C,SACEC,YAAY,EACZC,mBAAmB,EACnBC,gBAAgB,EAChBC,mBAAmB,QACd,oCAAiC;AAExC,MAAMC,SAASC,MAAMC,IAAI,CAAC;IAAEC,QAAQ;AAAG,GAAG,CAACC,GAAYC,IACrDZ,QAAQa,KAAK,CAACD,GAAGE,MAAM,CAAC;AAG1B,MAAMC,mBAAmBf,QAAQgB,IAAI,KAAK;AAC1C,MAAMC,iBAAiBjB,QAAQgB,IAAI,KAAK;AACxC,MAAME,QAAQV,MAAMC,IAAI,CACtB;IAAEC,QAAQO,iBAAiBF,mBAAmB;AAAE,GAChD,CAACJ,GAAYC,IAAcG,mBAAmBH;AAehD,gFAAgF;AAChF,6EAA6E;AAC7E,gFAAgF;AAChF,MAAMO,6BAA6B,CAACC;IAClCA,MAAMC,iBAAiB;QAAEC,OAAO;QAAUC,UAAU;IAAU;AAChE;AAEA,MAAMC,qBAAkD,CAAC,EACvDC,KAAK,EACLC,KAAK,EACLC,aAAa,EACbC,QAAQ,EACT,iBACC,MAACzB;QAAa0B,OAAO;;0BACnB,KAACvB;gBACCwB,sBACE,MAAC5B;oBACC6B,SAAQ;oBACRC,MAAK;oBACLC,WAAU;;wBAETR;sCACD,KAAC5B;4BAAgBoC,WAAU;;;;;0BAIjC,KAAC7B;gBAAoB6B,WAAU;0BAC5BP,MAAMQ,GAAG,CAAC,CAAC,EAAEC,KAAK,EAAEV,OAAOW,SAAS,EAAE,iBACrC,KAAC/B;wBAECgC,KAAKF,UAAUR,gBAAgBR,6BAA6BmB;wBAC5DC,SAAS,IAAMX,SAASO;kCAEvBC;uBAJID;;;;AAmBf,OAAO,MAAMK,iBAA0C,CAAC,EACtDC,cAAc,EACdC,WAAW,EACXC,WAAW,EACXC,aAAa,EACbX,SAAS,EACV;IACC,qBACE,MAACY;QACCC,aAAU;QACVb,WAAWhC,GAAG,iDAAiDgC;;0BAE/D,KAAC/B;gBACC6B,SAAQ;gBACRC,MAAK;gBACLC,WAAU;gBACVM,SAASG;gBACTK,cAAW;0BAEX,cAAA,KAACjD;oBAAgBmC,WAAU;;;0BAE7B,MAACY;gBAAIZ,WAAU;;kCACb,KAACT;wBACCC,OAAOgB,eAAe3B,MAAM,CAAC;wBAC7BY,OAAOnB,OAAO2B,GAAG,CAAC,CAACc,MAAMpC,IAAO,CAAA;gCAAEuB,OAAOvB;gCAAGa,OAAOuB;4BAAK,CAAA;wBACxDrB,eAAec,eAAe5B,KAAK;wBACnCe,UAAU,CAAChB,IAAMgC,cAAcH,eAAeQ,IAAI,CAAC,GAAGpC,KAAK,CAACD;;kCAE9D,KAACY;wBACCC,OAAOgB,eAAe3B,MAAM,CAAC;wBAC7BY,OAAOR,MAAMgB,GAAG,CAAC,CAACgB,IAAO,CAAA;gCAAEf,OAAOe;gCAAGzB,OAAO0B,OAAOD;4BAAG,CAAA;wBACtDvB,eAAec,eAAezB,IAAI;wBAClCY,UAAU,CAACsB,IAAMN,cAAcH,eAAeQ,IAAI,CAAC,GAAGjC,IAAI,CAACkC;;;;0BAG/D,KAAChD;gBACC6B,SAAQ;gBACRC,MAAK;gBACLC,WAAU;gBACVM,SAASI;gBACTI,cAAW;0BAEX,cAAA,KAAChD;oBAAiBkC,WAAU;;;;;AAIpC,EAAE"}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { Dayjs } from
|
|
1
|
+
import { type Dayjs } from "dayjs";
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
* Get all days to display in a calendar month grid (including padding days from prev/next months)
|
|
4
|
+
* @param month - The month to display
|
|
5
|
+
* @param locale - Optional locale for week start day (e.g., 'en', 'nb', 'de')
|
|
6
|
+
*/
|
|
7
7
|
export declare function getCalendarDays(month: Dayjs, locale?: string): Dayjs[];
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
* Check if a date is within a given range (inclusive)
|
|
10
|
+
* Uses dayjs isBetween plugin with '[]' for inclusive start and end
|
|
11
|
+
* @see https://day.js.org/docs/en/plugin/is-between
|
|
12
|
+
*/
|
|
13
13
|
export declare function isDateInRange(date: Dayjs, startDate: Dayjs | null, endDate: Dayjs | null): boolean;
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
* Check if a date is outside the current display month
|
|
16
|
+
*/
|
|
17
17
|
export declare function isOutsideMonth(date: Dayjs, displayMonth: Dayjs): boolean;
|
|
18
18
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
* Check if a date is today
|
|
20
|
+
* Note: Uses local timezone. Both the input date and current time are compared
|
|
21
|
+
* using the user's local timezone, which is the expected behavior for calendar UIs.
|
|
22
|
+
* @param date - The date to check
|
|
23
|
+
* @param now - Optional current date for testing (defaults to dayjs())
|
|
24
|
+
*/
|
|
25
25
|
export declare function isToday(date: Dayjs, now?: Dayjs): boolean;
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
* Get an array of weekday names (short form)
|
|
28
|
+
* @param locale - Optional locale for localized weekday names (e.g., 'en', 'nb', 'de')
|
|
29
|
+
* @param baseDate - Optional base date for testing (defaults to dayjs())
|
|
30
|
+
*/
|
|
31
31
|
export declare function getWeekdayNames(locale?: string, baseDate?: Dayjs): string[];
|
|
32
32
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
* Get the week number for a given date
|
|
34
|
+
*/
|
|
35
35
|
export declare function getWeekNumber(date: Dayjs): number;
|
|
36
36
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
* Get all week numbers for days in a calendar month grid
|
|
38
|
+
*/
|
|
39
39
|
export declare function getWeekNumbers(days: Dayjs[]): number[];
|
|
40
40
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
* Check if two dates are the same day
|
|
42
|
+
*/
|
|
43
43
|
export declare function isSameDay(date1: Dayjs | null, date2: Dayjs | null): boolean;
|
|
44
44
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
* Format a date range for display
|
|
46
|
+
* When one date is missing, shows the format placeholder for the missing date
|
|
47
|
+
*/
|
|
48
48
|
export declare function formatDateRange(startDate: Dayjs | null, endDate: Dayjs | null, format: string): string;
|
|
@@ -1,39 +1,116 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import isBetween from "dayjs/plugin/isBetween.js";
|
|
3
|
+
import isSameOrBefore from "dayjs/plugin/isSameOrBefore.js";
|
|
4
|
+
import weekOfYear from "dayjs/plugin/weekOfYear.js";
|
|
5
|
+
import { DAYS_IN_WEEK } from "./constants.js";
|
|
6
|
+
dayjs.extend(isBetween);
|
|
7
|
+
dayjs.extend(isSameOrBefore);
|
|
8
|
+
dayjs.extend(weekOfYear);
|
|
9
|
+
const DATE_RANGE_SEPARATOR = ' – ';
|
|
10
|
+
/**
|
|
11
|
+
* Get all days to display in a calendar month grid (including padding days from prev/next months)
|
|
12
|
+
* @param month - The month to display
|
|
13
|
+
* @param locale - Optional locale for week start day (e.g., 'en', 'nb', 'de')
|
|
14
|
+
*/ export function getCalendarDays(month, locale) {
|
|
15
|
+
// Create a localized instance without mutating global state
|
|
16
|
+
const localizedMonth = locale ? month.locale(locale) : month;
|
|
17
|
+
const firstDayOfMonth = localizedMonth.startOf('month');
|
|
18
|
+
const firstDayOfGrid = firstDayOfMonth.startOf('week');
|
|
19
|
+
const lastDayOfMonth = localizedMonth.endOf('month');
|
|
20
|
+
const lastDayOfGrid = lastDayOfMonth.endOf('week');
|
|
21
|
+
const days = [];
|
|
22
|
+
let currentDay = firstDayOfGrid;
|
|
23
|
+
while(currentDay.isSameOrBefore(lastDayOfGrid, 'day')){
|
|
24
|
+
days.push(currentDay);
|
|
25
|
+
currentDay = currentDay.add(1, 'day');
|
|
26
|
+
}
|
|
27
|
+
return days;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Check if a date is within a given range (inclusive)
|
|
31
|
+
* Uses dayjs isBetween plugin with '[]' for inclusive start and end
|
|
32
|
+
* @see https://day.js.org/docs/en/plugin/is-between
|
|
33
|
+
*/ export function isDateInRange(date, startDate, endDate) {
|
|
34
|
+
if (!startDate || !endDate) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
// Validate all dates are valid
|
|
38
|
+
if (!date.isValid() || !startDate.isValid() || !endDate.isValid()) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
// If start is after end, the range is invalid
|
|
42
|
+
if (startDate.isAfter(endDate, 'day')) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
// 'day' granularity ignores time, '[]' includes both start and end
|
|
46
|
+
return date.isBetween(startDate, endDate, 'day', '[]');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Check if a date is outside the current display month
|
|
50
|
+
*/ export function isOutsideMonth(date, displayMonth) {
|
|
51
|
+
return date.month() !== displayMonth.month();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Check if a date is today
|
|
55
|
+
* Note: Uses local timezone. Both the input date and current time are compared
|
|
56
|
+
* using the user's local timezone, which is the expected behavior for calendar UIs.
|
|
57
|
+
* @param date - The date to check
|
|
58
|
+
* @param now - Optional current date for testing (defaults to dayjs())
|
|
59
|
+
*/ export function isToday(date, now) {
|
|
60
|
+
return date.isSame(now ?? dayjs(), 'day');
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get an array of weekday names (short form)
|
|
64
|
+
* @param locale - Optional locale for localized weekday names (e.g., 'en', 'nb', 'de')
|
|
65
|
+
* @param baseDate - Optional base date for testing (defaults to dayjs())
|
|
66
|
+
*/ export function getWeekdayNames(locale, baseDate) {
|
|
67
|
+
const base = baseDate || dayjs();
|
|
68
|
+
// Create a localized instance without mutating global state
|
|
69
|
+
const localizedDayjs = locale ? base.locale(locale) : base;
|
|
70
|
+
// Calculate startOfWeek using the localized instance
|
|
71
|
+
const startOfWeek = localizedDayjs.startOf('week');
|
|
72
|
+
return Array.from({
|
|
73
|
+
length: DAYS_IN_WEEK
|
|
74
|
+
}, (_, i)=>{
|
|
75
|
+
return startOfWeek.add(i, 'day').format('dd');
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get the week number for a given date
|
|
80
|
+
*/ export function getWeekNumber(date) {
|
|
81
|
+
return date.week();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get all week numbers for days in a calendar month grid
|
|
85
|
+
*/ export function getWeekNumbers(days) {
|
|
86
|
+
const weekNumbers = [];
|
|
87
|
+
// Process days in chunks of DAYS_IN_WEEK (one week at a time)
|
|
88
|
+
for(let i = 0; i < days.length; i += DAYS_IN_WEEK){
|
|
89
|
+
const firstDayOfWeek = days[i];
|
|
90
|
+
if (firstDayOfWeek) {
|
|
91
|
+
weekNumbers.push(getWeekNumber(firstDayOfWeek));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return weekNumbers;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Check if two dates are the same day
|
|
98
|
+
*/ export function isSameDay(date1, date2) {
|
|
99
|
+
if (!date1 || !date2) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return date1.isSame(date2, 'day');
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Format a date range for display
|
|
106
|
+
* When one date is missing, shows the format placeholder for the missing date
|
|
107
|
+
*/ export function formatDateRange(startDate, endDate, format) {
|
|
108
|
+
if (!startDate && !endDate) {
|
|
109
|
+
return '';
|
|
110
|
+
}
|
|
111
|
+
const startStr = startDate?.format(format) ?? format;
|
|
112
|
+
const endStr = endDate?.format(format) ?? format;
|
|
113
|
+
return `${startStr}${DATE_RANGE_SEPARATOR}${endStr}`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=calendar-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/calendar/calendar-utils.ts"],"sourcesContent":["import dayjs, { type Dayjs } from 'dayjs';\nimport isBetween from 'dayjs/plugin/isBetween.js';\nimport isSameOrBefore from 'dayjs/plugin/isSameOrBefore.js';\nimport weekOfYear from 'dayjs/plugin/weekOfYear.js';\n\nimport { DAYS_IN_WEEK } from './constants';\n\ndayjs.extend(isBetween);\ndayjs.extend(isSameOrBefore);\ndayjs.extend(weekOfYear);\n\nconst DATE_RANGE_SEPARATOR = ' – ';\n\n/**\n * Get all days to display in a calendar month grid (including padding days from prev/next months)\n * @param month - The month to display\n * @param locale - Optional locale for week start day (e.g., 'en', 'nb', 'de')\n */\nexport function getCalendarDays(month: Dayjs, locale?: string): Dayjs[] {\n // Create a localized instance without mutating global state\n const localizedMonth = locale ? month.locale(locale) : month;\n\n const firstDayOfMonth = localizedMonth.startOf('month');\n const firstDayOfGrid = firstDayOfMonth.startOf('week');\n\n const lastDayOfMonth = localizedMonth.endOf('month');\n const lastDayOfGrid = lastDayOfMonth.endOf('week');\n\n const days: Dayjs[] = [];\n\n let currentDay = firstDayOfGrid;\n\n while (currentDay.isSameOrBefore(lastDayOfGrid, 'day')) {\n days.push(currentDay);\n currentDay = currentDay.add(1, 'day');\n }\n\n return days;\n}\n\n/**\n * Check if a date is within a given range (inclusive)\n * Uses dayjs isBetween plugin with '[]' for inclusive start and end\n * @see https://day.js.org/docs/en/plugin/is-between\n */\nexport function isDateInRange(\n date: Dayjs,\n startDate: Dayjs | null,\n endDate: Dayjs | null\n): boolean {\n if (!startDate || !endDate) {\n return false;\n }\n\n // Validate all dates are valid\n if (!date.isValid() || !startDate.isValid() || !endDate.isValid()) {\n return false;\n }\n\n // If start is after end, the range is invalid\n if (startDate.isAfter(endDate, 'day')) {\n return false;\n }\n\n // 'day' granularity ignores time, '[]' includes both start and end\n return date.isBetween(startDate, endDate, 'day', '[]');\n}\n\n/**\n * Check if a date is outside the current display month\n */\nexport function isOutsideMonth(date: Dayjs, displayMonth: Dayjs): boolean {\n return date.month() !== displayMonth.month();\n}\n\n/**\n * Check if a date is today\n * Note: Uses local timezone. Both the input date and current time are compared\n * using the user's local timezone, which is the expected behavior for calendar UIs.\n * @param date - The date to check\n * @param now - Optional current date for testing (defaults to dayjs())\n */\nexport function isToday(date: Dayjs, now?: Dayjs): boolean {\n return date.isSame(now ?? dayjs(), 'day');\n}\n\n/**\n * Get an array of weekday names (short form)\n * @param locale - Optional locale for localized weekday names (e.g., 'en', 'nb', 'de')\n * @param baseDate - Optional base date for testing (defaults to dayjs())\n */\nexport function getWeekdayNames(locale?: string, baseDate?: Dayjs): string[] {\n const base = baseDate || dayjs();\n\n // Create a localized instance without mutating global state\n const localizedDayjs = locale ? base.locale(locale) : base;\n\n // Calculate startOfWeek using the localized instance\n const startOfWeek = localizedDayjs.startOf('week');\n\n return Array.from({ length: DAYS_IN_WEEK }, (_, i) => {\n return startOfWeek.add(i, 'day').format('dd');\n });\n}\n\n/**\n * Get the week number for a given date\n */\nexport function getWeekNumber(date: Dayjs): number {\n return date.week();\n}\n\n/**\n * Get all week numbers for days in a calendar month grid\n */\nexport function getWeekNumbers(days: Dayjs[]): number[] {\n const weekNumbers: number[] = [];\n\n // Process days in chunks of DAYS_IN_WEEK (one week at a time)\n for (let i = 0; i < days.length; i += DAYS_IN_WEEK) {\n const firstDayOfWeek = days[i];\n if (firstDayOfWeek) {\n weekNumbers.push(getWeekNumber(firstDayOfWeek));\n }\n }\n\n return weekNumbers;\n}\n\n/**\n * Check if two dates are the same day\n */\nexport function isSameDay(date1: Dayjs | null, date2: Dayjs | null): boolean {\n if (!date1 || !date2) {\n return false;\n }\n return date1.isSame(date2, 'day');\n}\n\n/**\n * Format a date range for display\n * When one date is missing, shows the format placeholder for the missing date\n */\nexport function formatDateRange(\n startDate: Dayjs | null,\n endDate: Dayjs | null,\n format: string\n): string {\n if (!startDate && !endDate) {\n return '';\n }\n\n const startStr = startDate?.format(format) ?? format;\n const endStr = endDate?.format(format) ?? format;\n\n return `${startStr}${DATE_RANGE_SEPARATOR}${endStr}`;\n}\n"],"names":["dayjs","isBetween","isSameOrBefore","weekOfYear","DAYS_IN_WEEK","extend","DATE_RANGE_SEPARATOR","getCalendarDays","month","locale","localizedMonth","firstDayOfMonth","startOf","firstDayOfGrid","lastDayOfMonth","endOf","lastDayOfGrid","days","currentDay","push","add","isDateInRange","date","startDate","endDate","isValid","isAfter","isOutsideMonth","displayMonth","isToday","now","isSame","getWeekdayNames","baseDate","base","localizedDayjs","startOfWeek","Array","from","length","_","i","format","getWeekNumber","week","getWeekNumbers","weekNumbers","firstDayOfWeek","isSameDay","date1","date2","formatDateRange","startStr","endStr"],"mappings":"AAAA,OAAOA,WAA2B,QAAQ;AAC1C,OAAOC,eAAe,4BAA4B;AAClD,OAAOC,oBAAoB,iCAAiC;AAC5D,OAAOC,gBAAgB,6BAA6B;AAEpD,SAASC,YAAY,QAAQ,iBAAc;AAE3CJ,MAAMK,MAAM,CAACJ;AACbD,MAAMK,MAAM,CAACH;AACbF,MAAMK,MAAM,CAACF;AAEb,MAAMG,uBAAuB;AAE7B;;;;CAIC,GACD,OAAO,SAASC,gBAAgBC,KAAY,EAAEC,MAAe;IAC3D,4DAA4D;IAC5D,MAAMC,iBAAiBD,SAASD,MAAMC,MAAM,CAACA,UAAUD;IAEvD,MAAMG,kBAAkBD,eAAeE,OAAO,CAAC;IAC/C,MAAMC,iBAAiBF,gBAAgBC,OAAO,CAAC;IAE/C,MAAME,iBAAiBJ,eAAeK,KAAK,CAAC;IAC5C,MAAMC,gBAAgBF,eAAeC,KAAK,CAAC;IAE3C,MAAME,OAAgB,EAAE;IAExB,IAAIC,aAAaL;IAEjB,MAAOK,WAAWhB,cAAc,CAACc,eAAe,OAAQ;QACtDC,KAAKE,IAAI,CAACD;QACVA,aAAaA,WAAWE,GAAG,CAAC,GAAG;IACjC;IAEA,OAAOH;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASI,cACdC,IAAW,EACXC,SAAuB,EACvBC,OAAqB;IAErB,IAAI,CAACD,aAAa,CAACC,SAAS;QAC1B,OAAO;IACT;IAEA,+BAA+B;IAC/B,IAAI,CAACF,KAAKG,OAAO,MAAM,CAACF,UAAUE,OAAO,MAAM,CAACD,QAAQC,OAAO,IAAI;QACjE,OAAO;IACT;IAEA,8CAA8C;IAC9C,IAAIF,UAAUG,OAAO,CAACF,SAAS,QAAQ;QACrC,OAAO;IACT;IAEA,mEAAmE;IACnE,OAAOF,KAAKrB,SAAS,CAACsB,WAAWC,SAAS,OAAO;AACnD;AAEA;;CAEC,GACD,OAAO,SAASG,eAAeL,IAAW,EAAEM,YAAmB;IAC7D,OAAON,KAAKd,KAAK,OAAOoB,aAAapB,KAAK;AAC5C;AAEA;;;;;;CAMC,GACD,OAAO,SAASqB,QAAQP,IAAW,EAAEQ,GAAW;IAC9C,OAAOR,KAAKS,MAAM,CAACD,OAAO9B,SAAS;AACrC;AAEA;;;;CAIC,GACD,OAAO,SAASgC,gBAAgBvB,MAAe,EAAEwB,QAAgB;IAC/D,MAAMC,OAAOD,YAAYjC;IAEzB,4DAA4D;IAC5D,MAAMmC,iBAAiB1B,SAASyB,KAAKzB,MAAM,CAACA,UAAUyB;IAEtD,qDAAqD;IACrD,MAAME,cAAcD,eAAevB,OAAO,CAAC;IAE3C,OAAOyB,MAAMC,IAAI,CAAC;QAAEC,QAAQnC;IAAa,GAAG,CAACoC,GAAGC;QAC9C,OAAOL,YAAYhB,GAAG,CAACqB,GAAG,OAAOC,MAAM,CAAC;IAC1C;AACF;AAEA;;CAEC,GACD,OAAO,SAASC,cAAcrB,IAAW;IACvC,OAAOA,KAAKsB,IAAI;AAClB;AAEA;;CAEC,GACD,OAAO,SAASC,eAAe5B,IAAa;IAC1C,MAAM6B,cAAwB,EAAE;IAEhC,8DAA8D;IAC9D,IAAK,IAAIL,IAAI,GAAGA,IAAIxB,KAAKsB,MAAM,EAAEE,KAAKrC,aAAc;QAClD,MAAM2C,iBAAiB9B,IAAI,CAACwB,EAAE;QAC9B,IAAIM,gBAAgB;YAClBD,YAAY3B,IAAI,CAACwB,cAAcI;QACjC;IACF;IAEA,OAAOD;AACT;AAEA;;CAEC,GACD,OAAO,SAASE,UAAUC,KAAmB,EAAEC,KAAmB;IAChE,IAAI,CAACD,SAAS,CAACC,OAAO;QACpB,OAAO;IACT;IACA,OAAOD,MAAMlB,MAAM,CAACmB,OAAO;AAC7B;AAEA;;;CAGC,GACD,OAAO,SAASC,gBACd5B,SAAuB,EACvBC,OAAqB,EACrBkB,MAAc;IAEd,IAAI,CAACnB,aAAa,CAACC,SAAS;QAC1B,OAAO;IACT;IAEA,MAAM4B,WAAW7B,WAAWmB,OAAOA,WAAWA;IAC9C,MAAMW,SAAS7B,SAASkB,OAAOA,WAAWA;IAE1C,OAAO,GAAGU,WAAW9C,uBAAuB+C,QAAQ;AACtD"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { FC } from
|
|
2
|
-
import { Dayjs } from
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
import type { Dayjs } from "dayjs";
|
|
3
3
|
export interface CalendarProps {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
displayedMonth: Dayjs;
|
|
5
|
+
selectedRange: [Dayjs | null, Dayjs | null];
|
|
6
|
+
hoverDate: Dayjs | null;
|
|
7
|
+
displayWeekNumber?: boolean;
|
|
8
|
+
onDateClick: (date: Dayjs) => void;
|
|
9
|
+
onMonthChange: (month: Dayjs) => void;
|
|
10
|
+
onDateHover?: (date: Dayjs | null) => void;
|
|
11
|
+
className?: string;
|
|
12
12
|
}
|
|
13
13
|
export declare const Calendar: FC<CalendarProps>;
|