@donotdev/components 0.3.1 → 0.3.2
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/dist/advanced/Bento/Bento.js +1 -37
- package/dist/advanced/Bento/index.js +1 -2
- package/dist/advanced/Carousel/Carousel.js +1 -36
- package/dist/advanced/Carousel/CarouselContent.d.ts.map +1 -1
- package/dist/advanced/Carousel/CarouselContent.js +1 -653
- package/dist/advanced/Carousel/CarouselSkeleton.js +1 -51
- package/dist/advanced/Carousel/index.js +1 -2
- package/dist/advanced/Code/Code.js +2 -35
- package/dist/advanced/Code/CodeContent.d.ts.map +1 -1
- package/dist/advanced/Code/CodeContent.js +2 -182
- package/dist/advanced/Code/CodeSkeleton.js +1 -51
- package/dist/advanced/Code/index.js +1 -2
- package/dist/advanced/Crawl/Crawl.d.ts.map +1 -1
- package/dist/advanced/Crawl/Crawl.js +1 -84
- package/dist/advanced/Crawl/CrawlContent.d.ts.map +1 -1
- package/dist/advanced/Crawl/CrawlContent.js +1 -118
- package/dist/advanced/Crawl/index.js +1 -3
- package/dist/advanced/Crawl/utils/parseHtml.js +1 -159
- package/dist/advanced/ImageGallery/GalleryArrows.d.ts.map +1 -1
- package/dist/advanced/ImageGallery/GalleryArrows.js +1 -13
- package/dist/advanced/ImageGallery/ImageGallery.d.ts.map +1 -1
- package/dist/advanced/ImageGallery/ImageGallery.js +1 -181
- package/dist/advanced/ImageGallery/LightboxViewer.js +1 -138
- package/dist/advanced/ImageGallery/index.js +1 -2
- package/dist/advanced/ImageGallery/lightboxGestures.js +1 -425
- package/dist/advanced/ImageGallery/protectImages.js +1 -10
- package/dist/advanced/ImageGallery/snapStrip.d.ts.map +1 -1
- package/dist/advanced/ImageGallery/snapStrip.js +1 -74
- package/dist/advanced/JsonViewer/JsonViewer.js +1 -141
- package/dist/advanced/JsonViewer/index.js +1 -3
- package/dist/advanced/Marquee/Marquee.js +1 -35
- package/dist/advanced/Marquee/MarqueeContent.d.ts.map +1 -1
- package/dist/advanced/Marquee/MarqueeContent.js +1 -193
- package/dist/advanced/Marquee/MarqueeSkeleton.js +1 -36
- package/dist/advanced/Marquee/index.js +1 -3
- package/dist/advanced/Reveal/Reveal.d.ts.map +1 -1
- package/dist/advanced/Reveal/Reveal.js +1 -60
- package/dist/advanced/Reveal/index.js +1 -3
- package/dist/advanced/Roadmap/Roadmap.js +1 -6
- package/dist/advanced/Roadmap/RoadmapContent.d.ts.map +1 -1
- package/dist/advanced/Roadmap/RoadmapContent.js +1 -59
- package/dist/advanced/Roadmap/index.js +1 -3
- package/dist/advanced/SplitReveal/SplitReveal.js +1 -34
- package/dist/advanced/SplitReveal/index.js +1 -2
- package/dist/advanced/StackedCards/StackedCards.js +1 -22
- package/dist/advanced/StackedCards/StackedCardsContent.d.ts.map +1 -1
- package/dist/advanced/StackedCards/StackedCardsContent.js +1 -42
- package/dist/advanced/StackedCards/index.js +1 -3
- package/dist/advanced/index.js +1 -20
- package/dist/atomic/Accordion/AccordionPrimitive.d.ts +5 -1
- package/dist/atomic/Accordion/AccordionPrimitive.d.ts.map +1 -1
- package/dist/atomic/Accordion/AccordionPrimitive.js +1 -29
- package/dist/atomic/Accordion/index.d.ts +9 -1
- package/dist/atomic/Accordion/index.d.ts.map +1 -1
- package/dist/atomic/Accordion/index.js +1 -38
- package/dist/atomic/ActionButton/index.js +1 -70
- package/dist/atomic/ActionButton/useAction.d.ts.map +1 -1
- package/dist/atomic/ActionButton/useAction.js +1 -64
- package/dist/atomic/Alert/index.d.ts +1 -1
- package/dist/atomic/Alert/index.js +1 -78
- package/dist/atomic/AlertDialog/AlertDialogPrimitive.d.ts.map +1 -1
- package/dist/atomic/AlertDialog/AlertDialogPrimitive.js +1 -25
- package/dist/atomic/AlertDialog/index.d.ts.map +1 -1
- package/dist/atomic/AlertDialog/index.js +1 -36
- package/dist/atomic/Avatar/AvatarPrimitive.d.ts.map +1 -1
- package/dist/atomic/Avatar/AvatarPrimitive.js +1 -16
- package/dist/atomic/Avatar/index.js +1 -17
- package/dist/atomic/Badge/index.d.ts +1 -1
- package/dist/atomic/Badge/index.js +1 -84
- package/dist/atomic/Blockquote/index.js +1 -72
- package/dist/atomic/Button/index.d.ts +1 -1
- package/dist/atomic/Button/index.js +1 -173
- package/dist/atomic/ButtonGroup/index.d.ts.map +1 -1
- package/dist/atomic/ButtonGroup/index.js +1 -57
- package/dist/atomic/Calendar/CalendarPrimitive.d.ts.map +1 -1
- package/dist/atomic/Calendar/CalendarPrimitive.js +1 -10
- package/dist/atomic/Calendar/LazyCalendar.d.ts +38 -0
- package/dist/atomic/Calendar/LazyCalendar.d.ts.map +1 -0
- package/dist/atomic/Calendar/LazyCalendar.js +1 -0
- package/dist/atomic/Calendar/index.d.ts.map +1 -1
- package/dist/atomic/Calendar/index.js +1 -74
- package/dist/atomic/CallToAction/index.js +1 -78
- package/dist/atomic/Card/cover.js +1 -40
- package/dist/atomic/Card/index.d.ts +12 -2
- package/dist/atomic/Card/index.d.ts.map +1 -1
- package/dist/atomic/Card/index.js +1 -190
- package/dist/atomic/Checkbox/CheckboxPrimitive.d.ts.map +1 -1
- package/dist/atomic/Checkbox/CheckboxPrimitive.js +1 -26
- package/dist/atomic/Checkbox/index.js +1 -69
- package/dist/atomic/Collapsible/CollapsiblePrimitive.d.ts.map +1 -1
- package/dist/atomic/Collapsible/CollapsiblePrimitive.js +1 -25
- package/dist/atomic/Collapsible/index.d.ts.map +1 -1
- package/dist/atomic/Collapsible/index.js +1 -61
- package/dist/atomic/ColorPicker/index.d.ts.map +1 -1
- package/dist/atomic/ColorPicker/index.js +1 -196
- package/dist/atomic/Combobox/index.d.ts.map +1 -1
- package/dist/atomic/Combobox/index.js +1 -278
- package/dist/atomic/Command/index.d.ts.map +1 -1
- package/dist/atomic/Command/index.js +1 -115
- package/dist/atomic/CommandDialog/index.d.ts.map +1 -1
- package/dist/atomic/CommandDialog/index.js +1 -34
- package/dist/atomic/ContextMenu/ContextMenuPrimitive.d.ts.map +1 -1
- package/dist/atomic/ContextMenu/ContextMenuPrimitive.js +1 -32
- package/dist/atomic/ContextMenu/index.d.ts.map +1 -1
- package/dist/atomic/ContextMenu/index.js +1 -52
- package/dist/atomic/CopyToClipboard/index.d.ts.map +1 -1
- package/dist/atomic/CopyToClipboard/index.js +1 -61
- package/dist/atomic/DatePicker/index.d.ts +3 -1
- package/dist/atomic/DatePicker/index.d.ts.map +1 -1
- package/dist/atomic/DatePicker/index.js +1 -377
- package/dist/atomic/DateTimePicker/index.d.ts +3 -1
- package/dist/atomic/DateTimePicker/index.d.ts.map +1 -1
- package/dist/atomic/DateTimePicker/index.js +1 -460
- package/dist/atomic/DescriptionList/index.js +1 -30
- package/dist/atomic/Dialog/DialogPrimitive.d.ts.map +1 -1
- package/dist/atomic/Dialog/DialogPrimitive.js +1 -20
- package/dist/atomic/Dialog/index.d.ts.map +1 -1
- package/dist/atomic/Dialog/index.js +1 -63
- package/dist/atomic/DropdownMenu/DropdownMenuPrimitive.d.ts.map +1 -1
- package/dist/atomic/DropdownMenu/DropdownMenuPrimitive.js +1 -34
- package/dist/atomic/DropdownMenu/index.d.ts.map +1 -1
- package/dist/atomic/DropdownMenu/index.js +1 -121
- package/dist/atomic/DualCard/index.d.ts.map +1 -1
- package/dist/atomic/DualCard/index.js +1 -42
- package/dist/atomic/FeatureFallback/index.js +1 -32
- package/dist/atomic/FileButton/index.d.ts.map +1 -1
- package/dist/atomic/FileButton/index.js +1 -35
- package/dist/atomic/Grid/GridArea.js +1 -70
- package/dist/atomic/Grid/index.js +1 -118
- package/dist/atomic/HeroSection/index.d.ts +1 -1
- package/dist/atomic/HeroSection/index.js +1 -138
- package/dist/atomic/HoverCard/HoverCardPrimitive.d.ts.map +1 -1
- package/dist/atomic/HoverCard/HoverCardPrimitive.js +1 -19
- package/dist/atomic/HoverCard/index.d.ts.map +1 -1
- package/dist/atomic/HoverCard/index.js +1 -57
- package/dist/atomic/Icons/Icon.js +1 -37
- package/dist/atomic/Icons/IconBox.js +1 -49
- package/dist/atomic/Icons/Partner/AppleIcon.js +1 -31
- package/dist/atomic/Icons/Partner/DiscordIcon.js +1 -15
- package/dist/atomic/Icons/Partner/FacebookIcon.js +1 -15
- package/dist/atomic/Icons/Partner/GitHubIcon.js +1 -15
- package/dist/atomic/Icons/Partner/GoogleIcon.js +1 -15
- package/dist/atomic/Icons/Partner/InstagramIcon.js +1 -29
- package/dist/atomic/Icons/Partner/LinkedinIcon.js +1 -20
- package/dist/atomic/Icons/Partner/MastodonIcon.js +1 -19
- package/dist/atomic/Icons/Partner/MediumIcon.js +1 -19
- package/dist/atomic/Icons/Partner/MicrosoftIcon.js +1 -15
- package/dist/atomic/Icons/Partner/NotionIcon.js +1 -15
- package/dist/atomic/Icons/Partner/RedditIcon.js +1 -15
- package/dist/atomic/Icons/Partner/SlackIcon.js +1 -15
- package/dist/atomic/Icons/Partner/SpotifyIcon.js +1 -15
- package/dist/atomic/Icons/Partner/SupabaseIcon.js +1 -16
- package/dist/atomic/Icons/Partner/TwitchIcon.js +1 -15
- package/dist/atomic/Icons/Partner/XIcon.js +1 -15
- package/dist/atomic/Icons/Partner/YahooIcon.js +1 -15
- package/dist/atomic/Icons/Partner/YouTubeIcon.js +1 -19
- package/dist/atomic/Icons/Partner/index.js +1 -25
- package/dist/atomic/Icons/Partner/providerIcons.js +1 -98
- package/dist/atomic/Icons/index.js +1 -8
- package/dist/atomic/InfiniteScroll/index.d.ts.map +1 -1
- package/dist/atomic/InfiniteScroll/index.js +1 -53
- package/dist/atomic/Input/index.d.ts.map +1 -1
- package/dist/atomic/Input/index.js +1 -63
- package/dist/atomic/Label/FieldInfo.js +1 -34
- package/dist/atomic/Label/FloatingLabel.js +1 -35
- package/dist/atomic/Label/LabelPrimitive.d.ts.map +1 -1
- package/dist/atomic/Label/LabelPrimitive.js +1 -16
- package/dist/atomic/Label/index.js +1 -23
- package/dist/atomic/List/index.js +1 -48
- package/dist/atomic/NavigationMenu/NavigationMenuPrimitive.d.ts.map +1 -1
- package/dist/atomic/NavigationMenu/NavigationMenuPrimitive.js +1 -28
- package/dist/atomic/NavigationMenu/index.js +1 -72
- package/dist/atomic/Pagination/index.d.ts.map +1 -1
- package/dist/atomic/Pagination/index.js +1 -107
- package/dist/atomic/PasswordInput/index.d.ts.map +1 -1
- package/dist/atomic/PasswordInput/index.js +1 -66
- package/dist/atomic/PinInput/index.d.ts.map +1 -1
- package/dist/atomic/PinInput/index.js +1 -155
- package/dist/atomic/Popover/PopoverPrimitive.d.ts.map +1 -1
- package/dist/atomic/Popover/PopoverPrimitive.js +1 -29
- package/dist/atomic/Popover/index.d.ts.map +1 -1
- package/dist/atomic/Popover/index.js +1 -38
- package/dist/atomic/Portal/PortalPrimitive.d.ts.map +1 -1
- package/dist/atomic/Portal/PortalPrimitive.js +1 -21
- package/dist/atomic/Portal/index.js +1 -10
- package/dist/atomic/PortalButton/index.js +1 -33
- package/dist/atomic/Progress/ProgressPrimitive.d.ts.map +1 -1
- package/dist/atomic/Progress/ProgressPrimitive.js +1 -28
- package/dist/atomic/Progress/index.js +1 -15
- package/dist/atomic/QuantityStepper/index.js +1 -239
- package/dist/atomic/QuantityStepper/quantity.js +1 -35
- package/dist/atomic/RadioGroup/RadioGroupPrimitive.d.ts.map +1 -1
- package/dist/atomic/RadioGroup/RadioGroupPrimitive.js +1 -17
- package/dist/atomic/RadioGroup/index.js +1 -63
- package/dist/atomic/RangeInput/index.d.ts.map +1 -1
- package/dist/atomic/RangeInput/index.js +1 -62
- package/dist/atomic/Rating/index.d.ts +1 -1
- package/dist/atomic/Rating/index.d.ts.map +1 -1
- package/dist/atomic/Rating/index.js +1 -115
- package/dist/atomic/ScrollArea/ScrollAreaPrimitive.d.ts.map +1 -1
- package/dist/atomic/ScrollArea/ScrollAreaPrimitive.js +1 -18
- package/dist/atomic/ScrollArea/index.js +1 -22
- package/dist/atomic/Section/index.d.ts +6 -0
- package/dist/atomic/Section/index.d.ts.map +1 -1
- package/dist/atomic/Section/index.js +1 -119
- package/dist/atomic/Select/SelectPrimitive.d.ts.map +1 -1
- package/dist/atomic/Select/SelectPrimitive.js +1 -27
- package/dist/atomic/Select/index.d.ts.map +1 -1
- package/dist/atomic/Select/index.js +1 -58
- package/dist/atomic/Separator/SeparatorPrimitive.d.ts.map +1 -1
- package/dist/atomic/Separator/SeparatorPrimitive.js +1 -15
- package/dist/atomic/Separator/index.js +1 -47
- package/dist/atomic/Sheet/SheetPrimitive.d.ts.map +1 -1
- package/dist/atomic/Sheet/SheetPrimitive.js +1 -24
- package/dist/atomic/Sheet/index.d.ts.map +1 -1
- package/dist/atomic/Sheet/index.js +1 -66
- package/dist/atomic/Skeleton/index.js +1 -73
- package/dist/atomic/SkipLink/index.d.ts.map +1 -1
- package/dist/atomic/SkipLink/index.js +1 -45
- package/dist/atomic/Slider/SliderPrimitive.d.ts.map +1 -1
- package/dist/atomic/Slider/SliderPrimitive.js +1 -35
- package/dist/atomic/Slider/index.d.ts +11 -2
- package/dist/atomic/Slider/index.d.ts.map +1 -1
- package/dist/atomic/Slider/index.js +1 -59
- package/dist/atomic/Slot/SlotPrimitive.d.ts.map +1 -1
- package/dist/atomic/Slot/SlotPrimitive.js +1 -10
- package/dist/atomic/Slot/index.js +1 -21
- package/dist/atomic/Spinner/index.js +1 -72
- package/dist/atomic/Stack/index.js +1 -84
- package/dist/atomic/Stepper/index.d.ts +1 -1
- package/dist/atomic/Stepper/index.d.ts.map +1 -1
- package/dist/atomic/Stepper/index.js +1 -100
- package/dist/atomic/SwipeAction/index.js +1 -62
- package/dist/atomic/Switch/SwitchPrimitive.d.ts.map +1 -1
- package/dist/atomic/Switch/SwitchPrimitive.js +1 -28
- package/dist/atomic/Switch/index.d.ts.map +1 -1
- package/dist/atomic/Switch/index.js +1 -82
- package/dist/atomic/Table/editing.d.ts.map +1 -1
- package/dist/atomic/Table/editing.js +4 -173
- package/dist/atomic/Table/index.d.ts.map +1 -1
- package/dist/atomic/Table/index.js +3 -419
- package/dist/atomic/Tabs/TabsPrimitive.d.ts.map +1 -1
- package/dist/atomic/Tabs/TabsPrimitive.js +1 -17
- package/dist/atomic/Tabs/index.d.ts +1 -1
- package/dist/atomic/Tabs/index.d.ts.map +1 -1
- package/dist/atomic/Tabs/index.js +1 -124
- package/dist/atomic/Tag/index.d.ts.map +1 -1
- package/dist/atomic/Tag/index.js +1 -60
- package/dist/atomic/Text/index.js +3 -116
- package/dist/atomic/Textarea/index.js +1 -20
- package/dist/atomic/Toaster/Toast.types.js +0 -2
- package/dist/atomic/Toaster/ToastPrimitive.d.ts +1 -1
- package/dist/atomic/Toaster/ToastPrimitive.d.ts.map +1 -1
- package/dist/atomic/Toaster/ToastPrimitive.js +1 -68
- package/dist/atomic/Toaster/index.d.ts.map +1 -1
- package/dist/atomic/Toaster/index.js +1 -30
- package/dist/atomic/Toggle/TogglePrimitive.d.ts.map +1 -1
- package/dist/atomic/Toggle/TogglePrimitive.js +1 -16
- package/dist/atomic/Toggle/index.d.ts +1 -1
- package/dist/atomic/Toggle/index.js +1 -41
- package/dist/atomic/ToggleGroup/ToggleGroupPrimitive.d.ts.map +1 -1
- package/dist/atomic/ToggleGroup/ToggleGroupPrimitive.js +1 -36
- package/dist/atomic/ToggleGroup/index.js +1 -64
- package/dist/atomic/Tooltip/TooltipPrimitive.d.ts.map +1 -1
- package/dist/atomic/Tooltip/TooltipPrimitive.js +1 -20
- package/dist/atomic/Tooltip/index.js +1 -84
- package/dist/atomic/TreeView/index.d.ts.map +1 -1
- package/dist/atomic/TreeView/index.js +1 -316
- package/dist/atomic/VideoPlayer/index.d.ts.map +1 -1
- package/dist/atomic/VideoPlayer/index.js +1 -204
- package/dist/atomic/VisuallyHidden/VisuallyHiddenPrimitive.d.ts.map +1 -1
- package/dist/atomic/VisuallyHidden/VisuallyHiddenPrimitive.js +1 -10
- package/dist/atomic/VisuallyHidden/index.js +1 -4
- package/dist/atomic/index.js +1 -124
- package/dist/hooks/index.js +1 -14
- package/dist/hooks/useClickOutside.d.ts.map +1 -1
- package/dist/hooks/useClickOutside.js +1 -128
- package/dist/hooks/useIntersectionObserver.d.ts.map +1 -1
- package/dist/hooks/useIntersectionObserver.js +1 -222
- package/dist/hooks/useSwipeToClose.d.ts.map +1 -1
- package/dist/hooks/useSwipeToClose.js +1 -280
- package/dist/hooks/useToast.d.ts +1 -1
- package/dist/hooks/useToast.d.ts.map +1 -1
- package/dist/hooks/useToast.js +1 -419
- package/dist/hooks/useViewportVisibility.d.ts.map +1 -1
- package/dist/hooks/useViewportVisibility.js +1 -110
- package/dist/index.js +1 -12
- package/dist/rsc.d.ts +47 -0
- package/dist/rsc.d.ts.map +1 -0
- package/dist/rsc.js +1 -0
- package/dist/styles/componentConstants.js +1 -184
- package/dist/styles/index.css +25 -4
- package/dist/styles/index.js +1 -10
- package/dist/symbol-index.json +1 -1
- package/dist/types.js +0 -2
- package/dist/utils/constants.js +1 -62
- package/dist/utils/cssVars.js +1 -10
- package/dist/utils/date.js +1 -130
- package/dist/utils/eventListener.js +1 -57
- package/dist/utils/helpers.js +1 -58
- package/dist/utils/imageRetry.js +1 -35
- package/dist/utils/index.js +1 -24
- package/dist/utils/initRipple.js +6 -84
- package/dist/utils/intersectionObserver.js +1 -184
- package/dist/utils/isDark.d.ts.map +1 -1
- package/dist/utils/isDark.js +1 -69
- package/dist/utils/linkComponent.d.ts.map +1 -1
- package/dist/utils/linkComponent.js +1 -37
- package/dist/utils/measurement.js +1 -197
- package/dist/utils/responsiveImage.js +1 -45
- package/dist/utils/rtl.js +1 -56
- package/dist/utils/sanitizeHtml.js +1 -43
- package/dist/utils/variants.d.ts +1 -1
- package/dist/utils/variants.js +1 -31
- package/dist/utils/viewportDetection.js +1 -86
- package/guidelines/API_REFERENCE.md +34 -0
- package/guidelines/COMPONENTS.md +1 -1
- package/package.json +5 -1
- package/dist/CarouselContent-5W2E2F2I.js +0 -1
- package/dist/CarouselContent-EELYAALW.js +0 -1
- package/dist/CarouselContent-KLQY6OVW.css +0 -1
- package/dist/CarouselContent-MQPZBYOS.js +0 -1
- package/dist/CodeContent-265AM7HO.css +0 -1
- package/dist/CodeContent-64D4U3NM.js +0 -2
- package/dist/CodeContent-7FWYPAB3.js +0 -2
- package/dist/CodeContent-E3HLW6BW.js +0 -2
- package/dist/CrawlContent-5Z6AVDDW.js +0 -1
- package/dist/MarqueeContent-7BVN7TX3.css +0 -1
- package/dist/MarqueeContent-KAYCOUNM.js +0 -1
- package/dist/atomic/SwipeAction/gesture.d.ts +0 -5
- package/dist/atomic/SwipeAction/gesture.d.ts.map +0 -1
- package/dist/atomic/SwipeAction/gesture.js +0 -10
- package/dist/chunk-3WHSDDVJ.js +0 -1
- package/dist/chunk-CIBFOOWV.js +0 -1
- package/dist/chunk-IFHHPSKN.js +0 -1
- package/dist/chunk-JAV36ZQC.js +0 -3
- package/dist/chunk-O2XFH626.js +0 -1
- package/dist/chunk-SZNEXFUZ.js +0 -3
- package/dist/chunk-UTPWB5VD.js +0 -1
- package/dist/chunk-XK52GUFA.js +0 -3
package/dist/types.js
CHANGED
package/dist/utils/constants.js
CHANGED
|
@@ -1,62 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Shared constants for components
|
|
4
|
-
* @description DRY constants used across multiple components
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Theme variant constants - universal color variants used across all components
|
|
8
|
-
* Single source of truth for theme-based color variants
|
|
9
|
-
*/
|
|
10
|
-
export const THEME_VARIANT = {
|
|
11
|
-
DEFAULT: 'default',
|
|
12
|
-
MUTED: 'muted',
|
|
13
|
-
PRIMARY: 'primary',
|
|
14
|
-
SECONDARY: 'secondary',
|
|
15
|
-
ACCENT: 'accent',
|
|
16
|
-
SUCCESS: 'success',
|
|
17
|
-
WARNING: 'warning',
|
|
18
|
-
DESTRUCTIVE: 'destructive',
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Surface variant constants - matches .dndev-surface CSS class
|
|
22
|
-
* Used by Card, Dialog, Sheet, Alert (all components using dndev-surface)
|
|
23
|
-
*/
|
|
24
|
-
export const SURFACE_VARIANT = {
|
|
25
|
-
...THEME_VARIANT,
|
|
26
|
-
OUTLINE: 'outline',
|
|
27
|
-
GLASS: 'glass',
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Floating variant constants - matches .dndev-floating CSS class
|
|
31
|
-
* Used by Popover, DropdownMenu, Select, HoverCard, Tooltip (all components using dndev-floating)
|
|
32
|
-
*/
|
|
33
|
-
export const FLOATING_VARIANT = THEME_VARIANT;
|
|
34
|
-
/**
|
|
35
|
-
* Control variant constants (Checkbox, Switch, Slider, RadioGroup)
|
|
36
|
-
* Semantic color variants for form controls
|
|
37
|
-
* Uses all THEME_VARIANT values, defaults to primary like Button
|
|
38
|
-
*/
|
|
39
|
-
export const CONTROL_VARIANT = THEME_VARIANT;
|
|
40
|
-
/**
|
|
41
|
-
* Tone constants - background tone variants for breakthrough components
|
|
42
|
-
* Used by Section, HeroSection, CallToAction, TechBento for background colors
|
|
43
|
-
* Single source of truth for tone values
|
|
44
|
-
*/
|
|
45
|
-
export const TONE = {
|
|
46
|
-
GHOST: 'ghost',
|
|
47
|
-
BASE: 'base',
|
|
48
|
-
MUTED: 'muted',
|
|
49
|
-
CONTRAST: 'contrast',
|
|
50
|
-
ACCENT: 'accent',
|
|
51
|
-
PRIMARY: 'primary',
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Text alignment constants - text flow direction
|
|
55
|
-
* Used by Section, HeroSection, CallToAction, Stack, Grid, Text
|
|
56
|
-
* Single source of truth for text-align values
|
|
57
|
-
*/
|
|
58
|
-
export const TEXT_ALIGN = {
|
|
59
|
-
START: 'start',
|
|
60
|
-
CENTER: 'center',
|
|
61
|
-
END: 'end',
|
|
62
|
-
};
|
|
1
|
+
var t={DEFAULT:"default",MUTED:"muted",PRIMARY:"primary",SECONDARY:"secondary",ACCENT:"accent",SUCCESS:"success",WARNING:"warning",DESTRUCTIVE:"destructive"},e={...t,OUTLINE:"outline",GLASS:"glass"},o=t,T=t,A={GHOST:"ghost",BASE:"base",MUTED:"muted",CONTRAST:"contrast",ACCENT:"accent",PRIMARY:"primary"},r={START:"start",CENTER:"center",END:"end"};export{T as CONTROL_VARIANT,o as FLOATING_VARIANT,e as SURFACE_VARIANT,r as TEXT_ALIGN,t as THEME_VARIANT,A as TONE};
|
package/dist/utils/cssVars.js
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Types an inline style object that sets CSS custom properties.
|
|
4
|
-
*
|
|
5
|
-
* @param style - Standard style properties and/or `--name` custom properties
|
|
6
|
-
* @returns The same object, typed for the `style` prop
|
|
7
|
-
*/
|
|
8
|
-
export function withCssVars(style) {
|
|
9
|
-
return style;
|
|
10
|
-
}
|
|
1
|
+
function e(r){return r}export{e as withCssVars};
|
package/dist/utils/date.js
CHANGED
|
@@ -1,130 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// ---------------------------------------------------------------------------
|
|
3
|
-
// Constants
|
|
4
|
-
// ---------------------------------------------------------------------------
|
|
5
|
-
export const DEFAULT_LOCALE = 'fr-FR';
|
|
6
|
-
export const DATE_SEGMENT_BASE = {
|
|
7
|
-
day: { type: 'day', min: 1, digits: 2, placeholder: 'JJ', ariaLabel: 'Jour' },
|
|
8
|
-
month: {
|
|
9
|
-
type: 'month',
|
|
10
|
-
min: 1,
|
|
11
|
-
digits: 2,
|
|
12
|
-
placeholder: 'MM',
|
|
13
|
-
ariaLabel: 'Mois',
|
|
14
|
-
},
|
|
15
|
-
year: {
|
|
16
|
-
type: 'year',
|
|
17
|
-
min: 1,
|
|
18
|
-
digits: 4,
|
|
19
|
-
placeholder: 'AAAA',
|
|
20
|
-
ariaLabel: 'Année',
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
// ---------------------------------------------------------------------------
|
|
24
|
-
// Locale
|
|
25
|
-
// ---------------------------------------------------------------------------
|
|
26
|
-
/** Cache locale info to avoid repeated Intl calls. */
|
|
27
|
-
const localeCache = new Map();
|
|
28
|
-
/** Get locale-aware segment order and separator via Intl.DateTimeFormat. */
|
|
29
|
-
export function getLocaleInfo(locale) {
|
|
30
|
-
const cached = localeCache.get(locale);
|
|
31
|
-
if (cached)
|
|
32
|
-
return cached;
|
|
33
|
-
const formatter = new Intl.DateTimeFormat(locale, {
|
|
34
|
-
day: '2-digit',
|
|
35
|
-
month: '2-digit',
|
|
36
|
-
year: 'numeric',
|
|
37
|
-
});
|
|
38
|
-
const parts = formatter.formatToParts(new Date(2000, 0, 2));
|
|
39
|
-
const order = [];
|
|
40
|
-
let separator = '/';
|
|
41
|
-
for (const part of parts) {
|
|
42
|
-
if (part.type === 'day')
|
|
43
|
-
order.push('day');
|
|
44
|
-
else if (part.type === 'month')
|
|
45
|
-
order.push('month');
|
|
46
|
-
else if (part.type === 'year')
|
|
47
|
-
order.push('year');
|
|
48
|
-
else if (part.type === 'literal' && order.length === 1) {
|
|
49
|
-
separator = part.value;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (order.length !== 3) {
|
|
53
|
-
const fallback = {
|
|
54
|
-
order: ['day', 'month', 'year'],
|
|
55
|
-
separator: '/',
|
|
56
|
-
};
|
|
57
|
-
localeCache.set(locale, fallback);
|
|
58
|
-
return fallback;
|
|
59
|
-
}
|
|
60
|
-
const result = { order, separator };
|
|
61
|
-
localeCache.set(locale, result);
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
// ---------------------------------------------------------------------------
|
|
65
|
-
// Date math
|
|
66
|
-
// ---------------------------------------------------------------------------
|
|
67
|
-
/** Get the number of days in a given month/year. */
|
|
68
|
-
export function getDaysInMonth(month, year) {
|
|
69
|
-
if (month == null)
|
|
70
|
-
return 31;
|
|
71
|
-
const y = year ?? 2000; // Leap year default to be permissive
|
|
72
|
-
return new Date(y, month, 0).getDate();
|
|
73
|
-
}
|
|
74
|
-
/** Clamp day to the max days in the given month/year. */
|
|
75
|
-
export function clampDay(day, month, year) {
|
|
76
|
-
return Math.min(day, getDaysInMonth(month, year));
|
|
77
|
-
}
|
|
78
|
-
// ---------------------------------------------------------------------------
|
|
79
|
-
// Conversion
|
|
80
|
-
// ---------------------------------------------------------------------------
|
|
81
|
-
/** Normalize string or Date to Date object. */
|
|
82
|
-
export function toDate(input) {
|
|
83
|
-
return input instanceof Date ? input : new Date(input + 'T00:00:00');
|
|
84
|
-
}
|
|
85
|
-
/** Format Date as ISO date string (YYYY-MM-DD). */
|
|
86
|
-
export function toISODate(d) {
|
|
87
|
-
const y = String(d.getFullYear()).padStart(4, '0');
|
|
88
|
-
const m = String(d.getMonth() + 1).padStart(2, '0');
|
|
89
|
-
const day = String(d.getDate()).padStart(2, '0');
|
|
90
|
-
return `${y}-${m}-${day}`;
|
|
91
|
-
}
|
|
92
|
-
/** Format Date as ISO datetime-local string (YYYY-MM-DDTHH:MM). */
|
|
93
|
-
export function toISODateTime(d) {
|
|
94
|
-
const h = String(d.getHours()).padStart(2, '0');
|
|
95
|
-
const min = String(d.getMinutes()).padStart(2, '0');
|
|
96
|
-
return `${toISODate(d)}T${h}:${min}`;
|
|
97
|
-
}
|
|
98
|
-
/** Parse ISO date string to segment values. */
|
|
99
|
-
export function parseISODate(iso) {
|
|
100
|
-
const [y, m, d] = iso.split('T')[0].split('-').map(Number);
|
|
101
|
-
return { year: y, month: m, day: d };
|
|
102
|
-
}
|
|
103
|
-
/** Parse any common date format from pasted text. */
|
|
104
|
-
export function parseAnyDate(text) {
|
|
105
|
-
const trimmed = text.trim();
|
|
106
|
-
// ISO: YYYY-MM-DD or YYYY-MM-DDTHH:MM
|
|
107
|
-
const isoMatch = trimmed.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:T(\d{1,2}):(\d{1,2}))?/);
|
|
108
|
-
if (isoMatch) {
|
|
109
|
-
const d = new Date(Number(isoMatch[1]), Number(isoMatch[2]) - 1, Number(isoMatch[3]), Number(isoMatch[4] ?? 0), Number(isoMatch[5] ?? 0));
|
|
110
|
-
if (!isNaN(d.getTime()))
|
|
111
|
-
return d;
|
|
112
|
-
}
|
|
113
|
-
// European: DD/MM/YYYY or DD.MM.YYYY or DD-MM-YYYY (optionally with HH:MM)
|
|
114
|
-
const euMatch = trimmed.match(/^(\d{1,2})[/.\-](\d{1,2})[/.\-](\d{4})(?:\s+(\d{1,2}):(\d{1,2}))?$/);
|
|
115
|
-
if (euMatch) {
|
|
116
|
-
const d = new Date(Number(euMatch[3]), Number(euMatch[2]) - 1, Number(euMatch[1]), Number(euMatch[4] ?? 0), Number(euMatch[5] ?? 0));
|
|
117
|
-
if (!isNaN(d.getTime()))
|
|
118
|
-
return d;
|
|
119
|
-
}
|
|
120
|
-
// Last resort: Date.parse
|
|
121
|
-
const parsed = new Date(trimmed);
|
|
122
|
-
if (!isNaN(parsed.getTime()) && parsed.getFullYear() > 1900)
|
|
123
|
-
return parsed;
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
/** SSR-safe locale resolver. */
|
|
127
|
-
export function resolveLocale(locale) {
|
|
128
|
-
return (locale ??
|
|
129
|
-
(typeof navigator !== 'undefined' ? navigator.language : DEFAULT_LOCALE));
|
|
130
|
-
}
|
|
1
|
+
var m="fr-FR",l={day:{type:"day",min:1,digits:2,placeholder:"JJ",ariaLabel:"Jour"},month:{type:"month",min:1,digits:2,placeholder:"MM",ariaLabel:"Mois"},year:{type:"year",min:1,digits:4,placeholder:"AAAA",ariaLabel:"Ann\xE9e"}},s=new Map;function c(e){let r=s.get(e);if(r)return r;let n=new Intl.DateTimeFormat(e,{day:"2-digit",month:"2-digit",year:"numeric"}).formatToParts(new Date(2e3,0,2)),a=[],o="/";for(let i of n)i.type==="day"?a.push("day"):i.type==="month"?a.push("month"):i.type==="year"?a.push("year"):i.type==="literal"&&a.length===1&&(o=i.value);if(a.length!==3){let i={order:["day","month","year"],separator:"/"};return s.set(e,i),i}let u={order:a,separator:o};return s.set(e,u),u}function g(e,r){if(e==null)return 31;let t=r??2e3;return new Date(t,e,0).getDate()}function d(e,r,t){return Math.min(e,g(r,t))}function y(e){return e instanceof Date?e:new Date(e+"T00:00:00")}function p(e){let r=String(e.getFullYear()).padStart(4,"0"),t=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${r}-${t}-${n}`}function f(e){let r=String(e.getHours()).padStart(2,"0"),t=String(e.getMinutes()).padStart(2,"0");return`${p(e)}T${r}:${t}`}function D(e){let[r,t,n]=e.split("T")[0].split("-").map(Number);return{year:r,month:t,day:n}}function b(e){let r=e.trim(),t=r.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:T(\d{1,2}):(\d{1,2}))?/);if(t){let o=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),Number(t[4]??0),Number(t[5]??0));if(!isNaN(o.getTime()))return o}let n=r.match(/^(\d{1,2})[/.\-](\d{1,2})[/.\-](\d{4})(?:\s+(\d{1,2}):(\d{1,2}))?$/);if(n){let o=new Date(Number(n[3]),Number(n[2])-1,Number(n[1]),Number(n[4]??0),Number(n[5]??0));if(!isNaN(o.getTime()))return o}let a=new Date(r);return!isNaN(a.getTime())&&a.getFullYear()>1900?a:null}function h(e){return e??(typeof navigator<"u"?navigator.language:m)}export{l as DATE_SEGMENT_BASE,m as DEFAULT_LOCALE,d as clampDay,g as getDaysInMonth,c as getLocaleInfo,b as parseAnyDate,D as parseISODate,h as resolveLocale,y as toDate,p as toISODate,f as toISODateTime};
|
|
@@ -1,57 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Event Listener Utilities
|
|
4
|
-
* @description Utility functions for managing event listeners in components. Provides helper functions for adding and removing event listeners with proper cleanup.
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Add event listener with proper cleanup
|
|
12
|
-
* @param target - Event target to attach listener to
|
|
13
|
-
* @param eventType - Type of event to listen for
|
|
14
|
-
* @param handler - Event handler function
|
|
15
|
-
* @param options - Event listener options
|
|
16
|
-
* @returns Cleanup function
|
|
17
|
-
*
|
|
18
|
-
* @version 0.1.0
|
|
19
|
-
* @since 0.0.1
|
|
20
|
-
* @author AMBROISE PARK Consulting
|
|
21
|
-
*/
|
|
22
|
-
export function addEventListener(target, eventType, handler, options) {
|
|
23
|
-
if (!target)
|
|
24
|
-
return () => { };
|
|
25
|
-
const wrappedHandler = handler;
|
|
26
|
-
target.addEventListener(eventType, wrappedHandler, options);
|
|
27
|
-
return () => {
|
|
28
|
-
target.removeEventListener(eventType, wrappedHandler, options);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Add multiple event listeners with proper cleanup
|
|
33
|
-
* @param target - Event target to attach listeners to
|
|
34
|
-
* @param events - Array of event types and handlers
|
|
35
|
-
* @param options - Event listener options
|
|
36
|
-
* @returns Cleanup function
|
|
37
|
-
*
|
|
38
|
-
* @version 0.1.0
|
|
39
|
-
* @since 0.0.1
|
|
40
|
-
* @author AMBROISE PARK Consulting
|
|
41
|
-
*/
|
|
42
|
-
export function addEventListeners(target, events, defaultOptions) {
|
|
43
|
-
if (!target)
|
|
44
|
-
return () => { };
|
|
45
|
-
const cleanupFunctions = [];
|
|
46
|
-
events.forEach(({ type, handler, options }) => {
|
|
47
|
-
const finalOptions = { ...defaultOptions, ...options };
|
|
48
|
-
const wrappedHandler = handler;
|
|
49
|
-
target.addEventListener(type, wrappedHandler, finalOptions);
|
|
50
|
-
cleanupFunctions.push(() => {
|
|
51
|
-
target.removeEventListener(type, wrappedHandler, finalOptions);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
return () => {
|
|
55
|
-
cleanupFunctions.forEach((cleanup) => cleanup());
|
|
56
|
-
};
|
|
57
|
-
}
|
|
1
|
+
function E(e,r,i,t){if(!e)return()=>{};let n=i;return e.addEventListener(r,n,t),()=>{e.removeEventListener(r,n,t)}}function a(e,r,i){if(!e)return()=>{};let t=[];return r.forEach(({type:n,handler:d,options:o})=>{let s={...i,...o},v=d;e.addEventListener(n,v,s),t.push(()=>{e.removeEventListener(n,v,s)})}),()=>{t.forEach(n=>n())}}export{E as addEventListener,a as addEventListeners};
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,58 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Component Helper Utilities
|
|
4
|
-
* @description Provides utility functions for component styling and class name management.
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
import { clsx } from 'clsx';
|
|
11
|
-
/**
|
|
12
|
-
* Merges class names
|
|
13
|
-
*
|
|
14
|
-
* Combines multiple class name inputs into a single string.
|
|
15
|
-
*
|
|
16
|
-
* @param {...ClassValue} inputs - Class name inputs to merge
|
|
17
|
-
* @returns {string} Merged class name string
|
|
18
|
-
* @version 0.1.0
|
|
19
|
-
* @since 0.0.1
|
|
20
|
-
* @author AMBROISE PARK Consulting
|
|
21
|
-
*/
|
|
22
|
-
export function cn(...inputs) {
|
|
23
|
-
return clsx(inputs);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Generates data attributes from variant props
|
|
27
|
-
*
|
|
28
|
-
* Automatically converts variant props to data attributes for CSS selectors.
|
|
29
|
-
* Prevents duplication when using CVA (class-variance-authority).
|
|
30
|
-
*
|
|
31
|
-
* @param variants - Variant props object
|
|
32
|
-
* @returns Object with data-* attributes
|
|
33
|
-
* @example
|
|
34
|
-
* const attrs = getVariantDataAttrs({ variant: 'primary', size: 'md' });
|
|
35
|
-
* // Returns: { 'data-variant': 'primary', 'data-size': 'md' }
|
|
36
|
-
*
|
|
37
|
-
* @version 0.1.0
|
|
38
|
-
* @since 0.0.1
|
|
39
|
-
* @author AMBROISE PARK Consulting
|
|
40
|
-
*/
|
|
41
|
-
export function getVariantDataAttrs(variants) {
|
|
42
|
-
const attrs = {};
|
|
43
|
-
if (variants.variant != null)
|
|
44
|
-
attrs['data-variant'] = variants.variant;
|
|
45
|
-
if (variants.size != null)
|
|
46
|
-
attrs['data-size'] = variants.size;
|
|
47
|
-
if (variants.shadow != null)
|
|
48
|
-
attrs['data-shadow'] = variants.shadow;
|
|
49
|
-
if (variants.radius != null)
|
|
50
|
-
attrs['data-radius'] = variants.radius;
|
|
51
|
-
if (variants.hover != null)
|
|
52
|
-
attrs['data-hover'] = variants.hover;
|
|
53
|
-
if (variants.glow != null)
|
|
54
|
-
attrs['data-glow'] = variants.glow;
|
|
55
|
-
if (variants.side != null)
|
|
56
|
-
attrs['data-side'] = variants.side;
|
|
57
|
-
return attrs;
|
|
58
|
-
}
|
|
1
|
+
import{clsx as e}from"clsx";function i(...n){return e(n)}function u(n){let l={};return n.variant!=null&&(l["data-variant"]=n.variant),n.size!=null&&(l["data-size"]=n.size),n.shadow!=null&&(l["data-shadow"]=n.shadow),n.radius!=null&&(l["data-radius"]=n.radius),n.hover!=null&&(l["data-hover"]=n.hover),n.glow!=null&&(l["data-glow"]=n.glow),n.side!=null&&(l["data-side"]=n.side),l}export{i as cn,u as getVariantDataAttrs};
|
package/dist/utils/imageRetry.js
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/** Maximum retry attempts per image */
|
|
3
|
-
const MAX_RETRIES = 2;
|
|
4
|
-
/** Base delay between retries in ms (multiplied by attempt number) */
|
|
5
|
-
const BASE_DELAY_MS = 1500;
|
|
6
|
-
/** Protocols that are local/inline and won't benefit from retry */
|
|
7
|
-
const SKIP_PROTOCOLS = ['blob:', 'data:'];
|
|
8
|
-
/**
|
|
9
|
-
* onError handler for <img> elements. Retries loading with exponential backoff.
|
|
10
|
-
* Uses `data-retry` attribute on the element to track attempts (no React state needed).
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* <img src={url} onError={handleImageError} />
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export function handleImageError(e) {
|
|
18
|
-
const img = e.currentTarget;
|
|
19
|
-
if (SKIP_PROTOCOLS.some((p) => img.src.startsWith(p)))
|
|
20
|
-
return;
|
|
21
|
-
const retry = parseInt(img.dataset.retry || '0', 10);
|
|
22
|
-
if (retry >= MAX_RETRIES)
|
|
23
|
-
return;
|
|
24
|
-
const nextRetry = retry + 1;
|
|
25
|
-
setTimeout(() => {
|
|
26
|
-
// Guard: element may have been removed from DOM during the delay
|
|
27
|
-
if (!img.isConnected)
|
|
28
|
-
return;
|
|
29
|
-
img.dataset.retry = String(nextRetry);
|
|
30
|
-
// Build clean base URL, then append cache-bust param
|
|
31
|
-
const url = new URL(img.src);
|
|
32
|
-
url.searchParams.set('_r', String(nextRetry));
|
|
33
|
-
img.src = url.toString();
|
|
34
|
-
}, BASE_DELAY_MS * nextRetry);
|
|
35
|
-
}
|
|
1
|
+
var o=["blob:","data:"];function c(s){let t=s.currentTarget;if(o.some(r=>t.src.startsWith(r)))return;let n=parseInt(t.dataset.retry||"0",10);if(n>=2)return;let e=n+1;setTimeout(()=>{if(!t.isConnected)return;t.dataset.retry=String(e);let r=new URL(t.src);r.searchParams.set("_r",String(e)),t.src=r.toString()},1500*e)}export{c as handleImageError};
|
package/dist/utils/index.js
CHANGED
|
@@ -1,24 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Component Utilities Barrel Exports
|
|
4
|
-
* @description Barrel exports for component utility functions.
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
export * from './constants';
|
|
11
|
-
export * from './date';
|
|
12
|
-
export * from './eventListener';
|
|
13
|
-
export * from './initRipple';
|
|
14
|
-
export * from './intersectionObserver';
|
|
15
|
-
export * from './isDark';
|
|
16
|
-
export * from './linkComponent';
|
|
17
|
-
export * from './helpers';
|
|
18
|
-
export * from './measurement';
|
|
19
|
-
export * from './rtl';
|
|
20
|
-
export * from './viewportDetection';
|
|
21
|
-
export * from './variants';
|
|
22
|
-
export * from './imageRetry';
|
|
23
|
-
export * from './responsiveImage';
|
|
24
|
-
export * from './sanitizeHtml';
|
|
1
|
+
export*from"./constants.js";export*from"./date.js";export*from"./eventListener.js";export*from"./initRipple.js";export*from"./intersectionObserver.js";export*from"./isDark.js";export*from"./linkComponent.js";export*from"./helpers.js";export*from"./measurement.js";export*from"./rtl.js";export*from"./viewportDetection.js";export*from"./variants.js";export*from"./imageRetry.js";export*from"./responsiveImage.js";export*from"./sanitizeHtml.js";
|
package/dist/utils/initRipple.js
CHANGED
|
@@ -1,84 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @version 0.1.0
|
|
8
|
-
* @since 0.1.0
|
|
9
|
-
* @author AMBROISE PARK Consulting
|
|
10
|
-
*/
|
|
11
|
-
let initialized = false;
|
|
12
|
-
/**
|
|
13
|
-
* Initialize ripple effect for all .dndev-interactive elements.
|
|
14
|
-
* Uses event delegation - only one listener for the entire document.
|
|
15
|
-
* Safe to call multiple times (no-op after first call).
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* // In your app root/provider
|
|
20
|
-
* import { initRipple } from '@donotdev/components';
|
|
21
|
-
*
|
|
22
|
-
* useEffect(() => {
|
|
23
|
-
* initRipple();
|
|
24
|
-
* }, []);
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export function initRipple() {
|
|
28
|
-
if (typeof document === 'undefined')
|
|
29
|
-
return;
|
|
30
|
-
if (initialized)
|
|
31
|
-
return;
|
|
32
|
-
initialized = true;
|
|
33
|
-
document.addEventListener('pointerdown', handleRipple, { passive: true });
|
|
34
|
-
}
|
|
35
|
-
function handleRipple(event) {
|
|
36
|
-
const target = event.target?.closest?.('.dndev-interactive');
|
|
37
|
-
if (!target)
|
|
38
|
-
return;
|
|
39
|
-
// Check if ripple is disabled via CSS variable
|
|
40
|
-
const styles = getComputedStyle(target);
|
|
41
|
-
const rippleOpacity = parseFloat(styles.getPropertyValue('--ripple-opacity'));
|
|
42
|
-
if (!(rippleOpacity > 0))
|
|
43
|
-
return;
|
|
44
|
-
// Get click position relative to the target's padding box (the ripple's containing block)
|
|
45
|
-
const rect = target.getBoundingClientRect();
|
|
46
|
-
const paddingBoxStart = rect.left + target.clientLeft;
|
|
47
|
-
const inlineOffset = styles.direction === 'rtl'
|
|
48
|
-
? paddingBoxStart + target.clientWidth - event.clientX
|
|
49
|
-
: event.clientX - paddingBoxStart;
|
|
50
|
-
const blockOffset = event.clientY - rect.top - target.clientTop;
|
|
51
|
-
// Base ripple size on the element's longest side
|
|
52
|
-
const size = Math.max(rect.width, rect.height);
|
|
53
|
-
// Create ripple element
|
|
54
|
-
const ripple = document.createElement('span');
|
|
55
|
-
ripple.className = 'dndev-ripple';
|
|
56
|
-
ripple.style.cssText = `
|
|
57
|
-
width: ${size}px;
|
|
58
|
-
height: ${size}px;
|
|
59
|
-
inset-inline-start: ${inlineOffset - size / 2}px;
|
|
60
|
-
inset-block-start: ${blockOffset - size / 2}px;
|
|
61
|
-
`;
|
|
62
|
-
// Clip inside a dedicated layer: layout rules can override the target's overflow
|
|
63
|
-
const clip = document.createElement('span');
|
|
64
|
-
clip.className = 'dndev-ripple-clip';
|
|
65
|
-
clip.appendChild(ripple);
|
|
66
|
-
// Add to target
|
|
67
|
-
target.appendChild(clip);
|
|
68
|
-
// Remove after animation completes
|
|
69
|
-
ripple.addEventListener('animationend', () => {
|
|
70
|
-
clip.remove();
|
|
71
|
-
}, { once: true });
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Cleanup ripple event listener.
|
|
75
|
-
* Call when unmounting if needed (typically not required).
|
|
76
|
-
*/
|
|
77
|
-
export function destroyRipple() {
|
|
78
|
-
if (typeof document === 'undefined')
|
|
79
|
-
return;
|
|
80
|
-
if (!initialized)
|
|
81
|
-
return;
|
|
82
|
-
document.removeEventListener('pointerdown', handleRipple);
|
|
83
|
-
initialized = false;
|
|
84
|
-
}
|
|
1
|
+
var r=!1;function f(){typeof document>"u"||r||(r=!0,document.addEventListener("pointerdown",d,{passive:!0}))}function d(t){let e=t.target?.closest?.(".dndev-interactive");if(!e)return;let l=getComputedStyle(e);if(!(parseFloat(l.getPropertyValue("--ripple-opacity"))>0))return;let n=e.getBoundingClientRect(),c=n.left+e.clientLeft,s=l.direction==="rtl"?c+e.clientWidth-t.clientX:t.clientX-c,a=t.clientY-n.top-e.clientTop,i=Math.max(n.width,n.height),o=document.createElement("span");o.className="dndev-ripple",o.style.cssText=`
|
|
2
|
+
width: ${i}px;
|
|
3
|
+
height: ${i}px;
|
|
4
|
+
inset-inline-start: ${s-i/2}px;
|
|
5
|
+
inset-block-start: ${a-i/2}px;
|
|
6
|
+
`;let p=document.createElement("span");p.className="dndev-ripple-clip",p.appendChild(o),e.appendChild(p),o.addEventListener("animationend",()=>{p.remove()},{once:!0})}function m(){typeof document>"u"||r&&(document.removeEventListener("pointerdown",d),r=!1)}export{m as destroyRipple,f as initRipple};
|
|
@@ -1,184 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Intersection Observer Utilities
|
|
4
|
-
* @description Centralized IntersectionObserver utility for framework components. Provides optimized, SSR-safe intersection observation with shared instances and polyfill support.
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Polyfill for IntersectionObserver
|
|
12
|
-
*
|
|
13
|
-
* @version 0.1.0
|
|
14
|
-
* @since 0.0.1
|
|
15
|
-
* @author AMBROISE PARK Consulting
|
|
16
|
-
*/
|
|
17
|
-
export function polyfillIntersectionObserver() {
|
|
18
|
-
if (typeof window === 'undefined' || 'IntersectionObserver' in window) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
// Simple polyfill for basic intersection detection.
|
|
22
|
-
// Limitation: This mock fires the callback once on observe() but does NOT
|
|
23
|
-
// re-fire on scroll/resize. unobserve() removes the element from the set
|
|
24
|
-
// but cannot cancel an already-scheduled setTimeout callback.
|
|
25
|
-
// Write-only view of the global: the polyfill class is partial (no root/rootMargin/thresholds/takeRecords)
|
|
26
|
-
const writableGlobal = globalThis;
|
|
27
|
-
writableGlobal.IntersectionObserver = class IntersectionObserver {
|
|
28
|
-
callback;
|
|
29
|
-
elements;
|
|
30
|
-
options;
|
|
31
|
-
constructor(callback, options = {}) {
|
|
32
|
-
this.callback = callback;
|
|
33
|
-
this.elements = new Set();
|
|
34
|
-
this.options = options;
|
|
35
|
-
}
|
|
36
|
-
observe(element) {
|
|
37
|
-
this.elements.add(element);
|
|
38
|
-
// Check if element is actually visible
|
|
39
|
-
const rect = element.getBoundingClientRect();
|
|
40
|
-
const isVisible = rect.top < window.innerHeight && rect.bottom > 0;
|
|
41
|
-
const entry = {
|
|
42
|
-
target: element,
|
|
43
|
-
isIntersecting: isVisible,
|
|
44
|
-
intersectionRatio: isVisible ? 1 : 0,
|
|
45
|
-
boundingClientRect: rect,
|
|
46
|
-
intersectionRect: isVisible ? rect : new DOMRect(),
|
|
47
|
-
rootBounds: null,
|
|
48
|
-
time: Date.now(),
|
|
49
|
-
};
|
|
50
|
-
// Use setTimeout to ensure DOM is ready
|
|
51
|
-
// why: callback expects a full IntersectionObserver; this partial polyfill lacks root/rootMargin/thresholds/takeRecords
|
|
52
|
-
setTimeout(() => this.callback([entry], this), 0);
|
|
53
|
-
}
|
|
54
|
-
unobserve(element) {
|
|
55
|
-
this.elements.delete(element);
|
|
56
|
-
}
|
|
57
|
-
disconnect() {
|
|
58
|
-
this.elements.clear();
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Centralized IntersectionObserver utility for framework components
|
|
64
|
-
* Provides optimized, SSR-safe intersection observation with shared instances
|
|
65
|
-
*/
|
|
66
|
-
// Global observer cache for performance optimization
|
|
67
|
-
const observerCache = new Map();
|
|
68
|
-
const elementCallbacks = new Map();
|
|
69
|
-
/**
|
|
70
|
-
* Get or create a cached IntersectionObserver instance
|
|
71
|
-
* This reduces the number of observers and improves performance for Lighthouse scores
|
|
72
|
-
*
|
|
73
|
-
* @version 0.1.0
|
|
74
|
-
* @since 0.0.1
|
|
75
|
-
* @author AMBROISE PARK Consulting
|
|
76
|
-
*/
|
|
77
|
-
export function getIntersectionObserver(options = {}) {
|
|
78
|
-
const { threshold = 0, root = null, rootMargin = '0px' } = options;
|
|
79
|
-
const key = `${threshold}-${rootMargin}-${root?.toString() || 'null'}`;
|
|
80
|
-
if (observerCache.has(key)) {
|
|
81
|
-
return observerCache.get(key);
|
|
82
|
-
}
|
|
83
|
-
// Ensure polyfill is loaded for SSR safety
|
|
84
|
-
if (typeof window !== 'undefined') {
|
|
85
|
-
polyfillIntersectionObserver();
|
|
86
|
-
}
|
|
87
|
-
const observer = new IntersectionObserver((entries) => {
|
|
88
|
-
entries.forEach((entry) => {
|
|
89
|
-
const callbacks = elementCallbacks.get(entry.target);
|
|
90
|
-
if (callbacks) {
|
|
91
|
-
callbacks.forEach((callback) => callback(entry));
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}, {
|
|
95
|
-
threshold,
|
|
96
|
-
root,
|
|
97
|
-
rootMargin,
|
|
98
|
-
});
|
|
99
|
-
observerCache.set(key, observer);
|
|
100
|
-
return observer;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Subscribe an element to intersection observation
|
|
104
|
-
* @param element Element to observe
|
|
105
|
-
* @param callback Callback function for intersection changes
|
|
106
|
-
* @param options IntersectionObserver options
|
|
107
|
-
* @returns Cleanup function
|
|
108
|
-
*
|
|
109
|
-
* @version 0.1.0
|
|
110
|
-
* @since 0.0.1
|
|
111
|
-
* @author AMBROISE PARK Consulting
|
|
112
|
-
*/
|
|
113
|
-
export function observeElement(element, callback, options = {}) {
|
|
114
|
-
// SSR safety check
|
|
115
|
-
if (typeof window === 'undefined') {
|
|
116
|
-
// SSR fallback - no DOM methods available, just return noop
|
|
117
|
-
return () => { };
|
|
118
|
-
}
|
|
119
|
-
// Ensure polyfill is loaded
|
|
120
|
-
polyfillIntersectionObserver();
|
|
121
|
-
// Check if IntersectionObserver is available (after polyfill)
|
|
122
|
-
if (!window.IntersectionObserver) {
|
|
123
|
-
// Fallback for unsupported browsers - check actual visibility
|
|
124
|
-
const rect = element.getBoundingClientRect();
|
|
125
|
-
const isVisible = rect.top < window.innerHeight && rect.bottom > 0;
|
|
126
|
-
const mockEntry = {
|
|
127
|
-
target: element,
|
|
128
|
-
isIntersecting: isVisible,
|
|
129
|
-
intersectionRatio: isVisible ? 1 : 0,
|
|
130
|
-
boundingClientRect: rect,
|
|
131
|
-
intersectionRect: isVisible ? rect : new DOMRect(),
|
|
132
|
-
rootBounds: null,
|
|
133
|
-
time: Date.now(),
|
|
134
|
-
};
|
|
135
|
-
// Use setTimeout to ensure DOM is ready
|
|
136
|
-
setTimeout(() => callback(mockEntry), 0);
|
|
137
|
-
return () => { };
|
|
138
|
-
}
|
|
139
|
-
// Get cached observer
|
|
140
|
-
const observer = getIntersectionObserver(options);
|
|
141
|
-
// Add callback to element
|
|
142
|
-
if (!elementCallbacks.has(element)) {
|
|
143
|
-
elementCallbacks.set(element, new Set());
|
|
144
|
-
}
|
|
145
|
-
elementCallbacks.get(element).add(callback);
|
|
146
|
-
// Observe element
|
|
147
|
-
observer.observe(element);
|
|
148
|
-
// Return cleanup function
|
|
149
|
-
return () => {
|
|
150
|
-
const callbacks = elementCallbacks.get(element);
|
|
151
|
-
if (callbacks) {
|
|
152
|
-
callbacks.delete(callback);
|
|
153
|
-
if (callbacks.size === 0) {
|
|
154
|
-
elementCallbacks.delete(element);
|
|
155
|
-
observer.unobserve(element);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Create a simple intersection observer for basic visibility detection
|
|
162
|
-
* Optimized for performance and SSR safety
|
|
163
|
-
*
|
|
164
|
-
* @version 0.1.0
|
|
165
|
-
* @since 0.0.1
|
|
166
|
-
* @author AMBROISE PARK Consulting
|
|
167
|
-
*/
|
|
168
|
-
export function createVisibilityObserver(element, onVisible, options = {}) {
|
|
169
|
-
if (!element)
|
|
170
|
-
return () => { };
|
|
171
|
-
return observeElement(element, (entry) => onVisible(entry.isIntersecting), options);
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Cleanup all observers (useful for testing or app shutdown)
|
|
175
|
-
*
|
|
176
|
-
* @version 0.1.0
|
|
177
|
-
* @since 0.0.1
|
|
178
|
-
* @author AMBROISE PARK Consulting
|
|
179
|
-
*/
|
|
180
|
-
export function cleanupAllObservers() {
|
|
181
|
-
observerCache.forEach((observer) => observer.disconnect());
|
|
182
|
-
observerCache.clear();
|
|
183
|
-
elementCallbacks.clear();
|
|
184
|
-
}
|
|
1
|
+
var O=Object.defineProperty;var p=(e,n,t)=>n in e?O(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var l=(e,n,t)=>p(e,typeof n!="symbol"?n+"":n,t);function d(){if(typeof window>"u"||"IntersectionObserver"in window)return;let e=globalThis;e.IntersectionObserver=class{constructor(t,o={}){l(this,"callback");l(this,"elements");l(this,"options");this.callback=t,this.elements=new Set,this.options=o}observe(t){this.elements.add(t);let o=t.getBoundingClientRect(),r=o.top<window.innerHeight&&o.bottom>0,i={target:t,isIntersecting:r,intersectionRatio:r?1:0,boundingClientRect:o,intersectionRect:r?o:new DOMRect,rootBounds:null,time:Date.now()};setTimeout(()=>this.callback([i],this),0)}unobserve(t){this.elements.delete(t)}disconnect(){this.elements.clear()}}}var c=new Map,s=new Map;function I(e={}){let{threshold:n=0,root:t=null,rootMargin:o="0px"}=e,r=`${n}-${o}-${t?.toString()||"null"}`;if(c.has(r))return c.get(r);typeof window<"u"&&d();let i=new IntersectionObserver(b=>{b.forEach(v=>{let a=s.get(v.target);a&&a.forEach(u=>u(v))})},{threshold:n,root:t,rootMargin:o});return c.set(r,i),i}function f(e,n,t={}){if(typeof window>"u")return()=>{};if(d(),!window.IntersectionObserver){let r=e.getBoundingClientRect(),i=r.top<window.innerHeight&&r.bottom>0,b={target:e,isIntersecting:i,intersectionRatio:i?1:0,boundingClientRect:r,intersectionRect:i?r:new DOMRect,rootBounds:null,time:Date.now()};return setTimeout(()=>n(b),0),()=>{}}let o=I(t);return s.has(e)||s.set(e,new Set),s.get(e).add(n),o.observe(e),()=>{let r=s.get(e);r&&(r.delete(n),r.size===0&&(s.delete(e),o.unobserve(e)))}}function h(e,n,t={}){return e?f(e,o=>n(o.isIntersecting),t):()=>{}}function E(){c.forEach(e=>e.disconnect()),c.clear(),s.clear()}export{E as cleanupAllObservers,h as createVisibilityObserver,I as getIntersectionObserver,f as observeElement,d as polyfillIntersectionObserver};
|