@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
|
@@ -46,34 +46,31 @@ export default {
|
|
|
46
46
|
} as Meta<typeof Popover>;
|
|
47
47
|
|
|
48
48
|
// Default template
|
|
49
|
-
const Template: StoryFn<typeof Popover> =
|
|
49
|
+
const Template: StoryFn<typeof Popover> = args => {
|
|
50
50
|
const selectOptions = [
|
|
51
51
|
{ value: '1', label: 'Option 1' },
|
|
52
52
|
{ value: '2', label: 'Option 2' },
|
|
53
53
|
{ value: '3', label: 'Option 3' },
|
|
54
54
|
{ value: '4', label: 'Option 4' },
|
|
55
55
|
];
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
const [selectedOption, setSelectedOption] = React.useState('1');
|
|
58
58
|
const [showInternalOnly, setShowInternalOnly] = React.useState(false);
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
const handleSelectChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
61
61
|
setSelectedOption(e.target.value);
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
const handleToggleChange = () => {
|
|
65
65
|
setShowInternalOnly(!showInternalOnly);
|
|
66
66
|
};
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
const content = (
|
|
69
69
|
<>
|
|
70
70
|
<div className="u-d-flex u-align-items-center u-gap-7">
|
|
71
71
|
<span className="u-text-nowrap">Sort by</span>
|
|
72
72
|
<div className="c-select">
|
|
73
|
-
<select
|
|
74
|
-
value={selectedOption}
|
|
75
|
-
onChange={handleSelectChange}
|
|
76
|
-
>
|
|
73
|
+
<select value={selectedOption} onChange={handleSelectChange}>
|
|
77
74
|
{selectOptions.map(option => (
|
|
78
75
|
<option key={option.value} value={option.value}>
|
|
79
76
|
{option.label}
|
|
@@ -88,9 +85,11 @@ const Template: StoryFn<typeof Popover> = (args) => {
|
|
|
88
85
|
</div>
|
|
89
86
|
</>
|
|
90
87
|
);
|
|
91
|
-
|
|
88
|
+
|
|
92
89
|
return (
|
|
93
|
-
<div
|
|
90
|
+
<div
|
|
91
|
+
style={{ padding: '80px', display: 'flex', justifyContent: 'center', background: '#f5f5f5' }}
|
|
92
|
+
>
|
|
94
93
|
<Popover {...args} content={content}>
|
|
95
94
|
<PopoverTrigger trigger={args.trigger}>
|
|
96
95
|
<Button variant="primary" label="Open Popover" />
|
|
@@ -141,4 +140,4 @@ AutoPosition.args = {
|
|
|
141
140
|
...Default.args,
|
|
142
141
|
position: 'auto',
|
|
143
142
|
defaultOpen: true, // Open by default to showcase auto-positioning
|
|
144
|
-
};
|
|
143
|
+
};
|
|
@@ -16,7 +16,7 @@ export const PopoverContext = createContext<{
|
|
|
16
16
|
setIsOpen: () => {},
|
|
17
17
|
triggerRef: { current: null },
|
|
18
18
|
popoverId: '',
|
|
19
|
-
triggerType: 'click'
|
|
19
|
+
triggerType: 'click',
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -45,7 +45,7 @@ export const Popover: React.FC<PopoverProps> = ({
|
|
|
45
45
|
arrowRef,
|
|
46
46
|
popoverId,
|
|
47
47
|
currentPosition,
|
|
48
|
-
updatePosition
|
|
48
|
+
updatePosition,
|
|
49
49
|
} = usePopover({
|
|
50
50
|
position,
|
|
51
51
|
trigger,
|
|
@@ -56,32 +56,31 @@ export const Popover: React.FC<PopoverProps> = ({
|
|
|
56
56
|
onOpenChange,
|
|
57
57
|
closeOnClickOutside,
|
|
58
58
|
closeOnEscape,
|
|
59
|
-
id
|
|
59
|
+
id,
|
|
60
60
|
});
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
return (
|
|
63
63
|
<PopoverContext.Provider
|
|
64
64
|
value={{ isOpen, setIsOpen, triggerRef, popoverId, triggerType: trigger }}
|
|
65
65
|
>
|
|
66
66
|
{children}
|
|
67
|
-
|
|
68
|
-
{typeof document !== 'undefined' &&
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
<div className="c-popover__content
|
|
78
|
-
{content}
|
|
67
|
+
|
|
68
|
+
{typeof document !== 'undefined' &&
|
|
69
|
+
createPortal(
|
|
70
|
+
<div
|
|
71
|
+
ref={popoverRef}
|
|
72
|
+
className={`c-popover c-popover--${currentPosition} ${isOpen ? POPOVER.CLASSES.IS_OPEN : ''} ${className}`}
|
|
73
|
+
id={popoverId}
|
|
74
|
+
role="tooltip"
|
|
75
|
+
aria-hidden={!isOpen}
|
|
76
|
+
>
|
|
77
|
+
<div className="c-popover__content">
|
|
78
|
+
<div className="c-popover__content-inner">{content}</div>
|
|
79
79
|
</div>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
)}
|
|
80
|
+
<div ref={arrowRef} className="c-popover__arrow"></div>
|
|
81
|
+
</div>,
|
|
82
|
+
document.body
|
|
83
|
+
)}
|
|
85
84
|
</PopoverContext.Provider>
|
|
86
85
|
);
|
|
87
86
|
};
|
|
@@ -89,49 +88,50 @@ export const Popover: React.FC<PopoverProps> = ({
|
|
|
89
88
|
/**
|
|
90
89
|
* PopoverTrigger component to wrap the element that triggers the popover
|
|
91
90
|
*/
|
|
92
|
-
export const PopoverTrigger: React.FC<PopoverTriggerProps> = forwardRef<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}, ref) => {
|
|
96
|
-
const { isOpen, setIsOpen, triggerRef, popoverId, triggerType } =
|
|
97
|
-
|
|
91
|
+
export const PopoverTrigger: React.FC<PopoverTriggerProps> = forwardRef<
|
|
92
|
+
HTMLElement,
|
|
93
|
+
PopoverTriggerProps
|
|
94
|
+
>(({ children, trigger: triggerProp }, ref) => {
|
|
95
|
+
const { isOpen, setIsOpen, triggerRef, popoverId, triggerType } =
|
|
96
|
+
React.useContext(PopoverContext);
|
|
97
|
+
|
|
98
98
|
// Determine which trigger type to use - prop from PopoverTrigger or from context
|
|
99
99
|
const effectiveTrigger = triggerProp || triggerType;
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
// Handle trigger events
|
|
102
102
|
const handleClick = () => {
|
|
103
103
|
setIsOpen(!isOpen);
|
|
104
104
|
};
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
const handleMouseEnter = () => {
|
|
107
107
|
setIsOpen(true);
|
|
108
108
|
};
|
|
109
|
-
|
|
109
|
+
|
|
110
110
|
const handleMouseLeave = () => {
|
|
111
111
|
setIsOpen(false);
|
|
112
112
|
};
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
// Clone the children element with additional props
|
|
115
115
|
const child = React.Children.only(children) as React.ReactElement;
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
const triggerProps: any = {
|
|
118
118
|
ref: ref || triggerRef,
|
|
119
119
|
'aria-describedby': popoverId,
|
|
120
120
|
'aria-expanded': isOpen,
|
|
121
121
|
};
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
if (effectiveTrigger === 'click') {
|
|
124
124
|
triggerProps.onClick = handleClick;
|
|
125
125
|
} else if (effectiveTrigger === 'hover') {
|
|
126
126
|
triggerProps.onMouseEnter = handleMouseEnter;
|
|
127
127
|
triggerProps.onMouseLeave = handleMouseLeave;
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
|
|
130
130
|
return React.cloneElement(child, triggerProps);
|
|
131
|
-
});
|
|
131
|
+
});
|
|
132
132
|
|
|
133
133
|
export type { PopoverProps, PopoverTriggerProps };
|
|
134
134
|
|
|
135
135
|
Popover.displayName = 'Popover';
|
|
136
136
|
|
|
137
|
-
export default Popover;
|
|
137
|
+
export default Popover;
|
|
@@ -2,4 +2,4 @@ import { Popover, PopoverTrigger } from './Popover';
|
|
|
2
2
|
import type { PopoverProps, PopoverTriggerProps } from '../../lib/types/components';
|
|
3
3
|
|
|
4
4
|
export { Popover, PopoverTrigger };
|
|
5
|
-
export type { PopoverProps, PopoverTriggerProps };
|
|
5
|
+
export type { PopoverProps, PopoverTriggerProps };
|
|
@@ -28,7 +28,7 @@ export const handleTriggerClick = (
|
|
|
28
28
|
event.preventDefault();
|
|
29
29
|
event.stopPropagation();
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
if (isOpen) {
|
|
33
33
|
close();
|
|
34
34
|
} else {
|
|
@@ -47,12 +47,9 @@ export const handleDocumentClick = (
|
|
|
47
47
|
event: MouseEvent
|
|
48
48
|
): void => {
|
|
49
49
|
if (!isOpen) return;
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
const target = event.target as Node;
|
|
52
|
-
if (
|
|
53
|
-
!element.contains(target) &&
|
|
54
|
-
trigger && !trigger.contains(target)
|
|
55
|
-
) {
|
|
52
|
+
if (!element.contains(target) && trigger && !trigger.contains(target)) {
|
|
56
53
|
close();
|
|
57
54
|
}
|
|
58
55
|
};
|
|
@@ -63,13 +60,13 @@ export const handleDocumentClick = (
|
|
|
63
60
|
export const handleTriggerMouseEnter = (
|
|
64
61
|
open: () => void,
|
|
65
62
|
delay: number,
|
|
66
|
-
timeoutRef: { current: number | null }
|
|
63
|
+
timeoutRef: { current: number | null }
|
|
67
64
|
): void => {
|
|
68
65
|
if (timeoutRef.current !== null) {
|
|
69
66
|
window.clearTimeout(timeoutRef.current);
|
|
70
67
|
timeoutRef.current = null;
|
|
71
68
|
}
|
|
72
|
-
|
|
69
|
+
|
|
73
70
|
if (delay > 0) {
|
|
74
71
|
timeoutRef.current = window.setTimeout(() => {
|
|
75
72
|
open();
|
|
@@ -85,13 +82,13 @@ export const handleTriggerMouseEnter = (
|
|
|
85
82
|
export const handleTriggerMouseLeave = (
|
|
86
83
|
element: HTMLElement,
|
|
87
84
|
close: () => void,
|
|
88
|
-
timeoutRef: { current: number | null }
|
|
85
|
+
timeoutRef: { current: number | null }
|
|
89
86
|
): void => {
|
|
90
87
|
if (timeoutRef.current !== null) {
|
|
91
88
|
window.clearTimeout(timeoutRef.current);
|
|
92
89
|
timeoutRef.current = null;
|
|
93
90
|
}
|
|
94
|
-
|
|
91
|
+
|
|
95
92
|
timeoutRef.current = window.setTimeout(() => {
|
|
96
93
|
if (!element.matches(':hover')) {
|
|
97
94
|
close();
|
|
@@ -102,11 +99,7 @@ export const handleTriggerMouseLeave = (
|
|
|
102
99
|
/**
|
|
103
100
|
* Handle escape key to close popover
|
|
104
101
|
*/
|
|
105
|
-
export const handleEscapeKey = (
|
|
106
|
-
isOpen: boolean,
|
|
107
|
-
close: () => void,
|
|
108
|
-
event: KeyboardEvent
|
|
109
|
-
): void => {
|
|
102
|
+
export const handleEscapeKey = (isOpen: boolean, close: () => void, event: KeyboardEvent): void => {
|
|
110
103
|
if (isOpen && event.key === 'Escape') {
|
|
111
104
|
close();
|
|
112
105
|
}
|
|
@@ -115,29 +108,27 @@ export const handleEscapeKey = (
|
|
|
115
108
|
/**
|
|
116
109
|
* Determine the best position based on available space
|
|
117
110
|
*/
|
|
118
|
-
export const determineBestPosition = (
|
|
119
|
-
triggerRect: DOMRect,
|
|
120
|
-
): PopoverPosition => {
|
|
111
|
+
export const determineBestPosition = (triggerRect: DOMRect): PopoverPosition => {
|
|
121
112
|
const viewportWidth = window.innerWidth;
|
|
122
113
|
const viewportHeight = window.innerHeight;
|
|
123
|
-
|
|
114
|
+
|
|
124
115
|
// Calculate space available in each direction
|
|
125
116
|
const spaceTop = triggerRect.top;
|
|
126
117
|
const spaceBottom = viewportHeight - triggerRect.bottom;
|
|
127
118
|
const spaceLeft = triggerRect.left;
|
|
128
119
|
const spaceRight = viewportWidth - triggerRect.right;
|
|
129
|
-
|
|
120
|
+
|
|
130
121
|
// Find position with most space
|
|
131
122
|
const spaces = [
|
|
132
123
|
{ position: 'top', space: spaceTop },
|
|
133
124
|
{ position: 'right', space: spaceRight },
|
|
134
125
|
{ position: 'bottom', space: spaceBottom },
|
|
135
|
-
{ position: 'left', space: spaceLeft }
|
|
126
|
+
{ position: 'left', space: spaceLeft },
|
|
136
127
|
];
|
|
137
|
-
|
|
128
|
+
|
|
138
129
|
// Sort by available space (descending)
|
|
139
130
|
spaces.sort((a, b) => b.space - a.space);
|
|
140
|
-
|
|
131
|
+
|
|
141
132
|
// Select position with most space
|
|
142
133
|
return spaces[0].position as PopoverPosition;
|
|
143
134
|
};
|
|
@@ -152,16 +143,16 @@ export const checkAndFlipPosition = (
|
|
|
152
143
|
offset: number
|
|
153
144
|
): PopoverPosition => {
|
|
154
145
|
if (position === 'auto') return 'top';
|
|
155
|
-
|
|
146
|
+
|
|
156
147
|
const viewportWidth = window.innerWidth;
|
|
157
148
|
const viewportHeight = window.innerHeight;
|
|
158
|
-
|
|
149
|
+
|
|
159
150
|
// Space available in each direction
|
|
160
151
|
const spaceTop = triggerRect.top;
|
|
161
152
|
const spaceBottom = viewportHeight - triggerRect.bottom;
|
|
162
153
|
const spaceLeft = triggerRect.left;
|
|
163
154
|
const spaceRight = viewportWidth - triggerRect.right;
|
|
164
|
-
|
|
155
|
+
|
|
165
156
|
// Check if preferred position has enough space, flip if not
|
|
166
157
|
switch (position) {
|
|
167
158
|
case 'top':
|
|
@@ -195,69 +186,66 @@ export const calculatePopoverPosition = (
|
|
|
195
186
|
popoverRect: DOMRect,
|
|
196
187
|
position: PopoverPosition,
|
|
197
188
|
offset: number
|
|
198
|
-
): { top: number
|
|
189
|
+
): { top: number; left: number } => {
|
|
199
190
|
let top = 0;
|
|
200
191
|
let left = 0;
|
|
201
|
-
|
|
192
|
+
|
|
202
193
|
// Calculate position based on the determined position
|
|
203
194
|
switch (position) {
|
|
204
195
|
case 'top':
|
|
205
196
|
top = triggerRect.top - popoverRect.height - offset;
|
|
206
|
-
left = triggerRect.left +
|
|
197
|
+
left = triggerRect.left + triggerRect.width / 2 - popoverRect.width / 2;
|
|
207
198
|
break;
|
|
208
199
|
case 'bottom':
|
|
209
200
|
top = triggerRect.bottom + offset;
|
|
210
|
-
left = triggerRect.left +
|
|
201
|
+
left = triggerRect.left + triggerRect.width / 2 - popoverRect.width / 2;
|
|
211
202
|
break;
|
|
212
203
|
case 'left':
|
|
213
|
-
top = triggerRect.top +
|
|
204
|
+
top = triggerRect.top + triggerRect.height / 2 - popoverRect.height / 2;
|
|
214
205
|
left = triggerRect.left - popoverRect.width - offset;
|
|
215
206
|
break;
|
|
216
207
|
case 'right':
|
|
217
|
-
top = triggerRect.top +
|
|
208
|
+
top = triggerRect.top + triggerRect.height / 2 - popoverRect.height / 2;
|
|
218
209
|
left = triggerRect.right + offset;
|
|
219
210
|
break;
|
|
220
211
|
}
|
|
221
|
-
|
|
212
|
+
|
|
222
213
|
// Constrain to viewport boundaries
|
|
223
214
|
const viewportWidth = window.innerWidth;
|
|
224
215
|
const viewportHeight = window.innerHeight;
|
|
225
|
-
|
|
216
|
+
|
|
226
217
|
if (left < 0) {
|
|
227
218
|
left = 5;
|
|
228
219
|
} else if (left + popoverRect.width > viewportWidth) {
|
|
229
220
|
left = viewportWidth - popoverRect.width - 5;
|
|
230
221
|
}
|
|
231
|
-
|
|
222
|
+
|
|
232
223
|
if (top < 0) {
|
|
233
224
|
top = 5;
|
|
234
225
|
} else if (top + popoverRect.height > viewportHeight) {
|
|
235
226
|
top = viewportHeight - popoverRect.height - 5;
|
|
236
227
|
}
|
|
237
|
-
|
|
228
|
+
|
|
238
229
|
// Add scroll position to convert viewport coordinates to absolute position
|
|
239
230
|
return {
|
|
240
231
|
top: top + window.scrollY,
|
|
241
|
-
left: left + window.scrollX
|
|
232
|
+
left: left + window.scrollX,
|
|
242
233
|
};
|
|
243
234
|
};
|
|
244
235
|
|
|
245
236
|
/**
|
|
246
237
|
* Position the arrow based on current position
|
|
247
238
|
*/
|
|
248
|
-
export const positionArrow = (
|
|
249
|
-
arrow: HTMLElement,
|
|
250
|
-
position: PopoverPosition
|
|
251
|
-
): void => {
|
|
239
|
+
export const positionArrow = (arrow: HTMLElement, position: PopoverPosition): void => {
|
|
252
240
|
if (!arrow) return;
|
|
253
|
-
|
|
241
|
+
|
|
254
242
|
// Reset arrow position
|
|
255
243
|
arrow.style.top = '';
|
|
256
244
|
arrow.style.right = '';
|
|
257
245
|
arrow.style.bottom = '';
|
|
258
246
|
arrow.style.left = '';
|
|
259
247
|
arrow.style.transform = '';
|
|
260
|
-
|
|
248
|
+
|
|
261
249
|
// Position arrow based on current position
|
|
262
250
|
switch (position) {
|
|
263
251
|
case 'top':
|
|
@@ -297,15 +285,15 @@ export const setPositionClass = (
|
|
|
297
285
|
element.classList.remove(className);
|
|
298
286
|
}
|
|
299
287
|
});
|
|
300
|
-
|
|
288
|
+
|
|
301
289
|
// Add the current position class
|
|
302
290
|
const positionClass = POPOVER.CLASSES[position.toUpperCase() as keyof typeof POPOVER.CLASSES];
|
|
303
291
|
if (positionClass) {
|
|
304
292
|
element.classList.add(positionClass);
|
|
305
293
|
}
|
|
306
|
-
|
|
294
|
+
|
|
307
295
|
// Add auto class if auto positioning is enabled
|
|
308
296
|
if (isAuto) {
|
|
309
297
|
element.classList.add(POPOVER.CLASSES.AUTO);
|
|
310
298
|
}
|
|
311
|
-
};
|
|
299
|
+
};
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
checkAndFlipPosition,
|
|
12
12
|
calculatePopoverPosition,
|
|
13
13
|
positionArrow,
|
|
14
|
-
setPositionClass
|
|
14
|
+
setPositionClass,
|
|
15
15
|
} from './componentInteractions';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -46,16 +46,17 @@ class Popover {
|
|
|
46
46
|
this.updateInterval = null;
|
|
47
47
|
this.timeoutRef = { current: null };
|
|
48
48
|
this.options = {
|
|
49
|
-
position: options.position || POPOVER.DEFAULTS.POSITION as PopoverPosition | 'auto',
|
|
50
|
-
trigger: options.trigger || POPOVER.DEFAULTS.TRIGGER as 'hover' | 'click',
|
|
49
|
+
position: options.position || (POPOVER.DEFAULTS.POSITION as PopoverPosition | 'auto'),
|
|
50
|
+
trigger: options.trigger || (POPOVER.DEFAULTS.TRIGGER as 'hover' | 'click'),
|
|
51
51
|
offset: options.offset !== undefined ? options.offset : POPOVER.DEFAULTS.OFFSET,
|
|
52
|
-
delay: options.delay !== undefined ? options.delay : POPOVER.DEFAULTS.DELAY
|
|
52
|
+
delay: options.delay !== undefined ? options.delay : POPOVER.DEFAULTS.DELAY,
|
|
53
53
|
};
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
// Initialize current position from options (will be recalculated if auto)
|
|
56
|
-
this.currentPosition =
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
this.currentPosition =
|
|
57
|
+
this.options.position === 'auto'
|
|
58
|
+
? 'top' // default fallback
|
|
59
|
+
: (this.options.position as PopoverPosition);
|
|
59
60
|
|
|
60
61
|
this._initialize();
|
|
61
62
|
}
|
|
@@ -68,28 +69,24 @@ class Popover {
|
|
|
68
69
|
this.trigger = document.querySelector(`[data-popover-id="${this.element.id}"]`);
|
|
69
70
|
this.content = this.element.querySelector(POPOVER.SELECTORS.CONTENT);
|
|
70
71
|
this.contentInner = this.element.querySelector(POPOVER.SELECTORS.CONTENT_INNER);
|
|
71
|
-
|
|
72
|
+
|
|
72
73
|
// Create arrow element if needed
|
|
73
74
|
this.arrow = document.createElement('div');
|
|
74
75
|
this.arrow.className = POPOVER.SELECTORS.ARROW.slice(1); // Remove leading dot
|
|
75
76
|
this.content?.appendChild(this.arrow);
|
|
76
|
-
|
|
77
|
+
|
|
77
78
|
// Set initial position class
|
|
78
79
|
this._setPositionClass();
|
|
79
|
-
|
|
80
|
+
|
|
80
81
|
// Bind events
|
|
81
82
|
this._bindEvents();
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
+
|
|
84
85
|
/**
|
|
85
86
|
* Set the position class on the element
|
|
86
87
|
*/
|
|
87
88
|
private _setPositionClass(): void {
|
|
88
|
-
setPositionClass(
|
|
89
|
-
this.element,
|
|
90
|
-
this.currentPosition,
|
|
91
|
-
this.options.position === 'auto'
|
|
92
|
-
);
|
|
89
|
+
setPositionClass(this.element, this.currentPosition, this.options.position === 'auto');
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
/**
|
|
@@ -97,7 +94,7 @@ class Popover {
|
|
|
97
94
|
*/
|
|
98
95
|
private _bindEvents(): void {
|
|
99
96
|
if (!this.trigger) return;
|
|
100
|
-
|
|
97
|
+
|
|
101
98
|
if (this.options.trigger === 'click') {
|
|
102
99
|
this.trigger.addEventListener('click', this._handleTriggerClick.bind(this));
|
|
103
100
|
document.addEventListener('click', this._handleDocumentClick.bind(this));
|
|
@@ -108,10 +105,10 @@ class Popover {
|
|
|
108
105
|
this.element.addEventListener('mouseenter', this._handlePopoverMouseEnter.bind(this));
|
|
109
106
|
this.element.addEventListener('mouseleave', this._handlePopoverMouseLeave.bind(this));
|
|
110
107
|
}
|
|
111
|
-
|
|
108
|
+
|
|
112
109
|
window.addEventListener('resize', this._updatePosition.bind(this));
|
|
113
110
|
window.addEventListener('scroll', this._updatePosition.bind(this), { passive: true });
|
|
114
|
-
|
|
111
|
+
|
|
115
112
|
// Also update position periodically to handle any dynamic content changes
|
|
116
113
|
this.updateInterval = window.setInterval(this._updatePosition.bind(this), 200);
|
|
117
114
|
}
|
|
@@ -173,11 +170,11 @@ class Popover {
|
|
|
173
170
|
*/
|
|
174
171
|
private _updatePosition(): void {
|
|
175
172
|
if (!this.isOpen || !this.trigger) return;
|
|
176
|
-
|
|
173
|
+
|
|
177
174
|
const triggerRect = this.trigger.getBoundingClientRect();
|
|
178
175
|
const popoverRect = this.element.getBoundingClientRect();
|
|
179
176
|
const offset = this.options.offset || 0;
|
|
180
|
-
|
|
177
|
+
|
|
181
178
|
// If auto positioning is enabled, determine best position
|
|
182
179
|
if (this.options.position === 'auto') {
|
|
183
180
|
this.currentPosition = determineBestPosition(triggerRect);
|
|
@@ -191,7 +188,7 @@ class Popover {
|
|
|
191
188
|
offset
|
|
192
189
|
);
|
|
193
190
|
}
|
|
194
|
-
|
|
191
|
+
|
|
195
192
|
// Calculate position
|
|
196
193
|
const { top, left } = calculatePopoverPosition(
|
|
197
194
|
triggerRect,
|
|
@@ -199,15 +196,15 @@ class Popover {
|
|
|
199
196
|
this.currentPosition,
|
|
200
197
|
offset
|
|
201
198
|
);
|
|
202
|
-
|
|
199
|
+
|
|
203
200
|
// Apply position using absolute positioning to follow when scrolling
|
|
204
201
|
this.element.style.position = 'absolute';
|
|
205
202
|
this.element.style.top = `${top}px`;
|
|
206
203
|
this.element.style.left = `${left}px`;
|
|
207
|
-
|
|
204
|
+
|
|
208
205
|
// Update position class and arrow
|
|
209
206
|
this._setPositionClass();
|
|
210
|
-
|
|
207
|
+
|
|
211
208
|
// Position arrow
|
|
212
209
|
if (this.arrow) {
|
|
213
210
|
positionArrow(this.arrow, this.currentPosition);
|
|
@@ -219,17 +216,19 @@ class Popover {
|
|
|
219
216
|
*/
|
|
220
217
|
public open(): void {
|
|
221
218
|
if (this.isOpen) return;
|
|
222
|
-
|
|
219
|
+
|
|
223
220
|
this.element.classList.add(POPOVER.CLASSES.IS_OPEN);
|
|
224
221
|
this.isOpen = true;
|
|
225
|
-
|
|
222
|
+
|
|
226
223
|
// Update position right away
|
|
227
224
|
this._updatePosition();
|
|
228
|
-
|
|
225
|
+
|
|
229
226
|
// Dispatch custom event
|
|
230
|
-
this.element.dispatchEvent(
|
|
231
|
-
|
|
232
|
-
|
|
227
|
+
this.element.dispatchEvent(
|
|
228
|
+
new CustomEvent('popover:open', {
|
|
229
|
+
bubbles: true,
|
|
230
|
+
})
|
|
231
|
+
);
|
|
233
232
|
}
|
|
234
233
|
|
|
235
234
|
/**
|
|
@@ -237,14 +236,16 @@ class Popover {
|
|
|
237
236
|
*/
|
|
238
237
|
public close(): void {
|
|
239
238
|
if (!this.isOpen) return;
|
|
240
|
-
|
|
239
|
+
|
|
241
240
|
this.element.classList.remove(POPOVER.CLASSES.IS_OPEN);
|
|
242
241
|
this.isOpen = false;
|
|
243
|
-
|
|
242
|
+
|
|
244
243
|
// Dispatch custom event
|
|
245
|
-
this.element.dispatchEvent(
|
|
246
|
-
|
|
247
|
-
|
|
244
|
+
this.element.dispatchEvent(
|
|
245
|
+
new CustomEvent('popover:close', {
|
|
246
|
+
bubbles: true,
|
|
247
|
+
})
|
|
248
|
+
);
|
|
248
249
|
}
|
|
249
250
|
|
|
250
251
|
/**
|
|
@@ -270,24 +271,24 @@ class Popover {
|
|
|
270
271
|
this.trigger.removeEventListener('mouseleave', this._handleTriggerMouseLeave);
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
|
-
|
|
274
|
+
|
|
274
275
|
document.removeEventListener('click', this._handleDocumentClick);
|
|
275
276
|
document.removeEventListener('keydown', this._handleEscapeKey);
|
|
276
|
-
|
|
277
|
+
|
|
277
278
|
this.element.removeEventListener('mouseenter', this._handlePopoverMouseEnter);
|
|
278
279
|
this.element.removeEventListener('mouseleave', this._handlePopoverMouseLeave);
|
|
279
|
-
|
|
280
|
+
|
|
280
281
|
window.removeEventListener('resize', this._updatePosition);
|
|
281
282
|
window.removeEventListener('scroll', this._updatePosition);
|
|
282
|
-
|
|
283
|
+
|
|
283
284
|
if (this.timeout !== null) {
|
|
284
285
|
window.clearTimeout(this.timeout);
|
|
285
286
|
}
|
|
286
|
-
|
|
287
|
+
|
|
287
288
|
if (this.timeoutRef.current !== null) {
|
|
288
289
|
window.clearTimeout(this.timeoutRef.current);
|
|
289
290
|
}
|
|
290
|
-
|
|
291
|
+
|
|
291
292
|
if (this.updateInterval !== null) {
|
|
292
293
|
window.clearInterval(this.updateInterval);
|
|
293
294
|
}
|
|
@@ -299,21 +300,31 @@ class Popover {
|
|
|
299
300
|
*/
|
|
300
301
|
const initPopovers = (): void => {
|
|
301
302
|
const popovers = document.querySelectorAll(POPOVER.SELECTORS.POPOVER);
|
|
302
|
-
|
|
303
|
+
|
|
303
304
|
popovers.forEach((element: Element) => {
|
|
304
305
|
const popover = element as HTMLElement;
|
|
305
306
|
// Get configuration from data attributes
|
|
306
|
-
const position =
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
|
|
307
|
+
const position =
|
|
308
|
+
(popover.getAttribute(POPOVER.ATTRIBUTES.POSITION) as PopoverPosition | 'auto') ||
|
|
309
|
+
POPOVER.DEFAULTS.POSITION;
|
|
310
|
+
const trigger =
|
|
311
|
+
(popover.getAttribute(POPOVER.ATTRIBUTES.TRIGGER) as 'hover' | 'click') ||
|
|
312
|
+
POPOVER.DEFAULTS.TRIGGER;
|
|
313
|
+
const offset = parseInt(
|
|
314
|
+
popover.getAttribute('data-popover-offset') || String(POPOVER.DEFAULTS.OFFSET),
|
|
315
|
+
10
|
|
316
|
+
);
|
|
317
|
+
const delay = parseInt(
|
|
318
|
+
popover.getAttribute('data-popover-delay') || String(POPOVER.DEFAULTS.DELAY),
|
|
319
|
+
10
|
|
320
|
+
);
|
|
321
|
+
|
|
311
322
|
// Initialize popover
|
|
312
|
-
new Popover(popover, {
|
|
323
|
+
new Popover(popover, {
|
|
313
324
|
position: position as PopoverPosition | 'auto',
|
|
314
325
|
trigger: trigger as 'hover' | 'click',
|
|
315
|
-
offset,
|
|
316
|
-
delay
|
|
326
|
+
offset,
|
|
327
|
+
delay,
|
|
317
328
|
});
|
|
318
329
|
});
|
|
319
330
|
};
|
|
@@ -328,4 +339,4 @@ if (typeof document !== 'undefined') {
|
|
|
328
339
|
}
|
|
329
340
|
|
|
330
341
|
export default Popover;
|
|
331
|
-
export { initPopovers };
|
|
342
|
+
export { initPopovers };
|