@udixio/ui-react 0.4.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.mjs +22 -0
- package/.storybook/main.ts +20 -0
- package/.storybook/preview.ts +1 -0
- package/CHANGELOG.md +63 -0
- package/dist/index.cjs +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2811 -0
- package/dist/lib/components/Button.d.ts +9 -0
- package/dist/lib/components/Button.d.ts.map +1 -0
- package/{src → dist}/lib/components/Card.d.ts +5 -0
- package/dist/lib/components/Card.d.ts.map +1 -0
- package/{src → dist}/lib/components/Carousel.d.ts +6 -0
- package/dist/lib/components/Carousel.d.ts.map +1 -0
- package/{src → dist}/lib/components/CarouselItem.d.ts +4 -0
- package/dist/lib/components/CarouselItem.d.ts.map +1 -0
- package/dist/lib/components/Divider.d.ts +9 -0
- package/dist/lib/components/Divider.d.ts.map +1 -0
- package/dist/lib/components/Fab.d.ts +9 -0
- package/dist/lib/components/Fab.d.ts.map +1 -0
- package/dist/lib/components/IconButton.d.ts +10 -0
- package/dist/lib/components/IconButton.d.ts.map +1 -0
- package/{src → dist}/lib/components/NavigationRail.d.ts +5 -0
- package/dist/lib/components/NavigationRail.d.ts.map +1 -0
- package/{src → dist}/lib/components/NavigationRailItem.d.ts +9 -1
- package/dist/lib/components/NavigationRailItem.d.ts.map +1 -0
- package/dist/lib/components/ProgressIndicator.d.ts +8 -0
- package/dist/lib/components/ProgressIndicator.d.ts.map +1 -0
- package/{src → dist}/lib/components/Slider.d.ts +5 -0
- package/dist/lib/components/Slider.d.ts.map +1 -0
- package/dist/lib/components/Snackbar.d.ts +9 -0
- package/dist/lib/components/Snackbar.d.ts.map +1 -0
- package/{src → dist}/lib/components/Switch.d.ts +5 -0
- package/dist/lib/components/Switch.d.ts.map +1 -0
- package/{src → dist}/lib/components/Tab.d.ts +4 -0
- package/dist/lib/components/Tab.d.ts.map +1 -0
- package/{src → dist}/lib/components/Tabs.d.ts +5 -0
- package/dist/lib/components/Tabs.d.ts.map +1 -0
- package/{src → dist}/lib/components/TextField.d.ts +5 -0
- package/dist/lib/components/TextField.d.ts.map +1 -0
- package/{src → dist}/lib/components/ToolTip.d.ts +5 -0
- package/dist/lib/components/ToolTip.d.ts.map +1 -0
- package/{src → dist}/lib/components/index.d.ts +1 -1
- package/dist/lib/components/index.d.ts.map +1 -0
- package/dist/lib/effects/SyncedFixedWrapper.d.ts.map +1 -0
- package/dist/lib/effects/custom-scroll/custom-scroll.effect.d.ts.map +1 -0
- package/dist/lib/effects/custom-scroll/custom-scroll.interface.d.ts.map +1 -0
- package/dist/lib/effects/custom-scroll/custom-scroll.style.d.ts.map +1 -0
- package/dist/lib/effects/custom-scroll/index.d.ts.map +1 -0
- package/dist/lib/effects/index.d.ts.map +1 -0
- package/dist/lib/effects/ripple/RippleEffect.d.ts.map +1 -0
- package/dist/lib/effects/ripple/index.d.ts.map +1 -0
- package/dist/lib/effects/smooth-scroll.effect.d.ts.map +1 -0
- package/dist/lib/icon/icon.d.ts.map +1 -0
- package/dist/lib/icon/index.d.ts.map +1 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/{src → dist}/lib/interfaces/button.interface.d.ts +9 -3
- package/dist/lib/interfaces/button.interface.d.ts.map +1 -0
- package/{src → dist}/lib/interfaces/card.interface.d.ts +2 -0
- package/dist/lib/interfaces/card.interface.d.ts.map +1 -0
- package/dist/lib/interfaces/carousel-item.interface.d.ts.map +1 -0
- package/{src → dist}/lib/interfaces/carousel.interface.d.ts +3 -2
- package/dist/lib/interfaces/carousel.interface.d.ts.map +1 -0
- package/dist/lib/interfaces/divider.interface.d.ts.map +1 -0
- package/{src → dist}/lib/interfaces/fab.interface.d.ts +2 -1
- package/dist/lib/interfaces/fab.interface.d.ts.map +1 -0
- package/{src → dist}/lib/interfaces/icon-button.interface.d.ts +3 -2
- package/dist/lib/interfaces/icon-button.interface.d.ts.map +1 -0
- package/dist/lib/interfaces/index.d.ts.map +1 -0
- package/{src → dist}/lib/interfaces/navigation-rail-item.interface.d.ts +1 -0
- package/dist/lib/interfaces/navigation-rail-item.interface.d.ts.map +1 -0
- package/dist/lib/interfaces/navigation-rail.interface.d.ts.map +1 -0
- package/dist/lib/interfaces/progress-indicator.interface.d.ts.map +1 -0
- package/dist/lib/interfaces/slider.interface.d.ts.map +1 -0
- package/{src → dist}/lib/interfaces/snackbar.interface.d.ts +1 -1
- package/dist/lib/interfaces/snackbar.interface.d.ts.map +1 -0
- package/dist/lib/interfaces/switch.interface.d.ts.map +1 -0
- package/dist/lib/interfaces/tab.interface.d.ts.map +1 -0
- package/{src → dist}/lib/interfaces/tabs.interface.d.ts +1 -1
- package/dist/lib/interfaces/tabs.interface.d.ts.map +1 -0
- package/dist/lib/interfaces/text-field.interface.d.ts.map +1 -0
- package/dist/lib/interfaces/tooltip.interface.d.ts.map +1 -0
- package/{src → dist}/lib/styles/button.style.d.ts +22 -8
- package/dist/lib/styles/button.style.d.ts.map +1 -0
- package/{src → dist}/lib/styles/card.style.d.ts +2 -0
- package/dist/lib/styles/card.style.d.ts.map +1 -0
- package/dist/lib/styles/carousel-item.style.d.ts.map +1 -0
- package/{src → dist}/lib/styles/carousel.style.d.ts +1 -1
- package/dist/lib/styles/carousel.style.d.ts.map +1 -0
- package/dist/lib/styles/divider.style.d.ts.map +1 -0
- package/{src → dist}/lib/styles/fab.style.d.ts +6 -2
- package/dist/lib/styles/fab.style.d.ts.map +1 -0
- package/{src → dist}/lib/styles/icon-button.style.d.ts +9 -5
- package/dist/lib/styles/icon-button.style.d.ts.map +1 -0
- package/dist/lib/styles/index.d.ts.map +1 -0
- package/{src → dist}/lib/styles/navigation-rail-item.style.d.ts +2 -0
- package/dist/lib/styles/navigation-rail-item.style.d.ts.map +1 -0
- package/dist/lib/styles/navigation-rail.style.d.ts.map +1 -0
- package/dist/lib/styles/progress-indicator.style.d.ts.map +1 -0
- package/dist/lib/styles/slider.style.d.ts.map +1 -0
- package/{src → dist}/lib/styles/snackbar.style.d.ts +2 -2
- package/dist/lib/styles/snackbar.style.d.ts.map +1 -0
- package/dist/lib/styles/switch.style.d.ts.map +1 -0
- package/{src → dist}/lib/styles/tab.style.d.ts +1 -1
- package/dist/lib/styles/tab.style.d.ts.map +1 -0
- package/{src → dist}/lib/styles/tabs.style.d.ts +1 -1
- package/dist/lib/styles/tabs.style.d.ts.map +1 -0
- package/dist/lib/styles/text-field.style.d.ts.map +1 -0
- package/dist/lib/styles/tooltip.style.d.ts.map +1 -0
- package/dist/lib/utils/component-helper.d.ts.map +1 -0
- package/{src → dist}/lib/utils/component.d.ts +1 -1
- package/dist/lib/utils/component.d.ts.map +1 -0
- package/dist/lib/utils/index.d.ts.map +1 -0
- package/dist/lib/utils/string.d.ts.map +1 -0
- package/dist/lib/utils/styles/classnames.d.ts.map +1 -0
- package/dist/lib/utils/styles/get-classname.d.ts.map +1 -0
- package/dist/lib/utils/styles/index.d.ts.map +1 -0
- package/package.json +31 -8
- package/postcss.config.mjs +5 -0
- package/src/index.css +4 -0
- package/src/index.ts +1 -0
- package/src/lib/components/Button.tsx +174 -0
- package/src/lib/components/Card.tsx +36 -0
- package/src/lib/components/Carousel.tsx +196 -0
- package/src/lib/components/CarouselItem.tsx +58 -0
- package/src/lib/components/Divider.tsx +18 -0
- package/src/lib/components/Fab.tsx +122 -0
- package/src/lib/components/IconButton.tsx +155 -0
- package/src/lib/components/NavigationRail.tsx +177 -0
- package/src/lib/components/NavigationRailItem.tsx +211 -0
- package/src/lib/components/ProgressIndicator.tsx +154 -0
- package/src/lib/components/Slider.tsx +366 -0
- package/src/lib/components/Snackbar.tsx +71 -0
- package/src/lib/components/Switch.tsx +99 -0
- package/src/lib/components/Tab.tsx +114 -0
- package/src/lib/components/Tabs.tsx +90 -0
- package/src/lib/components/TextField.tsx +274 -0
- package/src/lib/components/ToolTip.tsx +232 -0
- package/src/lib/components/index.ts +19 -0
- package/src/lib/effects/SyncedFixedWrapper.tsx +62 -0
- package/src/lib/effects/custom-scroll/custom-scroll.effect.tsx +287 -0
- package/src/lib/effects/custom-scroll/custom-scroll.interface.ts +25 -0
- package/src/lib/effects/custom-scroll/custom-scroll.style.ts +32 -0
- package/src/lib/effects/custom-scroll/index.ts +3 -0
- package/src/lib/effects/index.ts +4 -0
- package/src/lib/effects/ripple/RippleEffect.tsx +103 -0
- package/src/lib/effects/ripple/index.tsx +1 -0
- package/src/lib/effects/smooth-scroll.effect.tsx +91 -0
- package/src/lib/icon/icon.tsx +47 -0
- package/src/lib/icon/index.ts +1 -0
- package/src/lib/index.ts +6 -0
- package/src/lib/interfaces/button.interface.ts +54 -0
- package/src/lib/interfaces/card.interface.ts +11 -0
- package/src/lib/interfaces/carousel-item.interface.ts +11 -0
- package/src/lib/interfaces/carousel.interface.ts +22 -0
- package/src/lib/interfaces/divider.interface.ts +7 -0
- package/src/lib/interfaces/fab.interface.ts +20 -0
- package/src/lib/interfaces/icon-button.interface.ts +36 -0
- package/src/lib/interfaces/index.ts +16 -0
- package/src/lib/interfaces/navigation-rail-item.interface.ts +39 -0
- package/src/lib/interfaces/navigation-rail.interface.ts +39 -0
- package/src/lib/interfaces/progress-indicator.interface.ts +35 -0
- package/src/lib/interfaces/slider.interface.ts +27 -0
- package/src/lib/interfaces/snackbar.interface.ts +13 -0
- package/src/lib/interfaces/switch.interface.ts +14 -0
- package/src/lib/interfaces/tab.interface.ts +30 -0
- package/src/lib/interfaces/tabs.interface.ts +22 -0
- package/src/lib/interfaces/text-field.interface.ts +48 -0
- package/src/lib/interfaces/tooltip.interface.ts +35 -0
- package/src/lib/styles/button.style.ts +142 -0
- package/src/lib/styles/card.style.ts +21 -0
- package/src/lib/styles/carousel-item.style.ts +11 -0
- package/src/lib/styles/carousel.style.ts +12 -0
- package/src/lib/styles/divider.style.ts +17 -0
- package/src/lib/styles/fab.style.ts +55 -0
- package/src/lib/styles/icon-button.style.ts +167 -0
- package/src/lib/styles/index.ts +15 -0
- package/src/lib/styles/navigation-rail-item.style.ts +44 -0
- package/src/lib/styles/navigation-rail.style.ts +20 -0
- package/src/lib/styles/progress-indicator.style.ts +43 -0
- package/src/lib/styles/slider.style.ts +27 -0
- package/src/lib/styles/snackbar.style.ts +14 -0
- package/src/lib/styles/switch.style.ts +51 -0
- package/src/lib/styles/tab.style.ts +68 -0
- package/src/lib/styles/tabs.style.ts +13 -0
- package/src/lib/styles/text-field.style.ts +104 -0
- package/src/lib/styles/tooltip.style.ts +37 -0
- package/src/lib/utils/component-helper.ts +134 -0
- package/src/lib/utils/component.ts +34 -0
- package/src/lib/utils/index.ts +7 -0
- package/src/lib/utils/string.ts +9 -0
- package/src/lib/utils/styles/classnames.ts +49 -0
- package/src/lib/utils/styles/get-classname.ts +73 -0
- package/src/lib/utils/styles/index.ts +3 -0
- package/src/stories/action/button.stories.tsx +86 -0
- package/src/stories/action/fab.stories.tsx +54 -0
- package/src/stories/action/icon-button.stories.tsx +134 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +5 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +15 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +3 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +12 -0
- package/src/stories/assets/youtube.svg +4 -0
- package/src/stories/communication/ProgressIndicator.stories.tsx +57 -0
- package/src/stories/communication/SnackBar.stories.tsx +32 -0
- package/src/stories/communication/tool-tip.stories.tsx +133 -0
- package/src/stories/containment/card.stories.tsx +42 -0
- package/src/stories/containment/carousel.stories.tsx +65 -0
- package/src/stories/containment/divider.stories.tsx +35 -0
- package/src/stories/effect/smooth-scroll.stories.tsx +45 -0
- package/src/stories/navigation/navigation-rail/navigation-rail-item.stories.tsx +65 -0
- package/src/stories/navigation/navigation-rail/navigation-rail.stories.tsx +122 -0
- package/src/stories/navigation/tabs/tab.stories.tsx +57 -0
- package/src/stories/navigation/tabs/tabs.stories.tsx +102 -0
- package/src/stories/selection/slider.stories.tsx +85 -0
- package/src/stories/selection/switch.stories.tsx +46 -0
- package/src/stories/text-inputs/text-field.stories.tsx +135 -0
- package/src/tests/Button.spec.tsx +67 -0
- package/src/udixio.css +120 -0
- package/theme.config.ts +7 -0
- package/tsconfig.json +22 -0
- package/tsconfig.lib.json +51 -0
- package/tsconfig.spec.json +37 -0
- package/tsconfig.storybook.json +38 -0
- package/vite.config.ts +77 -0
- package/index.js +0 -5
- package/index.mjs +0 -2823
- package/src/index.d.ts.map +0 -1
- package/src/lib/components/Button.d.ts +0 -7
- package/src/lib/components/Button.d.ts.map +0 -1
- package/src/lib/components/Card.d.ts.map +0 -1
- package/src/lib/components/Carousel.d.ts.map +0 -1
- package/src/lib/components/CarouselItem.d.ts.map +0 -1
- package/src/lib/components/Divided.d.ts +0 -4
- package/src/lib/components/Divided.d.ts.map +0 -1
- package/src/lib/components/Fab.d.ts +0 -4
- package/src/lib/components/Fab.d.ts.map +0 -1
- package/src/lib/components/IconButton.d.ts +0 -5
- package/src/lib/components/IconButton.d.ts.map +0 -1
- package/src/lib/components/NavigationRail.d.ts.map +0 -1
- package/src/lib/components/NavigationRailItem.d.ts.map +0 -1
- package/src/lib/components/ProgressIndicator.d.ts +0 -4
- package/src/lib/components/ProgressIndicator.d.ts.map +0 -1
- package/src/lib/components/Slider.d.ts.map +0 -1
- package/src/lib/components/Snackbar.d.ts +0 -4
- package/src/lib/components/Snackbar.d.ts.map +0 -1
- package/src/lib/components/Switch.d.ts.map +0 -1
- package/src/lib/components/Tab.d.ts.map +0 -1
- package/src/lib/components/Tabs.d.ts.map +0 -1
- package/src/lib/components/TextField.d.ts.map +0 -1
- package/src/lib/components/ToolTip.d.ts.map +0 -1
- package/src/lib/components/index.d.ts.map +0 -1
- package/src/lib/effects/SyncedFixedWrapper.d.ts.map +0 -1
- package/src/lib/effects/custom-scroll/custom-scroll.effect.d.ts.map +0 -1
- package/src/lib/effects/custom-scroll/custom-scroll.interface.d.ts.map +0 -1
- package/src/lib/effects/custom-scroll/custom-scroll.style.d.ts.map +0 -1
- package/src/lib/effects/custom-scroll/index.d.ts.map +0 -1
- package/src/lib/effects/index.d.ts.map +0 -1
- package/src/lib/effects/ripple/RippleEffect.d.ts.map +0 -1
- package/src/lib/effects/ripple/index.d.ts.map +0 -1
- package/src/lib/effects/smooth-scroll.effect.d.ts.map +0 -1
- package/src/lib/icon/icon.d.ts.map +0 -1
- package/src/lib/icon/index.d.ts.map +0 -1
- package/src/lib/index.d.ts.map +0 -1
- package/src/lib/interfaces/button.interface.d.ts.map +0 -1
- package/src/lib/interfaces/card.interface.d.ts.map +0 -1
- package/src/lib/interfaces/carousel-item.interface.d.ts.map +0 -1
- package/src/lib/interfaces/carousel.interface.d.ts.map +0 -1
- package/src/lib/interfaces/divider.interface.d.ts.map +0 -1
- package/src/lib/interfaces/fab.interface.d.ts.map +0 -1
- package/src/lib/interfaces/icon-button.interface.d.ts.map +0 -1
- package/src/lib/interfaces/index.d.ts.map +0 -1
- package/src/lib/interfaces/navigation-rail-item.interface.d.ts.map +0 -1
- package/src/lib/interfaces/navigation-rail.interface.d.ts.map +0 -1
- package/src/lib/interfaces/progress-indicator.interface.d.ts.map +0 -1
- package/src/lib/interfaces/slider.interface.d.ts.map +0 -1
- package/src/lib/interfaces/snackbar.interface.d.ts.map +0 -1
- package/src/lib/interfaces/switch.interface.d.ts.map +0 -1
- package/src/lib/interfaces/tab.interface.d.ts.map +0 -1
- package/src/lib/interfaces/tabs.interface.d.ts.map +0 -1
- package/src/lib/interfaces/text-field.interface.d.ts.map +0 -1
- package/src/lib/interfaces/tooltip.interface.d.ts.map +0 -1
- package/src/lib/styles/button.style.d.ts.map +0 -1
- package/src/lib/styles/card.style.d.ts.map +0 -1
- package/src/lib/styles/carousel-item.style.d.ts.map +0 -1
- package/src/lib/styles/carousel.style.d.ts.map +0 -1
- package/src/lib/styles/divider.style.d.ts.map +0 -1
- package/src/lib/styles/fab.style.d.ts.map +0 -1
- package/src/lib/styles/icon-button.style.d.ts.map +0 -1
- package/src/lib/styles/index.d.ts.map +0 -1
- package/src/lib/styles/navigation-rail-item.style.d.ts.map +0 -1
- package/src/lib/styles/navigation-rail.style.d.ts.map +0 -1
- package/src/lib/styles/progress-indicator.style.d.ts.map +0 -1
- package/src/lib/styles/slider.style.d.ts.map +0 -1
- package/src/lib/styles/snackbar.style.d.ts.map +0 -1
- package/src/lib/styles/switch.style.d.ts.map +0 -1
- package/src/lib/styles/tab.style.d.ts.map +0 -1
- package/src/lib/styles/tabs.style.d.ts.map +0 -1
- package/src/lib/styles/text-field.style.d.ts.map +0 -1
- package/src/lib/styles/tooltip.style.d.ts.map +0 -1
- package/src/lib/utils/component-helper.d.ts.map +0 -1
- package/src/lib/utils/component.d.ts.map +0 -1
- package/src/lib/utils/index.d.ts.map +0 -1
- package/src/lib/utils/string.d.ts.map +0 -1
- package/src/lib/utils/styles/classnames.d.ts.map +0 -1
- package/src/lib/utils/styles/get-classname.d.ts.map +0 -1
- package/src/lib/utils/styles/index.d.ts.map +0 -1
- /package/{LICENSE → dist/LICENSE} +0 -0
- /package/{src → dist}/index.d.ts +0 -0
- /package/{src → dist}/lib/effects/SyncedFixedWrapper.d.ts +0 -0
- /package/{src → dist}/lib/effects/custom-scroll/custom-scroll.effect.d.ts +0 -0
- /package/{src → dist}/lib/effects/custom-scroll/custom-scroll.interface.d.ts +0 -0
- /package/{src → dist}/lib/effects/custom-scroll/custom-scroll.style.d.ts +0 -0
- /package/{src → dist}/lib/effects/custom-scroll/index.d.ts +0 -0
- /package/{src → dist}/lib/effects/index.d.ts +0 -0
- /package/{src → dist}/lib/effects/ripple/RippleEffect.d.ts +0 -0
- /package/{src → dist}/lib/effects/ripple/index.d.ts +0 -0
- /package/{src → dist}/lib/effects/smooth-scroll.effect.d.ts +0 -0
- /package/{src → dist}/lib/icon/icon.d.ts +0 -0
- /package/{src → dist}/lib/icon/index.d.ts +0 -0
- /package/{src → dist}/lib/index.d.ts +0 -0
- /package/{src → dist}/lib/interfaces/carousel-item.interface.d.ts +0 -0
- /package/{src → dist}/lib/interfaces/divider.interface.d.ts +0 -0
- /package/{src → dist}/lib/interfaces/index.d.ts +0 -0
- /package/{src → dist}/lib/interfaces/navigation-rail.interface.d.ts +0 -0
- /package/{src → dist}/lib/interfaces/progress-indicator.interface.d.ts +0 -0
- /package/{src → dist}/lib/interfaces/slider.interface.d.ts +0 -0
- /package/{src → dist}/lib/interfaces/switch.interface.d.ts +0 -0
- /package/{src → dist}/lib/interfaces/tab.interface.d.ts +0 -0
- /package/{src → dist}/lib/interfaces/text-field.interface.d.ts +0 -0
- /package/{src → dist}/lib/interfaces/tooltip.interface.d.ts +0 -0
- /package/{src → dist}/lib/styles/carousel-item.style.d.ts +0 -0
- /package/{src → dist}/lib/styles/divider.style.d.ts +0 -0
- /package/{src → dist}/lib/styles/index.d.ts +0 -0
- /package/{src → dist}/lib/styles/navigation-rail.style.d.ts +0 -0
- /package/{src → dist}/lib/styles/progress-indicator.style.d.ts +0 -0
- /package/{src → dist}/lib/styles/slider.style.d.ts +0 -0
- /package/{src → dist}/lib/styles/switch.style.d.ts +0 -0
- /package/{src → dist}/lib/styles/text-field.style.d.ts +0 -0
- /package/{src → dist}/lib/styles/tooltip.style.d.ts +0 -0
- /package/{src → dist}/lib/utils/component-helper.d.ts +0 -0
- /package/{src → dist}/lib/utils/index.d.ts +0 -0
- /package/{src → dist}/lib/utils/string.d.ts +0 -0
- /package/{src → dist}/lib/utils/styles/classnames.d.ts +0 -0
- /package/{src → dist}/lib/utils/styles/get-classname.d.ts +0 -0
- /package/{src → dist}/lib/utils/styles/index.d.ts +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
+
import { TabsInterface } from '../interfaces/tabs.interface';
|
|
4
|
+
|
|
5
|
+
import { tabsStyle } from '../styles/tabs.style';
|
|
6
|
+
import { ReactProps } from '../utils/component';
|
|
7
|
+
import { TabProps } from '../interfaces/tab.interface';
|
|
8
|
+
import { Tab } from './Tab';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Tabs organize content across different screens and views
|
|
12
|
+
* @status beta
|
|
13
|
+
* @category Navigation
|
|
14
|
+
*/
|
|
15
|
+
export const Tabs = ({
|
|
16
|
+
variant = 'primary',
|
|
17
|
+
onTabSelected,
|
|
18
|
+
children,
|
|
19
|
+
className,
|
|
20
|
+
selectedTab: externalSelectedTab,
|
|
21
|
+
setSelectedTab: externalSetSelectedTab,
|
|
22
|
+
scrollable = false,
|
|
23
|
+
}: ReactProps<TabsInterface>) => {
|
|
24
|
+
const [internalSelectedTab, internalSetSelectedTab] = useState<number | null>(
|
|
25
|
+
null,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
let selectedTab: number | null;
|
|
29
|
+
if (externalSelectedTab == 0 || externalSelectedTab != undefined) {
|
|
30
|
+
selectedTab = externalSelectedTab;
|
|
31
|
+
} else {
|
|
32
|
+
selectedTab = internalSelectedTab;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const setSelectedTab = externalSetSelectedTab || internalSetSelectedTab;
|
|
36
|
+
|
|
37
|
+
const tabChildren = React.Children.toArray(children).filter(
|
|
38
|
+
(child) => React.isValidElement(child) && child.type === Tab,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const ref = React.useRef<HTMLDivElement | null>(null);
|
|
42
|
+
|
|
43
|
+
const handleOnTabSelected = (
|
|
44
|
+
args: { index: number } & Pick<TabProps, 'label' | 'icon'> & {
|
|
45
|
+
ref: React.RefObject<any>;
|
|
46
|
+
},
|
|
47
|
+
) => {
|
|
48
|
+
onTabSelected?.(args);
|
|
49
|
+
|
|
50
|
+
if (scrollable) {
|
|
51
|
+
const tabs: HTMLElement = ref.current!;
|
|
52
|
+
const tabSelected: HTMLElement = args.ref.current;
|
|
53
|
+
if (tabs && tabSelected) {
|
|
54
|
+
const scrollLeft =
|
|
55
|
+
tabSelected.offsetLeft +
|
|
56
|
+
tabSelected.offsetWidth / 2 -
|
|
57
|
+
tabs.offsetWidth / 2;
|
|
58
|
+
tabs.scrollTo({ left: scrollLeft, behavior: 'smooth' });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const tabsId = useMemo(() => uuidv4(), []);
|
|
64
|
+
|
|
65
|
+
const styles = tabsStyle({
|
|
66
|
+
children,
|
|
67
|
+
onTabSelected,
|
|
68
|
+
scrollable,
|
|
69
|
+
selectedTab,
|
|
70
|
+
setSelectedTab,
|
|
71
|
+
className,
|
|
72
|
+
variant,
|
|
73
|
+
});
|
|
74
|
+
return (
|
|
75
|
+
<div ref={ref} role="tablist" className={styles.tabs}>
|
|
76
|
+
{tabChildren.map((child, index) => {
|
|
77
|
+
return React.cloneElement(child as React.ReactElement<TabProps>, {
|
|
78
|
+
key: index,
|
|
79
|
+
index,
|
|
80
|
+
variant: variant,
|
|
81
|
+
selectedTab,
|
|
82
|
+
setSelectedTab: setSelectedTab,
|
|
83
|
+
tabsId: tabsId,
|
|
84
|
+
onTabSelected: handleOnTabSelected,
|
|
85
|
+
scrollable,
|
|
86
|
+
});
|
|
87
|
+
})}
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Icon } from '../icon';
|
|
3
|
+
import { faCircleExclamation } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
+
import { motion } from 'motion/react';
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
+
|
|
7
|
+
import TextareaAutosize from 'react-textarea-autosize';
|
|
8
|
+
import { textFieldStyle } from '../styles/text-field.style';
|
|
9
|
+
import { classNames } from '../utils';
|
|
10
|
+
import { ReactProps } from '../utils/component';
|
|
11
|
+
import { TextFieldInterface } from '../interfaces/text-field.interface';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Text fields let users enter text into a UI
|
|
15
|
+
* @status beta
|
|
16
|
+
* @category Input
|
|
17
|
+
*/
|
|
18
|
+
export const TextField = ({
|
|
19
|
+
variant = 'filled',
|
|
20
|
+
disabled = false,
|
|
21
|
+
errorText,
|
|
22
|
+
placeholder,
|
|
23
|
+
suffix,
|
|
24
|
+
name,
|
|
25
|
+
label,
|
|
26
|
+
className,
|
|
27
|
+
supportingText,
|
|
28
|
+
trailingIcon,
|
|
29
|
+
leadingIcon,
|
|
30
|
+
type = 'text',
|
|
31
|
+
textLine = 'singleLine',
|
|
32
|
+
autoComplete = 'on',
|
|
33
|
+
onChange,
|
|
34
|
+
value: defaultValue,
|
|
35
|
+
showSupportingText: defaultShowSupportingText = false,
|
|
36
|
+
...restProps
|
|
37
|
+
}: ReactProps<TextFieldInterface>) => {
|
|
38
|
+
const [value, setValue] = useState(defaultValue ?? '');
|
|
39
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
40
|
+
const [showErrorIcon, setShowErrorIcon] = useState(false);
|
|
41
|
+
const [showSupportingText, setShowSupportingText] = useState(
|
|
42
|
+
defaultShowSupportingText,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
setValue(defaultValue ?? '');
|
|
47
|
+
}, [defaultValue]);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (errorText?.length) {
|
|
51
|
+
setShowErrorIcon(true);
|
|
52
|
+
} else {
|
|
53
|
+
setShowErrorIcon(false);
|
|
54
|
+
}
|
|
55
|
+
}, [errorText]);
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (defaultShowSupportingText) {
|
|
59
|
+
setShowSupportingText(defaultShowSupportingText);
|
|
60
|
+
} else {
|
|
61
|
+
if (supportingText?.length) {
|
|
62
|
+
setShowSupportingText(true);
|
|
63
|
+
} else {
|
|
64
|
+
setShowSupportingText(false);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}, [showSupportingText, supportingText]);
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (isFocused) {
|
|
71
|
+
setShowErrorIcon(false);
|
|
72
|
+
}
|
|
73
|
+
}, [isFocused]);
|
|
74
|
+
|
|
75
|
+
const inputRef = React.useRef<HTMLInputElement & HTMLTextAreaElement>(null);
|
|
76
|
+
|
|
77
|
+
const focusInput = () => {
|
|
78
|
+
if (inputRef.current && !isFocused) {
|
|
79
|
+
inputRef.current.focus();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const handleOnFocus = () => {
|
|
84
|
+
setIsFocused(true);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const handleChange = (
|
|
88
|
+
event: React.ChangeEvent<HTMLInputElement & HTMLTextAreaElement>,
|
|
89
|
+
) => {
|
|
90
|
+
const newValue = event.target.value;
|
|
91
|
+
setValue(newValue); // Update local state
|
|
92
|
+
|
|
93
|
+
setShowErrorIcon(false);
|
|
94
|
+
|
|
95
|
+
// If external onChange prop is provided, call it with the new value
|
|
96
|
+
if (typeof onChange === 'function') {
|
|
97
|
+
onChange(newValue);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const handleBlur = () => {
|
|
102
|
+
setIsFocused(false);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const styles = textFieldStyle({
|
|
106
|
+
showSupportingText,
|
|
107
|
+
isFocused,
|
|
108
|
+
showErrorIcon,
|
|
109
|
+
disabled,
|
|
110
|
+
name,
|
|
111
|
+
label,
|
|
112
|
+
autoComplete,
|
|
113
|
+
className,
|
|
114
|
+
onChange,
|
|
115
|
+
placeholder,
|
|
116
|
+
supportingText,
|
|
117
|
+
type,
|
|
118
|
+
leadingIcon,
|
|
119
|
+
trailingIcon,
|
|
120
|
+
variant,
|
|
121
|
+
errorText,
|
|
122
|
+
value,
|
|
123
|
+
suffix,
|
|
124
|
+
textLine,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const [uuid] = useState(uuidv4());
|
|
128
|
+
|
|
129
|
+
let textComponentProps: object;
|
|
130
|
+
let TextComponent;
|
|
131
|
+
switch (textLine) {
|
|
132
|
+
case 'multiLine':
|
|
133
|
+
TextComponent = TextareaAutosize;
|
|
134
|
+
textComponentProps = {};
|
|
135
|
+
break;
|
|
136
|
+
case 'textAreas':
|
|
137
|
+
TextComponent = 'textarea';
|
|
138
|
+
textComponentProps = {};
|
|
139
|
+
break;
|
|
140
|
+
case 'singleLine':
|
|
141
|
+
default:
|
|
142
|
+
TextComponent = 'input';
|
|
143
|
+
textComponentProps = { type: type };
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<div className={styles.textField} {...restProps}>
|
|
149
|
+
<fieldset onClick={focusInput} className={styles.content}>
|
|
150
|
+
<div className={styles.stateLayer}></div>
|
|
151
|
+
{leadingIcon && (
|
|
152
|
+
<div className={styles.leadingIcon}>
|
|
153
|
+
{React.isValidElement(leadingIcon) ? (
|
|
154
|
+
leadingIcon
|
|
155
|
+
) : (
|
|
156
|
+
<Icon className={'w-5 h-5'} icon={leadingIcon}></Icon>
|
|
157
|
+
)}
|
|
158
|
+
</div>
|
|
159
|
+
)}
|
|
160
|
+
|
|
161
|
+
{!((!isFocused && !value.length) || variant == 'filled') && (
|
|
162
|
+
<motion.legend
|
|
163
|
+
variants={{
|
|
164
|
+
hidden: { width: 0, padding: 0 },
|
|
165
|
+
visible: { width: 'auto', padding: '0 8px' },
|
|
166
|
+
}}
|
|
167
|
+
initial={'hidden'}
|
|
168
|
+
animate={!(!isFocused && !value.length) ? 'visible' : 'hidden'}
|
|
169
|
+
className={'max-w-full ml-2 px-2 text-body-small h-0'}
|
|
170
|
+
transition={{ duration: 0.2 }}
|
|
171
|
+
>
|
|
172
|
+
<span className={'transform inline-flex -translate-y-1/2'}>
|
|
173
|
+
<motion.span
|
|
174
|
+
className={styles.label}
|
|
175
|
+
transition={{ duration: 0.3 }}
|
|
176
|
+
layoutId={uuid}
|
|
177
|
+
>
|
|
178
|
+
{label}
|
|
179
|
+
</motion.span>
|
|
180
|
+
</span>
|
|
181
|
+
</motion.legend>
|
|
182
|
+
)}
|
|
183
|
+
<div className={'flex-1 relative'}>
|
|
184
|
+
{((!isFocused && !value.length) || variant == 'filled') && (
|
|
185
|
+
<motion.label
|
|
186
|
+
htmlFor={name}
|
|
187
|
+
className={classNames(
|
|
188
|
+
'absolute left-4 transition-all duration-300',
|
|
189
|
+
{
|
|
190
|
+
'text-body-small top-2':
|
|
191
|
+
variant == 'filled' && !(!isFocused && !value.length),
|
|
192
|
+
'text-body-large top-1/2 transform -translate-y-1/2': !(
|
|
193
|
+
variant == 'filled' && !(!isFocused && !value.length)
|
|
194
|
+
),
|
|
195
|
+
},
|
|
196
|
+
)}
|
|
197
|
+
transition={{ duration: 0.3 }}
|
|
198
|
+
>
|
|
199
|
+
<motion.span
|
|
200
|
+
className={styles.label}
|
|
201
|
+
transition={{ duration: 0.3 }}
|
|
202
|
+
layoutId={variant == 'outlined' ? uuid : undefined}
|
|
203
|
+
>
|
|
204
|
+
{label}
|
|
205
|
+
</motion.span>
|
|
206
|
+
</motion.label>
|
|
207
|
+
)}
|
|
208
|
+
<TextComponent
|
|
209
|
+
ref={inputRef}
|
|
210
|
+
value={value}
|
|
211
|
+
onChange={handleChange}
|
|
212
|
+
className={styles.input}
|
|
213
|
+
id={name}
|
|
214
|
+
name={name}
|
|
215
|
+
placeholder={isFocused ? (placeholder ?? undefined) : ''}
|
|
216
|
+
onFocus={handleOnFocus}
|
|
217
|
+
onBlur={handleBlur}
|
|
218
|
+
disabled={disabled}
|
|
219
|
+
autoComplete={autoComplete}
|
|
220
|
+
aria-invalid={!!errorText?.length}
|
|
221
|
+
aria-label={label}
|
|
222
|
+
{...textComponentProps}
|
|
223
|
+
/>
|
|
224
|
+
</div>
|
|
225
|
+
|
|
226
|
+
<div className={styles.activeIndicator}></div>
|
|
227
|
+
|
|
228
|
+
{!showErrorIcon && (
|
|
229
|
+
<>
|
|
230
|
+
{trailingIcon && (
|
|
231
|
+
<div
|
|
232
|
+
onClick={(event) => {
|
|
233
|
+
event.stopPropagation();
|
|
234
|
+
}}
|
|
235
|
+
className={styles.trailingIcon}
|
|
236
|
+
>
|
|
237
|
+
{React.isValidElement(trailingIcon) ? (
|
|
238
|
+
trailingIcon
|
|
239
|
+
) : (
|
|
240
|
+
<Icon className={'h-5'} icon={trailingIcon}></Icon>
|
|
241
|
+
)}
|
|
242
|
+
</div>
|
|
243
|
+
)}
|
|
244
|
+
{!trailingIcon && suffix && (
|
|
245
|
+
<span className={styles.suffix}>{suffix}</span>
|
|
246
|
+
)}
|
|
247
|
+
</>
|
|
248
|
+
)}
|
|
249
|
+
|
|
250
|
+
{showErrorIcon && (
|
|
251
|
+
<div
|
|
252
|
+
className={classNames(styles.trailingIcon, {
|
|
253
|
+
' absolute right-0': !trailingIcon,
|
|
254
|
+
})}
|
|
255
|
+
>
|
|
256
|
+
<Icon
|
|
257
|
+
className={'h-5 text-error'}
|
|
258
|
+
icon={faCircleExclamation}
|
|
259
|
+
></Icon>
|
|
260
|
+
</div>
|
|
261
|
+
)}
|
|
262
|
+
</fieldset>
|
|
263
|
+
{showSupportingText && (
|
|
264
|
+
<p className={styles.supportingText}>
|
|
265
|
+
{errorText?.length
|
|
266
|
+
? errorText
|
|
267
|
+
: supportingText?.length
|
|
268
|
+
? supportingText
|
|
269
|
+
: '\u00A0'}
|
|
270
|
+
</p>
|
|
271
|
+
)}
|
|
272
|
+
</div>
|
|
273
|
+
);
|
|
274
|
+
};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { cloneElement, isValidElement, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { MotionProps } from '../utils';
|
|
3
|
+
import { Button } from './Button';
|
|
4
|
+
import { ToolTipInterface } from '../interfaces';
|
|
5
|
+
import { toolStyle } from '../styles';
|
|
6
|
+
import { v4 } from 'uuid';
|
|
7
|
+
import { AnimatePresence, motion } from 'motion/react';
|
|
8
|
+
import { SyncedFixedWrapper } from '../effects';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Tooltips display brief labels or messages
|
|
12
|
+
* @status beta
|
|
13
|
+
* @category Communication
|
|
14
|
+
*/
|
|
15
|
+
export const ToolTip = ({
|
|
16
|
+
variant = 'plain',
|
|
17
|
+
buttons,
|
|
18
|
+
className,
|
|
19
|
+
children,
|
|
20
|
+
title,
|
|
21
|
+
text,
|
|
22
|
+
position,
|
|
23
|
+
targetRef,
|
|
24
|
+
ref,
|
|
25
|
+
trigger = ['hover', 'focus'],
|
|
26
|
+
...props
|
|
27
|
+
}: MotionProps<ToolTipInterface>) => {
|
|
28
|
+
if (!children && !targetRef) {
|
|
29
|
+
throw new Error('ToolTip must have a child or a targetRef');
|
|
30
|
+
}
|
|
31
|
+
if (!Array.isArray(trigger)) {
|
|
32
|
+
trigger = [trigger];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (buttons && !Array.isArray(buttons)) {
|
|
36
|
+
buttons = [buttons];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const internalRef = useRef<HTMLElement | null>(null); // Ref interne au cas où targetRef est undefined
|
|
40
|
+
const resolvedRef = targetRef || internalRef; // Utilise targetRef si défini, sinon internalRef
|
|
41
|
+
|
|
42
|
+
const [currentToolTipId, setCurrentToolTipId] = useState<string | null>(null);
|
|
43
|
+
const [id] = useState(v4());
|
|
44
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
45
|
+
|
|
46
|
+
const timeout = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const handleUpdate = (event: CustomEvent) => {
|
|
50
|
+
setCurrentToolTipId(event.detail);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
document.addEventListener('tooltip-update', handleUpdate as EventListener);
|
|
54
|
+
return () => {
|
|
55
|
+
document.removeEventListener(
|
|
56
|
+
'tooltip-update',
|
|
57
|
+
handleUpdate as EventListener,
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (timeout.current) clearTimeout(timeout.current);
|
|
64
|
+
|
|
65
|
+
if (currentToolTipId) {
|
|
66
|
+
setIsVisible(currentToolTipId === id);
|
|
67
|
+
} else {
|
|
68
|
+
timeout.current = setTimeout(() => {
|
|
69
|
+
setIsVisible(false);
|
|
70
|
+
}, 1200);
|
|
71
|
+
}
|
|
72
|
+
}, [currentToolTipId, id]);
|
|
73
|
+
|
|
74
|
+
// Ajouter des gestionnaires sur l'élément cible (targetRef ou internalRef)
|
|
75
|
+
|
|
76
|
+
const handleMouseEnter = () => {
|
|
77
|
+
if (trigger.includes('hover')) {
|
|
78
|
+
const event = new CustomEvent('tooltip-update', { detail: id });
|
|
79
|
+
document.dispatchEvent(event);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const handleMouseLeave = () => {
|
|
84
|
+
if (trigger.includes('hover')) {
|
|
85
|
+
const event = new CustomEvent('tooltip-update', { detail: null });
|
|
86
|
+
document.dispatchEvent(event);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const handleClick = () => {
|
|
91
|
+
if (trigger.includes('click')) {
|
|
92
|
+
const event = new CustomEvent('tooltip-update', {
|
|
93
|
+
detail: isVisible ? null : id,
|
|
94
|
+
});
|
|
95
|
+
document.dispatchEvent(event);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const handleFocus = () => {
|
|
100
|
+
if (trigger.includes('focus')) {
|
|
101
|
+
const event = new CustomEvent('tooltip-update', { detail: id });
|
|
102
|
+
document.dispatchEvent(event);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const handleBlur = () => {
|
|
107
|
+
if (trigger.includes('focus')) {
|
|
108
|
+
const event = new CustomEvent('tooltip-update', { detail: null });
|
|
109
|
+
document.dispatchEvent(event);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (resolvedRef?.current) {
|
|
115
|
+
const targetElement = resolvedRef.current;
|
|
116
|
+
|
|
117
|
+
targetElement.addEventListener('mouseenter', handleMouseEnter);
|
|
118
|
+
targetElement.addEventListener('mouseleave', handleMouseLeave);
|
|
119
|
+
targetElement.addEventListener('click', handleClick);
|
|
120
|
+
targetElement.addEventListener('focus', handleFocus);
|
|
121
|
+
targetElement.addEventListener('blur', handleBlur);
|
|
122
|
+
|
|
123
|
+
// Nettoyage au démontage
|
|
124
|
+
return () => {
|
|
125
|
+
targetElement.removeEventListener('mouseenter', handleMouseEnter);
|
|
126
|
+
targetElement.removeEventListener('mouseleave', handleMouseLeave);
|
|
127
|
+
targetElement.removeEventListener('click', handleClick);
|
|
128
|
+
targetElement.removeEventListener('focus', handleFocus);
|
|
129
|
+
targetElement.removeEventListener('blur', handleBlur);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return;
|
|
133
|
+
}, [resolvedRef, trigger, id, isVisible]);
|
|
134
|
+
|
|
135
|
+
// Si targetRef est undefined, on applique la réf au premier enfant
|
|
136
|
+
const enhancedChildren =
|
|
137
|
+
!targetRef && isValidElement(children)
|
|
138
|
+
? cloneElement(children, { ref: internalRef } as any)
|
|
139
|
+
: children;
|
|
140
|
+
|
|
141
|
+
if (!position && typeof window !== 'undefined') {
|
|
142
|
+
if (resolvedRef?.current && !position) {
|
|
143
|
+
const rect = resolvedRef.current.getBoundingClientRect();
|
|
144
|
+
|
|
145
|
+
const viewportWidth = window.innerWidth;
|
|
146
|
+
const viewportHeight = window.innerHeight;
|
|
147
|
+
|
|
148
|
+
const x = rect.left / viewportWidth; // X entre 0 et 1
|
|
149
|
+
const y = rect.top / viewportHeight; // Y entre 0 et 1
|
|
150
|
+
|
|
151
|
+
if (variant === 'plain') {
|
|
152
|
+
if (x < 1 / 3) {
|
|
153
|
+
position = 'right';
|
|
154
|
+
} else if (x > 2 / 3) {
|
|
155
|
+
position = 'left';
|
|
156
|
+
} else {
|
|
157
|
+
position = y > 0.5 ? 'top' : 'bottom';
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
if (x < 1 / 2 && y < 1 / 2) {
|
|
161
|
+
position = 'bottom-right';
|
|
162
|
+
} else if (x > 1 / 2 && y < 1 / 2) {
|
|
163
|
+
position = 'bottom-left';
|
|
164
|
+
} else if (x > 1 / 2 && y > 1 / 2) {
|
|
165
|
+
position = 'top-left';
|
|
166
|
+
} else if (x < 1 / 2 && y > 1 / 2) {
|
|
167
|
+
position = 'top-right';
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const styles = toolStyle({
|
|
174
|
+
variant,
|
|
175
|
+
buttons,
|
|
176
|
+
className,
|
|
177
|
+
title,
|
|
178
|
+
text,
|
|
179
|
+
position,
|
|
180
|
+
trigger,
|
|
181
|
+
targetRef: targetRef as any,
|
|
182
|
+
children: children as any,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<>
|
|
187
|
+
{enhancedChildren}
|
|
188
|
+
<AnimatePresence>
|
|
189
|
+
{isVisible && (
|
|
190
|
+
<SyncedFixedWrapper targetRef={resolvedRef}>
|
|
191
|
+
<motion.div
|
|
192
|
+
initial={{ opacity: currentToolTipId ? 1 : 0 }}
|
|
193
|
+
animate={{ opacity: 1 }}
|
|
194
|
+
transition={{ duration: currentToolTipId ? 0 : 0.3 }}
|
|
195
|
+
exit={{ opacity: currentToolTipId ? 1 : 0 }}
|
|
196
|
+
className={styles.toolTip}
|
|
197
|
+
{...props}
|
|
198
|
+
onMouseEnter={handleMouseEnter}
|
|
199
|
+
onMouseLeave={handleMouseLeave}
|
|
200
|
+
>
|
|
201
|
+
<motion.div
|
|
202
|
+
className={styles.container}
|
|
203
|
+
layoutId={'tool-tip'}
|
|
204
|
+
transition={{
|
|
205
|
+
type: 'spring',
|
|
206
|
+
stiffness: 200,
|
|
207
|
+
damping: 20,
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
{title && <div className={styles.subHead}>{title}</div>}
|
|
211
|
+
<div className={styles.supportingText}>{text}</div>
|
|
212
|
+
{buttons && (
|
|
213
|
+
<div className={styles.actions}>
|
|
214
|
+
{Array.isArray(buttons) &&
|
|
215
|
+
buttons.map((buttonArgs, index) => (
|
|
216
|
+
<Button
|
|
217
|
+
key={index}
|
|
218
|
+
size={'small'}
|
|
219
|
+
variant={'text'}
|
|
220
|
+
{...buttonArgs}
|
|
221
|
+
/>
|
|
222
|
+
))}
|
|
223
|
+
</div>
|
|
224
|
+
)}
|
|
225
|
+
</motion.div>
|
|
226
|
+
</motion.div>
|
|
227
|
+
</SyncedFixedWrapper>
|
|
228
|
+
)}
|
|
229
|
+
</AnimatePresence>
|
|
230
|
+
</>
|
|
231
|
+
);
|
|
232
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from './Button';
|
|
2
|
+
export * from './Card';
|
|
3
|
+
export * from './Carousel';
|
|
4
|
+
export * from './CarouselItem';
|
|
5
|
+
export * from './CarouselItem';
|
|
6
|
+
export * from './Divider';
|
|
7
|
+
export * from './Fab';
|
|
8
|
+
export * from './IconButton';
|
|
9
|
+
export * from './IconButton';
|
|
10
|
+
export * from './ProgressIndicator';
|
|
11
|
+
export * from './Slider';
|
|
12
|
+
export * from './Snackbar';
|
|
13
|
+
export * from './Switch';
|
|
14
|
+
export * from './Tab';
|
|
15
|
+
export * from './Tabs';
|
|
16
|
+
export * from './TextField';
|
|
17
|
+
export * from './NavigationRailItem';
|
|
18
|
+
export * from './NavigationRail';
|
|
19
|
+
export * from './ToolTip';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ReactNode,
|
|
3
|
+
type RefObject,
|
|
4
|
+
useEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import { createPortal } from 'react-dom';
|
|
9
|
+
|
|
10
|
+
type SyncedFixedWrapperProps = {
|
|
11
|
+
targetRef: RefObject<any>;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const SyncedFixedWrapper = ({
|
|
16
|
+
targetRef,
|
|
17
|
+
children,
|
|
18
|
+
}: SyncedFixedWrapperProps) => {
|
|
19
|
+
const [style, setStyle] = useState<React.CSSProperties | null>(null);
|
|
20
|
+
const resizeObserver = useRef<ResizeObserver | null>(null);
|
|
21
|
+
|
|
22
|
+
const updatePosition = () => {
|
|
23
|
+
const target = targetRef.current;
|
|
24
|
+
if (!target) return;
|
|
25
|
+
|
|
26
|
+
const rect = target.getBoundingClientRect();
|
|
27
|
+
|
|
28
|
+
setStyle({
|
|
29
|
+
position: 'fixed',
|
|
30
|
+
top: rect.top,
|
|
31
|
+
left: rect.left,
|
|
32
|
+
width: rect.width,
|
|
33
|
+
height: rect.height,
|
|
34
|
+
pointerEvents: 'none', // si le wrapper ne doit pas capter les events
|
|
35
|
+
zIndex: 999, // personnalise si besoin
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const target = targetRef.current;
|
|
41
|
+
if (!target) return;
|
|
42
|
+
|
|
43
|
+
updatePosition();
|
|
44
|
+
|
|
45
|
+
window.addEventListener('scroll', updatePosition, true);
|
|
46
|
+
window.addEventListener('resize', updatePosition);
|
|
47
|
+
|
|
48
|
+
// Observe resize of the target element
|
|
49
|
+
resizeObserver.current = new ResizeObserver(updatePosition);
|
|
50
|
+
resizeObserver.current.observe(target);
|
|
51
|
+
|
|
52
|
+
return () => {
|
|
53
|
+
window.removeEventListener('scroll', updatePosition, true);
|
|
54
|
+
window.removeEventListener('resize', updatePosition);
|
|
55
|
+
resizeObserver.current?.disconnect();
|
|
56
|
+
};
|
|
57
|
+
}, [targetRef]);
|
|
58
|
+
|
|
59
|
+
if (!style) return null;
|
|
60
|
+
|
|
61
|
+
return createPortal(<div style={style}>{children}</div>, document.body);
|
|
62
|
+
};
|