@donotdev/components 0.3.0 → 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 +12 -2
- 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.d.ts +8 -1
- package/dist/atomic/Card/cover.d.ts.map +1 -1
- package/dist/atomic/Card/cover.js +1 -40
- package/dist/atomic/Card/index.d.ts +22 -3
- package/dist/atomic/Card/index.d.ts.map +1 -1
- package/dist/atomic/Card/index.js +1 -189
- 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.d.ts +2 -4
- package/dist/atomic/SwipeAction/index.d.ts.map +1 -1
- package/dist/atomic/SwipeAction/index.js +1 -67
- 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 +71 -17
- package/dist/styles/index.js +1 -10
- package/dist/symbol-index.json +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +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 +3 -3
- package/guidelines/SWIPE_ACTION.md +14 -24
- 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
|
@@ -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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isDark.d.ts","sourceRoot":"","sources":["../../src/utils/isDark.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isDark.d.ts","sourceRoot":"","sources":["../../src/utils/isDark.ts"],"names":[],"mappings":"AAcA;;;;;;;;;GASG;AACH,wBAAgB,MAAM,IAAI,OAAO,CA0BhC;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAqBnC"}
|
package/dist/utils/isDark.js
CHANGED
|
@@ -1,69 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Dark Mode Detection Utilities
|
|
4
|
-
* @description Utility functions and hooks for detecting dark mode state. Uses CSS custom properties set by the framework's theme system.
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
import { useEffect, useState } from 'react';
|
|
11
|
-
/**
|
|
12
|
-
* Utility to detect if the current theme is dark mode
|
|
13
|
-
* Uses CSS custom properties set by the framework's theme system
|
|
14
|
-
*
|
|
15
|
-
* @returns boolean indicating if dark mode is active
|
|
16
|
-
*
|
|
17
|
-
* @version 0.1.0
|
|
18
|
-
* @since 0.0.1
|
|
19
|
-
* @author AMBROISE PARK Consulting
|
|
20
|
-
*/
|
|
21
|
-
export function isDark() {
|
|
22
|
-
if (typeof window === 'undefined') {
|
|
23
|
-
return false; // SSR safe default
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
const root = document.documentElement;
|
|
27
|
-
// First try to read the CSS custom property set by the framework
|
|
28
|
-
const isDarkValue = getComputedStyle(root)
|
|
29
|
-
.getPropertyValue('--theme-is-dark')
|
|
30
|
-
.trim();
|
|
31
|
-
if (isDarkValue === '1') {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
if (isDarkValue === '0') {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
// Fallback to checking for 'dark' class
|
|
38
|
-
return root.classList.contains('dark');
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
// Fallback to checking for 'dark' class if CSS custom property fails
|
|
42
|
-
return document.documentElement.classList.contains('dark');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Hook version for React components
|
|
47
|
-
* Returns the current dark mode state and updates when theme changes
|
|
48
|
-
*
|
|
49
|
-
* @version 0.1.0
|
|
50
|
-
* @since 0.0.1
|
|
51
|
-
* @author AMBROISE PARK Consulting
|
|
52
|
-
*/
|
|
53
|
-
export function useIsDark() {
|
|
54
|
-
const [darkMode, setDarkMode] = useState(false);
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
// Set initial state
|
|
57
|
-
setDarkMode(isDark());
|
|
58
|
-
// Watch for theme changes
|
|
59
|
-
const observer = new MutationObserver(() => {
|
|
60
|
-
setDarkMode(isDark());
|
|
61
|
-
});
|
|
62
|
-
observer.observe(document.documentElement, {
|
|
63
|
-
attributes: true,
|
|
64
|
-
attributeFilter: ['class'],
|
|
65
|
-
});
|
|
66
|
-
return () => observer.disconnect();
|
|
67
|
-
}, []);
|
|
68
|
-
return darkMode;
|
|
69
|
-
}
|
|
1
|
+
"use client";import{useEffect as o,useState as s}from"react";function n(){if(typeof window>"u")return!1;try{let t=document.documentElement,e=getComputedStyle(t).getPropertyValue("--theme-is-dark").trim();return e==="1"?!0:e==="0"?!1:t.classList.contains("dark")}catch{return document.documentElement.classList.contains("dark")}}function a(){let[t,e]=s(!1);return o(()=>{e(n());let r=new MutationObserver(()=>{e(n())});return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),t}export{n as isDark,a as useIsDark};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkComponent.d.ts","sourceRoot":"","sources":["../../src/utils/linkComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linkComponent.d.ts","sourceRoot":"","sources":["../../src/utils/linkComponent.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EAEb,SAAS,EACV,MAAM,OAAO,CAAC;AAEf,0EAA0E;AAC1E,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC;AAQ5D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,wCAA+B,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAE9C"}
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
// packages/components/src/utils/linkComponent.tsx
|
|
3
|
-
/**
|
|
4
|
-
* @fileoverview Link renderer injection
|
|
5
|
-
* @description Components that render navigation (Card `href`) need the app router's link
|
|
6
|
-
* (Next `Link`, react-router `Link`) for client-side navigation, but this layer cannot
|
|
7
|
-
* import `@donotdev/ui`. `@donotdev/ui` registers its router link once in its providers;
|
|
8
|
-
* without a provider, a plain `<a href>` is rendered (full page load, still crawlable).
|
|
9
|
-
*
|
|
10
|
-
* @version 0.1.0
|
|
11
|
-
* @since 0.2.3
|
|
12
|
-
* @author AMBROISE PARK Consulting
|
|
13
|
-
*/
|
|
14
|
-
import { createContext, useContext } from 'react';
|
|
15
|
-
function PlainAnchor(props) {
|
|
16
|
-
return _jsx("a", { ...props });
|
|
17
|
-
}
|
|
18
|
-
const LinkRendererContext = createContext(PlainAnchor);
|
|
19
|
-
/**
|
|
20
|
-
* Provide the app router's link renderer to components of this package.
|
|
21
|
-
* Mounted by `@donotdev/ui` providers; apps do not use it directly.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```tsx
|
|
25
|
-
* <LinkRendererProvider value={({ href, ...rest }) => <Link path={href} {...rest} />}>
|
|
26
|
-
* {children}
|
|
27
|
-
* </LinkRendererProvider>
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export const LinkRendererProvider = LinkRendererContext.Provider;
|
|
31
|
-
/**
|
|
32
|
-
* The link renderer to use for `href` props: the router link when provided, else `<a>`.
|
|
33
|
-
* @returns The current link renderer
|
|
34
|
-
*/
|
|
35
|
-
export function useLinkRenderer() {
|
|
36
|
-
return useContext(LinkRendererContext);
|
|
37
|
-
}
|
|
1
|
+
"use client";import{createContext as n,useContext as t}from"react";import{jsx as i}from"react/jsx-runtime";function o(r){return i("a",{...r})}var e=n(o),c=e.Provider;function d(){return t(e)}export{c as LinkRendererProvider,d as useLinkRenderer};
|
|
@@ -1,197 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Measure an element's dimensions
|
|
4
|
-
*
|
|
5
|
-
* @version 0.1.0
|
|
6
|
-
* @since 0.0.1
|
|
7
|
-
* @author AMBROISE PARK Consulting
|
|
8
|
-
*/
|
|
9
|
-
export function measureElement(element, options = {}) {
|
|
10
|
-
if (!element || typeof window === 'undefined')
|
|
11
|
-
return null;
|
|
12
|
-
const { includePadding = false, includeBorders = false } = options;
|
|
13
|
-
try {
|
|
14
|
-
const rect = element.getBoundingClientRect();
|
|
15
|
-
const computedStyle = window.getComputedStyle(element);
|
|
16
|
-
// Cast to HTMLElement for offset properties
|
|
17
|
-
const htmlElement = element;
|
|
18
|
-
// getBoundingClientRect includes padding + borders by default.
|
|
19
|
-
// Start from content-box by subtracting both, then add back per options.
|
|
20
|
-
const paddingH = (parseFloat(computedStyle.paddingLeft) || 0) +
|
|
21
|
-
(parseFloat(computedStyle.paddingRight) || 0);
|
|
22
|
-
const paddingV = (parseFloat(computedStyle.paddingTop) || 0) +
|
|
23
|
-
(parseFloat(computedStyle.paddingBottom) || 0);
|
|
24
|
-
const borderH = (parseFloat(computedStyle.borderLeftWidth) || 0) +
|
|
25
|
-
(parseFloat(computedStyle.borderRightWidth) || 0);
|
|
26
|
-
const borderV = (parseFloat(computedStyle.borderTopWidth) || 0) +
|
|
27
|
-
(parseFloat(computedStyle.borderBottomWidth) || 0);
|
|
28
|
-
let width = rect.width - paddingH - borderH;
|
|
29
|
-
let height = rect.height - paddingV - borderV;
|
|
30
|
-
if (includePadding) {
|
|
31
|
-
width += paddingH;
|
|
32
|
-
height += paddingV;
|
|
33
|
-
}
|
|
34
|
-
if (includeBorders) {
|
|
35
|
-
width += borderH;
|
|
36
|
-
height += borderV;
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
width,
|
|
40
|
-
height,
|
|
41
|
-
scrollWidth: element.scrollWidth,
|
|
42
|
-
scrollHeight: element.scrollHeight,
|
|
43
|
-
clientWidth: element.clientWidth,
|
|
44
|
-
clientHeight: element.clientHeight,
|
|
45
|
-
offsetWidth: htmlElement.offsetWidth,
|
|
46
|
-
offsetHeight: htmlElement.offsetHeight,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
// Silent error handling for production
|
|
51
|
-
if (process.env.NODE_ENV === 'development') {
|
|
52
|
-
console.warn('Measurement error:', error);
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Measure content height of an element (scrollHeight)
|
|
59
|
-
*
|
|
60
|
-
* @version 0.1.0
|
|
61
|
-
* @since 0.0.1
|
|
62
|
-
* @author AMBROISE PARK Consulting
|
|
63
|
-
*/
|
|
64
|
-
export function measureContentHeight(element) {
|
|
65
|
-
if (!element || typeof window === 'undefined')
|
|
66
|
-
return 0;
|
|
67
|
-
try {
|
|
68
|
-
return element.scrollHeight;
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
if (process.env.NODE_ENV === 'development') {
|
|
72
|
-
console.warn('Content height measurement error:', error);
|
|
73
|
-
}
|
|
74
|
-
return 0;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Measure visible height of an element (clientHeight)
|
|
79
|
-
*
|
|
80
|
-
* @version 0.1.0
|
|
81
|
-
* @since 0.0.1
|
|
82
|
-
* @author AMBROISE PARK Consulting
|
|
83
|
-
*/
|
|
84
|
-
export function measureVisibleHeight(element) {
|
|
85
|
-
if (!element || typeof window === 'undefined')
|
|
86
|
-
return 0;
|
|
87
|
-
try {
|
|
88
|
-
return element.clientHeight;
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
if (process.env.NODE_ENV === 'development') {
|
|
92
|
-
console.warn('Visible height measurement error:', error);
|
|
93
|
-
}
|
|
94
|
-
return 0;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Create a ResizeObserver for measuring element dimensions
|
|
99
|
-
*
|
|
100
|
-
* @version 0.1.0
|
|
101
|
-
* @since 0.0.1
|
|
102
|
-
* @author AMBROISE PARK Consulting
|
|
103
|
-
*/
|
|
104
|
-
export function createMeasurementObserver(element, callback, options = {}) {
|
|
105
|
-
if (!element || typeof window === 'undefined')
|
|
106
|
-
return () => { };
|
|
107
|
-
const measure = () => {
|
|
108
|
-
const dimensions = measureElement(element, options);
|
|
109
|
-
if (dimensions) {
|
|
110
|
-
callback(dimensions);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
if (options.immediate) {
|
|
114
|
-
measure();
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
requestAnimationFrame(measure);
|
|
118
|
-
}
|
|
119
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
120
|
-
measure();
|
|
121
|
-
});
|
|
122
|
-
resizeObserver.observe(element);
|
|
123
|
-
return () => resizeObserver.disconnect();
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Create a measurement observer that tracks both container and content dimensions
|
|
127
|
-
* Batches DOM reads to minimize forced reflows
|
|
128
|
-
*
|
|
129
|
-
* @version 0.1.0
|
|
130
|
-
* @since 0.0.1
|
|
131
|
-
* @author AMBROISE PARK Consulting
|
|
132
|
-
*/
|
|
133
|
-
export function createDualMeasurementObserver(container, content, callback, options = {}) {
|
|
134
|
-
if (!container || !content || typeof window === 'undefined')
|
|
135
|
-
return () => { };
|
|
136
|
-
// Batch all DOM reads in single frame to avoid multiple reflows
|
|
137
|
-
const measure = () => {
|
|
138
|
-
try {
|
|
139
|
-
// Read both in one go - single reflow
|
|
140
|
-
const containerHeight = container.clientHeight;
|
|
141
|
-
const contentHeight = content.scrollHeight;
|
|
142
|
-
callback(containerHeight, contentHeight);
|
|
143
|
-
}
|
|
144
|
-
catch {
|
|
145
|
-
callback(0, 0);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
if (options.immediate) {
|
|
149
|
-
measure();
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
requestAnimationFrame(measure);
|
|
153
|
-
}
|
|
154
|
-
// Debounce ResizeObserver callback to avoid rapid-fire measurements
|
|
155
|
-
let rafId = null;
|
|
156
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
157
|
-
if (rafId)
|
|
158
|
-
cancelAnimationFrame(rafId);
|
|
159
|
-
rafId = requestAnimationFrame(measure);
|
|
160
|
-
});
|
|
161
|
-
resizeObserver.observe(container);
|
|
162
|
-
resizeObserver.observe(content);
|
|
163
|
-
return () => {
|
|
164
|
-
if (rafId)
|
|
165
|
-
cancelAnimationFrame(rafId);
|
|
166
|
-
resizeObserver.disconnect();
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Schedule a measurement callback to run in the next animation frame
|
|
171
|
-
* Use this to batch multiple measurements together
|
|
172
|
-
*
|
|
173
|
-
* @version 0.1.0
|
|
174
|
-
* @since 0.0.1
|
|
175
|
-
* @author AMBROISE PARK Consulting
|
|
176
|
-
*/
|
|
177
|
-
let pendingMeasurements = [];
|
|
178
|
-
let measurementFrameId = null;
|
|
179
|
-
export function scheduleMeasurement(callback) {
|
|
180
|
-
pendingMeasurements.push(callback);
|
|
181
|
-
if (measurementFrameId === null) {
|
|
182
|
-
measurementFrameId = requestAnimationFrame(() => {
|
|
183
|
-
const callbacks = pendingMeasurements;
|
|
184
|
-
pendingMeasurements = [];
|
|
185
|
-
measurementFrameId = null;
|
|
186
|
-
// Execute all measurements in single frame
|
|
187
|
-
for (const cb of callbacks) {
|
|
188
|
-
try {
|
|
189
|
-
cb();
|
|
190
|
-
}
|
|
191
|
-
catch {
|
|
192
|
-
// Silent fail for individual measurements
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
1
|
+
function p(e,n={}){if(!e||typeof window>"u")return null;let{includePadding:i=!1,includeBorders:o=!1}=n;try{let r=e.getBoundingClientRect(),t=window.getComputedStyle(e),s=e,l=(parseFloat(t.paddingLeft)||0)+(parseFloat(t.paddingRight)||0),d=(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0),h=(parseFloat(t.borderLeftWidth)||0)+(parseFloat(t.borderRightWidth)||0),f=(parseFloat(t.borderTopWidth)||0)+(parseFloat(t.borderBottomWidth)||0),u=r.width-l-h,a=r.height-d-f;return i&&(u+=l,a+=d),o&&(u+=h,a+=f),{width:u,height:a,scrollWidth:e.scrollWidth,scrollHeight:e.scrollHeight,clientWidth:e.clientWidth,clientHeight:e.clientHeight,offsetWidth:s.offsetWidth,offsetHeight:s.offsetHeight}}catch{return null}}function g(e){if(!e||typeof window>"u")return 0;try{return e.scrollHeight}catch{return 0}}function b(e){if(!e||typeof window>"u")return 0;try{return e.clientHeight}catch{return 0}}function v(e,n,i={}){if(!e||typeof window>"u")return()=>{};let o=()=>{let t=p(e,i);t&&n(t)};i.immediate?o():requestAnimationFrame(o);let r=new ResizeObserver(()=>{o()});return r.observe(e),()=>r.disconnect()}function H(e,n,i,o={}){if(!e||!n||typeof window>"u")return()=>{};let r=()=>{try{let l=e.clientHeight,d=n.scrollHeight;i(l,d)}catch{i(0,0)}};o.immediate?r():requestAnimationFrame(r);let t=null,s=new ResizeObserver(()=>{t&&cancelAnimationFrame(t),t=requestAnimationFrame(r)});return s.observe(e),s.observe(n),()=>{t&&cancelAnimationFrame(t),s.disconnect()}}var c=[],m=null;function w(e){c.push(e),m===null&&(m=requestAnimationFrame(()=>{let n=c;c=[],m=null;for(let i of n)try{i()}catch{}}))}export{H as createDualMeasurementObserver,v as createMeasurementObserver,g as measureContentHeight,p as measureElement,b as measureVisibleHeight,w as scheduleMeasurement};
|
|
@@ -1,45 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
/**
|
|
3
|
-
* Viewports that get the thumbnail: the `mobile` breakpoint (0-767px,
|
|
4
|
-
* `BREAKPOINT_RANGES.mobile` in `@donotdev/core`).
|
|
5
|
-
*/
|
|
6
|
-
export const THUMBNAIL_MEDIA = '(max-width: 767px)';
|
|
7
|
-
/**
|
|
8
|
-
* Whether `value` is a {@link ResponsiveImage} (has a string `fullUrl`), as
|
|
9
|
-
* opposed to a URL string or a React node.
|
|
10
|
-
*/
|
|
11
|
-
export function isResponsiveImage(value) {
|
|
12
|
-
return (typeof value === 'object' &&
|
|
13
|
-
value !== null &&
|
|
14
|
-
typeof value.fullUrl === 'string');
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* URL of the rendition {@link ResponsiveImg} shows at the current viewport.
|
|
18
|
-
* Client only (reads `matchMedia`); use it to preload the image a frame will show.
|
|
19
|
-
*/
|
|
20
|
-
export function currentRenditionUrl(image) {
|
|
21
|
-
const { fullUrl, thumbUrl } = image;
|
|
22
|
-
if (!thumbUrl || thumbUrl === fullUrl)
|
|
23
|
-
return fullUrl;
|
|
24
|
-
return window.matchMedia(THUMBNAIL_MEDIA).matches ? thumbUrl : fullUrl;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* `<img>` for an image pair: phones (below 768px) get the thumbnail, larger
|
|
28
|
-
* screens the full image, via `<picture><source media>`. The browser downloads
|
|
29
|
-
* one rendition only. A single rendition renders a plain `<img>`.
|
|
30
|
-
*
|
|
31
|
-
* `className` and `style` go on the `<img>`. The `<picture>` wrapper is an
|
|
32
|
-
* unstyled inline box, so the `<img>` lays out against the same container.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```tsx
|
|
36
|
-
* <ResponsiveImg image={product.images[0]} alt={product.name} loading="lazy" />
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export function ResponsiveImg({ image, ...imgProps }) {
|
|
40
|
-
const { fullUrl, thumbUrl } = image;
|
|
41
|
-
if (!thumbUrl || thumbUrl === fullUrl) {
|
|
42
|
-
return _jsx("img", { src: fullUrl, ...imgProps });
|
|
43
|
-
}
|
|
44
|
-
return (_jsxs("picture", { children: [_jsx("source", { media: THUMBNAIL_MEDIA, srcSet: thumbUrl }), _jsx("img", { src: fullUrl, ...imgProps })] }));
|
|
45
|
-
}
|
|
1
|
+
import{jsx as s,jsxs as o}from"react/jsx-runtime";var i="(max-width: 767px)";function m(e){return typeof e=="object"&&e!==null&&typeof e.fullUrl=="string"}function l(e){let{fullUrl:r,thumbUrl:t}=e;return!t||t===r?r:window.matchMedia(i).matches?t:r}function u({image:e,...r}){let{fullUrl:t,thumbUrl:n}=e;return!n||n===t?s("img",{src:t,...r}):o("picture",{children:[s("source",{media:i,srcSet:n}),s("img",{src:t,...r})]})}export{u as ResponsiveImg,i as THUMBNAIL_MEDIA,l as currentRenditionUrl,m as isResponsiveImage};
|
package/dist/utils/rtl.js
CHANGED
|
@@ -1,56 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview RTL Language Detection Utilities
|
|
4
|
-
* @description RTL language detection utility. Primarily used for setting the dir attribute on document.documentElement.
|
|
5
|
-
*
|
|
6
|
-
* IMPORTANT: For component RTL support, use native CSS with [dir='rtl'] selectors instead of JavaScript detection.
|
|
7
|
-
* - Radix UI components automatically handle RTL when using 'start'/'end' alignment props
|
|
8
|
-
* - Use CSS logical properties and [dir='rtl'] selectors for styling
|
|
9
|
-
* - Only use isRTLLanguage() when you need to set the dir attribute (e.g., in languageSelector)
|
|
10
|
-
*
|
|
11
|
-
* @version 0.1.0
|
|
12
|
-
* @since 0.0.1
|
|
13
|
-
* @author AMBROISE PARK Consulting
|
|
14
|
-
*/
|
|
15
|
-
// RTL language codes
|
|
16
|
-
const RTL_LANGUAGES = [
|
|
17
|
-
'ar', // Arabic
|
|
18
|
-
'he', // Hebrew
|
|
19
|
-
'fa', // Persian/Farsi
|
|
20
|
-
'ur', // Urdu
|
|
21
|
-
'ps', // Pashto
|
|
22
|
-
'sd', // Sindhi
|
|
23
|
-
'yi', // Yiddish
|
|
24
|
-
'ku', // Kurdish
|
|
25
|
-
'dv', // Divehi
|
|
26
|
-
];
|
|
27
|
-
/**
|
|
28
|
-
* Detects if a language is RTL
|
|
29
|
-
* @param language - Optional language code. If not provided, detects from current DOM
|
|
30
|
-
* @returns boolean indicating if the language is RTL
|
|
31
|
-
*
|
|
32
|
-
* NOTE: This function should primarily be used for setting the dir attribute on document.documentElement.
|
|
33
|
-
* For component logic, prefer checking document.documentElement.dir directly or using CSS [dir='rtl'] selectors.
|
|
34
|
-
*
|
|
35
|
-
* @version 0.1.0
|
|
36
|
-
* @since 0.0.1
|
|
37
|
-
* @author AMBROISE PARK Consulting
|
|
38
|
-
*/
|
|
39
|
-
export const isRTLLanguage = (language) => {
|
|
40
|
-
// If language parameter provided, check that specific language
|
|
41
|
-
if (language) {
|
|
42
|
-
return RTL_LANGUAGES.includes(language);
|
|
43
|
-
}
|
|
44
|
-
// SSR-safe: always return false during SSR to prevent hydration mismatches
|
|
45
|
-
if (typeof window === 'undefined')
|
|
46
|
-
return false;
|
|
47
|
-
// First check if dir attribute is set (most reliable)
|
|
48
|
-
const dir = document.documentElement.dir;
|
|
49
|
-
if (dir === 'rtl')
|
|
50
|
-
return true;
|
|
51
|
-
if (dir === 'ltr')
|
|
52
|
-
return false;
|
|
53
|
-
// Fallback to language detection
|
|
54
|
-
const currentLang = document.documentElement.lang || navigator.language.split('-')[0];
|
|
55
|
-
return RTL_LANGUAGES.includes(currentLang);
|
|
56
|
-
};
|
|
1
|
+
var t=["ar","he","fa","ur","ps","sd","yi","ku","dv"],u=e=>{if(e)return t.includes(e);if(typeof window>"u")return!1;let n=document.documentElement.dir;if(n==="rtl")return!0;if(n==="ltr")return!1;let r=document.documentElement.lang||navigator.language.split("-")[0];return t.includes(r)};export{u as isRTLLanguage};
|
|
@@ -1,43 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview HTML sanitizer (client + server)
|
|
4
|
-
* @description XSS-safe HTML sanitization for content rendered with
|
|
5
|
-
* `dangerouslySetInnerHTML` or parsed into React.
|
|
6
|
-
*
|
|
7
|
-
* DOMPurify from `@donotdev/components/sanitize-dom`, resolved by export condition:
|
|
8
|
-
* in the browser it runs on the real DOM (`sanitizeDom.browser.ts`); everywhere else
|
|
9
|
-
* (SSR, server components, tests) on jsdom (`sanitizeDom.server.ts`), the server setup
|
|
10
|
-
* DOMPurify recommends.
|
|
11
|
-
*
|
|
12
|
-
* @version 0.3.0
|
|
13
|
-
* @since 0.0.1
|
|
14
|
-
* @author AMBROISE PARK Consulting
|
|
15
|
-
*/
|
|
16
|
-
import { getPurifier } from '@donotdev/components/sanitize-dom';
|
|
17
|
-
/**
|
|
18
|
-
* Sanitize untrusted HTML. Removes scripts, event handlers, `javascript:` /
|
|
19
|
-
* `data:` URIs, and every tag or attribute outside the allowlist.
|
|
20
|
-
*
|
|
21
|
-
* Throws when no DOM implementation is available: DOMPurify would otherwise
|
|
22
|
-
* return the input unchanged.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```tsx
|
|
26
|
-
* <div dangerouslySetInnerHTML={{ __html: sanitizeHtml(value) }} />
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export function sanitizeHtml(html, options = {}) {
|
|
30
|
-
const DOMPurify = getPurifier();
|
|
31
|
-
if (!DOMPurify.isSupported) {
|
|
32
|
-
throw new Error('sanitizeHtml: no DOM implementation available, refusing to return unsanitized HTML');
|
|
33
|
-
}
|
|
34
|
-
return DOMPurify.sanitize(html, {
|
|
35
|
-
// No submittable forms in rendered content (phishing). Inputs stay: GFM
|
|
36
|
-
// task lists render as disabled checkboxes.
|
|
37
|
-
FORBID_TAGS: ['form'],
|
|
38
|
-
...(options.allowedTags && { ALLOWED_TAGS: [...options.allowedTags] }),
|
|
39
|
-
...(options.allowedAttributes && {
|
|
40
|
-
ALLOWED_ATTR: [...options.allowedAttributes],
|
|
41
|
-
}),
|
|
42
|
-
});
|
|
43
|
-
}
|
|
1
|
+
import{getPurifier as r}from"@donotdev/components/sanitize-dom";function a(i,t={}){let e=r();if(!e.isSupported)throw new Error("sanitizeHtml: no DOM implementation available, refusing to return unsanitized HTML");return e.sanitize(i,{FORBID_TAGS:["form"],...t.allowedTags&&{ALLOWED_TAGS:[...t.allowedTags]},...t.allowedAttributes&&{ALLOWED_ATTR:[...t.allowedAttributes]}})}export{a as sanitizeHtml};
|
package/dist/utils/variants.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { type VariantProps } from 'class-variance-authority';
|
|
|
9
9
|
* Used by: Card, DualCard, StackedCards, Dialog, Sheet, Alert
|
|
10
10
|
*/
|
|
11
11
|
export declare const surfaceVariants: (props?: ({
|
|
12
|
-
variant?: "default" | "muted" | "
|
|
12
|
+
variant?: "default" | "muted" | "accent" | "primary" | "destructive" | "outline" | "success" | "warning" | "secondary" | "glass" | null | undefined;
|
|
13
13
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
14
14
|
/** CVA variant props for surface components (Card, DualCard, etc.). */
|
|
15
15
|
export type SurfaceVariantProps = VariantProps<typeof surfaceVariants>;
|