fancy-ui-vue 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PORTING.md +123 -2
- package/README.md +20 -15
- package/dist/components/accordion/Accordion.vue.d.ts +44 -0
- package/dist/components/accordion/Accordion.vue.js +88 -0
- package/dist/components/accordion/Accordion.vue2.js +4 -0
- package/dist/components/accordion/AccordionContent.vue.d.ts +25 -0
- package/dist/components/accordion/AccordionContent.vue.js +42 -0
- package/dist/components/accordion/AccordionContent.vue2.js +4 -0
- package/dist/components/accordion/AccordionItem.vue.d.ts +21 -0
- package/dist/components/accordion/AccordionItem.vue.js +66 -0
- package/dist/components/accordion/AccordionItem.vue2.js +4 -0
- package/dist/components/accordion/AccordionTrigger.vue.d.ts +24 -0
- package/dist/components/accordion/AccordionTrigger.vue.js +83 -0
- package/dist/components/accordion/AccordionTrigger.vue2.js +4 -0
- package/dist/components/accordion/accordion-core.d.ts +35 -0
- package/dist/components/accordion/accordion-core.js +44 -0
- package/dist/components/accordion/index.d.ts +11 -0
- package/dist/components/accordion/types.d.ts +45 -0
- package/dist/components/accordion/types.js +7 -0
- package/dist/components/alert-dialog/AlertDialog.vue.js +22 -3
- package/dist/components/animated-testimonials/AnimatedTestimonials.vue.js +3 -3
- package/dist/components/apple-card-carousel/AppleCard.vue.js +1 -1
- package/dist/components/autocomplete/Autocomplete.vue.js +1 -1
- package/dist/components/autocomplete/Autocomplete.vue2.js +22 -15
- package/dist/components/avatar/Avatar.vue.d.ts +27 -0
- package/dist/components/avatar/Avatar.vue.js +119 -0
- package/dist/components/avatar/Avatar.vue2.js +4 -0
- package/dist/components/avatar/avatar-core.d.ts +40 -0
- package/dist/components/avatar/avatar-core.js +57 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/badge/Badge.vue.d.ts +21 -0
- package/dist/components/badge/Badge.vue.js +46 -0
- package/dist/components/badge/Badge.vue2.js +4 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/bento-grid/BentoFrame.vue.js +1 -1
- package/dist/components/bento-grid/BentoFrame.vue2.js +6 -5
- package/dist/components/bento-grid/BentoGrid.vue.js +1 -1
- package/dist/components/bento-grid/BentoGrid.vue2.js +12 -12
- package/dist/components/bento-grid/BentoGridCard.vue.js +6 -5
- package/dist/components/bento-grid/BentoGridItem.vue.js +6 -5
- package/dist/components/bg-falling-stars/FallingStarsBg.vue.d.ts +1 -1
- package/dist/components/bg-falling-stars/FallingStarsBg.vue.js +1 -1
- package/dist/components/bg-falling-stars/bg-falling-stars-core.d.ts +1 -1
- package/dist/components/bg-falling-stars/bg-falling-stars-core.js +47 -12
- package/dist/components/book/Book.vue.js +8 -9
- package/dist/components/book/BookDescription.vue.js +6 -5
- package/dist/components/book/BookHeader.vue.js +6 -5
- package/dist/components/book/BookTitle.vue.js +6 -5
- package/dist/components/box-reveal/BoxReveal.vue.js +6 -5
- package/dist/components/button/Button.vue.d.ts +6 -4
- package/dist/components/button/Button.vue.js +1 -1
- package/dist/components/button/Button.vue2.js +50 -22
- package/dist/components/card-3d/CardContainer.vue.js +1 -1
- package/dist/components/card-3d/CardItem.vue.js +1 -1
- package/dist/components/card-spotlight/CardSpotlight.vue.js +1 -1
- package/dist/components/chat-message/ChatMessageAction.vue.d.ts +4 -2
- package/dist/components/chat-message/ChatMessageAction.vue.js +4 -2
- package/dist/components/checkbox/Checkbox.vue.d.ts +2 -0
- package/dist/components/checkbox/Checkbox.vue.js +1 -1
- package/dist/components/checkbox/Checkbox.vue2.js +17 -7
- package/dist/components/collapsible/Collapsible.vue.d.ts +31 -0
- package/dist/components/collapsible/Collapsible.vue.js +60 -0
- package/dist/components/collapsible/Collapsible.vue2.js +4 -0
- package/dist/components/collapsible/CollapsibleContent.vue.d.ts +26 -0
- package/dist/components/collapsible/CollapsibleContent.vue.js +81 -0
- package/dist/components/collapsible/CollapsibleContent.vue2.js +4 -0
- package/dist/components/collapsible/CollapsibleTrigger.vue.d.ts +21 -0
- package/dist/components/collapsible/CollapsibleTrigger.vue.js +57 -0
- package/dist/components/collapsible/CollapsibleTrigger.vue2.js +4 -0
- package/dist/components/collapsible/collapsible-core.d.ts +47 -0
- package/dist/components/collapsible/collapsible-core.js +40 -0
- package/dist/components/collapsible/index.d.ts +8 -0
- package/dist/components/collapsible/types.d.ts +24 -0
- package/dist/components/collapsible/types.js +5 -0
- package/dist/components/combobox/Combobox.vue.js +1 -1
- package/dist/components/combobox/Combobox.vue2.js +24 -16
- package/dist/components/command-menu/CommandMenu.vue.d.ts +5 -0
- package/dist/components/command-menu/CommandMenu.vue.js +1 -1
- package/dist/components/command-menu/CommandMenu.vue2.js +5 -2
- package/dist/components/compare/Compare.vue.d.ts +15 -5
- package/dist/components/compare/Compare.vue.js +1 -1
- package/dist/components/compare/Compare.vue2.js +28 -13
- package/dist/components/composer/ComposerInput.vue.js +1 -1
- package/dist/components/composer/ComposerInput.vue2.js +11 -11
- package/dist/components/composer/ComposerModelPicker.vue.d.ts +4 -0
- package/dist/components/composer/ComposerModelPicker.vue.js +1 -1
- package/dist/components/composer/ComposerModelPicker.vue2.js +29 -15
- package/dist/components/composer/ComposerSubmit.vue.d.ts +2 -0
- package/dist/components/composer/ComposerSubmit.vue.js +16 -15
- package/dist/components/confetti/ConfettiButton.vue.d.ts +9 -2
- package/dist/components/confetti/ConfettiButton.vue.js +24 -6
- package/dist/components/container-text-flip/ContainerTextFlip.vue.js +1 -1
- package/dist/components/container-text-flip/ContainerTextFlip.vue2.js +12 -13
- package/dist/components/copy-button/CopyButton.vue.d.ts +5 -0
- package/dist/components/copy-button/CopyButton.vue.js +1 -1
- package/dist/components/copy-button/CopyButton.vue2.js +72 -11
- package/dist/components/datamosh-transition/DatamoshTransition.vue.d.ts +6 -2
- package/dist/components/datamosh-transition/DatamoshTransition.vue.js +7 -4
- package/dist/components/date-picker/DatePicker.vue.js +1 -1
- package/dist/components/date-picker/DatePicker.vue2.js +27 -21
- package/dist/components/dialog/Dialog.vue.js +20 -1
- package/dist/components/dialog/DialogSurface.vue.js +1 -1
- package/dist/components/dialog/DialogSurface.vue2.js +5 -2
- package/dist/components/dialog/types.d.ts +2 -0
- package/dist/components/direction-aware-hover/DirectionAwareHover.vue.js +1 -1
- package/dist/components/direction-aware-hover/DirectionAwareHover.vue2.js +9 -7
- package/dist/components/displacement-text/DisplacementText.vue.d.ts +4 -1
- package/dist/components/displacement-text/DisplacementText.vue.js +38 -11
- package/dist/components/displacement-text/displacement-text-core.d.ts +94 -4
- package/dist/components/displacement-text/displacement-text-core.js +287 -97
- package/dist/components/drawer/Drawer.vue.d.ts +5 -0
- package/dist/components/drawer/Drawer.vue.js +1 -1
- package/dist/components/drawer/Drawer.vue2.js +5 -2
- package/dist/components/dropdown-menu/DropdownMenuContent.vue.js +2 -1
- package/dist/components/dropdown-menu/DropdownMenuItem.vue.d.ts +4 -0
- package/dist/components/dropdown-menu/DropdownMenuItem.vue.js +17 -10
- package/dist/components/dropdown-menu/DropdownMenuSubTrigger.vue.d.ts +8 -0
- package/dist/components/dropdown-menu/DropdownMenuSubTrigger.vue.js +28 -13
- package/dist/components/dropdown-menu/DropdownMenuTrigger.vue.d.ts +4 -0
- package/dist/components/dropdown-menu/DropdownMenuTrigger.vue.js +1 -1
- package/dist/components/dropdown-menu/DropdownMenuTrigger.vue2.js +20 -10
- package/dist/components/editorial-engine/EditorialEngine.vue.js +1 -1
- package/dist/components/editorial-engine/engine.js +13 -0
- package/dist/components/file-upload/FileUpload.vue.d.ts +2 -0
- package/dist/components/file-upload/FileUpload.vue.js +1 -1
- package/dist/components/file-upload/FileUpload.vue2.js +20 -10
- package/dist/components/fireworks-hdr/FireworksHdr.vue.js +2 -2
- package/dist/components/flickering-grid/FlickeringGrid.vue.d.ts +1 -1
- package/dist/components/flickering-grid/FlickeringGrid.vue.js +1 -1
- package/dist/components/flickering-grid/flickering-grid-core.d.ts +1 -1
- package/dist/components/flickering-grid/flickering-grid-core.js +51 -9
- package/dist/components/flip-card/FlipCard.vue.d.ts +3 -1
- package/dist/components/flip-card/FlipCard.vue.js +1 -1
- package/dist/components/flip-card/FlipCard.vue2.js +5 -3
- package/dist/components/fluid-cursor/FluidCursor.vue.js +37 -9
- package/dist/components/fluid-cursor/fluid-cursor-core.js +3 -3
- package/dist/components/fluid-cursor/webgpu-engine.js +3 -3
- package/dist/components/focus/Focus.vue.js +1 -1
- package/dist/components/focus/Focus.vue2.js +2 -2
- package/dist/components/follow-button/FollowButton.vue.d.ts +69 -0
- package/dist/components/follow-button/FollowButton.vue.js +7 -0
- package/dist/components/follow-button/FollowButton.vue2.js +239 -0
- package/dist/components/follow-button/follow-core.d.ts +83 -0
- package/dist/components/follow-button/follow-core.js +92 -0
- package/dist/components/follow-button/index.d.ts +2 -0
- package/dist/components/frosted-glass/FrostedGlass.vue.js +1 -1
- package/dist/components/glare-card/GlareCard.vue.js +1 -1
- package/dist/components/glare-card/GlareCard.vue2.js +4 -4
- package/dist/components/glowing-effect/GlowingEffect.vue.js +3 -3
- package/dist/components/glowing-effect/glowing-effect-core.js +4 -1
- package/dist/components/gradient-button/GradientButton.vue.d.ts +6 -4
- package/dist/components/gradient-button/GradientButton.vue.js +1 -1
- package/dist/components/gradient-button/GradientButton.vue2.js +13 -3
- package/dist/components/icon-button/IconButton.vue.d.ts +6 -4
- package/dist/components/icon-button/IconButton.vue.js +11 -8
- package/dist/components/image-trail-cursor/ImageTrailCursor.vue.js +17 -7
- package/dist/components/image-trail-cursor/trail-variants.js +3 -6
- package/dist/components/inline-citation/InlineCitation.vue.js +1 -1
- package/dist/components/inline-citation/InlineCitation.vue2.js +20 -14
- package/dist/components/input/Input.vue.js +1 -1
- package/dist/components/input/Input.vue2.js +18 -8
- package/dist/components/interactive-grid-pattern/InteractiveGridPattern.vue.js +1 -1
- package/dist/components/interactive-grid-pattern/InteractiveGridPattern.vue2.js +1 -1
- package/dist/components/interactive-hover-button/InteractiveHoverButton.vue.d.ts +6 -3
- package/dist/components/interactive-hover-button/InteractiveHoverButton.vue.js +1 -1
- package/dist/components/interactive-hover-button/InteractiveHoverButton.vue2.js +12 -2
- package/dist/components/letter-pullup/LetterPullup.vue.js +4 -4
- package/dist/components/line-hover-link/LineHoverLink.vue.js +1 -1
- package/dist/components/line-hover-link/LineHoverLink.vue2.js +5 -6
- package/dist/components/link/Link.vue.d.ts +4 -2
- package/dist/components/link/Link.vue.js +1 -1
- package/dist/components/link/Link.vue2.js +11 -8
- package/dist/components/magnetic-field/MagnetPuck.vue.d.ts +51 -0
- package/dist/components/magnetic-field/MagnetPuck.vue.js +7 -0
- package/dist/components/magnetic-field/MagnetPuck.vue2.js +191 -0
- package/dist/components/magnetic-field/MagneticField.vue.d.ts +39 -0
- package/dist/components/magnetic-field/MagneticField.vue.js +7 -0
- package/dist/components/magnetic-field/MagneticField.vue2.js +157 -0
- package/dist/components/magnetic-field/MagneticItem.vue.d.ts +28 -0
- package/dist/components/magnetic-field/MagneticItem.vue.js +7 -0
- package/dist/components/magnetic-field/MagneticItem.vue2.js +72 -0
- package/dist/components/magnetic-field/index.d.ts +10 -0
- package/dist/components/magnetic-field/magnetic-field-core.d.ts +163 -0
- package/dist/components/magnetic-field/magnetic-field-core.js +534 -0
- package/dist/components/magnetic-field/magnetic-field-source.d.ts +58 -0
- package/dist/components/magnetic-field/magnetic-field-source.js +58 -0
- package/dist/components/magnetic-field/types.d.ts +14 -0
- package/dist/components/magnetic-field/types.js +5 -0
- package/dist/components/mosaic-glow/MosaicGlow.vue.d.ts +6 -0
- package/dist/components/mosaic-glow/MosaicGlow.vue.js +53 -9
- package/dist/components/mosaic-glow/mosaic-glow-core.d.ts +30 -0
- package/dist/components/mosaic-glow/mosaic-glow-core.js +27 -0
- package/dist/components/mosaic-glow/mosaic-glow-hdr.d.ts +24 -0
- package/dist/components/mosaic-glow/mosaic-glow-hdr.js +200 -0
- package/dist/components/navbar/NavbarLink.vue.d.ts +4 -2
- package/dist/components/navbar/NavbarLink.vue.js +1 -1
- package/dist/components/navbar/NavbarLink.vue2.js +16 -13
- package/dist/components/navigation-menu/NavigationMenu.vue.js +6 -3
- package/dist/components/navigation-menu/NavigationMenuLink.vue.js +1 -1
- package/dist/components/navigation-menu/NavigationMenuLink.vue2.js +8 -8
- package/dist/components/navigation-menu/NavigationMenuTrigger.vue.d.ts +15 -0
- package/dist/components/navigation-menu/NavigationMenuTrigger.vue.js +1 -1
- package/dist/components/navigation-menu/NavigationMenuTrigger.vue2.js +36 -15
- package/dist/components/neon-border/NeonBorder.vue.js +1 -1
- package/dist/components/neon-border/NeonBorder.vue2.js +10 -11
- package/dist/components/number-input/NumberInput.vue.js +1 -1
- package/dist/components/number-input/NumberInput.vue2.js +22 -12
- package/dist/components/password-input/PasswordInput.vue.js +1 -1
- package/dist/components/password-input/PasswordInput.vue2.js +18 -11
- package/dist/components/pixel-loader/PixelLoader.vue.js +1 -1
- package/dist/components/pixel-loader/PixelLoader.vue2.js +6 -6
- package/dist/components/pixel-scene/PixelScene.vue.d.ts +60 -0
- package/dist/components/pixel-scene/PixelScene.vue.js +184 -0
- package/dist/components/pixel-scene/PixelScene.vue2.js +4 -0
- package/dist/components/pixel-scene/index.d.ts +4 -0
- package/dist/components/pixel-scene/pixel-scene-core.d.ts +256 -0
- package/dist/components/pixel-scene/pixel-scene-core.js +878 -0
- package/dist/components/pixel-scene/pixel-scene-hdr.d.ts +68 -0
- package/dist/components/pixel-scene/pixel-scene-hdr.js +312 -0
- package/dist/components/pixel-scene/pixel-scene-scenes.d.ts +31 -0
- package/dist/components/pixel-scene/pixel-scene-scenes.js +1074 -0
- package/dist/components/popover/Popover.vue.d.ts +4 -0
- package/dist/components/popover/Popover.vue.js +1 -1
- package/dist/components/popover/Popover.vue2.js +8 -6
- package/dist/components/popover/PopoverContent.vue.js +6 -2
- package/dist/components/pulse-beam/PulseBeam.vue.d.ts +6 -2
- package/dist/components/pulse-beam/PulseBeam.vue.js +1 -1
- package/dist/components/pulse-beam/PulseBeam.vue2.js +7 -4
- package/dist/components/radio-group/RadioGroup.vue.js +12 -11
- package/dist/components/radio-group/RadioGroupItem.vue.d.ts +2 -0
- package/dist/components/radio-group/RadioGroupItem.vue.js +1 -1
- package/dist/components/radio-group/RadioGroupItem.vue2.js +20 -7
- package/dist/components/rainbow-button/RainbowButton.vue.d.ts +11 -2
- package/dist/components/rainbow-button/RainbowButton.vue.js +1 -1
- package/dist/components/rainbow-button/RainbowButton.vue2.js +35 -18
- package/dist/components/ripple-button/RippleButton.vue.d.ts +6 -4
- package/dist/components/ripple-button/RippleButton.vue.js +1 -1
- package/dist/components/ripple-button/RippleButton.vue2.js +10 -5
- package/dist/components/search-input/SearchInput.vue.js +1 -1
- package/dist/components/search-input/SearchInput.vue2.js +19 -9
- package/dist/components/select/Select.vue.d.ts +1 -1
- package/dist/components/select/Select.vue.js +1 -1
- package/dist/components/select/Select.vue2.js +25 -17
- package/dist/components/sheet/Sheet.vue.d.ts +5 -0
- package/dist/components/sheet/Sheet.vue.js +5 -2
- package/dist/components/shimmer-button/ShimmerButton.vue.d.ts +2 -2
- package/dist/components/shimmer-button/ShimmerButton.vue.js +1 -1
- package/dist/components/shimmer-button/ShimmerButton.vue2.js +14 -6
- package/dist/components/sidebar/SidebarItem.vue.d.ts +4 -2
- package/dist/components/sidebar/SidebarItem.vue.js +1 -1
- package/dist/components/sidebar/SidebarItem.vue2.js +4 -2
- package/dist/components/slider/Slider.vue.d.ts +4 -0
- package/dist/components/slider/Slider.vue.js +1 -1
- package/dist/components/slider/Slider.vue2.js +20 -8
- package/dist/components/sources/SourcesTrigger.vue.js +1 -1
- package/dist/components/sources/SourcesTrigger.vue2.js +11 -11
- package/dist/components/sparkles/sparkles-core.d.ts +1 -1
- package/dist/components/sparkles/sparkles-core.js +36 -2
- package/dist/components/story-thread/StoryNode.vue.d.ts +11 -0
- package/dist/components/story-thread/StoryNode.vue.js +7 -0
- package/dist/components/story-thread/StoryNode.vue2.js +23 -0
- package/dist/components/story-thread/StoryThread.vue.d.ts +56 -0
- package/dist/components/story-thread/StoryThread.vue.js +7 -0
- package/dist/components/story-thread/StoryThread.vue2.js +103 -0
- package/dist/components/story-thread/index.d.ts +5 -0
- package/dist/components/story-thread/story-thread-core.d.ts +119 -0
- package/dist/components/story-thread/story-thread-core.js +491 -0
- package/dist/components/story-thread/types.d.ts +1 -0
- package/dist/components/sun-switch/SunSwitch.vue.d.ts +61 -0
- package/dist/components/sun-switch/SunSwitch.vue.js +7 -0
- package/dist/components/sun-switch/SunSwitch.vue2.js +559 -0
- package/dist/components/sun-switch/index.d.ts +4 -0
- package/dist/components/sun-switch/pixel-wave-core.d.ts +82 -0
- package/dist/components/sun-switch/pixel-wave-core.js +508 -0
- package/dist/components/sun-switch/sun-switch-core.d.ts +251 -0
- package/dist/components/sun-switch/sun-switch-core.js +546 -0
- package/dist/components/sun-switch/sun-switch-hdr.d.ts +70 -0
- package/dist/components/sun-switch/sun-switch-hdr.js +311 -0
- package/dist/components/switch/Switch.vue.d.ts +2 -0
- package/dist/components/switch/Switch.vue.js +1 -1
- package/dist/components/switch/Switch.vue2.js +16 -6
- package/dist/components/tabs/TabsTrigger.vue.d.ts +6 -0
- package/dist/components/tabs/TabsTrigger.vue.js +1 -1
- package/dist/components/tabs/TabsTrigger.vue2.js +28 -15
- package/dist/components/terminal-block/TerminalBlock.vue.js +1 -1
- package/dist/components/terminal-block/TerminalBlock.vue2.js +10 -9
- package/dist/components/text-reveal-card/TextRevealCard.vue.js +1 -2
- package/dist/components/textarea/Textarea.vue.js +1 -1
- package/dist/components/textarea/Textarea.vue2.js +19 -12
- package/dist/components/tick-nav/TickNav.vue.d.ts +71 -0
- package/dist/components/tick-nav/TickNav.vue.js +7 -0
- package/dist/components/tick-nav/TickNav.vue2.js +285 -0
- package/dist/components/tick-nav/index.d.ts +3 -0
- package/dist/components/tick-nav/tick-nav-core.d.ts +102 -0
- package/dist/components/tick-nav/tick-nav-core.js +398 -0
- package/dist/components/tick-nav/tick-nav-hdr.d.ts +60 -0
- package/dist/components/tick-nav/tick-nav-hdr.js +284 -0
- package/dist/components/tick-nav/types.d.ts +13 -0
- package/dist/components/time-picker/TimePicker.vue.js +1 -1
- package/dist/components/time-picker/TimePicker.vue2.js +25 -17
- package/dist/components/toast/Toast.vue.js +1 -1
- package/dist/components/toast/Toast.vue2.js +16 -4
- package/dist/components/toast/index.d.ts +1 -1
- package/dist/components/toast/store.d.ts +23 -0
- package/dist/components/toast/store.js +35 -7
- package/dist/components/toggle/Toggle.vue.d.ts +12 -0
- package/dist/components/toggle/Toggle.vue.js +1 -1
- package/dist/components/toggle/Toggle.vue2.js +27 -11
- package/dist/components/toggle-group/ToggleGroup.vue.d.ts +11 -0
- package/dist/components/toggle-group/ToggleGroup.vue.js +1 -1
- package/dist/components/toggle-group/ToggleGroup.vue2.js +16 -3
- package/dist/components/toggle-group/ToggleGroupItem.vue.d.ts +6 -0
- package/dist/components/toggle-group/ToggleGroupItem.vue.js +1 -1
- package/dist/components/toggle-group/ToggleGroupItem.vue2.js +27 -14
- package/dist/components/tooltip/Tooltip.vue.js +13 -0
- package/dist/components/tracing-beam/TracingBeam.vue.d.ts +20 -1
- package/dist/components/tracing-beam/TracingBeam.vue.js +5 -164
- package/dist/components/tracing-beam/TracingBeam.vue2.js +168 -1
- package/dist/components/typing-indicator/TypingIndicator.vue.js +1 -1
- package/dist/components/typing-indicator/TypingIndicator.vue2.js +7 -6
- package/dist/index.d.ts +10 -0
- package/dist/index.js +466 -413
- package/dist/internals/anchor-position.js +3 -0
- package/dist/internals/call-listener.d.ts +11 -0
- package/dist/internals/call-listener.js +31 -0
- package/dist/internals/dismissable.d.ts +17 -0
- package/dist/internals/dismissable.js +44 -1
- package/dist/internals/env.d.ts +1 -0
- package/dist/internals/env.js +11 -0
- package/dist/internals/focus-trap.js +29 -4
- package/dist/internals/merge-ids.d.ts +6 -0
- package/dist/internals/merge-ids.js +11 -0
- package/dist/internals/motion/presence-core.d.ts +1 -1
- package/dist/sound/engine.js +23 -9
- package/dist/sound/themes.d.ts +4 -3
- package/dist/sound/themes.js +49 -211
- package/dist/sound/types.d.ts +9 -1
- package/dist/sound/types.js +2 -2
- package/dist/styles.css +1473 -571
- package/package.json +2 -2
- package/tailwind.css +9 -9
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
import { defineComponent, mergeModels, useModel, useTemplateRef, useAttrs, shallowRef, onMounted, watch, onBeforeUnmount, createElementBlock, openBlock, mergeProps, unref, createElementVNode, createCommentVNode, normalizeStyle, nextTick } from "vue";
|
|
2
|
+
import { cn } from "../../utils.js";
|
|
3
|
+
import { inView } from "../../internals/motion/in-view.js";
|
|
4
|
+
import { useReducedMotion } from "../../internals/motion/use-media-query.js";
|
|
5
|
+
import { sound } from "../../sound/sound.js";
|
|
6
|
+
import { flipWait, markFlip, isWaving, pixelWave } from "./pixel-wave-core.js";
|
|
7
|
+
import { createSunPainter, SUN_PALETTE } from "./sun-switch-core.js";
|
|
8
|
+
import { sunHdrAvailable, startSunHdr, SUN_HDR_RESTARTS, SUN_HDR_RESTART_MS } from "./sun-switch-hdr.js";
|
|
9
|
+
const _hoisted_1 = ["aria-checked", "aria-label", "aria-busy", "data-state", "data-waving", "data-hdr", "disabled"];
|
|
10
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
11
|
+
...{ name: "SunSwitch", inheritAttrs: false },
|
|
12
|
+
__name: "SunSwitch",
|
|
13
|
+
props: /* @__PURE__ */ mergeModels({
|
|
14
|
+
checked: { type: Boolean },
|
|
15
|
+
onCheckedChange: { type: Function },
|
|
16
|
+
radius: { default: 10 },
|
|
17
|
+
cell: { default: 5 },
|
|
18
|
+
dot: { default: 4 },
|
|
19
|
+
palette: { default: () => SUN_PALETTE },
|
|
20
|
+
ink: { default: "currentColor" },
|
|
21
|
+
nightAlpha: { default: 0.42 },
|
|
22
|
+
horizon: { type: Boolean, default: true },
|
|
23
|
+
lens: { type: Boolean, default: true },
|
|
24
|
+
lensRadius: { default: 7 },
|
|
25
|
+
mode: { default: "document" },
|
|
26
|
+
scope: { default: null },
|
|
27
|
+
fill: {},
|
|
28
|
+
duration: { default: 1300 },
|
|
29
|
+
haloCells: { default: 9 },
|
|
30
|
+
hdr: { type: Boolean, default: true },
|
|
31
|
+
sound: { type: Boolean, default: false },
|
|
32
|
+
label: { default: "Day mode" },
|
|
33
|
+
disabled: { type: Boolean, default: false },
|
|
34
|
+
class: { type: [Boolean, null, String, Object, Array] }
|
|
35
|
+
}, {
|
|
36
|
+
"checked": { type: Boolean, ...{ default: true } },
|
|
37
|
+
"checkedModifiers": {}
|
|
38
|
+
}),
|
|
39
|
+
emits: ["update:checked"],
|
|
40
|
+
setup(__props, { expose: __expose }) {
|
|
41
|
+
const checked = useModel(__props, "checked");
|
|
42
|
+
const el = useTemplateRef("ref");
|
|
43
|
+
const canvasEl = useTemplateRef("canvas");
|
|
44
|
+
const hdrCanvas = useTemplateRef("hdrCanvas");
|
|
45
|
+
__expose({ ref: el });
|
|
46
|
+
const attrs = useAttrs();
|
|
47
|
+
const CHAINED = [
|
|
48
|
+
"onClick",
|
|
49
|
+
"onPointerenter",
|
|
50
|
+
"onPointermove",
|
|
51
|
+
"onPointerdown",
|
|
52
|
+
"onPointerup",
|
|
53
|
+
"onPointerleave",
|
|
54
|
+
"onPointercancel",
|
|
55
|
+
"onFocus",
|
|
56
|
+
"onBlur",
|
|
57
|
+
"onKeydown"
|
|
58
|
+
];
|
|
59
|
+
function forwardedAttrs() {
|
|
60
|
+
const out = { ...attrs };
|
|
61
|
+
for (const key of CHAINED) delete out[key];
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
function chain(key, event) {
|
|
65
|
+
const listener = attrs[key];
|
|
66
|
+
if (Array.isArray(listener)) {
|
|
67
|
+
for (const fn of listener) if (typeof fn === "function") fn(event);
|
|
68
|
+
} else if (typeof listener === "function") {
|
|
69
|
+
listener(event);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const reduced = useReducedMotion();
|
|
73
|
+
let painter = null;
|
|
74
|
+
const painterReady = shallowRef(false);
|
|
75
|
+
const mounted = shallowRef(false);
|
|
76
|
+
const hdrCapable = shallowRef(false);
|
|
77
|
+
const hdrOn = shallowRef(false);
|
|
78
|
+
const hdrRun = shallowRef(0);
|
|
79
|
+
let hdrRestarts = 0;
|
|
80
|
+
const waving = shallowRef(false);
|
|
81
|
+
function sunRadius() {
|
|
82
|
+
return Math.max(1, Math.round(__props.radius));
|
|
83
|
+
}
|
|
84
|
+
let asleep = false;
|
|
85
|
+
let inkStale = false;
|
|
86
|
+
let inkFrame = 0;
|
|
87
|
+
function readInk() {
|
|
88
|
+
inkStale = false;
|
|
89
|
+
const canvas = canvasEl.value;
|
|
90
|
+
if (!painter || !canvas) return;
|
|
91
|
+
painter.setInk(getComputedStyle(canvas).color);
|
|
92
|
+
}
|
|
93
|
+
function scheduleInk() {
|
|
94
|
+
if (asleep) {
|
|
95
|
+
inkStale = true;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (inkFrame || typeof requestAnimationFrame !== "function") return;
|
|
99
|
+
inkFrame = requestAnimationFrame(() => {
|
|
100
|
+
inkFrame = 0;
|
|
101
|
+
readInk();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
let teardown = null;
|
|
105
|
+
onMounted(() => {
|
|
106
|
+
mounted.value = true;
|
|
107
|
+
hdrCapable.value = __props.hdr && sunHdrAvailable();
|
|
108
|
+
const canvas = canvasEl.value;
|
|
109
|
+
if (!canvas) return;
|
|
110
|
+
const p = createSunPainter(canvas, {
|
|
111
|
+
radius: __props.radius,
|
|
112
|
+
cell: __props.cell,
|
|
113
|
+
dot: __props.dot,
|
|
114
|
+
palette: __props.palette,
|
|
115
|
+
nightAlpha: __props.nightAlpha,
|
|
116
|
+
horizon: __props.horizon,
|
|
117
|
+
lens: __props.lens,
|
|
118
|
+
lensRadius: __props.lensRadius,
|
|
119
|
+
checked: checked.value,
|
|
120
|
+
reducedMotion: reduced.value
|
|
121
|
+
});
|
|
122
|
+
if (!p) return;
|
|
123
|
+
painter = p;
|
|
124
|
+
painterReady.value = true;
|
|
125
|
+
readInk();
|
|
126
|
+
let visible = true;
|
|
127
|
+
let hidden = document.visibilityState === "hidden";
|
|
128
|
+
const sync = () => {
|
|
129
|
+
asleep = !(visible && !hidden);
|
|
130
|
+
if (asleep) {
|
|
131
|
+
p.sleep();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (inkStale) readInk();
|
|
135
|
+
p.wake();
|
|
136
|
+
};
|
|
137
|
+
let ro;
|
|
138
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
139
|
+
ro = new ResizeObserver(() => p.resize());
|
|
140
|
+
try {
|
|
141
|
+
ro.observe(canvas, { box: "device-pixel-content-box" });
|
|
142
|
+
} catch {
|
|
143
|
+
ro.observe(canvas);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const io = inView(canvas, {
|
|
147
|
+
once: false,
|
|
148
|
+
threshold: 0,
|
|
149
|
+
onChange: (intersecting) => {
|
|
150
|
+
visible = intersecting;
|
|
151
|
+
sync();
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
const onVisibility = () => {
|
|
155
|
+
hidden = document.visibilityState === "hidden";
|
|
156
|
+
sync();
|
|
157
|
+
};
|
|
158
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
159
|
+
let mo;
|
|
160
|
+
if (typeof MutationObserver !== "undefined") {
|
|
161
|
+
mo = new MutationObserver(scheduleInk);
|
|
162
|
+
const attributeFilter = ["class", "style", "data-theme", "data-mode"];
|
|
163
|
+
mo.observe(document.documentElement, { attributes: true, attributeFilter });
|
|
164
|
+
mo.observe(document.body, { attributes: true, attributeFilter });
|
|
165
|
+
}
|
|
166
|
+
const scheme = typeof window.matchMedia === "function" ? window.matchMedia("(prefers-color-scheme: dark)") : null;
|
|
167
|
+
scheme?.addEventListener("change", scheduleInk);
|
|
168
|
+
const onColorSettled = (event) => {
|
|
169
|
+
const target = event.target;
|
|
170
|
+
if (event.propertyName !== "color" || !(target instanceof Node)) return;
|
|
171
|
+
if (target.contains(canvas)) scheduleInk();
|
|
172
|
+
};
|
|
173
|
+
document.addEventListener("transitionend", onColorSettled, true);
|
|
174
|
+
document.addEventListener("transitioncancel", onColorSettled, true);
|
|
175
|
+
sync();
|
|
176
|
+
teardown = () => {
|
|
177
|
+
ro?.disconnect();
|
|
178
|
+
io?.destroy?.();
|
|
179
|
+
mo?.disconnect();
|
|
180
|
+
scheme?.removeEventListener("change", scheduleInk);
|
|
181
|
+
document.removeEventListener("transitionend", onColorSettled, true);
|
|
182
|
+
document.removeEventListener("transitioncancel", onColorSettled, true);
|
|
183
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
184
|
+
if (inkFrame && typeof cancelAnimationFrame === "function") cancelAnimationFrame(inkFrame);
|
|
185
|
+
inkFrame = 0;
|
|
186
|
+
p.destroy();
|
|
187
|
+
painter = null;
|
|
188
|
+
painterReady.value = false;
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
watch(
|
|
192
|
+
() => __props.hdr,
|
|
193
|
+
(on) => {
|
|
194
|
+
hdrCapable.value = mounted.value && on && sunHdrAvailable();
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
watch(
|
|
198
|
+
[hdrCanvas, painterReady, hdrCapable, hdrRun],
|
|
199
|
+
([canvas, ready, capable], _old, onCleanup) => {
|
|
200
|
+
const p = painter;
|
|
201
|
+
if (!canvas || !ready || !capable || !p) return;
|
|
202
|
+
let cancelled = false;
|
|
203
|
+
let stop = null;
|
|
204
|
+
let retry = null;
|
|
205
|
+
const restart = () => {
|
|
206
|
+
if (hdrRestarts >= SUN_HDR_RESTARTS) {
|
|
207
|
+
hdrCapable.value = false;
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
hdrRestarts++;
|
|
211
|
+
retry = setTimeout(() => {
|
|
212
|
+
retry = null;
|
|
213
|
+
hdrRun.value++;
|
|
214
|
+
}, SUN_HDR_RESTART_MS * hdrRestarts);
|
|
215
|
+
};
|
|
216
|
+
void startSunHdr(canvas).then((layer) => {
|
|
217
|
+
if (cancelled || painter !== p) {
|
|
218
|
+
layer?.destroy();
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (!layer) {
|
|
222
|
+
if (hdrRestarts === 0) hdrCapable.value = false;
|
|
223
|
+
else restart();
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
p.setGlowTarget(layer);
|
|
227
|
+
hdrOn.value = true;
|
|
228
|
+
stop = () => {
|
|
229
|
+
p.setGlowTarget(null);
|
|
230
|
+
layer.destroy();
|
|
231
|
+
hdrOn.value = false;
|
|
232
|
+
};
|
|
233
|
+
void layer.lost.then(() => {
|
|
234
|
+
if (cancelled) return;
|
|
235
|
+
stop?.();
|
|
236
|
+
stop = null;
|
|
237
|
+
restart();
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
onCleanup(() => {
|
|
241
|
+
cancelled = true;
|
|
242
|
+
stop?.();
|
|
243
|
+
stop = null;
|
|
244
|
+
if (retry !== null) clearTimeout(retry);
|
|
245
|
+
});
|
|
246
|
+
},
|
|
247
|
+
{ flush: "post" }
|
|
248
|
+
);
|
|
249
|
+
onBeforeUnmount(() => {
|
|
250
|
+
clearTimeout(closeTimer);
|
|
251
|
+
clearTimeout(pendingTimer);
|
|
252
|
+
pendingTimer = void 0;
|
|
253
|
+
pending = null;
|
|
254
|
+
disarm?.();
|
|
255
|
+
disarm = null;
|
|
256
|
+
teardown?.();
|
|
257
|
+
teardown = null;
|
|
258
|
+
});
|
|
259
|
+
watch(
|
|
260
|
+
() => ({ radius: __props.radius, cell: __props.cell, dot: __props.dot, horizon: __props.horizon }),
|
|
261
|
+
(next) => painter?.setOptions(next),
|
|
262
|
+
{ flush: "post" }
|
|
263
|
+
);
|
|
264
|
+
watch(
|
|
265
|
+
() => ({ palette: __props.palette, nightAlpha: __props.nightAlpha, lens: __props.lens, lensRadius: __props.lensRadius }),
|
|
266
|
+
(next) => painter?.setOptions(next),
|
|
267
|
+
{ flush: "post" }
|
|
268
|
+
);
|
|
269
|
+
watch(checked, (value) => painter?.setOptions({ checked: value }), { flush: "post" });
|
|
270
|
+
watch(reduced, (value) => painter?.setOptions({ reducedMotion: value }), { flush: "post" });
|
|
271
|
+
watch(() => __props.ink, readInk, { flush: "post" });
|
|
272
|
+
let hovering = false;
|
|
273
|
+
let focused = false;
|
|
274
|
+
let lensOpen = false;
|
|
275
|
+
let targetX = 0;
|
|
276
|
+
let targetY = 0;
|
|
277
|
+
let closeTimer;
|
|
278
|
+
function sizeCells() {
|
|
279
|
+
return 2 * sunRadius() + 1;
|
|
280
|
+
}
|
|
281
|
+
function centreCells() {
|
|
282
|
+
return sunRadius() + 0.5;
|
|
283
|
+
}
|
|
284
|
+
function trackPointer(event) {
|
|
285
|
+
const canvas = canvasEl.value;
|
|
286
|
+
if (!canvas) return;
|
|
287
|
+
const r = canvas.getBoundingClientRect();
|
|
288
|
+
const size = sizeCells();
|
|
289
|
+
const sx = r.width > 0 ? size / r.width : 1 / __props.cell;
|
|
290
|
+
const sy = r.height > 0 ? size / r.height : 1 / __props.cell;
|
|
291
|
+
targetX = (event.clientX - r.left) * sx;
|
|
292
|
+
targetY = (event.clientY - r.top) * sy;
|
|
293
|
+
}
|
|
294
|
+
function syncLens() {
|
|
295
|
+
const want = __props.lens && !__props.disabled && (hovering || focused);
|
|
296
|
+
lensOpen = want || waving.value && lensOpen;
|
|
297
|
+
if (focused && !hovering) {
|
|
298
|
+
targetX = centreCells();
|
|
299
|
+
targetY = centreCells();
|
|
300
|
+
}
|
|
301
|
+
painter?.pointer(targetX, targetY, lensOpen);
|
|
302
|
+
}
|
|
303
|
+
function syncLensSoon() {
|
|
304
|
+
clearTimeout(closeTimer);
|
|
305
|
+
closeTimer = setTimeout(() => {
|
|
306
|
+
closeTimer = void 0;
|
|
307
|
+
syncLens();
|
|
308
|
+
}, 0);
|
|
309
|
+
}
|
|
310
|
+
watch(
|
|
311
|
+
() => [__props.lens, __props.disabled],
|
|
312
|
+
() => syncLens()
|
|
313
|
+
);
|
|
314
|
+
function onPointerEnter(event) {
|
|
315
|
+
hovering = true;
|
|
316
|
+
trackPointer(event);
|
|
317
|
+
syncLens();
|
|
318
|
+
chain("onPointerenter", event);
|
|
319
|
+
}
|
|
320
|
+
function onPointerMove(event) {
|
|
321
|
+
hovering = true;
|
|
322
|
+
trackPointer(event);
|
|
323
|
+
syncLens();
|
|
324
|
+
chain("onPointermove", event);
|
|
325
|
+
}
|
|
326
|
+
function onPointerDown(event) {
|
|
327
|
+
hovering = true;
|
|
328
|
+
trackPointer(event);
|
|
329
|
+
syncLens();
|
|
330
|
+
chain("onPointerdown", event);
|
|
331
|
+
}
|
|
332
|
+
function onPointerUp(event) {
|
|
333
|
+
if (event.pointerType === "touch") {
|
|
334
|
+
hovering = false;
|
|
335
|
+
syncLensSoon();
|
|
336
|
+
}
|
|
337
|
+
chain("onPointerup", event);
|
|
338
|
+
}
|
|
339
|
+
function onPointerLeave(event) {
|
|
340
|
+
hovering = false;
|
|
341
|
+
syncLensSoon();
|
|
342
|
+
chain("onPointerleave", event);
|
|
343
|
+
}
|
|
344
|
+
function onPointerCancel(event) {
|
|
345
|
+
hovering = false;
|
|
346
|
+
syncLensSoon();
|
|
347
|
+
chain("onPointercancel", event);
|
|
348
|
+
}
|
|
349
|
+
function onFocus(event) {
|
|
350
|
+
let visible = false;
|
|
351
|
+
try {
|
|
352
|
+
visible = event.currentTarget.matches(":focus-visible");
|
|
353
|
+
} catch {
|
|
354
|
+
visible = false;
|
|
355
|
+
}
|
|
356
|
+
focused = visible;
|
|
357
|
+
syncLens();
|
|
358
|
+
chain("onFocus", event);
|
|
359
|
+
}
|
|
360
|
+
function onBlur(event) {
|
|
361
|
+
focused = false;
|
|
362
|
+
syncLensSoon();
|
|
363
|
+
chain("onBlur", event);
|
|
364
|
+
}
|
|
365
|
+
let intent = null;
|
|
366
|
+
let token = 0;
|
|
367
|
+
let pending = null;
|
|
368
|
+
let pendingTimer;
|
|
369
|
+
let disarm = null;
|
|
370
|
+
function toggle() {
|
|
371
|
+
if (__props.disabled) return;
|
|
372
|
+
const next = !(pending ?? intent ?? checked.value);
|
|
373
|
+
const wait = flipWait(window.performance.now());
|
|
374
|
+
if (wait > 0) {
|
|
375
|
+
pending = next;
|
|
376
|
+
pendingTimer ??= setTimeout(flushPending, wait);
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
pending = null;
|
|
380
|
+
startWave(next);
|
|
381
|
+
}
|
|
382
|
+
function flushPending() {
|
|
383
|
+
pendingTimer = void 0;
|
|
384
|
+
const wait = flipWait(window.performance.now());
|
|
385
|
+
if (wait > 0 && pending !== null) {
|
|
386
|
+
pendingTimer = setTimeout(flushPending, wait);
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const next = pending;
|
|
390
|
+
pending = null;
|
|
391
|
+
if (next === null || __props.disabled || next === (intent ?? checked.value)) return;
|
|
392
|
+
startWave(next);
|
|
393
|
+
}
|
|
394
|
+
function overButton(x, y) {
|
|
395
|
+
const r = el.value?.getBoundingClientRect();
|
|
396
|
+
return !!r && x >= r.left && x < r.right && y >= r.top && y < r.bottom;
|
|
397
|
+
}
|
|
398
|
+
function armReentry() {
|
|
399
|
+
if (disarm || __props.mode !== "document") return;
|
|
400
|
+
const root = document.documentElement;
|
|
401
|
+
const onDown = (event) => {
|
|
402
|
+
if (event.target === root && overButton(event.clientX, event.clientY)) {
|
|
403
|
+
event.preventDefault();
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
const onMove = (event) => {
|
|
407
|
+
if (event.target !== root || !overButton(event.clientX, event.clientY)) return;
|
|
408
|
+
hovering = true;
|
|
409
|
+
trackPointer(event);
|
|
410
|
+
syncLens();
|
|
411
|
+
};
|
|
412
|
+
const onDocClick = (event) => {
|
|
413
|
+
if (event.target === root && overButton(event.clientX, event.clientY)) el.value?.click();
|
|
414
|
+
};
|
|
415
|
+
document.addEventListener("pointerdown", onDown, true);
|
|
416
|
+
document.addEventListener("pointermove", onMove, true);
|
|
417
|
+
document.addEventListener("click", onDocClick, true);
|
|
418
|
+
disarm = () => {
|
|
419
|
+
document.removeEventListener("pointerdown", onDown, true);
|
|
420
|
+
document.removeEventListener("pointermove", onMove, true);
|
|
421
|
+
document.removeEventListener("click", onDocClick, true);
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
function onKeyDown(event) {
|
|
425
|
+
if (event.repeat && (event.key === "Enter" || event.key === " ")) event.preventDefault();
|
|
426
|
+
chain("onKeydown", event);
|
|
427
|
+
}
|
|
428
|
+
function isHovered() {
|
|
429
|
+
try {
|
|
430
|
+
return !!el.value?.matches(":hover");
|
|
431
|
+
} catch {
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function onClick(event) {
|
|
436
|
+
toggle();
|
|
437
|
+
chain("onClick", event);
|
|
438
|
+
}
|
|
439
|
+
function writeState(value) {
|
|
440
|
+
const button = el.value;
|
|
441
|
+
if (!button) return;
|
|
442
|
+
button.setAttribute("aria-checked", value ? "true" : "false");
|
|
443
|
+
button.setAttribute("data-state", value ? "day" : "night");
|
|
444
|
+
}
|
|
445
|
+
function startWave(next) {
|
|
446
|
+
markFlip(window.performance.now());
|
|
447
|
+
intent = next;
|
|
448
|
+
const id = ++token;
|
|
449
|
+
if (__props.sound) sound.play(next ? "toggle-on" : "toggle-off");
|
|
450
|
+
const canvas = canvasEl.value;
|
|
451
|
+
const instant = reduced.value || isWaving();
|
|
452
|
+
const rect = canvas?.getBoundingClientRect();
|
|
453
|
+
const centre = centreCells() * __props.cell;
|
|
454
|
+
const sx = rect && rect.width > 0 ? rect.width / (sizeCells() * __props.cell) : 1;
|
|
455
|
+
const sy = rect && rect.height > 0 ? rect.height / (sizeCells() * __props.cell) : 1;
|
|
456
|
+
let origin = { x: (rect?.left ?? 0) + centre * sx, y: (rect?.top ?? 0) + centre * sy };
|
|
457
|
+
if (__props.mode === "contained" && __props.scope) {
|
|
458
|
+
const sr = __props.scope.getBoundingClientRect();
|
|
459
|
+
origin = {
|
|
460
|
+
x: origin.x - sr.left - __props.scope.clientLeft,
|
|
461
|
+
y: origin.y - sr.top - __props.scope.clientTop
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
const oldInk = canvas ? getComputedStyle(canvas).color : "";
|
|
465
|
+
const front = (outer) => ({
|
|
466
|
+
cx: centre,
|
|
467
|
+
cy: centre,
|
|
468
|
+
R: Math.max(0, outer - __props.haloCells + 0.5) * __props.cell,
|
|
469
|
+
nextChecked: next,
|
|
470
|
+
oldInk
|
|
471
|
+
});
|
|
472
|
+
waving.value = !instant;
|
|
473
|
+
if (!instant) armReentry();
|
|
474
|
+
painter?.setFront(instant ? null : front(0));
|
|
475
|
+
void pixelWave({
|
|
476
|
+
origin,
|
|
477
|
+
mode: __props.mode,
|
|
478
|
+
scope: __props.scope,
|
|
479
|
+
live: canvas ?? null,
|
|
480
|
+
liveHdr: hdrCanvas.value,
|
|
481
|
+
hdr: __props.hdr,
|
|
482
|
+
fill: __props.fill,
|
|
483
|
+
cell: __props.cell,
|
|
484
|
+
dot: __props.dot,
|
|
485
|
+
haloCells: __props.haloCells,
|
|
486
|
+
duration: __props.duration,
|
|
487
|
+
palette: __props.palette,
|
|
488
|
+
reducedMotion: reduced.value,
|
|
489
|
+
apply: () => {
|
|
490
|
+
checked.value = next;
|
|
491
|
+
__props.onCheckedChange?.(next);
|
|
492
|
+
writeState(next);
|
|
493
|
+
painter?.setOptions({ checked: next });
|
|
494
|
+
readInk();
|
|
495
|
+
scheduleInk();
|
|
496
|
+
},
|
|
497
|
+
onFront: (outer) => {
|
|
498
|
+
if (id === token) painter?.setFront(front(outer));
|
|
499
|
+
}
|
|
500
|
+
}).then(() => {
|
|
501
|
+
void nextTick(() => {
|
|
502
|
+
writeState(checked.value);
|
|
503
|
+
painter?.setOptions({ checked: checked.value });
|
|
504
|
+
});
|
|
505
|
+
if (id !== token) return;
|
|
506
|
+
intent = null;
|
|
507
|
+
waving.value = false;
|
|
508
|
+
disarm?.();
|
|
509
|
+
disarm = null;
|
|
510
|
+
painter?.setFront(null);
|
|
511
|
+
hovering = isHovered();
|
|
512
|
+
syncLens();
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
return (_ctx, _cache) => {
|
|
516
|
+
return openBlock(), createElementBlock("button", mergeProps(forwardedAttrs(), {
|
|
517
|
+
ref: "ref",
|
|
518
|
+
type: "button",
|
|
519
|
+
role: "switch",
|
|
520
|
+
"aria-checked": checked.value ? "true" : "false",
|
|
521
|
+
"aria-label": __props.label,
|
|
522
|
+
"aria-busy": waving.value ? "true" : void 0,
|
|
523
|
+
"data-state": checked.value ? "day" : "night",
|
|
524
|
+
"data-waving": waving.value ? "" : void 0,
|
|
525
|
+
"data-hdr": hdrOn.value ? "" : void 0,
|
|
526
|
+
disabled: __props.disabled,
|
|
527
|
+
class: unref(cn)("ft-sun-switch", __props.class),
|
|
528
|
+
style: { "--ft-sun-r": String(sunRadius()), "--ft-sun-cell": `${__props.cell}px` },
|
|
529
|
+
onClick,
|
|
530
|
+
onPointerenter: onPointerEnter,
|
|
531
|
+
onPointermove: onPointerMove,
|
|
532
|
+
onPointerdown: onPointerDown,
|
|
533
|
+
onPointerup: onPointerUp,
|
|
534
|
+
onPointerleave: onPointerLeave,
|
|
535
|
+
onPointercancel: onPointerCancel,
|
|
536
|
+
onFocus,
|
|
537
|
+
onBlur,
|
|
538
|
+
onKeydown: onKeyDown
|
|
539
|
+
}), [
|
|
540
|
+
createElementVNode("canvas", {
|
|
541
|
+
ref: "canvas",
|
|
542
|
+
class: "ft-sun-switch-canvas",
|
|
543
|
+
"aria-hidden": "true",
|
|
544
|
+
style: normalizeStyle({ color: __props.ink })
|
|
545
|
+
}, null, 4),
|
|
546
|
+
hdrCapable.value ? (openBlock(), createElementBlock("canvas", {
|
|
547
|
+
key: 0,
|
|
548
|
+
ref_key: "hdrCanvas",
|
|
549
|
+
ref: hdrCanvas,
|
|
550
|
+
class: "ft-sun-switch-hdr",
|
|
551
|
+
"aria-hidden": "true"
|
|
552
|
+
}, null, 512)) : createCommentVNode("", true)
|
|
553
|
+
], 16, _hoisted_1);
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
export {
|
|
558
|
+
_sfc_main as default
|
|
559
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as SunSwitch } from "./SunSwitch.vue";
|
|
2
|
+
export type { SunSwitchProps } from "./SunSwitch.vue";
|
|
3
|
+
export { SUN_PALETTE, type SunPalette } from "./sun-switch-core.js";
|
|
4
|
+
export { pixelWave, isWaving, WAVE_CSS, type PixelWaveOptions, type PixelWaveMode, } from "./pixel-wave-core.js";
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type SunPalette } from "./sun-switch-core.js";
|
|
2
|
+
export declare const WAVE_ATTR = "data-fancy-sun-waving";
|
|
3
|
+
export declare const WAVE_NAME = "fancy-sun-wave";
|
|
4
|
+
export declare const LIVE_NAME = "fancy-sun-live";
|
|
5
|
+
export declare const WAVE_HDR_NAME = "fancy-sun-wave-hdr";
|
|
6
|
+
export declare const LIVE_HDR_NAME = "fancy-sun-live-hdr";
|
|
7
|
+
export declare const WAVE_STYLE_ID = "fancy-sun-wave-styles";
|
|
8
|
+
export declare const HALO_ATTR = "data-fancy-sun-halo";
|
|
9
|
+
export declare const HALO_HDR_ATTR = "data-fancy-sun-halo-hdr";
|
|
10
|
+
export declare const SHEET_ATTR = "data-fancy-sun-sheet";
|
|
11
|
+
export declare const GHOST_ATTR = "data-fancy-sun-ghost";
|
|
12
|
+
/** Largest backing store (device px) the wave canvas may use; some engines refuse
|
|
13
|
+
* bigger canvases (no context at all). */
|
|
14
|
+
export declare const MAX_WAVE_CANVAS_PIXELS = 16000000;
|
|
15
|
+
/** Backing-store scale of the halo / sheet canvas: an integer from 1 to 2 (the dots
|
|
16
|
+
* are whole cells, drawn crisp with `image-rendering: pixelated`), dropping to 1 when
|
|
17
|
+
* the canvas would exceed `MAX_WAVE_CANVAS_PIXELS`. */
|
|
18
|
+
export declare function waveCanvasDpr(devicePixelRatio: number, W: number, H: number): number;
|
|
19
|
+
/** View-transition rules, scoped to `html[data-fancy-sun-waving]` so other view
|
|
20
|
+
* transitions on the page keep their own animations. */
|
|
21
|
+
export declare const WAVE_CSS = "html[data-fancy-sun-waving]::view-transition-group(root),\nhtml[data-fancy-sun-waving]::view-transition-old(root),\nhtml[data-fancy-sun-waving]::view-transition-new(root),\nhtml[data-fancy-sun-waving]::view-transition-group(fancy-sun-wave),\nhtml[data-fancy-sun-waving]::view-transition-new(fancy-sun-wave),\nhtml[data-fancy-sun-waving]::view-transition-group(fancy-sun-live),\nhtml[data-fancy-sun-waving]::view-transition-new(fancy-sun-live),\nhtml[data-fancy-sun-waving]::view-transition-group(fancy-sun-wave-hdr),\nhtml[data-fancy-sun-waving]::view-transition-new(fancy-sun-wave-hdr),\nhtml[data-fancy-sun-waving]::view-transition-group(fancy-sun-live-hdr),\nhtml[data-fancy-sun-waving]::view-transition-new(fancy-sun-live-hdr) {\n\tanimation: none;\n\tmix-blend-mode: normal;\n}\nhtml[data-fancy-sun-waving]::view-transition-old(fancy-sun-wave),\nhtml[data-fancy-sun-waving]::view-transition-old(fancy-sun-live),\nhtml[data-fancy-sun-waving]::view-transition-old(fancy-sun-wave-hdr),\nhtml[data-fancy-sun-waving]::view-transition-old(fancy-sun-live-hdr) {\n\tdisplay: none;\n}\nhtml[data-fancy-sun-waving]::view-transition-new(root) {\n\tclip-path: polygon(0 0, 0 0, 0 0);\n}\n";
|
|
22
|
+
export type PixelWaveMode = "document" | "contained";
|
|
23
|
+
export interface PixelWaveOptions {
|
|
24
|
+
/** Wave origin: viewport px (document) or scope-local px (contained). */
|
|
25
|
+
origin: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
};
|
|
29
|
+
/** Flips the state synchronously. Called exactly once; errors are reported, not thrown. */
|
|
30
|
+
apply: () => void;
|
|
31
|
+
mode?: PixelWaveMode;
|
|
32
|
+
/** The element the wave covers in contained mode (positioned, overflow hidden). */
|
|
33
|
+
scope?: HTMLElement | null;
|
|
34
|
+
/** Element kept live during the wave (named `fancy-sun-live`, kept out of the sheet). */
|
|
35
|
+
live?: HTMLElement | null;
|
|
36
|
+
/** A second live element, drawn above `live` (the switch's HDR canvas), named
|
|
37
|
+
* `fancy-sun-live-hdr` during a view transition. */
|
|
38
|
+
liveHdr?: HTMLElement | null;
|
|
39
|
+
/** HDR displays: the halo also glows above SDR white on a WebGPU canvas. Default true. */
|
|
40
|
+
hdr?: boolean;
|
|
41
|
+
/** Colour of the old-state sheet. Default: first opaque background from scope/body up. */
|
|
42
|
+
fill?: string;
|
|
43
|
+
cell?: number;
|
|
44
|
+
dot?: number;
|
|
45
|
+
haloCells?: number;
|
|
46
|
+
duration?: number;
|
|
47
|
+
palette?: SunPalette;
|
|
48
|
+
ease?: (t: number) => number;
|
|
49
|
+
/** Default: `prefers-reduced-motion` read at call time. */
|
|
50
|
+
reducedMotion?: boolean;
|
|
51
|
+
/** Called every frame with the outer halo radius (cells) and progress t in [0, 1]. */
|
|
52
|
+
onFront?: (R: number, t: number) => void;
|
|
53
|
+
/** Clock in ms (tests). Default `performance.now()`. */
|
|
54
|
+
now?: () => number;
|
|
55
|
+
}
|
|
56
|
+
/** Injects `WAVE_CSS` once per document: adopted style sheet when supported,
|
|
57
|
+
* otherwise a `<style id="fancy-sun-wave-styles">` in `<head>`. */
|
|
58
|
+
export declare function ensureWaveStyles(doc: Document): void;
|
|
59
|
+
/** Whether `doc.startViewTransition` exists. A function, never a module constant. */
|
|
60
|
+
export declare function supportsViewTransition(doc: Document): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The colour `el` visibly sits on: computed backgrounds from `el` up to `<html>`,
|
|
63
|
+
* translucent layers composited over the first opaque one (white if none).
|
|
64
|
+
* A colour that cannot be parsed counts as opaque.
|
|
65
|
+
*/
|
|
66
|
+
export declare function firstOpaqueBackground(el: Element): string;
|
|
67
|
+
/** Minimum time between two theme flips: at most 3 full-page flips a second
|
|
68
|
+
* (photosensitivity). Shared by every switch on the page. */
|
|
69
|
+
export declare const MIN_FLIP_MS = 334;
|
|
70
|
+
/** Milliseconds before the next flip may start, page-wide (0 = now). */
|
|
71
|
+
export declare function flipWait(now: number): number;
|
|
72
|
+
/** Records that a flip started at `now`. */
|
|
73
|
+
export declare function markFlip(now: number): void;
|
|
74
|
+
/** Forgets the last flip (tests). */
|
|
75
|
+
export declare function resetFlipGate(): void;
|
|
76
|
+
/** Whether a wave is running (waves are global: one at a time). */
|
|
77
|
+
export declare function isWaving(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Runs one wave. Always calls `apply` exactly once and never rejects; the promise
|
|
80
|
+
* resolves once every canvas, attribute and view-transition name is cleaned up.
|
|
81
|
+
*/
|
|
82
|
+
export declare function pixelWave(o: PixelWaveOptions): Promise<void>;
|