@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,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getMonthName,
|
|
3
|
-
getDaysInMonth,
|
|
4
|
-
getFirstDayOfMonth,
|
|
5
|
-
formatDate,
|
|
1
|
+
import {
|
|
2
|
+
getMonthName,
|
|
3
|
+
getDaysInMonth,
|
|
4
|
+
getFirstDayOfMonth,
|
|
5
|
+
formatDate,
|
|
6
6
|
parseDate,
|
|
7
|
-
isDateInRange
|
|
7
|
+
isDateInRange,
|
|
8
8
|
} from '../utils';
|
|
9
9
|
import { createPhosphorIcon } from '../../../lib/utils/icons';
|
|
10
10
|
|
|
@@ -38,7 +38,8 @@ export default class DatePicker {
|
|
|
38
38
|
* @param options - Configuration options
|
|
39
39
|
*/
|
|
40
40
|
constructor(element: string | HTMLElement, options: any = {}) {
|
|
41
|
-
this.element =
|
|
41
|
+
this.element =
|
|
42
|
+
typeof element === 'string' ? (document.querySelector(element) as HTMLElement) : element;
|
|
42
43
|
if (!this.element) {
|
|
43
44
|
throw new Error('DatePicker: Element not found');
|
|
44
45
|
}
|
|
@@ -67,10 +68,12 @@ export default class DatePicker {
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
// Dispatch init event
|
|
70
|
-
this.element.dispatchEvent(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
this.element.dispatchEvent(
|
|
72
|
+
new CustomEvent('datepicker:init', {
|
|
73
|
+
bubbles: true,
|
|
74
|
+
detail: { instance: this },
|
|
75
|
+
})
|
|
76
|
+
);
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
/**
|
|
@@ -87,7 +90,7 @@ export default class DatePicker {
|
|
|
87
90
|
private _bindEvents(): void {
|
|
88
91
|
if (this.input && !this.options.inline) {
|
|
89
92
|
// Input focus
|
|
90
|
-
this.eventListeners.inputFocus =
|
|
93
|
+
this.eventListeners.inputFocus = e => {
|
|
91
94
|
if (!this.options.disabled && !this.options.readOnly) {
|
|
92
95
|
this._showCalendar();
|
|
93
96
|
}
|
|
@@ -95,7 +98,7 @@ export default class DatePicker {
|
|
|
95
98
|
this.input.addEventListener('focus', this.eventListeners.inputFocus);
|
|
96
99
|
|
|
97
100
|
// Input change
|
|
98
|
-
this.eventListeners.inputChange =
|
|
101
|
+
this.eventListeners.inputChange = e => {
|
|
99
102
|
const value = (e.target as HTMLInputElement).value;
|
|
100
103
|
const date = parseDate(value, this.options.format);
|
|
101
104
|
if (date) {
|
|
@@ -104,10 +107,12 @@ export default class DatePicker {
|
|
|
104
107
|
this._updateCalendar();
|
|
105
108
|
|
|
106
109
|
// Dispatch change event
|
|
107
|
-
this.element.dispatchEvent(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
this.element.dispatchEvent(
|
|
111
|
+
new CustomEvent('datepicker:change', {
|
|
112
|
+
bubbles: true,
|
|
113
|
+
detail: { date: this.selectedDate },
|
|
114
|
+
})
|
|
115
|
+
);
|
|
111
116
|
}
|
|
112
117
|
};
|
|
113
118
|
this.input.addEventListener('input', this.eventListeners.inputChange);
|
|
@@ -115,14 +120,10 @@ export default class DatePicker {
|
|
|
115
120
|
|
|
116
121
|
// Document click (for click outside)
|
|
117
122
|
if (!this.options.inline) {
|
|
118
|
-
this.eventListeners.documentClick =
|
|
123
|
+
this.eventListeners.documentClick = e => {
|
|
119
124
|
if (this.isOpen) {
|
|
120
125
|
const target = e.target as Node;
|
|
121
|
-
if (
|
|
122
|
-
!this.element.contains(target) &&
|
|
123
|
-
this.calendar &&
|
|
124
|
-
!this.calendar.contains(target)
|
|
125
|
-
) {
|
|
126
|
+
if (!this.element.contains(target) && this.calendar && !this.calendar.contains(target)) {
|
|
126
127
|
this._hideCalendar();
|
|
127
128
|
}
|
|
128
129
|
}
|
|
@@ -143,7 +144,7 @@ export default class DatePicker {
|
|
|
143
144
|
this.calendar.className = `c-datepicker__calendar c-datepicker__calendar--${this.options.placement}`;
|
|
144
145
|
this.calendar.setAttribute('role', 'dialog');
|
|
145
146
|
this.calendar.setAttribute('aria-label', 'Date picker');
|
|
146
|
-
|
|
147
|
+
|
|
147
148
|
if (this.options.inline) {
|
|
148
149
|
this.element.appendChild(this.calendar);
|
|
149
150
|
} else {
|
|
@@ -151,15 +152,15 @@ export default class DatePicker {
|
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
// Add event delegation for calendar interactions
|
|
154
|
-
this.eventListeners.calendarClick =
|
|
155
|
+
this.eventListeners.calendarClick = e => {
|
|
155
156
|
const target = e.target as HTMLElement;
|
|
156
|
-
|
|
157
|
+
|
|
157
158
|
// Day selection
|
|
158
159
|
if (target.matches('.c-datepicker__day') && !(target as HTMLButtonElement).disabled) {
|
|
159
160
|
const day = parseInt(target.textContent || '0', 10);
|
|
160
161
|
this._selectDate(day);
|
|
161
162
|
}
|
|
162
|
-
|
|
163
|
+
|
|
163
164
|
// Navigation buttons
|
|
164
165
|
if (target.closest('.c-datepicker__nav-button--prev-month')) {
|
|
165
166
|
this._prevMonth();
|
|
@@ -173,7 +174,7 @@ export default class DatePicker {
|
|
|
173
174
|
if (target.closest('.c-datepicker__nav-button--next-year')) {
|
|
174
175
|
this._nextYear();
|
|
175
176
|
}
|
|
176
|
-
|
|
177
|
+
|
|
177
178
|
// View mode switches
|
|
178
179
|
if (target.closest('.c-datepicker__view-switch')) {
|
|
179
180
|
if (this.viewMode === 'days') {
|
|
@@ -182,7 +183,7 @@ export default class DatePicker {
|
|
|
182
183
|
this._switchToYearView();
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
|
-
|
|
186
|
+
|
|
186
187
|
// Month selection
|
|
187
188
|
if (target.matches('.c-datepicker__month')) {
|
|
188
189
|
const monthIndex = Array.from(target.parentElement?.children || []).indexOf(target);
|
|
@@ -190,32 +191,32 @@ export default class DatePicker {
|
|
|
190
191
|
this._selectMonth(monthIndex);
|
|
191
192
|
}
|
|
192
193
|
}
|
|
193
|
-
|
|
194
|
+
|
|
194
195
|
// Year selection
|
|
195
196
|
if (target.matches('.c-datepicker__year')) {
|
|
196
197
|
const year = parseInt(target.textContent || '0', 10);
|
|
197
198
|
this._selectYear(year);
|
|
198
199
|
}
|
|
199
|
-
|
|
200
|
+
|
|
200
201
|
// Today button
|
|
201
202
|
if (target.closest('.c-datepicker__today-button')) {
|
|
202
203
|
this._goToToday();
|
|
203
204
|
}
|
|
204
|
-
|
|
205
|
+
|
|
205
206
|
// Close button
|
|
206
207
|
if (target.closest('.c-datepicker__close-button')) {
|
|
207
208
|
this._hideCalendar();
|
|
208
209
|
}
|
|
209
|
-
|
|
210
|
+
|
|
210
211
|
// Clear button
|
|
211
212
|
if (target.closest('.c-datepicker__clear-button')) {
|
|
212
213
|
this._clearDate();
|
|
213
214
|
}
|
|
214
215
|
};
|
|
215
|
-
|
|
216
|
+
|
|
216
217
|
this.calendar.addEventListener('click', this.eventListeners.calendarClick);
|
|
217
218
|
}
|
|
218
|
-
|
|
219
|
+
|
|
219
220
|
this._updateCalendar();
|
|
220
221
|
}
|
|
221
222
|
|
|
@@ -224,15 +225,15 @@ export default class DatePicker {
|
|
|
224
225
|
*/
|
|
225
226
|
private _updateCalendar(): void {
|
|
226
227
|
if (!this.calendar) return;
|
|
227
|
-
|
|
228
|
+
|
|
228
229
|
const currentMonth = this.viewDate.getMonth();
|
|
229
230
|
const currentYear = this.viewDate.getFullYear();
|
|
230
|
-
|
|
231
|
+
|
|
231
232
|
let content = '';
|
|
232
|
-
|
|
233
|
+
|
|
233
234
|
// Calendar header
|
|
234
235
|
content += `<div class="c-datepicker__header">`;
|
|
235
|
-
|
|
236
|
+
|
|
236
237
|
if (this.viewMode === 'days') {
|
|
237
238
|
content += `
|
|
238
239
|
<button type="button" class="c-datepicker__nav-button c-datepicker__nav-button--prev-year" aria-label="Previous year">
|
|
@@ -266,7 +267,7 @@ export default class DatePicker {
|
|
|
266
267
|
} else if (this.viewMode === 'years') {
|
|
267
268
|
const startYear = currentYear - 6;
|
|
268
269
|
const endYear = currentYear + 5;
|
|
269
|
-
|
|
270
|
+
|
|
270
271
|
content += `
|
|
271
272
|
<button type="button" class="c-datepicker__nav-button c-datepicker__nav-button--prev-year" aria-label="Previous year range">
|
|
272
273
|
${createPhosphorIcon('CaretLeft', 16)}
|
|
@@ -279,58 +280,60 @@ export default class DatePicker {
|
|
|
279
280
|
</button>
|
|
280
281
|
`;
|
|
281
282
|
}
|
|
282
|
-
|
|
283
|
+
|
|
283
284
|
content += `</div>`;
|
|
284
|
-
|
|
285
|
+
|
|
285
286
|
// Calendar body
|
|
286
287
|
content += `<div class="c-datepicker__body">`;
|
|
287
|
-
|
|
288
|
+
|
|
288
289
|
if (this.viewMode === 'days') {
|
|
289
290
|
// Weekday headers
|
|
290
291
|
content += `<div class="c-datepicker__weekdays" role="row">`;
|
|
291
|
-
|
|
292
|
+
|
|
292
293
|
if (this.options.showWeekNumbers) {
|
|
293
294
|
content += `<div class="c-datepicker__weekday c-datepicker__weeknumber" role="columnheader">#</div>`;
|
|
294
295
|
}
|
|
295
|
-
|
|
296
|
+
|
|
296
297
|
const weekdays = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
297
298
|
weekdays.forEach(day => {
|
|
298
299
|
content += `<div class="c-datepicker__weekday" role="columnheader">${day}</div>`;
|
|
299
300
|
});
|
|
300
|
-
|
|
301
|
+
|
|
301
302
|
content += `</div>`;
|
|
302
|
-
|
|
303
|
+
|
|
303
304
|
// Days grid
|
|
304
305
|
content += `<div class="c-datepicker__days" role="grid">`;
|
|
305
|
-
|
|
306
|
+
|
|
306
307
|
const days = this._generateDays();
|
|
307
308
|
const today = new Date();
|
|
308
|
-
|
|
309
|
+
|
|
309
310
|
days.forEach((dateObj, index) => {
|
|
310
311
|
const isSelectable = this._isDateSelectable(dateObj.year, dateObj.month, dateObj.day);
|
|
311
312
|
const isSelected = this._isDateSelected(dateObj.year, dateObj.month, dateObj.day);
|
|
312
313
|
const isTodayDate = this._isToday(dateObj.year, dateObj.month, dateObj.day, today);
|
|
313
314
|
const dateValue = new Date(dateObj.year, dateObj.month, dateObj.day);
|
|
314
|
-
|
|
315
|
+
|
|
315
316
|
// Add week number if enabled
|
|
316
317
|
if (this.options.showWeekNumbers && index % 7 === 0) {
|
|
317
318
|
const weekNum = this._getWeekNumber(dateValue);
|
|
318
|
-
|
|
319
|
+
|
|
319
320
|
content += `
|
|
320
321
|
<div class="c-datepicker__weeknumber" aria-label="Week ${weekNum}">
|
|
321
322
|
${weekNum}
|
|
322
323
|
</div>
|
|
323
324
|
`;
|
|
324
325
|
}
|
|
325
|
-
|
|
326
|
+
|
|
326
327
|
const dayClasses = [
|
|
327
328
|
'c-datepicker__day',
|
|
328
329
|
!dateObj.isCurrentMonth ? 'c-datepicker__day--outside' : '',
|
|
329
330
|
isSelected ? 'c-datepicker__day--selected' : '',
|
|
330
331
|
isTodayDate ? 'c-datepicker__day--today' : '',
|
|
331
|
-
!isSelectable ? 'c-datepicker__day--disabled' : ''
|
|
332
|
-
]
|
|
333
|
-
|
|
332
|
+
!isSelectable ? 'c-datepicker__day--disabled' : '',
|
|
333
|
+
]
|
|
334
|
+
.filter(Boolean)
|
|
335
|
+
.join(' ');
|
|
336
|
+
|
|
334
337
|
content += `
|
|
335
338
|
<button
|
|
336
339
|
type="button"
|
|
@@ -345,18 +348,19 @@ export default class DatePicker {
|
|
|
345
348
|
</button>
|
|
346
349
|
`;
|
|
347
350
|
});
|
|
348
|
-
|
|
351
|
+
|
|
349
352
|
content += `</div>`;
|
|
350
353
|
} else if (this.viewMode === 'months') {
|
|
351
354
|
// Months grid
|
|
352
355
|
content += `<div class="c-datepicker__months" role="grid">`;
|
|
353
|
-
|
|
356
|
+
|
|
354
357
|
for (let i = 0; i < 12; i++) {
|
|
355
358
|
const monthName = getMonthName(i).substring(0, 3);
|
|
356
|
-
const isSelected =
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
359
|
+
const isSelected =
|
|
360
|
+
this.selectedDate &&
|
|
361
|
+
this.selectedDate.getMonth() === i &&
|
|
362
|
+
this.selectedDate.getFullYear() === currentYear;
|
|
363
|
+
|
|
360
364
|
content += `
|
|
361
365
|
<button
|
|
362
366
|
type="button"
|
|
@@ -368,17 +372,17 @@ export default class DatePicker {
|
|
|
368
372
|
</button>
|
|
369
373
|
`;
|
|
370
374
|
}
|
|
371
|
-
|
|
375
|
+
|
|
372
376
|
content += `</div>`;
|
|
373
377
|
} else if (this.viewMode === 'years') {
|
|
374
378
|
// Years grid
|
|
375
379
|
content += `<div class="c-datepicker__years" role="grid">`;
|
|
376
|
-
|
|
380
|
+
|
|
377
381
|
const startYear = currentYear - 6;
|
|
378
382
|
for (let i = 0; i < 12; i++) {
|
|
379
383
|
const year = startYear + i;
|
|
380
384
|
const isSelected = this.selectedDate && this.selectedDate.getFullYear() === year;
|
|
381
|
-
|
|
385
|
+
|
|
382
386
|
content += `
|
|
383
387
|
<button
|
|
384
388
|
type="button"
|
|
@@ -390,16 +394,16 @@ export default class DatePicker {
|
|
|
390
394
|
</button>
|
|
391
395
|
`;
|
|
392
396
|
}
|
|
393
|
-
|
|
397
|
+
|
|
394
398
|
content += `</div>`;
|
|
395
399
|
}
|
|
396
|
-
|
|
400
|
+
|
|
397
401
|
content += `</div>`;
|
|
398
|
-
|
|
402
|
+
|
|
399
403
|
// Calendar footer (only for days view)
|
|
400
404
|
if (this.viewMode === 'days') {
|
|
401
405
|
content += `<div class="c-datepicker__footer">`;
|
|
402
|
-
|
|
406
|
+
|
|
403
407
|
if (this.options.showTodayButton) {
|
|
404
408
|
content += `
|
|
405
409
|
<button
|
|
@@ -411,7 +415,7 @@ export default class DatePicker {
|
|
|
411
415
|
</button>
|
|
412
416
|
`;
|
|
413
417
|
}
|
|
414
|
-
|
|
418
|
+
|
|
415
419
|
if (!this.options.inline) {
|
|
416
420
|
content += `
|
|
417
421
|
<button
|
|
@@ -423,12 +427,12 @@ export default class DatePicker {
|
|
|
423
427
|
</button>
|
|
424
428
|
`;
|
|
425
429
|
}
|
|
426
|
-
|
|
430
|
+
|
|
427
431
|
content += `</div>`;
|
|
428
432
|
}
|
|
429
|
-
|
|
433
|
+
|
|
430
434
|
this.calendar.innerHTML = content;
|
|
431
|
-
|
|
435
|
+
|
|
432
436
|
if (!this.options.inline) {
|
|
433
437
|
this._positionCalendar();
|
|
434
438
|
}
|
|
@@ -437,39 +441,44 @@ export default class DatePicker {
|
|
|
437
441
|
/**
|
|
438
442
|
* Generate an array of date objects for the current month view
|
|
439
443
|
*/
|
|
440
|
-
private _generateDays(): Array<{
|
|
444
|
+
private _generateDays(): Array<{
|
|
445
|
+
day: number;
|
|
446
|
+
month: number;
|
|
447
|
+
year: number;
|
|
448
|
+
isCurrentMonth: boolean;
|
|
449
|
+
}> {
|
|
441
450
|
const currentMonth = this.viewDate.getMonth();
|
|
442
451
|
const currentYear = this.viewDate.getFullYear();
|
|
443
452
|
const daysInMonth = getDaysInMonth(currentYear, currentMonth);
|
|
444
453
|
const firstDayOfMonth = getFirstDayOfMonth(currentYear, currentMonth);
|
|
445
|
-
|
|
454
|
+
|
|
446
455
|
const days = [];
|
|
447
|
-
|
|
456
|
+
|
|
448
457
|
// Previous month days
|
|
449
458
|
const prevMonthDays = getDaysInMonth(
|
|
450
459
|
currentMonth === 0 ? currentYear - 1 : currentYear,
|
|
451
460
|
currentMonth === 0 ? 11 : currentMonth - 1
|
|
452
461
|
);
|
|
453
|
-
|
|
462
|
+
|
|
454
463
|
for (let i = firstDayOfMonth - 1; i >= 0; i--) {
|
|
455
464
|
days.push({
|
|
456
465
|
day: prevMonthDays - i,
|
|
457
466
|
month: currentMonth === 0 ? 11 : currentMonth - 1,
|
|
458
467
|
year: currentMonth === 0 ? currentYear - 1 : currentYear,
|
|
459
|
-
isCurrentMonth: false
|
|
468
|
+
isCurrentMonth: false,
|
|
460
469
|
});
|
|
461
470
|
}
|
|
462
|
-
|
|
471
|
+
|
|
463
472
|
// Current month days
|
|
464
473
|
for (let i = 1; i <= daysInMonth; i++) {
|
|
465
474
|
days.push({
|
|
466
475
|
day: i,
|
|
467
476
|
month: currentMonth,
|
|
468
477
|
year: currentYear,
|
|
469
|
-
isCurrentMonth: true
|
|
478
|
+
isCurrentMonth: true,
|
|
470
479
|
});
|
|
471
480
|
}
|
|
472
|
-
|
|
481
|
+
|
|
473
482
|
// Next month days
|
|
474
483
|
const remainingDays = 42 - days.length;
|
|
475
484
|
for (let i = 1; i <= remainingDays; i++) {
|
|
@@ -477,10 +486,10 @@ export default class DatePicker {
|
|
|
477
486
|
day: i,
|
|
478
487
|
month: currentMonth === 11 ? 0 : currentMonth + 1,
|
|
479
488
|
year: currentMonth === 11 ? currentYear + 1 : currentYear,
|
|
480
|
-
isCurrentMonth: false
|
|
489
|
+
isCurrentMonth: false,
|
|
481
490
|
});
|
|
482
491
|
}
|
|
483
|
-
|
|
492
|
+
|
|
484
493
|
return days;
|
|
485
494
|
}
|
|
486
495
|
|
|
@@ -489,22 +498,24 @@ export default class DatePicker {
|
|
|
489
498
|
*/
|
|
490
499
|
private _showCalendar(): void {
|
|
491
500
|
if (this.isOpen) return;
|
|
492
|
-
|
|
501
|
+
|
|
493
502
|
this.isOpen = true;
|
|
494
|
-
|
|
503
|
+
|
|
495
504
|
if (this.calendar) {
|
|
496
505
|
if (!this.options.inline) {
|
|
497
506
|
document.body.appendChild(this.calendar);
|
|
498
507
|
this._positionCalendar();
|
|
499
508
|
}
|
|
500
|
-
|
|
509
|
+
|
|
501
510
|
this.calendar.classList.add('is-open');
|
|
502
|
-
|
|
511
|
+
|
|
503
512
|
// Dispatch open event
|
|
504
|
-
this.element.dispatchEvent(
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
513
|
+
this.element.dispatchEvent(
|
|
514
|
+
new CustomEvent('datepicker:open', {
|
|
515
|
+
bubbles: true,
|
|
516
|
+
detail: { instance: this },
|
|
517
|
+
})
|
|
518
|
+
);
|
|
508
519
|
}
|
|
509
520
|
}
|
|
510
521
|
|
|
@@ -513,21 +524,23 @@ export default class DatePicker {
|
|
|
513
524
|
*/
|
|
514
525
|
private _hideCalendar(): void {
|
|
515
526
|
if (!this.isOpen || this.options.inline) return;
|
|
516
|
-
|
|
527
|
+
|
|
517
528
|
this.isOpen = false;
|
|
518
|
-
|
|
529
|
+
|
|
519
530
|
if (this.calendar) {
|
|
520
531
|
this.calendar.classList.remove('is-open');
|
|
521
|
-
|
|
532
|
+
|
|
522
533
|
if (!this.options.inline && this.calendar.parentNode) {
|
|
523
534
|
document.body.removeChild(this.calendar);
|
|
524
535
|
}
|
|
525
|
-
|
|
536
|
+
|
|
526
537
|
// Dispatch close event
|
|
527
|
-
this.element.dispatchEvent(
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
538
|
+
this.element.dispatchEvent(
|
|
539
|
+
new CustomEvent('datepicker:close', {
|
|
540
|
+
bubbles: true,
|
|
541
|
+
detail: { instance: this },
|
|
542
|
+
})
|
|
543
|
+
);
|
|
531
544
|
}
|
|
532
545
|
}
|
|
533
546
|
|
|
@@ -536,14 +549,14 @@ export default class DatePicker {
|
|
|
536
549
|
*/
|
|
537
550
|
private _positionCalendar(): void {
|
|
538
551
|
if (!this.calendar || !this.input) return;
|
|
539
|
-
|
|
552
|
+
|
|
540
553
|
const inputRect = this.input.getBoundingClientRect();
|
|
541
554
|
const calendarRect = this.calendar.getBoundingClientRect();
|
|
542
555
|
const scrollTop = window.scrollY || document.documentElement.scrollTop;
|
|
543
556
|
const scrollLeft = window.scrollX || document.documentElement.scrollLeft;
|
|
544
|
-
|
|
557
|
+
|
|
545
558
|
let top, left;
|
|
546
|
-
|
|
559
|
+
|
|
547
560
|
// Base position calculation on placement option
|
|
548
561
|
switch (this.options.placement) {
|
|
549
562
|
case 'top-start':
|
|
@@ -564,29 +577,29 @@ export default class DatePicker {
|
|
|
564
577
|
left = inputRect.left + scrollLeft;
|
|
565
578
|
break;
|
|
566
579
|
}
|
|
567
|
-
|
|
580
|
+
|
|
568
581
|
// Ensure the calendar stays within viewport
|
|
569
582
|
const viewport = {
|
|
570
583
|
width: window.innerWidth,
|
|
571
|
-
height: window.innerHeight
|
|
584
|
+
height: window.innerHeight,
|
|
572
585
|
};
|
|
573
|
-
|
|
586
|
+
|
|
574
587
|
if (left + calendarRect.width > viewport.width) {
|
|
575
588
|
left = viewport.width - calendarRect.width;
|
|
576
589
|
}
|
|
577
|
-
|
|
590
|
+
|
|
578
591
|
if (left < 0) {
|
|
579
592
|
left = 0;
|
|
580
593
|
}
|
|
581
|
-
|
|
594
|
+
|
|
582
595
|
if (top + calendarRect.height > viewport.height) {
|
|
583
596
|
top = inputRect.top - calendarRect.height + scrollTop;
|
|
584
597
|
}
|
|
585
|
-
|
|
598
|
+
|
|
586
599
|
if (top < 0) {
|
|
587
600
|
top = inputRect.bottom + scrollTop;
|
|
588
601
|
}
|
|
589
|
-
|
|
602
|
+
|
|
590
603
|
this.calendar.style.top = `${top}px`;
|
|
591
604
|
this.calendar.style.left = `${left}px`;
|
|
592
605
|
}
|
|
@@ -599,30 +612,32 @@ export default class DatePicker {
|
|
|
599
612
|
const month = this.viewDate.getMonth();
|
|
600
613
|
const year = this.viewDate.getFullYear();
|
|
601
614
|
const newDate = new Date(year, month, day);
|
|
602
|
-
|
|
615
|
+
|
|
603
616
|
if (this.options.minDate && newDate < this.options.minDate) return;
|
|
604
617
|
if (this.options.maxDate && newDate > this.options.maxDate) return;
|
|
605
|
-
|
|
618
|
+
|
|
606
619
|
this.selectedDate = newDate;
|
|
607
|
-
|
|
620
|
+
|
|
608
621
|
// Update input value
|
|
609
622
|
if (this.input) {
|
|
610
623
|
this.input.value = formatDate(newDate, this.options.format);
|
|
611
624
|
}
|
|
612
|
-
|
|
625
|
+
|
|
613
626
|
// Update calendar UI
|
|
614
627
|
this._updateCalendar();
|
|
615
|
-
|
|
628
|
+
|
|
616
629
|
// Close calendar if not inline
|
|
617
630
|
if (!this.options.inline) {
|
|
618
631
|
this._hideCalendar();
|
|
619
632
|
}
|
|
620
|
-
|
|
633
|
+
|
|
621
634
|
// Dispatch change event
|
|
622
|
-
this.element.dispatchEvent(
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
635
|
+
this.element.dispatchEvent(
|
|
636
|
+
new CustomEvent('datepicker:change', {
|
|
637
|
+
bubbles: true,
|
|
638
|
+
detail: { date: this.selectedDate },
|
|
639
|
+
})
|
|
640
|
+
);
|
|
626
641
|
}
|
|
627
642
|
|
|
628
643
|
/**
|
|
@@ -631,7 +646,7 @@ export default class DatePicker {
|
|
|
631
646
|
private _prevMonth(): void {
|
|
632
647
|
const month = this.viewDate.getMonth();
|
|
633
648
|
const year = this.viewDate.getFullYear();
|
|
634
|
-
|
|
649
|
+
|
|
635
650
|
this.viewDate = new Date(year, month - 1, 1);
|
|
636
651
|
this._updateCalendar();
|
|
637
652
|
}
|
|
@@ -642,7 +657,7 @@ export default class DatePicker {
|
|
|
642
657
|
private _nextMonth(): void {
|
|
643
658
|
const month = this.viewDate.getMonth();
|
|
644
659
|
const year = this.viewDate.getFullYear();
|
|
645
|
-
|
|
660
|
+
|
|
646
661
|
this.viewDate = new Date(year, month + 1, 1);
|
|
647
662
|
this._updateCalendar();
|
|
648
663
|
}
|
|
@@ -653,7 +668,7 @@ export default class DatePicker {
|
|
|
653
668
|
private _prevYear(): void {
|
|
654
669
|
const month = this.viewDate.getMonth();
|
|
655
670
|
const year = this.viewDate.getFullYear();
|
|
656
|
-
|
|
671
|
+
|
|
657
672
|
this.viewDate = new Date(year - 1, month, 1);
|
|
658
673
|
this._updateCalendar();
|
|
659
674
|
}
|
|
@@ -664,7 +679,7 @@ export default class DatePicker {
|
|
|
664
679
|
private _nextYear(): void {
|
|
665
680
|
const month = this.viewDate.getMonth();
|
|
666
681
|
const year = this.viewDate.getFullYear();
|
|
667
|
-
|
|
682
|
+
|
|
668
683
|
this.viewDate = new Date(year + 1, month, 1);
|
|
669
684
|
this._updateCalendar();
|
|
670
685
|
}
|
|
@@ -691,7 +706,7 @@ export default class DatePicker {
|
|
|
691
706
|
*/
|
|
692
707
|
private _selectMonth(month: number): void {
|
|
693
708
|
const year = this.viewDate.getFullYear();
|
|
694
|
-
|
|
709
|
+
|
|
695
710
|
this.viewDate = new Date(year, month, 1);
|
|
696
711
|
this.viewMode = 'days';
|
|
697
712
|
this._updateCalendar();
|
|
@@ -703,7 +718,7 @@ export default class DatePicker {
|
|
|
703
718
|
*/
|
|
704
719
|
private _selectYear(year: number): void {
|
|
705
720
|
const month = this.viewDate.getMonth();
|
|
706
|
-
|
|
721
|
+
|
|
707
722
|
this.viewDate = new Date(year, month, 1);
|
|
708
723
|
this.viewMode = 'months';
|
|
709
724
|
this._updateCalendar();
|
|
@@ -723,18 +738,20 @@ export default class DatePicker {
|
|
|
723
738
|
*/
|
|
724
739
|
private _clearDate(): void {
|
|
725
740
|
this.selectedDate = null;
|
|
726
|
-
|
|
741
|
+
|
|
727
742
|
if (this.input) {
|
|
728
743
|
this.input.value = '';
|
|
729
744
|
}
|
|
730
|
-
|
|
745
|
+
|
|
731
746
|
this._updateCalendar();
|
|
732
|
-
|
|
747
|
+
|
|
733
748
|
// Dispatch change event
|
|
734
|
-
this.element.dispatchEvent(
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
749
|
+
this.element.dispatchEvent(
|
|
750
|
+
new CustomEvent('datepicker:change', {
|
|
751
|
+
bubbles: true,
|
|
752
|
+
detail: { date: null },
|
|
753
|
+
})
|
|
754
|
+
);
|
|
738
755
|
}
|
|
739
756
|
|
|
740
757
|
/**
|
|
@@ -750,7 +767,7 @@ export default class DatePicker {
|
|
|
750
767
|
*/
|
|
751
768
|
private _isDateSelected(year: number, month: number, day: number): boolean {
|
|
752
769
|
if (!this.selectedDate) return false;
|
|
753
|
-
|
|
770
|
+
|
|
754
771
|
return (
|
|
755
772
|
this.selectedDate.getFullYear() === year &&
|
|
756
773
|
this.selectedDate.getMonth() === month &&
|
|
@@ -762,11 +779,7 @@ export default class DatePicker {
|
|
|
762
779
|
* Check if a date is today
|
|
763
780
|
*/
|
|
764
781
|
private _isToday(year: number, month: number, day: number, today: Date): boolean {
|
|
765
|
-
return (
|
|
766
|
-
today.getFullYear() === year &&
|
|
767
|
-
today.getMonth() === month &&
|
|
768
|
-
today.getDate() === day
|
|
769
|
-
);
|
|
782
|
+
return today.getFullYear() === year && today.getMonth() === month && today.getDate() === day;
|
|
770
783
|
}
|
|
771
784
|
|
|
772
785
|
/**
|
|
@@ -779,7 +792,7 @@ export default class DatePicker {
|
|
|
779
792
|
const firstThursday = target.valueOf();
|
|
780
793
|
target.setMonth(0, 1);
|
|
781
794
|
if (target.getDay() !== 4) {
|
|
782
|
-
target.setMonth(0, 1 + ((4 - target.getDay()
|
|
795
|
+
target.setMonth(0, 1 + ((4 - target.getDay() + 7) % 7));
|
|
783
796
|
}
|
|
784
797
|
return 1 + Math.ceil((firstThursday - target.valueOf()) / 604800000);
|
|
785
798
|
}
|
|
@@ -795,21 +808,23 @@ export default class DatePicker {
|
|
|
795
808
|
this._clearDate();
|
|
796
809
|
return;
|
|
797
810
|
}
|
|
798
|
-
|
|
811
|
+
|
|
799
812
|
this.selectedDate = date;
|
|
800
813
|
this.viewDate = new Date(date.getFullYear(), date.getMonth(), 1);
|
|
801
|
-
|
|
814
|
+
|
|
802
815
|
if (this.input) {
|
|
803
816
|
this.input.value = formatDate(date, this.options.format);
|
|
804
817
|
}
|
|
805
|
-
|
|
818
|
+
|
|
806
819
|
this._updateCalendar();
|
|
807
|
-
|
|
820
|
+
|
|
808
821
|
// Dispatch change event
|
|
809
|
-
this.element.dispatchEvent(
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
822
|
+
this.element.dispatchEvent(
|
|
823
|
+
new CustomEvent('datepicker:change', {
|
|
824
|
+
bubbles: true,
|
|
825
|
+
detail: { date },
|
|
826
|
+
})
|
|
827
|
+
);
|
|
813
828
|
}
|
|
814
829
|
|
|
815
830
|
/**
|
|
@@ -858,30 +873,35 @@ export default class DatePicker {
|
|
|
858
873
|
this.input.removeEventListener('focus', this.eventListeners.inputFocus);
|
|
859
874
|
this.input.removeEventListener('input', this.eventListeners.inputChange);
|
|
860
875
|
}
|
|
861
|
-
|
|
876
|
+
|
|
862
877
|
document.removeEventListener('click', this.eventListeners.documentClick);
|
|
863
|
-
|
|
878
|
+
|
|
864
879
|
if (this.calendar) {
|
|
865
880
|
this.calendar.removeEventListener('click', this.eventListeners.calendarClick);
|
|
866
|
-
|
|
881
|
+
|
|
867
882
|
// Remove calendar from DOM
|
|
868
883
|
if (this.calendar.parentNode) {
|
|
869
884
|
this.calendar.parentNode.removeChild(this.calendar);
|
|
870
885
|
}
|
|
871
886
|
}
|
|
872
|
-
|
|
887
|
+
|
|
873
888
|
// Dispatch destroy event
|
|
874
|
-
this.element.dispatchEvent(
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
889
|
+
this.element.dispatchEvent(
|
|
890
|
+
new CustomEvent('datepicker:destroy', {
|
|
891
|
+
bubbles: true,
|
|
892
|
+
detail: { instance: this },
|
|
893
|
+
})
|
|
894
|
+
);
|
|
878
895
|
}
|
|
879
896
|
|
|
880
897
|
/**
|
|
881
898
|
* Initialize all datepickers in the document
|
|
882
899
|
*/
|
|
883
|
-
public static initializeAll(
|
|
900
|
+
public static initializeAll(
|
|
901
|
+
selector: string = '[data-datepicker]',
|
|
902
|
+
options: any = {}
|
|
903
|
+
): DatePicker[] {
|
|
884
904
|
const elements = document.querySelectorAll(selector);
|
|
885
905
|
return Array.from(elements).map(element => new DatePicker(element as HTMLElement, options));
|
|
886
906
|
}
|
|
887
|
-
}
|
|
907
|
+
}
|