fancy-ui-vue 0.2.0 → 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 +15 -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,83 @@
|
|
|
1
|
+
import { defineComponent, useAttrs, useTemplateRef, computed, createElementBlock, openBlock, createVNode, mergeProps, unref, withCtx, renderSlot, createElementVNode } from "vue";
|
|
2
|
+
import { callListener } from "../../internals/call-listener.js";
|
|
3
|
+
import { cn } from "../../utils.js";
|
|
4
|
+
import _sfc_main$1 from "../collapsible/CollapsibleTrigger.vue.js";
|
|
5
|
+
import { ACCORDION_KEY, ACCORDION_ITEM_KEY } from "./types.js";
|
|
6
|
+
const _hoisted_1 = ["aria-level"];
|
|
7
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
|
+
...{ name: "AccordionTrigger", inheritAttrs: false },
|
|
9
|
+
__name: "AccordionTrigger",
|
|
10
|
+
props: {
|
|
11
|
+
headingLevel: { default: 3 },
|
|
12
|
+
disabled: { type: Boolean, default: false },
|
|
13
|
+
class: { type: [Boolean, null, String, Object, Array] },
|
|
14
|
+
onKeydown: { type: [Function, Array] }
|
|
15
|
+
},
|
|
16
|
+
setup(__props, { expose: __expose }) {
|
|
17
|
+
const attrs = useAttrs();
|
|
18
|
+
const el = useTemplateRef("el");
|
|
19
|
+
__expose({
|
|
20
|
+
/** The button element. */
|
|
21
|
+
get ref() {
|
|
22
|
+
return el.value?.ref ?? null;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const root = ACCORDION_KEY.useOptional();
|
|
26
|
+
const item = ACCORDION_ITEM_KEY.useOptional();
|
|
27
|
+
const locked = computed(() => item && root ? root.isLocked(item.value) : false);
|
|
28
|
+
const isInert = computed(() => __props.disabled || (item?.disabled ?? false));
|
|
29
|
+
function forwarded() {
|
|
30
|
+
if (!isInert.value) return attrs;
|
|
31
|
+
return Object.fromEntries(Object.entries(attrs).filter(([key]) => !/^onKeydown/.test(key)));
|
|
32
|
+
}
|
|
33
|
+
function handleKeydown(event) {
|
|
34
|
+
if (isInert.value) return;
|
|
35
|
+
if (root?.navigate(event.currentTarget, event.key)) event.preventDefault();
|
|
36
|
+
callListener(__props.onKeydown, event);
|
|
37
|
+
}
|
|
38
|
+
return (_ctx, _cache) => {
|
|
39
|
+
return openBlock(), createElementBlock("div", {
|
|
40
|
+
role: "heading",
|
|
41
|
+
"aria-level": __props.headingLevel,
|
|
42
|
+
class: "ft-accordion-header m-0 flex"
|
|
43
|
+
}, [
|
|
44
|
+
createVNode(_sfc_main$1, mergeProps({
|
|
45
|
+
ref_key: "el",
|
|
46
|
+
ref: el
|
|
47
|
+
}, forwarded(), {
|
|
48
|
+
disabled: __props.disabled,
|
|
49
|
+
class: unref(cn)(
|
|
50
|
+
"ft-accordion-trigger flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium",
|
|
51
|
+
"hover:underline",
|
|
52
|
+
"[&[data-state=open]>svg]:rotate-180",
|
|
53
|
+
__props.class
|
|
54
|
+
),
|
|
55
|
+
"data-ft-accordion-trigger": "",
|
|
56
|
+
"aria-disabled": locked.value ? "true" : unref(attrs)["aria-disabled"],
|
|
57
|
+
onKeydown: handleKeydown
|
|
58
|
+
}), {
|
|
59
|
+
default: withCtx(() => [
|
|
60
|
+
renderSlot(_ctx.$slots, "default"),
|
|
61
|
+
_cache[0] || (_cache[0] = createElementVNode("svg", {
|
|
62
|
+
class: "ft-accordion-chevron text-muted-foreground size-4 shrink-0 transition-transform duration-200 motion-reduce:transition-none",
|
|
63
|
+
viewBox: "0 0 16 16",
|
|
64
|
+
fill: "none",
|
|
65
|
+
stroke: "currentColor",
|
|
66
|
+
"stroke-width": "1.5",
|
|
67
|
+
"stroke-linecap": "round",
|
|
68
|
+
"stroke-linejoin": "round",
|
|
69
|
+
"aria-hidden": "true",
|
|
70
|
+
focusable: "false"
|
|
71
|
+
}, [
|
|
72
|
+
createElementVNode("path", { d: "m4 6 4 4 4-4" })
|
|
73
|
+
], -1))
|
|
74
|
+
]),
|
|
75
|
+
_: 3
|
|
76
|
+
}, 16, ["disabled", "class", "aria-disabled"])
|
|
77
|
+
], 8, _hoisted_1);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
export {
|
|
82
|
+
_sfc_main as default
|
|
83
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The framework-free rules of the accordion, shared byte for byte by the
|
|
3
|
+
* Svelte, React and Vue packages: which values are open after a toggle, and
|
|
4
|
+
* where arrow keys send focus.
|
|
5
|
+
*/
|
|
6
|
+
/** How many items may be open at once. */
|
|
7
|
+
export type AccordionType = "single" | "multiple";
|
|
8
|
+
/** The stacking axis; it picks the arrow-key pair that moves focus. */
|
|
9
|
+
export type AccordionOrientation = "horizontal" | "vertical";
|
|
10
|
+
/** What the accordion's `value` carries: one value (`""` for none) or a list. */
|
|
11
|
+
export type AccordionValue = string | string[];
|
|
12
|
+
/** `value` read as the list of open item values, whatever the type. */
|
|
13
|
+
export declare function openValues(type: AccordionType, value: AccordionValue | undefined): string[];
|
|
14
|
+
/** The `value` an accordion of this type emits for a list of open item values. */
|
|
15
|
+
export declare function valueFor(type: AccordionType, open: string[]): AccordionValue;
|
|
16
|
+
/**
|
|
17
|
+
* Whether an item that is open may be closed. A single accordion that is not
|
|
18
|
+
* `collapsible` keeps exactly one item open once one has been opened.
|
|
19
|
+
*/
|
|
20
|
+
export declare function canClose(type: AccordionType, collapsible: boolean): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The open values after toggling `item`, or `null` when nothing changes (the
|
|
23
|
+
* open item of a single accordion that is not `collapsible`).
|
|
24
|
+
*/
|
|
25
|
+
export declare function toggleItem(type: AccordionType, collapsible: boolean, open: string[], item: string): string[] | null;
|
|
26
|
+
/** A step along the list (wrapping) or a jump to one of its ends. */
|
|
27
|
+
export type NavigationTarget = {
|
|
28
|
+
step: 1 | -1;
|
|
29
|
+
} | {
|
|
30
|
+
edge: "first" | "last";
|
|
31
|
+
};
|
|
32
|
+
/** What `key` does to focus on this axis, or `null` when it is not a navigation key. */
|
|
33
|
+
export declare function navigationTarget(orientation: AccordionOrientation, key: string): NavigationTarget | null;
|
|
34
|
+
/** The index focus lands on, wrapping at both ends; `-1` when there is nothing to focus. */
|
|
35
|
+
export declare function targetIndex(count: number, from: number, target: NavigationTarget): number;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function openValues(type, value) {
|
|
2
|
+
if (type === "multiple") return Array.isArray(value) ? value : value ? [value] : [];
|
|
3
|
+
if (Array.isArray(value)) {
|
|
4
|
+
const [first] = value;
|
|
5
|
+
return first ? [first] : [];
|
|
6
|
+
}
|
|
7
|
+
return value ? [value] : [];
|
|
8
|
+
}
|
|
9
|
+
function valueFor(type, open) {
|
|
10
|
+
return type === "multiple" ? open : open[0] ?? "";
|
|
11
|
+
}
|
|
12
|
+
function canClose(type, collapsible) {
|
|
13
|
+
return type === "multiple" || collapsible;
|
|
14
|
+
}
|
|
15
|
+
function toggleItem(type, collapsible, open, item) {
|
|
16
|
+
if (open.includes(item)) {
|
|
17
|
+
if (!canClose(type, collapsible)) return null;
|
|
18
|
+
return open.filter((value) => value !== item);
|
|
19
|
+
}
|
|
20
|
+
return type === "multiple" ? [...open, item] : [item];
|
|
21
|
+
}
|
|
22
|
+
function navigationTarget(orientation, key) {
|
|
23
|
+
const next = orientation === "vertical" ? "ArrowDown" : "ArrowRight";
|
|
24
|
+
const previous = orientation === "vertical" ? "ArrowUp" : "ArrowLeft";
|
|
25
|
+
if (key === next) return { step: 1 };
|
|
26
|
+
if (key === previous) return { step: -1 };
|
|
27
|
+
if (key === "Home") return { edge: "first" };
|
|
28
|
+
if (key === "End") return { edge: "last" };
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
function targetIndex(count, from, target) {
|
|
32
|
+
if (count <= 0) return -1;
|
|
33
|
+
if ("edge" in target) return target.edge === "first" ? 0 : count - 1;
|
|
34
|
+
const base = from < 0 ? 0 : from;
|
|
35
|
+
return ((base + target.step) % count + count) % count;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
canClose,
|
|
39
|
+
navigationTarget,
|
|
40
|
+
openValues,
|
|
41
|
+
targetIndex,
|
|
42
|
+
toggleItem,
|
|
43
|
+
valueFor
|
|
44
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Accordion from "./Accordion.vue";
|
|
2
|
+
import AccordionItem from "./AccordionItem.vue";
|
|
3
|
+
import AccordionTrigger from "./AccordionTrigger.vue";
|
|
4
|
+
import AccordionContent from "./AccordionContent.vue";
|
|
5
|
+
import type { AccordionProps } from "./Accordion.vue";
|
|
6
|
+
import type { AccordionItemProps } from "./AccordionItem.vue";
|
|
7
|
+
import type { AccordionTriggerProps } from "./AccordionTrigger.vue";
|
|
8
|
+
import type { AccordionContentProps } from "./AccordionContent.vue";
|
|
9
|
+
export { Accordion, type AccordionProps, AccordionItem, type AccordionItemProps, AccordionTrigger, type AccordionTriggerProps, AccordionContent, type AccordionContentProps, };
|
|
10
|
+
export type { AccordionOrientation, AccordionType, AccordionValue } from "./accordion-core.js";
|
|
11
|
+
export { ACCORDION_KEY, ACCORDION_ITEM_KEY, type AccordionContext, type AccordionItemContext, } from "./types.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contracts between an accordion root, its items and their triggers.
|
|
3
|
+
*
|
|
4
|
+
* `Accordion` owns which values are open; `AccordionItem` narrows that to its
|
|
5
|
+
* own value and republishes it as a collapsible context (see
|
|
6
|
+
* `../collapsible/types.ts`), so an item's trigger and region are a
|
|
7
|
+
* collapsible's. Arrow-key navigation never reads a registry: the root asks
|
|
8
|
+
* the live DOM for its triggers when a key is pressed, so triggers that mount
|
|
9
|
+
* late or get reordered still step through in the order on screen.
|
|
10
|
+
*/
|
|
11
|
+
import { type InternalContext } from "../../internals/dom/context.js";
|
|
12
|
+
import type { AccordionOrientation, AccordionType } from "./accordion-core.js";
|
|
13
|
+
/** What the root publishes. Items and triggers read it; only the root writes it. */
|
|
14
|
+
export interface AccordionContext {
|
|
15
|
+
/** How many items may be open at once. */
|
|
16
|
+
readonly type: AccordionType;
|
|
17
|
+
/** The axis, and so which arrow-key pair moves focus. */
|
|
18
|
+
readonly orientation: AccordionOrientation;
|
|
19
|
+
/** Whether every item is disabled. */
|
|
20
|
+
readonly disabled: boolean;
|
|
21
|
+
/** Whether `value` is open. */
|
|
22
|
+
isOpen(value: string): boolean;
|
|
23
|
+
/** Whether `value` is the open item of a single accordion that may not collapse. */
|
|
24
|
+
isLocked(value: string): boolean;
|
|
25
|
+
/** Toggles `value` and reports the new accordion value. A no-op when nothing would change. */
|
|
26
|
+
toggle(value: string): void;
|
|
27
|
+
/** The id of the trigger for `value`. */
|
|
28
|
+
triggerId(value: string): string;
|
|
29
|
+
/** The id of the region for `value`. */
|
|
30
|
+
contentId(value: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Moves focus for a navigation key pressed on `origin`, skipping disabled
|
|
33
|
+
* triggers and wrapping at both ends. Returns whether the key was handled.
|
|
34
|
+
*/
|
|
35
|
+
navigate(origin: HTMLElement, key: string): boolean;
|
|
36
|
+
}
|
|
37
|
+
/** What an item publishes to its trigger and region. */
|
|
38
|
+
export interface AccordionItemContext {
|
|
39
|
+
/** The item's value. */
|
|
40
|
+
readonly value: string;
|
|
41
|
+
/** Whether this item, or the whole accordion, is disabled. */
|
|
42
|
+
readonly disabled: boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare const ACCORDION_KEY: InternalContext<AccordionContext>;
|
|
45
|
+
export declare const ACCORDION_ITEM_KEY: InternalContext<AccordionItemContext>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createInternalContext } from "../../internals/dom/context.js";
|
|
2
|
+
const ACCORDION_KEY = createInternalContext("AccordionContext");
|
|
3
|
+
const ACCORDION_ITEM_KEY = createInternalContext("AccordionItemContext");
|
|
4
|
+
export {
|
|
5
|
+
ACCORDION_ITEM_KEY,
|
|
6
|
+
ACCORDION_KEY
|
|
7
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, mergeModels, useModel, useTemplateRef, computed, createElementBlock, openBlock, Fragment, createCommentVNode, createVNode, renderSlot, unref, withCtx, createElementVNode, toDisplayString, createTextVNode } from "vue";
|
|
1
|
+
import { defineComponent, mergeModels, useModel, useTemplateRef, computed, watch, createElementBlock, openBlock, Fragment, createCommentVNode, createVNode, renderSlot, unref, withCtx, createElementVNode, toDisplayString, createTextVNode } from "vue";
|
|
2
2
|
import { cn } from "../../utils.js";
|
|
3
3
|
import { useFancyId } from "../../internals/use-id.js";
|
|
4
4
|
import { useSoundCue } from "../../sound/use-sound.js";
|
|
@@ -59,6 +59,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
59
59
|
const uid = useFancyId();
|
|
60
60
|
const titleId = computed(() => __props.title ? `${uid}-title` : void 0);
|
|
61
61
|
const descriptionId = computed(() => __props.description ? `${uid}-description` : void 0);
|
|
62
|
+
const panelId = `${uid}-panel`;
|
|
63
|
+
watch(
|
|
64
|
+
[triggerRef, open],
|
|
65
|
+
([wrapper, isOpen], _prev, onCleanup) => {
|
|
66
|
+
const el = wrapper?.firstElementChild;
|
|
67
|
+
if (!el) return;
|
|
68
|
+
el.setAttribute("aria-haspopup", "dialog");
|
|
69
|
+
el.setAttribute("aria-expanded", String(isOpen));
|
|
70
|
+
if (isOpen) el.setAttribute("aria-controls", panelId);
|
|
71
|
+
else el.removeAttribute("aria-controls");
|
|
72
|
+
onCleanup(() => {
|
|
73
|
+
el.removeAttribute("aria-haspopup");
|
|
74
|
+
el.removeAttribute("aria-expanded");
|
|
75
|
+
el.removeAttribute("aria-controls");
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
{ immediate: true, flush: "post" }
|
|
79
|
+
);
|
|
62
80
|
return (_ctx, _cache) => {
|
|
63
81
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
64
82
|
_ctx.$slots.trigger ? (openBlock(), createElementBlock("span", {
|
|
@@ -73,6 +91,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
73
91
|
createVNode(DialogSurface, {
|
|
74
92
|
ref_key: "surface",
|
|
75
93
|
ref: surface,
|
|
94
|
+
id: panelId,
|
|
76
95
|
open: open.value,
|
|
77
96
|
role: "alertdialog",
|
|
78
97
|
"title-id": titleId.value,
|
|
@@ -106,7 +125,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
106
125
|
createVNode(Button, {
|
|
107
126
|
variant: "outline",
|
|
108
127
|
size: "sm",
|
|
109
|
-
|
|
128
|
+
onClick: handleCancel
|
|
110
129
|
}, {
|
|
111
130
|
default: withCtx(() => [
|
|
112
131
|
createTextVNode(toDisplayString(__props.cancelLabel), 1)
|
|
@@ -116,7 +135,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
116
135
|
createVNode(Button, {
|
|
117
136
|
variant: "destructive",
|
|
118
137
|
size: "sm",
|
|
119
|
-
|
|
138
|
+
onClick: handleConfirm
|
|
120
139
|
}, {
|
|
121
140
|
default: withCtx(() => [
|
|
122
141
|
createTextVNode(toDisplayString(__props.confirmLabel), 1)
|
|
@@ -99,7 +99,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
99
99
|
key: index,
|
|
100
100
|
class: normalizeClass(
|
|
101
101
|
unref(cn)(
|
|
102
|
-
"absolute inset-0 h-full w-full origin-bottom rounded-3xl
|
|
102
|
+
"absolute inset-0 h-full w-full origin-bottom rounded-3xl ease-in-out motion-safe:transition-all",
|
|
103
103
|
index === activeIndex.value ? "z-20 translate-y-0 scale-100 rotate-0 opacity-100" : "z-10 translate-y-4 scale-95 opacity-0",
|
|
104
104
|
index !== activeIndex.value && direction.value === "next" ? "-translate-y-4" : index !== activeIndex.value ? "translate-y-4" : ""
|
|
105
105
|
)
|
|
@@ -148,7 +148,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
148
148
|
"stroke-width": "2",
|
|
149
149
|
"stroke-linecap": "round",
|
|
150
150
|
"stroke-linejoin": "round",
|
|
151
|
-
class: "text-gray-800
|
|
151
|
+
class: "text-gray-800 group-hover/button:-translate-x-0.5 motion-safe:transition-transform dark:text-neutral-200"
|
|
152
152
|
}, [
|
|
153
153
|
createElementVNode("path", { d: "m15 18-6-6 6-6" })
|
|
154
154
|
], -1)
|
|
@@ -169,7 +169,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
169
169
|
"stroke-width": "2",
|
|
170
170
|
"stroke-linecap": "round",
|
|
171
171
|
"stroke-linejoin": "round",
|
|
172
|
-
class: "text-gray-800
|
|
172
|
+
class: "text-gray-800 group-hover/button:translate-x-0.5 motion-safe:transition-transform dark:text-neutral-200"
|
|
173
173
|
}, [
|
|
174
174
|
createElementVNode("path", { d: "m9 18 6-6-6-6" })
|
|
175
175
|
], -1)
|
|
@@ -140,7 +140,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
140
140
|
createElementVNode("img", {
|
|
141
141
|
src: __props.card.src,
|
|
142
142
|
alt: __props.card.title,
|
|
143
|
-
class: "absolute inset-0 h-full w-full object-cover transition-transform duration-500 hover:scale-105",
|
|
143
|
+
class: "absolute inset-0 h-full w-full object-cover motion-safe:transition-transform motion-safe:duration-500 hover:scale-105",
|
|
144
144
|
draggable: "false"
|
|
145
145
|
}, null, 8, _hoisted_2),
|
|
146
146
|
_cache[0] || (_cache[0] = createElementVNode("div", { class: "absolute inset-0 bg-gradient-to-t from-black/60 via-black/10 to-transparent" }, null, -1)),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _sfc_main from "./Autocomplete.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const Autocomplete = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4
|
+
const Autocomplete = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-220d004a"]]);
|
|
5
5
|
export {
|
|
6
6
|
Autocomplete as default
|
|
7
7
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, mergeModels, useModel, computed, ref, watch, useTemplateRef, createElementBlock, openBlock, Fragment, createElementVNode, createVNode,
|
|
1
|
+
import { defineComponent, mergeModels, useAttrs, useModel, computed, ref, watch, useTemplateRef, createElementBlock, openBlock, Fragment, createElementVNode, createVNode, mergeProps, toDisplayString } 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,7 +7,7 @@ import { useSoundCue } from "../../sound/use-sound.js";
|
|
|
7
7
|
import _sfc_main$1 from "./AutocompletePanel.vue.js";
|
|
8
8
|
import { AUTOCOMPLETE_CONTEXT } from "./types.js";
|
|
9
9
|
const _hoisted_1 = { class: "ft-autocomplete-wrapper relative" };
|
|
10
|
-
const _hoisted_2 = ["id", "name", "placeholder", "value", "disabled", "required"
|
|
10
|
+
const _hoisted_2 = ["id", "name", "placeholder", "value", "disabled", "required"];
|
|
11
11
|
const _hoisted_3 = {
|
|
12
12
|
class: "sr-only",
|
|
13
13
|
role: "status",
|
|
@@ -38,6 +38,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
38
38
|
}),
|
|
39
39
|
emits: ["update:value"],
|
|
40
40
|
setup(__props, { expose: __expose }) {
|
|
41
|
+
const attrs = useAttrs();
|
|
41
42
|
const value = useModel(__props, "value");
|
|
42
43
|
const field = useField();
|
|
43
44
|
const uid = useFancyId();
|
|
@@ -176,34 +177,40 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
176
177
|
__props.class
|
|
177
178
|
)
|
|
178
179
|
);
|
|
180
|
+
function inputAttrs() {
|
|
181
|
+
const describedBy = [field?.describedBy, attrs["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
182
|
+
return {
|
|
183
|
+
...attrs,
|
|
184
|
+
type: "text",
|
|
185
|
+
role: "combobox",
|
|
186
|
+
"aria-invalid": effectiveInvalid.value ? "true" : attrs["aria-invalid"],
|
|
187
|
+
"aria-describedby": describedBy,
|
|
188
|
+
"aria-label": field?.labelId ? void 0 : __props.label ?? attrs["aria-label"],
|
|
189
|
+
"aria-expanded": open.value,
|
|
190
|
+
"aria-haspopup": "listbox",
|
|
191
|
+
"aria-autocomplete": "list",
|
|
192
|
+
"aria-controls": open.value ? panelId : void 0,
|
|
193
|
+
"aria-activedescendant": open.value && listbox.activeIndex >= 0 ? optionId(listbox.activeIndex) : void 0
|
|
194
|
+
};
|
|
195
|
+
}
|
|
179
196
|
return (_ctx, _cache) => {
|
|
180
197
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
181
198
|
createElementVNode("div", _hoisted_1, [
|
|
182
|
-
createElementVNode("input", {
|
|
199
|
+
createElementVNode("input", mergeProps({
|
|
183
200
|
ref_key: "el",
|
|
184
201
|
ref: el,
|
|
185
|
-
type: "text",
|
|
186
|
-
role: "combobox",
|
|
187
202
|
id: effectiveId.value,
|
|
188
203
|
name: __props.name,
|
|
189
204
|
placeholder: __props.placeholder,
|
|
190
205
|
value: value.value,
|
|
191
206
|
disabled: effectiveDisabled.value,
|
|
192
207
|
required: effectiveRequired.value,
|
|
193
|
-
|
|
194
|
-
"aria-describedby": unref(field)?.describedBy,
|
|
195
|
-
"aria-label": unref(field)?.labelId ? void 0 : __props.label,
|
|
196
|
-
"aria-expanded": open.value,
|
|
197
|
-
"aria-haspopup": "listbox",
|
|
198
|
-
"aria-autocomplete": "list",
|
|
199
|
-
"aria-controls": open.value ? panelId : void 0,
|
|
200
|
-
"aria-activedescendant": open.value && unref(listbox).activeIndex >= 0 ? optionId(unref(listbox).activeIndex) : void 0,
|
|
201
|
-
class: normalizeClass(classes.value),
|
|
208
|
+
class: classes.value,
|
|
202
209
|
onInput: handleInput,
|
|
203
210
|
onFocus: handleFocus,
|
|
204
211
|
onBlur: handleBlur,
|
|
205
212
|
onKeydown: handleKeydown
|
|
206
|
-
}, null,
|
|
213
|
+
}, inputAttrs()), null, 16, _hoisted_2),
|
|
207
214
|
createElementVNode("div", _hoisted_3, toDisplayString(open.value ? resultsMessage.value : ""), 1)
|
|
208
215
|
]),
|
|
209
216
|
createVNode(_sfc_main$1)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "vue";
|
|
2
|
+
export type AvatarSize = "sm" | "md" | "lg";
|
|
3
|
+
export type AvatarShape = "circle" | "square";
|
|
4
|
+
export interface AvatarProps {
|
|
5
|
+
/** Image URL. While it loads a skeleton shows; if it fails the initials show. */
|
|
6
|
+
src?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The accessible name, and the one required decision whenever `src` is set:
|
|
9
|
+
* describe the image, or pass `""` to mark the avatar decorative (beside
|
|
10
|
+
* a visible name that already says who it is). Falls back to `name`.
|
|
11
|
+
*/
|
|
12
|
+
alt?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Who this is. Gives one or two initials for the fallback and a colour that
|
|
15
|
+
* is always the same for the same name.
|
|
16
|
+
*/
|
|
17
|
+
name?: string;
|
|
18
|
+
/** Diameter: 28, 36 or 64px. */
|
|
19
|
+
size?: AvatarSize;
|
|
20
|
+
/** Fully round, or a rounded square. */
|
|
21
|
+
shape?: AvatarShape;
|
|
22
|
+
/** Additional CSS classes. */
|
|
23
|
+
class?: HTMLAttributes["class"];
|
|
24
|
+
}
|
|
25
|
+
declare const _default: typeof __VLS_export;
|
|
26
|
+
export default _default;
|
|
27
|
+
declare const __VLS_export: import("vue").DefineComponent<AvatarProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AvatarProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { defineComponent, useAttrs, ref, useTemplateRef, computed, onMounted, watch, createElementBlock, openBlock, mergeProps, unref, createCommentVNode, normalizeClass, Fragment, toDisplayString, createElementVNode } from "vue";
|
|
2
|
+
import { cn } from "../../utils.js";
|
|
3
|
+
import { resolveAvatarStatus, accessibleName, initialsOf, avatarToneClass } from "./avatar-core.js";
|
|
4
|
+
const _hoisted_1 = ["role", "aria-label", "aria-hidden", "data-size", "data-shape", "data-status"];
|
|
5
|
+
const _hoisted_2 = ["src"];
|
|
6
|
+
const _hoisted_3 = {
|
|
7
|
+
key: 1,
|
|
8
|
+
"data-slot": "skeleton",
|
|
9
|
+
"aria-hidden": "true",
|
|
10
|
+
class: "bg-foreground/10 absolute inset-0 motion-safe:animate-pulse"
|
|
11
|
+
};
|
|
12
|
+
const _hoisted_4 = {
|
|
13
|
+
key: 0,
|
|
14
|
+
"data-slot": "initials",
|
|
15
|
+
"aria-hidden": "true"
|
|
16
|
+
};
|
|
17
|
+
const _hoisted_5 = {
|
|
18
|
+
key: 1,
|
|
19
|
+
"data-slot": "silhouette",
|
|
20
|
+
"aria-hidden": "true",
|
|
21
|
+
viewBox: "0 0 24 24",
|
|
22
|
+
fill: "currentColor",
|
|
23
|
+
class: "size-[60%]"
|
|
24
|
+
};
|
|
25
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
26
|
+
...{ name: "Avatar", inheritAttrs: false },
|
|
27
|
+
__name: "Avatar",
|
|
28
|
+
props: {
|
|
29
|
+
src: {},
|
|
30
|
+
alt: {},
|
|
31
|
+
name: {},
|
|
32
|
+
size: { default: "md" },
|
|
33
|
+
shape: { default: "circle" },
|
|
34
|
+
class: { type: [Boolean, null, String, Object, Array] }
|
|
35
|
+
},
|
|
36
|
+
setup(__props) {
|
|
37
|
+
const attrs = useAttrs();
|
|
38
|
+
const SIZE_CLASSES = {
|
|
39
|
+
sm: "size-7 text-[0.65rem]",
|
|
40
|
+
md: "size-9 text-xs",
|
|
41
|
+
lg: "size-16 text-lg"
|
|
42
|
+
};
|
|
43
|
+
const SHAPE_CLASSES = {
|
|
44
|
+
circle: "rounded-full",
|
|
45
|
+
square: "rounded-lg"
|
|
46
|
+
};
|
|
47
|
+
const loadedSrc = ref(null);
|
|
48
|
+
const failedSrc = ref(null);
|
|
49
|
+
const img = useTemplateRef("img");
|
|
50
|
+
const status = computed(() => resolveAvatarStatus(__props.src, loadedSrc.value, failedSrc.value));
|
|
51
|
+
const label = computed(() => accessibleName(__props.alt, __props.name));
|
|
52
|
+
const initials = computed(() => initialsOf(__props.name));
|
|
53
|
+
function settle() {
|
|
54
|
+
const el = img.value;
|
|
55
|
+
if (!el || !__props.src || !el.complete) return;
|
|
56
|
+
if (el.naturalWidth > 0) loadedSrc.value = __props.src;
|
|
57
|
+
else failedSrc.value = __props.src;
|
|
58
|
+
}
|
|
59
|
+
onMounted(settle);
|
|
60
|
+
watch(() => __props.src, settle, { flush: "post" });
|
|
61
|
+
const classes = computed(
|
|
62
|
+
() => cn(
|
|
63
|
+
"relative inline-flex shrink-0 items-center justify-center overflow-hidden font-semibold select-none",
|
|
64
|
+
SIZE_CLASSES[__props.size],
|
|
65
|
+
SHAPE_CLASSES[__props.shape],
|
|
66
|
+
status.value === "fallback" ? avatarToneClass(__props.name) : "bg-muted text-muted-foreground",
|
|
67
|
+
__props.class
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
function onLoad() {
|
|
71
|
+
loadedSrc.value = __props.src ?? null;
|
|
72
|
+
}
|
|
73
|
+
function onError() {
|
|
74
|
+
failedSrc.value = __props.src ?? null;
|
|
75
|
+
}
|
|
76
|
+
return (_ctx, _cache) => {
|
|
77
|
+
return openBlock(), createElementBlock("span", mergeProps(unref(attrs), {
|
|
78
|
+
class: classes.value,
|
|
79
|
+
role: label.value ? "img" : unref(attrs).role,
|
|
80
|
+
"aria-label": label.value ?? unref(attrs)["aria-label"],
|
|
81
|
+
"aria-hidden": label.value ? void 0 : "true",
|
|
82
|
+
"data-size": __props.size,
|
|
83
|
+
"data-shape": __props.shape,
|
|
84
|
+
"data-status": status.value
|
|
85
|
+
}), [
|
|
86
|
+
__props.src && status.value !== "fallback" ? (openBlock(), createElementBlock("img", {
|
|
87
|
+
key: 0,
|
|
88
|
+
ref_key: "img",
|
|
89
|
+
ref: img,
|
|
90
|
+
src: __props.src,
|
|
91
|
+
alt: "",
|
|
92
|
+
decoding: "async",
|
|
93
|
+
draggable: "false",
|
|
94
|
+
class: normalizeClass(
|
|
95
|
+
unref(cn)(
|
|
96
|
+
"absolute inset-0 size-full object-cover motion-safe:transition-opacity motion-safe:duration-200",
|
|
97
|
+
status.value === "loaded" ? "opacity-100" : "opacity-0"
|
|
98
|
+
)
|
|
99
|
+
),
|
|
100
|
+
onLoad,
|
|
101
|
+
onError
|
|
102
|
+
}, null, 42, _hoisted_2)) : createCommentVNode("", true),
|
|
103
|
+
status.value === "loading" ? (openBlock(), createElementBlock("span", _hoisted_3)) : status.value === "fallback" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
104
|
+
initials.value ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(initials.value), 1)) : (openBlock(), createElementBlock("svg", _hoisted_5, [..._cache[0] || (_cache[0] = [
|
|
105
|
+
createElementVNode("circle", {
|
|
106
|
+
cx: "12",
|
|
107
|
+
cy: "8.5",
|
|
108
|
+
r: "4"
|
|
109
|
+
}, null, -1),
|
|
110
|
+
createElementVNode("path", { d: "M4 21c0-4.2 3.6-7 8-7s8 2.8 8 7z" }, null, -1)
|
|
111
|
+
])]))
|
|
112
|
+
], 64)) : createCommentVNode("", true)
|
|
113
|
+
], 16, _hoisted_1);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
export {
|
|
118
|
+
_sfc_main as default
|
|
119
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure rules behind Avatar, shared byte for byte by the Svelte, React and Vue
|
|
3
|
+
* packages so the same name gives the same initials and the same colour in all
|
|
4
|
+
* three, on the server and in the browser.
|
|
5
|
+
*
|
|
6
|
+
* Nothing here touches the DOM, a timer or a random source.
|
|
7
|
+
*/
|
|
8
|
+
export type AvatarStatus = "loading" | "loaded" | "fallback";
|
|
9
|
+
/**
|
|
10
|
+
* Soft tinted pairs for the initials fallback. Each entry is a complete static
|
|
11
|
+
* class string on purpose: Tailwind finds a class by scanning the shipped
|
|
12
|
+
* source, so a name built from a variable (`bg-${hue}-500/15`) would never be
|
|
13
|
+
* generated.
|
|
14
|
+
*/
|
|
15
|
+
export declare const AVATAR_TONES: readonly string[];
|
|
16
|
+
/** Used when there is nothing to take initials from. */
|
|
17
|
+
export declare const AVATAR_NEUTRAL_TONE = "bg-muted text-muted-foreground";
|
|
18
|
+
/**
|
|
19
|
+
* One or two letters for a name: the first letter of the first word and of the
|
|
20
|
+
* last word, upper-cased, or a single letter for a one-word name. Leading
|
|
21
|
+
* punctuation is skipped, and a name with no letter or digit gives "".
|
|
22
|
+
*/
|
|
23
|
+
export declare function initialsOf(name: string | null | undefined): string;
|
|
24
|
+
/** A stable index in `[0, count)` for a name (a small multiplicative hash). */
|
|
25
|
+
export declare function toneIndexOf(name: string, count?: number): number;
|
|
26
|
+
/** The class pair for a name's fallback: a palette entry, or the neutral one. */
|
|
27
|
+
export declare function avatarToneClass(name: string | null | undefined): string;
|
|
28
|
+
/**
|
|
29
|
+
* Where an image is, given the last `src` that loaded and the last that
|
|
30
|
+
* failed. Keeping the two sources instead of a flag means a new `src` is
|
|
31
|
+
* "loading" again with no reset step, and a server render agrees with the
|
|
32
|
+
* first client render.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveAvatarStatus(src: string | null | undefined, loadedSrc: string | null, failedSrc: string | null): AvatarStatus;
|
|
35
|
+
/**
|
|
36
|
+
* The accessible name, or undefined when the avatar is decorative: `alt` wins
|
|
37
|
+
* (so `alt=""` is the explicit opt-out), then `name`; blank text counts as no
|
|
38
|
+
* text.
|
|
39
|
+
*/
|
|
40
|
+
export declare function accessibleName(alt: string | null | undefined, name: string | null | undefined): string | undefined;
|