fancy-ui-vue 0.1.1 → 0.3.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 +40 -13
- 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/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/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/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/typing-indicator/TypingIndicator.vue.js +1 -1
- package/dist/components/typing-indicator/TypingIndicator.vue2.js +7 -6
- package/dist/index.d.ts +6 -0
- package/dist/index.js +440 -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 +974 -571
- package/package.json +2 -2
- package/tailwind.css +9 -9
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
const TICK_NAV_HDR_PEAK = 4.9;
|
|
2
|
+
const MAX_LIGHTS = 256;
|
|
3
|
+
const MAX_DPR = 2;
|
|
4
|
+
const FORMAT = "rgba16float";
|
|
5
|
+
const WGSL = (
|
|
6
|
+
/* wgsl */
|
|
7
|
+
`
|
|
8
|
+
struct Frame {
|
|
9
|
+
size: vec2f,
|
|
10
|
+
accent: vec3f,
|
|
11
|
+
};
|
|
12
|
+
@group(0) @binding(0) var<uniform> frame: Frame;
|
|
13
|
+
|
|
14
|
+
struct Light {
|
|
15
|
+
@location(0) seg: vec4f, // x0, y, x1, radius
|
|
16
|
+
@location(1) look: vec4f, // halo, intensity, white, unused
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
struct Out {
|
|
20
|
+
@builtin(position) pos: vec4f,
|
|
21
|
+
@location(0) p: vec2f,
|
|
22
|
+
@location(1) seg: vec4f,
|
|
23
|
+
@location(2) look: vec4f,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
@vertex
|
|
27
|
+
fn vs(@builtin(vertex_index) vi: u32, light: Light) -> Out {
|
|
28
|
+
let corners = array<vec2f, 6>(
|
|
29
|
+
vec2f(0.0, 0.0), vec2f(1.0, 0.0), vec2f(0.0, 1.0),
|
|
30
|
+
vec2f(0.0, 1.0), vec2f(1.0, 0.0), vec2f(1.0, 1.0)
|
|
31
|
+
);
|
|
32
|
+
let reach = light.seg.w * 2.0 + light.look.x * 6.0;
|
|
33
|
+
let lo = vec2f(min(light.seg.x, light.seg.z) - reach, light.seg.y - reach);
|
|
34
|
+
let hi = vec2f(max(light.seg.x, light.seg.z) + reach, light.seg.y + reach);
|
|
35
|
+
let p = mix(lo, hi, corners[vi]);
|
|
36
|
+
var out: Out;
|
|
37
|
+
out.pos = vec4f(p.x / frame.size.x * 2.0 - 1.0, 1.0 - p.y / frame.size.y * 2.0, 0.0, 1.0);
|
|
38
|
+
out.p = p;
|
|
39
|
+
out.seg = light.seg;
|
|
40
|
+
out.look = light.look;
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@fragment
|
|
45
|
+
fn fs(in: Out) -> @location(0) vec4f {
|
|
46
|
+
let a = vec2f(in.seg.x, in.seg.y);
|
|
47
|
+
let b = vec2f(in.seg.z, in.seg.y);
|
|
48
|
+
let ab = b - a;
|
|
49
|
+
let t = clamp(dot(in.p - a, ab) / max(dot(ab, ab), 1e-4), 0.0, 1.0);
|
|
50
|
+
let d = length(in.p - (a + ab * t));
|
|
51
|
+
let core = exp(-(d * d) / max(in.seg.w * in.seg.w, 1e-3));
|
|
52
|
+
let halo = exp(-d / max(in.look.x, 1e-3)) * 0.35;
|
|
53
|
+
let v = (core + halo) * in.look.y;
|
|
54
|
+
let colour = mix(frame.accent, vec3f(1.0), in.look.z * core);
|
|
55
|
+
// Premultiplied, nearly additive: light adds to the page under it.
|
|
56
|
+
return vec4f(colour * v, clamp(v * 0.08, 0.0, 1.0));
|
|
57
|
+
}
|
|
58
|
+
`
|
|
59
|
+
);
|
|
60
|
+
function srgbToLinear(c) {
|
|
61
|
+
const s = c / 255;
|
|
62
|
+
return s <= 0.04045 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
|
|
63
|
+
}
|
|
64
|
+
async function startTickNavHdr(canvas) {
|
|
65
|
+
try {
|
|
66
|
+
let writeUniform = function() {
|
|
67
|
+
device.queue.writeBuffer(
|
|
68
|
+
uniform,
|
|
69
|
+
0,
|
|
70
|
+
new Float32Array([width, height, 0, 0, accent[0], accent[1], accent[2], 0])
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
if (typeof navigator === "undefined" || typeof window === "undefined") return null;
|
|
74
|
+
const hdrDisplay = typeof window.matchMedia === "function" && window.matchMedia("(dynamic-range: high)").matches;
|
|
75
|
+
if (!hdrDisplay) return null;
|
|
76
|
+
const gpu = navigator.gpu;
|
|
77
|
+
if (!gpu) return null;
|
|
78
|
+
const adapter = await gpu.requestAdapter();
|
|
79
|
+
if (!adapter) return null;
|
|
80
|
+
const device = await adapter.requestDevice();
|
|
81
|
+
const context = canvas.getContext("webgpu");
|
|
82
|
+
if (!context) {
|
|
83
|
+
device.destroy();
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
context.configure({
|
|
87
|
+
device,
|
|
88
|
+
format: FORMAT,
|
|
89
|
+
alphaMode: "premultiplied",
|
|
90
|
+
colorSpace: "display-p3",
|
|
91
|
+
toneMapping: { mode: "extended" }
|
|
92
|
+
});
|
|
93
|
+
let extended = false;
|
|
94
|
+
try {
|
|
95
|
+
const applied = context.getConfiguration?.();
|
|
96
|
+
extended = applied?.toneMapping?.mode === "extended";
|
|
97
|
+
} catch {
|
|
98
|
+
extended = false;
|
|
99
|
+
}
|
|
100
|
+
if (!extended) {
|
|
101
|
+
context.unconfigure();
|
|
102
|
+
device.destroy();
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const module = device.createShaderModule({ code: WGSL });
|
|
106
|
+
const uniform = device.createBuffer({
|
|
107
|
+
size: 32,
|
|
108
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
109
|
+
});
|
|
110
|
+
const instances = device.createBuffer({
|
|
111
|
+
size: MAX_LIGHTS * 8 * 4,
|
|
112
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST
|
|
113
|
+
});
|
|
114
|
+
const pipeline = device.createRenderPipeline({
|
|
115
|
+
layout: "auto",
|
|
116
|
+
vertex: {
|
|
117
|
+
module,
|
|
118
|
+
entryPoint: "vs",
|
|
119
|
+
buffers: [
|
|
120
|
+
{
|
|
121
|
+
arrayStride: 32,
|
|
122
|
+
stepMode: "instance",
|
|
123
|
+
attributes: [
|
|
124
|
+
{ shaderLocation: 0, offset: 0, format: "float32x4" },
|
|
125
|
+
{ shaderLocation: 1, offset: 16, format: "float32x4" }
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
fragment: {
|
|
131
|
+
module,
|
|
132
|
+
entryPoint: "fs",
|
|
133
|
+
targets: [
|
|
134
|
+
{
|
|
135
|
+
format: FORMAT,
|
|
136
|
+
blend: {
|
|
137
|
+
color: { srcFactor: "one", dstFactor: "one", operation: "add" },
|
|
138
|
+
alpha: { srcFactor: "one", dstFactor: "one", operation: "add" }
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
primitive: { topology: "triangle-list" }
|
|
144
|
+
});
|
|
145
|
+
const bindGroup = device.createBindGroup({
|
|
146
|
+
layout: pipeline.getBindGroupLayout(0),
|
|
147
|
+
entries: [{ binding: 0, resource: { buffer: uniform } }]
|
|
148
|
+
});
|
|
149
|
+
let width = 1;
|
|
150
|
+
let height = 1;
|
|
151
|
+
let accent = [0.6, 0.3, 1];
|
|
152
|
+
let destroyed = false;
|
|
153
|
+
const data = new Float32Array(MAX_LIGHTS * 8);
|
|
154
|
+
writeUniform();
|
|
155
|
+
return {
|
|
156
|
+
render(lights) {
|
|
157
|
+
if (destroyed) return;
|
|
158
|
+
const n = Math.min(lights.length, MAX_LIGHTS);
|
|
159
|
+
for (let i = 0; i < n; i++) {
|
|
160
|
+
const l = lights[i];
|
|
161
|
+
if (!l) continue;
|
|
162
|
+
data.set([l.x0, l.y, l.x1, l.radius, l.halo, l.intensity, l.white, 0], i * 8);
|
|
163
|
+
}
|
|
164
|
+
if (n) device.queue.writeBuffer(instances, 0, data, 0, n * 8);
|
|
165
|
+
const encoder = device.createCommandEncoder();
|
|
166
|
+
const pass = encoder.beginRenderPass({
|
|
167
|
+
colorAttachments: [
|
|
168
|
+
{
|
|
169
|
+
view: context.getCurrentTexture().createView(),
|
|
170
|
+
clearValue: { r: 0, g: 0, b: 0, a: 0 },
|
|
171
|
+
loadOp: "clear",
|
|
172
|
+
storeOp: "store"
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
if (n) {
|
|
177
|
+
pass.setPipeline(pipeline);
|
|
178
|
+
pass.setBindGroup(0, bindGroup);
|
|
179
|
+
pass.setVertexBuffer(0, instances);
|
|
180
|
+
pass.draw(6, n);
|
|
181
|
+
}
|
|
182
|
+
pass.end();
|
|
183
|
+
device.queue.submit([encoder.finish()]);
|
|
184
|
+
},
|
|
185
|
+
resize(w, h) {
|
|
186
|
+
width = Math.max(1, w);
|
|
187
|
+
height = Math.max(1, h);
|
|
188
|
+
const dpr = Math.min(window.devicePixelRatio || 1, MAX_DPR);
|
|
189
|
+
canvas.width = Math.round(width * dpr);
|
|
190
|
+
canvas.height = Math.round(height * dpr);
|
|
191
|
+
writeUniform();
|
|
192
|
+
},
|
|
193
|
+
setAccent(rgb) {
|
|
194
|
+
accent = [srgbToLinear(rgb[0]), srgbToLinear(rgb[1]), srgbToLinear(rgb[2])];
|
|
195
|
+
writeUniform();
|
|
196
|
+
},
|
|
197
|
+
destroy() {
|
|
198
|
+
destroyed = true;
|
|
199
|
+
try {
|
|
200
|
+
context.unconfigure();
|
|
201
|
+
} catch {
|
|
202
|
+
}
|
|
203
|
+
device.destroy();
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
} catch {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const TICK_NAV_HDR_PAD = 24;
|
|
211
|
+
function tickNavLights(lines) {
|
|
212
|
+
const out = [];
|
|
213
|
+
const pad = TICK_NAV_HDR_PAD;
|
|
214
|
+
for (const line of lines) {
|
|
215
|
+
const row = line.kind === "row";
|
|
216
|
+
const tube = Math.max(line.current ? 0.9 : 0, line.near * (row ? 1.1 : 0.45));
|
|
217
|
+
if (tube > 0.02) {
|
|
218
|
+
out.push({
|
|
219
|
+
x0: line.x + pad,
|
|
220
|
+
x1: line.x + line.length + pad,
|
|
221
|
+
y: line.y + pad,
|
|
222
|
+
radius: row ? 1.1 : 0.8,
|
|
223
|
+
halo: 3 + line.near * 5,
|
|
224
|
+
intensity: tube,
|
|
225
|
+
white: 0.2
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
if (line.progress !== null) {
|
|
229
|
+
const head = line.x + line.length * line.progress + pad;
|
|
230
|
+
out.push({
|
|
231
|
+
x0: head - 3,
|
|
232
|
+
x1: head + 3,
|
|
233
|
+
y: line.y + pad,
|
|
234
|
+
radius: row ? 1.6 : 1.2,
|
|
235
|
+
halo: 7,
|
|
236
|
+
intensity: TICK_NAV_HDR_PEAK * Math.pow(1 - line.progress, 0.6) * (row ? 1 : 0.6),
|
|
237
|
+
white: 0.85
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return out;
|
|
242
|
+
}
|
|
243
|
+
function watchTickNavAccent(el, onChange) {
|
|
244
|
+
const view = el.ownerDocument.defaultView;
|
|
245
|
+
if (!view) return () => {
|
|
246
|
+
};
|
|
247
|
+
let last = "";
|
|
248
|
+
const read = () => {
|
|
249
|
+
const css = view.getComputedStyle(el).color;
|
|
250
|
+
if (css === last) return;
|
|
251
|
+
last = css;
|
|
252
|
+
onChange(css);
|
|
253
|
+
};
|
|
254
|
+
read();
|
|
255
|
+
const doc = el.ownerDocument;
|
|
256
|
+
const observer = new view.MutationObserver(read);
|
|
257
|
+
const watched = { attributes: true, attributeFilter: ["class", "style", "data-theme"] };
|
|
258
|
+
observer.observe(doc.documentElement, watched);
|
|
259
|
+
if (doc.body) observer.observe(doc.body, watched);
|
|
260
|
+
const scheme = view.matchMedia?.("(prefers-color-scheme: dark)");
|
|
261
|
+
scheme?.addEventListener?.("change", read);
|
|
262
|
+
return () => {
|
|
263
|
+
observer.disconnect();
|
|
264
|
+
scheme?.removeEventListener?.("change", read);
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function resolveCssColor(css) {
|
|
268
|
+
if (typeof document === "undefined") return null;
|
|
269
|
+
const ctx = document.createElement("canvas").getContext("2d", { willReadFrequently: true });
|
|
270
|
+
if (!ctx) return null;
|
|
271
|
+
ctx.fillStyle = "#000";
|
|
272
|
+
ctx.fillStyle = css;
|
|
273
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
274
|
+
const px = ctx.getImageData(0, 0, 1, 1).data;
|
|
275
|
+
return [px[0] ?? 0, px[1] ?? 0, px[2] ?? 0];
|
|
276
|
+
}
|
|
277
|
+
export {
|
|
278
|
+
TICK_NAV_HDR_PAD,
|
|
279
|
+
TICK_NAV_HDR_PEAK,
|
|
280
|
+
resolveCssColor,
|
|
281
|
+
startTickNavHdr,
|
|
282
|
+
tickNavLights,
|
|
283
|
+
watchTickNavAccent
|
|
284
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** One row of a TickNav. */
|
|
2
|
+
export interface TickNavItem {
|
|
3
|
+
/** Stable id; matched against `value` to mark the current row. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Visible text. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Renders the row as a link when set; otherwise it is a button. */
|
|
8
|
+
href?: string;
|
|
9
|
+
/** Short trailing tag, such as "New". */
|
|
10
|
+
badge?: string;
|
|
11
|
+
/** Greyed out, not activatable, silent. */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _sfc_main from "./TimePicker.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const TimePicker = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4
|
+
const TimePicker = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f8bb8e56"]]);
|
|
5
5
|
export {
|
|
6
6
|
TimePicker as default
|
|
7
7
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, mergeModels, useModel, computed, ref, useTemplateRef, watch, createElementBlock, openBlock, Fragment, createElementVNode, createCommentVNode, createVNode,
|
|
1
|
+
import { defineComponent, mergeModels, useAttrs, useModel, computed, ref, useTemplateRef, watch, createElementBlock, openBlock, Fragment, createElementVNode, createCommentVNode, createVNode, mergeProps, normalizeProps, guardReactiveProps, toDisplayString, unref } from "vue";
|
|
2
2
|
import { cn } from "../../utils.js";
|
|
3
3
|
import { useField } from "../../internals/field.js";
|
|
4
4
|
import { useListbox } from "../../internals/listbox.js";
|
|
@@ -7,8 +7,8 @@ import { useSoundCue } from "../../sound/use-sound.js";
|
|
|
7
7
|
import { filterByBounds, generateSlots, nearestIndex, formatSlotLabel } from "./time-utils.js";
|
|
8
8
|
import TimePickerPanel from "./TimePickerPanel.vue.js";
|
|
9
9
|
import { TIME_PICKER_CONTEXT } from "./types.js";
|
|
10
|
-
const _hoisted_1 = ["id", "
|
|
11
|
-
const _hoisted_2 = ["name", "^value", "disabled"];
|
|
10
|
+
const _hoisted_1 = ["id", "disabled"];
|
|
11
|
+
const _hoisted_2 = ["name", "form", "^value", "disabled"];
|
|
12
12
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
13
13
|
...{ name: "TimePicker", inheritAttrs: false },
|
|
14
14
|
__name: "TimePicker",
|
|
@@ -35,6 +35,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
35
35
|
}),
|
|
36
36
|
emits: ["update:value"],
|
|
37
37
|
setup(__props, { expose: __expose }) {
|
|
38
|
+
const attrs = useAttrs();
|
|
38
39
|
const value = useModel(__props, "value");
|
|
39
40
|
const field = useField();
|
|
40
41
|
const effectiveId = computed(() => field?.controlId ?? __props.id);
|
|
@@ -218,37 +219,44 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
218
219
|
__props.class
|
|
219
220
|
)
|
|
220
221
|
);
|
|
222
|
+
function triggerAttrs() {
|
|
223
|
+
const describedBy = [field?.describedBy, attrs["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
224
|
+
return {
|
|
225
|
+
...attrs,
|
|
226
|
+
type: "button",
|
|
227
|
+
role: "combobox",
|
|
228
|
+
"aria-haspopup": "listbox",
|
|
229
|
+
"aria-expanded": open.value,
|
|
230
|
+
"aria-controls": open.value ? panelId : void 0,
|
|
231
|
+
"aria-activedescendant": open.value && listbox.activeIndex !== -1 ? optionId(listbox.activeIndex) : void 0,
|
|
232
|
+
"aria-invalid": effectiveInvalid.value ? "true" : attrs["aria-invalid"],
|
|
233
|
+
"aria-required": effectiveRequired.value ? "true" : attrs["aria-required"],
|
|
234
|
+
"aria-describedby": describedBy,
|
|
235
|
+
"aria-label": __props.label ?? attrs["aria-label"]
|
|
236
|
+
};
|
|
237
|
+
}
|
|
221
238
|
return (_ctx, _cache) => {
|
|
222
239
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
223
|
-
createElementVNode("button", {
|
|
240
|
+
createElementVNode("button", mergeProps({
|
|
224
241
|
ref_key: "trigger",
|
|
225
242
|
ref: trigger,
|
|
226
243
|
id: effectiveId.value,
|
|
227
|
-
type: "button",
|
|
228
|
-
role: "combobox",
|
|
229
|
-
"aria-haspopup": "listbox",
|
|
230
|
-
"aria-expanded": open.value,
|
|
231
|
-
"aria-controls": open.value ? panelId : void 0,
|
|
232
|
-
"aria-activedescendant": open.value && unref(listbox).activeIndex !== -1 ? optionId(unref(listbox).activeIndex) : void 0,
|
|
233
|
-
"aria-invalid": effectiveInvalid.value ? "true" : void 0,
|
|
234
|
-
"aria-required": effectiveRequired.value ? "true" : void 0,
|
|
235
|
-
"aria-describedby": unref(field)?.describedBy,
|
|
236
|
-
"aria-label": __props.label,
|
|
237
244
|
disabled: effectiveDisabled.value,
|
|
238
|
-
class:
|
|
245
|
+
class: classes.value,
|
|
239
246
|
onClick: handleTriggerClick,
|
|
240
247
|
onKeydown: handleTriggerKeydown
|
|
241
|
-
}, [
|
|
248
|
+
}, triggerAttrs()), [
|
|
242
249
|
createElementVNode("span", normalizeProps(guardReactiveProps(triggerLabel.value ? {} : { class: "text-muted-foreground" })), toDisplayString(triggerLabel.value ?? __props.placeholder), 17),
|
|
243
250
|
_cache[0] || (_cache[0] = createElementVNode("span", {
|
|
244
251
|
"aria-hidden": "true",
|
|
245
252
|
class: "text-muted-foreground"
|
|
246
253
|
}, "◷", -1))
|
|
247
|
-
],
|
|
254
|
+
], 16, _hoisted_1),
|
|
248
255
|
__props.name ? (openBlock(), createElementBlock("input", {
|
|
249
256
|
key: 0,
|
|
250
257
|
type: "hidden",
|
|
251
258
|
name: __props.name,
|
|
259
|
+
form: unref(attrs).form,
|
|
252
260
|
"^value": value.value ?? "",
|
|
253
261
|
disabled: effectiveDisabled.value
|
|
254
262
|
}, null, 8, _hoisted_2)) : createCommentVNode("", true),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _sfc_main from "./Toast.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const Toast = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4
|
+
const Toast = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f2b313d4"]]);
|
|
5
5
|
export {
|
|
6
6
|
Toast as default
|
|
7
7
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent, useTemplateRef, computed, createElementBlock, openBlock, normalizeClass, createElementVNode, createCommentVNode, Fragment, createTextVNode, toDisplayString } from "vue";
|
|
1
|
+
import { defineComponent, useTemplateRef, ref, computed, createElementBlock, openBlock, normalizeClass, createElementVNode, createCommentVNode, Fragment, createTextVNode, toDisplayString, normalizeStyle } from "vue";
|
|
2
2
|
import { cn } from "../../utils.js";
|
|
3
|
-
import { dismissToast, pauseToast, resumeToast } from "./store.js";
|
|
3
|
+
import { settleToastAction, dismissToast, pauseToast, resumeToast } from "./store.js";
|
|
4
4
|
const _hoisted_1 = ["data-variant"];
|
|
5
5
|
const _hoisted_2 = {
|
|
6
6
|
key: 0,
|
|
@@ -12,6 +12,7 @@ const _hoisted_5 = {
|
|
|
12
12
|
key: 0,
|
|
13
13
|
class: "text-muted-foreground text-[11px]"
|
|
14
14
|
};
|
|
15
|
+
const _hoisted_6 = ["data-paused"];
|
|
15
16
|
const VARIANT_ICON_CLASSES = {
|
|
16
17
|
success: "ft-toast-icon--success",
|
|
17
18
|
error: "ft-toast-icon--error",
|
|
@@ -30,8 +31,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
30
31
|
__expose({ ref: el });
|
|
31
32
|
let hovering = false;
|
|
32
33
|
let focusedWithin = false;
|
|
34
|
+
const paused = ref(false);
|
|
33
35
|
function syncTimer() {
|
|
34
|
-
|
|
36
|
+
paused.value = hovering || focusedWithin;
|
|
37
|
+
if (paused.value) {
|
|
35
38
|
pauseToast(__props.item.id);
|
|
36
39
|
} else {
|
|
37
40
|
resumeToast(__props.item.id);
|
|
@@ -54,6 +57,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
54
57
|
syncTimer();
|
|
55
58
|
}
|
|
56
59
|
function handleAction() {
|
|
60
|
+
settleToastAction(__props.item.id);
|
|
57
61
|
__props.item.action?.onClick();
|
|
58
62
|
}
|
|
59
63
|
function handleDismiss() {
|
|
@@ -63,6 +67,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
63
67
|
() => cn(
|
|
64
68
|
"ft-toast bg-popover text-popover-foreground border-border flex w-[300px] items-center gap-3 rounded-xl border p-3 shadow-[0_12px_32px_rgba(0,0,0,.5)]",
|
|
65
69
|
__props.item.variant === "error" && "border-destructive/30",
|
|
70
|
+
__props.item.progress && "relative overflow-hidden",
|
|
66
71
|
__props.class
|
|
67
72
|
)
|
|
68
73
|
);
|
|
@@ -108,7 +113,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
108
113
|
class: "text-muted-foreground hover:text-foreground shrink-0 text-[12px] transition-colors",
|
|
109
114
|
"aria-label": "Dismiss",
|
|
110
115
|
onClick: handleDismiss
|
|
111
|
-
}, " ✕ ")
|
|
116
|
+
}, " ✕ "),
|
|
117
|
+
__props.item.progress ? (openBlock(), createElementBlock("div", {
|
|
118
|
+
key: 1,
|
|
119
|
+
class: "ft-toast-progress",
|
|
120
|
+
"aria-hidden": "true",
|
|
121
|
+
"data-paused": paused.value ? "true" : "false",
|
|
122
|
+
style: normalizeStyle({ "--toast-duration": `${__props.item.duration}ms` })
|
|
123
|
+
}, null, 12, _hoisted_6)) : createCommentVNode("", true)
|
|
112
124
|
], 42, _hoisted_1);
|
|
113
125
|
};
|
|
114
126
|
}
|
|
@@ -3,4 +3,4 @@ export type { ToastProps } from "./Toast.vue";
|
|
|
3
3
|
export { default as Toaster } from "./Toaster.vue";
|
|
4
4
|
export type { ToasterProps, ToasterPosition } from "./Toaster.vue";
|
|
5
5
|
export { toast, dismissToast } from "./store.js";
|
|
6
|
-
export type { ToastVariant, ToastAction, ToastOptions, ToastItem } from "./store.js";
|
|
6
|
+
export type { ToastVariant, ToastAction, ToastCloseReason, ToastOptions, ToastItem, } from "./store.js";
|
|
@@ -16,6 +16,14 @@ export interface ToastAction {
|
|
|
16
16
|
/** Called on activation. Does not dismiss the toast on its own — call `dismissToast` from inside if the action should also close it. */
|
|
17
17
|
onClick: () => void;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Why a toast closed, as handed to `onClose`:
|
|
21
|
+
* - `"timeout"` — its unpaused on-screen time ran out.
|
|
22
|
+
* - `"dismiss"` — the close button, or a `dismissToast` call.
|
|
23
|
+
* - `"action"` — its action button was pressed (the toast itself stays until dismissed).
|
|
24
|
+
* - `"evicted"` — pushed out by a newer toast once the stack was full.
|
|
25
|
+
*/
|
|
26
|
+
export type ToastCloseReason = "timeout" | "dismiss" | "action" | "evicted";
|
|
19
27
|
export interface ToastOptions {
|
|
20
28
|
/** Primary line. */
|
|
21
29
|
title: string;
|
|
@@ -33,6 +41,17 @@ export interface ToastOptions {
|
|
|
33
41
|
duration?: number;
|
|
34
42
|
/** A single optional action button. */
|
|
35
43
|
action?: ToastAction;
|
|
44
|
+
/**
|
|
45
|
+
* Called exactly once, with the reason the toast closed. Pressing the
|
|
46
|
+
* action settles it with `"action"` before the action's own `onClick`
|
|
47
|
+
* runs; a later `dismissToast` on that same toast does not fire it again.
|
|
48
|
+
*/
|
|
49
|
+
onClose?: (reason: ToastCloseReason) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Shows a thin bar that drains over `duration`, pausing while the toast
|
|
52
|
+
* is paused and static under reduced motion. Ignored for a sticky toast.
|
|
53
|
+
*/
|
|
54
|
+
progress?: boolean;
|
|
36
55
|
}
|
|
37
56
|
export interface ToastItem {
|
|
38
57
|
readonly id: string;
|
|
@@ -41,7 +60,11 @@ export interface ToastItem {
|
|
|
41
60
|
readonly variant: ToastVariant;
|
|
42
61
|
readonly duration: number;
|
|
43
62
|
readonly action?: ToastAction;
|
|
63
|
+
readonly onClose?: (reason: ToastCloseReason) => void;
|
|
64
|
+
readonly progress: boolean;
|
|
44
65
|
}
|
|
66
|
+
/** Settles a toast as `"action"` — called by `<Toast>` just before it runs the action's `onClick`. Does not close it. */
|
|
67
|
+
export declare function settleToastAction(id: string): void;
|
|
45
68
|
/**
|
|
46
69
|
* Queues a toast and returns its id (usable with `dismissToast`). A no-op
|
|
47
70
|
* that returns `""` when called outside the browser: there is no client to
|
|
@@ -15,7 +15,32 @@ function armHandle(id) {
|
|
|
15
15
|
const entry = timers.get(id);
|
|
16
16
|
if (!entry) return;
|
|
17
17
|
const ms = Math.max(0, entry.deadline - Date.now());
|
|
18
|
-
entry.handle = setTimeout(() =>
|
|
18
|
+
entry.handle = setTimeout(() => removeToast(id, "timeout"), ms);
|
|
19
|
+
}
|
|
20
|
+
const settled = /* @__PURE__ */ new Set();
|
|
21
|
+
function fireClose(item, reason) {
|
|
22
|
+
try {
|
|
23
|
+
item.onClose?.(reason);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
queueMicrotask(() => {
|
|
26
|
+
throw error;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function removeToast(id, reason) {
|
|
31
|
+
const item = items.value.find((candidate) => candidate.id === id);
|
|
32
|
+
if (!item) return;
|
|
33
|
+
items.value = items.value.filter((candidate) => candidate.id !== id);
|
|
34
|
+
clearHandle(id);
|
|
35
|
+
timers.delete(id);
|
|
36
|
+
if (settled.delete(id)) return;
|
|
37
|
+
fireClose(item, reason);
|
|
38
|
+
}
|
|
39
|
+
function settleToastAction(id) {
|
|
40
|
+
const item = items.value.find((candidate) => candidate.id === id);
|
|
41
|
+
if (!item || settled.has(id)) return;
|
|
42
|
+
settled.add(id);
|
|
43
|
+
fireClose(item, "action");
|
|
19
44
|
}
|
|
20
45
|
function toast(options) {
|
|
21
46
|
if (typeof window === "undefined") {
|
|
@@ -31,17 +56,21 @@ function toast(options) {
|
|
|
31
56
|
description: options.description,
|
|
32
57
|
variant,
|
|
33
58
|
duration,
|
|
34
|
-
action: options.action
|
|
59
|
+
action: options.action,
|
|
60
|
+
onClose: options.onClose,
|
|
61
|
+
progress: options.progress === true && Number.isFinite(duration)
|
|
35
62
|
};
|
|
36
63
|
const next = [...items.value, item];
|
|
64
|
+
let evicted;
|
|
37
65
|
if (next.length > MAX_VISIBLE) {
|
|
38
|
-
|
|
66
|
+
evicted = next.shift();
|
|
39
67
|
if (evicted) {
|
|
40
68
|
clearHandle(evicted.id);
|
|
41
69
|
timers.delete(evicted.id);
|
|
42
70
|
}
|
|
43
71
|
}
|
|
44
72
|
items.value = next;
|
|
73
|
+
if (evicted && !settled.delete(evicted.id)) fireClose(evicted, "evicted");
|
|
45
74
|
if (Number.isFinite(duration)) {
|
|
46
75
|
timers.set(id, { handle: void 0, deadline: Date.now() + duration, pausedAt: void 0 });
|
|
47
76
|
armHandle(id);
|
|
@@ -49,9 +78,7 @@ function toast(options) {
|
|
|
49
78
|
return id;
|
|
50
79
|
}
|
|
51
80
|
function dismissToast(id) {
|
|
52
|
-
|
|
53
|
-
clearHandle(id);
|
|
54
|
-
timers.delete(id);
|
|
81
|
+
removeToast(id, "dismiss");
|
|
55
82
|
}
|
|
56
83
|
function pauseToast(id) {
|
|
57
84
|
const entry = timers.get(id);
|
|
@@ -67,7 +94,7 @@ function resumeToast(id) {
|
|
|
67
94
|
entry.pausedAt = void 0;
|
|
68
95
|
}
|
|
69
96
|
if (entry.deadline <= Date.now()) {
|
|
70
|
-
|
|
97
|
+
removeToast(id, "timeout");
|
|
71
98
|
return;
|
|
72
99
|
}
|
|
73
100
|
armHandle(id);
|
|
@@ -99,6 +126,7 @@ export {
|
|
|
99
126
|
pauseToast,
|
|
100
127
|
rearmToastTimers,
|
|
101
128
|
resumeToast,
|
|
129
|
+
settleToastAction,
|
|
102
130
|
toast,
|
|
103
131
|
toastStore
|
|
104
132
|
};
|
|
@@ -19,6 +19,18 @@ export interface ToggleProps {
|
|
|
19
19
|
* default; only audible once the user has enabled sound.
|
|
20
20
|
*/
|
|
21
21
|
sound?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Form field name. When set, a hidden input named `name` is rendered inside
|
|
24
|
+
* the button and submits `value` (default `"on"`) while pressed, nothing
|
|
25
|
+
* while off or disabled, like a checkbox. The button is `type="button"` and never submits.
|
|
26
|
+
*/
|
|
27
|
+
name?: string;
|
|
28
|
+
/** Value submitted under `name` while pressed. Defaults to `"on"`. */
|
|
29
|
+
value?: string;
|
|
30
|
+
/** `id` of the `<form>` the hidden input belongs to, when not nested in it. */
|
|
31
|
+
form?: string;
|
|
32
|
+
/** Called after the component's own handling, never while disabled. */
|
|
33
|
+
onClick?: ((event: MouseEvent) => void) | ((event: MouseEvent) => void)[];
|
|
22
34
|
}
|
|
23
35
|
declare const _default: typeof __VLS_export;
|
|
24
36
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _sfc_main from "./Toggle.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const Toggle = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4
|
+
const Toggle = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1258c41c"]]);
|
|
5
5
|
export {
|
|
6
6
|
Toggle as default
|
|
7
7
|
};
|