@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 @@
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 :key=\"`${animationKey}-${wordIdx}`\"\n >\n <Transition\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 :key=\"`${animationKey}-${wordIdx}-${charIdx}`\"\n >\n <Transition\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","_hoisted_1","_hoisted_3","_hoisted_4","_createElementBlock","_normalizeClass","$options","_normalizeStyle","$props","$data","_hoisted_2","_toDisplayString","_createCommentVNode","_openBlock","_Fragment","_createTextVNode","_renderSlot","_ctx","_renderList","_createBlock","_Transition","_withCtx","char","charIdx","_hoisted_5"],"mappings":"sOA8EKA,EAAU,CACb,aAAc,CAAE,KAAM,GACtB,KAAM,qBAEN,aAAc,GAEd,MAAO,CAKL,KAAM,CACJ,KAAM,OACN,QAAS,IAOX,cAAe,CACb,KAAM,OACN,QAAS,cACT,UAAYC,GAAUC,8BAA4B,SAASD,CAAK,GAOlE,MAAO,CACL,KAAM,OACN,QAAS,KACT,UAAYA,GAAUE,qBAAmB,SAASF,CAAK,GAOzD,UAAW,CACT,KAAM,QACN,QAAS,IAOX,KAAM,CACJ,KAAM,QACN,QAAS,IAOX,sBAAuB,CACr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,EAAA,MAAM,QAAM,CAAKD,EAAA,OAASF,EAAA,uBADnCO,EAAAA,YAAAT,EAAAA,mBAKO,OALPoB,EAKO,CADLR,aAAQC,EAAA,OAAA,SAAA,KAtEdL,EAAAA,mBAAA,GAAA,EAAA,CAAA,EAAA,GAAAX,CAAA"}
@@ -0,0 +1,389 @@
1
+ import { MOTION_TEXT_SPEEDS as y, MOTION_TEXT_ANIMATION_MODES as M, MOTION_TEXT_TIMING_PRESETS as w } from "./motion-text-constants.js";
2
+ import { createElementBlock as h, openBlock as s, normalizeStyle as u, normalizeClass as A, createCommentVNode as l, toDisplayString as f, Fragment as p, createTextVNode as W, renderSlot as T, renderList as g, createBlock as C, Transition as _, withCtx as x } from "vue";
3
+ import { _ as v } from "../../_plugin-vue_export-helper-CHgC5LLL.js";
4
+ const S = {
5
+ compatConfig: { MODE: 3 },
6
+ name: "DtRecipeMotionText",
7
+ inheritAttrs: !1,
8
+ props: {
9
+ /**
10
+ * The text content to animate.
11
+ * @type {string}
12
+ */
13
+ text: {
14
+ type: String,
15
+ default: ""
16
+ },
17
+ /**
18
+ * The animation mode to use for the text reveal.
19
+ * @values gradient-in, fade-in, slide-in, gradient-sweep, shimmer, none
20
+ */
21
+ animationMode: {
22
+ type: String,
23
+ default: "gradient-in",
24
+ validator: (t) => M.includes(t)
25
+ },
26
+ /**
27
+ * Animation speed using t-shirt sizing.
28
+ * @values sm, md, lg
29
+ */
30
+ speed: {
31
+ type: String,
32
+ default: "md",
33
+ validator: (t) => y.includes(t)
34
+ },
35
+ /**
36
+ * Whether to start animation automatically when component is mounted.
37
+ * @values true, false
38
+ */
39
+ autoStart: {
40
+ type: Boolean,
41
+ default: !0
42
+ },
43
+ /**
44
+ * Whether to loop the animation continuously.
45
+ * @values true, false
46
+ */
47
+ loop: {
48
+ type: Boolean,
49
+ default: !1
50
+ },
51
+ /**
52
+ * Whether to respect the user's prefers-reduced-motion system setting.
53
+ * @values true, false
54
+ */
55
+ respectsReducedMotion: {
56
+ type: Boolean,
57
+ default: !0
58
+ },
59
+ /**
60
+ * Alternative text for screen readers. If provided, this will be announced
61
+ * instead of the animated text.
62
+ * @type {string}
63
+ */
64
+ screenReaderText: {
65
+ type: String,
66
+ default: ""
67
+ }
68
+ },
69
+ emits: [
70
+ /**
71
+ * Emitted when the animation starts.
72
+ * @event start
73
+ */
74
+ "start",
75
+ /**
76
+ * Emitted when the animation completes.
77
+ * @event complete
78
+ */
79
+ "complete",
80
+ /**
81
+ * Emitted during animation progress.
82
+ * @event progress
83
+ * @type {{ wordsComplete: number, totalWords: number, progress: number }}
84
+ */
85
+ "progress",
86
+ /**
87
+ * Emitted when the animation is paused.
88
+ * @event pause
89
+ */
90
+ "pause",
91
+ /**
92
+ * Emitted when the animation resumes.
93
+ * @event resume
94
+ */
95
+ "resume"
96
+ ],
97
+ data() {
98
+ return {
99
+ words: [],
100
+ visibleWordCount: 0,
101
+ visibleCharsPerWord: [],
102
+ isAnimating: !1,
103
+ isPaused: !1,
104
+ isLooped: !1,
105
+ animationTimeouts: [],
106
+ prefersReducedMotion: !1,
107
+ animationKey: 0
108
+ };
109
+ },
110
+ computed: {
111
+ /**
112
+ * Get timing preset based on speed prop
113
+ */
114
+ timing() {
115
+ return w[this.speed];
116
+ },
117
+ /**
118
+ * Computed styles with timing CSS variables
119
+ */
120
+ componentStyles() {
121
+ return {
122
+ "--dt-recipe-motion-text-duration": `${this.timing.duration}ms`,
123
+ "--dt-recipe-motion-text-char-duration": `${this.timing.duration}ms`,
124
+ "--dt-recipe-motion-text-word-duration": `${this.timing.duration * 2}ms`
125
+ };
126
+ },
127
+ /**
128
+ * Check if current animation mode is static (gradient-sweep or shimmer)
129
+ */
130
+ isStaticAnimationMode() {
131
+ return this.animationMode === "gradient-sweep" || this.animationMode === "shimmer";
132
+ },
133
+ /**
134
+ * Computed classes for the motion text element
135
+ */
136
+ motionTextClasses() {
137
+ return [
138
+ "dt-recipe-motion-text",
139
+ `dt-recipe-motion-text--${this.animationMode}`,
140
+ {
141
+ "dt-recipe-motion-text--animating": this.isAnimating,
142
+ "dt-recipe-motion-text--paused": this.isPaused,
143
+ "dt-recipe-motion-text--looped": this.isLooped
144
+ },
145
+ this.$attrs.class
146
+ ];
147
+ }
148
+ },
149
+ watch: {
150
+ text() {
151
+ this.reset(), this.initializeContent();
152
+ },
153
+ loop: {
154
+ handler(t) {
155
+ this.isLooped = t;
156
+ },
157
+ immediate: !0
158
+ }
159
+ },
160
+ mounted() {
161
+ this.checkReducedMotion(), this.initializeContent();
162
+ },
163
+ beforeUnmount() {
164
+ this.clearTimeouts();
165
+ },
166
+ methods: {
167
+ /**
168
+ * Self-contained text processing from DOM nodes
169
+ */
170
+ processTextToChars(t) {
171
+ const d = [], e = (n, i = 0) => {
172
+ var r;
173
+ if (n.nodeType === Node.TEXT_NODE) {
174
+ const a = ((r = n.textContent) == null ? void 0 : r.match(/\S+\s*/g)) || [];
175
+ return d.push(...a.map((o, c) => ({
176
+ text: o,
177
+ chars: o.split(""),
178
+ index: i + c
179
+ }))), i + a.length;
180
+ } else if (n.nodeType === Node.ELEMENT_NODE) {
181
+ let a = i;
182
+ return Array.from(n.childNodes).forEach((o) => {
183
+ a = e(o, a);
184
+ }), a;
185
+ }
186
+ return i;
187
+ };
188
+ return e(t), d;
189
+ },
190
+ /**
191
+ * Process direct text prop into word/character data
192
+ */
193
+ processDirectText(t) {
194
+ return t ? (t.match(/\S+\s*/g) || []).map((e, n) => ({
195
+ text: e,
196
+ chars: e.split(""),
197
+ index: n
198
+ })) : [];
199
+ },
200
+ /**
201
+ * Check for reduced motion preference
202
+ */
203
+ checkReducedMotion() {
204
+ typeof window < "u" && window.matchMedia && (this.prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches);
205
+ },
206
+ /**
207
+ * Clear all animation timeouts
208
+ */
209
+ clearTimeouts() {
210
+ this.animationTimeouts.forEach((t) => clearTimeout(t)), this.animationTimeouts = [];
211
+ },
212
+ /**
213
+ * Start the animation
214
+ * @public
215
+ */
216
+ start() {
217
+ if (!this.isAnimating) {
218
+ if (this.isAnimating = !0, this.isPaused = !1, this.$emit("start"), this.respectsReducedMotion && this.prefersReducedMotion) {
219
+ this.showAllContent();
220
+ return;
221
+ }
222
+ if (this.animationMode === "none") {
223
+ this.showAllContent();
224
+ return;
225
+ }
226
+ this.isStaticAnimationMode || this.showNextWord();
227
+ }
228
+ },
229
+ /**
230
+ * Pause the animation
231
+ * @public
232
+ */
233
+ pause() {
234
+ !this.isAnimating || this.isPaused || (this.isPaused = !0, this.clearTimeouts(), this.$emit("pause"));
235
+ },
236
+ /**
237
+ * Resume the animation
238
+ * @public
239
+ */
240
+ resume() {
241
+ this.isPaused && (this.isPaused = !1, this.$emit("resume"), this.showNextWord());
242
+ },
243
+ /**
244
+ * Reset the animation to initial state
245
+ * @public
246
+ */
247
+ reset() {
248
+ this.clearTimeouts(), this.isAnimating = !1, this.isPaused = !1, this.visibleWordCount = 0, this.visibleCharsPerWord = Array(this.words.length).fill(0), this.animationKey++;
249
+ },
250
+ /**
251
+ * Skip to the end of the animation
252
+ * @public
253
+ */
254
+ skipToEnd() {
255
+ this.showAllContent();
256
+ },
257
+ /**
258
+ * Show all content immediately
259
+ */
260
+ showAllContent() {
261
+ this.visibleWordCount = this.words.length, this.visibleCharsPerWord = this.words.map((t) => t.chars.length), setTimeout(() => {
262
+ this.isAnimating = !1, this.$emit("complete");
263
+ }, 0);
264
+ },
265
+ /**
266
+ * Show next word in sequence
267
+ */
268
+ showNextWord() {
269
+ if (this.isPaused || this.visibleWordCount >= this.words.length) {
270
+ this.visibleWordCount >= this.words.length && this.completeAnimation();
271
+ return;
272
+ }
273
+ const t = setTimeout(() => {
274
+ this.visibleWordCount++, this.$emit("progress", {
275
+ wordsComplete: this.visibleWordCount,
276
+ totalWords: this.words.length,
277
+ progress: this.visibleWordCount / this.words.length
278
+ }), this.animateCharsForWord(this.visibleWordCount - 1);
279
+ }, this.timing.wordDelay);
280
+ this.animationTimeouts.push(t);
281
+ },
282
+ /**
283
+ * Animate characters for a specific word
284
+ */
285
+ animateCharsForWord(t) {
286
+ if (this.isPaused || t >= this.words.length) return;
287
+ this.visibleCharsPerWord[t] = 0;
288
+ const d = this.words[t].chars.length, e = () => {
289
+ if (this.isPaused || this.visibleCharsPerWord[t] >= d) {
290
+ this.visibleCharsPerWord[t] >= d && this.showNextWord();
291
+ return;
292
+ }
293
+ this.visibleCharsPerWord[t]++;
294
+ const n = setTimeout(e, this.timing.characterDelay);
295
+ this.animationTimeouts.push(n);
296
+ };
297
+ e();
298
+ },
299
+ /**
300
+ * Complete the animation
301
+ */
302
+ completeAnimation() {
303
+ if (this.isAnimating = !1, this.clearTimeouts(), this.$emit("complete"), this.loop) {
304
+ const t = setTimeout(() => {
305
+ this.reset(), this.$nextTick(() => {
306
+ this.start();
307
+ });
308
+ }, 500);
309
+ this.animationTimeouts.push(t);
310
+ }
311
+ },
312
+ /**
313
+ * Initialize content based on text prop or slot content
314
+ */
315
+ initializeContent() {
316
+ if (this.isStaticAnimationMode) {
317
+ this.autoStart && this.$nextTick(() => this.start());
318
+ return;
319
+ }
320
+ 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());
321
+ }
322
+ }
323
+ }, b = ["data-text-content", "aria-live", "aria-label"], P = {
324
+ key: 0,
325
+ class: "dt-recipe-motion-text__sr-only"
326
+ }, k = ["aria-hidden"], E = ["data-text-content"], N = {
327
+ key: 3,
328
+ class: "dt-recipe-motion-text__fallback"
329
+ };
330
+ function R(t, d, e, n, i, r) {
331
+ return s(), h("span", {
332
+ ref: "contentRef",
333
+ class: A(r.motionTextClasses),
334
+ style: u(r.componentStyles),
335
+ "data-text-content": r.isStaticAnimationMode ? e.text : void 0,
336
+ "aria-live": i.isAnimating ? "polite" : "off",
337
+ "aria-label": e.screenReaderText || void 0
338
+ }, [
339
+ e.screenReaderText ? (s(), h("span", P, f(e.screenReaderText), 1)) : l("", !0),
340
+ r.isStaticAnimationMode ? (s(), h(p, { key: 1 }, [
341
+ W(f(e.text) + " ", 1),
342
+ e.text ? l("", !0) : T(t.$slots, "default", { key: 0 })
343
+ ], 64)) : (s(), h("span", {
344
+ key: i.animationKey,
345
+ class: "dt-recipe-motion-text__content",
346
+ "aria-hidden": i.isAnimating
347
+ }, [
348
+ (s(!0), h(p, null, g(i.words, (a, o) => (s(), C(_, {
349
+ key: `${i.animationKey}-${o}`,
350
+ name: `dt-recipe-motion-text-word-${e.animationMode}`
351
+ }, {
352
+ default: x(() => [
353
+ o < i.visibleWordCount ? (s(), h("span", {
354
+ key: 0,
355
+ class: "dt-recipe-motion-text__word",
356
+ "data-text-content": a.text,
357
+ style: u({ "--word-index": o })
358
+ }, [
359
+ (s(!0), h(p, null, g(a.chars, (c, m) => (s(), C(_, {
360
+ key: `${i.animationKey}-${o}-${m}`,
361
+ name: `dt-recipe-motion-text-char-${e.animationMode}`
362
+ }, {
363
+ default: x(() => [
364
+ m < i.visibleCharsPerWord[o] ? (s(), h("span", {
365
+ key: 0,
366
+ class: "dt-recipe-motion-text__char",
367
+ style: u({
368
+ "--char-index": m,
369
+ "--char-delay": `${m * r.timing.characterDelay}ms`
370
+ })
371
+ }, f(c), 5)) : l("", !0)
372
+ ]),
373
+ _: 2
374
+ }, 1032, ["name"]))), 128))
375
+ ], 12, E)) : l("", !0)
376
+ ]),
377
+ _: 2
378
+ }, 1032, ["name"]))), 128))
379
+ ], 8, k)),
380
+ !i.words.length && !e.text && !r.isStaticAnimationMode ? (s(), h("span", N, [
381
+ T(t.$slots, "default")
382
+ ])) : l("", !0)
383
+ ], 14, b);
384
+ }
385
+ const $ = /* @__PURE__ */ v(S, [["render", R]]);
386
+ export {
387
+ $ as default
388
+ };
389
+ //# 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 :key=\"`${animationKey}-${wordIdx}`\"\n >\n <Transition\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 :key=\"`${animationKey}-${wordIdx}-${charIdx}`\"\n >\n <Transition\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","_hoisted_1","_hoisted_3","_hoisted_4","_createElementBlock","_normalizeClass","$options","_normalizeStyle","$props","$data","_hoisted_2","_toDisplayString","_createCommentVNode","_openBlock","_Fragment","_createTextVNode","_renderSlot","_ctx","_renderList","_createBlock","_Transition","_withCtx","char","charIdx","_hoisted_5"],"mappings":";;;AA8EA,MAAKA,IAAU;AAAA,EACb,cAAc,EAAE,MAAM;EACtB,MAAM;AAAA,EAEN,cAAc;AAAA,EAEd,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA;;;;;IAOX,eAAe;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,MACT,WAAW,CAACC,MAAUC,EAA4B,SAASD,CAAK;AAAA;;;;;IAOlE,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,MACT,WAAW,CAACA,MAAUE,EAAmB,SAASF,CAAK;AAAA;;;;;IAOzD,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA;;;;;IAOX,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA;;;;;IAOX,uBAAuB;AAAA,MACrB,MAAM;AAAA,MACN,SAAS;AAAA;;;;;;IAQX,kBAAkB;AAAA,MAChB,MAAM;AAAA,MACN,SAAS;AAAA;;EAIb,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA;AAAA;EAGF,OAAQ;AACN,WAAO;AAAA,MACL,OAAO,CAAA;AAAA,MACP,kBAAkB;AAAA,MAClB,qBAAqB,CAAA;AAAA,MACrB,aAAa;AAAA,MACb,UAAU;AAAA,MACV,UAAU;AAAA,MACV,mBAAmB,CAAA;AAAA,MACnB,sBAAsB;AAA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AAA,YA5DjB,KAAA;AAAA,YAuCY,OAAM;AAAA,YACL,qBAAmBP,EAAK;AAAA,YACxB,OAzCbU,oBAyCsCT,EAAO,CAAA;AAAA;oBAEjCM,EAgBWU,GAAA,MA3DvBI,EA4CwCrB,EAAK,OA5C7C,CA4CsByB,GAAMC,YAGdJ,EAWaC,GAAA;AAAA,cA1D3B,KAAA,GA6CuBX,EAAA,YAAY,IAAIX,CAAO,IAAIyB,CAAO;AAAA,cAGxC,oCAAoCf,EAAA,aAAa;AAAA;cAhDlE,SAAAa,EAkDgB,MAOkB;AAAA,gBANVE,IAAUd,EAAA,oBAAoBX,CAAO,UAD7CM,EAOkB,QAAA;AAAA,kBAzDlC,KAAA;AAAA,kBAoDkB,OAAM;AAAA,kBACL,OArDnBG,EAAA;AAAA,oCAqDgEgB;AAAA,uCAAgDA,IAAUjB,EAAA,OAAO,cAAc;AAAA;qBAI3HgB,CAAI,GAAA,CAAA,KAzDxBV,EAAA,IAAA,EAAA;AAAA;cAAA,GAAA;AAAA;UAAA,GAAA,IAAAT,CAAA,KAAAS,EAAA,IAAA,EAAA;AAAA;QAAA,GAAA;AAAA;IAAA,GAAA,GAAAV,CAAA;AAAA,IAmEa,CAAAO,EAAA,MAAM,UAAM,CAAKD,EAAA,SAASF,EAAA,yBADnCO,KAAAT,EAKO,QALPoB,GAKO;AAAA,MADLR,EAAQC,EAAA,QAAA,SAAA;AAAA,UAtEdL,EAAA,IAAA,EAAA;AAAA,EAAA,GAAA,IAAAX,CAAA;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("./popover-constants.cjs"),a=require("../../common/utils/index.cjs"),f=require("../../common/mixins/modal.cjs"),u=require("./tippy-utils.cjs"),m=require("./popover-header-footer.cjs"),v=require("../../shared/sr_only_close_button.cjs"),n=require("vue"),y=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),E=require("../lazy-show/lazy-show.cjs"),g={compatConfig:{MODE:3},name:"DtPopover",components:{SrOnlyCloseButton:v.default,DtLazyShow:E.default,PopoverHeaderFooter:m.default},mixins:[f.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:e=>d.POPOVER_ROLES.includes(e)},ariaLabelledby:{type:String,default:null},ariaLabel:{type:String,default:null},padding:{type:String,default:"large",validator:e=>Object.keys(d.POPOVER_PADDING_CLASSES).some(t=>t===e)},contentClass:{type:[String,Array,Object],default:""},contentWidth:{type:String,default:"",validator:e=>d.POPOVER_CONTENT_WIDTHS.includes(e)},contentAppear:{type:Boolean,default:null},contentTabindex:{type:Number||null,default:-1},externalAnchor:{type:String,default:""},id:{type:String,default(){return a.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:e=>d.POPOVER_STICKY_VALUES.includes(e)},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:e=>d.POPOVER_INITIAL_FOCUS_STRINGS.includes(e)||e instanceof HTMLElement||e.startsWith("#")},openWithArrowKeys:{type:Boolean,default:!1},appendTo:{type:[HTMLElement,String],default:"body",validator:e=>d.POPOVER_APPEND_TO_VALUES.includes(e)||e instanceof HTMLElement}},emits:["keydown","update:open","opened","mouseenter-popover","mouseleave-popover","mouseenter-popover-anchor","mouseleave-popover-anchor"],data(){return{POPOVER_PADDING_CLASSES:d.POPOVER_PADDING_CLASSES,POPOVER_HEADER_FOOTER_PADDING_CLASSES:d.POPOVER_HEADER_FOOTER_PADDING_CLASSES,intersectionObserver:null,mutationObserver:null,isOutsideViewport:!1,isOpen:!1,toAppear:!1,anchorEl:null,popoverContentEl:null,hasSlotContent:a.hasSlotContent}},computed:{popoverListeners(){return{keydown:e=>{this.onKeydown(e)},"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&&a.getUniqueString("DtPopover__anchor")}},watch:{$props:{immediate:!0,deep:!0,handler(){this.validateProps()}},modal(e){var t;(t=this.tip)==null||t.setProps({zIndex:e?650:this.calculateAnchorZindex()})},offset(e){var t;(t=this.tip)==null||t.setProps({offset:e})},sticky(e){var t;(t=this.tip)==null||t.setProps({sticky:e})},fallbackPlacements(){var e;(e=this.tip)==null||e.setProps({popperOptions:this.popperOptions()})},tether(){var e;(e=this.tip)==null||e.setProps({popperOptions:this.popperOptions()})},placement(e){var t;(t=this.tip)==null||t.setProps({placement:e})},open:{handler:function(e){e!==null&&(this.isOpen=e),e===!0&&(this.toAppear=!0)},immediate:!0},contentAppear:{handler:function(e){e!==null&&(this.toAppear=e)}},isOpen(e,t){var o,i;e?(this.initTippyInstance(),(o=this.tip)==null||o.show()):!e&&t!==e&&(this.removeEventListeners(),(i=this.tip)==null||i.hide())}},mounted(){var e;a.warnIfUnmounted(a.returnFirstEl(this.$el),this.$options.name),this.popoverContentEl=a.returnFirstEl((e=this.$refs.content)==null?void 0:e.$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)},beforeUnmount(){var e,t,o;(e=this.tip)==null||e.destroy(),(t=this.intersectionObserver)==null||t.disconnect(),(o=this.mutationObserver)==null||o.disconnect(),this.removeReferences(),this.removeEventListeners()},methods:{hasIntersectedViewport(e){var i;const t=(i=e==null?void 0:e[0])==null?void 0:i.target;if(!t)return;const o=a.isOutOfViewPort(t);this.isOutsideViewport=o.bottom||o.top},updateAnchorEl(){var t,o;const e=this.externalAnchor?this.$refs.anchor.getRootNode().querySelector(`#${this.externalAnchor}`):null;if(this.anchorEl=e??this.$refs.anchor.children[0],(t=this.tip)==null||t.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 u.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 e;return a.returnFirstEl(this.$el).getRootNode().querySelector('.d-modal[aria-hidden="false"], .d-modal--transparent[aria-hidden="false"]')||(e=this.anchorEl)!=null&&e.closest(".d-zi-drawer")?650:300},defaultToggleOpen(e){var t,o,i;if(!this.openOnContext&&(this.open===null||this.open===void 0)){if(!((t=this.anchorEl)!=null&&t.contains(e.target))&&!((o=this.anchorEl)!=null&&o.isEqualNode(e.target))||(i=this.anchorEl)!=null&&i.disabled)return;this.toggleOpen()}},async onContext(e){var t;this.openOnContext&&(e.preventDefault(),this.isOpen=!0,await this.$nextTick(),(t=this.tip)==null||t.setProps({placement:"right-start",getReferenceClientRect:()=>({width:0,height:0,top:e.clientY,bottom:e.clientY,left:e.clientX,right:e.clientX})}))},toggleOpen(){this.isOpen=!this.isOpen},onArrowKeyPress(e){var t;this.open===null&&(this.openWithArrowKeys&&((t=this.anchorEl)!=null&&t.contains(e.target))&&(this.isOpen||(this.isOpen=!0)),this.$emit("keydown",e))},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 e,t,o;if(this.modal){const i=(e=this.anchorEl)==null?void 0:e.closest("body, .tippy-box");if(!i)return;((t=i.tagName)==null?void 0:t.toLowerCase())==="body"?(a.disableRootScrolling(this.anchorEl.getRootNode().host),(o=this.tip)==null||o.setProps({offset:this.offset})):i.classList.add("d-zi-popover")}},enableScrolling(){var t,o,i;const e=(t=this.anchorEl)==null?void 0:t.closest("body, .tippy-box");e&&(((o=e.tagName)==null?void 0:o.toLowerCase())==="body"?(a.enableRootScrolling(this.anchorEl.getRootNode().host),(i=this.tip)==null||i.setProps({offset:this.offset})):e.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 e;this.modal&&(await this.focusFirstElement(this.$refs.anchor),await this.$nextTick(),this.enableScrolling()),(e=this.tip)==null||e.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 e,t;this.initialFocusElement==="dialog"&&((t=a.returnFirstEl((e=this.$refs.content)==null?void 0:e.$el))==null||t.focus()),this.initialFocusElement.startsWith("#")&&this.focusInitialElementById(),this.initialFocusElement==="first"&&this.focusFirstElementIfNeeded(this.$refs.popover__content),this.initialFocusElement instanceof HTMLElement&&this.initialFocusElement.focus()},focusInitialElementById(){var t,o,i;const e=(o=a.returnFirstEl((t=this.$refs.content)==null?void 0:t.$el))==null?void 0:o.querySelector(this.initialFocusElement);e?e.focus():console.warn('Could not find the element specified in dt-popover prop "initialFocusElement". Defaulting to focusing the dialog.'),e?e.focus():a.returnFirstEl((i=this.$refs.content)==null?void 0:i.$el).focus()},onResize(){this.closePopover()},onClickOutside(){var t;if(!this.hideOnClick)return;((t=this.popoverContentEl)==null?void 0:t.querySelector(".d-popover__anchor--opened"))||this.closePopover()},onKeydown(e){e.key==="Tab"&&this.modal&&this.focusTrappedTabPress(e,this.popoverContentEl),e.key==="Escape"&&this.closePopover(),this.$emit("keydown",e)},async setPopoverContentAnchorWidth(){var e;await this.$nextTick(),this.popoverContentEl.style.width=`${(e=this.anchorEl)==null?void 0:e.clientWidth}px`},focusFirstElementIfNeeded(e){var o,i;this._getFocusableElements(e,!0).length!==0?this.focusFirstElement(e):this.showCloseButton?(o=this.$refs.popover__header)==null||o.focusCloseButton():a.returnFirstEl((i=this.$refs.content)==null?void 0:i.$el).focus()},getReferenceClientRect(e){var h,p;const t=(h=this.anchorEl)==null?void 0:h.getBoundingClientRect();if(this.appendTo!=="root"||e)return t;const o=(p=this.anchorEl)==null?void 0:p.ownerDocument,i=(o==null?void 0:o.defaultView)||(o==null?void 0:o.parentWindow),r=i==null?void 0:i.frameElement;if(!r)return t;const s=r.getBoundingClientRect();return{width:t==null?void 0:t.width,height:t==null?void 0:t.height,top:(s==null?void 0:s.top)+(t==null?void 0:t.top),left:(s==null?void 0:s.left)+(t==null?void 0:t.left),right:(s==null?void 0:s.right)+(t==null?void 0:t.right),bottom:(s==null?void 0:s.bottom)+(t==null?void 0:t.bottom)}},initTippyInstance(){var o,i,r;let e=null,t=!1;switch(this.appendTo){case"body":e=(i=(o=this.anchorEl)==null?void 0:o.getRootNode())==null?void 0:i.querySelector("body");break;case"root":try{e=window.parent.document.body}catch(s){console.error("Could not attach the popover to iframe parent window: ",s),e="parent",t=!0}break;default:e=this.appendTo;break}(r=this.tip)==null||r.destroy(),this.tip=u.createTippyPopover(this.anchorEl,{popperOptions:this.popperOptions(),contentElement:this.popoverContentEl,placement:this.placement,offset:this.offset,sticky:this.sticky,appendTo:e,interactive:!0,trigger:"manual",getReferenceClientRect:()=>this.getReferenceClientRect(t),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")}}},C=["id","data-qa","tabindex"],O=["data-qa"];function b(e,t,o,i,r,s){const h=n.resolveComponent("popover-header-footer"),p=n.resolveComponent("sr-only-close-button"),c=n.resolveComponent("dt-lazy-show");return n.openBlock(),n.createElementBlock("div",null,[o.modal&&r.isOpen?(n.openBlock(),n.createBlock(n.Teleport,{key:0,to:"body"},[n.createElementVNode("div",{class:"d-modal--transparent","aria-hidden":"false",onClick:t[0]||(t[0]=n.withModifiers(()=>{},["prevent","stop"]))})])):n.createCommentVNode("",!0),(n.openBlock(),n.createBlock(n.resolveDynamicComponent(o.elementType),{ref:"popover",class:n.normalizeClass(["d-popover",{"d-popover__anchor--opened":r.isOpen}]),"data-qa":"dt-popover-container"},{default:n.withCtx(()=>[n.createElementVNode("div",{id:!o.ariaLabelledby&&s.labelledBy,ref:"anchor","data-qa":e.$attrs["data-qa"]?`${e.$attrs["data-qa"]}-anchor`:"dt-popover-anchor",tabindex:o.openOnContext?0:void 0,onClickCapture:t[1]||(t[1]=(...l)=>s.defaultToggleOpen&&s.defaultToggleOpen(...l)),onContextmenu:t[2]||(t[2]=(...l)=>s.onContext&&s.onContext(...l)),onKeydown:[t[3]||(t[3]=n.withKeys(n.withModifiers((...l)=>s.onArrowKeyPress&&s.onArrowKeyPress(...l),["prevent"]),["up"])),t[4]||(t[4]=n.withKeys(n.withModifiers((...l)=>s.onArrowKeyPress&&s.onArrowKeyPress(...l),["prevent"]),["down"])),t[6]||(t[6]=n.withKeys(l=>e.$emit("keydown",l),["enter"])),t[7]||(t[7]=n.withKeys(l=>e.$emit("keydown",l),["space"]))],onKeydownCapture:t[5]||(t[5]=n.withKeys((...l)=>s.closePopover&&s.closePopover(...l),["escape"])),onMouseenter:t[8]||(t[8]=(...l)=>s.onMouseEnter&&s.onMouseEnter(...l)),onMouseleave:t[9]||(t[9]=(...l)=>s.onMouseLeave&&s.onMouseLeave(...l))},[n.renderSlot(e.$slots,"anchor",{attrs:{"aria-expanded":r.isOpen.toString(),"aria-controls":o.id,"aria-haspopup":o.role}})],40,C),n.createVNode(c,n.mergeProps({id:o.id,ref:"content",role:o.role,"data-qa":e.$attrs["data-qa"]?`${e.$attrs["data-qa"]}__dialog`:"dt-popover","aria-hidden":`${!r.isOpen}`,"aria-labelledby":s.labelledBy,"aria-label":o.ariaLabel,"aria-modal":`${!o.modal}`,transition:o.transition,show:r.isOpen,appear:r.toAppear,class:["d-popover__dialog",{"d-popover__dialog--modal":o.modal},o.dialogClass],style:{"max-height":s.calculatedMaxHeight,"max-width":o.maxWidth},css:e.$attrs.css,tabindex:o.contentTabindex},n.toHandlers(s.popoverListeners),{onMouseenter:s.onMouseEnterAnchor,onMouseleave:s.onMouseLeaveAnchor}),{default:n.withCtx(()=>[r.hasSlotContent(e.$slots.headerContent)||o.showCloseButton?(n.openBlock(),n.createBlock(h,{key:0,ref:"popover__header",class:n.normalizeClass(r.POPOVER_HEADER_FOOTER_PADDING_CLASSES[o.padding]),"content-class":o.headerClass,type:"header","show-close-button":o.showCloseButton,onClose:s.closePopover},{content:n.withCtx(()=>[n.renderSlot(e.$slots,"headerContent",{close:s.closePopover})]),_:3},8,["class","content-class","show-close-button","onClose"])):n.createCommentVNode("",!0),n.createElementVNode("div",{ref:"popover__content","data-qa":e.$attrs["data-qa"]?`${e.$attrs["data-qa"]}-content`:"dt-popover-content",class:n.normalizeClass(["d-popover__content",r.POPOVER_PADDING_CLASSES[o.padding],o.contentClass])},[n.renderSlot(e.$slots,"content",{close:s.closePopover})],10,O),r.hasSlotContent(e.$slots.footerContent)?(n.openBlock(),n.createBlock(h,{key:1,ref:"popover__footer",type:"footer",class:n.normalizeClass(r.POPOVER_HEADER_FOOTER_PADDING_CLASSES[o.padding]),"content-class":o.footerClass},{content:n.withCtx(()=>[n.renderSlot(e.$slots,"footerContent",{close:s.closePopover})]),_:3},8,["class","content-class"])):n.createCommentVNode("",!0),o.showCloseButton?n.createCommentVNode("",!0):(n.openBlock(),n.createBlock(p,{key:2,onClose:s.closePopover},null,8,["onClose"]))]),_:3},16,["id","role","data-qa","aria-hidden","aria-labelledby","aria-label","aria-modal","transition","show","appear","class","style","css","tabindex","onMouseenter","onMouseleave"])]),_:3},8,["class"]))])}const w=y._(g,[["render",b]]);exports.default=w;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("./popover-constants.cjs"),a=require("../../common/utils/index.cjs"),f=require("../../common/mixins/modal.cjs"),u=require("./tippy-utils.cjs"),m=require("./popover-header-footer.cjs"),v=require("../../shared/sr_only_close_button.cjs"),n=require("vue"),E=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),y=require("../lazy-show/lazy-show.cjs"),g={compatConfig:{MODE:3},name:"DtPopover",components:{SrOnlyCloseButton:v.default,DtLazyShow:y.default,PopoverHeaderFooter:m.default},mixins:[f.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:e=>d.POPOVER_ROLES.includes(e)},ariaLabelledby:{type:String,default:null},ariaLabel:{type:String,default:null},padding:{type:String,default:"large",validator:e=>Object.keys(d.POPOVER_PADDING_CLASSES).some(t=>t===e)},contentClass:{type:[String,Array,Object],default:""},contentWidth:{type:String,default:"",validator:e=>d.POPOVER_CONTENT_WIDTHS.includes(e)},contentAppear:{type:Boolean,default:null},contentTabindex:{type:Number||null,default:-1},externalAnchor:{type:String,default:""},id:{type:String,default(){return a.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:e=>d.POPOVER_STICKY_VALUES.includes(e)},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:e=>d.POPOVER_INITIAL_FOCUS_STRINGS.includes(e)||e instanceof HTMLElement||e.startsWith("#")},openWithArrowKeys:{type:Boolean,default:!1},appendTo:{type:[HTMLElement,String],default:"body",validator:e=>d.POPOVER_APPEND_TO_VALUES.includes(e)||e instanceof HTMLElement}},emits:["keydown","update:open","opened","mouseenter-popover","mouseleave-popover","mouseenter-popover-anchor","mouseleave-popover-anchor"],data(){return{POPOVER_PADDING_CLASSES:d.POPOVER_PADDING_CLASSES,POPOVER_HEADER_FOOTER_PADDING_CLASSES:d.POPOVER_HEADER_FOOTER_PADDING_CLASSES,intersectionObserver:null,mutationObserver:null,isOutsideViewport:!1,isOpen:!1,toAppear:!1,anchorEl:null,popoverContentEl:null,hasSlotContent:a.hasSlotContent}},computed:{popoverListeners(){return{keydown:e=>{this.onKeydown(e)},"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&&a.getUniqueString("DtPopover__anchor")}},watch:{$props:{immediate:!0,deep:!0,handler(){this.validateProps()}},modal(e){var t;(t=this.tip)==null||t.setProps({zIndex:e?650:this.calculateAnchorZindex()})},offset(e){var t;(t=this.tip)==null||t.setProps({offset:e})},sticky(e){var t;(t=this.tip)==null||t.setProps({sticky:e})},fallbackPlacements(){var e;(e=this.tip)==null||e.setProps({popperOptions:this.popperOptions()})},tether(){var e;(e=this.tip)==null||e.setProps({popperOptions:this.popperOptions()})},placement(e){var t;(t=this.tip)==null||t.setProps({placement:e})},open:{handler:function(e){e!==null&&(this.isOpen=e),e===!0&&(this.toAppear=!0)},immediate:!0},contentAppear:{handler:function(e){e!==null&&(this.toAppear=e)}},isOpen(e,t){var o,i;e?(this.initTippyInstance(),(o=this.tip)==null||o.show()):!e&&t!==e&&(this.removeEventListeners(),(i=this.tip)==null||i.hide())}},mounted(){var e;a.warnIfUnmounted(a.returnFirstEl(this.$el),this.$options.name),this.popoverContentEl=a.returnFirstEl((e=this.$refs.content)==null?void 0:e.$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)},beforeUnmount(){var e,t,o;(e=this.tip)==null||e.destroy(),(t=this.intersectionObserver)==null||t.disconnect(),(o=this.mutationObserver)==null||o.disconnect(),this.removeReferences(),this.removeEventListeners()},methods:{hasIntersectedViewport(e){var i;const t=(i=e==null?void 0:e[0])==null?void 0:i.target;if(!t)return;const o=a.isOutOfViewPort(t);this.isOutsideViewport=o.bottom||o.top},updateAnchorEl(){var o,i;const t=(this.externalAnchor?this.$refs.anchor.getRootNode().querySelector(`#${this.externalAnchor}`):null)??this.$refs.anchor.children[0];if(t!==this.anchorEl){if(this.anchorEl=t,(o=this.tip)==null||o.destroy(),delete this.tip,!this.anchorEl){console.warn("No anchor found for popover");return}this.isOpen&&(this.initTippyInstance(),(i=this.tip)==null||i.show())}},popperOptions(){return u.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 e;return a.returnFirstEl(this.$el).getRootNode().querySelector('.d-modal[aria-hidden="false"], .d-modal--transparent[aria-hidden="false"]')||(e=this.anchorEl)!=null&&e.closest(".d-zi-drawer")?650:300},defaultToggleOpen(e){var t,o,i;if(!this.openOnContext&&(this.open===null||this.open===void 0)){if(!((t=this.anchorEl)!=null&&t.contains(e.target))&&!((o=this.anchorEl)!=null&&o.isEqualNode(e.target))||(i=this.anchorEl)!=null&&i.disabled)return;this.toggleOpen()}},async onContext(e){var t;this.openOnContext&&(e.preventDefault(),this.isOpen=!0,await this.$nextTick(),(t=this.tip)==null||t.setProps({placement:"right-start",getReferenceClientRect:()=>({width:0,height:0,top:e.clientY,bottom:e.clientY,left:e.clientX,right:e.clientX})}))},toggleOpen(){this.isOpen=!this.isOpen},onArrowKeyPress(e){var t;this.open===null&&(this.openWithArrowKeys&&((t=this.anchorEl)!=null&&t.contains(e.target))&&(this.isOpen||(this.isOpen=!0)),this.$emit("keydown",e))},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 e,t,o;if(this.modal){const i=(e=this.anchorEl)==null?void 0:e.closest("body, .tippy-box");if(!i)return;((t=i.tagName)==null?void 0:t.toLowerCase())==="body"?(a.disableRootScrolling(this.anchorEl.getRootNode().host),(o=this.tip)==null||o.setProps({offset:this.offset})):i.classList.add("d-zi-popover")}},enableScrolling(){var t,o,i;const e=(t=this.anchorEl)==null?void 0:t.closest("body, .tippy-box");e&&(((o=e.tagName)==null?void 0:o.toLowerCase())==="body"?(a.enableRootScrolling(this.anchorEl.getRootNode().host),(i=this.tip)==null||i.setProps({offset:this.offset})):e.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 e;this.modal&&(await this.focusFirstElement(this.$refs.anchor),await this.$nextTick(),this.enableScrolling()),(e=this.tip)==null||e.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 e,t;this.initialFocusElement==="dialog"&&((t=a.returnFirstEl((e=this.$refs.content)==null?void 0:e.$el))==null||t.focus()),this.initialFocusElement.startsWith("#")&&this.focusInitialElementById(),this.initialFocusElement==="first"&&this.focusFirstElementIfNeeded(this.$refs.popover__content),this.initialFocusElement instanceof HTMLElement&&this.initialFocusElement.focus()},focusInitialElementById(){var t,o,i;const e=(o=a.returnFirstEl((t=this.$refs.content)==null?void 0:t.$el))==null?void 0:o.querySelector(this.initialFocusElement);e?e.focus():console.warn('Could not find the element specified in dt-popover prop "initialFocusElement". Defaulting to focusing the dialog.'),e?e.focus():a.returnFirstEl((i=this.$refs.content)==null?void 0:i.$el).focus()},onResize(){this.closePopover()},onClickOutside(){var t;if(!this.hideOnClick)return;((t=this.popoverContentEl)==null?void 0:t.querySelector(".d-popover__anchor--opened"))||this.closePopover()},onKeydown(e){e.key==="Tab"&&this.modal&&this.focusTrappedTabPress(e,this.popoverContentEl),e.key==="Escape"&&this.closePopover(),this.$emit("keydown",e)},async setPopoverContentAnchorWidth(){var e;await this.$nextTick(),this.popoverContentEl.style.width=`${(e=this.anchorEl)==null?void 0:e.clientWidth}px`},focusFirstElementIfNeeded(e){var o,i;this._getFocusableElements(e,!0).length!==0?this.focusFirstElement(e):this.showCloseButton?(o=this.$refs.popover__header)==null||o.focusCloseButton():a.returnFirstEl((i=this.$refs.content)==null?void 0:i.$el).focus()},getReferenceClientRect(e){var h,p;const t=(h=this.anchorEl)==null?void 0:h.getBoundingClientRect();if(this.appendTo!=="root"||e)return t;const o=(p=this.anchorEl)==null?void 0:p.ownerDocument,i=(o==null?void 0:o.defaultView)||(o==null?void 0:o.parentWindow),r=i==null?void 0:i.frameElement;if(!r)return t;const s=r.getBoundingClientRect();return{width:t==null?void 0:t.width,height:t==null?void 0:t.height,top:(s==null?void 0:s.top)+(t==null?void 0:t.top),left:(s==null?void 0:s.left)+(t==null?void 0:t.left),right:(s==null?void 0:s.right)+(t==null?void 0:t.right),bottom:(s==null?void 0:s.bottom)+(t==null?void 0:t.bottom)}},initTippyInstance(){var o,i,r;let e=null,t=!1;switch(this.appendTo){case"body":e=(i=(o=this.anchorEl)==null?void 0:o.getRootNode())==null?void 0:i.querySelector("body");break;case"root":try{e=window.parent.document.body}catch(s){console.error("Could not attach the popover to iframe parent window: ",s),e="parent",t=!0}break;default:e=this.appendTo;break}(r=this.tip)==null||r.destroy(),this.tip=u.createTippyPopover(this.anchorEl,{popperOptions:this.popperOptions(),contentElement:this.popoverContentEl,placement:this.placement,offset:this.offset,sticky:this.sticky,appendTo:e,interactive:!0,trigger:"manual",getReferenceClientRect:()=>this.getReferenceClientRect(t),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")}}},C=["id","data-qa","tabindex"],O=["data-qa"];function b(e,t,o,i,r,s){const h=n.resolveComponent("popover-header-footer"),p=n.resolveComponent("sr-only-close-button"),c=n.resolveComponent("dt-lazy-show");return n.openBlock(),n.createElementBlock("div",null,[o.modal&&r.isOpen?(n.openBlock(),n.createBlock(n.Teleport,{key:0,to:"body"},[n.createElementVNode("div",{class:"d-modal--transparent","aria-hidden":"false",onClick:t[0]||(t[0]=n.withModifiers(()=>{},["prevent","stop"]))})])):n.createCommentVNode("",!0),(n.openBlock(),n.createBlock(n.resolveDynamicComponent(o.elementType),{ref:"popover",class:n.normalizeClass(["d-popover",{"d-popover__anchor--opened":r.isOpen}]),"data-qa":"dt-popover-container"},{default:n.withCtx(()=>[n.createElementVNode("div",{id:!o.ariaLabelledby&&s.labelledBy,ref:"anchor","data-qa":e.$attrs["data-qa"]?`${e.$attrs["data-qa"]}-anchor`:"dt-popover-anchor",tabindex:o.openOnContext?0:void 0,onClickCapture:t[1]||(t[1]=(...l)=>s.defaultToggleOpen&&s.defaultToggleOpen(...l)),onContextmenu:t[2]||(t[2]=(...l)=>s.onContext&&s.onContext(...l)),onKeydown:[t[3]||(t[3]=n.withKeys(n.withModifiers((...l)=>s.onArrowKeyPress&&s.onArrowKeyPress(...l),["prevent"]),["up"])),t[4]||(t[4]=n.withKeys(n.withModifiers((...l)=>s.onArrowKeyPress&&s.onArrowKeyPress(...l),["prevent"]),["down"])),t[6]||(t[6]=n.withKeys(l=>e.$emit("keydown",l),["enter"])),t[7]||(t[7]=n.withKeys(l=>e.$emit("keydown",l),["space"]))],onKeydownCapture:t[5]||(t[5]=n.withKeys((...l)=>s.closePopover&&s.closePopover(...l),["escape"])),onMouseenter:t[8]||(t[8]=(...l)=>s.onMouseEnter&&s.onMouseEnter(...l)),onMouseleave:t[9]||(t[9]=(...l)=>s.onMouseLeave&&s.onMouseLeave(...l))},[n.renderSlot(e.$slots,"anchor",{attrs:{"aria-expanded":r.isOpen.toString(),"aria-controls":o.id,"aria-haspopup":o.role}})],40,C),n.createVNode(c,n.mergeProps({id:o.id,ref:"content",role:o.role,"data-qa":e.$attrs["data-qa"]?`${e.$attrs["data-qa"]}__dialog`:"dt-popover","aria-hidden":`${!r.isOpen}`,"aria-labelledby":s.labelledBy,"aria-label":o.ariaLabel,"aria-modal":`${!o.modal}`,transition:o.transition,show:r.isOpen,appear:r.toAppear,class:["d-popover__dialog",{"d-popover__dialog--modal":o.modal},o.dialogClass],style:{"max-height":s.calculatedMaxHeight,"max-width":o.maxWidth},css:e.$attrs.css,tabindex:o.contentTabindex},n.toHandlers(s.popoverListeners),{onMouseenter:s.onMouseEnterAnchor,onMouseleave:s.onMouseLeaveAnchor}),{default:n.withCtx(()=>[r.hasSlotContent(e.$slots.headerContent)||o.showCloseButton?(n.openBlock(),n.createBlock(h,{key:0,ref:"popover__header",class:n.normalizeClass(r.POPOVER_HEADER_FOOTER_PADDING_CLASSES[o.padding]),"content-class":o.headerClass,type:"header","show-close-button":o.showCloseButton,onClose:s.closePopover},{content:n.withCtx(()=>[n.renderSlot(e.$slots,"headerContent",{close:s.closePopover})]),_:3},8,["class","content-class","show-close-button","onClose"])):n.createCommentVNode("",!0),n.createElementVNode("div",{ref:"popover__content","data-qa":e.$attrs["data-qa"]?`${e.$attrs["data-qa"]}-content`:"dt-popover-content",class:n.normalizeClass(["d-popover__content",r.POPOVER_PADDING_CLASSES[o.padding],o.contentClass])},[n.renderSlot(e.$slots,"content",{close:s.closePopover})],10,O),r.hasSlotContent(e.$slots.footerContent)?(n.openBlock(),n.createBlock(h,{key:1,ref:"popover__footer",type:"footer",class:n.normalizeClass(r.POPOVER_HEADER_FOOTER_PADDING_CLASSES[o.padding]),"content-class":o.footerClass},{content:n.withCtx(()=>[n.renderSlot(e.$slots,"footerContent",{close:s.closePopover})]),_:3},8,["class","content-class"])):n.createCommentVNode("",!0),o.showCloseButton?n.createCommentVNode("",!0):(n.openBlock(),n.createBlock(p,{key:2,onClose:s.closePopover},null,8,["onClose"]))]),_:3},16,["id","role","data-qa","aria-hidden","aria-labelledby","aria-label","aria-modal","transition","show","appear","class","style","css","tabindex","onMouseenter","onMouseleave"])]),_:3},8,["class"]))])}const w=E._(g,[["render",b]]);exports.default=w;
2
2
  //# sourceMappingURL=popover.cjs.map