@shohojdhara/atomix 0.1.16 → 0.1.18
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/CONTRIBUTING.md +151 -0
- package/NEXTJS_INTEGRATION.md +358 -0
- package/README.md +168 -119
- package/babel.config.js +58 -0
- package/css.d.ts +10 -0
- package/dist/css/atomix.css +1 -2
- package/dist/js/194.js +1 -2
- package/dist/js/244.js +1 -0
- package/dist/js/atomix.react.cjs.js +1 -0
- package/dist/js/atomix.react.esm.js +1 -2
- package/dist/js/atomix.react.umd.js +1 -2
- package/dist/js/chunks/cjs/202.9d3b1ef1eaa0d5c8a309.js +1 -0
- package/dist/js/chunks/cjs/308.6ea9685ea38ead4120d0.js +1 -0
- package/dist/js/chunks/cjs/54.73db6922594e421ba6b1.js +1 -0
- package/dist/js/chunks/cjs/619.51feecaadcab819780d4.js +1 -0
- package/dist/js/chunks/cjs/690.90f6d11164081cbcbc4d.js +1 -0
- package/dist/js/chunks/cjs/894.24877561df336a8dfd14.js +1 -0
- package/dist/js/chunks/cjs/897.6c2a71fae95338890de7.js +1 -0
- package/dist/js/chunks/esm/{202.ff48d27672233280e021.js → 202.82aa7b3244e53c9edb72.js} +1 -2
- package/dist/js/chunks/esm/{308.f873332126eba90e5c62.js → 308.27e1e4005705ae320432.js} +1 -2
- package/dist/js/chunks/esm/{54.4db919e5e4e5cc6d7c72.js → 54.ece1fd6964f98d4d994f.js} +1 -2
- package/dist/js/chunks/esm/{619.afc5a718eff77fa423b5.js → 619.ebeb0298432a066ac05c.js} +1 -2
- package/dist/js/chunks/esm/{690.a9e968c7497d61e56cdc.js → 690.c5f412cc979b55740359.js} +1 -2
- package/dist/js/chunks/esm/{894.f1091a4a8758c26d29e4.js → 894.3604ddc9367d75191198.js} +1 -2
- package/dist/js/chunks/esm/{897.561a50f7d043d42169da.js → 897.a4aab2fad9401693eb12.js} +1 -2
- package/dist/js/chunks/umd/{202.dac7605cc555b6bda542.js → 202.5017dd0403d696bf1644.js} +1 -2
- package/dist/js/chunks/umd/{308.6709979849dcbdb90c9b.js → 308.4bc14b9d7b16b6ee0ab8.js} +1 -2
- package/dist/js/chunks/umd/{54.403470e1f7d0ef4424a7.js → 54.7fdfb4a031989470a70d.js} +1 -2
- package/dist/js/chunks/umd/{619.fa05ea98c10270eb64c5.js → 619.84a0c35ecee695250085.js} +1 -2
- package/dist/js/chunks/umd/{690.aa7054d1c53e5402c2d6.js → 690.d7041094a34a4a434be2.js} +1 -2
- package/dist/js/chunks/umd/{894.3e1eaf0a2aadf4434390.js → 894.c127ee4e9513c22ee97d.js} +1 -2
- package/dist/js/chunks/umd/{897.554ea37be4453698c167.js → 897.26932ac837a39fc91907.js} +1 -2
- package/dist/types/components/Badge/index.d.ts +3 -3
- package/dist/types/components/{Navbar → Navigation/Menu}/MegaMenu.d.ts +1 -1
- package/dist/types/components/{Navbar → Navigation/Menu}/Menu.d.ts +1 -1
- package/dist/types/components/Navigation/Nav/Nav.d.ts +20 -0
- package/dist/types/components/{Navbar → Navigation/Nav}/NavDropdown.d.ts +1 -1
- package/dist/types/components/Navigation/Nav/NavItem.d.ts +33 -0
- package/dist/types/components/Navigation/Navbar/Navbar.d.ts +19 -0
- package/dist/types/components/Navigation/SideMenu/SideMenu.d.ts +20 -0
- package/dist/types/components/Navigation/SideMenu/SideMenuItem.d.ts +30 -0
- package/dist/types/components/Navigation/SideMenu/SideMenuList.d.ts +17 -0
- package/dist/types/components/Navigation/index.d.ts +10 -0
- package/dist/types/components/PhotoViewer/PhotoViewer.d.ts +2 -2
- package/dist/types/components/PhotoViewer/PhotoViewerHeader.d.ts +2 -2
- package/dist/types/components/Tab/index.d.ts +2 -2
- package/dist/types/components/Toggle/index.d.ts +2 -2
- package/dist/types/components/Tooltip/index.d.ts +3 -3
- package/dist/types/components/index.d.ts +1 -1
- package/dist/types/lib/composables/index.d.ts +1 -0
- package/dist/types/lib/composables/useDatePicker.d.ts +1 -1
- package/dist/types/lib/composables/useDropdown.d.ts +1 -1
- package/dist/types/lib/composables/useModal.d.ts +1 -1
- package/dist/types/lib/composables/usePhotoViewer.d.ts +1 -1
- package/dist/types/lib/composables/useRating.d.ts +1 -1
- package/dist/types/lib/composables/useSideMenu.d.ts +28 -0
- package/dist/types/lib/constants/components.d.ts +72 -0
- package/dist/types/lib/types/components.d.ts +103 -0
- package/examples/nextjs-example.tsx +271 -0
- package/implementation-guide.md +505 -0
- package/next.config.js +69 -0
- package/package.json +80 -42
- package/postcss.config.js +28 -0
- package/src/Introduction.mdx +3 -5
- package/src/assets/fonts/HelveticaNeue/stylesheet.css +140 -127
- package/src/components/Accordion/Accordion.stories.tsx +58 -45
- package/src/components/Accordion/Accordion.tsx +14 -4
- package/src/components/Accordion/scripts/accordionInteractions.ts +9 -9
- package/src/components/Accordion/scripts/bundle.ts +1 -1
- package/src/components/Accordion/scripts/index.ts +3 -3
- package/src/components/AtomixLogo.tsx +13 -19
- package/src/components/Avatar/Avatar.stories.tsx +24 -21
- package/src/components/Avatar/Avatar.tsx +5 -8
- package/src/components/Avatar/AvatarGroup.tsx +11 -11
- package/src/components/Avatar/index.ts +1 -1
- package/src/components/Avatar/scripts/index.ts +66 -71
- package/src/components/Badge/Badge.stories.tsx +51 -21
- package/src/components/Badge/Badge.tsx +14 -12
- package/src/components/Badge/index.ts +3 -3
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +40 -40
- package/src/components/Breadcrumb/Breadcrumb.tsx +19 -26
- package/src/components/Breadcrumb/index.ts +1 -1
- package/src/components/Breadcrumb/scripts/breadcrumb.ts +36 -34
- package/src/components/Breadcrumb/scripts/index.ts +1 -1
- package/src/components/Breadcrumb/scripts/types.ts +9 -9
- package/src/components/Button/Button.stories.tsx +36 -12
- package/src/components/Button/Button.tsx +52 -39
- package/src/components/Button/index.ts +1 -1
- package/src/components/Button/scripts/buttonInteractions.ts +9 -9
- package/src/components/Button/scripts/index.ts +1 -1
- package/src/components/Callout/Callout.stories.tsx +207 -114
- package/src/components/Callout/Callout.tsx +12 -12
- package/src/components/Callout/index.ts +1 -1
- package/src/components/Callout/scripts/CalloutInteractions.ts +58 -48
- package/src/components/Callout/scripts/bundle.ts +2 -2
- package/src/components/Callout/scripts/index.ts +19 -15
- package/src/components/Card/Card.stories.tsx +2 -2
- package/src/components/Card/Card.tsx +49 -72
- package/src/components/Card/ElevationCard.tsx +4 -8
- package/src/components/Card/index.ts +1 -1
- package/src/components/Card/scripts/bundle.ts +7 -7
- package/src/components/Card/scripts/cardInteractions.ts +24 -24
- package/src/components/Card/scripts/index.ts +25 -26
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +6 -3
- package/src/components/ColorModeToggle/ColorModeToggle.tsx +12 -15
- package/src/components/ColorModeToggle/index.ts +1 -1
- package/src/components/Countdown/Countdown.stories.tsx +6 -2
- package/src/components/Countdown/Countdown.tsx +56 -48
- package/src/components/Countdown/index.ts +1 -1
- package/src/components/Countdown/scripts/index.ts +33 -28
- package/src/components/DataTable/DataTable.stories.tsx +23 -18
- package/src/components/DataTable/DataTable.tsx +39 -39
- package/src/components/DataTable/index.ts +1 -1
- package/src/components/DataTable/scripts/bundle.ts +8 -3
- package/src/components/DataTable/scripts/index.ts +182 -164
- package/src/components/DatePicker/DatePicker.stories.tsx +136 -148
- package/src/components/DatePicker/DatePicker.tsx +461 -420
- package/src/components/DatePicker/scripts/bundle.ts +12 -7
- package/src/components/DatePicker/scripts/componentInteractions.ts +76 -46
- package/src/components/DatePicker/scripts/index.ts +176 -156
- package/src/components/DatePicker/types.ts +32 -32
- package/src/components/DatePicker/utils.ts +41 -30
- package/src/components/Dropdown/Dropdown.stories.tsx +85 -55
- package/src/components/Dropdown/Dropdown.tsx +97 -88
- package/src/components/Dropdown/index.ts +5 -10
- package/src/components/Dropdown/scripts/bundle.ts +10 -10
- package/src/components/Dropdown/scripts/componentInteractions.ts +10 -2
- package/src/components/Dropdown/scripts/index.ts +122 -117
- package/src/components/EdgePanel/EdgePanel.stories.tsx +142 -58
- package/src/components/EdgePanel/EdgePanel.tsx +7 -13
- package/src/components/EdgePanel/index.ts +1 -1
- package/src/components/EdgePanel/scripts/bundle.ts +5 -5
- package/src/components/EdgePanel/scripts/edgePanelInteractions.ts +26 -26
- package/src/components/EdgePanel/scripts/index.ts +53 -53
- package/src/components/Form/Checkbox.stories.tsx +2 -2
- package/src/components/Form/Checkbox.tsx +13 -7
- package/src/components/Form/Form.stories.tsx +144 -218
- package/src/components/Form/Form.tsx +6 -6
- package/src/components/Form/FormGroup.stories.tsx +21 -38
- package/src/components/Form/FormGroup.tsx +18 -20
- package/src/components/Form/Input.stories.tsx +1 -1
- package/src/components/Form/Input.tsx +18 -8
- package/src/components/Form/Radio.stories.tsx +12 -25
- package/src/components/Form/Radio.tsx +11 -6
- package/src/components/Form/Select.stories.tsx +6 -6
- package/src/components/Form/Select.tsx +31 -33
- package/src/components/Form/Textarea.stories.tsx +7 -2
- package/src/components/Form/Textarea.tsx +17 -8
- package/src/components/Form/index.ts +1 -1
- package/src/components/Hero/Hero.stories.tsx +44 -42
- package/src/components/Hero/Hero.tsx +28 -38
- package/src/components/Hero/index.ts +1 -1
- package/src/components/Hero/scripts/bundle.ts +6 -6
- package/src/components/Hero/scripts/heroInteractions.ts +24 -29
- package/src/components/Hero/scripts/index.ts +16 -17
- package/src/components/Icon/Icon.tsx +16 -18
- package/src/components/Icon/index.ts +1 -1
- package/src/components/List/List.stories.tsx +1 -3
- package/src/components/List/List.tsx +6 -10
- package/src/components/List/ListGroup.tsx +1 -1
- package/src/components/List/index.ts +1 -1
- package/src/components/Messages/Messages.stories.tsx +30 -29
- package/src/components/Messages/Messages.tsx +60 -55
- package/src/components/Messages/index.ts +1 -1
- package/src/components/Messages/scripts/bundle.ts +1 -6
- package/src/components/Messages/scripts/componentInteractions.ts +32 -37
- package/src/components/Messages/scripts/index.ts +61 -55
- package/src/components/Modal/Modal.stories.tsx +77 -53
- package/src/components/Modal/Modal.tsx +63 -62
- package/src/components/Modal/index.ts +1 -1
- package/src/components/Modal/scripts/bundle.ts +3 -3
- package/src/components/Modal/scripts/index.ts +96 -84
- package/src/components/Modal/scripts/modalInteractions.ts +16 -14
- package/src/components/{Navbar → Navigation/Menu}/MegaMenu.tsx +50 -59
- package/src/components/Navigation/Menu/Menu.stories.tsx +340 -0
- package/src/components/Navigation/Menu/Menu.tsx +110 -0
- package/src/components/Navigation/Nav/Nav.stories.tsx +458 -0
- package/src/components/Navigation/Nav/Nav.tsx +50 -0
- package/src/components/Navigation/Nav/NavDropdown.tsx +105 -0
- package/src/components/Navigation/Nav/NavItem.tsx +159 -0
- package/src/components/{Navbar → Navigation/Navbar}/Navbar.stories.tsx +198 -104
- package/src/components/Navigation/Navbar/Navbar.tsx +150 -0
- package/src/components/Navigation/README.md +314 -0
- package/src/components/Navigation/SideMenu/SideMenu.README.md +494 -0
- package/src/components/Navigation/SideMenu/SideMenu.stories.tsx +618 -0
- package/src/components/Navigation/SideMenu/SideMenu.tsx +101 -0
- package/src/components/Navigation/SideMenu/SideMenuItem.tsx +95 -0
- package/src/components/Navigation/SideMenu/SideMenuList.tsx +41 -0
- package/src/components/Navigation/index.ts +23 -0
- package/src/components/Navigation/scripts/NavbarInteractions.ts +171 -0
- package/src/components/Navigation/scripts/SideMenu.ts +319 -0
- package/src/components/Navigation/scripts/SideMenuBundle.ts +69 -0
- package/src/components/Navigation/scripts/SideMenuInteractions.ts +250 -0
- package/src/components/Navigation/scripts/bundle.ts +58 -0
- package/src/components/Navigation/scripts/index.ts +248 -0
- package/src/components/Pagination/Pagination.stories.tsx +34 -33
- package/src/components/Pagination/Pagination.tsx +25 -35
- package/src/components/Pagination/index.ts +1 -1
- package/src/components/Pagination/scripts/index.ts +42 -37
- package/src/components/PhotoViewer/PhotoViewer.stories.tsx +48 -48
- package/src/components/PhotoViewer/PhotoViewer.tsx +29 -46
- package/src/components/PhotoViewer/PhotoViewerHeader.tsx +20 -26
- package/src/components/PhotoViewer/PhotoViewerImage.tsx +19 -17
- package/src/components/PhotoViewer/PhotoViewerInfo.tsx +13 -5
- package/src/components/PhotoViewer/PhotoViewerNavigation.tsx +5 -5
- package/src/components/PhotoViewer/PhotoViewerThumbnails.tsx +31 -30
- package/src/components/PhotoViewer/examples/ImageGallery.tsx +27 -37
- package/src/components/PhotoViewer/examples/SimpleGallery.tsx +19 -13
- package/src/components/PhotoViewer/examples/index.ts +1 -1
- package/src/components/PhotoViewer/index.ts +1 -1
- package/src/components/PhotoViewer/scripts/PhotoViewerInteractions.ts +43 -33
- package/src/components/PhotoViewer/scripts/bundle.ts +14 -14
- package/src/components/PhotoViewer/scripts/index.ts +173 -129
- package/src/components/Popover/Popover.stories.tsx +11 -12
- package/src/components/Popover/Popover.tsx +36 -36
- package/src/components/Popover/index.ts +1 -1
- package/src/components/Popover/scripts/bundle.ts +1 -1
- package/src/components/Popover/scripts/componentInteractions.ts +34 -46
- package/src/components/Popover/scripts/index.ts +64 -53
- package/src/components/ProductReview/ProductReview.stories.tsx +10 -8
- package/src/components/ProductReview/ProductReview.tsx +28 -32
- package/src/components/ProductReview/scripts/componentInteractions.ts +20 -20
- package/src/components/Progress/Progress.tsx +36 -34
- package/src/components/Progress/scripts/bundle.ts +7 -2
- package/src/components/Progress/scripts/componentInteractions.ts +29 -23
- package/src/components/Progress/scripts/index.ts +45 -39
- package/src/components/Rating/Rating.stories.tsx +3 -16
- package/src/components/Rating/Rating.tsx +250 -231
- package/src/components/Rating/scripts/bundle.ts +11 -6
- package/src/components/Rating/scripts/index.ts +85 -80
- package/src/components/Rating/scripts/ratingInteractions.ts +27 -24
- package/src/components/River/River.stories.tsx +70 -24
- package/src/components/River/River.tsx +28 -38
- package/src/components/River/index.ts +1 -1
- package/src/components/River/scripts/index.ts +11 -12
- package/src/components/SectionIntro/SectionIntro.stories.tsx +12 -9
- package/src/components/SectionIntro/SectionIntro.tsx +25 -31
- package/src/components/SectionIntro/scripts/componentInteractions.ts +1 -1
- package/src/components/SectionIntro/scripts/index.ts +30 -16
- package/src/components/Spinner/Spinner.stories.tsx +5 -7
- package/src/components/Spinner/Spinner.tsx +11 -6
- package/src/components/Spinner/index.ts +2 -2
- package/src/components/Steps/Steps.stories.tsx +44 -48
- package/src/components/Steps/Steps.tsx +20 -20
- package/src/components/Steps/index.ts +1 -1
- package/src/components/Steps/scripts/index.ts +9 -9
- package/src/components/Tab/Tab.stories.tsx +14 -6
- package/src/components/Tab/Tab.tsx +16 -18
- package/src/components/Tab/index.ts +2 -2
- package/src/components/Tab/scripts/index.ts +13 -13
- package/src/components/Testimonial/Testimonial.stories.tsx +54 -51
- package/src/components/Testimonial/Testimonial.tsx +18 -19
- package/src/components/Testimonial/index.ts +1 -1
- package/src/components/Testimonial/scripts/index.ts +19 -8
- package/src/components/Todo/Todo.stories.tsx +7 -24
- package/src/components/Todo/Todo.tsx +35 -46
- package/src/components/Todo/index.ts +1 -1
- package/src/components/Todo/scripts/bundle.ts +1 -1
- package/src/components/Todo/scripts/index.ts +99 -81
- package/src/components/Todo/scripts/todoInteractions.ts +12 -12
- package/src/components/Todo/scripts/types.ts +3 -3
- package/src/components/Toggle/Toggle.stories.tsx +2 -2
- package/src/components/Toggle/Toggle.tsx +18 -18
- package/src/components/Toggle/index.ts +2 -2
- package/src/components/Toggle/scripts/bundle.ts +7 -2
- package/src/components/Toggle/scripts/index.ts +14 -10
- package/src/components/Toggle/scripts/toggleInteractions.ts +11 -14
- package/src/components/Tooltip/Tooltip.stories.tsx +13 -6
- package/src/components/Tooltip/Tooltip.tsx +25 -15
- package/src/components/Tooltip/index.ts +3 -3
- package/src/components/Tooltip/scripts/bundle.ts +0 -1
- package/src/components/Tooltip/scripts/index.ts +44 -41
- package/src/components/Tooltip/scripts/tooltipInteractions.ts +22 -22
- package/src/components/Upload/Upload.stories.tsx +28 -34
- package/src/components/Upload/Upload.tsx +86 -71
- package/src/components/Upload/index.ts +1 -1
- package/src/components/Upload/scripts/index.ts +58 -43
- package/src/components/index.ts +5 -6
- package/src/design-tokens/BoxShadow/BoxShadow.stories.tsx +13 -10
- package/src/design-tokens/Colors/colors.scss +10 -7
- package/src/design-tokens/Colors/colors.stories.tsx +46 -59
- package/src/design-tokens/Spacing/Spacing.scss +7 -5
- package/src/design-tokens/Spacing/Spacing.stories.tsx +19 -18
- package/src/design-tokens/Typography/Typography.scss +88 -25
- package/src/design-tokens/Typography/Typography.stories.tsx +22 -25
- package/src/docs/implementation-guide.mdx +2 -2
- package/src/htmlComponentsEntry.ts +23 -23
- package/src/index.ts +1 -1
- package/src/layouts/Grid/Container.tsx +6 -10
- package/src/layouts/Grid/Grid.stories.tsx +72 -34
- package/src/layouts/Grid/Grid.tsx +6 -13
- package/src/layouts/Grid/GridCol.tsx +29 -26
- package/src/layouts/Grid/Row.tsx +6 -13
- package/src/layouts/MasonryGrid/MasonryGrid.stories.tsx +79 -72
- package/src/layouts/MasonryGrid/MasonryGrid.tsx +23 -25
- package/src/layouts/MasonryGrid/MasonryGridItem.tsx +4 -12
- package/src/layouts/index.ts +3 -4
- package/src/lib/composables/index.ts +3 -3
- package/src/lib/composables/useAccordion.ts +15 -6
- package/src/lib/composables/useBadge.ts +3 -3
- package/src/lib/composables/useBreadcrumb.ts +6 -12
- package/src/lib/composables/useButton.ts +3 -3
- package/src/lib/composables/useCallout.ts +3 -3
- package/src/lib/composables/useCard.ts +50 -28
- package/src/lib/composables/useCheckbox.ts +7 -7
- package/src/lib/composables/useDataTable.ts +61 -57
- package/src/lib/composables/useDatePicker.ts +255 -231
- package/src/lib/composables/useDropdown.ts +90 -75
- package/src/lib/composables/useEdgePanel.ts +50 -47
- package/src/lib/composables/useForm.ts +4 -7
- package/src/lib/composables/useFormGroup.ts +11 -12
- package/src/lib/composables/useHero.ts +36 -38
- package/src/lib/composables/useInput.ts +9 -10
- package/src/lib/composables/useMessages.ts +12 -14
- package/src/lib/composables/useModal.ts +37 -34
- package/src/lib/composables/useNavbar.ts +33 -22
- package/src/lib/composables/usePagination.ts +3 -10
- package/src/lib/composables/usePhotoViewer.ts +625 -578
- package/src/lib/composables/usePopover.ts +68 -62
- package/src/lib/composables/useProgress.ts +9 -12
- package/src/lib/composables/useRadio.ts +4 -4
- package/src/lib/composables/useRating.ts +82 -70
- package/src/lib/composables/useRiver.ts +28 -31
- package/src/lib/composables/useSelect.ts +7 -8
- package/src/lib/composables/useSideMenu.ts +197 -0
- package/src/lib/composables/useSpinner.ts +3 -3
- package/src/lib/composables/useTextarea.ts +8 -9
- package/src/lib/composables/useTodo.ts +14 -18
- package/src/lib/constants/components.ts +191 -118
- package/src/lib/constants/index.ts +1 -1
- package/src/lib/types/components.ts +454 -324
- package/src/lib/utils/dom.ts +2 -6
- package/src/lib/utils/icons.ts +20 -12
- package/src/lib/utils/index.ts +2 -2
- package/src/lib/utils/useForkRef.ts +1 -2
- package/src/styles/01-settings/_index.scss +59 -59
- package/src/styles/01-settings/_settings.accordion.scss +21 -21
- package/src/styles/01-settings/_settings.animations.scss +2 -2
- package/src/styles/01-settings/_settings.avatar-group.scss +14 -14
- package/src/styles/01-settings/_settings.avatar.scss +31 -31
- package/src/styles/01-settings/_settings.badge.scss +11 -11
- package/src/styles/01-settings/_settings.border-radius.scss +10 -9
- package/src/styles/01-settings/_settings.border.scss +7 -7
- package/src/styles/01-settings/_settings.box-shadow.scss +24 -12
- package/src/styles/01-settings/_settings.breadcrumb.scss +18 -18
- package/src/styles/01-settings/_settings.btn-group.scss +1 -1
- package/src/styles/01-settings/_settings.button.scss +63 -49
- package/src/styles/01-settings/_settings.callout.scss +27 -7
- package/src/styles/01-settings/_settings.card.scss +27 -30
- package/src/styles/01-settings/_settings.checkbox-group.scss +2 -3
- package/src/styles/01-settings/_settings.checkbox.scss +17 -18
- package/src/styles/01-settings/_settings.color-mode.scss +1 -1
- package/src/styles/01-settings/_settings.colors.scss +197 -214
- package/src/styles/01-settings/_settings.config.scss +1 -3
- package/src/styles/01-settings/_settings.countdown.scss +14 -14
- package/src/styles/01-settings/_settings.data-table.scss +6 -6
- package/src/styles/01-settings/_settings.datepicker.scss +40 -42
- package/src/styles/01-settings/_settings.dropdown.scss +30 -30
- package/src/styles/01-settings/_settings.edge-panel.scss +16 -16
- package/src/styles/01-settings/_settings.fonts.scss +14 -12
- package/src/styles/01-settings/_settings.form-group.scss +10 -10
- package/src/styles/01-settings/_settings.form.scss +3 -3
- package/src/styles/01-settings/_settings.grid.scss +1 -1
- package/src/styles/01-settings/_settings.hero.scss +23 -23
- package/src/styles/01-settings/_settings.input.scss +32 -32
- package/src/styles/01-settings/_settings.link.scss +6 -6
- package/src/styles/01-settings/_settings.list-group.scss +12 -12
- package/src/styles/01-settings/_settings.list.scss +2 -2
- package/src/styles/01-settings/_settings.maps.scss +183 -188
- package/src/styles/01-settings/_settings.masonry-grid.scss +2 -2
- package/src/styles/01-settings/_settings.menu.scss +35 -38
- package/src/styles/01-settings/_settings.messages.scss +71 -77
- package/src/styles/01-settings/_settings.modal.scss +24 -24
- package/src/styles/01-settings/_settings.nav.scss +15 -15
- package/src/styles/01-settings/_settings.navbar.scss +39 -12
- package/src/styles/01-settings/_settings.pagination.scss +21 -21
- package/src/styles/01-settings/_settings.photoviewer.scss +1 -1
- package/src/styles/01-settings/_settings.popover.scss +3 -3
- package/src/styles/01-settings/_settings.position.scss +2 -2
- package/src/styles/01-settings/_settings.progress.scss +15 -18
- package/src/styles/01-settings/_settings.rating.scss +7 -7
- package/src/styles/01-settings/_settings.river.scss +25 -25
- package/src/styles/01-settings/_settings.sectionintro.scss +15 -16
- package/src/styles/01-settings/_settings.select.scss +31 -31
- package/src/styles/01-settings/_settings.side-menu.scss +64 -16
- package/src/styles/01-settings/_settings.skeleton.scss +12 -12
- package/src/styles/01-settings/_settings.spacing.scss +62 -33
- package/src/styles/01-settings/_settings.spinner.scss +10 -10
- package/src/styles/01-settings/_settings.steps.scss +22 -22
- package/src/styles/01-settings/_settings.tabs.scss +25 -25
- package/src/styles/01-settings/_settings.testimonials.scss +17 -19
- package/src/styles/01-settings/_settings.todo.scss +1 -1
- package/src/styles/01-settings/_settings.toggle.scss +26 -26
- package/src/styles/01-settings/_settings.tooltip.scss +15 -15
- package/src/styles/01-settings/_settings.typography.scss +65 -48
- package/src/styles/01-settings/_settings.upload.scss +70 -77
- package/src/styles/01-settings/_settings.z-layers.scss +1 -1
- package/src/styles/02-tools/_index.scss +19 -19
- package/src/styles/02-tools/_tools.animations.scss +4 -4
- package/src/styles/02-tools/_tools.border-radius.scss +4 -5
- package/src/styles/02-tools/_tools.breakpoints.scss +33 -34
- package/src/styles/02-tools/_tools.button.scss +49 -25
- package/src/styles/02-tools/_tools.color-mode.scss +11 -11
- package/src/styles/02-tools/_tools.event.scss +1 -1
- package/src/styles/02-tools/_tools.hidden-visually.scss +1 -1
- package/src/styles/02-tools/_tools.hidden.scss +1 -1
- package/src/styles/02-tools/_tools.map-loop.scss +9 -9
- package/src/styles/02-tools/_tools.media-queries.scss +5 -3
- package/src/styles/02-tools/_tools.object-fit.scss +3 -3
- package/src/styles/02-tools/_tools.placeholder.scss +0 -1
- package/src/styles/02-tools/_tools.rem.scss +1 -1
- package/src/styles/02-tools/_tools.spacing.scss +8 -34
- package/src/styles/02-tools/_tools.to-rgb.scss +3 -3
- package/src/styles/02-tools/_tools.transition.scss +1 -1
- package/src/styles/02-tools/_tools.utility-api.scss +29 -14
- package/src/styles/03-generic/_generic.fonts.scss +0 -1
- package/src/styles/03-generic/_generic.reset.scss +13 -8
- package/src/styles/03-generic/_generic.root.scss +5 -5
- package/src/styles/03-generic/_index.scss +4 -4
- package/src/styles/04-elements/_elements.all.scss +2 -2
- package/src/styles/04-elements/_elements.body.scss +1 -2
- package/src/styles/04-elements/_elements.heading.scss +37 -21
- package/src/styles/04-elements/_elements.links.scss +0 -1
- package/src/styles/04-elements/_index.scss +5 -5
- package/src/styles/05-objects/_index.scss +3 -3
- package/src/styles/05-objects/_objects.container.scss +5 -4
- package/src/styles/05-objects/_objects.grid.scss +12 -12
- package/src/styles/05-objects/_objects.masonry-grid.scss +80 -74
- package/src/styles/06-components/_components.accordion.scss +12 -6
- package/src/styles/06-components/_components.avatar-group.scss +9 -8
- package/src/styles/06-components/_components.avatar.scss +78 -77
- package/src/styles/06-components/_components.badge.scss +48 -48
- package/src/styles/06-components/_components.breadcrumb.scss +57 -58
- package/src/styles/06-components/_components.btn-group.scss +22 -22
- package/src/styles/06-components/_components.button.scss +118 -110
- package/src/styles/06-components/_components.callout.scss +21 -15
- package/src/styles/06-components/_components.card.scss +6 -10
- package/src/styles/06-components/_components.checkbox-group.scss +9 -10
- package/src/styles/06-components/_components.checkbox.scss +10 -17
- package/src/styles/06-components/_components.color-mode-toggle.scss +6 -6
- package/src/styles/06-components/_components.countdown.scss +53 -54
- package/src/styles/06-components/_components.data-table.scss +40 -36
- package/src/styles/06-components/_components.datepicker.scss +95 -73
- package/src/styles/06-components/_components.dropdown.scss +15 -9
- package/src/styles/06-components/_components.edge-panel.scss +87 -46
- package/src/styles/06-components/_components.form-group.scss +5 -4
- package/src/styles/06-components/_components.hero.scss +128 -132
- package/src/styles/06-components/_components.icon.scss +16 -16
- package/src/styles/06-components/_components.image-gallery.scss +9 -7
- package/src/styles/06-components/_components.input.scss +18 -16
- package/src/styles/06-components/_components.list-group.scss +52 -51
- package/src/styles/06-components/_components.list.scss +15 -15
- package/src/styles/06-components/_components.menu.scss +225 -220
- package/src/styles/06-components/_components.messages.scss +45 -32
- package/src/styles/06-components/_components.modal.scss +0 -1
- package/src/styles/06-components/_components.nav.scss +56 -11
- package/src/styles/06-components/_components.navbar.scss +278 -202
- package/src/styles/06-components/_components.pagination.scss +7 -6
- package/src/styles/06-components/_components.photoviewer.scss +121 -116
- package/src/styles/06-components/_components.popover.scss +10 -10
- package/src/styles/06-components/_components.product-review.scss +3 -3
- package/src/styles/06-components/_components.progress.scss +32 -35
- package/src/styles/06-components/_components.rating.scss +9 -8
- package/src/styles/06-components/_components.river.scss +4 -2
- package/src/styles/06-components/_components.sectionintro.scss +19 -26
- package/src/styles/06-components/_components.select.scss +7 -8
- package/src/styles/06-components/_components.side-menu.scss +154 -28
- package/src/styles/06-components/_components.skeleton.scss +0 -1
- package/src/styles/06-components/_components.spinner.scss +2 -4
- package/src/styles/06-components/_components.steps.scss +76 -77
- package/src/styles/06-components/_components.tabs.scss +17 -12
- package/src/styles/06-components/_components.testimonials.scss +49 -52
- package/src/styles/06-components/_components.todo.scss +26 -26
- package/src/styles/06-components/_components.tooltip.scss +114 -115
- package/src/styles/06-components/_components.upload.scss +8 -18
- package/src/styles/06-components/_index.scss +48 -48
- package/src/styles/99-utilities/_index.scss +18 -18
- package/src/styles/99-utilities/_utilities.background.scss +13 -13
- package/src/styles/99-utilities/_utilities.border.scss +30 -30
- package/src/styles/99-utilities/_utilities.clearfix.scss +1 -1
- package/src/styles/99-utilities/_utilities.display.scss +5 -4
- package/src/styles/99-utilities/_utilities.flex.scss +19 -19
- package/src/styles/99-utilities/_utilities.link.scss +52 -35
- package/src/styles/99-utilities/_utilities.object-fit.scss +3 -3
- package/src/styles/99-utilities/_utilities.opacity.scss +6 -6
- package/src/styles/99-utilities/_utilities.overflow.scss +4 -4
- package/src/styles/99-utilities/_utilities.position.scss +8 -8
- package/src/styles/99-utilities/_utilities.shadow.scss +13 -13
- package/src/styles/99-utilities/_utilities.sizes.scss +17 -17
- package/src/styles/99-utilities/_utilities.spacing.scss +72 -37
- package/src/styles/99-utilities/_utilities.text.scss +15 -15
- package/src/styles/99-utilities/_utilities.visibility.scss +8 -8
- package/src/styles/99-utilities/_utilities.visually-hidden.scss +1 -1
- package/src/styles/99-utilities/_utilities.z-index.scss +2 -2
- package/tsconfig.json +74 -0
- package/webpack.config.js +463 -0
- package/NPM_PUBLISHING.md +0 -221
- package/dist/css/atomix.css.map +0 -1
- package/dist/js/194.js.map +0 -1
- package/dist/js/atomix.react.esm.js.map +0 -1
- package/dist/js/atomix.react.umd.js.map +0 -1
- package/dist/js/chunks/esm/202.ff48d27672233280e021.js.map +0 -1
- package/dist/js/chunks/esm/308.f873332126eba90e5c62.js.map +0 -1
- package/dist/js/chunks/esm/54.4db919e5e4e5cc6d7c72.js.map +0 -1
- package/dist/js/chunks/esm/619.afc5a718eff77fa423b5.js.map +0 -1
- package/dist/js/chunks/esm/690.a9e968c7497d61e56cdc.js.map +0 -1
- package/dist/js/chunks/esm/894.f1091a4a8758c26d29e4.js.map +0 -1
- package/dist/js/chunks/esm/897.561a50f7d043d42169da.js.map +0 -1
- package/dist/js/chunks/umd/202.dac7605cc555b6bda542.js.map +0 -1
- package/dist/js/chunks/umd/308.6709979849dcbdb90c9b.js.map +0 -1
- package/dist/js/chunks/umd/54.403470e1f7d0ef4424a7.js.map +0 -1
- package/dist/js/chunks/umd/619.fa05ea98c10270eb64c5.js.map +0 -1
- package/dist/js/chunks/umd/690.aa7054d1c53e5402c2d6.js.map +0 -1
- package/dist/js/chunks/umd/894.3e1eaf0a2aadf4434390.js.map +0 -1
- package/dist/js/chunks/umd/897.554ea37be4453698c167.js.map +0 -1
- package/dist/types/components/Navbar/Nav.d.ts +0 -5
- package/dist/types/components/Navbar/NavItem.d.ts +0 -5
- package/dist/types/components/Navbar/Navbar.d.ts +0 -5
- package/dist/types/components/Navbar/index.d.ts +0 -6
- package/src/components/Navbar/Menu.tsx +0 -122
- package/src/components/Navbar/Nav.tsx +0 -35
- package/src/components/Navbar/NavDropdown.tsx +0 -108
- package/src/components/Navbar/NavItem.tsx +0 -128
- package/src/components/Navbar/Navbar.tsx +0 -124
- package/src/components/Navbar/index.ts +0 -6
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import {
|
|
3
|
+
DatePickerViewMode,
|
|
4
|
+
DatePickerSelectionMode,
|
|
5
|
+
DateRange,
|
|
6
|
+
} from '../../components/DatePicker/types';
|
|
7
|
+
import {
|
|
8
|
+
getMonthName,
|
|
9
|
+
getDaysInMonth,
|
|
10
|
+
getFirstDayOfMonth,
|
|
11
|
+
formatDate,
|
|
12
|
+
isDateInRange,
|
|
9
13
|
} from '../../components/DatePicker/utils';
|
|
10
14
|
|
|
11
15
|
interface UseDatePickerProps {
|
|
@@ -13,47 +17,47 @@ interface UseDatePickerProps {
|
|
|
13
17
|
* The currently selected date value
|
|
14
18
|
*/
|
|
15
19
|
value?: Date | null;
|
|
16
|
-
|
|
20
|
+
|
|
17
21
|
/**
|
|
18
22
|
* Callback function when date is changed
|
|
19
23
|
*/
|
|
20
24
|
onChange?: (date: Date | null) => void;
|
|
21
|
-
|
|
25
|
+
|
|
22
26
|
/**
|
|
23
27
|
* Selection mode - single date or date range
|
|
24
28
|
*/
|
|
25
29
|
selectionMode?: DatePickerSelectionMode;
|
|
26
|
-
|
|
30
|
+
|
|
27
31
|
/**
|
|
28
32
|
* The start date of the range
|
|
29
33
|
*/
|
|
30
34
|
startDate?: Date | null;
|
|
31
|
-
|
|
35
|
+
|
|
32
36
|
/**
|
|
33
37
|
* The end date of the range
|
|
34
38
|
*/
|
|
35
39
|
endDate?: Date | null;
|
|
36
|
-
|
|
40
|
+
|
|
37
41
|
/**
|
|
38
42
|
* Callback function when date range is changed
|
|
39
43
|
*/
|
|
40
44
|
onRangeChange?: (range: DateRange) => void;
|
|
41
|
-
|
|
45
|
+
|
|
42
46
|
/**
|
|
43
47
|
* Format for the date display
|
|
44
48
|
*/
|
|
45
49
|
format?: string;
|
|
46
|
-
|
|
50
|
+
|
|
47
51
|
/**
|
|
48
52
|
* Minimum selectable date
|
|
49
53
|
*/
|
|
50
54
|
minDate?: Date;
|
|
51
|
-
|
|
55
|
+
|
|
52
56
|
/**
|
|
53
57
|
* Maximum selectable date
|
|
54
58
|
*/
|
|
55
59
|
maxDate?: Date;
|
|
56
|
-
|
|
60
|
+
|
|
57
61
|
/**
|
|
58
62
|
* Whether the datepicker is in inline mode
|
|
59
63
|
*/
|
|
@@ -82,15 +86,15 @@ export function useDatePicker({
|
|
|
82
86
|
format = 'MM/dd/yyyy',
|
|
83
87
|
minDate,
|
|
84
88
|
maxDate,
|
|
85
|
-
inline = false
|
|
89
|
+
inline = false,
|
|
86
90
|
}: UseDatePickerProps = {}) {
|
|
87
91
|
const [isOpen, setIsOpen] = useState(inline);
|
|
88
92
|
const [inputValue, setInputValue] = useState(value ? formatDate(value, format) : '');
|
|
89
93
|
const [rangeInputValue, setRangeInputValue] = useState(
|
|
90
|
-
startDate && endDate
|
|
94
|
+
startDate && endDate
|
|
91
95
|
? `${formatDate(startDate, format)} - ${formatDate(endDate, format)}`
|
|
92
|
-
: startDate
|
|
93
|
-
? `${formatDate(startDate, format)} - Select end date`
|
|
96
|
+
: startDate
|
|
97
|
+
? `${formatDate(startDate, format)} - Select end date`
|
|
94
98
|
: ''
|
|
95
99
|
);
|
|
96
100
|
const [viewDate, setViewDate] = useState(value || startDate || new Date());
|
|
@@ -98,144 +102,157 @@ export function useDatePicker({
|
|
|
98
102
|
const [rangeSelectionState, setRangeSelectionState] = useState<'start' | 'end'>(
|
|
99
103
|
!startDate || (startDate && endDate) ? 'start' : 'end'
|
|
100
104
|
);
|
|
101
|
-
|
|
105
|
+
|
|
102
106
|
const datePickerRef = useRef<HTMLDivElement>(null);
|
|
103
107
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
104
|
-
|
|
108
|
+
|
|
105
109
|
const today = new Date();
|
|
106
110
|
const currentMonth = viewDate.getMonth();
|
|
107
111
|
const currentYear = viewDate.getFullYear();
|
|
108
112
|
const daysInMonth = getDaysInMonth(currentYear, currentMonth);
|
|
109
113
|
const firstDayOfMonth = getFirstDayOfMonth(currentYear, currentMonth);
|
|
110
|
-
|
|
114
|
+
|
|
111
115
|
// Update input value when value or range dates change externally
|
|
112
116
|
useEffect(() => {
|
|
113
117
|
if (selectionMode === 'single') {
|
|
114
118
|
setInputValue(value ? formatDate(value, format) : '');
|
|
115
119
|
} else {
|
|
116
120
|
setRangeInputValue(
|
|
117
|
-
startDate && endDate
|
|
121
|
+
startDate && endDate
|
|
118
122
|
? `${formatDate(startDate, format)} - ${formatDate(endDate, format)}`
|
|
119
|
-
: startDate
|
|
120
|
-
? `${formatDate(startDate, format)} - Select end date`
|
|
123
|
+
: startDate
|
|
124
|
+
? `${formatDate(startDate, format)} - Select end date`
|
|
121
125
|
: ''
|
|
122
126
|
);
|
|
123
127
|
setRangeSelectionState(!startDate || (startDate && endDate) ? 'start' : 'end');
|
|
124
128
|
}
|
|
125
129
|
}, [value, startDate, endDate, format, selectionMode]);
|
|
126
|
-
|
|
130
|
+
|
|
127
131
|
// Handle date selection
|
|
128
|
-
const handleDateSelect = useCallback(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (
|
|
136
|
-
onChange
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
} else {
|
|
144
|
-
// Range selection mode
|
|
145
|
-
if (rangeSelectionState === 'start') {
|
|
146
|
-
// Selecting start date
|
|
147
|
-
if (onRangeChange) {
|
|
148
|
-
onRangeChange({
|
|
149
|
-
startDate: selectedDate,
|
|
150
|
-
endDate: null
|
|
151
|
-
});
|
|
132
|
+
const handleDateSelect = useCallback(
|
|
133
|
+
(day: number) => {
|
|
134
|
+
const selectedDate = new Date(currentYear, currentMonth, day);
|
|
135
|
+
|
|
136
|
+
if (minDate && selectedDate < minDate) return;
|
|
137
|
+
if (maxDate && selectedDate > maxDate) return;
|
|
138
|
+
|
|
139
|
+
if (selectionMode === 'single') {
|
|
140
|
+
if (onChange) {
|
|
141
|
+
onChange(selectedDate);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
setInputValue(formatDate(selectedDate, format));
|
|
145
|
+
if (!inline) {
|
|
146
|
+
setIsOpen(false);
|
|
152
147
|
}
|
|
153
|
-
setRangeInputValue(`${formatDate(selectedDate, format)} - Select end date`);
|
|
154
|
-
setRangeSelectionState('end');
|
|
155
148
|
} else {
|
|
156
|
-
//
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
// Make sure end date is after start date
|
|
160
|
-
if (selectedDate < startDate) {
|
|
149
|
+
// Range selection mode
|
|
150
|
+
if (rangeSelectionState === 'start') {
|
|
151
|
+
// Selecting start date
|
|
161
152
|
if (onRangeChange) {
|
|
162
153
|
onRangeChange({
|
|
163
154
|
startDate: selectedDate,
|
|
164
|
-
endDate:
|
|
155
|
+
endDate: null,
|
|
165
156
|
});
|
|
166
157
|
}
|
|
167
|
-
setRangeInputValue(`${formatDate(selectedDate, format)} -
|
|
158
|
+
setRangeInputValue(`${formatDate(selectedDate, format)} - Select end date`);
|
|
159
|
+
setRangeSelectionState('end');
|
|
168
160
|
} else {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
161
|
+
// Selecting end date
|
|
162
|
+
if (!startDate) return;
|
|
163
|
+
|
|
164
|
+
// Make sure end date is after start date
|
|
165
|
+
if (selectedDate < startDate) {
|
|
166
|
+
if (onRangeChange) {
|
|
167
|
+
onRangeChange({
|
|
168
|
+
startDate: selectedDate,
|
|
169
|
+
endDate: startDate,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
setRangeInputValue(
|
|
173
|
+
`${formatDate(selectedDate, format)} - ${formatDate(startDate, format)}`
|
|
174
|
+
);
|
|
175
|
+
} else {
|
|
176
|
+
if (onRangeChange) {
|
|
177
|
+
onRangeChange({
|
|
178
|
+
startDate,
|
|
179
|
+
endDate: selectedDate,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
setRangeInputValue(
|
|
183
|
+
`${formatDate(startDate, format)} - ${formatDate(selectedDate, format)}`
|
|
184
|
+
);
|
|
174
185
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
186
|
+
|
|
187
|
+
if (!inline) {
|
|
188
|
+
setIsOpen(false);
|
|
189
|
+
}
|
|
190
|
+
setRangeSelectionState('start');
|
|
180
191
|
}
|
|
181
|
-
setRangeSelectionState('start');
|
|
182
192
|
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
},
|
|
194
|
+
[
|
|
195
|
+
currentYear,
|
|
196
|
+
currentMonth,
|
|
197
|
+
minDate,
|
|
198
|
+
maxDate,
|
|
199
|
+
onChange,
|
|
200
|
+
onRangeChange,
|
|
201
|
+
format,
|
|
202
|
+
inline,
|
|
203
|
+
selectionMode,
|
|
204
|
+
rangeSelectionState,
|
|
205
|
+
startDate,
|
|
206
|
+
]
|
|
207
|
+
);
|
|
208
|
+
|
|
198
209
|
// Calendar navigation
|
|
199
210
|
const handlePrevMonth = useCallback(() => {
|
|
200
211
|
setViewDate(new Date(currentYear, currentMonth - 1, 1));
|
|
201
212
|
}, [currentYear, currentMonth]);
|
|
202
|
-
|
|
213
|
+
|
|
203
214
|
const handleNextMonth = useCallback(() => {
|
|
204
215
|
setViewDate(new Date(currentYear, currentMonth + 1, 1));
|
|
205
216
|
}, [currentYear, currentMonth]);
|
|
206
|
-
|
|
217
|
+
|
|
207
218
|
const handlePrevYear = useCallback(() => {
|
|
208
219
|
setViewDate(new Date(currentYear - 1, currentMonth, 1));
|
|
209
220
|
}, [currentYear, currentMonth]);
|
|
210
|
-
|
|
221
|
+
|
|
211
222
|
const handleNextYear = useCallback(() => {
|
|
212
223
|
setViewDate(new Date(currentYear + 1, currentMonth, 1));
|
|
213
224
|
}, [currentYear, currentMonth]);
|
|
214
|
-
|
|
225
|
+
|
|
215
226
|
// Handle view mode changes
|
|
216
227
|
const switchToMonthView = useCallback(() => {
|
|
217
228
|
setViewMode('months');
|
|
218
229
|
}, []);
|
|
219
|
-
|
|
230
|
+
|
|
220
231
|
const switchToYearView = useCallback(() => {
|
|
221
232
|
setViewMode('years');
|
|
222
233
|
}, []);
|
|
223
|
-
|
|
224
|
-
const selectMonth = useCallback(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
+
|
|
235
|
+
const selectMonth = useCallback(
|
|
236
|
+
(month: number) => {
|
|
237
|
+
setViewDate(new Date(currentYear, month, 1));
|
|
238
|
+
setViewMode('days');
|
|
239
|
+
},
|
|
240
|
+
[currentYear]
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
const selectYear = useCallback(
|
|
244
|
+
(year: number) => {
|
|
245
|
+
setViewDate(new Date(year, currentMonth, 1));
|
|
246
|
+
setViewMode('months');
|
|
247
|
+
},
|
|
248
|
+
[currentMonth]
|
|
249
|
+
);
|
|
250
|
+
|
|
234
251
|
// Handle today button click
|
|
235
252
|
const handleTodayClick = useCallback(() => {
|
|
236
253
|
const todayDate = new Date();
|
|
237
254
|
setViewDate(todayDate);
|
|
238
|
-
|
|
255
|
+
|
|
239
256
|
if (selectionMode === 'single') {
|
|
240
257
|
handleDateSelect(todayDate.getDate());
|
|
241
258
|
} else {
|
|
@@ -243,7 +260,7 @@ export function useDatePicker({
|
|
|
243
260
|
setViewDate(new Date());
|
|
244
261
|
}
|
|
245
262
|
}, [handleDateSelect, selectionMode]);
|
|
246
|
-
|
|
263
|
+
|
|
247
264
|
// Handle clear button click
|
|
248
265
|
const handleClear = useCallback(() => {
|
|
249
266
|
if (selectionMode === 'single') {
|
|
@@ -257,69 +274,72 @@ export function useDatePicker({
|
|
|
257
274
|
if (onRangeChange) {
|
|
258
275
|
onRangeChange({
|
|
259
276
|
startDate: null,
|
|
260
|
-
endDate: null
|
|
277
|
+
endDate: null,
|
|
261
278
|
});
|
|
262
279
|
}
|
|
263
280
|
}
|
|
264
281
|
}, [onChange, onRangeChange, selectionMode]);
|
|
265
|
-
|
|
282
|
+
|
|
266
283
|
// Handle input change
|
|
267
|
-
const handleInputChange = useCallback(
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (
|
|
275
|
-
onChange
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
} else {
|
|
280
|
-
setRangeInputValue(e.target.value);
|
|
281
|
-
|
|
282
|
-
// Attempt to parse range input (not fully implemented - would need complex parsing)
|
|
283
|
-
// This is a simplified implementation that would need improvement
|
|
284
|
-
const parts = e.target.value.split('-');
|
|
285
|
-
if (parts.length === 2) {
|
|
286
|
-
const startPart = parts[0].trim();
|
|
287
|
-
const endPart = parts[1].trim();
|
|
288
|
-
|
|
289
|
-
const parsedStart = new Date(startPart);
|
|
290
|
-
if (!isNaN(parsedStart.getTime())) {
|
|
291
|
-
setViewDate(parsedStart);
|
|
284
|
+
const handleInputChange = useCallback(
|
|
285
|
+
(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
286
|
+
if (selectionMode === 'single') {
|
|
287
|
+
setInputValue(e.target.value);
|
|
288
|
+
|
|
289
|
+
// Try to parse the date
|
|
290
|
+
const parsedDate = new Date(e.target.value);
|
|
291
|
+
if (!isNaN(parsedDate.getTime())) {
|
|
292
|
+
if (onChange) {
|
|
293
|
+
onChange(parsedDate);
|
|
294
|
+
}
|
|
295
|
+
setViewDate(parsedDate);
|
|
292
296
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
297
|
+
} else {
|
|
298
|
+
setRangeInputValue(e.target.value);
|
|
299
|
+
|
|
300
|
+
// Attempt to parse range input (not fully implemented - would need complex parsing)
|
|
301
|
+
// This is a simplified implementation that would need improvement
|
|
302
|
+
const parts = e.target.value.split('-');
|
|
303
|
+
if (parts.length === 2) {
|
|
304
|
+
const startPart = parts[0].trim();
|
|
305
|
+
const endPart = parts[1].trim();
|
|
306
|
+
|
|
307
|
+
const parsedStart = new Date(startPart);
|
|
308
|
+
if (!isNaN(parsedStart.getTime())) {
|
|
309
|
+
setViewDate(parsedStart);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Attempt to parse both dates
|
|
313
|
+
if (startPart && endPart) {
|
|
314
|
+
const parsedStartDate = new Date(startPart);
|
|
315
|
+
const parsedEndDate = new Date(endPart);
|
|
316
|
+
|
|
317
|
+
if (!isNaN(parsedStartDate.getTime()) && !isNaN(parsedEndDate.getTime())) {
|
|
318
|
+
if (onRangeChange) {
|
|
319
|
+
onRangeChange({
|
|
320
|
+
startDate: parsedStartDate,
|
|
321
|
+
endDate: parsedEndDate,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
305
324
|
}
|
|
306
325
|
}
|
|
307
326
|
}
|
|
308
327
|
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
328
|
+
},
|
|
329
|
+
[onChange, onRangeChange, selectionMode]
|
|
330
|
+
);
|
|
331
|
+
|
|
312
332
|
// Handle input focus
|
|
313
333
|
const handleInputFocus = useCallback(() => {
|
|
314
334
|
if (!inline) {
|
|
315
335
|
setIsOpen(true);
|
|
316
336
|
}
|
|
317
337
|
}, [inline]);
|
|
318
|
-
|
|
338
|
+
|
|
319
339
|
// Handle click outside
|
|
320
340
|
const handleClickOutside = useCallback((event: MouseEvent) => {
|
|
321
341
|
if (
|
|
322
|
-
datePickerRef.current &&
|
|
342
|
+
datePickerRef.current &&
|
|
323
343
|
!datePickerRef.current.contains(event.target as Node) &&
|
|
324
344
|
inputRef.current &&
|
|
325
345
|
!inputRef.current.contains(event.target as Node)
|
|
@@ -327,7 +347,7 @@ export function useDatePicker({
|
|
|
327
347
|
setIsOpen(false);
|
|
328
348
|
}
|
|
329
349
|
}, []);
|
|
330
|
-
|
|
350
|
+
|
|
331
351
|
// Add/remove event listeners
|
|
332
352
|
useEffect(() => {
|
|
333
353
|
if (isOpen && !inline) {
|
|
@@ -335,12 +355,12 @@ export function useDatePicker({
|
|
|
335
355
|
} else {
|
|
336
356
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
337
357
|
}
|
|
338
|
-
|
|
358
|
+
|
|
339
359
|
return () => {
|
|
340
360
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
341
361
|
};
|
|
342
362
|
}, [isOpen, handleClickOutside, inline]);
|
|
343
|
-
|
|
363
|
+
|
|
344
364
|
// Generate days for the calendar
|
|
345
365
|
const generateDays = useCallback((): DateObject[] => {
|
|
346
366
|
const days: DateObject[] = [];
|
|
@@ -348,27 +368,27 @@ export function useDatePicker({
|
|
|
348
368
|
currentMonth === 0 ? currentYear - 1 : currentYear,
|
|
349
369
|
currentMonth === 0 ? 11 : currentMonth - 1
|
|
350
370
|
);
|
|
351
|
-
|
|
371
|
+
|
|
352
372
|
// Add previous month's days
|
|
353
373
|
for (let i = firstDayOfMonth - 1; i >= 0; i--) {
|
|
354
374
|
days.push({
|
|
355
375
|
day: prevMonthDays - i,
|
|
356
376
|
month: currentMonth === 0 ? 11 : currentMonth - 1,
|
|
357
377
|
year: currentMonth === 0 ? currentYear - 1 : currentYear,
|
|
358
|
-
isCurrentMonth: false
|
|
378
|
+
isCurrentMonth: false,
|
|
359
379
|
});
|
|
360
380
|
}
|
|
361
|
-
|
|
381
|
+
|
|
362
382
|
// Add current month's days
|
|
363
383
|
for (let i = 1; i <= daysInMonth; i++) {
|
|
364
384
|
days.push({
|
|
365
385
|
day: i,
|
|
366
386
|
month: currentMonth,
|
|
367
387
|
year: currentYear,
|
|
368
|
-
isCurrentMonth: true
|
|
388
|
+
isCurrentMonth: true,
|
|
369
389
|
});
|
|
370
390
|
}
|
|
371
|
-
|
|
391
|
+
|
|
372
392
|
// Add next month's days
|
|
373
393
|
const remainingDays = 42 - days.length;
|
|
374
394
|
for (let i = 1; i <= remainingDays; i++) {
|
|
@@ -376,25 +396,25 @@ export function useDatePicker({
|
|
|
376
396
|
day: i,
|
|
377
397
|
month: currentMonth === 11 ? 0 : currentMonth + 1,
|
|
378
398
|
year: currentMonth === 11 ? currentYear + 1 : currentYear,
|
|
379
|
-
isCurrentMonth: false
|
|
399
|
+
isCurrentMonth: false,
|
|
380
400
|
});
|
|
381
401
|
}
|
|
382
|
-
|
|
402
|
+
|
|
383
403
|
return days;
|
|
384
404
|
}, [daysInMonth, firstDayOfMonth, currentMonth, currentYear]);
|
|
385
|
-
|
|
405
|
+
|
|
386
406
|
// Generate months for month picker
|
|
387
407
|
const generateMonths = useCallback((): MonthObject[] => {
|
|
388
408
|
const months: MonthObject[] = [];
|
|
389
409
|
for (let i = 0; i < 12; i++) {
|
|
390
410
|
months.push({
|
|
391
411
|
month: i,
|
|
392
|
-
name: getMonthName(i)
|
|
412
|
+
name: getMonthName(i),
|
|
393
413
|
});
|
|
394
414
|
}
|
|
395
415
|
return months;
|
|
396
416
|
}, []);
|
|
397
|
-
|
|
417
|
+
|
|
398
418
|
// Generate years for year picker
|
|
399
419
|
const generateYears = useCallback((): number[] => {
|
|
400
420
|
const years: number[] = [];
|
|
@@ -404,74 +424,78 @@ export function useDatePicker({
|
|
|
404
424
|
}
|
|
405
425
|
return years;
|
|
406
426
|
}, [currentYear]);
|
|
407
|
-
|
|
427
|
+
|
|
408
428
|
// Check if a date is selectable
|
|
409
|
-
const isDateSelectable = useCallback(
|
|
410
|
-
|
|
411
|
-
return isDateInRange(date, minDate, maxDate);
|
|
412
|
-
}, [minDate, maxDate]);
|
|
413
|
-
|
|
414
|
-
// Check if a date is selected
|
|
415
|
-
const isDateSelected = useCallback((year: number, month: number, day: number): boolean => {
|
|
416
|
-
if (selectionMode === 'single') {
|
|
417
|
-
if (!value) return false;
|
|
418
|
-
|
|
419
|
-
return (
|
|
420
|
-
value.getFullYear() === year &&
|
|
421
|
-
value.getMonth() === month &&
|
|
422
|
-
value.getDate() === day
|
|
423
|
-
);
|
|
424
|
-
} else {
|
|
425
|
-
if (!startDate && !endDate) return false;
|
|
426
|
-
|
|
429
|
+
const isDateSelectable = useCallback(
|
|
430
|
+
(year: number, month: number, day: number): boolean => {
|
|
427
431
|
const date = new Date(year, month, day);
|
|
428
|
-
|
|
429
|
-
|
|
432
|
+
return isDateInRange(date, minDate, maxDate);
|
|
433
|
+
},
|
|
434
|
+
[minDate, maxDate]
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
// Check if a date is selected
|
|
438
|
+
const isDateSelected = useCallback(
|
|
439
|
+
(year: number, month: number, day: number): boolean => {
|
|
440
|
+
if (selectionMode === 'single') {
|
|
441
|
+
if (!value) return false;
|
|
442
|
+
|
|
430
443
|
return (
|
|
431
|
-
|
|
432
|
-
startDate.getMonth() === month &&
|
|
433
|
-
startDate.getDate() === day
|
|
434
|
-
);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
if (startDate && endDate) {
|
|
438
|
-
// Return true if the date is the start date or end date
|
|
439
|
-
const isStartDate = (
|
|
440
|
-
startDate.getFullYear() === year &&
|
|
441
|
-
startDate.getMonth() === month &&
|
|
442
|
-
startDate.getDate() === day
|
|
444
|
+
value.getFullYear() === year && value.getMonth() === month && value.getDate() === day
|
|
443
445
|
);
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
)
|
|
450
|
-
|
|
451
|
-
|
|
446
|
+
} else {
|
|
447
|
+
if (!startDate && !endDate) return false;
|
|
448
|
+
|
|
449
|
+
const date = new Date(year, month, day);
|
|
450
|
+
|
|
451
|
+
if (startDate && !endDate) {
|
|
452
|
+
return (
|
|
453
|
+
startDate.getFullYear() === year &&
|
|
454
|
+
startDate.getMonth() === month &&
|
|
455
|
+
startDate.getDate() === day
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
if (startDate && endDate) {
|
|
460
|
+
// Return true if the date is the start date or end date
|
|
461
|
+
const isStartDate =
|
|
462
|
+
startDate.getFullYear() === year &&
|
|
463
|
+
startDate.getMonth() === month &&
|
|
464
|
+
startDate.getDate() === day;
|
|
465
|
+
|
|
466
|
+
const isEndDate =
|
|
467
|
+
endDate.getFullYear() === year &&
|
|
468
|
+
endDate.getMonth() === month &&
|
|
469
|
+
endDate.getDate() === day;
|
|
470
|
+
|
|
471
|
+
return isStartDate || isEndDate;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
return false;
|
|
452
475
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
476
|
+
},
|
|
477
|
+
[value, selectionMode, startDate, endDate]
|
|
478
|
+
);
|
|
479
|
+
|
|
458
480
|
// Check if a date is in range (between startDate and endDate)
|
|
459
|
-
const isDateInSelectedRange = useCallback(
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
481
|
+
const isDateInSelectedRange = useCallback(
|
|
482
|
+
(year: number, month: number, day: number): boolean => {
|
|
483
|
+
if (selectionMode !== 'range' || !startDate || !endDate) return false;
|
|
484
|
+
|
|
485
|
+
const date = new Date(year, month, day);
|
|
486
|
+
return date > startDate && date < endDate;
|
|
487
|
+
},
|
|
488
|
+
[selectionMode, startDate, endDate]
|
|
489
|
+
);
|
|
490
|
+
|
|
466
491
|
// Check if a date is today
|
|
467
|
-
const isToday = useCallback(
|
|
468
|
-
|
|
469
|
-
today.getFullYear() === year &&
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
492
|
+
const isToday = useCallback(
|
|
493
|
+
(year: number, month: number, day: number): boolean => {
|
|
494
|
+
return today.getFullYear() === year && today.getMonth() === month && today.getDate() === day;
|
|
495
|
+
},
|
|
496
|
+
[today]
|
|
497
|
+
);
|
|
498
|
+
|
|
475
499
|
// Calculate week number for a date
|
|
476
500
|
const getWeekNumber = useCallback((date: Date): number => {
|
|
477
501
|
const target = new Date(date.valueOf());
|
|
@@ -480,11 +504,11 @@ export function useDatePicker({
|
|
|
480
504
|
const firstThursday = target.valueOf();
|
|
481
505
|
target.setMonth(0, 1);
|
|
482
506
|
if (target.getDay() !== 4) {
|
|
483
|
-
target.setMonth(0, 1 + ((4 - target.getDay()
|
|
507
|
+
target.setMonth(0, 1 + ((4 - target.getDay() + 7) % 7));
|
|
484
508
|
}
|
|
485
509
|
return 1 + Math.ceil((firstThursday - target.valueOf()) / 604800000);
|
|
486
510
|
}, []);
|
|
487
|
-
|
|
511
|
+
|
|
488
512
|
return {
|
|
489
513
|
// State
|
|
490
514
|
isOpen,
|
|
@@ -496,15 +520,15 @@ export function useDatePicker({
|
|
|
496
520
|
currentYear,
|
|
497
521
|
selectionMode,
|
|
498
522
|
rangeSelectionState,
|
|
499
|
-
|
|
523
|
+
|
|
500
524
|
// Refs
|
|
501
525
|
datePickerRef,
|
|
502
526
|
inputRef,
|
|
503
|
-
|
|
527
|
+
|
|
504
528
|
// Range state
|
|
505
529
|
startDate,
|
|
506
530
|
endDate,
|
|
507
|
-
|
|
531
|
+
|
|
508
532
|
// Action handlers
|
|
509
533
|
setIsOpen,
|
|
510
534
|
handleDateSelect,
|
|
@@ -516,18 +540,18 @@ export function useDatePicker({
|
|
|
516
540
|
handleClear,
|
|
517
541
|
handleInputChange,
|
|
518
542
|
handleInputFocus,
|
|
519
|
-
|
|
543
|
+
|
|
520
544
|
// View mode handlers
|
|
521
545
|
switchToMonthView,
|
|
522
546
|
switchToYearView,
|
|
523
547
|
selectMonth,
|
|
524
548
|
selectYear,
|
|
525
|
-
|
|
549
|
+
|
|
526
550
|
// Data generators
|
|
527
551
|
generateDays,
|
|
528
552
|
generateMonths,
|
|
529
553
|
generateYears,
|
|
530
|
-
|
|
554
|
+
|
|
531
555
|
// State checkers
|
|
532
556
|
isDateSelectable,
|
|
533
557
|
isDateSelected,
|
|
@@ -535,4 +559,4 @@ export function useDatePicker({
|
|
|
535
559
|
isToday,
|
|
536
560
|
getWeekNumber,
|
|
537
561
|
};
|
|
538
|
-
}
|
|
562
|
+
}
|