@dialpad/dialtone 9.146.0 → 9.147.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.
Files changed (75) hide show
  1. package/README.md +17 -10
  2. package/dist/css/dialtone-default-theme.css +275 -32
  3. package/dist/css/dialtone-default-theme.min.css +1 -1
  4. package/dist/css/dialtone-docs.json +1 -1
  5. package/dist/css/dialtone.css +275 -32
  6. package/dist/css/dialtone.min.css +1 -1
  7. package/dist/css/tokens-docs.json +1 -1
  8. package/dist/tokens/doc.json +73664 -73664
  9. package/dist/vue2/component-documentation.json +1 -1
  10. package/dist/vue2/dialtone-vue.cjs +1 -1
  11. package/dist/vue2/dialtone-vue.js +29 -23
  12. package/dist/vue2/dialtone-vue.js.map +1 -1
  13. package/dist/vue2/lib/hovercard/hovercard.cjs +1 -1
  14. package/dist/vue2/lib/hovercard/hovercard.cjs.map +1 -1
  15. package/dist/vue2/lib/hovercard/hovercard.js +29 -21
  16. package/dist/vue2/lib/hovercard/hovercard.js.map +1 -1
  17. package/dist/vue2/lib/motion-text/index.cjs +2 -0
  18. package/dist/vue2/lib/motion-text/index.cjs.map +1 -0
  19. package/dist/vue2/lib/motion-text/index.js +9 -0
  20. package/dist/vue2/lib/motion-text/index.js.map +1 -0
  21. package/dist/vue2/lib/motion-text/motion-text-constants.cjs +2 -0
  22. package/dist/vue2/lib/motion-text/motion-text-constants.cjs.map +1 -0
  23. package/dist/vue2/lib/motion-text/motion-text-constants.js +35 -0
  24. package/dist/vue2/lib/motion-text/motion-text-constants.js.map +1 -0
  25. package/dist/vue2/lib/motion-text/motion-text.cjs +2 -0
  26. package/dist/vue2/lib/motion-text/motion-text.cjs.map +1 -0
  27. package/dist/vue2/lib/motion-text/motion-text.js +342 -0
  28. package/dist/vue2/lib/motion-text/motion-text.js.map +1 -0
  29. package/dist/vue2/lib/popover/popover.cjs +1 -1
  30. package/dist/vue2/lib/popover/popover.cjs.map +1 -1
  31. package/dist/vue2/lib/popover/popover.js +14 -12
  32. package/dist/vue2/lib/popover/popover.js.map +1 -1
  33. package/dist/vue2/types/components/hovercard/hovercard.vue.d.ts.map +1 -1
  34. package/dist/vue2/types/components/popover/popover.vue.d.ts.map +1 -1
  35. package/dist/vue2/types/index.d.ts +1 -0
  36. package/dist/vue2/types/recipes/motion/motion_text/index.d.ts +3 -0
  37. package/dist/vue2/types/recipes/motion/motion_text/index.d.ts.map +1 -0
  38. package/dist/vue2/types/recipes/motion/motion_text/motion_text.vue.d.ts +3 -0
  39. package/dist/vue2/types/recipes/motion/motion_text/motion_text.vue.d.ts.map +1 -0
  40. package/dist/vue2/types/recipes/motion/motion_text/motion_text_constants.d.ts +32 -0
  41. package/dist/vue2/types/recipes/motion/motion_text/motion_text_constants.d.ts.map +1 -0
  42. package/dist/vue3/component-documentation.json +1 -1
  43. package/dist/vue3/dialtone-vue.cjs +1 -1
  44. package/dist/vue3/dialtone-vue.js +10 -4
  45. package/dist/vue3/dialtone-vue.js.map +1 -1
  46. package/dist/vue3/lib/hovercard/hovercard.cjs +1 -1
  47. package/dist/vue3/lib/hovercard/hovercard.cjs.map +1 -1
  48. package/dist/vue3/lib/hovercard/hovercard.js +57 -46
  49. package/dist/vue3/lib/hovercard/hovercard.js.map +1 -1
  50. package/dist/vue3/lib/motion-text/index.cjs +2 -0
  51. package/dist/vue3/lib/motion-text/index.cjs.map +1 -0
  52. package/dist/vue3/lib/motion-text/index.js +9 -0
  53. package/dist/vue3/lib/motion-text/index.js.map +1 -0
  54. package/dist/vue3/lib/motion-text/motion-text-constants.cjs +2 -0
  55. package/dist/vue3/lib/motion-text/motion-text-constants.cjs.map +1 -0
  56. package/dist/vue3/lib/motion-text/motion-text-constants.js +35 -0
  57. package/dist/vue3/lib/motion-text/motion-text-constants.js.map +1 -0
  58. package/dist/vue3/lib/motion-text/motion-text.cjs +2 -0
  59. package/dist/vue3/lib/motion-text/motion-text.cjs.map +1 -0
  60. package/dist/vue3/lib/motion-text/motion-text.js +389 -0
  61. package/dist/vue3/lib/motion-text/motion-text.js.map +1 -0
  62. package/dist/vue3/lib/popover/popover.cjs +1 -1
  63. package/dist/vue3/lib/popover/popover.cjs.map +1 -1
  64. package/dist/vue3/lib/popover/popover.js +22 -20
  65. package/dist/vue3/lib/popover/popover.js.map +1 -1
  66. package/dist/vue3/types/components/hovercard/hovercard.vue.d.ts.map +1 -1
  67. package/dist/vue3/types/components/popover/popover.vue.d.ts.map +1 -1
  68. package/dist/vue3/types/index.d.ts +1 -0
  69. package/dist/vue3/types/recipes/motion/motion_text/index.d.ts +3 -0
  70. package/dist/vue3/types/recipes/motion/motion_text/index.d.ts.map +1 -0
  71. package/dist/vue3/types/recipes/motion/motion_text/motion_text.vue.d.ts +3 -0
  72. package/dist/vue3/types/recipes/motion/motion_text/motion_text.vue.d.ts.map +1 -0
  73. package/dist/vue3/types/recipes/motion/motion_text/motion_text_constants.d.ts +32 -0
  74. package/dist/vue3/types/recipes/motion/motion_text/motion_text_constants.d.ts.map +1 -0
  75. package/package.json +4 -4
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("./motion-text-constants.cjs"),l=require("../../_plugin-vue2_normalizer-e_CkxkSV.cjs"),m={compatConfig:{MODE:3},name:"DtRecipeMotionText",inheritAttrs:!1,props:{text:{type:String,default:""},animationMode:{type:String,default:"gradient-in",validator:e=>h.MOTION_TEXT_ANIMATION_MODES.includes(e)},speed:{type:String,default:"md",validator:e=>h.MOTION_TEXT_SPEEDS.includes(e)},autoStart:{type:Boolean,default:!0},loop:{type:Boolean,default:!1},respectsReducedMotion:{type:Boolean,default:!0},screenReaderText:{type:String,default:""}},emits:["start","complete","progress","pause","resume"],data(){return{words:[],visibleWordCount:0,visibleCharsPerWord:[],isAnimating:!1,isPaused:!1,isLooped:!1,animationTimeouts:[],prefersReducedMotion:!1,animationKey:0}},computed:{timing(){return h.MOTION_TEXT_TIMING_PRESETS[this.speed]},componentStyles(){return{"--dt-recipe-motion-text-duration":`${this.timing.duration}ms`,"--dt-recipe-motion-text-char-duration":`${this.timing.duration}ms`,"--dt-recipe-motion-text-word-duration":`${this.timing.duration*2}ms`}},isStaticAnimationMode(){return this.animationMode==="gradient-sweep"||this.animationMode==="shimmer"},motionTextClasses(){return["dt-recipe-motion-text",`dt-recipe-motion-text--${this.animationMode}`,{"dt-recipe-motion-text--animating":this.isAnimating,"dt-recipe-motion-text--paused":this.isPaused,"dt-recipe-motion-text--looped":this.isLooped},this.$attrs.class]}},watch:{text(){this.reset(),this.initializeContent()},loop:{handler(e){this.isLooped=e},immediate:!0}},mounted(){this.checkReducedMotion(),this.initializeContent()},beforeUnmount(){this.clearTimeouts()},methods:{processTextToChars(e){const t=[],i=(s,n=0)=>{var r;if(s.nodeType===Node.TEXT_NODE){const o=((r=s.textContent)==null?void 0:r.match(/\S+\s*/g))||[];return t.push(...o.map((a,d)=>({text:a,chars:a.split(""),index:n+d}))),n+o.length}else if(s.nodeType===Node.ELEMENT_NODE){let o=n;return Array.from(s.childNodes).forEach(a=>{o=i(a,o)}),o}return n};return i(e),t},processDirectText(e){return e?(e.match(/\S+\s*/g)||[]).map((i,s)=>({text:i,chars:i.split(""),index:s})):[]},checkReducedMotion(){typeof window<"u"&&window.matchMedia&&(this.prefersReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches)},clearTimeouts(){this.animationTimeouts.forEach(e=>clearTimeout(e)),this.animationTimeouts=[]},start(){if(!this.isAnimating){if(this.isAnimating=!0,this.isPaused=!1,this.$emit("start"),this.respectsReducedMotion&&this.prefersReducedMotion){this.showAllContent();return}if(this.animationMode==="none"){this.showAllContent();return}this.isStaticAnimationMode||this.showNextWord()}},pause(){!this.isAnimating||this.isPaused||(this.isPaused=!0,this.clearTimeouts(),this.$emit("pause"))},resume(){this.isPaused&&(this.isPaused=!1,this.$emit("resume"),this.showNextWord())},reset(){this.clearTimeouts(),this.isAnimating=!1,this.isPaused=!1,this.visibleWordCount=0,this.visibleCharsPerWord=Array(this.words.length).fill(0),this.animationKey++},skipToEnd(){this.showAllContent()},showAllContent(){this.visibleWordCount=this.words.length,this.visibleCharsPerWord=this.words.map(e=>e.chars.length),setTimeout(()=>{this.isAnimating=!1,this.$emit("complete")},0)},showNextWord(){if(this.isPaused||this.visibleWordCount>=this.words.length){this.visibleWordCount>=this.words.length&&this.completeAnimation();return}const e=setTimeout(()=>{this.visibleWordCount++,this.$emit("progress",{wordsComplete:this.visibleWordCount,totalWords:this.words.length,progress:this.visibleWordCount/this.words.length}),this.animateCharsForWord(this.visibleWordCount-1)},this.timing.wordDelay);this.animationTimeouts.push(e)},animateCharsForWord(e){if(this.isPaused||e>=this.words.length)return;this.visibleCharsPerWord[e]=0;const t=this.words[e].chars.length,i=()=>{if(this.isPaused||this.visibleCharsPerWord[e]>=t){this.visibleCharsPerWord[e]>=t&&this.showNextWord();return}this.visibleCharsPerWord[e]++;const s=setTimeout(i,this.timing.characterDelay);this.animationTimeouts.push(s)};i()},completeAnimation(){if(this.isAnimating=!1,this.clearTimeouts(),this.$emit("complete"),this.loop){const e=setTimeout(()=>{this.reset(),this.$nextTick(()=>{this.start()})},500);this.animationTimeouts.push(e)}},initializeContent(){if(this.isStaticAnimationMode){this.autoStart&&this.$nextTick(()=>this.start());return}this.text?this.words=this.processDirectText(this.text):this.$refs.contentRef&&(this.words=this.processTextToChars(this.$refs.contentRef)),this.visibleCharsPerWord=Array(this.words.length).fill(0),this.visibleWordCount=0,this.autoStart&&this.words.length>0&&this.$nextTick(()=>this.start())}}};var c=function(){var t=this,i=t._self._c;return i("span",{ref:"contentRef",class:t.motionTextClasses,style:t.componentStyles,attrs:{"data-text-content":t.isStaticAnimationMode?t.text:void 0,"aria-live":t.isAnimating?"polite":"off","aria-label":t.screenReaderText||void 0}},[t.screenReaderText?i("span",{staticClass:"dt-recipe-motion-text__sr-only"},[t._v(" "+t._s(t.screenReaderText)+" ")]):t._e(),t.isStaticAnimationMode?[t._v(" "+t._s(t.text)+" "),t.text?t._e():t._t("default")]:i("span",{key:t.animationKey,staticClass:"dt-recipe-motion-text__content",attrs:{"aria-hidden":t.isAnimating}},[t._l(t.words,function(s,n){return[i("Transition",{key:`${t.animationKey}-${n}`,attrs:{name:`dt-recipe-motion-text-word-${t.animationMode}`}},[n<t.visibleWordCount?i("span",{staticClass:"dt-recipe-motion-text__word",style:{"--word-index":n},attrs:{"data-text-content":s.text}},[t._l(s.chars,function(r,o){return[i("Transition",{key:`${t.animationKey}-${n}-${o}`,attrs:{name:`dt-recipe-motion-text-char-${t.animationMode}`}},[o<t.visibleCharsPerWord[n]?i("span",{staticClass:"dt-recipe-motion-text__char",style:{"--char-index":o,"--char-delay":`${o*t.timing.characterDelay}ms`}},[t._v(t._s(r))]):t._e()])]})],2):t._e()])]})],2),!t.words.length&&!t.text&&!t.isStaticAnimationMode?i("span",{staticClass:"dt-recipe-motion-text__fallback"},[t._t("default")],2):t._e()],2)},u=[],p=l.n(m,c,u);const f=p.exports;exports.default=f;
2
+ //# sourceMappingURL=motion-text.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion-text.cjs","sources":["../../../recipes/motion/motion_text/motion_text.vue"],"sourcesContent":["<template>\n <span\n ref=\"contentRef\"\n :class=\"motionTextClasses\"\n :style=\"componentStyles\"\n :data-text-content=\"isStaticAnimationMode ? text : undefined\"\n :aria-live=\"isAnimating ? 'polite' : 'off'\"\n :aria-label=\"screenReaderText || undefined\"\n >\n <!-- Screen reader content -->\n <span\n v-if=\"screenReaderText\"\n class=\"dt-recipe-motion-text__sr-only\"\n >\n {{ screenReaderText }}\n </span>\n\n <!-- Gradient-sweep and shimmer modes: Simple static text with gradient animation -->\n <template v-if=\"isStaticAnimationMode\">\n {{ text }}\n <slot v-if=\"!text\" />\n </template>\n\n <!-- Character-by-character animated content for other modes -->\n <span\n v-else\n :key=\"animationKey\"\n class=\"dt-recipe-motion-text__content\"\n :aria-hidden=\"isAnimating\"\n >\n <template\n v-for=\"(word, wordIdx) in words\"\n >\n <Transition\n :key=\"`${animationKey}-${wordIdx}`\"\n :name=\"`dt-recipe-motion-text-word-${animationMode}`\"\n >\n <span\n v-if=\"wordIdx < visibleWordCount\"\n class=\"dt-recipe-motion-text__word\"\n :data-text-content=\"word.text\"\n :style=\"{ '--word-index': wordIdx }\"\n >\n <template\n v-for=\"(char, charIdx) in word.chars\"\n >\n <Transition\n :key=\"`${animationKey}-${wordIdx}-${charIdx}`\"\n :name=\"`dt-recipe-motion-text-char-${animationMode}`\"\n >\n <span\n v-if=\"charIdx < visibleCharsPerWord[wordIdx]\"\n class=\"dt-recipe-motion-text__char\"\n :style=\"{\n '--char-index': charIdx,\n '--char-delay': `${charIdx * timing.characterDelay}ms`,\n }\"\n >{{ char }}</span>\n </Transition>\n </template>\n </span>\n </Transition>\n </template>\n </span>\n\n <!-- Fallback slot content -->\n <span\n v-if=\"!words.length && !text && !isStaticAnimationMode\"\n class=\"dt-recipe-motion-text__fallback\"\n >\n <slot />\n </span>\n </span>\n</template>\n\n<script>\nimport { MOTION_TEXT_ANIMATION_MODES, MOTION_TEXT_SPEEDS, MOTION_TEXT_TIMING_PRESETS } from './motion_text_constants';\n\nexport default {\n compatConfig: { MODE: 3 },\n name: 'DtRecipeMotionText',\n\n inheritAttrs: false,\n\n props: {\n /**\n * The text content to animate.\n * @type {string}\n */\n text: {\n type: String,\n default: '',\n },\n\n /**\n * The animation mode to use for the text reveal.\n * @values gradient-in, fade-in, slide-in, gradient-sweep, shimmer, none\n */\n animationMode: {\n type: String,\n default: 'gradient-in',\n validator: (value) => MOTION_TEXT_ANIMATION_MODES.includes(value),\n },\n\n /**\n * Animation speed using t-shirt sizing.\n * @values sm, md, lg\n */\n speed: {\n type: String,\n default: 'md',\n validator: (value) => MOTION_TEXT_SPEEDS.includes(value),\n },\n\n /**\n * Whether to start animation automatically when component is mounted.\n * @values true, false\n */\n autoStart: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether to loop the animation continuously.\n * @values true, false\n */\n loop: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Whether to respect the user's prefers-reduced-motion system setting.\n * @values true, false\n */\n respectsReducedMotion: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Alternative text for screen readers. If provided, this will be announced\n * instead of the animated text.\n * @type {string}\n */\n screenReaderText: {\n type: String,\n default: '',\n },\n },\n\n emits: [\n /**\n * Emitted when the animation starts.\n * @event start\n */\n 'start',\n\n /**\n * Emitted when the animation completes.\n * @event complete\n */\n 'complete',\n\n /**\n * Emitted during animation progress.\n * @event progress\n * @type {{ wordsComplete: number, totalWords: number, progress: number }}\n */\n 'progress',\n\n /**\n * Emitted when the animation is paused.\n * @event pause\n */\n 'pause',\n\n /**\n * Emitted when the animation resumes.\n * @event resume\n */\n 'resume',\n ],\n\n data () {\n return {\n words: [],\n visibleWordCount: 0,\n visibleCharsPerWord: [],\n isAnimating: false,\n isPaused: false,\n isLooped: false,\n animationTimeouts: [],\n prefersReducedMotion: false,\n animationKey: 0,\n };\n },\n\n computed: {\n /**\n * Get timing preset based on speed prop\n */\n timing () {\n return MOTION_TEXT_TIMING_PRESETS[this.speed];\n },\n\n /**\n * Computed styles with timing CSS variables\n */\n componentStyles () {\n return {\n '--dt-recipe-motion-text-duration': `${this.timing.duration}ms`,\n '--dt-recipe-motion-text-char-duration': `${this.timing.duration}ms`,\n '--dt-recipe-motion-text-word-duration': `${this.timing.duration * 2}ms`,\n };\n },\n\n /**\n * Check if current animation mode is static (gradient-sweep or shimmer)\n */\n isStaticAnimationMode () {\n return this.animationMode === 'gradient-sweep' || this.animationMode === 'shimmer';\n },\n\n /**\n * Computed classes for the motion text element\n */\n motionTextClasses () {\n return [\n 'dt-recipe-motion-text',\n `dt-recipe-motion-text--${this.animationMode}`,\n {\n 'dt-recipe-motion-text--animating': this.isAnimating,\n 'dt-recipe-motion-text--paused': this.isPaused,\n 'dt-recipe-motion-text--looped': this.isLooped,\n },\n this.$attrs.class,\n ];\n },\n },\n\n watch: {\n text () {\n this.reset();\n this.initializeContent();\n },\n\n loop: {\n handler (newVal) {\n this.isLooped = newVal;\n },\n\n immediate: true,\n },\n },\n\n mounted () {\n this.checkReducedMotion();\n this.initializeContent();\n },\n\n beforeUnmount () {\n this.clearTimeouts();\n },\n\n methods: {\n /**\n * Self-contained text processing from DOM nodes\n */\n processTextToChars (node) {\n const words = [];\n\n const processNode = (node, index = 0) => {\n if (node.nodeType === Node.TEXT_NODE) {\n const matches = node.textContent?.match(/\\S+\\s*/g) || [];\n words.push(...matches.map((text, i) => ({\n text,\n chars: text.split(''),\n index: index + i,\n })));\n return index + matches.length;\n } else if (node.nodeType === Node.ELEMENT_NODE) {\n let currentIdx = index;\n Array.from(node.childNodes).forEach(child => {\n currentIdx = processNode(child, currentIdx);\n });\n return currentIdx;\n }\n return index;\n };\n\n processNode(node);\n return words;\n },\n\n /**\n * Process direct text prop into word/character data\n */\n processDirectText (text) {\n if (!text) return [];\n\n const matches = text.match(/\\S+\\s*/g) || [];\n return matches.map((wordText, i) => ({\n text: wordText,\n chars: wordText.split(''),\n index: i,\n }));\n },\n\n /**\n * Check for reduced motion preference\n */\n checkReducedMotion () {\n if (typeof window !== 'undefined' && window.matchMedia) {\n this.prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n }\n },\n\n /**\n * Clear all animation timeouts\n */\n clearTimeouts () {\n this.animationTimeouts.forEach(timeout => clearTimeout(timeout));\n this.animationTimeouts = [];\n },\n\n /**\n * Start the animation\n * @public\n */\n start () {\n if (this.isAnimating) return;\n\n this.isAnimating = true;\n this.isPaused = false;\n this.$emit('start');\n\n // Skip animation if reduced motion is preferred and enabled\n if (this.respectsReducedMotion && this.prefersReducedMotion) {\n this.showAllContent();\n return;\n }\n\n if (this.animationMode === 'none') {\n this.showAllContent();\n return;\n }\n\n // For gradient-sweep and shimmer modes, just mark as animating (CSS handles the animation)\n if (this.isStaticAnimationMode) {\n return;\n }\n\n // Start the word-by-word animation for \"-in\" modes\n this.showNextWord();\n },\n\n /**\n * Pause the animation\n * @public\n */\n pause () {\n if (!this.isAnimating || this.isPaused) return;\n\n this.isPaused = true;\n this.clearTimeouts();\n this.$emit('pause');\n },\n\n /**\n * Resume the animation\n * @public\n */\n resume () {\n if (!this.isPaused) return;\n\n this.isPaused = false;\n this.$emit('resume');\n this.showNextWord();\n },\n\n /**\n * Reset the animation to initial state\n * @public\n */\n reset () {\n this.clearTimeouts();\n this.isAnimating = false;\n this.isPaused = false;\n this.visibleWordCount = 0;\n this.visibleCharsPerWord = Array(this.words.length).fill(0);\n this.animationKey++;\n },\n\n /**\n * Skip to the end of the animation\n * @public\n */\n skipToEnd () {\n this.showAllContent();\n },\n\n /**\n * Show all content immediately\n */\n showAllContent () {\n this.visibleWordCount = this.words.length;\n this.visibleCharsPerWord = this.words.map(word => word.chars.length);\n setTimeout(() => {\n this.isAnimating = false;\n this.$emit('complete');\n }, 0);\n },\n\n /**\n * Show next word in sequence\n */\n showNextWord () {\n if (this.isPaused || this.visibleWordCount >= this.words.length) {\n if (this.visibleWordCount >= this.words.length) {\n this.completeAnimation();\n }\n return;\n }\n\n const timeout = setTimeout(() => {\n this.visibleWordCount++;\n this.$emit('progress', {\n wordsComplete: this.visibleWordCount,\n totalWords: this.words.length,\n progress: this.visibleWordCount / this.words.length,\n });\n\n this.animateCharsForWord(this.visibleWordCount - 1);\n }, this.timing.wordDelay);\n\n this.animationTimeouts.push(timeout);\n },\n\n /**\n * Animate characters for a specific word\n */\n animateCharsForWord (wordIdx) {\n if (this.isPaused || wordIdx >= this.words.length) return;\n\n this.visibleCharsPerWord[wordIdx] = 0;\n const chars = this.words[wordIdx].chars.length;\n\n const revealChar = () => {\n if (this.isPaused || this.visibleCharsPerWord[wordIdx] >= chars) {\n if (this.visibleCharsPerWord[wordIdx] >= chars) {\n this.showNextWord();\n }\n return;\n }\n\n this.visibleCharsPerWord[wordIdx]++;\n const timeout = setTimeout(revealChar, this.timing.characterDelay);\n this.animationTimeouts.push(timeout);\n };\n\n revealChar();\n },\n\n /**\n * Complete the animation\n */\n completeAnimation () {\n this.isAnimating = false;\n this.clearTimeouts();\n\n this.$emit('complete');\n\n if (this.loop) {\n const timeout = setTimeout(() => {\n this.reset();\n this.$nextTick(() => {\n this.start();\n });\n }, 500);\n\n this.animationTimeouts.push(timeout);\n }\n },\n\n /**\n * Initialize content based on text prop or slot content\n */\n initializeContent () {\n // For gradient-sweep and shimmer modes, skip word/character processing\n if (this.isStaticAnimationMode) {\n if (this.autoStart) {\n this.$nextTick(() => this.start());\n }\n return;\n }\n\n if (this.text) {\n this.words = this.processDirectText(this.text);\n } else if (this.$refs.contentRef) {\n this.words = this.processTextToChars(this.$refs.contentRef);\n }\n\n this.visibleCharsPerWord = Array(this.words.length).fill(0);\n this.visibleWordCount = 0;\n\n if (this.autoStart && this.words.length > 0) {\n this.$nextTick(() => this.start());\n }\n },\n },\n};\n</script>\n"],"names":["_sfc_main","value","MOTION_TEXT_ANIMATION_MODES","MOTION_TEXT_SPEEDS","MOTION_TEXT_TIMING_PRESETS","newVal","node","words","processNode","index","matches","_a","text","i","currentIdx","child","wordText","timeout","word","wordIdx","chars","revealChar"],"mappings":"mNA8EAA,EAAA,CACA,aAAA,CAAA,KAAA,CAAA,EACA,KAAA,qBAEA,aAAA,GAEA,MAAA,CAKA,KAAA,CACA,KAAA,OACA,QAAA,EACA,EAMA,cAAA,CACA,KAAA,OACA,QAAA,cACA,UAAAC,GAAAC,8BAAA,SAAAD,CAAA,CACA,EAMA,MAAA,CACA,KAAA,OACA,QAAA,KACA,UAAAA,GAAAE,qBAAA,SAAAF,CAAA,CACA,EAMA,UAAA,CACA,KAAA,QACA,QAAA,EACA,EAMA,KAAA,CACA,KAAA,QACA,QAAA,EACA,EAMA,sBAAA,CACA,KAAA,QACA,QAAA,EACA,EAOA,iBAAA,CACA,KAAA,OACA,QAAA,EACA,CACA,EAEA,MAAA,CAKA,QAMA,WAOA,WAMA,QAMA,QACA,EAEA,MAAA,CACA,MA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CAEA,KAAA,KACA,KAAA,MAAA,KAAA,kBAAA,KAAA,IAAA,EACA,KAAA,MAAA,aACA,KAAA,MAAA,KAAA,mBAAA,KAAA,MAAA,UAAA,GAGA,KAAA,oBAAA,MAAA,KAAA,MAAA,MAAA,EAAA,KAAA,CAAA,EACA,KAAA,iBAAA,EAEA,KAAA,WAAA,KAAA,MAAA,OAAA,GACA,KAAA,UAAA,IAAA,KAAA,MAAA,CAAA,CAEA,CACA,CACA"}
@@ -0,0 +1,342 @@
1
+ import { MOTION_TEXT_SPEEDS as d, MOTION_TEXT_ANIMATION_MODES as m, MOTION_TEXT_TIMING_PRESETS as l } from "./motion-text-constants.js";
2
+ import { n as c } from "../../_plugin-vue2_normalizer-DSLOjnn3.js";
3
+ const u = {
4
+ compatConfig: { MODE: 3 },
5
+ name: "DtRecipeMotionText",
6
+ inheritAttrs: !1,
7
+ props: {
8
+ /**
9
+ * The text content to animate.
10
+ * @type {string}
11
+ */
12
+ text: {
13
+ type: String,
14
+ default: ""
15
+ },
16
+ /**
17
+ * The animation mode to use for the text reveal.
18
+ * @values gradient-in, fade-in, slide-in, gradient-sweep, shimmer, none
19
+ */
20
+ animationMode: {
21
+ type: String,
22
+ default: "gradient-in",
23
+ validator: (e) => m.includes(e)
24
+ },
25
+ /**
26
+ * Animation speed using t-shirt sizing.
27
+ * @values sm, md, lg
28
+ */
29
+ speed: {
30
+ type: String,
31
+ default: "md",
32
+ validator: (e) => d.includes(e)
33
+ },
34
+ /**
35
+ * Whether to start animation automatically when component is mounted.
36
+ * @values true, false
37
+ */
38
+ autoStart: {
39
+ type: Boolean,
40
+ default: !0
41
+ },
42
+ /**
43
+ * Whether to loop the animation continuously.
44
+ * @values true, false
45
+ */
46
+ loop: {
47
+ type: Boolean,
48
+ default: !1
49
+ },
50
+ /**
51
+ * Whether to respect the user's prefers-reduced-motion system setting.
52
+ * @values true, false
53
+ */
54
+ respectsReducedMotion: {
55
+ type: Boolean,
56
+ default: !0
57
+ },
58
+ /**
59
+ * Alternative text for screen readers. If provided, this will be announced
60
+ * instead of the animated text.
61
+ * @type {string}
62
+ */
63
+ screenReaderText: {
64
+ type: String,
65
+ default: ""
66
+ }
67
+ },
68
+ emits: [
69
+ /**
70
+ * Emitted when the animation starts.
71
+ * @event start
72
+ */
73
+ "start",
74
+ /**
75
+ * Emitted when the animation completes.
76
+ * @event complete
77
+ */
78
+ "complete",
79
+ /**
80
+ * Emitted during animation progress.
81
+ * @event progress
82
+ * @type {{ wordsComplete: number, totalWords: number, progress: number }}
83
+ */
84
+ "progress",
85
+ /**
86
+ * Emitted when the animation is paused.
87
+ * @event pause
88
+ */
89
+ "pause",
90
+ /**
91
+ * Emitted when the animation resumes.
92
+ * @event resume
93
+ */
94
+ "resume"
95
+ ],
96
+ data() {
97
+ return {
98
+ words: [],
99
+ visibleWordCount: 0,
100
+ visibleCharsPerWord: [],
101
+ isAnimating: !1,
102
+ isPaused: !1,
103
+ isLooped: !1,
104
+ animationTimeouts: [],
105
+ prefersReducedMotion: !1,
106
+ animationKey: 0
107
+ };
108
+ },
109
+ computed: {
110
+ /**
111
+ * Get timing preset based on speed prop
112
+ */
113
+ timing() {
114
+ return l[this.speed];
115
+ },
116
+ /**
117
+ * Computed styles with timing CSS variables
118
+ */
119
+ componentStyles() {
120
+ return {
121
+ "--dt-recipe-motion-text-duration": `${this.timing.duration}ms`,
122
+ "--dt-recipe-motion-text-char-duration": `${this.timing.duration}ms`,
123
+ "--dt-recipe-motion-text-word-duration": `${this.timing.duration * 2}ms`
124
+ };
125
+ },
126
+ /**
127
+ * Check if current animation mode is static (gradient-sweep or shimmer)
128
+ */
129
+ isStaticAnimationMode() {
130
+ return this.animationMode === "gradient-sweep" || this.animationMode === "shimmer";
131
+ },
132
+ /**
133
+ * Computed classes for the motion text element
134
+ */
135
+ motionTextClasses() {
136
+ return [
137
+ "dt-recipe-motion-text",
138
+ `dt-recipe-motion-text--${this.animationMode}`,
139
+ {
140
+ "dt-recipe-motion-text--animating": this.isAnimating,
141
+ "dt-recipe-motion-text--paused": this.isPaused,
142
+ "dt-recipe-motion-text--looped": this.isLooped
143
+ },
144
+ this.$attrs.class
145
+ ];
146
+ }
147
+ },
148
+ watch: {
149
+ text() {
150
+ this.reset(), this.initializeContent();
151
+ },
152
+ loop: {
153
+ handler(e) {
154
+ this.isLooped = e;
155
+ },
156
+ immediate: !0
157
+ }
158
+ },
159
+ mounted() {
160
+ this.checkReducedMotion(), this.initializeContent();
161
+ },
162
+ beforeUnmount() {
163
+ this.clearTimeouts();
164
+ },
165
+ methods: {
166
+ /**
167
+ * Self-contained text processing from DOM nodes
168
+ */
169
+ processTextToChars(e) {
170
+ const t = [], i = (s, n = 0) => {
171
+ var r;
172
+ if (s.nodeType === Node.TEXT_NODE) {
173
+ const o = ((r = s.textContent) == null ? void 0 : r.match(/\S+\s*/g)) || [];
174
+ return t.push(...o.map((a, h) => ({
175
+ text: a,
176
+ chars: a.split(""),
177
+ index: n + h
178
+ }))), n + o.length;
179
+ } else if (s.nodeType === Node.ELEMENT_NODE) {
180
+ let o = n;
181
+ return Array.from(s.childNodes).forEach((a) => {
182
+ o = i(a, o);
183
+ }), o;
184
+ }
185
+ return n;
186
+ };
187
+ return i(e), t;
188
+ },
189
+ /**
190
+ * Process direct text prop into word/character data
191
+ */
192
+ processDirectText(e) {
193
+ return e ? (e.match(/\S+\s*/g) || []).map((i, s) => ({
194
+ text: i,
195
+ chars: i.split(""),
196
+ index: s
197
+ })) : [];
198
+ },
199
+ /**
200
+ * Check for reduced motion preference
201
+ */
202
+ checkReducedMotion() {
203
+ typeof window < "u" && window.matchMedia && (this.prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches);
204
+ },
205
+ /**
206
+ * Clear all animation timeouts
207
+ */
208
+ clearTimeouts() {
209
+ this.animationTimeouts.forEach((e) => clearTimeout(e)), this.animationTimeouts = [];
210
+ },
211
+ /**
212
+ * Start the animation
213
+ * @public
214
+ */
215
+ start() {
216
+ if (!this.isAnimating) {
217
+ if (this.isAnimating = !0, this.isPaused = !1, this.$emit("start"), this.respectsReducedMotion && this.prefersReducedMotion) {
218
+ this.showAllContent();
219
+ return;
220
+ }
221
+ if (this.animationMode === "none") {
222
+ this.showAllContent();
223
+ return;
224
+ }
225
+ this.isStaticAnimationMode || this.showNextWord();
226
+ }
227
+ },
228
+ /**
229
+ * Pause the animation
230
+ * @public
231
+ */
232
+ pause() {
233
+ !this.isAnimating || this.isPaused || (this.isPaused = !0, this.clearTimeouts(), this.$emit("pause"));
234
+ },
235
+ /**
236
+ * Resume the animation
237
+ * @public
238
+ */
239
+ resume() {
240
+ this.isPaused && (this.isPaused = !1, this.$emit("resume"), this.showNextWord());
241
+ },
242
+ /**
243
+ * Reset the animation to initial state
244
+ * @public
245
+ */
246
+ reset() {
247
+ this.clearTimeouts(), this.isAnimating = !1, this.isPaused = !1, this.visibleWordCount = 0, this.visibleCharsPerWord = Array(this.words.length).fill(0), this.animationKey++;
248
+ },
249
+ /**
250
+ * Skip to the end of the animation
251
+ * @public
252
+ */
253
+ skipToEnd() {
254
+ this.showAllContent();
255
+ },
256
+ /**
257
+ * Show all content immediately
258
+ */
259
+ showAllContent() {
260
+ this.visibleWordCount = this.words.length, this.visibleCharsPerWord = this.words.map((e) => e.chars.length), setTimeout(() => {
261
+ this.isAnimating = !1, this.$emit("complete");
262
+ }, 0);
263
+ },
264
+ /**
265
+ * Show next word in sequence
266
+ */
267
+ showNextWord() {
268
+ if (this.isPaused || this.visibleWordCount >= this.words.length) {
269
+ this.visibleWordCount >= this.words.length && this.completeAnimation();
270
+ return;
271
+ }
272
+ const e = setTimeout(() => {
273
+ this.visibleWordCount++, this.$emit("progress", {
274
+ wordsComplete: this.visibleWordCount,
275
+ totalWords: this.words.length,
276
+ progress: this.visibleWordCount / this.words.length
277
+ }), this.animateCharsForWord(this.visibleWordCount - 1);
278
+ }, this.timing.wordDelay);
279
+ this.animationTimeouts.push(e);
280
+ },
281
+ /**
282
+ * Animate characters for a specific word
283
+ */
284
+ animateCharsForWord(e) {
285
+ if (this.isPaused || e >= this.words.length) return;
286
+ this.visibleCharsPerWord[e] = 0;
287
+ const t = this.words[e].chars.length, i = () => {
288
+ if (this.isPaused || this.visibleCharsPerWord[e] >= t) {
289
+ this.visibleCharsPerWord[e] >= t && this.showNextWord();
290
+ return;
291
+ }
292
+ this.visibleCharsPerWord[e]++;
293
+ const s = setTimeout(i, this.timing.characterDelay);
294
+ this.animationTimeouts.push(s);
295
+ };
296
+ i();
297
+ },
298
+ /**
299
+ * Complete the animation
300
+ */
301
+ completeAnimation() {
302
+ if (this.isAnimating = !1, this.clearTimeouts(), this.$emit("complete"), this.loop) {
303
+ const e = setTimeout(() => {
304
+ this.reset(), this.$nextTick(() => {
305
+ this.start();
306
+ });
307
+ }, 500);
308
+ this.animationTimeouts.push(e);
309
+ }
310
+ },
311
+ /**
312
+ * Initialize content based on text prop or slot content
313
+ */
314
+ initializeContent() {
315
+ if (this.isStaticAnimationMode) {
316
+ this.autoStart && this.$nextTick(() => this.start());
317
+ return;
318
+ }
319
+ this.text ? this.words = this.processDirectText(this.text) : this.$refs.contentRef && (this.words = this.processTextToChars(this.$refs.contentRef)), this.visibleCharsPerWord = Array(this.words.length).fill(0), this.visibleWordCount = 0, this.autoStart && this.words.length > 0 && this.$nextTick(() => this.start());
320
+ }
321
+ }
322
+ };
323
+ var p = function() {
324
+ var t = this, i = t._self._c;
325
+ return i("span", { ref: "contentRef", class: t.motionTextClasses, style: t.componentStyles, attrs: { "data-text-content": t.isStaticAnimationMode ? t.text : void 0, "aria-live": t.isAnimating ? "polite" : "off", "aria-label": t.screenReaderText || void 0 } }, [t.screenReaderText ? i("span", { staticClass: "dt-recipe-motion-text__sr-only" }, [t._v(" " + t._s(t.screenReaderText) + " ")]) : t._e(), t.isStaticAnimationMode ? [t._v(" " + t._s(t.text) + " "), t.text ? t._e() : t._t("default")] : i("span", { key: t.animationKey, staticClass: "dt-recipe-motion-text__content", attrs: { "aria-hidden": t.isAnimating } }, [t._l(t.words, function(s, n) {
326
+ return [i("Transition", { key: `${t.animationKey}-${n}`, attrs: { name: `dt-recipe-motion-text-word-${t.animationMode}` } }, [n < t.visibleWordCount ? i("span", { staticClass: "dt-recipe-motion-text__word", style: { "--word-index": n }, attrs: { "data-text-content": s.text } }, [t._l(s.chars, function(r, o) {
327
+ return [i("Transition", { key: `${t.animationKey}-${n}-${o}`, attrs: { name: `dt-recipe-motion-text-char-${t.animationMode}` } }, [o < t.visibleCharsPerWord[n] ? i("span", { staticClass: "dt-recipe-motion-text__char", style: {
328
+ "--char-index": o,
329
+ "--char-delay": `${o * t.timing.characterDelay}ms`
330
+ } }, [t._v(t._s(r))]) : t._e()])];
331
+ })], 2) : t._e()])];
332
+ })], 2), !t.words.length && !t.text && !t.isStaticAnimationMode ? i("span", { staticClass: "dt-recipe-motion-text__fallback" }, [t._t("default")], 2) : t._e()], 2);
333
+ }, f = [], T = /* @__PURE__ */ c(
334
+ u,
335
+ p,
336
+ f
337
+ );
338
+ const C = T.exports;
339
+ export {
340
+ C as default
341
+ };
342
+ //# sourceMappingURL=motion-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion-text.js","sources":["../../../recipes/motion/motion_text/motion_text.vue"],"sourcesContent":["<template>\n <span\n ref=\"contentRef\"\n :class=\"motionTextClasses\"\n :style=\"componentStyles\"\n :data-text-content=\"isStaticAnimationMode ? text : undefined\"\n :aria-live=\"isAnimating ? 'polite' : 'off'\"\n :aria-label=\"screenReaderText || undefined\"\n >\n <!-- Screen reader content -->\n <span\n v-if=\"screenReaderText\"\n class=\"dt-recipe-motion-text__sr-only\"\n >\n {{ screenReaderText }}\n </span>\n\n <!-- Gradient-sweep and shimmer modes: Simple static text with gradient animation -->\n <template v-if=\"isStaticAnimationMode\">\n {{ text }}\n <slot v-if=\"!text\" />\n </template>\n\n <!-- Character-by-character animated content for other modes -->\n <span\n v-else\n :key=\"animationKey\"\n class=\"dt-recipe-motion-text__content\"\n :aria-hidden=\"isAnimating\"\n >\n <template\n v-for=\"(word, wordIdx) in words\"\n >\n <Transition\n :key=\"`${animationKey}-${wordIdx}`\"\n :name=\"`dt-recipe-motion-text-word-${animationMode}`\"\n >\n <span\n v-if=\"wordIdx < visibleWordCount\"\n class=\"dt-recipe-motion-text__word\"\n :data-text-content=\"word.text\"\n :style=\"{ '--word-index': wordIdx }\"\n >\n <template\n v-for=\"(char, charIdx) in word.chars\"\n >\n <Transition\n :key=\"`${animationKey}-${wordIdx}-${charIdx}`\"\n :name=\"`dt-recipe-motion-text-char-${animationMode}`\"\n >\n <span\n v-if=\"charIdx < visibleCharsPerWord[wordIdx]\"\n class=\"dt-recipe-motion-text__char\"\n :style=\"{\n '--char-index': charIdx,\n '--char-delay': `${charIdx * timing.characterDelay}ms`,\n }\"\n >{{ char }}</span>\n </Transition>\n </template>\n </span>\n </Transition>\n </template>\n </span>\n\n <!-- Fallback slot content -->\n <span\n v-if=\"!words.length && !text && !isStaticAnimationMode\"\n class=\"dt-recipe-motion-text__fallback\"\n >\n <slot />\n </span>\n </span>\n</template>\n\n<script>\nimport { MOTION_TEXT_ANIMATION_MODES, MOTION_TEXT_SPEEDS, MOTION_TEXT_TIMING_PRESETS } from './motion_text_constants';\n\nexport default {\n compatConfig: { MODE: 3 },\n name: 'DtRecipeMotionText',\n\n inheritAttrs: false,\n\n props: {\n /**\n * The text content to animate.\n * @type {string}\n */\n text: {\n type: String,\n default: '',\n },\n\n /**\n * The animation mode to use for the text reveal.\n * @values gradient-in, fade-in, slide-in, gradient-sweep, shimmer, none\n */\n animationMode: {\n type: String,\n default: 'gradient-in',\n validator: (value) => MOTION_TEXT_ANIMATION_MODES.includes(value),\n },\n\n /**\n * Animation speed using t-shirt sizing.\n * @values sm, md, lg\n */\n speed: {\n type: String,\n default: 'md',\n validator: (value) => MOTION_TEXT_SPEEDS.includes(value),\n },\n\n /**\n * Whether to start animation automatically when component is mounted.\n * @values true, false\n */\n autoStart: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether to loop the animation continuously.\n * @values true, false\n */\n loop: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Whether to respect the user's prefers-reduced-motion system setting.\n * @values true, false\n */\n respectsReducedMotion: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Alternative text for screen readers. If provided, this will be announced\n * instead of the animated text.\n * @type {string}\n */\n screenReaderText: {\n type: String,\n default: '',\n },\n },\n\n emits: [\n /**\n * Emitted when the animation starts.\n * @event start\n */\n 'start',\n\n /**\n * Emitted when the animation completes.\n * @event complete\n */\n 'complete',\n\n /**\n * Emitted during animation progress.\n * @event progress\n * @type {{ wordsComplete: number, totalWords: number, progress: number }}\n */\n 'progress',\n\n /**\n * Emitted when the animation is paused.\n * @event pause\n */\n 'pause',\n\n /**\n * Emitted when the animation resumes.\n * @event resume\n */\n 'resume',\n ],\n\n data () {\n return {\n words: [],\n visibleWordCount: 0,\n visibleCharsPerWord: [],\n isAnimating: false,\n isPaused: false,\n isLooped: false,\n animationTimeouts: [],\n prefersReducedMotion: false,\n animationKey: 0,\n };\n },\n\n computed: {\n /**\n * Get timing preset based on speed prop\n */\n timing () {\n return MOTION_TEXT_TIMING_PRESETS[this.speed];\n },\n\n /**\n * Computed styles with timing CSS variables\n */\n componentStyles () {\n return {\n '--dt-recipe-motion-text-duration': `${this.timing.duration}ms`,\n '--dt-recipe-motion-text-char-duration': `${this.timing.duration}ms`,\n '--dt-recipe-motion-text-word-duration': `${this.timing.duration * 2}ms`,\n };\n },\n\n /**\n * Check if current animation mode is static (gradient-sweep or shimmer)\n */\n isStaticAnimationMode () {\n return this.animationMode === 'gradient-sweep' || this.animationMode === 'shimmer';\n },\n\n /**\n * Computed classes for the motion text element\n */\n motionTextClasses () {\n return [\n 'dt-recipe-motion-text',\n `dt-recipe-motion-text--${this.animationMode}`,\n {\n 'dt-recipe-motion-text--animating': this.isAnimating,\n 'dt-recipe-motion-text--paused': this.isPaused,\n 'dt-recipe-motion-text--looped': this.isLooped,\n },\n this.$attrs.class,\n ];\n },\n },\n\n watch: {\n text () {\n this.reset();\n this.initializeContent();\n },\n\n loop: {\n handler (newVal) {\n this.isLooped = newVal;\n },\n\n immediate: true,\n },\n },\n\n mounted () {\n this.checkReducedMotion();\n this.initializeContent();\n },\n\n beforeUnmount () {\n this.clearTimeouts();\n },\n\n methods: {\n /**\n * Self-contained text processing from DOM nodes\n */\n processTextToChars (node) {\n const words = [];\n\n const processNode = (node, index = 0) => {\n if (node.nodeType === Node.TEXT_NODE) {\n const matches = node.textContent?.match(/\\S+\\s*/g) || [];\n words.push(...matches.map((text, i) => ({\n text,\n chars: text.split(''),\n index: index + i,\n })));\n return index + matches.length;\n } else if (node.nodeType === Node.ELEMENT_NODE) {\n let currentIdx = index;\n Array.from(node.childNodes).forEach(child => {\n currentIdx = processNode(child, currentIdx);\n });\n return currentIdx;\n }\n return index;\n };\n\n processNode(node);\n return words;\n },\n\n /**\n * Process direct text prop into word/character data\n */\n processDirectText (text) {\n if (!text) return [];\n\n const matches = text.match(/\\S+\\s*/g) || [];\n return matches.map((wordText, i) => ({\n text: wordText,\n chars: wordText.split(''),\n index: i,\n }));\n },\n\n /**\n * Check for reduced motion preference\n */\n checkReducedMotion () {\n if (typeof window !== 'undefined' && window.matchMedia) {\n this.prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n }\n },\n\n /**\n * Clear all animation timeouts\n */\n clearTimeouts () {\n this.animationTimeouts.forEach(timeout => clearTimeout(timeout));\n this.animationTimeouts = [];\n },\n\n /**\n * Start the animation\n * @public\n */\n start () {\n if (this.isAnimating) return;\n\n this.isAnimating = true;\n this.isPaused = false;\n this.$emit('start');\n\n // Skip animation if reduced motion is preferred and enabled\n if (this.respectsReducedMotion && this.prefersReducedMotion) {\n this.showAllContent();\n return;\n }\n\n if (this.animationMode === 'none') {\n this.showAllContent();\n return;\n }\n\n // For gradient-sweep and shimmer modes, just mark as animating (CSS handles the animation)\n if (this.isStaticAnimationMode) {\n return;\n }\n\n // Start the word-by-word animation for \"-in\" modes\n this.showNextWord();\n },\n\n /**\n * Pause the animation\n * @public\n */\n pause () {\n if (!this.isAnimating || this.isPaused) return;\n\n this.isPaused = true;\n this.clearTimeouts();\n this.$emit('pause');\n },\n\n /**\n * Resume the animation\n * @public\n */\n resume () {\n if (!this.isPaused) return;\n\n this.isPaused = false;\n this.$emit('resume');\n this.showNextWord();\n },\n\n /**\n * Reset the animation to initial state\n * @public\n */\n reset () {\n this.clearTimeouts();\n this.isAnimating = false;\n this.isPaused = false;\n this.visibleWordCount = 0;\n this.visibleCharsPerWord = Array(this.words.length).fill(0);\n this.animationKey++;\n },\n\n /**\n * Skip to the end of the animation\n * @public\n */\n skipToEnd () {\n this.showAllContent();\n },\n\n /**\n * Show all content immediately\n */\n showAllContent () {\n this.visibleWordCount = this.words.length;\n this.visibleCharsPerWord = this.words.map(word => word.chars.length);\n setTimeout(() => {\n this.isAnimating = false;\n this.$emit('complete');\n }, 0);\n },\n\n /**\n * Show next word in sequence\n */\n showNextWord () {\n if (this.isPaused || this.visibleWordCount >= this.words.length) {\n if (this.visibleWordCount >= this.words.length) {\n this.completeAnimation();\n }\n return;\n }\n\n const timeout = setTimeout(() => {\n this.visibleWordCount++;\n this.$emit('progress', {\n wordsComplete: this.visibleWordCount,\n totalWords: this.words.length,\n progress: this.visibleWordCount / this.words.length,\n });\n\n this.animateCharsForWord(this.visibleWordCount - 1);\n }, this.timing.wordDelay);\n\n this.animationTimeouts.push(timeout);\n },\n\n /**\n * Animate characters for a specific word\n */\n animateCharsForWord (wordIdx) {\n if (this.isPaused || wordIdx >= this.words.length) return;\n\n this.visibleCharsPerWord[wordIdx] = 0;\n const chars = this.words[wordIdx].chars.length;\n\n const revealChar = () => {\n if (this.isPaused || this.visibleCharsPerWord[wordIdx] >= chars) {\n if (this.visibleCharsPerWord[wordIdx] >= chars) {\n this.showNextWord();\n }\n return;\n }\n\n this.visibleCharsPerWord[wordIdx]++;\n const timeout = setTimeout(revealChar, this.timing.characterDelay);\n this.animationTimeouts.push(timeout);\n };\n\n revealChar();\n },\n\n /**\n * Complete the animation\n */\n completeAnimation () {\n this.isAnimating = false;\n this.clearTimeouts();\n\n this.$emit('complete');\n\n if (this.loop) {\n const timeout = setTimeout(() => {\n this.reset();\n this.$nextTick(() => {\n this.start();\n });\n }, 500);\n\n this.animationTimeouts.push(timeout);\n }\n },\n\n /**\n * Initialize content based on text prop or slot content\n */\n initializeContent () {\n // For gradient-sweep and shimmer modes, skip word/character processing\n if (this.isStaticAnimationMode) {\n if (this.autoStart) {\n this.$nextTick(() => this.start());\n }\n return;\n }\n\n if (this.text) {\n this.words = this.processDirectText(this.text);\n } else if (this.$refs.contentRef) {\n this.words = this.processTextToChars(this.$refs.contentRef);\n }\n\n this.visibleCharsPerWord = Array(this.words.length).fill(0);\n this.visibleWordCount = 0;\n\n if (this.autoStart && this.words.length > 0) {\n this.$nextTick(() => this.start());\n }\n },\n },\n};\n</script>\n"],"names":["_sfc_main","value","MOTION_TEXT_ANIMATION_MODES","MOTION_TEXT_SPEEDS","MOTION_TEXT_TIMING_PRESETS","newVal","node","words","processNode","index","matches","_a","text","i","currentIdx","child","wordText","timeout","word","wordIdx","chars","revealChar"],"mappings":";;AA8EA,MAAAA,IAAA;AAAA,EACA,cAAA,EAAA,MAAA,EAAA;AAAA,EACA,MAAA;AAAA,EAEA,cAAA;AAAA,EAEA,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,eAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,MACA,WAAA,CAAAC,MAAAC,EAAA,SAAAD,CAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,OAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,MACA,WAAA,CAAAA,MAAAE,EAAA,SAAAF,CAAA;AAAA,IACA;AAAA;AAAA;A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AKA,oBAAA;AAMA,UALA,KAAA,cAAA,IACA,KAAA,cAAA,GAEA,KAAA,MAAA,UAAA,GAEA,KAAA,MAAA;AACA,cAAAJ,IAAA,WAAA,MAAA;AACA,eAAA,MAAA,GACA,KAAA,UAAA,MAAA;AACA,iBAAA,MAAA;AAAA,UACA,CAAA;AAAA,QACA,GAAA,GAAA;AAEA,aAAA,kBAAA,KAAAA,CAAA;AAAA,MACA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,oBAAA;AAEA,UAAA,KAAA,uBAAA;AACA,QAAA,KAAA,aACA,KAAA,UAAA,MAAA,KAAA,MAAA,CAAA;AAEA;AAAA,MACA;AAEA,MAAA,KAAA,OACA,KAAA,QAAA,KAAA,kBAAA,KAAA,IAAA,IACA,KAAA,MAAA,eACA,KAAA,QAAA,KAAA,mBAAA,KAAA,MAAA,UAAA,IAGA,KAAA,sBAAA,MAAA,KAAA,MAAA,MAAA,EAAA,KAAA,CAAA,GACA,KAAA,mBAAA,GAEA,KAAA,aAAA,KAAA,MAAA,SAAA,KACA,KAAA,UAAA,MAAA,KAAA,MAAA,CAAA;AAAA,IAEA;AAAA,EACA;AACA;;;;;;;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./popover-constants.cjs"),r=require("../../common/utils/index.cjs"),h=require("../../node_modules/@linusborg/vue-simple-portal.cjs"),u=require("../../common/mixins/modal.cjs"),d=require("./tippy-utils.cjs"),c=require("./popover-header-footer.cjs"),f=require("../../shared/sr_only_close_button.cjs"),m=require("../../_plugin-vue2_normalizer-e_CkxkSV.cjs"),v=require("../lazy-show/lazy-show.cjs"),y={name:"DtPopover",components:{SrOnlyCloseButton:f.default,DtLazyShow:v.default,PopoverHeaderFooter:c.default,Portal:h.Portal},mixins:[u.default],props:{open:{type:Boolean,default:null},openOnContext:{type:Boolean,default:!1},elementType:{type:String,default:"div"},transition:{type:String,default:"fade"},role:{type:String,default:"dialog",validator:t=>s.POPOVER_ROLES.includes(t)},ariaLabelledby:{type:String,default:null},ariaLabel:{type:String,default:null},padding:{type:String,default:"large",validator:t=>Object.keys(s.POPOVER_PADDING_CLASSES).some(e=>e===t)},contentClass:{type:[String,Array,Object],default:""},contentWidth:{type:String,default:"",validator:t=>s.POPOVER_CONTENT_WIDTHS.includes(t)},contentTabindex:{type:Number||null,default:-1},externalAnchor:{type:String,default:""},id:{type:String,default(){return r.getUniqueString()}},offset:{type:Array,default:()=>[0,4]},hideOnClick:{type:Boolean,default:!0},modal:{type:Boolean,default:!0},fallbackPlacements:{type:Array,default:()=>["auto"]},placement:{type:String,default:"bottom-end"},tether:{type:Boolean,default:!0},sticky:{type:[Boolean,String],default:!1,validator:t=>s.POPOVER_STICKY_VALUES.includes(t)},maxHeight:{type:String,default:""},maxWidth:{type:String,default:""},showCloseButton:{type:Boolean,default:!1},headerClass:{type:[String,Array,Object],default:""},footerClass:{type:[String,Array,Object],default:""},dialogClass:{type:[String,Array,Object],default:""},initialFocusElement:{type:[String,HTMLElement],default:"first",validator:t=>s.POPOVER_INITIAL_FOCUS_STRINGS.includes(t)||t instanceof HTMLElement||t.startsWith("#")},openWithArrowKeys:{type:Boolean,default:!1},appendTo:{type:[HTMLElement,String],default:"body",validator:t=>s.POPOVER_APPEND_TO_VALUES.includes(t)||t instanceof HTMLElement}},emits:["opened","update:open","mouseenter-popover","mouseleave-popover","mouseenter-popover-anchor","mouseleave-popover-anchor"],data(){return{POPOVER_PADDING_CLASSES:s.POPOVER_PADDING_CLASSES,POPOVER_HEADER_FOOTER_PADDING_CLASSES:s.POPOVER_HEADER_FOOTER_PADDING_CLASSES,intersectionObserver:null,mutationObserver:null,isOutsideViewport:!1,isOpen:!1,anchorEl:null,popoverContentEl:null}},computed:{popoverListeners(){return{...this.$listeners,keydown:t=>{this.onKeydown(t),this.$emit("keydown",t)},"after-leave":()=>{this.onLeaveTransitionComplete()},"after-enter":()=>{this.onEnterTransitionComplete()}}},calculatedMaxHeight(){return this.isOutsideViewport&&this.modal?"calc(100vh - var(--dt-space-300))":this.maxHeight},labelledBy(){return this.ariaLabelledby||!this.ariaLabel&&r.getUniqueString("DtPopover__anchor")}},watch:{$props:{immediate:!0,deep:!0,handler(){this.validateProps()}},modal(t){var e;(e=this.tip)==null||e.setProps({zIndex:t?650:this.calculateAnchorZindex()})},offset(t){var e;(e=this.tip)==null||e.setProps({offset:t})},sticky(t){var e;(e=this.tip)==null||e.setProps({sticky:t})},fallbackPlacements(){var t;(t=this.tip)==null||t.setProps({popperOptions:this.popperOptions()})},tether(){var t;(t=this.tip)==null||t.setProps({popperOptions:this.popperOptions()})},placement(t){var e;(e=this.tip)==null||e.setProps({placement:t})},open:{handler:function(t){t!==null&&(this.isOpen=t)},immediate:!0},isOpen(t,e){var o,n;t?(this.initTippyInstance(),(o=this.tip)==null||o.show()):!t&&e!==t&&(this.removeEventListeners(),(n=this.tip)==null||n.hide())}},mounted(){var t;r.warnIfUnmounted(this.$el,this.$options.name),this.popoverContentEl=(t=this.$refs.content)==null?void 0:t.$el,this.updateAnchorEl(),this.mutationObserver=new MutationObserver(this.updateAnchorEl),this.mutationObserver.observe(this.$refs.anchor,{childList:!0}),this.intersectionObserver=new IntersectionObserver(this.hasIntersectedViewport),this.intersectionObserver.observe(this.popoverContentEl)},beforeDestroy(){var t,e,o;(t=this.tip)==null||t.destroy(),(e=this.intersectionObserver)==null||e.disconnect(),(o=this.mutationObserver)==null||o.disconnect(),this.removeReferences(),this.removeEventListeners()},methods:{hasIntersectedViewport(t){var n;const e=(n=t==null?void 0:t[0])==null?void 0:n.target;if(!e)return;const o=r.isOutOfViewPort(e);this.isOutsideViewport=o.bottom||o.top},updateAnchorEl(){var e,o;const t=this.externalAnchor?this.$refs.anchor.getRootNode().querySelector(`#${this.externalAnchor}`):null;if(this.anchorEl=t??this.$refs.anchor.children[0],(e=this.tip)==null||e.destroy(),delete this.tip,!this.anchorEl){console.warn("No anchor found for popover");return}this.isOpen&&(this.initTippyInstance(),(o=this.tip)==null||o.show())},popperOptions(){return d.getPopperOptions({fallbackPlacements:this.fallbackPlacements,tether:this.tether,hasHideModifierEnabled:!0})},validateProps(){this.modal&&this.initialFocusElement==="none"&&console.error('If the popover is modal you must set the initialFocusElement prop. Possible values: "dialog", "first", HTMLElement')},calculateAnchorZindex(){var t;return this.$el.getRootNode().querySelector('.d-modal[aria-hidden="false"], .d-modal--transparent[aria-hidden="false"]')||(t=this.anchorEl)!=null&&t.closest(".d-zi-drawer")?650:300},defaultToggleOpen(t){var e,o;this.openOnContext||(this.open??((e=this.anchorEl)!=null&&e.contains(t.target)&&!((o=this.anchorEl)!=null&&o.disabled)&&this.toggleOpen()))},async onContext(t){var e;this.openOnContext&&(t.preventDefault(),this.isOpen=!0,await this.$nextTick(),(e=this.tip)==null||e.setProps({placement:"right-start",getReferenceClientRect:()=>({width:0,height:0,top:t.clientY,bottom:t.clientY,left:t.clientX,right:t.clientX})}))},toggleOpen(){this.isOpen=!this.isOpen},onArrowKeyPress(t){var e;this.open===null&&this.openWithArrowKeys&&(e=this.anchorEl)!=null&&e.contains(t.target)&&(this.isOpen||(this.isOpen=!0))},addEventListeners(){window.addEventListener("dt-popover-close",this.closePopover),this.contentWidth==="anchor"&&window.addEventListener("resize",this.onResize)},removeEventListeners(){window.removeEventListener("dt-popover-close",this.closePopover),this.contentWidth==="anchor"&&window.removeEventListener("resize",this.onResize)},closePopover(){this.isOpen=!1},preventScrolling(){var t,e,o;if(this.modal){const n=(t=this.anchorEl)==null?void 0:t.closest("body, .tippy-box");if(!n)return;((e=n.tagName)==null?void 0:e.toLowerCase())==="body"?(r.disableRootScrolling(this.anchorEl.getRootNode().host),(o=this.tip)==null||o.setProps({offset:this.offset})):n.classList.add("d-zi-popover")}},enableScrolling(){var e,o,n;const t=(e=this.anchorEl)==null?void 0:e.closest("body, .tippy-box");t&&(((o=t.tagName)==null?void 0:o.toLowerCase())==="body"?(r.enableRootScrolling(this.anchorEl.getRootNode().host),(n=this.tip)==null||n.setProps({offset:this.offset})):t.classList.remove("d-zi-popover"))},removeReferences(){this.anchorEl=null,this.popoverContentEl=null,this.tip=null},async onShow(){this.contentWidth==="anchor"&&await this.setPopoverContentAnchorWidth(),this.contentWidth===null&&(this.popoverContentEl.style.width="auto"),this.addEventListeners()},async onLeaveTransitionComplete(){var t;this.modal&&(await this.focusFirstElement(this.$refs.anchor),await this.$nextTick(),this.enableScrolling()),(t=this.tip)==null||t.unmount(),this.$emit("opened",!1),this.open!==null&&this.$emit("update:open",!1)},async onEnterTransitionComplete(){this.focusInitialElement(),await this.$nextTick(),this.preventScrolling(),this.$emit("opened",!0,this.$refs.popover__content),this.open!==null&&this.$emit("update:open",!0)},focusInitialElement(){var t,e;this.initialFocusElement==="dialog"&&((e=(t=this.$refs.content)==null?void 0:t.$el)==null||e.focus()),this.initialFocusElement.startsWith("#")&&this.focusInitialElementById(),this.initialFocusElement==="first"&&this.focusFirstElementIfNeeded(this.$refs.popover__content),this.initialFocusElement instanceof HTMLElement&&this.initialFocusElement.focus()},focusInitialElementById(){var e,o,n;const t=(o=(e=this.$refs.content)==null?void 0:e.$el)==null?void 0:o.querySelector(this.initialFocusElement);t?t.focus():console.warn('Could not find the element specified in dt-popover prop "initialFocusElement". Defaulting to focusing the dialog.'),t?t.focus():(n=this.$refs.content)==null||n.$el.focus()},onResize(){this.closePopover()},onClickOutside(){var e;if(!this.hideOnClick)return;((e=this.popoverContentEl)==null?void 0:e.querySelector(".d-popover__anchor--opened"))||this.closePopover()},onKeydown(t){t.key==="Tab"&&this.modal&&this.focusTrappedTabPress(t,this.popoverContentEl),t.key==="Escape"&&this.closePopover()},async setPopoverContentAnchorWidth(){var t;await this.$nextTick(),this.popoverContentEl.style.width=`${(t=this.anchorEl)==null?void 0:t.clientWidth}px`},focusFirstElementIfNeeded(t){var o,n;this._getFocusableElements(t,!0).length!==0?this.focusFirstElement(t):this.showCloseButton?(o=this.$refs.popover__header)==null||o.focusCloseButton():(n=this.$refs.content)==null||n.$el.focus()},getReferenceClientRect(t){var a,p;const e=(a=this.anchorEl)==null?void 0:a.getBoundingClientRect();if(this.appendTo!=="root"||t)return e;const o=(p=this.anchorEl)==null?void 0:p.ownerDocument,n=(o==null?void 0:o.defaultView)||(o==null?void 0:o.parentWindow),l=n==null?void 0:n.frameElement;if(!l)return e;const i=l.getBoundingClientRect();return{width:e==null?void 0:e.width,height:e==null?void 0:e.height,top:(i==null?void 0:i.top)+(e==null?void 0:e.top),left:(i==null?void 0:i.left)+(e==null?void 0:e.left),right:(i==null?void 0:i.right)+(e==null?void 0:e.right),bottom:(i==null?void 0:i.bottom)+(e==null?void 0:e.bottom)}},initTippyInstance(){var o,n,l;let t=null,e=!1;switch(this.appendTo){case"body":t=(n=(o=this.anchorEl)==null?void 0:o.getRootNode())==null?void 0:n.querySelector("body");break;case"root":try{t=window.parent.document.body}catch(i){console.error("Could not attach the popover to iframe parent window: ",i),t="parent",e=!0}break;default:t=this.appendTo;break}(l=this.tip)==null||l.destroy(),this.tip=d.createTippyPopover(this.anchorEl,{popperOptions:this.popperOptions(),contentElement:this.popoverContentEl,placement:this.placement,offset:this.offset,sticky:this.sticky,appendTo:t,interactive:!0,trigger:"manual",getReferenceClientRect:()=>this.getReferenceClientRect(e),hideOnClick:!1,zIndex:this.modal?650:this.calculateAnchorZindex(),onClickOutside:this.onClickOutside,onShow:this.onShow})},onMouseEnter(){this.$emit("mouseenter-popover")},onMouseLeave(){this.$emit("mouseleave-popover")},onMouseEnterAnchor(){this.$emit("mouseenter-popover-anchor")},onMouseLeaveAnchor(){this.$emit("mouseleave-popover-anchor")},hasFooter(){var t,e;return this.$slots.footerContent||((e=(t=this.$scopedSlots).footerContent)==null?void 0:e.call(t))}}};var _=function(){var e=this,o=e._self._c;return o("div",[e.modal&&e.isOpen?o("portal",[o("div",{staticClass:"d-modal--transparent",attrs:{"aria-hidden":"false"},on:{click:function(n){n.preventDefault(),n.stopPropagation()}}})]):e._e(),o(e.elementType,e._g({ref:"popover",tag:"component",class:["d-popover",{"d-popover__anchor--opened":e.isOpen}],attrs:{"data-qa":"dt-popover-container"}},e.$listeners),[o("div",{ref:"anchor",attrs:{id:!e.ariaLabelledby&&e.labelledBy,"data-qa":e.$attrs["data-qa"]?`${e.$attrs["data-qa"]}-anchor`:"dt-popover-anchor",tabindex:e.openOnContext?0:void 0},on:{"!click":function(n){return e.defaultToggleOpen.apply(null,arguments)},contextmenu:e.onContext,keydown:[function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"up",38,n.key,["Up","ArrowUp"])?null:(n.preventDefault(),e.onArrowKeyPress.apply(null,arguments))},function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"down",40,n.key,["Down","ArrowDown"])?null:(n.preventDefault(),e.onArrowKeyPress.apply(null,arguments))}],"!keydown":function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"escape",void 0,n.key,void 0)?null:e.closePopover.apply(null,arguments)},mouseenter:e.onMouseEnter,mouseleave:e.onMouseLeave}},[e._t("anchor",null,{attrs:{"aria-expanded":e.isOpen.toString(),"aria-controls":e.id,"aria-haspopup":e.role}})],2),o("dt-lazy-show",e._g({ref:"content",class:["d-popover__dialog",{"d-popover__dialog--modal":e.modal},e.dialogClass],style:{"max-height":e.calculatedMaxHeight,"max-width":e.maxWidth},attrs:{id:e.id,role:e.role,"data-qa":e.$attrs["data-qa"]?`${e.$attrs["data-qa"]}__dialog`:"dt-popover","aria-hidden":`${!e.isOpen}`,"aria-labelledby":e.labelledBy,"aria-label":e.ariaLabel,"aria-modal":`${!e.modal}`,transition:e.transition,show:e.isOpen,tabindex:e.contentTabindex,appear:""},on:{mouseenter:e.onMouseEnterAnchor,mouseleave:e.onMouseLeaveAnchor}},e.popoverListeners),[e.$slots.headerContent||e.showCloseButton?o("popover-header-footer",{ref:"popover__header",class:e.POPOVER_HEADER_FOOTER_PADDING_CLASSES[e.padding],attrs:{"content-class":e.headerClass,type:"header","show-close-button":e.showCloseButton},on:{close:e.closePopover},scopedSlots:e._u([{key:"content",fn:function(){return[e._t("headerContent",null,{close:e.closePopover})]},proxy:!0}],null,!0)}):e._e(),o("div",{ref:"popover__content",class:["d-popover__content",e.POPOVER_PADDING_CLASSES[e.padding],e.contentClass],attrs:{"data-qa":e.$attrs["data-qa"]?`${e.$attrs["data-qa"]}-content`:"dt-popover-content"}},[e._t("content",null,{close:e.closePopover})],2),e.hasFooter()?o("popover-header-footer",{ref:"popover__footer",class:e.POPOVER_HEADER_FOOTER_PADDING_CLASSES[e.padding],attrs:{type:"footer","content-class":e.footerClass},scopedSlots:e._u([{key:"content",fn:function(){return[e._t("footerContent",null,{close:e.closePopover})]},proxy:!0}],null,!0)}):e._e(),e.showCloseButton?e._e():o("sr-only-close-button",{on:{close:e.closePopover}})],1)],1)],1)},E=[],g=m.n(y,_,E);const O=g.exports;exports.default=O;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./popover-constants.cjs"),r=require("../../common/utils/index.cjs"),h=require("../../node_modules/@linusborg/vue-simple-portal.cjs"),u=require("../../common/mixins/modal.cjs"),d=require("./tippy-utils.cjs"),c=require("./popover-header-footer.cjs"),f=require("../../shared/sr_only_close_button.cjs"),m=require("../../_plugin-vue2_normalizer-e_CkxkSV.cjs"),v=require("../lazy-show/lazy-show.cjs"),y={name:"DtPopover",components:{SrOnlyCloseButton:f.default,DtLazyShow:v.default,PopoverHeaderFooter:c.default,Portal:h.Portal},mixins:[u.default],props:{open:{type:Boolean,default:null},openOnContext:{type:Boolean,default:!1},elementType:{type:String,default:"div"},transition:{type:String,default:"fade"},role:{type:String,default:"dialog",validator:t=>s.POPOVER_ROLES.includes(t)},ariaLabelledby:{type:String,default:null},ariaLabel:{type:String,default:null},padding:{type:String,default:"large",validator:t=>Object.keys(s.POPOVER_PADDING_CLASSES).some(e=>e===t)},contentClass:{type:[String,Array,Object],default:""},contentWidth:{type:String,default:"",validator:t=>s.POPOVER_CONTENT_WIDTHS.includes(t)},contentTabindex:{type:Number||null,default:-1},externalAnchor:{type:String,default:""},id:{type:String,default(){return r.getUniqueString()}},offset:{type:Array,default:()=>[0,4]},hideOnClick:{type:Boolean,default:!0},modal:{type:Boolean,default:!0},fallbackPlacements:{type:Array,default:()=>["auto"]},placement:{type:String,default:"bottom-end"},tether:{type:Boolean,default:!0},sticky:{type:[Boolean,String],default:!1,validator:t=>s.POPOVER_STICKY_VALUES.includes(t)},maxHeight:{type:String,default:""},maxWidth:{type:String,default:""},showCloseButton:{type:Boolean,default:!1},headerClass:{type:[String,Array,Object],default:""},footerClass:{type:[String,Array,Object],default:""},dialogClass:{type:[String,Array,Object],default:""},initialFocusElement:{type:[String,HTMLElement],default:"first",validator:t=>s.POPOVER_INITIAL_FOCUS_STRINGS.includes(t)||t instanceof HTMLElement||t.startsWith("#")},openWithArrowKeys:{type:Boolean,default:!1},appendTo:{type:[HTMLElement,String],default:"body",validator:t=>s.POPOVER_APPEND_TO_VALUES.includes(t)||t instanceof HTMLElement}},emits:["opened","update:open","mouseenter-popover","mouseleave-popover","mouseenter-popover-anchor","mouseleave-popover-anchor"],data(){return{POPOVER_PADDING_CLASSES:s.POPOVER_PADDING_CLASSES,POPOVER_HEADER_FOOTER_PADDING_CLASSES:s.POPOVER_HEADER_FOOTER_PADDING_CLASSES,intersectionObserver:null,mutationObserver:null,isOutsideViewport:!1,isOpen:!1,anchorEl:null,popoverContentEl:null}},computed:{popoverListeners(){return{...this.$listeners,keydown:t=>{this.onKeydown(t),this.$emit("keydown",t)},"after-leave":()=>{this.onLeaveTransitionComplete()},"after-enter":()=>{this.onEnterTransitionComplete()}}},calculatedMaxHeight(){return this.isOutsideViewport&&this.modal?"calc(100vh - var(--dt-space-300))":this.maxHeight},labelledBy(){return this.ariaLabelledby||!this.ariaLabel&&r.getUniqueString("DtPopover__anchor")}},watch:{$props:{immediate:!0,deep:!0,handler(){this.validateProps()}},modal(t){var e;(e=this.tip)==null||e.setProps({zIndex:t?650:this.calculateAnchorZindex()})},offset(t){var e;(e=this.tip)==null||e.setProps({offset:t})},sticky(t){var e;(e=this.tip)==null||e.setProps({sticky:t})},fallbackPlacements(){var t;(t=this.tip)==null||t.setProps({popperOptions:this.popperOptions()})},tether(){var t;(t=this.tip)==null||t.setProps({popperOptions:this.popperOptions()})},placement(t){var e;(e=this.tip)==null||e.setProps({placement:t})},open:{handler:function(t){t!==null&&(this.isOpen=t)},immediate:!0},isOpen(t,e){var o,n;t?(this.initTippyInstance(),(o=this.tip)==null||o.show()):!t&&e!==t&&(this.removeEventListeners(),(n=this.tip)==null||n.hide())}},mounted(){var t;r.warnIfUnmounted(this.$el,this.$options.name),this.popoverContentEl=(t=this.$refs.content)==null?void 0:t.$el,this.updateAnchorEl(),this.mutationObserver=new MutationObserver(this.updateAnchorEl),this.mutationObserver.observe(this.$refs.anchor,{childList:!0}),this.intersectionObserver=new IntersectionObserver(this.hasIntersectedViewport),this.intersectionObserver.observe(this.popoverContentEl)},beforeDestroy(){var t,e,o;(t=this.tip)==null||t.destroy(),(e=this.intersectionObserver)==null||e.disconnect(),(o=this.mutationObserver)==null||o.disconnect(),this.removeReferences(),this.removeEventListeners()},methods:{hasIntersectedViewport(t){var n;const e=(n=t==null?void 0:t[0])==null?void 0:n.target;if(!e)return;const o=r.isOutOfViewPort(e);this.isOutsideViewport=o.bottom||o.top},updateAnchorEl(){var o,n;const e=(this.externalAnchor?this.$refs.anchor.getRootNode().querySelector(`#${this.externalAnchor}`):null)??this.$refs.anchor.children[0];if(e!==this.anchorEl){if(this.anchorEl=e,(o=this.tip)==null||o.destroy(),delete this.tip,!this.anchorEl){console.warn("No anchor found for popover");return}this.isOpen&&(this.initTippyInstance(),(n=this.tip)==null||n.show())}},popperOptions(){return d.getPopperOptions({fallbackPlacements:this.fallbackPlacements,tether:this.tether,hasHideModifierEnabled:!0})},validateProps(){this.modal&&this.initialFocusElement==="none"&&console.error('If the popover is modal you must set the initialFocusElement prop. Possible values: "dialog", "first", HTMLElement')},calculateAnchorZindex(){var t;return this.$el.getRootNode().querySelector('.d-modal[aria-hidden="false"], .d-modal--transparent[aria-hidden="false"]')||(t=this.anchorEl)!=null&&t.closest(".d-zi-drawer")?650:300},defaultToggleOpen(t){var e,o;this.openOnContext||(this.open??((e=this.anchorEl)!=null&&e.contains(t.target)&&!((o=this.anchorEl)!=null&&o.disabled)&&this.toggleOpen()))},async onContext(t){var e;this.openOnContext&&(t.preventDefault(),this.isOpen=!0,await this.$nextTick(),(e=this.tip)==null||e.setProps({placement:"right-start",getReferenceClientRect:()=>({width:0,height:0,top:t.clientY,bottom:t.clientY,left:t.clientX,right:t.clientX})}))},toggleOpen(){this.isOpen=!this.isOpen},onArrowKeyPress(t){var e;this.open===null&&this.openWithArrowKeys&&(e=this.anchorEl)!=null&&e.contains(t.target)&&(this.isOpen||(this.isOpen=!0))},addEventListeners(){window.addEventListener("dt-popover-close",this.closePopover),this.contentWidth==="anchor"&&window.addEventListener("resize",this.onResize)},removeEventListeners(){window.removeEventListener("dt-popover-close",this.closePopover),this.contentWidth==="anchor"&&window.removeEventListener("resize",this.onResize)},closePopover(){this.isOpen=!1},preventScrolling(){var t,e,o;if(this.modal){const n=(t=this.anchorEl)==null?void 0:t.closest("body, .tippy-box");if(!n)return;((e=n.tagName)==null?void 0:e.toLowerCase())==="body"?(r.disableRootScrolling(this.anchorEl.getRootNode().host),(o=this.tip)==null||o.setProps({offset:this.offset})):n.classList.add("d-zi-popover")}},enableScrolling(){var e,o,n;const t=(e=this.anchorEl)==null?void 0:e.closest("body, .tippy-box");t&&(((o=t.tagName)==null?void 0:o.toLowerCase())==="body"?(r.enableRootScrolling(this.anchorEl.getRootNode().host),(n=this.tip)==null||n.setProps({offset:this.offset})):t.classList.remove("d-zi-popover"))},removeReferences(){this.anchorEl=null,this.popoverContentEl=null,this.tip=null},async onShow(){this.contentWidth==="anchor"&&await this.setPopoverContentAnchorWidth(),this.contentWidth===null&&(this.popoverContentEl.style.width="auto"),this.addEventListeners()},async onLeaveTransitionComplete(){var t;this.modal&&(await this.focusFirstElement(this.$refs.anchor),await this.$nextTick(),this.enableScrolling()),(t=this.tip)==null||t.unmount(),this.$emit("opened",!1),this.open!==null&&this.$emit("update:open",!1)},async onEnterTransitionComplete(){this.focusInitialElement(),await this.$nextTick(),this.preventScrolling(),this.$emit("opened",!0,this.$refs.popover__content),this.open!==null&&this.$emit("update:open",!0)},focusInitialElement(){var t,e;this.initialFocusElement==="dialog"&&((e=(t=this.$refs.content)==null?void 0:t.$el)==null||e.focus()),this.initialFocusElement.startsWith("#")&&this.focusInitialElementById(),this.initialFocusElement==="first"&&this.focusFirstElementIfNeeded(this.$refs.popover__content),this.initialFocusElement instanceof HTMLElement&&this.initialFocusElement.focus()},focusInitialElementById(){var e,o,n;const t=(o=(e=this.$refs.content)==null?void 0:e.$el)==null?void 0:o.querySelector(this.initialFocusElement);t?t.focus():console.warn('Could not find the element specified in dt-popover prop "initialFocusElement". Defaulting to focusing the dialog.'),t?t.focus():(n=this.$refs.content)==null||n.$el.focus()},onResize(){this.closePopover()},onClickOutside(){var e;if(!this.hideOnClick)return;((e=this.popoverContentEl)==null?void 0:e.querySelector(".d-popover__anchor--opened"))||this.closePopover()},onKeydown(t){t.key==="Tab"&&this.modal&&this.focusTrappedTabPress(t,this.popoverContentEl),t.key==="Escape"&&this.closePopover()},async setPopoverContentAnchorWidth(){var t;await this.$nextTick(),this.popoverContentEl.style.width=`${(t=this.anchorEl)==null?void 0:t.clientWidth}px`},focusFirstElementIfNeeded(t){var o,n;this._getFocusableElements(t,!0).length!==0?this.focusFirstElement(t):this.showCloseButton?(o=this.$refs.popover__header)==null||o.focusCloseButton():(n=this.$refs.content)==null||n.$el.focus()},getReferenceClientRect(t){var a,p;const e=(a=this.anchorEl)==null?void 0:a.getBoundingClientRect();if(this.appendTo!=="root"||t)return e;const o=(p=this.anchorEl)==null?void 0:p.ownerDocument,n=(o==null?void 0:o.defaultView)||(o==null?void 0:o.parentWindow),l=n==null?void 0:n.frameElement;if(!l)return e;const i=l.getBoundingClientRect();return{width:e==null?void 0:e.width,height:e==null?void 0:e.height,top:(i==null?void 0:i.top)+(e==null?void 0:e.top),left:(i==null?void 0:i.left)+(e==null?void 0:e.left),right:(i==null?void 0:i.right)+(e==null?void 0:e.right),bottom:(i==null?void 0:i.bottom)+(e==null?void 0:e.bottom)}},initTippyInstance(){var o,n,l;let t=null,e=!1;switch(this.appendTo){case"body":t=(n=(o=this.anchorEl)==null?void 0:o.getRootNode())==null?void 0:n.querySelector("body");break;case"root":try{t=window.parent.document.body}catch(i){console.error("Could not attach the popover to iframe parent window: ",i),t="parent",e=!0}break;default:t=this.appendTo;break}(l=this.tip)==null||l.destroy(),this.tip=d.createTippyPopover(this.anchorEl,{popperOptions:this.popperOptions(),contentElement:this.popoverContentEl,placement:this.placement,offset:this.offset,sticky:this.sticky,appendTo:t,interactive:!0,trigger:"manual",getReferenceClientRect:()=>this.getReferenceClientRect(e),hideOnClick:!1,zIndex:this.modal?650:this.calculateAnchorZindex(),onClickOutside:this.onClickOutside,onShow:this.onShow})},onMouseEnter(){this.$emit("mouseenter-popover")},onMouseLeave(){this.$emit("mouseleave-popover")},onMouseEnterAnchor(){this.$emit("mouseenter-popover-anchor")},onMouseLeaveAnchor(){this.$emit("mouseleave-popover-anchor")},hasFooter(){var t,e;return this.$slots.footerContent||((e=(t=this.$scopedSlots).footerContent)==null?void 0:e.call(t))}}};var E=function(){var e=this,o=e._self._c;return o("div",[e.modal&&e.isOpen?o("portal",[o("div",{staticClass:"d-modal--transparent",attrs:{"aria-hidden":"false"},on:{click:function(n){n.preventDefault(),n.stopPropagation()}}})]):e._e(),o(e.elementType,e._g({ref:"popover",tag:"component",class:["d-popover",{"d-popover__anchor--opened":e.isOpen}],attrs:{"data-qa":"dt-popover-container"}},e.$listeners),[o("div",{ref:"anchor",attrs:{id:!e.ariaLabelledby&&e.labelledBy,"data-qa":e.$attrs["data-qa"]?`${e.$attrs["data-qa"]}-anchor`:"dt-popover-anchor",tabindex:e.openOnContext?0:void 0},on:{"!click":function(n){return e.defaultToggleOpen.apply(null,arguments)},contextmenu:e.onContext,keydown:[function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"up",38,n.key,["Up","ArrowUp"])?null:(n.preventDefault(),e.onArrowKeyPress.apply(null,arguments))},function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"down",40,n.key,["Down","ArrowDown"])?null:(n.preventDefault(),e.onArrowKeyPress.apply(null,arguments))}],"!keydown":function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"escape",void 0,n.key,void 0)?null:e.closePopover.apply(null,arguments)},mouseenter:e.onMouseEnter,mouseleave:e.onMouseLeave}},[e._t("anchor",null,{attrs:{"aria-expanded":e.isOpen.toString(),"aria-controls":e.id,"aria-haspopup":e.role}})],2),o("dt-lazy-show",e._g({ref:"content",class:["d-popover__dialog",{"d-popover__dialog--modal":e.modal},e.dialogClass],style:{"max-height":e.calculatedMaxHeight,"max-width":e.maxWidth},attrs:{id:e.id,role:e.role,"data-qa":e.$attrs["data-qa"]?`${e.$attrs["data-qa"]}__dialog`:"dt-popover","aria-hidden":`${!e.isOpen}`,"aria-labelledby":e.labelledBy,"aria-label":e.ariaLabel,"aria-modal":`${!e.modal}`,transition:e.transition,show:e.isOpen,tabindex:e.contentTabindex,appear:""},on:{mouseenter:e.onMouseEnterAnchor,mouseleave:e.onMouseLeaveAnchor}},e.popoverListeners),[e.$slots.headerContent||e.showCloseButton?o("popover-header-footer",{ref:"popover__header",class:e.POPOVER_HEADER_FOOTER_PADDING_CLASSES[e.padding],attrs:{"content-class":e.headerClass,type:"header","show-close-button":e.showCloseButton},on:{close:e.closePopover},scopedSlots:e._u([{key:"content",fn:function(){return[e._t("headerContent",null,{close:e.closePopover})]},proxy:!0}],null,!0)}):e._e(),o("div",{ref:"popover__content",class:["d-popover__content",e.POPOVER_PADDING_CLASSES[e.padding],e.contentClass],attrs:{"data-qa":e.$attrs["data-qa"]?`${e.$attrs["data-qa"]}-content`:"dt-popover-content"}},[e._t("content",null,{close:e.closePopover})],2),e.hasFooter()?o("popover-header-footer",{ref:"popover__footer",class:e.POPOVER_HEADER_FOOTER_PADDING_CLASSES[e.padding],attrs:{type:"footer","content-class":e.footerClass},scopedSlots:e._u([{key:"content",fn:function(){return[e._t("footerContent",null,{close:e.closePopover})]},proxy:!0}],null,!0)}):e._e(),e.showCloseButton?e._e():o("sr-only-close-button",{on:{close:e.closePopover}})],1)],1)],1)},_=[],g=m.n(y,E,_);const O=g.exports;exports.default=O;
2
2
  //# sourceMappingURL=popover.cjs.map