@boostdev/design-system-components 2.8.0 → 2.11.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/AGENTS.md +54 -46
- package/README.md +34 -20
- package/dist/client.cjs +1317 -779
- package/dist/client.css +1029 -812
- package/dist/client.d.cts +88 -26
- package/dist/client.d.ts +88 -26
- package/dist/client.js +1278 -732
- package/dist/index.cjs +1317 -779
- package/dist/index.css +1029 -812
- package/dist/index.d.cts +88 -26
- package/dist/index.d.ts +88 -26
- package/dist/index.js +1278 -732
- package/dist/web-components/chunk-2OLVQUBU.js +193 -0
- package/dist/web-components/{chunk-OF6FFGOT.js → chunk-3AY2YKCM.js} +77 -21
- package/dist/web-components/chunk-3WAV6MDN.js +212 -0
- package/dist/web-components/{chunk-UUKSDCYS.js → chunk-47AT5KZD.js} +87 -15
- package/dist/web-components/chunk-4A2YYTYN.js +93 -0
- package/dist/web-components/{chunk-Q4T5BJT6.js → chunk-62NK3ZSC.js} +18 -3
- package/dist/web-components/chunk-66M6ETWD.js +77 -0
- package/dist/web-components/{chunk-NCPQ7AF3.js → chunk-6G22I2CK.js} +18 -3
- package/dist/web-components/{chunk-QDST57JC.js → chunk-7ZOJ7N4E.js} +14 -4
- package/dist/web-components/{chunk-QLT6MTZF.js → chunk-AIBOHNDU.js} +10 -0
- package/dist/web-components/{chunk-X3NQMBAQ.js → chunk-AP4RDUL2.js} +14 -3
- package/dist/web-components/{chunk-QWPACK5L.js → chunk-BPYKZVDK.js} +11 -1
- package/dist/web-components/{chunk-YLVTEY23.js → chunk-BTCMJQKB.js} +53 -21
- package/dist/web-components/chunk-CUKQ2L5B.js +245 -0
- package/dist/web-components/chunk-DIZDCL7Z.js +14 -0
- package/dist/web-components/{chunk-PC3IOQAH.js → chunk-DV5T43ZC.js} +27 -7
- package/dist/web-components/{chunk-2QA62WCQ.js → chunk-EF7IVYTY.js} +10 -0
- package/dist/web-components/{chunk-L3XHOMN6.js → chunk-F3ZDNHZZ.js} +26 -1
- package/dist/web-components/chunk-FEDABOR5.js +248 -0
- package/dist/web-components/{chunk-6I2DBFQ7.js → chunk-HGFCJXOQ.js} +36 -5
- package/dist/web-components/{chunk-SOQQ7RVJ.js → chunk-IPGHUCJT.js} +23 -8
- package/dist/web-components/chunk-ITD2MV5K.js +392 -0
- package/dist/web-components/{chunk-ARMKC4BQ.js → chunk-JH6LQKLK.js} +77 -5
- package/dist/web-components/chunk-JMCXAAFK.js +120 -0
- package/dist/web-components/{chunk-KUI55GFB.js → chunk-JUPCZVVW.js} +50 -18
- package/dist/web-components/chunk-JV5QT2OU.js +146 -0
- package/dist/web-components/{chunk-3GFWLSLS.js → chunk-KA3VPKMY.js} +29 -6
- package/dist/web-components/{chunk-CR5PGUHV.js → chunk-KJGRFDFI.js} +26 -11
- package/dist/web-components/{chunk-PY62FTRW.js → chunk-KZPRFY5P.js} +68 -33
- package/dist/web-components/{chunk-X46KL5BK.js → chunk-LDIPCTRN.js} +18 -1
- package/dist/web-components/chunk-M3ECULRH.js +174 -0
- package/dist/web-components/chunk-NBN2ENWJ.js +90 -0
- package/dist/web-components/chunk-NIN3JO6Q.js +189 -0
- package/dist/web-components/{chunk-2FGATTGT.js → chunk-NTQ4TCUT.js} +76 -55
- package/dist/web-components/chunk-OY74D4X6.js +302 -0
- package/dist/web-components/{chunk-3S42DZ7W.js → chunk-P24JYC5V.js} +7 -0
- package/dist/web-components/{chunk-BKIHQYJR.js → chunk-PXPPKCLT.js} +17 -2
- package/dist/web-components/{chunk-TQ7IQ4GZ.js → chunk-QEF2IRID.js} +71 -29
- package/dist/web-components/chunk-QZAIRJ75.js +111 -0
- package/dist/web-components/{chunk-6I3CFC26.js → chunk-RSZ3BWBK.js} +20 -5
- package/dist/web-components/chunk-RVF7W653.js +101 -0
- package/dist/web-components/chunk-SEO2F5KJ.js +234 -0
- package/dist/web-components/{chunk-VMMVWLXL.js → chunk-SFZ6Q4BP.js} +10 -0
- package/dist/web-components/{chunk-LY62SAVN.js → chunk-SYNLFKD3.js} +12 -2
- package/dist/web-components/chunk-TMWXRHGF.js +192 -0
- package/dist/web-components/{chunk-65JXQOBA.js → chunk-U3YZE6R6.js} +51 -7
- package/dist/web-components/chunk-UO7ROSHD.js +424 -0
- package/dist/web-components/chunk-VANAKB6D.js +152 -0
- package/dist/web-components/{chunk-PXZWYO6Z.js → chunk-VED2DFJ6.js} +108 -29
- package/dist/web-components/chunk-W6H5ID2U.js +161 -0
- package/dist/web-components/{chunk-FSZRP43R.js → chunk-WFVKU4GX.js} +21 -10
- package/dist/web-components/{chunk-OQTRTMAB.js → chunk-WIBAN7KP.js} +10 -0
- package/dist/web-components/chunk-XI7KRAH7.js +54 -0
- package/dist/web-components/{chunk-ORC56MDY.js → chunk-XIZWAWMJ.js} +45 -6
- package/dist/web-components/{chunk-FXURM6D5.js → chunk-YFAXGRPR.js} +10 -0
- package/dist/web-components/globals.js +1 -1
- package/dist/web-components/index.d.ts +77 -707
- package/dist/web-components/index.js +339 -2066
- package/dist/web-components/interaction/bds-accordion-item.js +1 -1
- package/dist/web-components/interaction/bds-accordion.js +1 -1
- package/dist/web-components/interaction/bds-button.d.ts +10 -2
- package/dist/web-components/interaction/bds-button.js +1 -1
- package/dist/web-components/interaction/bds-collapsible.d.ts +7 -2
- package/dist/web-components/interaction/bds-collapsible.js +1 -1
- package/dist/web-components/interaction/bds-dialog.d.ts +11 -3
- package/dist/web-components/interaction/bds-dialog.js +1 -1
- package/dist/web-components/interaction/bds-drawer.d.ts +7 -1
- package/dist/web-components/interaction/bds-drawer.js +1 -1
- package/dist/web-components/interaction/bds-dropdown-menu-item.d.ts +51 -0
- package/dist/web-components/interaction/bds-dropdown-menu-item.js +7 -0
- package/dist/web-components/interaction/bds-dropdown-menu.d.ts +70 -0
- package/dist/web-components/interaction/bds-dropdown-menu.js +7 -0
- package/dist/web-components/interaction/bds-popover.d.ts +14 -3
- package/dist/web-components/interaction/bds-popover.js +1 -1
- package/dist/web-components/interaction/bds-skip-link.js +1 -1
- package/dist/web-components/interaction/bds-tab-panel.js +1 -1
- package/dist/web-components/interaction/bds-tab.js +1 -1
- package/dist/web-components/interaction/bds-tabs.d.ts +1 -0
- package/dist/web-components/interaction/bds-tabs.js +1 -1
- package/dist/web-components/interaction/bds-toast-provider.js +1 -1
- package/dist/web-components/interaction/bds-tooltip.d.ts +19 -3
- package/dist/web-components/interaction/bds-tooltip.js +1 -1
- package/dist/web-components/interaction/form/bds-checkbox-group.d.ts +83 -0
- package/dist/web-components/interaction/form/bds-checkbox-group.js +7 -0
- package/dist/web-components/interaction/form/bds-checkbox.d.ts +6 -0
- package/dist/web-components/interaction/form/bds-checkbox.js +1 -1
- package/dist/web-components/interaction/form/bds-combobox.d.ts +18 -0
- package/dist/web-components/interaction/form/bds-combobox.js +1 -1
- package/dist/web-components/interaction/form/bds-field-group.d.ts +89 -0
- package/dist/web-components/interaction/form/bds-field-group.js +7 -0
- package/dist/web-components/interaction/form/bds-file-input.d.ts +1 -1
- package/dist/web-components/interaction/form/bds-file-input.js +1 -1
- package/dist/web-components/interaction/form/bds-form-input.d.ts +92 -0
- package/dist/web-components/interaction/form/bds-form-input.js +7 -0
- package/dist/web-components/interaction/form/bds-number-input.d.ts +18 -1
- package/dist/web-components/interaction/form/bds-number-input.js +1 -1
- package/dist/web-components/interaction/form/bds-radio-group.d.ts +81 -0
- package/dist/web-components/interaction/form/bds-radio-group.js +7 -0
- package/dist/web-components/interaction/form/bds-radio.d.ts +34 -6
- package/dist/web-components/interaction/form/bds-radio.js +1 -1
- package/dist/web-components/interaction/form/bds-segmented-control.d.ts +4 -4
- package/dist/web-components/interaction/form/bds-segmented-control.js +1 -1
- package/dist/web-components/interaction/form/bds-select.d.ts +22 -1
- package/dist/web-components/interaction/form/bds-select.js +1 -1
- package/dist/web-components/interaction/form/bds-slider.d.ts +42 -10
- package/dist/web-components/interaction/form/bds-slider.js +1 -1
- package/dist/web-components/interaction/form/bds-switch.d.ts +20 -0
- package/dist/web-components/interaction/form/bds-switch.js +1 -1
- package/dist/web-components/interaction/form/bds-textarea.d.ts +23 -3
- package/dist/web-components/interaction/form/bds-textarea.js +1 -1
- package/dist/web-components/layout/bds-grid-item.d.ts +63 -0
- package/dist/web-components/layout/bds-grid-item.js +7 -0
- package/dist/web-components/layout/bds-grid.d.ts +108 -0
- package/dist/web-components/layout/bds-grid.js +7 -0
- package/dist/web-components/ui/bds-alert.d.ts +16 -2
- package/dist/web-components/ui/bds-alert.js +1 -1
- package/dist/web-components/ui/bds-avatar.d.ts +2 -1
- package/dist/web-components/ui/bds-avatar.js +1 -1
- package/dist/web-components/ui/bds-badge.js +1 -1
- package/dist/web-components/ui/bds-breadcrumb.d.ts +3 -1
- package/dist/web-components/ui/bds-breadcrumb.js +1 -1
- package/dist/web-components/ui/bds-button-container.d.ts +52 -0
- package/dist/web-components/ui/bds-button-container.js +7 -0
- package/dist/web-components/ui/bds-button-group.d.ts +21 -0
- package/dist/web-components/ui/bds-button-group.js +8 -0
- package/dist/web-components/ui/bds-calendar.d.ts +121 -0
- package/dist/web-components/ui/bds-calendar.js +7 -0
- package/dist/web-components/ui/bds-card.d.ts +12 -3
- package/dist/web-components/ui/bds-card.js +1 -1
- package/dist/web-components/ui/bds-carousel.d.ts +98 -0
- package/dist/web-components/ui/bds-carousel.js +7 -0
- package/dist/web-components/ui/bds-description-list.js +1 -1
- package/dist/web-components/ui/bds-icon-wrapper.d.ts +0 -9
- package/dist/web-components/ui/bds-icon-wrapper.js +1 -1
- package/dist/web-components/ui/bds-link.js +1 -1
- package/dist/web-components/ui/bds-loading.js +1 -1
- package/dist/web-components/ui/bds-notification-banner.js +1 -1
- package/dist/web-components/ui/bds-pagination.d.ts +47 -0
- package/dist/web-components/ui/bds-pagination.js +7 -0
- package/dist/web-components/ui/bds-progress-circle.d.ts +3 -1
- package/dist/web-components/ui/bds-progress-circle.js +1 -1
- package/dist/web-components/ui/bds-progress.d.ts +3 -1
- package/dist/web-components/ui/bds-progress.js +1 -1
- package/dist/web-components/ui/bds-rating.js +1 -1
- package/dist/web-components/ui/bds-section-header.d.ts +18 -4
- package/dist/web-components/ui/bds-section-header.js +1 -1
- package/dist/web-components/ui/bds-separator.js +1 -1
- package/dist/web-components/ui/bds-skeleton.js +1 -1
- package/dist/web-components/ui/bds-table.d.ts +52 -0
- package/dist/web-components/ui/bds-table.js +7 -0
- package/dist/web-components/ui/bds-typography.d.ts +1 -0
- package/dist/web-components/ui/bds-typography.js +1 -1
- package/package.json +60 -3
- package/src/components/interaction/Button/Button.module.css +23 -14
- package/src/components/interaction/Button/Button.spec.tsx +20 -0
- package/src/components/interaction/Button/Button.tsx +2 -2
- package/src/components/interaction/Command/Command.mdx +5 -2
- package/src/components/interaction/Command/Command.module.css +23 -7
- package/src/components/interaction/Command/Command.spec.tsx +35 -0
- package/src/components/interaction/Command/Command.tsx +15 -4
- package/src/components/interaction/Command/index.ts +1 -1
- package/src/components/interaction/Dialog/Dialog.mdx +4 -4
- package/src/components/interaction/Dialog/Dialog.module.css +20 -0
- package/src/components/interaction/Dialog/Dialog.spec.tsx +20 -0
- package/src/components/interaction/Dialog/Dialog.tsx +8 -3
- package/src/components/interaction/Dialog/index.ts +1 -0
- package/src/components/interaction/Drawer/Drawer.mdx +5 -2
- package/src/components/interaction/Drawer/Drawer.module.css +34 -3
- package/src/components/interaction/Drawer/Drawer.spec.tsx +67 -1
- package/src/components/interaction/Drawer/Drawer.tsx +30 -12
- package/src/components/interaction/Drawer/index.ts +1 -0
- package/src/components/interaction/DropdownMenu/DropdownMenu.mdx +2 -0
- package/src/components/interaction/DropdownMenu/DropdownMenu.spec.tsx +34 -0
- package/src/components/interaction/DropdownMenu/DropdownMenu.tsx +15 -5
- package/src/components/interaction/DropdownMenu/index.ts +1 -0
- package/src/components/interaction/Popover/Popover.mdx +6 -2
- package/src/components/interaction/Popover/Popover.module.css +26 -18
- package/src/components/interaction/Popover/Popover.spec.tsx +38 -0
- package/src/components/interaction/Popover/Popover.tsx +19 -5
- package/src/components/interaction/Popover/index.ts +1 -0
- package/src/components/interaction/Rating/Rating.mdx +1 -1
- package/src/components/interaction/Rating/Rating.module.css +2 -2
- package/src/components/interaction/Rating/Rating.tsx +1 -1
- package/src/components/interaction/Rating/index.ts +1 -0
- package/src/components/interaction/Toast/Toast.mdx +3 -0
- package/src/components/interaction/Toast/Toast.module.css +35 -5
- package/src/components/interaction/Toast/Toast.spec.tsx +69 -1
- package/src/components/interaction/Toast/Toast.tsx +15 -9
- package/src/components/interaction/form/Checkbox/Checkbox.mdx +3 -0
- package/src/components/interaction/form/Checkbox/Checkbox.module.css +13 -6
- package/src/components/interaction/form/Checkbox/Checkbox.spec.tsx +6 -0
- package/src/components/interaction/form/Checkbox/Checkbox.tsx +1 -1
- package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.mdx +16 -1
- package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.module.css +24 -8
- package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.spec.tsx +32 -2
- package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.tsx +14 -2
- package/src/components/interaction/form/Combobox/Combobox.mdx +11 -4
- package/src/components/interaction/form/Combobox/Combobox.module.css +6 -6
- package/src/components/interaction/form/Combobox/Combobox.spec.tsx +47 -0
- package/src/components/interaction/form/Combobox/Combobox.tsx +10 -5
- package/src/components/interaction/form/FieldGroup/FieldGroup.mdx +9 -10
- package/src/components/interaction/form/FieldGroup/FieldGroup.module.css +57 -23
- package/src/components/interaction/form/FieldGroup/FieldGroup.spec.tsx +129 -7
- package/src/components/interaction/form/FieldGroup/FieldGroup.tsx +72 -12
- package/src/components/interaction/form/FileInput/FileInput.mdx +9 -1
- package/src/components/interaction/form/FileInput/FileInput.module.css +8 -8
- package/src/components/interaction/form/FileInput/FileInput.spec.tsx +89 -1
- package/src/components/interaction/form/FileInput/FileInput.tsx +6 -2
- package/src/components/interaction/form/FormInput/FormInput.mdx +9 -5
- package/src/components/interaction/form/FormInput/FormInput.module.css +17 -8
- package/src/components/interaction/form/FormInput/FormInput.spec.tsx +20 -0
- package/src/components/interaction/form/FormInput/FormInput.tsx +7 -2
- package/src/components/interaction/form/NumberInput/NumberInput.mdx +5 -1
- package/src/components/interaction/form/NumberInput/NumberInput.module.css +6 -6
- package/src/components/interaction/form/NumberInput/NumberInput.spec.tsx +51 -0
- package/src/components/interaction/form/NumberInput/NumberInput.tsx +36 -8
- package/src/components/interaction/form/Radio/Radio.mdx +8 -1
- package/src/components/interaction/form/Radio/Radio.module.css +20 -7
- package/src/components/interaction/form/Radio/Radio.spec.tsx +15 -0
- package/src/components/interaction/form/Radio/Radio.tsx +10 -4
- package/src/components/interaction/form/RadioGroup/RadioGroup.mdx +16 -1
- package/src/components/interaction/form/RadioGroup/RadioGroup.module.css +24 -8
- package/src/components/interaction/form/RadioGroup/RadioGroup.spec.tsx +32 -2
- package/src/components/interaction/form/RadioGroup/RadioGroup.tsx +14 -2
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.mdx +9 -3
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.module.css +25 -12
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.spec.tsx +86 -5
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.tsx +44 -4
- package/src/components/interaction/form/Select/Select.mdx +10 -4
- package/src/components/interaction/form/Select/Select.module.css +4 -4
- package/src/components/interaction/form/Select/Select.spec.tsx +34 -0
- package/src/components/interaction/form/Select/Select.tsx +21 -9
- package/src/components/interaction/form/Slider/Slider.mdx +4 -1
- package/src/components/interaction/form/Slider/Slider.module.css +32 -8
- package/src/components/interaction/form/Slider/Slider.spec.tsx +29 -0
- package/src/components/interaction/form/Slider/Slider.tsx +9 -7
- package/src/components/interaction/form/Switch/Switch.mdx +2 -2
- package/src/components/interaction/form/Switch/Switch.module.css +12 -13
- package/src/components/interaction/form/Switch/Switch.spec.tsx +20 -0
- package/src/components/interaction/form/Switch/Switch.tsx +2 -1
- package/src/components/interaction/form/Textarea/Textarea.mdx +5 -0
- package/src/components/interaction/form/Textarea/Textarea.module.css +5 -5
- package/src/components/interaction/form/Textarea/Textarea.spec.tsx +13 -0
- package/src/components/interaction/form/Textarea/Textarea.tsx +3 -1
- package/src/components/interaction/form/atoms/Message.module.css +1 -1
- package/src/components/interaction/form/atoms/Message.spec.tsx +29 -0
- package/src/components/interaction/form/atoms/Message.tsx +1 -1
- package/src/components/layout/ButtonGroup/ButtonGroup.mdx +11 -0
- package/src/components/layout/ButtonGroup/ButtonGroup.module.css +1 -5
- package/src/components/layout/ButtonGroup/ButtonGroup.stories.tsx +14 -0
- package/src/components/layout/Card/Card.mdx +6 -1
- package/src/components/layout/Card/Card.module.css +26 -5
- package/src/components/layout/Card/Card.spec.tsx +7 -0
- package/src/components/layout/Card/Card.tsx +4 -3
- package/src/components/layout/Grid/Grid.spec.tsx +44 -0
- package/src/components/layout/Grid/Grid.tsx +5 -5
- package/src/components/layout/Grid/GridItem.tsx +6 -6
- package/src/components/layout/Grid/masonry.ts +31 -5
- package/src/components/layout/Grid/useIsomorphicLayoutEffect.ts +11 -0
- package/src/components/layout/IconWrapper/IconWrapper.mdx +8 -2
- package/src/components/layout/IconWrapper/IconWrapper.module.css +9 -6
- package/src/components/layout/SectionHeader/SectionHeader.mdx +4 -1
- package/src/components/layout/SectionHeader/SectionHeader.module.css +10 -9
- package/src/components/ui/Accordion/Accordion.mdx +4 -1
- package/src/components/ui/Accordion/Accordion.module.css +2 -1
- package/src/components/ui/Alert/Alert.mdx +21 -4
- package/src/components/ui/Alert/Alert.module.css +9 -4
- package/src/components/ui/Alert/Alert.spec.tsx +20 -0
- package/src/components/ui/Avatar/Avatar.mdx +8 -3
- package/src/components/ui/Avatar/Avatar.module.css +13 -8
- package/src/components/ui/Badge/Badge.mdx +3 -1
- package/src/components/ui/Breadcrumb/Breadcrumb.mdx +3 -0
- package/src/components/ui/Breadcrumb/Breadcrumb.module.css +4 -0
- package/src/components/ui/Breadcrumb/Breadcrumb.spec.tsx +12 -0
- package/src/components/ui/Breadcrumb/Breadcrumb.tsx +11 -3
- package/src/components/ui/Calendar/Calendar.mdx +6 -0
- package/src/components/ui/Calendar/Calendar.module.css +68 -19
- package/src/components/ui/Calendar/Calendar.spec.tsx +139 -24
- package/src/components/ui/Calendar/Calendar.stories.tsx +14 -0
- package/src/components/ui/Calendar/Calendar.tsx +143 -154
- package/src/components/ui/Calendar/CalendarRange.mdx +39 -0
- package/src/components/ui/Calendar/CalendarRange.spec.tsx +119 -0
- package/src/components/ui/Calendar/CalendarRange.stories.tsx +51 -0
- package/src/components/ui/Calendar/CalendarRange.tsx +213 -0
- package/src/components/ui/Calendar/MonthGrid.tsx +141 -0
- package/src/components/ui/Calendar/calendar-core.spec.ts +176 -0
- package/src/components/ui/Calendar/calendar-core.ts +164 -0
- package/src/components/ui/Calendar/index.ts +1 -0
- package/src/components/ui/Carousel/Carousel.mdx +8 -3
- package/src/components/ui/Carousel/Carousel.module.css +7 -5
- package/src/components/ui/Carousel/Carousel.spec.tsx +67 -0
- package/src/components/ui/Carousel/Carousel.tsx +19 -7
- package/src/components/ui/Collapsible/Collapsible.mdx +17 -6
- package/src/components/ui/Collapsible/Collapsible.module.css +7 -2
- package/src/components/ui/Collapsible/Collapsible.spec.tsx +40 -0
- package/src/components/ui/Collapsible/Collapsible.tsx +19 -2
- package/src/components/ui/DescriptionList/DescriptionList.mdx +2 -0
- package/src/components/ui/Link/Link.mdx +4 -2
- package/src/components/ui/Loading/Loading.mdx +6 -3
- package/src/components/ui/Loading/Loading.module.css +7 -7
- package/src/components/ui/Loading/Loading.spec.tsx +12 -0
- package/src/components/ui/Loading/Loading.tsx +8 -3
- package/src/components/ui/NotificationBanner/NotificationBanner.mdx +4 -0
- package/src/components/ui/NotificationBanner/NotificationBanner.module.css +5 -0
- package/src/components/ui/NotificationBanner/NotificationBanner.spec.tsx +20 -0
- package/src/components/ui/Pagination/Pagination.mdx +29 -7
- package/src/components/ui/Pagination/Pagination.module.css +15 -14
- package/src/components/ui/Progress/Progress.mdx +6 -2
- package/src/components/ui/Progress/Progress.module.css +1 -1
- package/src/components/ui/Progress/Progress.spec.tsx +17 -0
- package/src/components/ui/Progress/Progress.tsx +2 -2
- package/src/components/ui/ProgressCircle/ProgressCircle.mdx +8 -4
- package/src/components/ui/ProgressCircle/ProgressCircle.module.css +2 -2
- package/src/components/ui/ProgressCircle/ProgressCircle.spec.tsx +11 -1
- package/src/components/ui/ProgressCircle/ProgressCircle.tsx +1 -1
- package/src/components/ui/Separator/Separator.mdx +7 -0
- package/src/components/ui/Separator/Separator.module.css +1 -0
- package/src/components/ui/Skeleton/Skeleton.mdx +17 -0
- package/src/components/ui/Skeleton/Skeleton.module.css +12 -5
- package/src/components/ui/SkipLink/SkipLink.mdx +19 -0
- package/src/components/ui/SkipLink/SkipLink.module.css +8 -7
- package/src/components/ui/SkipLink/SkipLink.spec.tsx +28 -0
- package/src/components/ui/Table/Table.mdx +14 -0
- package/src/components/ui/Table/Table.module.css +13 -8
- package/src/components/ui/Table/Table.spec.tsx +56 -0
- package/src/components/ui/Table/Table.tsx +44 -6
- package/src/components/ui/Tabs/Tabs.mdx +16 -0
- package/src/components/ui/Tabs/Tabs.module.css +3 -3
- package/src/components/ui/Tabs/Tabs.spec.tsx +20 -0
- package/src/components/ui/Tabs/Tabs.tsx +5 -1
- package/src/components/ui/Tooltip/Tooltip.mdx +9 -0
- package/src/components/ui/Tooltip/Tooltip.module.css +32 -12
- package/src/components/ui/Tooltip/Tooltip.spec.tsx +56 -0
- package/src/components/ui/Tooltip/Tooltip.tsx +26 -7
- package/src/components/ui/Typography/Typography.mdx +7 -0
- package/src/components/ui/Typography/Typography.module.css +5 -5
- package/src/index.ts +7 -3
- package/src/stories/DesignSystem/Borders.mdx +14 -9
- package/src/stories/DesignSystem/Colors.mdx +43 -41
- package/src/stories/DesignSystem/Overview.mdx +4 -3
- package/src/stories/Introduction.mdx +5 -5
- package/src/web-components/globals.ts +7 -0
- package/src/web-components/index.ts +2 -0
- package/src/web-components/interaction/BdsAccordion.mdx +10 -1
- package/src/web-components/interaction/BdsButton.mdx +15 -4
- package/src/web-components/interaction/BdsButton.stories.tsx +1 -1
- package/src/web-components/interaction/BdsCollapsible.mdx +3 -3
- package/src/web-components/interaction/BdsDialog.mdx +12 -7
- package/src/web-components/interaction/BdsDialog.stories.tsx +2 -2
- package/src/web-components/interaction/BdsDrawer.mdx +9 -6
- package/src/web-components/interaction/BdsDropdownMenu.mdx +20 -1
- package/src/web-components/interaction/BdsPopover.mdx +7 -3
- package/src/web-components/interaction/BdsSkipLink.mdx +14 -1
- package/src/web-components/interaction/BdsTabs.mdx +18 -1
- package/src/web-components/interaction/BdsToastProvider.mdx +21 -3
- package/src/web-components/interaction/BdsTooltip.mdx +4 -4
- package/src/web-components/interaction/bds-accordion-item.ts +10 -0
- package/src/web-components/interaction/bds-accordion.spec.ts +41 -0
- package/src/web-components/interaction/bds-accordion.ts +28 -2
- package/src/web-components/interaction/bds-button.spec.ts +81 -0
- package/src/web-components/interaction/bds-button.ts +55 -8
- package/src/web-components/interaction/bds-collapsible.spec.ts +93 -2
- package/src/web-components/interaction/bds-collapsible.ts +49 -7
- package/src/web-components/interaction/bds-dialog.spec.ts +49 -0
- package/src/web-components/interaction/bds-dialog.ts +68 -11
- package/src/web-components/interaction/bds-drawer.spec.ts +93 -4
- package/src/web-components/interaction/bds-drawer.ts +54 -21
- package/src/web-components/interaction/bds-dropdown-menu-item.ts +12 -1
- package/src/web-components/interaction/bds-dropdown-menu.spec.ts +63 -0
- package/src/web-components/interaction/bds-dropdown-menu.ts +45 -7
- package/src/web-components/interaction/bds-popover.spec.ts +80 -6
- package/src/web-components/interaction/bds-popover.ts +83 -32
- package/src/web-components/interaction/bds-skip-link.spec.ts +18 -0
- package/src/web-components/interaction/bds-skip-link.ts +29 -8
- package/src/web-components/interaction/bds-tab-panel.ts +10 -0
- package/src/web-components/interaction/bds-tab.spec.ts +25 -0
- package/src/web-components/interaction/bds-tab.ts +20 -5
- package/src/web-components/interaction/bds-tabs.spec.ts +92 -5
- package/src/web-components/interaction/bds-tabs.ts +42 -1
- package/src/web-components/interaction/bds-toast-provider.spec.ts +43 -0
- package/src/web-components/interaction/bds-toast-provider.ts +50 -21
- package/src/web-components/interaction/bds-tooltip.spec.ts +71 -0
- package/src/web-components/interaction/bds-tooltip.ts +100 -5
- package/src/web-components/interaction/form/BdsCheckbox.mdx +20 -1
- package/src/web-components/interaction/form/BdsCheckbox.stories.tsx +8 -0
- package/src/web-components/interaction/form/BdsCheckboxGroup.mdx +4 -3
- package/src/web-components/interaction/form/BdsCombobox.mdx +39 -2
- package/src/web-components/interaction/form/BdsCombobox.stories.tsx +31 -0
- package/src/web-components/interaction/form/BdsFieldGroup.mdx +8 -3
- package/src/web-components/interaction/form/BdsFieldGroup.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsFileInput.mdx +26 -5
- package/src/web-components/interaction/form/BdsFormInput.mdx +16 -1
- package/src/web-components/interaction/form/BdsNumberInput.mdx +34 -2
- package/src/web-components/interaction/form/BdsNumberInput.stories.tsx +27 -3
- package/src/web-components/interaction/form/BdsRadio.mdx +39 -12
- package/src/web-components/interaction/form/BdsRadio.stories.tsx +26 -0
- package/src/web-components/interaction/form/BdsRadioGroup.mdx +9 -4
- package/src/web-components/interaction/form/BdsSegmentedControl.mdx +37 -11
- package/src/web-components/interaction/form/BdsSelect.mdx +22 -4
- package/src/web-components/interaction/form/BdsSelect.stories.tsx +33 -0
- package/src/web-components/interaction/form/BdsSlider.mdx +36 -19
- package/src/web-components/interaction/form/BdsSlider.stories.tsx +24 -0
- package/src/web-components/interaction/form/BdsSwitch.mdx +38 -11
- package/src/web-components/interaction/form/BdsSwitch.stories.tsx +16 -0
- package/src/web-components/interaction/form/BdsTextarea.mdx +42 -16
- package/src/web-components/interaction/form/BdsTextarea.stories.tsx +21 -0
- package/src/web-components/interaction/form/bds-checkbox-group.spec.ts +99 -0
- package/src/web-components/interaction/form/bds-checkbox-group.ts +95 -9
- package/src/web-components/interaction/form/bds-checkbox.spec.ts +55 -0
- package/src/web-components/interaction/form/bds-checkbox.ts +30 -5
- package/src/web-components/interaction/form/bds-combobox.spec.ts +79 -0
- package/src/web-components/interaction/form/bds-combobox.ts +101 -16
- package/src/web-components/interaction/form/bds-field-group.spec.ts +158 -0
- package/src/web-components/interaction/form/bds-field-group.ts +167 -23
- package/src/web-components/interaction/form/bds-file-input.spec.ts +73 -5
- package/src/web-components/interaction/form/bds-file-input.ts +71 -34
- package/src/web-components/interaction/form/bds-form-input.spec.ts +22 -0
- package/src/web-components/interaction/form/bds-form-input.ts +27 -16
- package/src/web-components/interaction/form/bds-number-input.spec.ts +49 -0
- package/src/web-components/interaction/form/bds-number-input.ts +118 -29
- package/src/web-components/interaction/form/bds-radio-group.spec.ts +57 -0
- package/src/web-components/interaction/form/bds-radio-group.ts +60 -12
- package/src/web-components/interaction/form/bds-radio.spec.ts +123 -0
- package/src/web-components/interaction/form/bds-radio.ts +135 -22
- package/src/web-components/interaction/form/bds-segmented-control.spec.ts +55 -0
- package/src/web-components/interaction/form/bds-segmented-control.ts +81 -59
- package/src/web-components/interaction/form/bds-select.spec.ts +57 -0
- package/src/web-components/interaction/form/bds-select.ts +95 -7
- package/src/web-components/interaction/form/bds-slider.spec.ts +83 -0
- package/src/web-components/interaction/form/bds-slider.ts +154 -26
- package/src/web-components/interaction/form/bds-switch.spec.ts +68 -0
- package/src/web-components/interaction/form/bds-switch.ts +87 -20
- package/src/web-components/interaction/form/bds-textarea.spec.ts +71 -0
- package/src/web-components/interaction/form/bds-textarea.ts +108 -7
- package/src/web-components/layout/BdsGrid.mdx +6 -2
- package/src/web-components/layout/BdsGrid.stories.tsx +4 -0
- package/src/web-components/layout/bds-grid-item.spec.ts +21 -0
- package/src/web-components/layout/bds-grid-item.ts +17 -3
- package/src/web-components/layout/bds-grid.spec.ts +98 -0
- package/src/web-components/layout/bds-grid.ts +139 -19
- package/src/web-components/ui/BdsAlert.mdx +6 -5
- package/src/web-components/ui/BdsAlert.stories.tsx +6 -6
- package/src/web-components/ui/BdsAvatar.mdx +4 -2
- package/src/web-components/ui/BdsBreadcrumb.mdx +3 -2
- package/src/web-components/ui/BdsButtonContainer.mdx +64 -0
- package/src/web-components/ui/BdsButtonContainer.stories.tsx +84 -0
- package/src/web-components/ui/BdsCalendar.mdx +29 -4
- package/src/web-components/ui/BdsCalendar.stories.tsx +16 -18
- package/src/web-components/ui/BdsCalendarRange.mdx +71 -0
- package/src/web-components/ui/BdsCalendarRange.stories.tsx +31 -0
- package/src/web-components/ui/BdsCard.mdx +7 -3
- package/src/web-components/ui/BdsCard.stories.tsx +17 -1
- package/src/web-components/ui/BdsCarousel.mdx +40 -12
- package/src/web-components/ui/BdsDescriptionList.mdx +6 -1
- package/src/web-components/ui/BdsIconWrapper.mdx +3 -2
- package/src/web-components/ui/BdsLink.mdx +14 -2
- package/src/web-components/ui/BdsNotificationBanner.mdx +18 -0
- package/src/web-components/ui/BdsPagination.mdx +40 -1
- package/src/web-components/ui/BdsProgress.mdx +8 -2
- package/src/web-components/ui/BdsProgressCircle.mdx +5 -2
- package/src/web-components/ui/BdsRating.mdx +7 -0
- package/src/web-components/ui/BdsSectionHeader.mdx +22 -3
- package/src/web-components/ui/BdsSectionHeader.stories.tsx +15 -13
- package/src/web-components/ui/BdsTable.mdx +23 -2
- package/src/web-components/ui/BdsTable.stories.tsx +8 -2
- package/src/web-components/ui/BdsTypography.mdx +17 -1
- package/src/web-components/ui/bds-alert.spec.ts +17 -2
- package/src/web-components/ui/bds-alert.ts +31 -5
- package/src/web-components/ui/bds-avatar.spec.ts +29 -0
- package/src/web-components/ui/bds-avatar.ts +29 -11
- package/src/web-components/ui/bds-badge.spec.ts +5 -0
- package/src/web-components/ui/bds-badge.ts +11 -1
- package/src/web-components/ui/bds-breadcrumb.spec.ts +30 -0
- package/src/web-components/ui/bds-breadcrumb.ts +26 -4
- package/src/web-components/ui/bds-button-container.spec.ts +39 -0
- package/src/web-components/ui/bds-button-container.ts +123 -0
- package/src/web-components/ui/bds-button-group.spec.ts +14 -20
- package/src/web-components/ui/bds-button-group.ts +13 -64
- package/src/web-components/ui/bds-calendar-range.spec.ts +123 -0
- package/src/web-components/ui/bds-calendar-range.ts +307 -0
- package/src/web-components/ui/bds-calendar.spec.ts +176 -0
- package/src/web-components/ui/bds-calendar.ts +186 -344
- package/src/web-components/ui/bds-card.spec.ts +32 -0
- package/src/web-components/ui/bds-card.ts +34 -9
- package/src/web-components/ui/bds-carousel.spec.ts +147 -0
- package/src/web-components/ui/bds-carousel.ts +109 -32
- package/src/web-components/ui/bds-description-list.spec.ts +15 -0
- package/src/web-components/ui/bds-description-list.ts +37 -3
- package/src/web-components/ui/bds-icon-wrapper.spec.ts +12 -0
- package/src/web-components/ui/bds-icon-wrapper.ts +15 -14
- package/src/web-components/ui/bds-link.spec.ts +17 -0
- package/src/web-components/ui/bds-link.ts +26 -11
- package/src/web-components/ui/bds-loading.ts +10 -0
- package/src/web-components/ui/bds-notification-banner.spec.ts +13 -0
- package/src/web-components/ui/bds-notification-banner.ts +18 -1
- package/src/web-components/ui/bds-pagination.spec.ts +44 -0
- package/src/web-components/ui/bds-pagination.ts +39 -19
- package/src/web-components/ui/bds-progress-circle.spec.ts +21 -0
- package/src/web-components/ui/bds-progress-circle.ts +17 -5
- package/src/web-components/ui/bds-progress.spec.ts +21 -0
- package/src/web-components/ui/bds-progress.ts +17 -4
- package/src/web-components/ui/bds-rating.spec.ts +6 -0
- package/src/web-components/ui/bds-rating.ts +12 -2
- package/src/web-components/ui/bds-section-header.spec.ts +39 -8
- package/src/web-components/ui/bds-section-header.ts +47 -13
- package/src/web-components/ui/bds-separator.ts +10 -0
- package/src/web-components/ui/bds-skeleton.ts +10 -0
- package/src/web-components/ui/bds-table.spec.ts +63 -0
- package/src/web-components/ui/bds-table.ts +88 -28
- package/src/web-components/ui/bds-typography.spec.ts +47 -0
- package/src/web-components/ui/bds-typography.ts +28 -10
- package/src/web-components/ui/calendar-styles.ts +94 -0
- package/dist/web-components/chunk-7YURXHTS.js +0 -147
- package/dist/web-components/chunk-A3RLT3AS.js +0 -49
- package/dist/web-components/chunk-AGKJTMJI.js +0 -56
- package/dist/web-components/chunk-BQLZ7I4G.js +0 -56
- package/dist/web-components/chunk-DZOEPVFT.js +0 -107
- package/dist/web-components/chunk-JYYRJS2D.js +0 -118
- package/dist/web-components/chunk-Y4MAXTMA.js +0 -80
- package/dist/web-components/chunk-Y7V7LM6R.js +0 -98
- package/src/web-components/ui/BdsButtonGroup.mdx +0 -69
- package/src/web-components/ui/BdsButtonGroup.stories.tsx +0 -66
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { CalendarRange } from './CalendarRange';
|
|
4
|
+
|
|
5
|
+
const JAN = (d: number) => new Date(2024, 0, d);
|
|
6
|
+
const day = (n: number) => screen.getByRole('button', { name: `January ${n}, 2024` });
|
|
7
|
+
|
|
8
|
+
describe('CalendarRange', () => {
|
|
9
|
+
it('selects a range across two clicks and calls onChange with a sorted pair', async () => {
|
|
10
|
+
const onChange = vi.fn();
|
|
11
|
+
render(<CalendarRange value={[JAN(10), JAN(12)]} onChange={onChange} />);
|
|
12
|
+
await userEvent.click(day(5));
|
|
13
|
+
await userEvent.click(day(8));
|
|
14
|
+
expect(onChange).toHaveBeenCalledOnce();
|
|
15
|
+
const [start, end] = onChange.mock.calls[0][0] as [Date, Date];
|
|
16
|
+
expect(start.getDate()).toBe(5);
|
|
17
|
+
expect(end.getDate()).toBe(8);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('auto-sorts when the second click precedes the first', async () => {
|
|
21
|
+
const onChange = vi.fn();
|
|
22
|
+
render(<CalendarRange value={[JAN(10), JAN(12)]} onChange={onChange} />);
|
|
23
|
+
await userEvent.click(day(8));
|
|
24
|
+
await userEvent.click(day(5));
|
|
25
|
+
const [start, end] = onChange.mock.calls[0][0] as [Date, Date];
|
|
26
|
+
expect(start.getDate()).toBe(5);
|
|
27
|
+
expect(end.getDate()).toBe(8);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('sorts an externally reversed value pair for painting', () => {
|
|
31
|
+
render(<CalendarRange value={[JAN(12), JAN(10)]} onChange={() => {}} />);
|
|
32
|
+
expect(day(10)).toHaveAttribute('data-range-start');
|
|
33
|
+
expect(day(12)).toHaveAttribute('data-range-end');
|
|
34
|
+
expect(day(11)).toHaveAttribute('data-in-range');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('marks a committed range with start/end/in-range hooks', () => {
|
|
38
|
+
render(<CalendarRange value={[JAN(10), JAN(12)]} onChange={() => {}} />);
|
|
39
|
+
expect(day(10)).toHaveAttribute('data-range-start');
|
|
40
|
+
expect(day(12)).toHaveAttribute('data-range-end');
|
|
41
|
+
expect(day(11)).toHaveAttribute('data-in-range');
|
|
42
|
+
expect(day(10).closest('[role="gridcell"]')).toHaveAttribute('aria-selected', 'true');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('previews the range on hover after the first click', () => {
|
|
46
|
+
render(<CalendarRange value={[JAN(10), JAN(12)]} onChange={() => {}} />);
|
|
47
|
+
fireEvent.click(day(5)); // anchor
|
|
48
|
+
fireEvent.pointerEnter(day(8)); // hover preview
|
|
49
|
+
expect(day(5)).toHaveAttribute('data-range-start');
|
|
50
|
+
expect(day(8)).toHaveAttribute('data-range-end');
|
|
51
|
+
expect(day(6)).toHaveAttribute('data-in-range');
|
|
52
|
+
expect(day(7)).toHaveAttribute('data-in-range');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('selects a range with the keyboard', async () => {
|
|
56
|
+
const onChange = vi.fn();
|
|
57
|
+
render(<CalendarRange value={[JAN(10), JAN(12)]} onChange={onChange} />);
|
|
58
|
+
day(10).focus(); // committed start is tabbable
|
|
59
|
+
await userEvent.keyboard('{Enter}'); // anchor at Jan 10
|
|
60
|
+
await userEvent.keyboard('{ArrowRight}{Enter}'); // end at Jan 11
|
|
61
|
+
const [start, end] = onChange.mock.calls[0][0] as [Date, Date];
|
|
62
|
+
expect(start.getDate()).toBe(10);
|
|
63
|
+
expect(end.getDate()).toBe(11);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('does not select disallowed dates', async () => {
|
|
67
|
+
const onChange = vi.fn();
|
|
68
|
+
render(<CalendarRange value={[JAN(10), JAN(12)]} min={JAN(6)} onChange={onChange} />);
|
|
69
|
+
expect(day(4)).toBeDisabled();
|
|
70
|
+
await userEvent.click(day(4));
|
|
71
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('commits into internal state when uncontrolled', async () => {
|
|
75
|
+
render(<CalendarRange defaultValue={[JAN(10), JAN(12)]} onChange={() => {}} />);
|
|
76
|
+
await userEvent.click(day(5));
|
|
77
|
+
await userEvent.click(day(8));
|
|
78
|
+
expect(day(5)).toHaveAttribute('data-range-start');
|
|
79
|
+
expect(day(8)).toHaveAttribute('data-range-end');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('shows two months when months=2', () => {
|
|
83
|
+
render(<CalendarRange value={[JAN(10), JAN(12)]} months={2} onChange={() => {}} />);
|
|
84
|
+
expect(screen.getByText('January 2024')).toBeInTheDocument();
|
|
85
|
+
expect(screen.getByText('February 2024')).toBeInTheDocument();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('previews the range while navigating with the keyboard', async () => {
|
|
89
|
+
render(<CalendarRange value={[JAN(10), JAN(12)]} onChange={() => {}} />);
|
|
90
|
+
day(10).focus();
|
|
91
|
+
await userEvent.keyboard('{Enter}'); // anchor at Jan 10
|
|
92
|
+
await userEvent.keyboard('{ArrowRight}{ArrowRight}'); // focus moves to Jan 12
|
|
93
|
+
expect(day(10)).toHaveAttribute('data-range-start');
|
|
94
|
+
expect(day(11)).toHaveAttribute('data-in-range');
|
|
95
|
+
expect(day(12)).toHaveAttribute('data-range-end');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('cancels an in-progress selection on Escape', async () => {
|
|
99
|
+
const onChange = vi.fn();
|
|
100
|
+
render(<CalendarRange value={[JAN(10), JAN(12)]} onChange={onChange} />);
|
|
101
|
+
day(5).focus();
|
|
102
|
+
await userEvent.keyboard('{Enter}'); // anchor at Jan 5 (starts a new selection)
|
|
103
|
+
expect(day(5)).toHaveAttribute('data-range-start');
|
|
104
|
+
await userEvent.keyboard('{Escape}'); // cancel — committed range is restored
|
|
105
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
106
|
+
expect(day(5)).not.toHaveAttribute('data-range-start');
|
|
107
|
+
expect(day(10)).toHaveAttribute('data-range-start');
|
|
108
|
+
expect(day(12)).toHaveAttribute('data-range-end');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('does not end a range on a disallowed date', async () => {
|
|
112
|
+
const onChange = vi.fn();
|
|
113
|
+
render(<CalendarRange value={[JAN(10), JAN(12)]} min={JAN(6)} onChange={onChange} />);
|
|
114
|
+
await userEvent.click(day(8)); // anchor at Jan 8 (valid)
|
|
115
|
+
expect(day(4)).toBeDisabled();
|
|
116
|
+
await userEvent.click(day(4)); // Jan 4 < min → disabled, cannot end the range
|
|
117
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { CalendarRange } from './CalendarRange';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'React/UI/CalendarRange',
|
|
7
|
+
component: CalendarRange,
|
|
8
|
+
decorators: [
|
|
9
|
+
Story => (
|
|
10
|
+
<div style={{ display: 'flex', justifyContent: 'center', padding: '2rem' }}>
|
|
11
|
+
<Story />
|
|
12
|
+
</div>
|
|
13
|
+
),
|
|
14
|
+
],
|
|
15
|
+
} satisfies Meta<typeof CalendarRange>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
render: () => {
|
|
22
|
+
const [range, setRange] = useState<[Date, Date] | undefined>();
|
|
23
|
+
return (
|
|
24
|
+
<div>
|
|
25
|
+
<CalendarRange value={range} onChange={setRange} />
|
|
26
|
+
{range && (
|
|
27
|
+
<p style={{ marginTop: '1rem', textAlign: 'center', fontSize: '0.875rem' }}>
|
|
28
|
+
{range[0].toLocaleDateString()} — {range[1].toLocaleDateString()}
|
|
29
|
+
</p>
|
|
30
|
+
)}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const TwoMonths: Story = {
|
|
37
|
+
render: () => {
|
|
38
|
+
const [range, setRange] = useState<[Date, Date] | undefined>();
|
|
39
|
+
return <CalendarRange value={range} months={2} onChange={setRange} />;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const WithMinMax: Story = {
|
|
44
|
+
render: () => {
|
|
45
|
+
const today = new Date();
|
|
46
|
+
const min = new Date(today.getFullYear(), today.getMonth(), 1);
|
|
47
|
+
const max = new Date(today.getFullYear(), today.getMonth() + 2, 0);
|
|
48
|
+
const [range, setRange] = useState<[Date, Date] | undefined>();
|
|
49
|
+
return <CalendarRange value={range} min={min} max={max} months={2} onChange={setRange} />;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { HTMLAttributes, useState, useId, useRef, useEffect, useCallback, KeyboardEvent } from 'react';
|
|
2
|
+
import { cn } from '@boostdev/design-system-foundation';
|
|
3
|
+
import type { WithClassName } from '../../../types';
|
|
4
|
+
import css from './Calendar.module.css';
|
|
5
|
+
import { MonthGrid, type DayState } from './MonthGrid';
|
|
6
|
+
import {
|
|
7
|
+
isSameDay, isInRange, sortRange, isDisabled as coreIsDisabled,
|
|
8
|
+
toISO, parseISO, type ISODate, getWeekdayNames, getMonthLabel, getDayLabel, nextFocusDate,
|
|
9
|
+
} from './calendar-core';
|
|
10
|
+
|
|
11
|
+
type PageBy = 'months' | 'single';
|
|
12
|
+
|
|
13
|
+
interface CalendarRangeProps
|
|
14
|
+
extends WithClassName,
|
|
15
|
+
Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange'> {
|
|
16
|
+
value?: [Date, Date];
|
|
17
|
+
defaultValue?: [Date, Date];
|
|
18
|
+
min?: Date;
|
|
19
|
+
max?: Date;
|
|
20
|
+
months?: number;
|
|
21
|
+
pageBy?: PageBy;
|
|
22
|
+
firstDayOfWeek?: number;
|
|
23
|
+
locale?: string;
|
|
24
|
+
isDateDisallowed?: (date: Date) => boolean;
|
|
25
|
+
formatWeekday?: (date: Date) => string;
|
|
26
|
+
formatMonth?: (date: Date) => string;
|
|
27
|
+
formatDay?: (date: Date) => string;
|
|
28
|
+
labels?: { previousMonth?: string; nextMonth?: string };
|
|
29
|
+
onChange?: (range: [Date, Date]) => void;
|
|
30
|
+
onRangeStart?: (date: Date) => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isMonthVisible(date: Date, viewYear: number, viewMonth: number, months: number): boolean {
|
|
34
|
+
const start = viewYear * 12 + viewMonth;
|
|
35
|
+
const idx = date.getFullYear() * 12 + date.getMonth();
|
|
36
|
+
return idx >= start && idx < start + months;
|
|
37
|
+
}
|
|
38
|
+
function weekdayNamesFrom(fmt: (d: Date) => string, firstDayOfWeek: number): string[] {
|
|
39
|
+
return Array.from({ length: 7 }, (_, i) => fmt(new Date(2023, 0, 1 + ((firstDayOfWeek + i) % 7))));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function CalendarRange({
|
|
43
|
+
value, defaultValue, min, max,
|
|
44
|
+
months = 1, pageBy = 'months', firstDayOfWeek = 1, locale,
|
|
45
|
+
isDateDisallowed, formatWeekday, formatMonth, formatDay, labels,
|
|
46
|
+
onChange, onRangeStart, className, ...rest
|
|
47
|
+
}: Readonly<CalendarRangeProps>) {
|
|
48
|
+
const today = new Date();
|
|
49
|
+
const controlled = value !== undefined;
|
|
50
|
+
const [internal, setInternal] = useState<[Date, Date] | undefined>(defaultValue);
|
|
51
|
+
const committed = controlled ? value : internal;
|
|
52
|
+
|
|
53
|
+
const [anchor, setAnchor] = useState<Date | undefined>();
|
|
54
|
+
const [hover, setHover] = useState<Date | undefined>();
|
|
55
|
+
|
|
56
|
+
const base = committed ? committed[0] : today;
|
|
57
|
+
const [viewYear, setViewYear] = useState(base.getFullYear());
|
|
58
|
+
const [viewMonth, setViewMonth] = useState(base.getMonth());
|
|
59
|
+
const [focusedIso, setFocusedIso] = useState<ISODate | undefined>();
|
|
60
|
+
|
|
61
|
+
const headingBaseId = useId();
|
|
62
|
+
const dayRefs = useRef<Map<ISODate, HTMLButtonElement>>(new Map());
|
|
63
|
+
const registerRef = useCallback((iso: ISODate, el: HTMLButtonElement | null) => {
|
|
64
|
+
if (el) dayRefs.current.set(iso, el);
|
|
65
|
+
else dayRefs.current.delete(iso);
|
|
66
|
+
}, []);
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (!controlled || !value) return;
|
|
70
|
+
if (!isMonthVisible(value[0], viewYear, viewMonth, months)) {
|
|
71
|
+
setViewYear(value[0].getFullYear());
|
|
72
|
+
setViewMonth(value[0].getMonth());
|
|
73
|
+
}
|
|
74
|
+
// Only re-sync when the controlled value itself changes, not on internal navigation.
|
|
75
|
+
}, [controlled, value]);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (focusedIso) dayRefs.current.get(focusedIso)?.focus();
|
|
79
|
+
}, [focusedIso, viewYear, viewMonth]);
|
|
80
|
+
|
|
81
|
+
const disabledFor = (date: Date) => coreIsDisabled(date, { min, max, isDateDisallowed });
|
|
82
|
+
|
|
83
|
+
const page = (dir: number) => {
|
|
84
|
+
const step = pageBy === 'single' ? 1 : months;
|
|
85
|
+
const d = new Date(viewYear, viewMonth + dir * step, 1);
|
|
86
|
+
setViewYear(d.getFullYear());
|
|
87
|
+
setViewMonth(d.getMonth());
|
|
88
|
+
setFocusedIso(undefined);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const select = (date: Date) => {
|
|
92
|
+
if (disabledFor(date)) return;
|
|
93
|
+
if (!anchor) {
|
|
94
|
+
setAnchor(date);
|
|
95
|
+
setHover(undefined);
|
|
96
|
+
onRangeStart?.(date);
|
|
97
|
+
} else {
|
|
98
|
+
const pair = sortRange(anchor, date);
|
|
99
|
+
if (!controlled) setInternal(pair);
|
|
100
|
+
onChange?.(pair);
|
|
101
|
+
setAnchor(undefined);
|
|
102
|
+
setHover(undefined);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const moveFocus = (target: Date) => {
|
|
107
|
+
setFocusedIso(toISO(target));
|
|
108
|
+
if (!isMonthVisible(target, viewYear, viewMonth, months)) {
|
|
109
|
+
setViewYear(target.getFullYear());
|
|
110
|
+
setViewMonth(target.getMonth());
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const onKeyDown = (e: KeyboardEvent<HTMLElement>, date: Date) => {
|
|
115
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
select(date);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (e.key === 'Escape') {
|
|
121
|
+
if (anchor) { setAnchor(undefined); setHover(undefined); }
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const next = nextFocusDate(date, e.key, { shiftKey: e.shiftKey, firstDayOfWeek });
|
|
125
|
+
if (!next) return;
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
moveFocus(next);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// Resolve the effective [start, end] used for painting: the in-progress
|
|
131
|
+
// selection (anchor + hover/focus preview) if anchoring, else the committed range.
|
|
132
|
+
let paintStart: Date | undefined;
|
|
133
|
+
let paintEnd: Date | undefined;
|
|
134
|
+
if (anchor) {
|
|
135
|
+
const previewEnd = hover ?? (focusedIso ? parseISO(focusedIso) ?? anchor : anchor);
|
|
136
|
+
[paintStart, paintEnd] = sortRange(anchor, previewEnd);
|
|
137
|
+
} else if (committed) {
|
|
138
|
+
// Sort so an externally-set out-of-order value pair still paints correctly.
|
|
139
|
+
[paintStart, paintEnd] = sortRange(committed[0], committed[1]);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const anchorVisible = anchor && isMonthVisible(anchor, viewYear, viewMonth, months) ? anchor : undefined;
|
|
143
|
+
const committedStartVisible = committed && isMonthVisible(committed[0], viewYear, viewMonth, months) ? committed[0] : undefined;
|
|
144
|
+
const todayVisible = isMonthVisible(today, viewYear, viewMonth, months) ? today : undefined;
|
|
145
|
+
const tabbableIso = focusedIso
|
|
146
|
+
?? (anchorVisible && toISO(anchorVisible))
|
|
147
|
+
?? (committedStartVisible && toISO(committedStartVisible))
|
|
148
|
+
?? (todayVisible && toISO(todayVisible))
|
|
149
|
+
?? toISO(new Date(viewYear, viewMonth, 1));
|
|
150
|
+
|
|
151
|
+
const classifyDay = (date: Date): DayState => {
|
|
152
|
+
const isStart = !!paintStart && isSameDay(date, paintStart);
|
|
153
|
+
const isEnd = !!paintEnd && isSameDay(date, paintEnd);
|
|
154
|
+
const inRange = !!paintStart && !!paintEnd && !isStart && !isEnd && isInRange(date, paintStart, paintEnd);
|
|
155
|
+
return {
|
|
156
|
+
today: isSameDay(date, today),
|
|
157
|
+
selected: false,
|
|
158
|
+
rangeStart: isStart,
|
|
159
|
+
rangeEnd: isEnd,
|
|
160
|
+
inRange,
|
|
161
|
+
disabled: disabledFor(date),
|
|
162
|
+
tabbable: toISO(date) === tabbableIso,
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const weekdayNames = formatWeekday
|
|
167
|
+
? weekdayNamesFrom(formatWeekday, firstDayOfWeek)
|
|
168
|
+
: getWeekdayNames(locale, firstDayOfWeek);
|
|
169
|
+
const labelOfMonth = (y: number, m: number) =>
|
|
170
|
+
formatMonth ? formatMonth(new Date(y, m, 1)) : getMonthLabel(y, m, locale);
|
|
171
|
+
const labelOfDay = (d: Date) => (formatDay ? formatDay(d) : getDayLabel(d, locale));
|
|
172
|
+
const prevLabel = labels?.previousMonth ?? 'Previous month';
|
|
173
|
+
const nextLabel = labels?.nextMonth ?? 'Next month';
|
|
174
|
+
const count = Math.max(1, months);
|
|
175
|
+
// Name every visible month in the group label, not just the first (matters for months > 1).
|
|
176
|
+
const groupLabel = Array.from({ length: count }, (_, i) => {
|
|
177
|
+
const d = new Date(viewYear, viewMonth + i, 1);
|
|
178
|
+
return labelOfMonth(d.getFullYear(), d.getMonth());
|
|
179
|
+
}).join(', ');
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<div {...rest} className={cn(css.calendar, className)} role="group" aria-label={groupLabel}>
|
|
183
|
+
<div className={css.months}>
|
|
184
|
+
{Array.from({ length: count }, (_, i) => {
|
|
185
|
+
const d = new Date(viewYear, viewMonth + i, 1);
|
|
186
|
+
return (
|
|
187
|
+
<MonthGrid
|
|
188
|
+
key={i}
|
|
189
|
+
year={d.getFullYear()}
|
|
190
|
+
month={d.getMonth()}
|
|
191
|
+
firstDayOfWeek={firstDayOfWeek}
|
|
192
|
+
weekdayNames={weekdayNames}
|
|
193
|
+
monthLabel={labelOfMonth(d.getFullYear(), d.getMonth())}
|
|
194
|
+
headingId={`${headingBaseId}-${i}`}
|
|
195
|
+
showPrev={i === 0}
|
|
196
|
+
showNext={i === count - 1}
|
|
197
|
+
onPrev={() => page(-1)}
|
|
198
|
+
onNext={() => page(1)}
|
|
199
|
+
prevLabel={prevLabel}
|
|
200
|
+
nextLabel={nextLabel}
|
|
201
|
+
classifyDay={classifyDay}
|
|
202
|
+
formatDay={labelOfDay}
|
|
203
|
+
registerRef={registerRef}
|
|
204
|
+
onSelect={select}
|
|
205
|
+
onKeyDown={onKeyDown}
|
|
206
|
+
onDayPointerEnter={anchor ? (date => setHover(date)) : undefined}
|
|
207
|
+
/>
|
|
208
|
+
);
|
|
209
|
+
})}
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { KeyboardEvent } from 'react';
|
|
2
|
+
import { cn } from '@boostdev/design-system-foundation';
|
|
3
|
+
import css from './Calendar.module.css';
|
|
4
|
+
import { buildMonthGrid, type ISODate } from './calendar-core';
|
|
5
|
+
|
|
6
|
+
export interface DayState {
|
|
7
|
+
today: boolean;
|
|
8
|
+
selected: boolean;
|
|
9
|
+
rangeStart: boolean;
|
|
10
|
+
rangeEnd: boolean;
|
|
11
|
+
inRange: boolean;
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
tabbable: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface MonthGridProps {
|
|
17
|
+
year: number;
|
|
18
|
+
month: number;
|
|
19
|
+
firstDayOfWeek: number;
|
|
20
|
+
weekdayNames: string[];
|
|
21
|
+
monthLabel: string;
|
|
22
|
+
headingId: string;
|
|
23
|
+
showPrev: boolean;
|
|
24
|
+
showNext: boolean;
|
|
25
|
+
onPrev: () => void;
|
|
26
|
+
onNext: () => void;
|
|
27
|
+
prevLabel: string;
|
|
28
|
+
nextLabel: string;
|
|
29
|
+
classifyDay: (date: Date) => DayState;
|
|
30
|
+
formatDay: (date: Date) => string;
|
|
31
|
+
registerRef: (iso: ISODate, el: HTMLButtonElement | null) => void;
|
|
32
|
+
onSelect: (date: Date) => void;
|
|
33
|
+
onKeyDown: (e: KeyboardEvent<HTMLElement>, date: Date) => void;
|
|
34
|
+
onDayPointerEnter?: (date: Date) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ChevronLeft = () => (
|
|
38
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
|
39
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M15 19l-7-7 7-7" />
|
|
40
|
+
</svg>
|
|
41
|
+
);
|
|
42
|
+
const ChevronRight = () => (
|
|
43
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
|
44
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M9 5l7 7-7 7" />
|
|
45
|
+
</svg>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export function MonthGrid(props: Readonly<MonthGridProps>) {
|
|
49
|
+
const {
|
|
50
|
+
year, month, firstDayOfWeek, weekdayNames, monthLabel, headingId,
|
|
51
|
+
showPrev, showNext, onPrev, onNext, prevLabel, nextLabel,
|
|
52
|
+
classifyDay, formatDay, registerRef, onSelect, onKeyDown, onDayPointerEnter,
|
|
53
|
+
} = props;
|
|
54
|
+
|
|
55
|
+
const cells = buildMonthGrid(year, month, firstDayOfWeek);
|
|
56
|
+
const rows = Array.from({ length: 6 }, (_, r) => cells.slice(r * 7, r * 7 + 7));
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className={css.month}>
|
|
60
|
+
<div className={css.monthHeader}>
|
|
61
|
+
<span className={css.navSlot}>
|
|
62
|
+
{showPrev && (
|
|
63
|
+
<button type="button" className={css.navBtn} aria-label={prevLabel} onClick={onPrev}>
|
|
64
|
+
<ChevronLeft />
|
|
65
|
+
</button>
|
|
66
|
+
)}
|
|
67
|
+
</span>
|
|
68
|
+
<span id={headingId} className={css.monthYear} aria-live="polite">{monthLabel}</span>
|
|
69
|
+
<span className={css.navSlot}>
|
|
70
|
+
{showNext && (
|
|
71
|
+
<button type="button" className={css.navBtn} aria-label={nextLabel} onClick={onNext}>
|
|
72
|
+
<ChevronRight />
|
|
73
|
+
</button>
|
|
74
|
+
)}
|
|
75
|
+
</span>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<div className={css.grid} role="grid" aria-labelledby={headingId}>
|
|
79
|
+
<div className={css.row} role="row">
|
|
80
|
+
{weekdayNames.map((name, i) => (
|
|
81
|
+
<span key={i} role="columnheader" className={css.weekday} aria-label={name}>{name}</span>
|
|
82
|
+
))}
|
|
83
|
+
</div>
|
|
84
|
+
{rows.map((week, r) => (
|
|
85
|
+
<div key={r} className={css.row} role="row">
|
|
86
|
+
{week.map(cell => {
|
|
87
|
+
// Outside days (from adjacent months) are inert: greyed, disabled,
|
|
88
|
+
// and never carry selected/range/today state — classifyDay keys off
|
|
89
|
+
// the Date alone and can't tell an in-month cell from an outside cell
|
|
90
|
+
// sharing the same date, so gate the state here.
|
|
91
|
+
const s: DayState = cell.outside
|
|
92
|
+
? { today: false, selected: false, rangeStart: false, rangeEnd: false, inRange: false, disabled: true, tabbable: false }
|
|
93
|
+
: classifyDay(cell.date);
|
|
94
|
+
const isEndpoint = s.selected || s.rangeStart || s.rangeEnd;
|
|
95
|
+
return (
|
|
96
|
+
<span
|
|
97
|
+
key={cell.iso}
|
|
98
|
+
role="gridcell"
|
|
99
|
+
aria-selected={isEndpoint}
|
|
100
|
+
className={css.cell}
|
|
101
|
+
>
|
|
102
|
+
<button
|
|
103
|
+
ref={el => registerRef(cell.iso, el)}
|
|
104
|
+
type="button"
|
|
105
|
+
data-date={cell.iso}
|
|
106
|
+
data-outside={cell.outside || undefined}
|
|
107
|
+
data-today={s.today || undefined}
|
|
108
|
+
data-selected={s.selected || undefined}
|
|
109
|
+
data-range-start={s.rangeStart || undefined}
|
|
110
|
+
data-range-end={s.rangeEnd || undefined}
|
|
111
|
+
data-in-range={s.inRange || undefined}
|
|
112
|
+
className={cn(
|
|
113
|
+
css.day,
|
|
114
|
+
cell.outside && css.outside,
|
|
115
|
+
s.today && !isEndpoint && css.today,
|
|
116
|
+
s.selected && css.selected,
|
|
117
|
+
s.rangeStart && css.rangeStart,
|
|
118
|
+
s.rangeEnd && css.rangeEnd,
|
|
119
|
+
s.inRange && css.inRange,
|
|
120
|
+
s.disabled && css.disabled,
|
|
121
|
+
)}
|
|
122
|
+
aria-label={formatDay(cell.date)}
|
|
123
|
+
aria-current={s.today ? 'date' : undefined}
|
|
124
|
+
aria-disabled={s.disabled || undefined}
|
|
125
|
+
disabled={s.disabled || cell.outside}
|
|
126
|
+
tabIndex={s.tabbable ? 0 : -1}
|
|
127
|
+
onClick={() => onSelect(cell.date)}
|
|
128
|
+
onKeyDown={e => onKeyDown(e, cell.date)}
|
|
129
|
+
onPointerEnter={onDayPointerEnter ? () => onDayPointerEnter(cell.date) : undefined}
|
|
130
|
+
>
|
|
131
|
+
{cell.day}
|
|
132
|
+
</button>
|
|
133
|
+
</span>
|
|
134
|
+
);
|
|
135
|
+
})}
|
|
136
|
+
</div>
|
|
137
|
+
))}
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
);
|
|
141
|
+
}
|