@shohojdhara/atomix 0.1.30 → 0.2.1
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/CHANGELOG.md +0 -0
- package/LICENSE +0 -0
- package/README.md +151 -39
- package/dist/atomix.css +13529 -0
- package/dist/atomix.min.css +15 -0
- package/dist/index.d.ts +6112 -1757
- package/dist/index.esm.js +16852 -8364
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16892 -8369
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/themes/boomdevs.css +13241 -0
- package/dist/themes/boomdevs.min.css +353 -0
- package/dist/themes/esrar.css +15374 -0
- package/dist/themes/esrar.min.css +189 -0
- package/dist/themes/mashroom.css +28079 -0
- package/dist/themes/mashroom.min.css +403 -0
- package/dist/themes/shaj-default.css +14203 -0
- package/dist/themes/shaj-default.min.css +500 -0
- package/dist/themes/yabai.css +13711 -0
- package/dist/themes/yabai.min.css +189 -0
- package/package.json +126 -99
- package/src/components/Accordion/Accordion.stories.tsx +271 -0
- package/src/components/Accordion/Accordion.tsx +131 -0
- package/src/components/Accordion/index.ts +3 -0
- package/src/components/AtomixLogo/AtomixLogo.tsx +36 -0
- package/src/components/AtomixLogo/index.ts +3 -0
- package/src/components/AtomixLogo.tsx +40 -0
- package/src/components/Avatar/Avatar.stories.tsx +257 -0
- package/src/components/Avatar/Avatar.tsx +68 -0
- package/src/components/Avatar/AvatarGroup.tsx +73 -0
- package/src/components/Avatar/index.ts +3 -0
- package/src/components/Badge/Badge.stories.tsx +371 -0
- package/src/components/Badge/Badge.tsx +39 -0
- package/src/components/Badge/index.ts +3 -0
- package/src/components/Block/Block.stories.tsx +408 -0
- package/src/components/Block/Block.tsx +137 -0
- package/src/components/Block/index.ts +1 -0
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +106 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +112 -0
- package/src/components/Breadcrumb/index.ts +3 -0
- package/src/components/Button/Button.stories.tsx +312 -0
- package/src/components/Button/Button.tsx +69 -0
- package/src/components/Button/index.ts +3 -0
- package/src/components/Callout/Callout.stories.tsx +588 -0
- package/src/components/Callout/Callout.tsx +78 -0
- package/src/components/Callout/index.ts +1 -0
- package/src/components/Card/Card.stories.tsx +105 -0
- package/src/components/Card/Card.tsx +69 -0
- package/src/components/Card/ElevationCard.tsx +47 -0
- package/src/components/Card/index.ts +15 -0
- package/src/components/Chart/AdvancedChart.tsx +624 -0
- package/src/components/Chart/AnimatedChart.tsx +206 -0
- package/src/components/Chart/AreaChart.tsx +27 -0
- package/src/components/Chart/BarChart.tsx +148 -0
- package/src/components/Chart/BubbleChart.tsx +411 -0
- package/src/components/Chart/CandlestickChart.tsx +765 -0
- package/src/components/Chart/Chart.stories.tsx +527 -0
- package/src/components/Chart/Chart.tsx +218 -0
- package/src/components/Chart/ChartRenderer.tsx +322 -0
- package/src/components/Chart/ChartToolbar.tsx +436 -0
- package/src/components/Chart/ChartTooltip.tsx +101 -0
- package/src/components/Chart/DonutChart.tsx +370 -0
- package/src/components/Chart/FunnelChart.tsx +393 -0
- package/src/components/Chart/GaugeChart.tsx +550 -0
- package/src/components/Chart/HeatmapChart.tsx +614 -0
- package/src/components/Chart/LineChart.tsx +172 -0
- package/src/components/Chart/LineChartNew.tsx +167 -0
- package/src/components/Chart/MultiAxisChart.tsx +498 -0
- package/src/components/Chart/PieChart.tsx +103 -0
- package/src/components/Chart/RadarChart.tsx +332 -0
- package/src/components/Chart/RealTimeChart.tsx +436 -0
- package/src/components/Chart/ScatterChart.tsx +152 -0
- package/src/components/Chart/TreemapChart.tsx +574 -0
- package/src/components/Chart/WaterfallChart.tsx +450 -0
- package/src/components/Chart/index.ts +119 -0
- package/src/components/Chart/types.ts +338 -0
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +44 -0
- package/src/components/ColorModeToggle/ColorModeToggle.tsx +85 -0
- package/src/components/ColorModeToggle/index.ts +2 -0
- package/src/components/Countdown/Countdown.stories.tsx +46 -0
- package/src/components/Countdown/Countdown.tsx +90 -0
- package/src/components/Countdown/index.ts +2 -0
- package/src/components/DataTable/DataTable.stories.tsx +248 -0
- package/src/components/DataTable/DataTable.tsx +213 -0
- package/src/components/DataTable/index.ts +3 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +364 -0
- package/src/components/DatePicker/DatePicker.tsx +504 -0
- package/src/components/DatePicker/index.ts +4 -0
- package/src/components/DatePicker/readme.md +106 -0
- package/src/components/DatePicker/types.ts +167 -0
- package/src/components/DatePicker/utils.ts +185 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +358 -0
- package/src/components/Dropdown/Dropdown.tsx +352 -0
- package/src/components/Dropdown/index.ts +14 -0
- package/src/components/Dropdown/readme.md +151 -0
- package/src/components/EdgePanel/EdgePanel.stories.tsx +266 -0
- package/src/components/EdgePanel/EdgePanel.tsx +73 -0
- package/src/components/EdgePanel/index.ts +1 -0
- package/src/components/Form/Checkbox.stories.tsx +76 -0
- package/src/components/Form/Checkbox.tsx +69 -0
- package/src/components/Form/Form.stories.tsx +497 -0
- package/src/components/Form/Form.tsx +46 -0
- package/src/components/Form/FormGroup.stories.tsx +162 -0
- package/src/components/Form/FormGroup.tsx +53 -0
- package/src/components/Form/Input.stories.tsx +106 -0
- package/src/components/Form/Input.tsx +87 -0
- package/src/components/Form/Radio.stories.tsx +94 -0
- package/src/components/Form/Radio.tsx +65 -0
- package/src/components/Form/Select.stories.tsx +151 -0
- package/src/components/Form/Select.tsx +191 -0
- package/src/components/Form/Textarea.stories.tsx +123 -0
- package/src/components/Form/Textarea.tsx +78 -0
- package/src/components/Form/index.ts +7 -0
- package/src/components/Hero/Hero.stories.tsx +295 -0
- package/src/components/Hero/Hero.tsx +175 -0
- package/src/components/Hero/index.ts +6 -0
- package/src/components/Icon/Icon.tsx +87 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/List/List.stories.tsx +122 -0
- package/src/components/List/List.tsx +35 -0
- package/src/components/List/ListGroup.tsx +35 -0
- package/src/components/List/index.ts +2 -0
- package/src/components/Messages/Messages.stories.tsx +160 -0
- package/src/components/Messages/Messages.tsx +172 -0
- package/src/components/Messages/index.ts +3 -0
- package/src/components/Modal/Modal.stories.tsx +284 -0
- package/src/components/Modal/Modal.tsx +198 -0
- package/src/components/Modal/README.md +169 -0
- package/src/components/Modal/index.ts +1 -0
- package/src/components/Navigation/Menu/MegaMenu.tsx +109 -0
- package/src/components/Navigation/Menu/Menu.stories.tsx +339 -0
- package/src/components/Navigation/Menu/Menu.tsx +111 -0
- package/src/components/Navigation/Nav/Nav.stories.tsx +456 -0
- package/src/components/Navigation/Nav/Nav.tsx +51 -0
- package/src/components/Navigation/Nav/NavDropdown.tsx +105 -0
- package/src/components/Navigation/Nav/NavItem.tsx +168 -0
- package/src/components/Navigation/Navbar/Navbar.stories.tsx +569 -0
- 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 +609 -0
- package/src/components/Navigation/SideMenu/SideMenu.tsx +101 -0
- package/src/components/Navigation/SideMenu/SideMenuItem.tsx +103 -0
- package/src/components/Navigation/SideMenu/SideMenuList.tsx +41 -0
- package/src/components/Navigation/index.ts +23 -0
- package/src/components/Pagination/Pagination.stories.tsx +188 -0
- package/src/components/Pagination/Pagination.tsx +162 -0
- package/src/components/Pagination/index.ts +1 -0
- package/src/components/PhotoViewer/PhotoViewer.stories.tsx +397 -0
- package/src/components/PhotoViewer/PhotoViewer.tsx +246 -0
- package/src/components/PhotoViewer/PhotoViewerHeader.tsx +184 -0
- package/src/components/PhotoViewer/PhotoViewerImage.tsx +173 -0
- package/src/components/PhotoViewer/PhotoViewerInfo.tsx +91 -0
- package/src/components/PhotoViewer/PhotoViewerNavigation.tsx +85 -0
- package/src/components/PhotoViewer/PhotoViewerThumbnails.tsx +63 -0
- package/src/components/PhotoViewer/README.md +358 -0
- package/src/components/PhotoViewer/examples/ImageGallery.tsx +187 -0
- package/src/components/PhotoViewer/examples/SimpleGallery.tsx +73 -0
- package/src/components/PhotoViewer/examples/index.ts +2 -0
- package/src/components/PhotoViewer/index.ts +14 -0
- package/src/components/Popover/Popover.stories.tsx +143 -0
- package/src/components/Popover/Popover.tsx +137 -0
- package/src/components/Popover/index.ts +5 -0
- package/src/components/Popover/readme.md +120 -0
- package/src/components/ProductReview/ProductReview.stories.tsx +88 -0
- package/src/components/ProductReview/ProductReview.tsx +169 -0
- package/src/components/ProductReview/index.ts +3 -0
- package/src/components/Progress/Progress.stories.tsx +75 -0
- package/src/components/Progress/Progress.tsx +45 -0
- package/src/components/Progress/index.ts +1 -0
- package/src/components/Rating/Rating.stories.tsx +109 -0
- package/src/components/Rating/Rating.tsx +286 -0
- package/src/components/Rating/index.ts +6 -0
- package/src/components/River/River.stories.tsx +230 -0
- package/src/components/River/River.tsx +134 -0
- package/src/components/River/index.ts +2 -0
- package/src/components/SectionIntro/SectionIntro.stories.tsx +143 -0
- package/src/components/SectionIntro/SectionIntro.tsx +184 -0
- package/src/components/SectionIntro/index.ts +3 -0
- package/src/components/Slider/Slider.stories.tsx +241 -0
- package/src/components/Slider/Slider.tsx +225 -0
- package/src/components/Slider/index.ts +24 -0
- package/src/components/Spinner/Spinner.stories.tsx +65 -0
- package/src/components/Spinner/Spinner.tsx +36 -0
- package/src/components/Spinner/index.ts +2 -0
- package/src/components/Steps/Steps.stories.tsx +158 -0
- package/src/components/Steps/Steps.tsx +115 -0
- package/src/components/Steps/index.ts +3 -0
- package/src/components/Tab/Tab.stories.tsx +129 -0
- package/src/components/Tab/Tab.tsx +111 -0
- package/src/components/Tab/index.ts +2 -0
- package/src/components/Testimonial/Testimonial.stories.tsx +180 -0
- package/src/components/Testimonial/Testimonial.tsx +138 -0
- package/src/components/Testimonial/index.ts +3 -0
- package/src/components/Todo/Todo.stories.tsx +103 -0
- package/src/components/Todo/Todo.tsx +158 -0
- package/src/components/Todo/index.ts +1 -0
- package/src/components/Toggle/Toggle.stories.tsx +49 -0
- package/src/components/Toggle/Toggle.tsx +84 -0
- package/src/components/Toggle/index.ts +2 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +115 -0
- package/src/components/Tooltip/Tooltip.tsx +150 -0
- package/src/components/Tooltip/index.ts +3 -0
- package/src/components/Upload/Upload.stories.tsx +220 -0
- package/src/components/Upload/Upload.tsx +354 -0
- package/src/components/Upload/index.ts +3 -0
- package/src/components/VideoPlayer/VideoPlayer.stories.tsx +484 -0
- package/src/components/VideoPlayer/VideoPlayer.tsx +574 -0
- package/src/components/VideoPlayer/index.ts +7 -0
- package/src/components/index.ts +111 -0
- package/src/layouts/Grid/Container.tsx +58 -0
- package/src/layouts/Grid/Grid.stories.tsx +861 -0
- package/src/layouts/Grid/Grid.tsx +68 -0
- package/src/layouts/Grid/GridCol.tsx +161 -0
- package/src/layouts/Grid/README.md +108 -0
- package/src/layouts/Grid/Row.tsx +70 -0
- package/src/layouts/Grid/index.ts +8 -0
- package/src/layouts/MasonryGrid/MasonryGrid.stories.tsx +387 -0
- package/src/layouts/MasonryGrid/MasonryGrid.tsx +408 -0
- package/src/layouts/MasonryGrid/MasonryGridItem.tsx +44 -0
- package/src/layouts/MasonryGrid/README.md +117 -0
- package/src/layouts/MasonryGrid/index.ts +4 -0
- package/src/layouts/index.ts +7 -0
- package/src/lib/README.md +89 -0
- package/src/lib/composables/index.ts +63 -0
- package/src/lib/composables/useAccordion.ts +129 -0
- package/src/lib/composables/useAmbientMode.ts +90 -0
- package/src/lib/composables/useBadge.ts +42 -0
- package/src/lib/composables/useBarChart.ts +365 -0
- package/src/lib/composables/useBlock.ts +56 -0
- package/src/lib/composables/useBreadcrumb.ts +81 -0
- package/src/lib/composables/useButton.ts +59 -0
- package/src/lib/composables/useCallout.ts +55 -0
- package/src/lib/composables/useCard.ts +155 -0
- package/src/lib/composables/useChart.ts +1082 -0
- package/src/lib/composables/useChartAnalytics.ts +505 -0
- package/src/lib/composables/useChartData.ts +38 -0
- package/src/lib/composables/useChartExport.ts +392 -0
- package/src/lib/composables/useChartInteraction.ts +34 -0
- package/src/lib/composables/useChartInteractions.ts +123 -0
- package/src/lib/composables/useChartPerformance.ts +323 -0
- package/src/lib/composables/useChartScale.ts +48 -0
- package/src/lib/composables/useChartToolbar.ts +532 -0
- package/src/lib/composables/useCheckbox.ts +70 -0
- package/src/lib/composables/useDataTable.ts +208 -0
- package/src/lib/composables/useDatePicker.ts +564 -0
- package/src/lib/composables/useDropdown.ts +272 -0
- package/src/lib/composables/useEdgePanel.ts +261 -0
- package/src/lib/composables/useForm.ts +62 -0
- package/src/lib/composables/useFormGroup.ts +51 -0
- package/src/lib/composables/useHero.ts +250 -0
- package/src/lib/composables/useInput.ts +58 -0
- package/src/lib/composables/useLineChart.ts +319 -0
- package/src/lib/composables/useMessages.ts +77 -0
- package/src/lib/composables/useModal.ts +110 -0
- package/src/lib/composables/useNavbar.ts +288 -0
- package/src/lib/composables/usePagination.ts +101 -0
- package/src/lib/composables/usePhotoViewer.ts +937 -0
- package/src/lib/composables/usePieChart.ts +362 -0
- package/src/lib/composables/usePopover.ts +354 -0
- package/src/lib/composables/useProgress.ts +74 -0
- package/src/lib/composables/useRadio.ts +47 -0
- package/src/lib/composables/useRating.ts +174 -0
- package/src/lib/composables/useRiver.ts +205 -0
- package/src/lib/composables/useSelect.ts +52 -0
- package/src/lib/composables/useSideMenu.ts +197 -0
- package/src/lib/composables/useSlider.ts +339 -0
- package/src/lib/composables/useSpinner.ts +42 -0
- package/src/lib/composables/useTextarea.ts +55 -0
- package/src/lib/composables/useTodo.ts +141 -0
- package/src/lib/composables/useVideoPlayer.ts +398 -0
- package/src/lib/constants/components.ts +1433 -0
- package/src/lib/constants/index.ts +4 -0
- package/src/lib/index.ts +11 -0
- package/src/lib/types/components.ts +4750 -0
- package/src/lib/types/index.ts +2 -0
- package/src/lib/utils/dom.ts +41 -0
- package/src/lib/utils/icons.ts +74 -0
- package/src/lib/utils/index.ts +55 -0
- package/src/lib/utils/useForkRef.test.tsx +64 -0
- package/src/lib/utils/useForkRef.ts +36 -0
- package/src/lib/utils.test.ts +14 -0
- package/src/styles/01-settings/_index.scss +2 -0
- package/src/styles/01-settings/_settings.accordion.scss +7 -5
- package/src/styles/01-settings/_settings.animations.scss +0 -0
- package/src/styles/01-settings/_settings.avatar-group.scss +6 -3
- package/src/styles/01-settings/_settings.avatar.scss +2 -2
- package/src/styles/01-settings/_settings.badge.scss +15 -9
- package/src/styles/01-settings/_settings.block.scss +11 -0
- package/src/styles/01-settings/_settings.border-radius.scss +12 -9
- package/src/styles/01-settings/_settings.border.scss +4 -1
- package/src/styles/01-settings/_settings.box-shadow.scss +1 -1
- package/src/styles/01-settings/_settings.breadcrumb.scss +9 -8
- package/src/styles/01-settings/_settings.breakpoints.scss +0 -0
- package/src/styles/01-settings/_settings.btn-group.scss +4 -1
- package/src/styles/01-settings/_settings.button.scss +19 -21
- package/src/styles/01-settings/_settings.callout.scss +42 -24
- package/src/styles/01-settings/_settings.card.scss +12 -10
- package/src/styles/01-settings/_settings.chart.scss +199 -0
- package/src/styles/01-settings/_settings.checkbox-group.scss +0 -0
- package/src/styles/01-settings/_settings.checkbox.scss +0 -0
- package/src/styles/01-settings/_settings.color-mode.scss +0 -0
- package/src/styles/01-settings/_settings.colors.scss +20 -0
- package/src/styles/01-settings/_settings.config.scss +1 -1
- package/src/styles/01-settings/_settings.countdown.scss +0 -0
- package/src/styles/01-settings/_settings.data-table.scss +0 -0
- package/src/styles/01-settings/_settings.datepicker.scss +0 -0
- package/src/styles/01-settings/_settings.dropdown.scss +0 -0
- package/src/styles/01-settings/_settings.edge-panel.scss +0 -0
- package/src/styles/01-settings/_settings.fonts.scss +1 -1
- package/src/styles/01-settings/_settings.form-group.scss +0 -0
- package/src/styles/01-settings/_settings.form.scss +0 -0
- package/src/styles/01-settings/_settings.grid.scss +3 -3
- package/src/styles/01-settings/_settings.hero.scss +1 -1
- package/src/styles/01-settings/_settings.input.scss +1 -1
- package/src/styles/01-settings/_settings.link.scss +0 -0
- package/src/styles/01-settings/_settings.list-group.scss +0 -0
- package/src/styles/01-settings/_settings.list.scss +0 -0
- package/src/styles/01-settings/_settings.maps.scss +43 -8
- package/src/styles/01-settings/_settings.masonry-grid.scss +0 -0
- package/src/styles/01-settings/_settings.menu.scss +0 -0
- package/src/styles/01-settings/_settings.messages.scss +0 -0
- package/src/styles/01-settings/_settings.modal.scss +1 -1
- package/src/styles/01-settings/_settings.nav.scss +0 -0
- package/src/styles/01-settings/_settings.navbar.scss +0 -0
- package/src/styles/01-settings/_settings.pagination.scss +0 -0
- package/src/styles/01-settings/_settings.photoviewer.scss +89 -23
- package/src/styles/01-settings/_settings.popover.scss +0 -0
- package/src/styles/01-settings/_settings.position.scss +0 -0
- package/src/styles/01-settings/_settings.progress.scss +0 -0
- package/src/styles/01-settings/_settings.rating.scss +0 -0
- package/src/styles/01-settings/_settings.river.scss +0 -0
- package/src/styles/01-settings/_settings.sectionintro.scss +0 -0
- package/src/styles/01-settings/_settings.select.scss +0 -0
- package/src/styles/01-settings/_settings.side-menu.scss +0 -0
- package/src/styles/01-settings/_settings.skeleton.scss +0 -0
- package/src/styles/01-settings/_settings.slider.scss +59 -0
- package/src/styles/01-settings/_settings.spacing.scss +11 -3
- package/src/styles/01-settings/_settings.spinner.scss +0 -0
- package/src/styles/01-settings/_settings.steps.scss +1 -1
- package/src/styles/01-settings/_settings.tabs.scss +4 -4
- package/src/styles/01-settings/_settings.testimonials.scss +0 -0
- package/src/styles/01-settings/_settings.todo.scss +0 -0
- package/src/styles/01-settings/_settings.toggle.scss +1 -1
- package/src/styles/01-settings/_settings.tooltip.scss +0 -0
- package/src/styles/01-settings/_settings.typography.scss +2 -0
- package/src/styles/01-settings/_settings.upload.scss +0 -0
- package/src/styles/01-settings/_settings.video-player.scss +64 -0
- package/src/styles/01-settings/_settings.z-layers.scss +0 -0
- package/src/styles/02-tools/_index.scss +1 -0
- package/src/styles/02-tools/_tools.animations.scss +82 -0
- package/src/styles/02-tools/_tools.border-radius.scss +0 -0
- package/src/styles/02-tools/_tools.breakpoints.scss +0 -0
- package/src/styles/02-tools/_tools.button.scss +5 -0
- package/src/styles/02-tools/_tools.clearfix.scss +0 -0
- package/src/styles/02-tools/_tools.color-functions.scss +0 -0
- package/src/styles/02-tools/_tools.color-mode.scss +1 -1
- package/src/styles/02-tools/_tools.component.scss +479 -0
- package/src/styles/02-tools/_tools.event.scss +0 -0
- package/src/styles/02-tools/_tools.grid.scss +0 -0
- package/src/styles/02-tools/_tools.hidden-visually.scss +0 -0
- package/src/styles/02-tools/_tools.hidden.scss +0 -0
- package/src/styles/02-tools/_tools.map-loop.scss +0 -0
- package/src/styles/02-tools/_tools.media-queries.scss +0 -0
- package/src/styles/02-tools/_tools.object-fit.scss +0 -0
- package/src/styles/02-tools/_tools.placeholder.scss +0 -0
- package/src/styles/02-tools/_tools.rem.scss +5 -1
- package/src/styles/02-tools/_tools.size.scss +0 -0
- package/src/styles/02-tools/_tools.spacing.scss +0 -0
- package/src/styles/02-tools/_tools.to-rgb.scss +0 -0
- package/src/styles/02-tools/_tools.transition.scss +0 -0
- package/src/styles/02-tools/_tools.utilities.scss +0 -0
- package/src/styles/02-tools/_tools.utility-api.scss +23 -2
- package/src/styles/03-generic/_generic.fonts.scss +0 -0
- package/src/styles/03-generic/_generic.reset.scss +0 -0
- package/src/styles/03-generic/_generic.root.scss +5 -1
- package/src/styles/03-generic/_generic.selection.scss +0 -0
- package/src/styles/03-generic/_index.scss +0 -0
- package/src/styles/04-elements/_elements.all.scss +0 -0
- package/src/styles/04-elements/_elements.body.scss +0 -0
- package/src/styles/04-elements/_elements.heading.scss +0 -0
- package/src/styles/04-elements/_elements.html.scss +0 -0
- package/src/styles/04-elements/_elements.links.scss +0 -0
- package/src/styles/04-elements/_index.scss +0 -0
- package/src/styles/05-objects/_index.scss +1 -0
- package/src/styles/05-objects/_objects.block.scss +122 -0
- package/src/styles/05-objects/_objects.container.scss +14 -10
- package/src/styles/05-objects/_objects.grid.scss +0 -0
- package/src/styles/05-objects/_objects.masonry-grid.scss +0 -0
- package/src/styles/06-components/_components.accordion.scss +3 -1
- package/src/styles/06-components/_components.avatar-group.scss +0 -0
- package/src/styles/06-components/_components.avatar.scss +0 -0
- package/src/styles/06-components/_components.badge.scss +9 -9
- package/src/styles/06-components/_components.breadcrumb.scss +0 -0
- package/src/styles/06-components/_components.btn-group.scss +0 -0
- package/src/styles/06-components/_components.button.scss +0 -0
- package/src/styles/06-components/_components.callout.scss +2 -1
- package/src/styles/06-components/_components.card.scss +0 -1
- package/src/styles/06-components/_components.chart.scss +2102 -0
- package/src/styles/06-components/_components.checkbox-group.scss +0 -0
- package/src/styles/06-components/_components.checkbox.scss +0 -0
- package/src/styles/06-components/_components.color-mode-toggle.scss +0 -0
- package/src/styles/06-components/_components.countdown.scss +0 -0
- package/src/styles/06-components/_components.data-table.scss +0 -0
- package/src/styles/06-components/_components.datepicker.scss +0 -0
- package/src/styles/06-components/_components.dropdown.scss +0 -0
- package/src/styles/06-components/_components.edge-panel.scss +0 -0
- package/src/styles/06-components/_components.form-group.scss +0 -0
- package/src/styles/06-components/_components.form.scss +0 -0
- package/src/styles/06-components/_components.hero.scss +1 -0
- package/src/styles/06-components/_components.icon.scss +2 -2
- package/src/styles/06-components/_components.image-gallery.scss +0 -0
- package/src/styles/06-components/_components.input.scss +0 -0
- package/src/styles/06-components/_components.list-group.scss +0 -0
- package/src/styles/06-components/_components.list.scss +0 -0
- package/src/styles/06-components/_components.menu.scss +0 -0
- package/src/styles/06-components/_components.messages.scss +0 -0
- package/src/styles/06-components/_components.modal.scss +3 -0
- package/src/styles/06-components/_components.nav.scss +0 -0
- package/src/styles/06-components/_components.navbar.scss +0 -0
- package/src/styles/06-components/_components.pagination.scss +0 -0
- package/src/styles/06-components/_components.photoviewer.scss +603 -545
- package/src/styles/06-components/_components.popover.scss +0 -0
- package/src/styles/06-components/_components.product-review.scss +0 -0
- package/src/styles/06-components/_components.progress.scss +0 -0
- package/src/styles/06-components/_components.rating.scss +0 -0
- package/src/styles/06-components/_components.river.scss +0 -0
- package/src/styles/06-components/_components.sectionintro.scss +0 -0
- package/src/styles/06-components/_components.select.scss +0 -0
- package/src/styles/06-components/_components.side-menu.scss +0 -0
- package/src/styles/06-components/_components.skeleton.scss +0 -0
- package/src/styles/06-components/_components.slider.scss +273 -0
- package/src/styles/06-components/_components.spinner.scss +0 -0
- package/src/styles/06-components/_components.steps.scss +1 -0
- package/src/styles/06-components/_components.tabs.scss +0 -0
- package/src/styles/06-components/_components.testimonials.scss +0 -0
- package/src/styles/06-components/_components.todo.scss +0 -0
- package/src/styles/06-components/_components.toggle.scss +0 -0
- package/src/styles/06-components/_components.tooltip.scss +4 -9
- package/src/styles/06-components/_components.upload.scss +0 -0
- package/src/styles/06-components/_components.video-player.scss +623 -0
- package/src/styles/06-components/_index.scss +3 -0
- package/src/styles/06-components/old.chart.styles.scss +2819 -0
- package/src/styles/99-utilities/_index.scss +0 -0
- package/src/styles/99-utilities/_utilities.background.scss +0 -0
- package/src/styles/99-utilities/_utilities.border.scss +0 -0
- package/src/styles/99-utilities/_utilities.clearfix.scss +0 -0
- package/src/styles/99-utilities/_utilities.display.scss +0 -0
- package/src/styles/99-utilities/_utilities.flex.scss +0 -0
- package/src/styles/99-utilities/_utilities.link.scss +0 -0
- package/src/styles/99-utilities/_utilities.object-fit.scss +0 -0
- package/src/styles/99-utilities/_utilities.opacity.scss +0 -0
- package/src/styles/99-utilities/_utilities.overflow.scss +0 -0
- package/src/styles/99-utilities/_utilities.position.scss +0 -0
- package/src/styles/99-utilities/_utilities.scss +2 -1
- package/src/styles/99-utilities/_utilities.shadow.scss +0 -0
- package/src/styles/99-utilities/_utilities.sizes.scss +0 -0
- package/src/styles/99-utilities/_utilities.spacing.scss +0 -0
- package/src/styles/99-utilities/_utilities.text.scss +5 -0
- package/src/styles/99-utilities/_utilities.visibility.scss +0 -0
- package/src/styles/99-utilities/_utilities.visually-hidden.scss +0 -0
- package/src/styles/99-utilities/_utilities.z-index.scss +0 -0
- package/src/styles/css-modules.d.ts +0 -0
- package/src/styles/index.scss +0 -0
- package/dist/index.css +0 -15
- package/dist/index.esm.css +0 -15
- package/dist/index.min.css +0 -15
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface ExportOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Export format
|
|
6
|
+
*/
|
|
7
|
+
format: 'png' | 'svg' | 'pdf' | 'csv' | 'json' | 'xlsx';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Export quality (for raster formats)
|
|
11
|
+
*/
|
|
12
|
+
quality?: number;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Export dimensions
|
|
16
|
+
*/
|
|
17
|
+
dimensions?: {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Background color
|
|
24
|
+
*/
|
|
25
|
+
backgroundColor?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Include title and metadata
|
|
29
|
+
*/
|
|
30
|
+
includeMetadata?: boolean;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Custom filename
|
|
34
|
+
*/
|
|
35
|
+
filename?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ShareOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Share platforms
|
|
41
|
+
*/
|
|
42
|
+
platforms: ('twitter' | 'facebook' | 'linkedin' | 'email' | 'copy-link')[];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Share message
|
|
46
|
+
*/
|
|
47
|
+
message?: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Share URL
|
|
51
|
+
*/
|
|
52
|
+
url?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Hook for chart export and sharing functionality
|
|
57
|
+
*/
|
|
58
|
+
export function useChartExport() {
|
|
59
|
+
const canvasRef = useRef<HTMLCanvasElement | null>(null);
|
|
60
|
+
|
|
61
|
+
// Convert SVG to Canvas
|
|
62
|
+
const svgToCanvas = useCallback(
|
|
63
|
+
async (svgElement: SVGSVGElement, options: ExportOptions): Promise<HTMLCanvasElement> => {
|
|
64
|
+
const { dimensions, backgroundColor = 'white' } = options;
|
|
65
|
+
|
|
66
|
+
// Get SVG dimensions
|
|
67
|
+
const svgRect = svgElement.getBoundingClientRect();
|
|
68
|
+
const width = dimensions?.width || svgRect.width;
|
|
69
|
+
const height = dimensions?.height || svgRect.height;
|
|
70
|
+
|
|
71
|
+
// Create canvas
|
|
72
|
+
const canvas = document.createElement('canvas');
|
|
73
|
+
const ctx = canvas.getContext('2d')!;
|
|
74
|
+
|
|
75
|
+
// Set canvas dimensions
|
|
76
|
+
canvas.width = width;
|
|
77
|
+
canvas.height = height;
|
|
78
|
+
|
|
79
|
+
// Set background
|
|
80
|
+
ctx.fillStyle = backgroundColor;
|
|
81
|
+
ctx.fillRect(0, 0, width, height);
|
|
82
|
+
|
|
83
|
+
// Convert SVG to data URL
|
|
84
|
+
const svgData = new XMLSerializer().serializeToString(svgElement);
|
|
85
|
+
const svgBlob = new Blob([svgData], { type: 'image/svg+xml;charset=utf-8' });
|
|
86
|
+
const svgUrl = URL.createObjectURL(svgBlob);
|
|
87
|
+
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
const img = new Image();
|
|
90
|
+
img.onload = () => {
|
|
91
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
92
|
+
URL.revokeObjectURL(svgUrl);
|
|
93
|
+
resolve(canvas);
|
|
94
|
+
};
|
|
95
|
+
img.onerror = reject;
|
|
96
|
+
img.src = svgUrl;
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
[]
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// Export as PNG
|
|
103
|
+
const exportAsPNG = useCallback(
|
|
104
|
+
async (svgElement: SVGSVGElement, options: ExportOptions): Promise<void> => {
|
|
105
|
+
const canvas = await svgToCanvas(svgElement, options);
|
|
106
|
+
const quality = options.quality || 0.9;
|
|
107
|
+
|
|
108
|
+
canvas.toBlob(
|
|
109
|
+
blob => {
|
|
110
|
+
if (blob) {
|
|
111
|
+
const url = URL.createObjectURL(blob);
|
|
112
|
+
const link = document.createElement('a');
|
|
113
|
+
link.download = options.filename || 'chart.png';
|
|
114
|
+
link.href = url;
|
|
115
|
+
link.click();
|
|
116
|
+
URL.revokeObjectURL(url);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
'image/png',
|
|
120
|
+
quality
|
|
121
|
+
);
|
|
122
|
+
},
|
|
123
|
+
[svgToCanvas]
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// Export as SVG
|
|
127
|
+
const exportAsSVG = useCallback((svgElement: SVGSVGElement, options: ExportOptions): void => {
|
|
128
|
+
const svgData = new XMLSerializer().serializeToString(svgElement);
|
|
129
|
+
const svgBlob = new Blob([svgData], { type: 'image/svg+xml;charset=utf-8' });
|
|
130
|
+
const url = URL.createObjectURL(svgBlob);
|
|
131
|
+
|
|
132
|
+
const link = document.createElement('a');
|
|
133
|
+
link.download = options.filename || 'chart.svg';
|
|
134
|
+
link.href = url;
|
|
135
|
+
link.click();
|
|
136
|
+
URL.revokeObjectURL(url);
|
|
137
|
+
}, []);
|
|
138
|
+
|
|
139
|
+
// Export as PDF
|
|
140
|
+
const exportAsPDF = useCallback(
|
|
141
|
+
async (svgElement: SVGSVGElement, options: ExportOptions): Promise<void> => {
|
|
142
|
+
// Note: This requires a PDF library like jsPDF
|
|
143
|
+
// For now, we'll convert to canvas and then to PDF
|
|
144
|
+
const canvas = await svgToCanvas(svgElement, options);
|
|
145
|
+
|
|
146
|
+
// This would require jsPDF library
|
|
147
|
+
// const pdf = new jsPDF();
|
|
148
|
+
// const imgData = canvas.toDataURL('image/png');
|
|
149
|
+
// pdf.addImage(imgData, 'PNG', 0, 0);
|
|
150
|
+
// pdf.save(options.filename || 'chart.pdf');
|
|
151
|
+
|
|
152
|
+
console.warn('PDF export requires jsPDF library to be installed');
|
|
153
|
+
},
|
|
154
|
+
[svgToCanvas]
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
// Export data as CSV
|
|
158
|
+
const exportAsCSV = useCallback((datasets: any[], options: ExportOptions): void => {
|
|
159
|
+
if (!datasets.length) return;
|
|
160
|
+
|
|
161
|
+
// Create CSV content
|
|
162
|
+
const headers = ['Label', ...datasets.map(d => d.label)];
|
|
163
|
+
const rows: string[][] = [headers];
|
|
164
|
+
|
|
165
|
+
// Get all unique labels
|
|
166
|
+
const allLabels = new Set<string>();
|
|
167
|
+
datasets.forEach(dataset => {
|
|
168
|
+
dataset.data?.forEach((point: any) => allLabels.add(point.label));
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Create data rows
|
|
172
|
+
Array.from(allLabels).forEach(label => {
|
|
173
|
+
const row = [label];
|
|
174
|
+
datasets.forEach(dataset => {
|
|
175
|
+
const point = dataset.data?.find((p: any) => p.label === label);
|
|
176
|
+
row.push(point ? point.value.toString() : '');
|
|
177
|
+
});
|
|
178
|
+
rows.push(row);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Convert to CSV string
|
|
182
|
+
const csvContent = rows
|
|
183
|
+
.map(row => row.map(cell => `"${cell.replace(/"/g, '""')}"`).join(','))
|
|
184
|
+
.join('\n');
|
|
185
|
+
|
|
186
|
+
// Download
|
|
187
|
+
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
|
|
188
|
+
const url = URL.createObjectURL(blob);
|
|
189
|
+
const link = document.createElement('a');
|
|
190
|
+
link.download = options.filename || 'chart-data.csv';
|
|
191
|
+
link.href = url;
|
|
192
|
+
link.click();
|
|
193
|
+
URL.revokeObjectURL(url);
|
|
194
|
+
}, []);
|
|
195
|
+
|
|
196
|
+
// Export data as JSON
|
|
197
|
+
const exportAsJSON = useCallback((datasets: any[], options: ExportOptions): void => {
|
|
198
|
+
const jsonData = {
|
|
199
|
+
metadata: {
|
|
200
|
+
exportDate: new Date().toISOString(),
|
|
201
|
+
format: 'chart-data',
|
|
202
|
+
version: '1.0',
|
|
203
|
+
},
|
|
204
|
+
datasets: datasets.map(dataset => ({
|
|
205
|
+
label: dataset.label,
|
|
206
|
+
color: dataset.color,
|
|
207
|
+
data: dataset.data,
|
|
208
|
+
})),
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const jsonString = JSON.stringify(jsonData, null, 2);
|
|
212
|
+
const blob = new Blob([jsonString], { type: 'application/json;charset=utf-8;' });
|
|
213
|
+
const url = URL.createObjectURL(blob);
|
|
214
|
+
const link = document.createElement('a');
|
|
215
|
+
link.download = options.filename || 'chart-data.json';
|
|
216
|
+
link.href = url;
|
|
217
|
+
link.click();
|
|
218
|
+
URL.revokeObjectURL(url);
|
|
219
|
+
}, []);
|
|
220
|
+
|
|
221
|
+
// Export data as Excel
|
|
222
|
+
const exportAsXLSX = useCallback((datasets: any[], options: ExportOptions): void => {
|
|
223
|
+
// Note: This requires a library like xlsx or exceljs
|
|
224
|
+
console.warn('XLSX export requires xlsx library to be installed');
|
|
225
|
+
}, []);
|
|
226
|
+
|
|
227
|
+
// Main export function
|
|
228
|
+
const exportChart = useCallback(
|
|
229
|
+
async (
|
|
230
|
+
svgElement: SVGSVGElement | null,
|
|
231
|
+
datasets: any[],
|
|
232
|
+
options: ExportOptions
|
|
233
|
+
): Promise<void> => {
|
|
234
|
+
if (!svgElement && !['csv', 'json', 'xlsx'].includes(options.format)) {
|
|
235
|
+
throw new Error('SVG element is required for image exports');
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
try {
|
|
239
|
+
switch (options.format) {
|
|
240
|
+
case 'png':
|
|
241
|
+
if (svgElement) await exportAsPNG(svgElement, options);
|
|
242
|
+
break;
|
|
243
|
+
case 'svg':
|
|
244
|
+
if (svgElement) exportAsSVG(svgElement, options);
|
|
245
|
+
break;
|
|
246
|
+
case 'pdf':
|
|
247
|
+
if (svgElement) await exportAsPDF(svgElement, options);
|
|
248
|
+
break;
|
|
249
|
+
case 'csv':
|
|
250
|
+
exportAsCSV(datasets, options);
|
|
251
|
+
break;
|
|
252
|
+
case 'json':
|
|
253
|
+
exportAsJSON(datasets, options);
|
|
254
|
+
break;
|
|
255
|
+
case 'xlsx':
|
|
256
|
+
exportAsXLSX(datasets, options);
|
|
257
|
+
break;
|
|
258
|
+
default:
|
|
259
|
+
throw new Error(`Unsupported export format: ${options.format}`);
|
|
260
|
+
}
|
|
261
|
+
} catch (error) {
|
|
262
|
+
console.error('Export failed:', error);
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
[exportAsPNG, exportAsSVG, exportAsPDF, exportAsCSV, exportAsJSON, exportAsXLSX]
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
// Share functionality
|
|
270
|
+
const shareChart = useCallback(
|
|
271
|
+
async (svgElement: SVGSVGElement | null, shareOptions: ShareOptions): Promise<void> => {
|
|
272
|
+
const {
|
|
273
|
+
platforms,
|
|
274
|
+
message = 'Check out this chart!',
|
|
275
|
+
url = window.location.href,
|
|
276
|
+
} = shareOptions;
|
|
277
|
+
|
|
278
|
+
for (const platform of platforms) {
|
|
279
|
+
switch (platform) {
|
|
280
|
+
case 'twitter':
|
|
281
|
+
window.open(
|
|
282
|
+
`https://twitter.com/intent/tweet?text=${encodeURIComponent(message)}&url=${encodeURIComponent(url)}`,
|
|
283
|
+
'_blank'
|
|
284
|
+
);
|
|
285
|
+
break;
|
|
286
|
+
case 'facebook':
|
|
287
|
+
window.open(
|
|
288
|
+
`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(url)}`,
|
|
289
|
+
'_blank'
|
|
290
|
+
);
|
|
291
|
+
break;
|
|
292
|
+
case 'linkedin':
|
|
293
|
+
window.open(
|
|
294
|
+
`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(url)}`,
|
|
295
|
+
'_blank'
|
|
296
|
+
);
|
|
297
|
+
break;
|
|
298
|
+
case 'email':
|
|
299
|
+
window.open(
|
|
300
|
+
`mailto:?subject=${encodeURIComponent('Chart Share')}&body=${encodeURIComponent(`${message}\n\n${url}`)}`,
|
|
301
|
+
'_blank'
|
|
302
|
+
);
|
|
303
|
+
break;
|
|
304
|
+
case 'copy-link':
|
|
305
|
+
try {
|
|
306
|
+
await navigator.clipboard.writeText(url);
|
|
307
|
+
// You might want to show a toast notification here
|
|
308
|
+
console.log('Link copied to clipboard');
|
|
309
|
+
} catch (error) {
|
|
310
|
+
console.error('Failed to copy link:', error);
|
|
311
|
+
}
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
[]
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
// Copy chart as image to clipboard
|
|
320
|
+
const copyToClipboard = useCallback(
|
|
321
|
+
async (svgElement: SVGSVGElement, options: Partial<ExportOptions> = {}): Promise<void> => {
|
|
322
|
+
try {
|
|
323
|
+
const canvas = await svgToCanvas(svgElement, { format: 'png', ...options });
|
|
324
|
+
|
|
325
|
+
canvas.toBlob(async blob => {
|
|
326
|
+
if (blob && navigator.clipboard && window.ClipboardItem) {
|
|
327
|
+
try {
|
|
328
|
+
await navigator.clipboard.write([new ClipboardItem({ 'image/png': blob })]);
|
|
329
|
+
console.log('Chart copied to clipboard');
|
|
330
|
+
} catch (error) {
|
|
331
|
+
console.error('Failed to copy to clipboard:', error);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}, 'image/png');
|
|
335
|
+
} catch (error) {
|
|
336
|
+
console.error('Failed to copy chart:', error);
|
|
337
|
+
throw error;
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
[svgToCanvas]
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
// Print chart
|
|
344
|
+
const printChart = useCallback(
|
|
345
|
+
async (svgElement: SVGSVGElement, options: Partial<ExportOptions> = {}): Promise<void> => {
|
|
346
|
+
try {
|
|
347
|
+
const canvas = await svgToCanvas(svgElement, { format: 'png', ...options });
|
|
348
|
+
const dataUrl = canvas.toDataURL('image/png');
|
|
349
|
+
|
|
350
|
+
const printWindow = window.open('', '_blank');
|
|
351
|
+
if (printWindow) {
|
|
352
|
+
printWindow.document.write(`
|
|
353
|
+
<html>
|
|
354
|
+
<head>
|
|
355
|
+
<title>Chart Print</title>
|
|
356
|
+
<style>
|
|
357
|
+
body { margin: 0; padding: 20px; text-align: center; }
|
|
358
|
+
img { max-width: 100%; height: auto; }
|
|
359
|
+
</style>
|
|
360
|
+
</head>
|
|
361
|
+
<body>
|
|
362
|
+
<img src="${dataUrl}" alt="Chart" />
|
|
363
|
+
</body>
|
|
364
|
+
</html>
|
|
365
|
+
`);
|
|
366
|
+
printWindow.document.close();
|
|
367
|
+
printWindow.focus();
|
|
368
|
+
printWindow.print();
|
|
369
|
+
}
|
|
370
|
+
} catch (error) {
|
|
371
|
+
console.error('Failed to print chart:', error);
|
|
372
|
+
throw error;
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
[svgToCanvas]
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
return {
|
|
379
|
+
exportChart,
|
|
380
|
+
shareChart,
|
|
381
|
+
copyToClipboard,
|
|
382
|
+
printChart,
|
|
383
|
+
|
|
384
|
+
// Individual export methods
|
|
385
|
+
exportAsPNG,
|
|
386
|
+
exportAsSVG,
|
|
387
|
+
exportAsPDF,
|
|
388
|
+
exportAsCSV,
|
|
389
|
+
exportAsJSON,
|
|
390
|
+
exportAsXLSX,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { ChartInteraction } from '../../components/Chart/types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Simplified hook for basic chart interactions
|
|
6
|
+
*/
|
|
7
|
+
export function useChartInteraction() {
|
|
8
|
+
const [interaction, setInteraction] = useState<ChartInteraction>({
|
|
9
|
+
hoveredIndex: null,
|
|
10
|
+
selectedIndex: null,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const handlePointHover = useCallback((index: number | null) => {
|
|
14
|
+
setInteraction(prev => ({ ...prev, hoveredIndex: index }));
|
|
15
|
+
}, []);
|
|
16
|
+
|
|
17
|
+
const handlePointClick = useCallback((index: number) => {
|
|
18
|
+
setInteraction(prev => ({
|
|
19
|
+
...prev,
|
|
20
|
+
selectedIndex: prev.selectedIndex === index ? null : index,
|
|
21
|
+
}));
|
|
22
|
+
}, []);
|
|
23
|
+
|
|
24
|
+
const clearInteraction = useCallback(() => {
|
|
25
|
+
setInteraction({ hoveredIndex: null, selectedIndex: null });
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
interaction,
|
|
30
|
+
handlePointHover,
|
|
31
|
+
handlePointClick,
|
|
32
|
+
clearInteraction,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
interface InteractionState {
|
|
4
|
+
isDragging: boolean;
|
|
5
|
+
isZooming: boolean;
|
|
6
|
+
lastPointerPos: { x: number; y: number } | null;
|
|
7
|
+
zoomLevel: number;
|
|
8
|
+
panOffset: { x: number; y: number };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function useChartInteractions() {
|
|
12
|
+
const [state, setState] = useState<InteractionState>({
|
|
13
|
+
isDragging: false,
|
|
14
|
+
isZooming: false,
|
|
15
|
+
lastPointerPos: null,
|
|
16
|
+
zoomLevel: 1,
|
|
17
|
+
panOffset: { x: 0, y: 0 },
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const wheelTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
21
|
+
const lastWheelTime = useRef(0);
|
|
22
|
+
|
|
23
|
+
// Improved wheel handling for both mouse and trackpad
|
|
24
|
+
const handleWheel = useCallback((event: WheelEvent) => {
|
|
25
|
+
event.preventDefault();
|
|
26
|
+
|
|
27
|
+
const now = Date.now();
|
|
28
|
+
const timeDelta = now - lastWheelTime.current;
|
|
29
|
+
lastWheelTime.current = now;
|
|
30
|
+
|
|
31
|
+
// Detect trackpad vs mouse wheel
|
|
32
|
+
const isTrackpad = Math.abs(event.deltaY) < 50 && timeDelta < 50;
|
|
33
|
+
const sensitivity = isTrackpad ? 0.01 : 0.1;
|
|
34
|
+
|
|
35
|
+
if (wheelTimeoutRef.current) {
|
|
36
|
+
clearTimeout(wheelTimeoutRef.current);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setState(prev => {
|
|
40
|
+
const rect = (event.target as Element).getBoundingClientRect();
|
|
41
|
+
const centerX = event.clientX - rect.left;
|
|
42
|
+
const centerY = event.clientY - rect.top;
|
|
43
|
+
|
|
44
|
+
// Zoom calculation
|
|
45
|
+
const zoomFactor = 1 - event.deltaY * sensitivity;
|
|
46
|
+
const newZoomLevel = Math.max(0.1, Math.min(10, prev.zoomLevel * zoomFactor));
|
|
47
|
+
|
|
48
|
+
// Pan to zoom center
|
|
49
|
+
const zoomRatio = newZoomLevel / prev.zoomLevel;
|
|
50
|
+
const newPanOffset = {
|
|
51
|
+
x: centerX - (centerX - prev.panOffset.x) * zoomRatio,
|
|
52
|
+
y: centerY - (centerY - prev.panOffset.y) * zoomRatio,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
...prev,
|
|
57
|
+
zoomLevel: newZoomLevel,
|
|
58
|
+
panOffset: newPanOffset,
|
|
59
|
+
isZooming: true,
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
wheelTimeoutRef.current = setTimeout(() => {
|
|
64
|
+
setState(prev => ({ ...prev, isZooming: false }));
|
|
65
|
+
}, 150);
|
|
66
|
+
}, []);
|
|
67
|
+
|
|
68
|
+
// Unified pointer events for mouse and touch
|
|
69
|
+
const handlePointerDown = useCallback((event: PointerEvent) => {
|
|
70
|
+
setState(prev => ({
|
|
71
|
+
...prev,
|
|
72
|
+
isDragging: true,
|
|
73
|
+
lastPointerPos: { x: event.clientX, y: event.clientY },
|
|
74
|
+
}));
|
|
75
|
+
(event.target as Element).setPointerCapture(event.pointerId);
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
78
|
+
const handlePointerMove = useCallback((event: PointerEvent) => {
|
|
79
|
+
setState(prev => {
|
|
80
|
+
if (!prev.isDragging || !prev.lastPointerPos) return prev;
|
|
81
|
+
|
|
82
|
+
const deltaX = event.clientX - prev.lastPointerPos.x;
|
|
83
|
+
const deltaY = event.clientY - prev.lastPointerPos.y;
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
...prev,
|
|
87
|
+
panOffset: {
|
|
88
|
+
x: prev.panOffset.x + deltaX,
|
|
89
|
+
y: prev.panOffset.y + deltaY,
|
|
90
|
+
},
|
|
91
|
+
lastPointerPos: { x: event.clientX, y: event.clientY },
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
}, []);
|
|
95
|
+
|
|
96
|
+
const handlePointerUp = useCallback((event: PointerEvent) => {
|
|
97
|
+
setState(prev => ({
|
|
98
|
+
...prev,
|
|
99
|
+
isDragging: false,
|
|
100
|
+
lastPointerPos: null,
|
|
101
|
+
}));
|
|
102
|
+
(event.target as Element).releasePointerCapture(event.pointerId);
|
|
103
|
+
}, []);
|
|
104
|
+
|
|
105
|
+
const resetView = useCallback(() => {
|
|
106
|
+
setState(prev => ({
|
|
107
|
+
...prev,
|
|
108
|
+
zoomLevel: 1,
|
|
109
|
+
panOffset: { x: 0, y: 0 },
|
|
110
|
+
}));
|
|
111
|
+
}, []);
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
state,
|
|
115
|
+
handlers: {
|
|
116
|
+
onWheel: handleWheel,
|
|
117
|
+
onPointerDown: handlePointerDown,
|
|
118
|
+
onPointerMove: handlePointerMove,
|
|
119
|
+
onPointerUp: handlePointerUp,
|
|
120
|
+
},
|
|
121
|
+
resetView,
|
|
122
|
+
};
|
|
123
|
+
}
|