@masaraxui/react 1.0.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/LICENSE +21 -0
- package/README.md +50 -0
- package/dist/components/accordion/accordion.d.ts +30 -0
- package/dist/components/accordion/accordion.js +191 -0
- package/dist/components/accordion/index.d.ts +25 -0
- package/dist/components/accordion/index.js +18 -0
- package/dist/components/alert/alert.d.ts +15 -0
- package/dist/components/alert/alert.js +152 -0
- package/dist/components/alert/index.d.ts +21 -0
- package/dist/components/alert/index.js +16 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +65 -0
- package/dist/components/alert-dialog/alert-dialog.js +309 -0
- package/dist/components/alert-dialog/index.d.ts +33 -0
- package/dist/components/alert-dialog/index.js +22 -0
- package/dist/components/autocomplete/autocomplete.d.ts +31 -0
- package/dist/components/autocomplete/autocomplete.js +241 -0
- package/dist/components/autocomplete/index.d.ts +25 -0
- package/dist/components/autocomplete/index.js +18 -0
- package/dist/components/avatar/avatar.d.ts +15 -0
- package/dist/components/avatar/avatar.js +93 -0
- package/dist/components/avatar/index.d.ts +17 -0
- package/dist/components/avatar/index.js +14 -0
- package/dist/components/badge/badge.d.ts +19 -0
- package/dist/components/badge/badge.js +87 -0
- package/dist/components/badge/index.d.ts +17 -0
- package/dist/components/badge/index.js +14 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +14 -0
- package/dist/components/breadcrumbs/breadcrumbs.js +84 -0
- package/dist/components/breadcrumbs/index.d.ts +15 -0
- package/dist/components/breadcrumbs/index.js +13 -0
- package/dist/components/button/button.d.ts +10 -0
- package/dist/components/button/button.js +49 -0
- package/dist/components/button/index.d.ts +15 -0
- package/dist/components/button/index.js +13 -0
- package/dist/components/button-group/button-group.d.ts +26 -0
- package/dist/components/button-group/button-group.js +82 -0
- package/dist/components/button-group/index.d.ts +16 -0
- package/dist/components/button-group/index.js +14 -0
- package/dist/components/calendar/calendar.d.ts +71 -0
- package/dist/components/calendar/calendar.js +283 -0
- package/dist/components/calendar/index.d.ts +91 -0
- package/dist/components/calendar/index.js +29 -0
- package/dist/components/calendar-year-picker/calendar-year-picker.d.ts +61 -0
- package/dist/components/calendar-year-picker/calendar-year-picker.js +411 -0
- package/dist/components/calendar-year-picker/index.d.ts +43 -0
- package/dist/components/calendar-year-picker/index.js +18 -0
- package/dist/components/calendar-year-picker/year-picker-context.d.ts +28 -0
- package/dist/components/calendar-year-picker/year-picker-context.js +39 -0
- package/dist/components/card/card.d.ts +22 -0
- package/dist/components/card/card.js +141 -0
- package/dist/components/card/index.d.ts +23 -0
- package/dist/components/card/index.js +17 -0
- package/dist/components/checkbox/checkbox.d.ts +22 -0
- package/dist/components/checkbox/checkbox.js +124 -0
- package/dist/components/checkbox/index.d.ts +19 -0
- package/dist/components/checkbox/index.js +15 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts +14 -0
- package/dist/components/checkbox-group/checkbox-group.js +33 -0
- package/dist/components/checkbox-group/index.d.ts +3 -0
- package/dist/components/checkbox-group/index.js +3 -0
- package/dist/components/chip/chip.d.ts +14 -0
- package/dist/components/chip/chip.js +67 -0
- package/dist/components/chip/index.d.ts +15 -0
- package/dist/components/chip/index.js +13 -0
- package/dist/components/close-button/close-button.d.ts +8 -0
- package/dist/components/close-button/close-button.js +33 -0
- package/dist/components/close-button/index.d.ts +13 -0
- package/dist/components/close-button/index.js +12 -0
- package/dist/components/color-area/color-area.d.ts +11 -0
- package/dist/components/color-area/color-area.js +70 -0
- package/dist/components/color-area/index.d.ts +15 -0
- package/dist/components/color-area/index.js +13 -0
- package/dist/components/color-field/color-field.d.ts +9 -0
- package/dist/components/color-field/color-field.js +29 -0
- package/dist/components/color-field/index.d.ts +22 -0
- package/dist/components/color-field/index.js +18 -0
- package/dist/components/color-input-group/color-input-group.d.ts +19 -0
- package/dist/components/color-input-group/color-input-group.js +98 -0
- package/dist/components/color-input-group/index.d.ts +19 -0
- package/dist/components/color-input-group/index.js +15 -0
- package/dist/components/color-picker/color-picker.d.ts +21 -0
- package/dist/components/color-picker/color-picker.js +86 -0
- package/dist/components/color-picker/index.d.ts +17 -0
- package/dist/components/color-picker/index.js +14 -0
- package/dist/components/color-slider/color-slider.d.ts +50 -0
- package/dist/components/color-slider/color-slider.js +205 -0
- package/dist/components/color-slider/index.d.ts +19 -0
- package/dist/components/color-slider/index.js +15 -0
- package/dist/components/color-swatch/color-swatch.d.ts +8 -0
- package/dist/components/color-swatch/color-swatch.js +31 -0
- package/dist/components/color-swatch/index.d.ts +13 -0
- package/dist/components/color-swatch/index.js +12 -0
- package/dist/components/color-swatch-picker/color-swatch-picker.d.ts +20 -0
- package/dist/components/color-swatch-picker/color-swatch-picker.js +149 -0
- package/dist/components/color-swatch-picker/index.d.ts +19 -0
- package/dist/components/color-swatch-picker/index.js +15 -0
- package/dist/components/combo-box/combo-box.d.ts +34 -0
- package/dist/components/combo-box/combo-box.js +116 -0
- package/dist/components/combo-box/index.d.ts +20 -0
- package/dist/components/combo-box/index.js +16 -0
- package/dist/components/date-field/date-field.d.ts +9 -0
- package/dist/components/date-field/date-field.js +29 -0
- package/dist/components/date-field/index.d.ts +26 -0
- package/dist/components/date-field/index.js +20 -0
- package/dist/components/date-input-group/date-input-group.d.ts +25 -0
- package/dist/components/date-input-group/date-input-group.js +146 -0
- package/dist/components/date-input-group/index.d.ts +23 -0
- package/dist/components/date-input-group/index.js +17 -0
- package/dist/components/date-picker/date-picker.d.ts +30 -0
- package/dist/components/date-picker/date-picker.js +151 -0
- package/dist/components/date-picker/index.d.ts +31 -0
- package/dist/components/date-picker/index.js +15 -0
- package/dist/components/date-range-picker/date-range-picker.d.ts +36 -0
- package/dist/components/date-range-picker/date-range-picker.js +173 -0
- package/dist/components/date-range-picker/index.d.ts +36 -0
- package/dist/components/date-range-picker/index.js +16 -0
- package/dist/components/description/description.d.ts +9 -0
- package/dist/components/description/description.js +22 -0
- package/dist/components/description/index.d.ts +13 -0
- package/dist/components/description/index.js +12 -0
- package/dist/components/disclosure/disclosure.d.ts +27 -0
- package/dist/components/disclosure/disclosure.js +157 -0
- package/dist/components/disclosure/index.d.ts +23 -0
- package/dist/components/disclosure/index.js +17 -0
- package/dist/components/disclosure-group/disclosure-group.d.ts +8 -0
- package/dist/components/disclosure-group/disclosure-group.js +35 -0
- package/dist/components/disclosure-group/index.d.ts +15 -0
- package/dist/components/disclosure-group/index.js +13 -0
- package/dist/components/disclosure-group/use-disclosure-group-navigation.d.ts +14 -0
- package/dist/components/disclosure-group/use-disclosure-group-navigation.js +51 -0
- package/dist/components/drawer/drawer.d.ts +84 -0
- package/dist/components/drawer/drawer.js +439 -0
- package/dist/components/drawer/index.d.ts +69 -0
- package/dist/components/drawer/index.js +22 -0
- package/dist/components/dropdown/dropdown.d.ts +38 -0
- package/dist/components/dropdown/dropdown.js +156 -0
- package/dist/components/dropdown/index.d.ts +29 -0
- package/dist/components/dropdown/index.js +20 -0
- package/dist/components/empty-state/empty-state.d.ts +7 -0
- package/dist/components/empty-state/empty-state.js +20 -0
- package/dist/components/empty-state/index.d.ts +13 -0
- package/dist/components/empty-state/index.js +12 -0
- package/dist/components/error-message/error-message.d.ts +9 -0
- package/dist/components/error-message/error-message.js +22 -0
- package/dist/components/error-message/index.d.ts +13 -0
- package/dist/components/error-message/index.js +12 -0
- package/dist/components/field-error/field-error.d.ts +8 -0
- package/dist/components/field-error/field-error.js +21 -0
- package/dist/components/field-error/index.d.ts +13 -0
- package/dist/components/field-error/index.js +12 -0
- package/dist/components/fieldset/fieldset.d.ts +16 -0
- package/dist/components/fieldset/fieldset.js +88 -0
- package/dist/components/fieldset/index.d.ts +19 -0
- package/dist/components/fieldset/index.js +15 -0
- package/dist/components/form/form.d.ts +7 -0
- package/dist/components/form/form.js +13 -0
- package/dist/components/form/index.d.ts +11 -0
- package/dist/components/form/index.js +11 -0
- package/dist/components/header/header.d.ts +7 -0
- package/dist/components/header/header.js +21 -0
- package/dist/components/header/index.d.ts +9 -0
- package/dist/components/header/index.js +10 -0
- package/dist/components/icons.d.ts +18 -0
- package/dist/components/icons.js +243 -0
- package/dist/components/index.d.ts +84 -0
- package/dist/components/input/index.d.ts +13 -0
- package/dist/components/input/index.js +12 -0
- package/dist/components/input/input.d.ts +8 -0
- package/dist/components/input/input.js +31 -0
- package/dist/components/input-group/index.d.ts +21 -0
- package/dist/components/input-group/index.js +16 -0
- package/dist/components/input-group/input-group.d.ts +20 -0
- package/dist/components/input-group/input-group.js +129 -0
- package/dist/components/input-otp/index.d.ts +22 -0
- package/dist/components/input-otp/index.js +21 -0
- package/dist/components/input-otp/input-otp.d.ts +26 -0
- package/dist/components/input-otp/input-otp.js +139 -0
- package/dist/components/kbd/index.d.ts +19 -0
- package/dist/components/kbd/index.js +15 -0
- package/dist/components/kbd/kbd.constants.d.ts +3 -0
- package/dist/components/kbd/kbd.constants.js +51 -0
- package/dist/components/kbd/kbd.d.ts +24 -0
- package/dist/components/kbd/kbd.js +76 -0
- package/dist/components/label/index.d.ts +13 -0
- package/dist/components/label/index.js +12 -0
- package/dist/components/label/label.d.ts +8 -0
- package/dist/components/label/label.js +27 -0
- package/dist/components/link/index.d.ts +15 -0
- package/dist/components/link/index.js +13 -0
- package/dist/components/link/link.d.ts +10 -0
- package/dist/components/link/link.js +59 -0
- package/dist/components/list-box/index.d.ts +23 -0
- package/dist/components/list-box/index.js +18 -0
- package/dist/components/list-box/list-box.d.ts +9 -0
- package/dist/components/list-box/list-box.js +23 -0
- package/dist/components/list-box-item/index.d.ts +15 -0
- package/dist/components/list-box-item/index.js +13 -0
- package/dist/components/list-box-item/list-box-item.d.ts +15 -0
- package/dist/components/list-box-item/list-box-item.js +77 -0
- package/dist/components/list-box-section/index.d.ts +10 -0
- package/dist/components/list-box-section/index.js +10 -0
- package/dist/components/list-box-section/list-box-section.d.ts +8 -0
- package/dist/components/list-box-section/list-box-section.js +22 -0
- package/dist/components/menu/index.d.ts +24 -0
- package/dist/components/menu/index.js +18 -0
- package/dist/components/menu/menu.d.ts +9 -0
- package/dist/components/menu/menu.js +20 -0
- package/dist/components/menu-item/index.d.ts +17 -0
- package/dist/components/menu-item/index.js +14 -0
- package/dist/components/menu-item/menu-item.d.ts +20 -0
- package/dist/components/menu-item/menu-item.js +123 -0
- package/dist/components/menu-section/index.d.ts +10 -0
- package/dist/components/menu-section/index.js +10 -0
- package/dist/components/menu-section/menu-section.d.ts +8 -0
- package/dist/components/menu-section/menu-section.js +22 -0
- package/dist/components/meter/index.d.ts +34 -0
- package/dist/components/meter/index.js +15 -0
- package/dist/components/meter/meter.d.ts +29 -0
- package/dist/components/meter/meter.js +108 -0
- package/dist/components/modal/index.d.ts +33 -0
- package/dist/components/modal/index.js +22 -0
- package/dist/components/modal/modal.d.ts +53 -0
- package/dist/components/modal/modal.js +288 -0
- package/dist/components/number-field/index.d.ts +21 -0
- package/dist/components/number-field/index.js +16 -0
- package/dist/components/number-field/number-field.d.ts +20 -0
- package/dist/components/number-field/number-field.js +127 -0
- package/dist/components/pagination/index.d.ts +64 -0
- package/dist/components/pagination/index.js +21 -0
- package/dist/components/pagination/pagination.d.ts +84 -0
- package/dist/components/pagination/pagination.js +230 -0
- package/dist/components/popover/index.d.ts +23 -0
- package/dist/components/popover/index.js +17 -0
- package/dist/components/popover/popover.d.ts +24 -0
- package/dist/components/popover/popover.js +153 -0
- package/dist/components/progress-bar/index.d.ts +34 -0
- package/dist/components/progress-bar/index.js +15 -0
- package/dist/components/progress-bar/progress-bar.d.ts +29 -0
- package/dist/components/progress-bar/progress-bar.js +108 -0
- package/dist/components/progress-circle/index.d.ts +34 -0
- package/dist/components/progress-circle/index.js +15 -0
- package/dist/components/progress-circle/progress-circle.d.ts +29 -0
- package/dist/components/progress-circle/progress-circle.js +126 -0
- package/dist/components/rac/components.d.ts +1 -0
- package/dist/components/rac/index.d.ts +5 -0
- package/dist/components/rac/index.js +3 -0
- package/dist/components/rac/types.d.ts +3 -0
- package/dist/components/rac/utils.d.ts +1 -0
- package/dist/components/radio/index.d.ts +19 -0
- package/dist/components/radio/index.js +15 -0
- package/dist/components/radio/radio.d.ts +21 -0
- package/dist/components/radio/radio.js +97 -0
- package/dist/components/radio-group/index.d.ts +13 -0
- package/dist/components/radio-group/index.js +12 -0
- package/dist/components/radio-group/radio-group.d.ts +8 -0
- package/dist/components/radio-group/radio-group.js +27 -0
- package/dist/components/range-calendar/index.d.ts +91 -0
- package/dist/components/range-calendar/index.js +29 -0
- package/dist/components/range-calendar/range-calendar.d.ts +71 -0
- package/dist/components/range-calendar/range-calendar.js +298 -0
- package/dist/components/scroll-shadow/index.d.ts +21 -0
- package/dist/components/scroll-shadow/index.js +13 -0
- package/dist/components/scroll-shadow/scroll-shadow.d.ts +32 -0
- package/dist/components/scroll-shadow/scroll-shadow.js +76 -0
- package/dist/components/scroll-shadow/use-scroll-shadow.d.ts +11 -0
- package/dist/components/scroll-shadow/use-scroll-shadow.js +121 -0
- package/dist/components/search-field/index.d.ts +21 -0
- package/dist/components/search-field/index.js +16 -0
- package/dist/components/search-field/search-field.d.ts +23 -0
- package/dist/components/search-field/search-field.js +127 -0
- package/dist/components/select/index.d.ts +21 -0
- package/dist/components/select/index.js +16 -0
- package/dist/components/select/select.d.ts +24 -0
- package/dist/components/select/select.js +140 -0
- package/dist/components/separator/index.d.ts +13 -0
- package/dist/components/separator/index.js +12 -0
- package/dist/components/separator/separator.d.ts +8 -0
- package/dist/components/separator/separator.js +27 -0
- package/dist/components/skeleton/index.d.ts +13 -0
- package/dist/components/skeleton/index.js +12 -0
- package/dist/components/skeleton/skeleton.d.ts +7 -0
- package/dist/components/skeleton/skeleton.js +25 -0
- package/dist/components/slider/index.d.ts +23 -0
- package/dist/components/slider/index.js +17 -0
- package/dist/components/slider/slider.d.ts +23 -0
- package/dist/components/slider/slider.js +177 -0
- package/dist/components/spinner/index.d.ts +13 -0
- package/dist/components/spinner/index.js +12 -0
- package/dist/components/spinner/spinner.d.ts +7 -0
- package/dist/components/spinner/spinner.js +88 -0
- package/dist/components/surface/index.d.ts +14 -0
- package/dist/components/surface/index.js +13 -0
- package/dist/components/surface/surface.d.ts +12 -0
- package/dist/components/surface/surface.js +34 -0
- package/dist/components/switch/index.d.ts +21 -0
- package/dist/components/switch/index.js +16 -0
- package/dist/components/switch/switch.d.ts +20 -0
- package/dist/components/switch/switch.js +118 -0
- package/dist/components/switch-group/index.d.ts +13 -0
- package/dist/components/switch-group/index.js +12 -0
- package/dist/components/switch-group/switch-group.d.ts +7 -0
- package/dist/components/switch-group/switch-group.js +25 -0
- package/dist/components/table/index.d.ts +38 -0
- package/dist/components/table/index.js +25 -0
- package/dist/components/table/table.d.ts +50 -0
- package/dist/components/table/table.js +283 -0
- package/dist/components/tabs/index.d.ts +25 -0
- package/dist/components/tabs/index.js +18 -0
- package/dist/components/tabs/tabs.d.ts +37 -0
- package/dist/components/tabs/tabs.js +156 -0
- package/dist/components/tag/index.d.ts +15 -0
- package/dist/components/tag/index.js +13 -0
- package/dist/components/tag/tag.d.ts +14 -0
- package/dist/components/tag/tag.js +85 -0
- package/dist/components/tag-group/index.d.ts +15 -0
- package/dist/components/tag-group/index.js +14 -0
- package/dist/components/tag-group/tag-group.d.ts +20 -0
- package/dist/components/tag-group/tag-group.js +59 -0
- package/dist/components/text/index.d.ts +13 -0
- package/dist/components/text/index.js +12 -0
- package/dist/components/text/text.d.ts +8 -0
- package/dist/components/text/text.js +25 -0
- package/dist/components/textarea/index.d.ts +13 -0
- package/dist/components/textarea/index.js +12 -0
- package/dist/components/textarea/textarea.d.ts +8 -0
- package/dist/components/textarea/textarea.js +27 -0
- package/dist/components/textfield/index.d.ts +14 -0
- package/dist/components/textfield/index.js +13 -0
- package/dist/components/textfield/textfield.d.ts +18 -0
- package/dist/components/textfield/textfield.js +39 -0
- package/dist/components/time-field/index.d.ts +26 -0
- package/dist/components/time-field/index.js +20 -0
- package/dist/components/time-field/time-field.d.ts +9 -0
- package/dist/components/time-field/time-field.js +29 -0
- package/dist/components/toast/constants.d.ts +6 -0
- package/dist/components/toast/constants.js +15 -0
- package/dist/components/toast/index.d.ts +75 -0
- package/dist/components/toast/index.js +23 -0
- package/dist/components/toast/toast-queue.d.ts +70 -0
- package/dist/components/toast/toast-queue.js +147 -0
- package/dist/components/toast/toast.d.ts +69 -0
- package/dist/components/toast/toast.js +365 -0
- package/dist/components/toggle-button/index.d.ts +13 -0
- package/dist/components/toggle-button/index.js +12 -0
- package/dist/components/toggle-button/toggle-button.d.ts +8 -0
- package/dist/components/toggle-button/toggle-button.js +36 -0
- package/dist/components/toggle-button-group/index.d.ts +16 -0
- package/dist/components/toggle-button-group/index.js +14 -0
- package/dist/components/toggle-button-group/toggle-button-group.d.ts +25 -0
- package/dist/components/toggle-button-group/toggle-button-group.js +70 -0
- package/dist/components/toolbar/index.d.ts +19 -0
- package/dist/components/toolbar/index.js +12 -0
- package/dist/components/toolbar/toolbar.d.ts +11 -0
- package/dist/components/toolbar/toolbar.js +39 -0
- package/dist/components/tooltip/index.d.ts +19 -0
- package/dist/components/tooltip/index.js +15 -0
- package/dist/components/tooltip/tooltip.d.ts +20 -0
- package/dist/components/tooltip/tooltip.js +106 -0
- package/dist/hooks/index.d.ts +9 -0
- package/dist/hooks/use-css-variable.d.ts +36 -0
- package/dist/hooks/use-css-variable.js +72 -0
- package/dist/hooks/use-is-hydrated.d.ts +19 -0
- package/dist/hooks/use-is-hydrated.js +28 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts +2 -0
- package/dist/hooks/use-isomorphic-layout-effect.js +6 -0
- package/dist/hooks/use-list-data.d.ts +111 -0
- package/dist/hooks/use-list-data.js +296 -0
- package/dist/hooks/use-measured-height.d.ts +4 -0
- package/dist/hooks/use-measured-height.js +47 -0
- package/dist/hooks/use-media-query.d.ts +6 -0
- package/dist/hooks/use-media-query.js +50 -0
- package/dist/hooks/use-mounted.d.ts +1 -0
- package/dist/hooks/use-mounted.js +15 -0
- package/dist/hooks/use-overlay-state.d.ts +52 -0
- package/dist/hooks/use-overlay-state.js +70 -0
- package/dist/hooks/use-safe-layout-effect.d.ts +2 -0
- package/dist/hooks/use-safe-layout-effect.js +6 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +190 -0
- package/dist/prerelease.d.ts +4 -0
- package/dist/prerelease.js +50 -0
- package/dist/styles.css +2 -0
- package/dist/utils/assertion.d.ts +9 -0
- package/dist/utils/assertion.js +3 -0
- package/dist/utils/calendar.d.ts +12 -0
- package/dist/utils/calendar.js +52 -0
- package/dist/utils/children.d.ts +9 -0
- package/dist/utils/children.js +17 -0
- package/dist/utils/compose.d.ts +7 -0
- package/dist/utils/compose.js +18 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/logger.d.ts +23 -0
- package/dist/utils/logger.js +78 -0
- package/dist/utils/tv.d.ts +3 -0
- package/dist/utils/variants.d.ts +73 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/package.json +406 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { CalendarYearPickerCell, CalendarYearPickerGridBody, CalendarYearPickerGrid, CalendarYearPickerTriggerIndicator, CalendarYearPickerTriggerHeading, CalendarYearPickerTrigger } from '../calendar-year-picker/calendar-year-picker.js';
|
|
3
|
+
export { YearPickerContext, YearPickerStateContext, useYearPicker, useYearPickerState } from '../calendar-year-picker/year-picker-context.js';
|
|
4
|
+
export { rangeCalendarVariants } from '@masaraxui/styles';
|
|
5
|
+
import { RangeCalendarRoot, RangeCalendarCellIndicator, RangeCalendarCell, RangeCalendarHeaderCell, RangeCalendarGridBody, RangeCalendarGridHeader, RangeCalendarGrid, RangeCalendarNavButton, RangeCalendarHeading, RangeCalendarHeader } from './range-calendar.js';
|
|
6
|
+
|
|
7
|
+
/* -------------------------------------------------------------------------------------------------
|
|
8
|
+
| * Compound Component
|
|
9
|
+
| * -----------------------------------------------------------------------------------------------*/
|
|
10
|
+
const RangeCalendar = Object.assign(RangeCalendarRoot, {
|
|
11
|
+
Root: RangeCalendarRoot,
|
|
12
|
+
Header: RangeCalendarHeader,
|
|
13
|
+
Heading: RangeCalendarHeading,
|
|
14
|
+
NavButton: RangeCalendarNavButton,
|
|
15
|
+
Grid: RangeCalendarGrid,
|
|
16
|
+
GridHeader: RangeCalendarGridHeader,
|
|
17
|
+
GridBody: RangeCalendarGridBody,
|
|
18
|
+
HeaderCell: RangeCalendarHeaderCell,
|
|
19
|
+
Cell: RangeCalendarCell,
|
|
20
|
+
CellIndicator: RangeCalendarCellIndicator,
|
|
21
|
+
YearPickerTrigger: CalendarYearPickerTrigger,
|
|
22
|
+
YearPickerTriggerHeading: CalendarYearPickerTriggerHeading,
|
|
23
|
+
YearPickerTriggerIndicator: CalendarYearPickerTriggerIndicator,
|
|
24
|
+
YearPickerGrid: CalendarYearPickerGrid,
|
|
25
|
+
YearPickerGridBody: CalendarYearPickerGridBody,
|
|
26
|
+
YearPickerCell: CalendarYearPickerCell
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export { RangeCalendar, RangeCalendarCell, RangeCalendarCellIndicator, RangeCalendarGrid, RangeCalendarGridBody, RangeCalendarGridHeader, RangeCalendarHeader, RangeCalendarHeaderCell, RangeCalendarHeading, RangeCalendarNavButton, RangeCalendarRoot };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { RangeCalendarVariants } from "@masaraxui/styles";
|
|
2
|
+
import type { ComponentPropsWithRef } from "react";
|
|
3
|
+
import type { DateValue } from "react-aria-components";
|
|
4
|
+
import { Button as ButtonPrimitive, CalendarCell as CalendarCellPrimitive, CalendarGridBody as CalendarGridBodyPrimitive, CalendarGridHeader as CalendarGridHeaderPrimitive, CalendarGrid as CalendarGridPrimitive, CalendarHeaderCell as CalendarHeaderCellPrimitive, Heading as HeadingPrimitive, RangeCalendar as RangeCalendarPrimitive } from "react-aria-components";
|
|
5
|
+
interface RangeCalendarRootProps<T extends DateValue = DateValue> extends ComponentPropsWithRef<typeof RangeCalendarPrimitive<T>>, RangeCalendarVariants {
|
|
6
|
+
isYearPickerOpen?: boolean;
|
|
7
|
+
onYearPickerOpenChange?: (isYearPickerOpen: boolean) => void;
|
|
8
|
+
defaultYearPickerOpen?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare function RangeCalendarRoot<T extends DateValue = DateValue>({ children, className, defaultYearPickerOpen: defaultYearPickerOpenProp, isYearPickerOpen: isYearPickerOpenProp, maxValue: maxValueProp, minValue: minValueProp, onYearPickerOpenChange: onYearPickerOpenChangeProp, ...rest }: RangeCalendarRootProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare namespace RangeCalendarRoot {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
interface RangeCalendarHeaderProps extends ComponentPropsWithRef<"header"> {
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const RangeCalendarHeader: {
|
|
18
|
+
({ children, className, ...props }: RangeCalendarHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
interface RangeCalendarHeadingProps extends ComponentPropsWithRef<typeof HeadingPrimitive> {
|
|
22
|
+
}
|
|
23
|
+
declare const RangeCalendarHeading: {
|
|
24
|
+
({ className, ...props }: RangeCalendarHeadingProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
displayName: string;
|
|
26
|
+
};
|
|
27
|
+
interface RangeCalendarNavButtonProps extends ComponentPropsWithRef<typeof ButtonPrimitive> {
|
|
28
|
+
slot?: "previous" | "next";
|
|
29
|
+
}
|
|
30
|
+
declare const RangeCalendarNavButton: {
|
|
31
|
+
({ children, className, slot, ...props }: RangeCalendarNavButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
displayName: string;
|
|
33
|
+
};
|
|
34
|
+
interface RangeCalendarGridProps extends ComponentPropsWithRef<typeof CalendarGridPrimitive> {
|
|
35
|
+
}
|
|
36
|
+
declare const RangeCalendarGrid: {
|
|
37
|
+
({ children, className, weekdayStyle, ...props }: RangeCalendarGridProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
displayName: string;
|
|
39
|
+
};
|
|
40
|
+
interface RangeCalendarGridHeaderProps extends ComponentPropsWithRef<typeof CalendarGridHeaderPrimitive> {
|
|
41
|
+
}
|
|
42
|
+
declare const RangeCalendarGridHeader: {
|
|
43
|
+
({ className, ...props }: RangeCalendarGridHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
displayName: string;
|
|
45
|
+
};
|
|
46
|
+
interface RangeCalendarGridBodyProps extends ComponentPropsWithRef<typeof CalendarGridBodyPrimitive> {
|
|
47
|
+
}
|
|
48
|
+
declare const RangeCalendarGridBody: {
|
|
49
|
+
({ className, ...props }: RangeCalendarGridBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
displayName: string;
|
|
51
|
+
};
|
|
52
|
+
interface RangeCalendarHeaderCellProps extends ComponentPropsWithRef<typeof CalendarHeaderCellPrimitive> {
|
|
53
|
+
}
|
|
54
|
+
declare const RangeCalendarHeaderCell: {
|
|
55
|
+
({ className, ...props }: RangeCalendarHeaderCellProps): import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
displayName: string;
|
|
57
|
+
};
|
|
58
|
+
interface RangeCalendarCellProps extends ComponentPropsWithRef<typeof CalendarCellPrimitive> {
|
|
59
|
+
}
|
|
60
|
+
declare const RangeCalendarCell: {
|
|
61
|
+
({ children, className, ...props }: RangeCalendarCellProps): import("react/jsx-runtime").JSX.Element;
|
|
62
|
+
displayName: string;
|
|
63
|
+
};
|
|
64
|
+
interface RangeCalendarCellIndicatorProps extends ComponentPropsWithRef<"span"> {
|
|
65
|
+
}
|
|
66
|
+
declare const RangeCalendarCellIndicator: {
|
|
67
|
+
({ className, ...props }: RangeCalendarCellIndicatorProps): import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
displayName: string;
|
|
69
|
+
};
|
|
70
|
+
export { RangeCalendarRoot, RangeCalendarHeader, RangeCalendarHeading, RangeCalendarNavButton, RangeCalendarGrid, RangeCalendarGridHeader, RangeCalendarGridBody, RangeCalendarHeaderCell, RangeCalendarCell, RangeCalendarCellIndicator, };
|
|
71
|
+
export type { RangeCalendarRootProps, RangeCalendarHeaderProps, RangeCalendarHeadingProps, RangeCalendarNavButtonProps, RangeCalendarGridProps, RangeCalendarGridHeaderProps, RangeCalendarGridBodyProps, RangeCalendarHeaderCellProps, RangeCalendarCellProps, RangeCalendarCellIndicatorProps, };
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { rangeCalendarVariants } from '@masaraxui/styles';
|
|
3
|
+
import { DateFormatter, createCalendar, CalendarDate } from '@internationalized/date';
|
|
4
|
+
import { useControlledState } from '@react-stately/utils';
|
|
5
|
+
import React__default, { createContext, useContext } from 'react';
|
|
6
|
+
import { useLocale, RangeCalendar, CalendarCell, CalendarHeaderCell, CalendarGridBody, CalendarGridHeader, CalendarGrid, Button, Heading, RangeCalendarStateContext } from 'react-aria-components';
|
|
7
|
+
import { dataAttr } from '../../utils/assertion.js';
|
|
8
|
+
import { getGregorianYearOffset } from '../../utils/calendar.js';
|
|
9
|
+
import { composeTwRenderProps, composeSlotClassName } from '../../utils/compose.js';
|
|
10
|
+
import { YearPickerContext, YearPickerStateContext } from '../calendar-year-picker/year-picker-context.js';
|
|
11
|
+
import { IconChevronLeft, IconChevronRight } from '../icons.js';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
const RangeCalendarContext = /*#__PURE__*/createContext({});
|
|
15
|
+
const RangeCalendarYearPickerStateBridge = ({
|
|
16
|
+
children
|
|
17
|
+
}) => {
|
|
18
|
+
const state = React__default.useContext(RangeCalendarStateContext);
|
|
19
|
+
if (!state) {
|
|
20
|
+
throw new Error("RangeCalendar year picker state must be used within <RangeCalendar>.");
|
|
21
|
+
}
|
|
22
|
+
const yearPickerStateValue = {
|
|
23
|
+
focusedDate: state.focusedDate,
|
|
24
|
+
maxValue: state.maxValue,
|
|
25
|
+
minValue: state.minValue,
|
|
26
|
+
setFocusedDate: value => state.setFocusedDate(value),
|
|
27
|
+
timeZone: state.timeZone
|
|
28
|
+
};
|
|
29
|
+
return /*#__PURE__*/jsx(YearPickerStateContext, {
|
|
30
|
+
value: yearPickerStateValue,
|
|
31
|
+
children: children
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/* -------------------------------------------------------------------------------------------------
|
|
36
|
+
| * RangeCalendar Root
|
|
37
|
+
| * -----------------------------------------------------------------------------------------------*/
|
|
38
|
+
|
|
39
|
+
function RangeCalendarRoot({
|
|
40
|
+
children,
|
|
41
|
+
className,
|
|
42
|
+
defaultYearPickerOpen: defaultYearPickerOpenProp = false,
|
|
43
|
+
isYearPickerOpen: isYearPickerOpenProp,
|
|
44
|
+
maxValue: maxValueProp,
|
|
45
|
+
minValue: minValueProp,
|
|
46
|
+
onYearPickerOpenChange: onYearPickerOpenChangeProp,
|
|
47
|
+
...rest
|
|
48
|
+
}) {
|
|
49
|
+
const {
|
|
50
|
+
locale
|
|
51
|
+
} = useLocale();
|
|
52
|
+
const slots = React__default.useMemo(() => rangeCalendarVariants(), []);
|
|
53
|
+
const calendarRef = React__default.useRef(null);
|
|
54
|
+
const [isYearPickerOpen, setIsYearPickerOpen] = useControlledState(isYearPickerOpenProp, defaultYearPickerOpenProp, onYearPickerOpenChangeProp);
|
|
55
|
+
const calendarProp = React__default.useMemo(() => {
|
|
56
|
+
const calendarIdentifier = new DateFormatter(locale).resolvedOptions().calendar;
|
|
57
|
+
return createCalendar(calendarIdentifier);
|
|
58
|
+
}, [locale]);
|
|
59
|
+
const gregorianYearOffset = React__default.useMemo(() => getGregorianYearOffset(calendarProp.identifier), [calendarProp.identifier]);
|
|
60
|
+
const minValue = minValueProp ?? new CalendarDate(calendarProp, 1900 + gregorianYearOffset, 1, 1);
|
|
61
|
+
const maxValue = maxValueProp ?? new CalendarDate(calendarProp, 2099 + gregorianYearOffset, 12, 31);
|
|
62
|
+
return /*#__PURE__*/jsx(YearPickerContext, {
|
|
63
|
+
value: {
|
|
64
|
+
calendarGridSlot: "range-calendar-grid",
|
|
65
|
+
isYearPickerOpen,
|
|
66
|
+
setIsYearPickerOpen,
|
|
67
|
+
calendarRef
|
|
68
|
+
},
|
|
69
|
+
children: /*#__PURE__*/jsx(RangeCalendarContext, {
|
|
70
|
+
value: {
|
|
71
|
+
slots
|
|
72
|
+
},
|
|
73
|
+
children: /*#__PURE__*/jsx(RangeCalendar, {
|
|
74
|
+
ref: calendarRef,
|
|
75
|
+
"data-slot": "range-calendar",
|
|
76
|
+
maxValue: maxValue,
|
|
77
|
+
minValue: minValue,
|
|
78
|
+
...rest,
|
|
79
|
+
className: composeTwRenderProps(className, slots.base()),
|
|
80
|
+
children: values => /*#__PURE__*/jsx(RangeCalendarYearPickerStateBridge, {
|
|
81
|
+
children: typeof children === "function" ? children(values) : children
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
RangeCalendarRoot.displayName = "MasaraxUI.RangeCalendar";
|
|
88
|
+
|
|
89
|
+
/* -------------------------------------------------------------------------------------------------
|
|
90
|
+
| * RangeCalendar Header
|
|
91
|
+
| * -----------------------------------------------------------------------------------------------*/
|
|
92
|
+
|
|
93
|
+
const RangeCalendarHeader = ({
|
|
94
|
+
children,
|
|
95
|
+
className,
|
|
96
|
+
...props
|
|
97
|
+
}) => {
|
|
98
|
+
const {
|
|
99
|
+
slots
|
|
100
|
+
} = useContext(RangeCalendarContext);
|
|
101
|
+
return /*#__PURE__*/jsx("header", {
|
|
102
|
+
className: composeSlotClassName(slots?.header, className),
|
|
103
|
+
"data-slot": "range-calendar-header",
|
|
104
|
+
...props,
|
|
105
|
+
children: children
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
RangeCalendarHeader.displayName = "MasaraxUI.RangeCalendar.Header";
|
|
109
|
+
|
|
110
|
+
/* -------------------------------------------------------------------------------------------------
|
|
111
|
+
| * RangeCalendar Heading
|
|
112
|
+
| * -----------------------------------------------------------------------------------------------*/
|
|
113
|
+
|
|
114
|
+
const RangeCalendarHeading = ({
|
|
115
|
+
className,
|
|
116
|
+
...props
|
|
117
|
+
}) => {
|
|
118
|
+
const {
|
|
119
|
+
slots
|
|
120
|
+
} = useContext(RangeCalendarContext);
|
|
121
|
+
return /*#__PURE__*/jsx(Heading, {
|
|
122
|
+
"data-slot": "range-calendar-heading",
|
|
123
|
+
...props,
|
|
124
|
+
className: composeSlotClassName(slots?.heading, className)
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
RangeCalendarHeading.displayName = "MasaraxUI.RangeCalendar.Heading";
|
|
128
|
+
|
|
129
|
+
/* -------------------------------------------------------------------------------------------------
|
|
130
|
+
| * RangeCalendar Nav Button
|
|
131
|
+
| * -----------------------------------------------------------------------------------------------*/
|
|
132
|
+
|
|
133
|
+
const RangeCalendarNavButton = ({
|
|
134
|
+
children,
|
|
135
|
+
className,
|
|
136
|
+
slot,
|
|
137
|
+
...props
|
|
138
|
+
}) => {
|
|
139
|
+
const {
|
|
140
|
+
slots
|
|
141
|
+
} = useContext(RangeCalendarContext);
|
|
142
|
+
return /*#__PURE__*/jsx(Button, {
|
|
143
|
+
"data-slot": "range-calendar-nav-button",
|
|
144
|
+
slot: slot,
|
|
145
|
+
...props,
|
|
146
|
+
className: composeTwRenderProps(className, slots?.navButton()),
|
|
147
|
+
children: children || (slot === "previous" ? /*#__PURE__*/jsx(IconChevronLeft, {
|
|
148
|
+
className: slots?.navButtonIcon(),
|
|
149
|
+
"data-slot": "range-calendar-nav-button-icon"
|
|
150
|
+
}) : /*#__PURE__*/jsx(IconChevronRight, {
|
|
151
|
+
className: slots?.navButtonIcon(),
|
|
152
|
+
"data-slot": "range-calendar-nav-button-icon"
|
|
153
|
+
}))
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
RangeCalendarNavButton.displayName = "MasaraxUI.RangeCalendar.NavButton";
|
|
157
|
+
|
|
158
|
+
/* -------------------------------------------------------------------------------------------------
|
|
159
|
+
| * RangeCalendar Grid
|
|
160
|
+
| * -----------------------------------------------------------------------------------------------*/
|
|
161
|
+
|
|
162
|
+
const RangeCalendarGrid = ({
|
|
163
|
+
children,
|
|
164
|
+
className,
|
|
165
|
+
weekdayStyle = "short",
|
|
166
|
+
...props
|
|
167
|
+
}) => {
|
|
168
|
+
const {
|
|
169
|
+
slots
|
|
170
|
+
} = useContext(RangeCalendarContext);
|
|
171
|
+
return /*#__PURE__*/jsx(CalendarGrid, {
|
|
172
|
+
"data-slot": "range-calendar-grid",
|
|
173
|
+
weekdayStyle: weekdayStyle,
|
|
174
|
+
...props,
|
|
175
|
+
className: composeSlotClassName(slots?.grid, className),
|
|
176
|
+
children: children
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
RangeCalendarGrid.displayName = "MasaraxUI.RangeCalendar.Grid";
|
|
180
|
+
|
|
181
|
+
/* -------------------------------------------------------------------------------------------------
|
|
182
|
+
| * RangeCalendar Grid Header
|
|
183
|
+
| * -----------------------------------------------------------------------------------------------*/
|
|
184
|
+
|
|
185
|
+
const RangeCalendarGridHeader = ({
|
|
186
|
+
className,
|
|
187
|
+
...props
|
|
188
|
+
}) => {
|
|
189
|
+
const {
|
|
190
|
+
slots
|
|
191
|
+
} = useContext(RangeCalendarContext);
|
|
192
|
+
return /*#__PURE__*/jsx(CalendarGridHeader, {
|
|
193
|
+
"data-slot": "range-calendar-grid-header",
|
|
194
|
+
...props,
|
|
195
|
+
className: composeSlotClassName(slots?.gridHeader, className)
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
RangeCalendarGridHeader.displayName = "MasaraxUI.RangeCalendar.GridHeader";
|
|
199
|
+
|
|
200
|
+
/* -------------------------------------------------------------------------------------------------
|
|
201
|
+
| * RangeCalendar Grid Body
|
|
202
|
+
| * -----------------------------------------------------------------------------------------------*/
|
|
203
|
+
|
|
204
|
+
const RangeCalendarGridBody = ({
|
|
205
|
+
className,
|
|
206
|
+
...props
|
|
207
|
+
}) => {
|
|
208
|
+
const {
|
|
209
|
+
slots
|
|
210
|
+
} = useContext(RangeCalendarContext);
|
|
211
|
+
return /*#__PURE__*/jsx(CalendarGridBody, {
|
|
212
|
+
"data-slot": "range-calendar-grid-body",
|
|
213
|
+
...props,
|
|
214
|
+
className: composeSlotClassName(slots?.gridBody, className)
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
RangeCalendarGridBody.displayName = "MasaraxUI.RangeCalendar.GridBody";
|
|
218
|
+
|
|
219
|
+
/* -------------------------------------------------------------------------------------------------
|
|
220
|
+
| * RangeCalendar Header Cell
|
|
221
|
+
| * -----------------------------------------------------------------------------------------------*/
|
|
222
|
+
|
|
223
|
+
const RangeCalendarHeaderCell = ({
|
|
224
|
+
className,
|
|
225
|
+
...props
|
|
226
|
+
}) => {
|
|
227
|
+
const {
|
|
228
|
+
slots
|
|
229
|
+
} = useContext(RangeCalendarContext);
|
|
230
|
+
return /*#__PURE__*/jsx(CalendarHeaderCell, {
|
|
231
|
+
"data-slot": "range-calendar-header-cell",
|
|
232
|
+
...props,
|
|
233
|
+
className: composeSlotClassName(slots?.headerCell, className)
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
RangeCalendarHeaderCell.displayName = "MasaraxUI.RangeCalendar.HeaderCell";
|
|
237
|
+
|
|
238
|
+
/* -------------------------------------------------------------------------------------------------
|
|
239
|
+
| * RangeCalendar Cell
|
|
240
|
+
| * -----------------------------------------------------------------------------------------------*/
|
|
241
|
+
|
|
242
|
+
const RangeCalendarCell = ({
|
|
243
|
+
children,
|
|
244
|
+
className,
|
|
245
|
+
...props
|
|
246
|
+
}) => {
|
|
247
|
+
const {
|
|
248
|
+
slots
|
|
249
|
+
} = useContext(RangeCalendarContext);
|
|
250
|
+
return /*#__PURE__*/jsx(CalendarCell, {
|
|
251
|
+
"data-slot": "range-calendar-cell",
|
|
252
|
+
...props,
|
|
253
|
+
className: composeTwRenderProps(className, slots?.cell()),
|
|
254
|
+
children: values => {
|
|
255
|
+
const {
|
|
256
|
+
formattedDate,
|
|
257
|
+
isDisabled,
|
|
258
|
+
isHovered,
|
|
259
|
+
isPressed,
|
|
260
|
+
isSelectionEnd,
|
|
261
|
+
isSelectionStart
|
|
262
|
+
} = values;
|
|
263
|
+
const content = typeof children === "function" ? children(values) : children || formattedDate;
|
|
264
|
+
return /*#__PURE__*/jsx("span", {
|
|
265
|
+
className: "range-calendar__cell-button",
|
|
266
|
+
"data-disabled": dataAttr(isDisabled),
|
|
267
|
+
"data-hovered": dataAttr(isHovered),
|
|
268
|
+
"data-pressed": dataAttr(isPressed),
|
|
269
|
+
"data-selected": dataAttr(isSelectionStart || isSelectionEnd),
|
|
270
|
+
"data-slot": "range-calendar-cell-button",
|
|
271
|
+
children: content
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
RangeCalendarCell.displayName = "MasaraxUI.RangeCalendar.Cell";
|
|
277
|
+
|
|
278
|
+
/* -------------------------------------------------------------------------------------------------
|
|
279
|
+
| * RangeCalendar Cell Indicator
|
|
280
|
+
| * -----------------------------------------------------------------------------------------------*/
|
|
281
|
+
|
|
282
|
+
const RangeCalendarCellIndicator = ({
|
|
283
|
+
className,
|
|
284
|
+
...props
|
|
285
|
+
}) => {
|
|
286
|
+
const {
|
|
287
|
+
slots
|
|
288
|
+
} = useContext(RangeCalendarContext);
|
|
289
|
+
return /*#__PURE__*/jsx("span", {
|
|
290
|
+
"aria-hidden": "true",
|
|
291
|
+
className: composeSlotClassName(slots?.cellIndicator, className),
|
|
292
|
+
"data-slot": "range-calendar-cell-indicator",
|
|
293
|
+
...props
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
RangeCalendarCellIndicator.displayName = "MasaraxUI.RangeCalendar.CellIndicator";
|
|
297
|
+
|
|
298
|
+
export { RangeCalendarCell, RangeCalendarCellIndicator, RangeCalendarGrid, RangeCalendarGridBody, RangeCalendarGridHeader, RangeCalendarHeader, RangeCalendarHeaderCell, RangeCalendarHeading, RangeCalendarNavButton, RangeCalendarRoot };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { ScrollShadowRoot } from "./scroll-shadow";
|
|
3
|
+
export declare const ScrollShadow: {
|
|
4
|
+
({ children, className, hideScrollBar, isEnabled, offset, onVisibilityChange, orientation, ref, size, variant, visibility, ...props }: import("./scroll-shadow").ScrollShadowRootProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
displayName: string;
|
|
6
|
+
} & {
|
|
7
|
+
Root: {
|
|
8
|
+
({ children, className, hideScrollBar, isEnabled, offset, onVisibilityChange, orientation, ref, size, variant, visibility, ...props }: import("./scroll-shadow").ScrollShadowRootProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export type ScrollShadow = {
|
|
13
|
+
Props: ComponentProps<typeof ScrollShadowRoot>;
|
|
14
|
+
RootProps: ComponentProps<typeof ScrollShadowRoot>;
|
|
15
|
+
};
|
|
16
|
+
export { ScrollShadowRoot };
|
|
17
|
+
export type { ScrollShadowRootProps, ScrollShadowRootProps as ScrollShadowProps, ScrollShadowVisibility, } from "./scroll-shadow";
|
|
18
|
+
export { scrollShadowVariants } from "@masaraxui/styles";
|
|
19
|
+
export type { ScrollShadowVariants } from "@masaraxui/styles";
|
|
20
|
+
export { useScrollShadow } from "./use-scroll-shadow";
|
|
21
|
+
export type { UseScrollShadowProps } from "./use-scroll-shadow";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { ScrollShadowRoot } from './scroll-shadow.js';
|
|
3
|
+
export { scrollShadowVariants } from '@masaraxui/styles';
|
|
4
|
+
export { useScrollShadow } from './use-scroll-shadow.js';
|
|
5
|
+
|
|
6
|
+
/* -------------------------------------------------------------------------------------------------
|
|
7
|
+
* Component
|
|
8
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
9
|
+
const ScrollShadow = Object.assign(ScrollShadowRoot, {
|
|
10
|
+
Root: ScrollShadowRoot
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { ScrollShadow, ScrollShadowRoot };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ScrollShadowVariants } from "@masaraxui/styles";
|
|
2
|
+
export type ScrollShadowVisibility = "auto" | "both" | "top" | "bottom" | "left" | "right" | "none";
|
|
3
|
+
export interface ScrollShadowRootProps extends Omit<React.ComponentProps<"div">, "size">, ScrollShadowVariants {
|
|
4
|
+
/**
|
|
5
|
+
* The shadow size in pixels
|
|
6
|
+
* @default 40
|
|
7
|
+
*/
|
|
8
|
+
size?: number;
|
|
9
|
+
/**
|
|
10
|
+
* The scroll offset before showing shadows (in pixels)
|
|
11
|
+
* @default 0
|
|
12
|
+
*/
|
|
13
|
+
offset?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Controlled shadow visibility state
|
|
16
|
+
* @default "auto"
|
|
17
|
+
*/
|
|
18
|
+
visibility?: ScrollShadowVisibility;
|
|
19
|
+
/**
|
|
20
|
+
* Whether scroll shadow detection is enabled
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
isEnabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Callback invoked when shadow visibility changes
|
|
26
|
+
*/
|
|
27
|
+
onVisibilityChange?: (visibility: ScrollShadowVisibility) => void;
|
|
28
|
+
}
|
|
29
|
+
export declare const ScrollShadowRoot: {
|
|
30
|
+
({ children, className, hideScrollBar, isEnabled, offset, onVisibilityChange, orientation, ref, size, variant, visibility, ...props }: ScrollShadowRootProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
displayName: string;
|
|
32
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { scrollShadowVariants } from '@masaraxui/styles';
|
|
3
|
+
import { mergeRefs } from '@react-aria/utils';
|
|
4
|
+
import { useRef, useMemo } from 'react';
|
|
5
|
+
import { useSafeLayoutEffect } from '../../hooks/use-safe-layout-effect.js';
|
|
6
|
+
import { useScrollShadow } from './use-scroll-shadow.js';
|
|
7
|
+
import { jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
const ScrollShadowRoot = ({
|
|
10
|
+
children,
|
|
11
|
+
className,
|
|
12
|
+
hideScrollBar = false,
|
|
13
|
+
isEnabled = true,
|
|
14
|
+
offset = 0,
|
|
15
|
+
onVisibilityChange,
|
|
16
|
+
orientation = "vertical",
|
|
17
|
+
ref,
|
|
18
|
+
size = 40,
|
|
19
|
+
variant = "fade",
|
|
20
|
+
visibility = "auto",
|
|
21
|
+
...props
|
|
22
|
+
}) => {
|
|
23
|
+
const internalRef = useRef(null);
|
|
24
|
+
useScrollShadow({
|
|
25
|
+
containerRef: internalRef,
|
|
26
|
+
isEnabled,
|
|
27
|
+
offset,
|
|
28
|
+
onVisibilityChange,
|
|
29
|
+
orientation,
|
|
30
|
+
visibility
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Handle controlled visibility mode
|
|
34
|
+
useSafeLayoutEffect(() => {
|
|
35
|
+
const el = internalRef.current;
|
|
36
|
+
if (!el || visibility === "auto") return;
|
|
37
|
+
|
|
38
|
+
// Clear all data attributes
|
|
39
|
+
delete el.dataset["topScroll"];
|
|
40
|
+
delete el.dataset["bottomScroll"];
|
|
41
|
+
delete el.dataset["topBottomScroll"];
|
|
42
|
+
delete el.dataset["leftScroll"];
|
|
43
|
+
delete el.dataset["rightScroll"];
|
|
44
|
+
delete el.dataset["leftRightScroll"];
|
|
45
|
+
|
|
46
|
+
// Set controlled visibility
|
|
47
|
+
if (visibility === "both") {
|
|
48
|
+
el.dataset[orientation === "vertical" ? "topBottomScroll" : "leftRightScroll"] = "true";
|
|
49
|
+
} else if (visibility !== "none") {
|
|
50
|
+
el.dataset[`${visibility}Scroll`] = "true";
|
|
51
|
+
}
|
|
52
|
+
}, [visibility, orientation]);
|
|
53
|
+
const slots = useMemo(() => scrollShadowVariants({
|
|
54
|
+
hideScrollBar,
|
|
55
|
+
orientation,
|
|
56
|
+
variant
|
|
57
|
+
}), [orientation, hideScrollBar, variant]);
|
|
58
|
+
return /*#__PURE__*/jsx("div", {
|
|
59
|
+
ref: mergeRefs(internalRef, ref),
|
|
60
|
+
className: slots.base({
|
|
61
|
+
className
|
|
62
|
+
}),
|
|
63
|
+
"data-orientation": orientation,
|
|
64
|
+
"data-scroll-shadow-size": size,
|
|
65
|
+
style: {
|
|
66
|
+
// @ts-expect-error - CSS variables are not typed
|
|
67
|
+
"--scroll-shadow-size": `${size}px`,
|
|
68
|
+
...props.style
|
|
69
|
+
},
|
|
70
|
+
...props,
|
|
71
|
+
children: children
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
ScrollShadowRoot.displayName = "MasaraxUI.ScrollShadow";
|
|
75
|
+
|
|
76
|
+
export { ScrollShadowRoot };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ScrollShadowVisibility } from "./scroll-shadow";
|
|
2
|
+
import type { RefObject } from "react";
|
|
3
|
+
export interface UseScrollShadowProps {
|
|
4
|
+
containerRef: RefObject<HTMLElement>;
|
|
5
|
+
orientation: "vertical" | "horizontal";
|
|
6
|
+
offset: number;
|
|
7
|
+
visibility: ScrollShadowVisibility;
|
|
8
|
+
isEnabled: boolean;
|
|
9
|
+
onVisibilityChange?: (visibility: ScrollShadowVisibility) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const useScrollShadow: (props: UseScrollShadowProps) => void;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { useRef, useCallback, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
const useScrollShadow = props => {
|
|
5
|
+
const {
|
|
6
|
+
containerRef,
|
|
7
|
+
isEnabled,
|
|
8
|
+
offset,
|
|
9
|
+
onVisibilityChange,
|
|
10
|
+
orientation,
|
|
11
|
+
visibility
|
|
12
|
+
} = props;
|
|
13
|
+
|
|
14
|
+
// Cache previous state to avoid unnecessary DOM updates
|
|
15
|
+
const prevStateRef = useRef(null);
|
|
16
|
+
|
|
17
|
+
// Track pending RAF to avoid multiple scheduled updates
|
|
18
|
+
const rafIdRef = useRef(null);
|
|
19
|
+
const checkOverflow = useCallback(() => {
|
|
20
|
+
const el = containerRef.current;
|
|
21
|
+
if (!el) return;
|
|
22
|
+
const isVertical = orientation === "vertical";
|
|
23
|
+
const scrollStart = isVertical ? el.scrollTop : el.scrollLeft;
|
|
24
|
+
const scrollSize = isVertical ? el.scrollHeight : el.scrollWidth;
|
|
25
|
+
const clientSize = isVertical ? el.clientHeight : el.clientWidth;
|
|
26
|
+
const hasScrollBefore = scrollStart > offset;
|
|
27
|
+
const hasScrollAfter = scrollStart + clientSize + offset < scrollSize;
|
|
28
|
+
|
|
29
|
+
// Skip DOM updates if state hasn't changed
|
|
30
|
+
const prevState = prevStateRef.current;
|
|
31
|
+
if (prevState && prevState.hasScrollBefore === hasScrollBefore && prevState.hasScrollAfter === hasScrollAfter) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Update state cache
|
|
36
|
+
prevStateRef.current = {
|
|
37
|
+
hasScrollBefore,
|
|
38
|
+
hasScrollAfter
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Cancel previous pending update
|
|
42
|
+
if (rafIdRef.current !== null) {
|
|
43
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Batch DOM updates with RAF for better performance
|
|
47
|
+
rafIdRef.current = requestAnimationFrame(() => {
|
|
48
|
+
rafIdRef.current = null;
|
|
49
|
+
if (isVertical) {
|
|
50
|
+
if (hasScrollBefore && hasScrollAfter) {
|
|
51
|
+
el.dataset["topBottomScroll"] = "true";
|
|
52
|
+
delete el.dataset["topScroll"];
|
|
53
|
+
delete el.dataset["bottomScroll"];
|
|
54
|
+
onVisibilityChange?.("both");
|
|
55
|
+
} else {
|
|
56
|
+
el.dataset["topScroll"] = String(hasScrollBefore);
|
|
57
|
+
el.dataset["bottomScroll"] = String(hasScrollAfter);
|
|
58
|
+
delete el.dataset["topBottomScroll"];
|
|
59
|
+
if (onVisibilityChange) {
|
|
60
|
+
if (hasScrollBefore) {
|
|
61
|
+
onVisibilityChange("top");
|
|
62
|
+
} else if (hasScrollAfter) {
|
|
63
|
+
onVisibilityChange("bottom");
|
|
64
|
+
} else {
|
|
65
|
+
onVisibilityChange("none");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
if (hasScrollBefore && hasScrollAfter) {
|
|
71
|
+
el.dataset["leftRightScroll"] = "true";
|
|
72
|
+
delete el.dataset["leftScroll"];
|
|
73
|
+
delete el.dataset["rightScroll"];
|
|
74
|
+
onVisibilityChange?.("both");
|
|
75
|
+
} else {
|
|
76
|
+
el.dataset["leftScroll"] = String(hasScrollBefore);
|
|
77
|
+
el.dataset["rightScroll"] = String(hasScrollAfter);
|
|
78
|
+
delete el.dataset["leftRightScroll"];
|
|
79
|
+
if (onVisibilityChange) {
|
|
80
|
+
if (hasScrollBefore) {
|
|
81
|
+
onVisibilityChange("left");
|
|
82
|
+
} else if (hasScrollAfter) {
|
|
83
|
+
onVisibilityChange("right");
|
|
84
|
+
} else {
|
|
85
|
+
onVisibilityChange("none");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}, [containerRef, orientation, offset, onVisibilityChange]);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
const el = containerRef.current;
|
|
94
|
+
if (!el || !isEnabled || visibility !== "auto") return;
|
|
95
|
+
|
|
96
|
+
// Initial check
|
|
97
|
+
checkOverflow();
|
|
98
|
+
|
|
99
|
+
// Use passive listener for better scroll performance
|
|
100
|
+
el.addEventListener("scroll", checkOverflow, {
|
|
101
|
+
passive: true
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Monitor size changes
|
|
105
|
+
const resizeObserver = new ResizeObserver(checkOverflow);
|
|
106
|
+
resizeObserver.observe(el);
|
|
107
|
+
return () => {
|
|
108
|
+
el.removeEventListener("scroll", checkOverflow);
|
|
109
|
+
resizeObserver.disconnect();
|
|
110
|
+
|
|
111
|
+
// Cancel pending RAF and cleanup cache
|
|
112
|
+
if (rafIdRef.current !== null) {
|
|
113
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
114
|
+
rafIdRef.current = null;
|
|
115
|
+
}
|
|
116
|
+
prevStateRef.current = null;
|
|
117
|
+
};
|
|
118
|
+
}, [containerRef, visibility, isEnabled, checkOverflow]);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export { useScrollShadow };
|