@designbasekorea/ui-wc 0.5.5 → 0.5.6

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 (155) hide show
  1. package/dist/chunks/lottie-e273b936.js +17032 -0
  2. package/dist/esm/components/animation-background/canvas-controller.js +121 -1
  3. package/dist/esm/components/animation-background/controls.js +180 -1
  4. package/dist/esm/components/animation-background/graphite-controller.js +196 -1
  5. package/dist/esm/components/animation-background/graphite-presets.js +42 -1
  6. package/dist/esm/components/animation-background/graphite-shader.js +111 -1
  7. package/dist/esm/components/animation-background/layers.js +369 -1
  8. package/dist/esm/components/animation-background/lumina-presets.js +53 -1
  9. package/dist/esm/components/animation-background/lumina-shaders.js +181 -1
  10. package/dist/esm/components/animation-background/lumina-utils.js +60 -1
  11. package/dist/esm/components/animation-background/particle-defaults.js +36 -1
  12. package/dist/esm/components/animation-background/renderers.js +167 -1
  13. package/dist/esm/components/animation-background/shader-controller.js +154 -1
  14. package/dist/esm/components/color-picker-utils.js +134 -1
  15. package/dist/esm/components/date-picker-utils.js +140 -1
  16. package/dist/esm/components/db-accordion.js +304 -1
  17. package/dist/esm/components/db-ad-banner.js +455 -1
  18. package/dist/esm/components/db-alert.js +149 -1
  19. package/dist/esm/components/db-animation-background.js +486 -1
  20. package/dist/esm/components/db-animation-text.js +601 -1
  21. package/dist/esm/components/db-app-badge.js +88 -1
  22. package/dist/esm/components/db-audio-player.js +752 -1
  23. package/dist/esm/components/db-avatar.js +188 -1
  24. package/dist/esm/components/db-backdrop.js +139 -1
  25. package/dist/esm/components/db-badge.js +91 -1
  26. package/dist/esm/components/db-banner.js +188 -1
  27. package/dist/esm/components/db-bottom-navigation.js +146 -1
  28. package/dist/esm/components/db-bottom-sheet.js +481 -1
  29. package/dist/esm/components/db-breadcrumbs.js +329 -1
  30. package/dist/esm/components/db-button.js +316 -1
  31. package/dist/esm/components/db-calendar.js +675 -1
  32. package/dist/esm/components/db-card.js +265 -1
  33. package/dist/esm/components/db-carousel.js +264 -1
  34. package/dist/esm/components/db-checkbox.js +202 -1
  35. package/dist/esm/components/db-chip.js +104 -1
  36. package/dist/esm/components/db-code-block.js +304 -1
  37. package/dist/esm/components/db-color-picker.js +746 -1
  38. package/dist/esm/components/db-confirm.js +191 -1
  39. package/dist/esm/components/db-container.js +39 -1
  40. package/dist/esm/components/db-context-menu.js +265 -1
  41. package/dist/esm/components/db-countdown.js +146 -1
  42. package/dist/esm/components/db-cursor-follower.js +173 -1
  43. package/dist/esm/components/db-date-picker.js +837 -1
  44. package/dist/esm/components/db-divider.js +66 -1
  45. package/dist/esm/components/db-drawer.js +245 -1
  46. package/dist/esm/components/db-dropdown.js +493 -1
  47. package/dist/esm/components/db-dropzone.js +266 -1
  48. package/dist/esm/components/db-empty-state.js +97 -1
  49. package/dist/esm/components/db-file-uploader.js +256 -1
  50. package/dist/esm/components/db-floating-action-button.js +139 -1
  51. package/dist/esm/components/db-footer.js +385 -1
  52. package/dist/esm/components/db-form.js +566 -1
  53. package/dist/esm/components/db-gantt.js +882 -1
  54. package/dist/esm/components/db-gradient.js +133 -1
  55. package/dist/esm/components/db-grid-background.js +909 -1
  56. package/dist/esm/components/db-grid.js +73 -1
  57. package/dist/esm/components/db-icons.js +82 -1
  58. package/dist/esm/components/db-image-list.js +214 -1
  59. package/dist/esm/components/db-image-placeholder.js +96 -1
  60. package/dist/esm/components/db-image.js +289 -1
  61. package/dist/esm/components/db-indicator.js +517 -1
  62. package/dist/esm/components/db-input.js +420 -1
  63. package/dist/esm/components/db-kanban.js +538 -1
  64. package/dist/esm/components/db-label.js +66 -1
  65. package/dist/esm/components/db-lightbox.js +372 -1
  66. package/dist/esm/components/db-list.js +340 -1
  67. package/dist/esm/components/db-logo-svg.js +72 -1
  68. package/dist/esm/components/db-logo.js +106 -1
  69. package/dist/esm/components/db-lottie.js +109 -1
  70. package/dist/esm/components/db-markdown-editor.js +458 -1
  71. package/dist/esm/components/db-marquee.js +402 -1
  72. package/dist/esm/components/db-masonry.js +94 -1
  73. package/dist/esm/components/db-menu-item.js +211 -1
  74. package/dist/esm/components/db-modal.js +522 -1
  75. package/dist/esm/components/db-navbar.js +680 -1
  76. package/dist/esm/components/db-onboarding-modal.js +322 -1
  77. package/dist/esm/components/db-page-header.js +312 -1
  78. package/dist/esm/components/db-pagination.js +271 -1
  79. package/dist/esm/components/db-popover.js +580 -1
  80. package/dist/esm/components/db-progress-step.js +166 -1
  81. package/dist/esm/components/db-progress.js +171 -1
  82. package/dist/esm/components/db-progressbar.js +72 -1
  83. package/dist/esm/components/db-radio.js +172 -1
  84. package/dist/esm/components/db-random-gradient.js +121 -1
  85. package/dist/esm/components/db-range-slider.js +811 -1
  86. package/dist/esm/components/db-rating.js +325 -1
  87. package/dist/esm/components/db-reorder.js +286 -1
  88. package/dist/esm/components/db-resizable-panels.js +282 -1
  89. package/dist/esm/components/db-scroll-area.js +126 -1
  90. package/dist/esm/components/db-search-bar.js +668 -1
  91. package/dist/esm/components/db-section-app-download.js +101 -1
  92. package/dist/esm/components/db-section-contact.js +102 -1
  93. package/dist/esm/components/db-section-cta.js +150 -1
  94. package/dist/esm/components/db-section-faq.js +120 -1
  95. package/dist/esm/components/db-section-feature-grid.js +137 -1
  96. package/dist/esm/components/db-section-feature.js +179 -1
  97. package/dist/esm/components/db-section-hero.js +243 -1
  98. package/dist/esm/components/db-section-logo-cloud.js +138 -1
  99. package/dist/esm/components/db-section-pricing.js +166 -1
  100. package/dist/esm/components/db-section-stats.js +129 -1
  101. package/dist/esm/components/db-section-testimonials.js +252 -1
  102. package/dist/esm/components/db-section.js +385 -1
  103. package/dist/esm/components/db-segment-control.js +231 -1
  104. package/dist/esm/components/db-select.js +571 -1
  105. package/dist/esm/components/db-share-icons.js +40 -1
  106. package/dist/esm/components/db-share.js +489 -1
  107. package/dist/esm/components/db-sidebar.js +1068 -1
  108. package/dist/esm/components/db-skeleton.js +94 -1
  109. package/dist/esm/components/db-spinner.js +102 -1
  110. package/dist/esm/components/db-split-view.js +297 -1
  111. package/dist/esm/components/db-stack.js +46 -1
  112. package/dist/esm/components/db-stat.js +218 -1
  113. package/dist/esm/components/db-stepper.js +398 -1
  114. package/dist/esm/components/db-table.js +412 -1
  115. package/dist/esm/components/db-tabs.js +335 -1
  116. package/dist/esm/components/db-testimonial.js +162 -1
  117. package/dist/esm/components/db-textarea.js +233 -1
  118. package/dist/esm/components/db-time-picker.js +523 -1
  119. package/dist/esm/components/db-timeline.js +174 -1
  120. package/dist/esm/components/db-toast.js +158 -1
  121. package/dist/esm/components/db-toggle.js +162 -1
  122. package/dist/esm/components/db-toolbar.js +94 -1
  123. package/dist/esm/components/db-tooltip.js +440 -1
  124. package/dist/esm/components/db-top-banner.js +121 -1
  125. package/dist/esm/components/db-tutorial.js +324 -1
  126. package/dist/esm/components/db-video-player.js +503 -1
  127. package/dist/esm/components/db-youtube-player.js +194 -1
  128. package/dist/esm/components/highlight-code.js +65 -1
  129. package/dist/esm/components/input-validation.js +50 -1
  130. package/dist/esm/components/marketing-block-host-utils.js +9 -1
  131. package/dist/esm/components/number-scrub.js +117 -1
  132. package/dist/esm/components/random-gradient-palettes.js +67 -1
  133. package/dist/esm/components/section-block-header-utils.js +48 -1
  134. package/dist/esm/helpers/confirm.js +52 -1
  135. package/dist/esm/helpers/toast.js +73 -1
  136. package/dist/esm/index.js +111 -1
  137. package/dist/esm/node_modules/prismjs/components/prism-bash.js +235 -1
  138. package/dist/esm/node_modules/prismjs/components/prism-clike.js +31 -1
  139. package/dist/esm/node_modules/prismjs/components/prism-css.js +64 -1
  140. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +172 -1
  141. package/dist/esm/node_modules/prismjs/components/prism-json.js +27 -1
  142. package/dist/esm/node_modules/prismjs/components/prism-jsx.js +143 -1
  143. package/dist/esm/node_modules/prismjs/components/prism-markup.js +186 -1
  144. package/dist/esm/node_modules/prismjs/components/prism-scss.js +81 -1
  145. package/dist/esm/node_modules/prismjs/components/prism-tsx.js +15 -1
  146. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +60 -1
  147. package/dist/index.cjs +55414 -1
  148. package/dist/index.css +1 -1
  149. package/dist/index.esm.js +38284 -1
  150. package/dist/react/chunks/lottie-72a4c6d4.js +17032 -0
  151. package/dist/react/index.cjs +56503 -1
  152. package/dist/react/index.esm.js +39373 -1
  153. package/package.json +1 -1
  154. package/dist/chunks/lottie-2637aa0f.js +0 -1
  155. package/dist/react/chunks/lottie-14e7addb.js +0 -1
@@ -1 +1,601 @@
1
- const t="designbase-wc-animation-text";class DbAnimationText extends HTMLElement{constructor(){super(...arguments),this.timers=[],this.displayText="",this.isVisible=!1,this.isAnimating=!1,this.wordEls=[],this.rotateToken=0}static get observedAttributes(){return["text","texts","interval","trigger","type","speed","repeat","delay","direction","size","color","custom-color","weight","align","gradient-colors","wave-colors","glow-color","clickable","disabled"]}connectedCallback(){this.style.display="inline-block",this.ensureStructure(),this.syncFromAttributes(),this.setupTrigger()}disconnectedCallback(){this.clearTimers(),this.observer?.disconnect(),this.teardownScrollFill(),this.rotateObserver?.disconnect()}attributeChangedCallback(){this.isConnected&&(this.syncFromAttributes(),this.setupTrigger())}getText(){return this.getAttribute("text")||this.textContent?.trim()||""}getRotateTexts(){const t=this.getAttribute("texts");if(t){const e=t.split(",").map(t=>t.trim()).filter(Boolean);if(e.length)return e}const e=this.getText();return e?[e]:[]}getLongestText(){return this.getRotateTexts().reduce((t,e)=>e.length>t.length?e:t,"")}getType(){const t=this.getAttribute("type")||"fade";return["typing","fade","slide","bounce","shake","glow","gradient","wave","flip","scale","decode","roll","reveal","scroll-fill","text-rotate"].includes(t)?t:"fade"}getTrigger(){const t=this.getAttribute("trigger")||"mount";return["mount","hover","click","in-view"].includes(t)?t:"mount"}ensureStructure(){this.ghostEl||(this.ghostEl=document.createElement("span"),this.ghostEl.setAttribute("aria-hidden","true"),this.ghostEl.style.visibility="hidden",this.ghostEl.style.pointerEvents="none",this.ghostEl.style.userSelect="none",this.layerEl=document.createElement("span"),this.layerEl.style.position="absolute",this.layerEl.style.top="0",this.layerEl.style.left="0",this.append(this.ghostEl,this.layerEl),this.addEventListener("mouseenter",()=>{"hover"!==this.getTrigger()||this.hasAttribute("disabled")||"roll"!==this.getType()&&(this.isVisible=!0,this.startAnimation(),this.syncClasses())}),this.addEventListener("mouseleave",()=>{if("hover"!==this.getTrigger())return;if("roll"===this.getType())return;this.isVisible=!1,this.isAnimating=!1,this.clearTimers();const t=this.getType();"typing"!==t&&"decode"!==t||(this.displayText=this.getText()),this.renderLayer(),this.syncClasses()}),this.addEventListener("click",()=>{if(!this.hasAttribute("disabled")){if("click"===this.getTrigger()){if(this.isVisible=!this.isVisible,this.isVisible)this.startAnimation();else{this.isAnimating=!1,this.clearTimers();const t=this.getType();"typing"!==t&&"decode"!==t||(this.displayText=this.getText()),this.renderLayer()}this.syncClasses()}this.hasAttribute("clickable")&&this.dispatchEvent(new CustomEvent("db-click",{bubbles:!0,composed:!0}))}}))}clearTimers(){this.timers.forEach(t=>window.clearInterval(t)),this.timers.forEach(t=>window.clearTimeout(t)),this.timers=[]}syncFromAttributes(){const e=this.getText(),i=this.getType(),s=this.getTrigger(),r=Number(this.getAttribute("speed")||1e3),n=Number(this.getAttribute("repeat")||1),l=this.getAttribute("custom-color"),o=(this.getAttribute("gradient-colors")||"#667eea,#764ba2").split(","),a=(this.getAttribute("wave-colors")||"#ff6b6b,#4ecdc4,#45b7d1,#96ceb4,#feca57").split(","),h=this.getAttribute("glow-color")||"#667eea";this.className=[t,"typing"!==i&&`${t}--${i}`,`${t}--${this.getAttribute("size")||"m"}`,`${t}--${this.getAttribute("color")||"primary"}`,`${t}--${this.getAttribute("weight")||"normal"}`,`${t}--${this.getAttribute("align")||"left"}`,`${t}--${this.getAttribute("direction")||"left"}`,this.isVisible&&`${t}--visible`,this.isAnimating&&`${t}--animating`,(this.hasAttribute("clickable")||"click"===s)&&`${t}--clickable`,this.hasAttribute("disabled")&&`${t}--disabled`].filter(Boolean).join(" "),this.style.setProperty("--db-animation-speed",`${Number.isFinite(r)?r:1e3}ms`),this.style.setProperty("--db-animation-iteration-count",0===n?"infinite":String(n)),l&&this.style.setProperty("--db-text-custom",l),this.style.setProperty("--db-wave-colors",a.join(", ")),this.style.setProperty("--db-glow-color",h),this.style.removeProperty("background"),this.style.removeProperty("background-size"),this.style.removeProperty("-webkit-background-clip"),this.style.removeProperty("-webkit-text-fill-color"),this.style.removeProperty("background-clip"),this.layerEl&&("gradient"===i&&o.length>=2?this.layerEl.style.backgroundImage=`linear-gradient(45deg, ${o.join(", ")})`:this.layerEl.style.removeProperty("background-image")),"typing"!==i&&"decode"!==i||"mount"!==s||this.isAnimating?this.isAnimating||(this.displayText=e):this.displayText="";const c="typing"===i||"decode"===i||"roll"===i||"text-rotate"===i,d="roll"===i||"text-rotate"===i?"nowrap":c?"pre-wrap":"";this.ghostEl&&(c?(this.ghostEl.textContent="text-rotate"===i?this.getLongestText():e,this.ghostEl.style.display="inline-block",this.ghostEl.style.whiteSpace=d,this.ghostEl.style.paddingRight="typing"===i?"0.25em":""):(this.ghostEl.textContent="",this.ghostEl.style.display="none")),this.layerEl&&(this.layerEl.className=[`${t}__layer`,"typing"===i&&`${t}--typing`,this.isAnimating&&"typing"===i&&`${t}--animating`].filter(Boolean).join(" "),c?(this.layerEl.style.position="absolute",this.layerEl.style.top="0",this.layerEl.style.left="0",this.layerEl.style.width="100%",this.layerEl.style.height="100%",this.layerEl.style.whiteSpace=d):(this.layerEl.style.position="static",this.layerEl.style.removeProperty("top"),this.layerEl.style.removeProperty("left"),this.layerEl.style.width="auto",this.layerEl.style.height="auto",this.layerEl.style.whiteSpace="")),this.renderLayer()}syncClasses(){this.classList.toggle(`${t}--visible`,this.isVisible),this.classList.toggle(`${t}--animating`,this.isAnimating)}setupTrigger(){this.clearTimers(),this.observer?.disconnect(),this.teardownScrollFill(),this.rotateObserver?.disconnect(),this.rotateObserver=void 0,this.rotateToken++;const t=this.getTrigger(),e=Number(this.getAttribute("delay")||0);if("scroll-fill"!==this.getType())if("text-rotate"!==this.getType()){if("mount"===t){const t=window.setTimeout(()=>{this.isVisible=!0,this.syncClasses(),this.startAnimation()},e);return void this.timers.push(t)}"in-view"===t&&(this.observer=new IntersectionObserver(t=>{t[0]?.isIntersecting&&(window.setTimeout(()=>{this.isVisible=!0,this.syncClasses(),this.startAnimation()},e),this.observer?.disconnect())}),this.observer.observe(this))}else this.setupTextRotate();else this.setupScrollFill()}setupTextRotate(){if(this.getRotateTexts().length<=1)return;const e=++this.rotateToken,start=()=>{if(e!==this.rotateToken||!this.isConnected||"text-rotate"!==this.getType())return;const i=this.layerEl?.querySelector(`.${t}__rotate-track`);if(!i||!i.firstElementChild)return;const s=Array.from(i.children),r=Number(this.getAttribute("speed")||500),n=Math.max(r+200,Number(this.getAttribute("interval")||2e3));let l=0;const apply=t=>{const e=s[0].getBoundingClientRect().height;if(!e)return;const n="cubic-bezier(0.22, 1, 0.36, 1)";var o;i.style.transition=t?`transform ${r}ms ${n}`:"none",i.style.transform=`translateY(-${l*e}px)`,this.style.transition=t?`width ${r}ms ${n}`:"none",this.style.width=`${o=l,s[o].getBoundingClientRect().width}px`};apply(!1);const o=window.setInterval(()=>{if(l+=1,apply(!0),l===s.length-1){const t=window.setTimeout(()=>{l=0,apply(!1)},r);this.timers.push(t)}},n);this.timers.push(o),this.rotateObserver?.disconnect();let a=!0;const h=new ResizeObserver(()=>{a?a=!1:apply(!1)});h.observe(s[0]),this.rotateObserver=h};"undefined"!=typeof document&&document.fonts?document.fonts.ready.then(()=>window.requestAnimationFrame(start)):window.requestAnimationFrame(start)}setupScrollFill(){this.scrollHandler=()=>{null==this.rafId&&(this.rafId=window.requestAnimationFrame(()=>{this.rafId=void 0,this.updateScrollFill()}))},window.addEventListener("scroll",this.scrollHandler,{passive:!0}),window.addEventListener("resize",this.scrollHandler,{passive:!0}),this.updateScrollFill()}teardownScrollFill(){this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler),window.removeEventListener("resize",this.scrollHandler),this.scrollHandler=void 0),null!=this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0)}updateScrollFill(){if("scroll-fill"!==this.getType()||0===this.wordEls.length)return;const clamp=t=>Math.max(0,Math.min(1,t)),t=this.getBoundingClientRect(),e=window.innerHeight||document.documentElement.clientHeight,i=.85*e,s=.35*e,r=clamp((i-t.top)/(i-s||1)),n=this.wordEls.length;this.wordEls.forEach((t,e)=>{const i=clamp((r*(n+4)-e)/4);t.style.opacity=String(.18+(1-.18)*i)})}startAnimation(){const t=this.getType(),e=this.getText();if(this.isAnimating=!0,this.syncClasses(),this.syncFromAttributes(),"typing"===t)return void this.startTyping(0);if("decode"===t)return void this.startDecoding(0);if("reveal"===t||"scroll-fill"===t||"roll"===t)return this.displayText=e,"roll"!==t&&this.renderLayer(),this.isAnimating=!1,void this.syncClasses();this.displayText=e,this.renderLayer();const i=Number(this.getAttribute("speed")||1e3),s=window.setTimeout(()=>{this.isAnimating=!1,this.syncClasses(),this.syncFromAttributes()},i);this.timers.push(s)}startTyping(t){const e=this.getText(),i=Number(this.getAttribute("speed")||1e3),s=Number(this.getAttribute("repeat")||1);this.displayText="",this.renderLayer();let r=0;const n=window.setInterval(()=>{if(r>=e.length)if(window.clearInterval(n),0===s||t<s-1){const e=window.setTimeout(()=>this.startTyping(t+1),500);this.timers.push(e)}else this.isAnimating=!1,this.syncClasses();else this.displayText=e.slice(0,r+1),this.renderLayer(),r+=1},Math.max(16,i/Math.max(e.length,1)));this.timers.push(n)}startDecoding(t){const e=this.getText(),i=Number(this.getAttribute("repeat")||1),s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+";let r=0;const n=window.setInterval(()=>{if(this.displayText=e.split("").map((t,i)=>i<r?e[i]:s[Math.floor(74*Math.random())]||t).join(""),this.renderLayer(),r>=e.length)if(window.clearInterval(n),this.displayText=e,this.renderLayer(),0===i||t<i-1){const e=window.setTimeout(()=>this.startDecoding(t+1),500);this.timers.push(e)}else this.isAnimating=!1,this.syncClasses();r+=1/3},30);this.timers.push(n)}renderLayer(){if(!this.layerEl)return;const e=this.getType(),i=this.getText(),s=this.isVisible||this.isAnimating;if("reveal"===e||"scroll-fill"===e){this.wordEls=[];const s=document.createDocumentFragment(),r=i.split(/(\s+)/);let n=0;for(const i of r){if(""===i)continue;if(/^\s+$/.test(i)){s.appendChild(document.createTextNode(i));continue}const r=document.createElement("span");r.className=`${t}__word`,r.textContent=i,"reveal"===e&&(r.style.animationDelay=.06*n+"s"),this.wordEls.push(r),s.appendChild(r),n+=1}return this.layerEl.replaceChildren(s),void("scroll-fill"===e&&this.updateScrollFill())}if("text-rotate"===e){const e=this.getRotateTexts(),s=e.length?e:[i],r=document.createElement("span");r.className=`${t}__rotate-track`;const build=e=>{const i=document.createElement("span");return i.className=`${t}__rotate-item`,i.textContent=e,i};return s.forEach(t=>r.appendChild(build(t))),s.length>1&&r.appendChild(build(s[0])),void this.layerEl.replaceChildren(r)}if("roll"===e){const e=document.createElement("span");e.className=`${t}__roll-track`;const s=document.createElement("span");s.className=`${t}__roll-item`,s.textContent=i;const r=s.cloneNode(!0);return e.append(s,r),void this.layerEl.replaceChildren(e)}if("typing"!==e)"wave"!==e&&"shake"!==e||!s?this.layerEl.textContent=this.displayText||(s?i:""):this.layerEl.replaceChildren(...i.split("").map((t,e)=>{const i=document.createElement("span");return i.style.animationDelay=.05*e+"s",i.style.display="inline-block",i.textContent=" "===t?" ":t,i}));else if(this.layerEl.textContent=this.displayText,this.isAnimating){const e=document.createElement("span");e.className=`${t}__caret`,e.setAttribute("aria-hidden","true"),this.layerEl.appendChild(e)}}}customElements.get("db-animation-text")||customElements.define("db-animation-text",DbAnimationText);export{DbAnimationText};
1
+ const CLASS = 'designbase-wc-animation-text';
2
+ class DbAnimationText extends HTMLElement {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.timers = [];
6
+ this.displayText = '';
7
+ this.isVisible = false;
8
+ this.isAnimating = false;
9
+ this.wordEls = [];
10
+ this.rotateToken = 0;
11
+ }
12
+ static get observedAttributes() {
13
+ return [
14
+ 'text',
15
+ 'texts',
16
+ 'interval',
17
+ 'trigger',
18
+ 'type',
19
+ 'speed',
20
+ 'repeat',
21
+ 'delay',
22
+ 'direction',
23
+ 'size',
24
+ 'color',
25
+ 'custom-color',
26
+ 'weight',
27
+ 'align',
28
+ 'gradient-colors',
29
+ 'wave-colors',
30
+ 'glow-color',
31
+ 'clickable',
32
+ 'disabled',
33
+ ];
34
+ }
35
+ connectedCallback() {
36
+ this.style.display = 'inline-block';
37
+ this.ensureStructure();
38
+ this.syncFromAttributes();
39
+ this.setupTrigger();
40
+ }
41
+ disconnectedCallback() {
42
+ this.clearTimers();
43
+ this.observer?.disconnect();
44
+ this.teardownScrollFill();
45
+ this.rotateObserver?.disconnect();
46
+ }
47
+ attributeChangedCallback() {
48
+ if (!this.isConnected)
49
+ return;
50
+ this.syncFromAttributes();
51
+ this.setupTrigger();
52
+ }
53
+ getText() {
54
+ return this.getAttribute('text') || this.textContent?.trim() || '';
55
+ }
56
+ getRotateTexts() {
57
+ const raw = this.getAttribute('texts');
58
+ if (raw) {
59
+ const list = raw
60
+ .split(',')
61
+ .map((s) => s.trim())
62
+ .filter(Boolean);
63
+ if (list.length)
64
+ return list;
65
+ }
66
+ const single = this.getText();
67
+ return single ? [single] : [];
68
+ }
69
+ getLongestText() {
70
+ return this.getRotateTexts().reduce((a, b) => (b.length > a.length ? b : a), '');
71
+ }
72
+ getType() {
73
+ const value = this.getAttribute('type') || 'fade';
74
+ const allowed = [
75
+ 'typing',
76
+ 'fade',
77
+ 'slide',
78
+ 'bounce',
79
+ 'shake',
80
+ 'glow',
81
+ 'gradient',
82
+ 'wave',
83
+ 'flip',
84
+ 'scale',
85
+ 'decode',
86
+ 'roll',
87
+ 'reveal',
88
+ 'scroll-fill',
89
+ 'text-rotate',
90
+ ];
91
+ return allowed.includes(value) ? value : 'fade';
92
+ }
93
+ getTrigger() {
94
+ const value = this.getAttribute('trigger') || 'mount';
95
+ return ['mount', 'hover', 'click', 'in-view'].includes(value) ? value : 'mount';
96
+ }
97
+ ensureStructure() {
98
+ if (this.ghostEl)
99
+ return;
100
+ this.ghostEl = document.createElement('span');
101
+ this.ghostEl.setAttribute('aria-hidden', 'true');
102
+ this.ghostEl.style.visibility = 'hidden';
103
+ this.ghostEl.style.pointerEvents = 'none';
104
+ this.ghostEl.style.userSelect = 'none';
105
+ this.layerEl = document.createElement('span');
106
+ this.layerEl.style.position = 'absolute';
107
+ this.layerEl.style.top = '0';
108
+ this.layerEl.style.left = '0';
109
+ this.append(this.ghostEl, this.layerEl);
110
+ this.addEventListener('mouseenter', () => {
111
+ if (this.getTrigger() !== 'hover' || this.hasAttribute('disabled'))
112
+ return;
113
+ // roll 은 정적 렌더 + CSS :hover 로만 동작한다. 재렌더 시 transition 이 리셋된다.
114
+ if (this.getType() === 'roll')
115
+ return;
116
+ this.isVisible = true;
117
+ this.startAnimation();
118
+ this.syncClasses();
119
+ });
120
+ this.addEventListener('mouseleave', () => {
121
+ if (this.getTrigger() !== 'hover')
122
+ return;
123
+ if (this.getType() === 'roll')
124
+ return;
125
+ this.isVisible = false;
126
+ this.isAnimating = false;
127
+ this.clearTimers();
128
+ const type = this.getType();
129
+ if (type === 'typing' || type === 'decode') {
130
+ this.displayText = this.getText();
131
+ }
132
+ this.renderLayer();
133
+ this.syncClasses();
134
+ });
135
+ this.addEventListener('click', () => {
136
+ if (this.hasAttribute('disabled'))
137
+ return;
138
+ if (this.getTrigger() === 'click') {
139
+ this.isVisible = !this.isVisible;
140
+ if (this.isVisible)
141
+ this.startAnimation();
142
+ else {
143
+ this.isAnimating = false;
144
+ this.clearTimers();
145
+ const type = this.getType();
146
+ if (type === 'typing' || type === 'decode')
147
+ this.displayText = this.getText();
148
+ this.renderLayer();
149
+ }
150
+ this.syncClasses();
151
+ }
152
+ if (this.hasAttribute('clickable')) {
153
+ this.dispatchEvent(new CustomEvent('db-click', { bubbles: true, composed: true }));
154
+ }
155
+ });
156
+ }
157
+ clearTimers() {
158
+ this.timers.forEach((id) => window.clearInterval(id));
159
+ this.timers.forEach((id) => window.clearTimeout(id));
160
+ this.timers = [];
161
+ }
162
+ syncFromAttributes() {
163
+ const text = this.getText();
164
+ const type = this.getType();
165
+ const trigger = this.getTrigger();
166
+ const speed = Number(this.getAttribute('speed') || 1000);
167
+ const repeat = Number(this.getAttribute('repeat') || 1);
168
+ const customColor = this.getAttribute('custom-color');
169
+ const gradientColors = (this.getAttribute('gradient-colors') || '#667eea,#764ba2').split(',');
170
+ const waveColors = (this.getAttribute('wave-colors') || '#ff6b6b,#4ecdc4,#45b7d1,#96ceb4,#feca57').split(',');
171
+ const glowColor = this.getAttribute('glow-color') || '#667eea';
172
+ this.className = [
173
+ CLASS,
174
+ type !== 'typing' && `${CLASS}--${type}`,
175
+ `${CLASS}--${this.getAttribute('size') || 'm'}`,
176
+ `${CLASS}--${this.getAttribute('color') || 'primary'}`,
177
+ `${CLASS}--${this.getAttribute('weight') || 'normal'}`,
178
+ `${CLASS}--${this.getAttribute('align') || 'left'}`,
179
+ `${CLASS}--${this.getAttribute('direction') || 'left'}`,
180
+ this.isVisible && `${CLASS}--visible`,
181
+ this.isAnimating && `${CLASS}--animating`,
182
+ (this.hasAttribute('clickable') || trigger === 'click') && `${CLASS}--clickable`,
183
+ this.hasAttribute('disabled') && `${CLASS}--disabled`,
184
+ ]
185
+ .filter(Boolean)
186
+ .join(' ');
187
+ this.style.setProperty('--db-animation-speed', `${Number.isFinite(speed) ? speed : 1000}ms`);
188
+ this.style.setProperty('--db-animation-iteration-count', repeat === 0 ? 'infinite' : String(repeat));
189
+ if (customColor)
190
+ this.style.setProperty('--db-text-custom', customColor);
191
+ this.style.setProperty('--db-wave-colors', waveColors.join(', '));
192
+ this.style.setProperty('--db-glow-color', glowColor);
193
+ // 그라디언트 텍스트는 실제 텍스트가 들어있는 레이어(span)에 적용해야 한다.
194
+ // (host에 background-clip:text를 걸면 자식 레이어 텍스트는 투명하게만 보인다)
195
+ this.style.removeProperty('background');
196
+ this.style.removeProperty('background-size');
197
+ this.style.removeProperty('-webkit-background-clip');
198
+ this.style.removeProperty('-webkit-text-fill-color');
199
+ this.style.removeProperty('background-clip');
200
+ if (this.layerEl) {
201
+ if (type === 'gradient' && gradientColors.length >= 2) {
202
+ this.layerEl.style.backgroundImage = `linear-gradient(45deg, ${gradientColors.join(', ')})`;
203
+ }
204
+ else {
205
+ this.layerEl.style.removeProperty('background-image');
206
+ }
207
+ }
208
+ if ((type === 'typing' || type === 'decode') && trigger === 'mount' && !this.isAnimating) {
209
+ this.displayText = '';
210
+ }
211
+ else if (!this.isAnimating) {
212
+ this.displayText = text;
213
+ }
214
+ // typing/decode 는 글자 수가 변하고 roll 은 1줄 높이를 고정해야 하므로
215
+ // ghost 로 공간을 예약하고 layer 를 절대배치로 겹친다.
216
+ // 그 외 타입(fade·reveal·scroll-fill 등)은 일반 흐름으로 렌더해
217
+ // 문장 길이(줄바꿈)에 따라 호스트 높이가 자연스럽게 늘어나도록 한다.
218
+ const overlay = type === 'typing' || type === 'decode' || type === 'roll' || type === 'text-rotate';
219
+ const whiteSpace = type === 'roll' || type === 'text-rotate' ? 'nowrap' : overlay ? 'pre-wrap' : '';
220
+ if (this.ghostEl) {
221
+ if (overlay) {
222
+ this.ghostEl.textContent = type === 'text-rotate' ? this.getLongestText() : text;
223
+ this.ghostEl.style.display = 'inline-block';
224
+ this.ghostEl.style.whiteSpace = whiteSpace;
225
+ // 타이핑은 완료 시 텍스트가 폭을 꽉 채워 캐럿이 다음 줄로 밀리지 않도록 여유 확보
226
+ this.ghostEl.style.paddingRight = type === 'typing' ? '0.25em' : '';
227
+ }
228
+ else {
229
+ this.ghostEl.textContent = '';
230
+ this.ghostEl.style.display = 'none';
231
+ }
232
+ }
233
+ if (this.layerEl) {
234
+ this.layerEl.className = [
235
+ `${CLASS}__layer`,
236
+ type === 'typing' && `${CLASS}--typing`,
237
+ this.isAnimating && type === 'typing' && `${CLASS}--animating`,
238
+ ]
239
+ .filter(Boolean)
240
+ .join(' ');
241
+ if (overlay) {
242
+ this.layerEl.style.position = 'absolute';
243
+ this.layerEl.style.top = '0';
244
+ this.layerEl.style.left = '0';
245
+ this.layerEl.style.width = '100%';
246
+ this.layerEl.style.height = '100%';
247
+ this.layerEl.style.whiteSpace = whiteSpace;
248
+ }
249
+ else {
250
+ this.layerEl.style.position = 'static';
251
+ this.layerEl.style.removeProperty('top');
252
+ this.layerEl.style.removeProperty('left');
253
+ this.layerEl.style.width = 'auto';
254
+ this.layerEl.style.height = 'auto';
255
+ this.layerEl.style.whiteSpace = '';
256
+ }
257
+ }
258
+ this.renderLayer();
259
+ }
260
+ syncClasses() {
261
+ this.classList.toggle(`${CLASS}--visible`, this.isVisible);
262
+ this.classList.toggle(`${CLASS}--animating`, this.isAnimating);
263
+ }
264
+ setupTrigger() {
265
+ this.clearTimers();
266
+ this.observer?.disconnect();
267
+ this.teardownScrollFill();
268
+ this.rotateObserver?.disconnect();
269
+ this.rotateObserver = undefined;
270
+ this.rotateToken++; // 대기 중이던 이전 rotate 예약 무효화
271
+ const trigger = this.getTrigger();
272
+ const delay = Number(this.getAttribute('delay') || 0);
273
+ // scroll-fill 은 스크롤 위치에 연동되므로 별도 핸들러로 처리한다.
274
+ if (this.getType() === 'scroll-fill') {
275
+ this.setupScrollFill();
276
+ return;
277
+ }
278
+ // text-rotate 는 타이머로 자동 순환한다.
279
+ if (this.getType() === 'text-rotate') {
280
+ this.setupTextRotate();
281
+ return;
282
+ }
283
+ if (trigger === 'mount') {
284
+ const timer = window.setTimeout(() => {
285
+ this.isVisible = true;
286
+ this.syncClasses();
287
+ this.startAnimation();
288
+ }, delay);
289
+ this.timers.push(timer);
290
+ return;
291
+ }
292
+ if (trigger === 'in-view') {
293
+ this.observer = new IntersectionObserver((entries) => {
294
+ if (entries[0]?.isIntersecting) {
295
+ window.setTimeout(() => {
296
+ this.isVisible = true;
297
+ this.syncClasses();
298
+ this.startAnimation();
299
+ }, delay);
300
+ this.observer?.disconnect();
301
+ }
302
+ });
303
+ this.observer.observe(this);
304
+ }
305
+ }
306
+ setupTextRotate() {
307
+ const texts = this.getRotateTexts();
308
+ if (texts.length <= 1)
309
+ return; // 순환할 텍스트가 없으면 정적 표시
310
+ // 재설정마다 토큰을 올려, 폰트 로드 후 뒤늦게 실행되는 이전 예약을 무효화한다.
311
+ const token = ++this.rotateToken;
312
+ const start = () => {
313
+ if (token !== this.rotateToken || !this.isConnected || this.getType() !== 'text-rotate')
314
+ return;
315
+ const track = this.layerEl?.querySelector(`.${CLASS}__rotate-track`);
316
+ if (!track || !track.firstElementChild)
317
+ return;
318
+ const items = Array.from(track.children);
319
+ const duration = Number(this.getAttribute('speed') || 500);
320
+ const interval = Math.max(duration + 200, Number(this.getAttribute('interval') || 2000));
321
+ let index = 0;
322
+ // 줄 높이·폭은 폰트 로드 타이밍에 따라 달라지므로 매번 실측한다.
323
+ const stepOf = () => items[0].getBoundingClientRect().height;
324
+ const widthOf = (i) => items[i].getBoundingClientRect().width;
325
+ // 현재 index 위치로 트랙/호스트를 맞춘다. animate=false 면 즉시(트랜지션 없이) 스냅.
326
+ const apply = (animate) => {
327
+ const step = stepOf();
328
+ if (!step)
329
+ return;
330
+ const ease = 'cubic-bezier(0.22, 1, 0.36, 1)';
331
+ track.style.transition = animate ? `transform ${duration}ms ${ease}` : 'none';
332
+ track.style.transform = `translateY(-${index * step}px)`;
333
+ this.style.transition = animate ? `width ${duration}ms ${ease}` : 'none';
334
+ this.style.width = `${widthOf(index)}px`;
335
+ };
336
+ apply(false);
337
+ const advance = () => {
338
+ index += 1;
339
+ apply(true);
340
+ if (index === items.length - 1) {
341
+ // 마지막 복제본(=첫 항목) 위치 → 트랜지션 종료 후 순간 이동으로 원점 복귀
342
+ const reset = window.setTimeout(() => {
343
+ index = 0;
344
+ apply(false);
345
+ }, duration);
346
+ this.timers.push(reset);
347
+ }
348
+ };
349
+ const timer = window.setInterval(advance, interval);
350
+ this.timers.push(timer);
351
+ // 폰트 로드 등으로 항목 크기가 바뀌면(초기 폴백→웹폰트) 현재 위치를 다시 맞춰
352
+ // 세로 어긋남·가로 잘림을 보정한다. 최초 observe 콜백(초기 크기)은 건너뛴다.
353
+ this.rotateObserver?.disconnect();
354
+ let firstObserve = true;
355
+ const ro = new ResizeObserver(() => {
356
+ if (firstObserve) {
357
+ firstObserve = false;
358
+ return;
359
+ }
360
+ apply(false);
361
+ });
362
+ ro.observe(items[0]);
363
+ this.rotateObserver = ro;
364
+ };
365
+ // 웹폰트 로드 후 측정을 시도하되, ready 가 조기 resolve 되는 경우는 위 ResizeObserver 가 보정한다.
366
+ if (typeof document !== 'undefined' && document.fonts) {
367
+ document.fonts.ready.then(() => window.requestAnimationFrame(start));
368
+ }
369
+ else {
370
+ window.requestAnimationFrame(start);
371
+ }
372
+ }
373
+ setupScrollFill() {
374
+ this.scrollHandler = () => {
375
+ if (this.rafId != null)
376
+ return;
377
+ this.rafId = window.requestAnimationFrame(() => {
378
+ this.rafId = undefined;
379
+ this.updateScrollFill();
380
+ });
381
+ };
382
+ window.addEventListener('scroll', this.scrollHandler, { passive: true });
383
+ window.addEventListener('resize', this.scrollHandler, { passive: true });
384
+ this.updateScrollFill();
385
+ }
386
+ teardownScrollFill() {
387
+ if (this.scrollHandler) {
388
+ window.removeEventListener('scroll', this.scrollHandler);
389
+ window.removeEventListener('resize', this.scrollHandler);
390
+ this.scrollHandler = undefined;
391
+ }
392
+ if (this.rafId != null) {
393
+ window.cancelAnimationFrame(this.rafId);
394
+ this.rafId = undefined;
395
+ }
396
+ }
397
+ updateScrollFill() {
398
+ if (this.getType() !== 'scroll-fill' || this.wordEls.length === 0)
399
+ return;
400
+ const clamp = (v) => Math.max(0, Math.min(1, v));
401
+ const rect = this.getBoundingClientRect();
402
+ const vh = window.innerHeight || document.documentElement.clientHeight;
403
+ // 요소 상단이 뷰포트 85% 지점에 오면 시작, 35% 지점에 오면 완료
404
+ const start = vh * 0.85;
405
+ const end = vh * 0.35;
406
+ const progress = clamp((start - rect.top) / (start - end || 1));
407
+ const n = this.wordEls.length;
408
+ const softness = 4; // 몇 단어에 걸쳐 부드럽게 채워질지
409
+ const minOpacity = 0.18;
410
+ this.wordEls.forEach((el, i) => {
411
+ const p = clamp((progress * (n + softness) - i) / softness);
412
+ el.style.opacity = String(minOpacity + (1 - minOpacity) * p);
413
+ });
414
+ }
415
+ startAnimation() {
416
+ const type = this.getType();
417
+ const text = this.getText();
418
+ this.isAnimating = true;
419
+ this.syncClasses();
420
+ this.syncFromAttributes();
421
+ if (type === 'typing') {
422
+ this.startTyping(0);
423
+ return;
424
+ }
425
+ if (type === 'decode') {
426
+ this.startDecoding(0);
427
+ return;
428
+ }
429
+ // reveal 은 --visible 클래스로 CSS stagger 가 재생되므로 재빌드 루프를 타지 않는다.
430
+ // roll 은 이미 정적으로 렌더되어 있고 CSS :hover 로만 동작하므로 재렌더하지 않는다.
431
+ if (type === 'reveal' || type === 'scroll-fill' || type === 'roll') {
432
+ this.displayText = text;
433
+ if (type !== 'roll')
434
+ this.renderLayer();
435
+ this.isAnimating = false;
436
+ this.syncClasses();
437
+ return;
438
+ }
439
+ this.displayText = text;
440
+ this.renderLayer();
441
+ const speed = Number(this.getAttribute('speed') || 1000);
442
+ const timer = window.setTimeout(() => {
443
+ this.isAnimating = false;
444
+ this.syncClasses();
445
+ this.syncFromAttributes();
446
+ }, speed);
447
+ this.timers.push(timer);
448
+ }
449
+ startTyping(iteration) {
450
+ const text = this.getText();
451
+ const speed = Number(this.getAttribute('speed') || 1000);
452
+ const repeat = Number(this.getAttribute('repeat') || 1);
453
+ this.displayText = '';
454
+ this.renderLayer();
455
+ let currentIndex = 0;
456
+ const interval = window.setInterval(() => {
457
+ if (currentIndex >= text.length) {
458
+ window.clearInterval(interval);
459
+ if (repeat === 0 || iteration < repeat - 1) {
460
+ const timer = window.setTimeout(() => this.startTyping(iteration + 1), 500);
461
+ this.timers.push(timer);
462
+ }
463
+ else {
464
+ this.isAnimating = false;
465
+ this.syncClasses();
466
+ }
467
+ return;
468
+ }
469
+ this.displayText = text.slice(0, currentIndex + 1);
470
+ this.renderLayer();
471
+ currentIndex += 1;
472
+ }, Math.max(16, speed / Math.max(text.length, 1)));
473
+ this.timers.push(interval);
474
+ }
475
+ startDecoding(iteration) {
476
+ const text = this.getText();
477
+ const repeat = Number(this.getAttribute('repeat') || 1);
478
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+';
479
+ let iterations = 0;
480
+ const interval = window.setInterval(() => {
481
+ this.displayText = text
482
+ .split('')
483
+ .map((char, index) => {
484
+ if (index < iterations)
485
+ return text[index];
486
+ return characters[Math.floor(Math.random() * characters.length)] || char;
487
+ })
488
+ .join('');
489
+ this.renderLayer();
490
+ if (iterations >= text.length) {
491
+ window.clearInterval(interval);
492
+ this.displayText = text;
493
+ this.renderLayer();
494
+ if (repeat === 0 || iteration < repeat - 1) {
495
+ const timer = window.setTimeout(() => this.startDecoding(iteration + 1), 500);
496
+ this.timers.push(timer);
497
+ }
498
+ else {
499
+ this.isAnimating = false;
500
+ this.syncClasses();
501
+ }
502
+ }
503
+ iterations += 1 / 3;
504
+ }, 30);
505
+ this.timers.push(interval);
506
+ }
507
+ renderLayer() {
508
+ if (!this.layerEl)
509
+ return;
510
+ const type = this.getType();
511
+ const text = this.getText();
512
+ const visible = this.isVisible || this.isAnimating;
513
+ // Reveal / Scroll-fill: 텍스트를 단어 단위 span 으로 렌더한다.
514
+ // (reveal 은 CSS stagger 애니메이션, scroll-fill 은 스크롤 연동 투명도)
515
+ if (type === 'reveal' || type === 'scroll-fill') {
516
+ this.wordEls = [];
517
+ const frag = document.createDocumentFragment();
518
+ const tokens = text.split(/(\s+)/);
519
+ let wordIndex = 0;
520
+ for (const token of tokens) {
521
+ if (token === '')
522
+ continue;
523
+ if (/^\s+$/.test(token)) {
524
+ frag.appendChild(document.createTextNode(token));
525
+ continue;
526
+ }
527
+ const span = document.createElement('span');
528
+ span.className = `${CLASS}__word`;
529
+ span.textContent = token;
530
+ if (type === 'reveal')
531
+ span.style.animationDelay = `${wordIndex * 0.06}s`;
532
+ this.wordEls.push(span);
533
+ frag.appendChild(span);
534
+ wordIndex += 1;
535
+ }
536
+ this.layerEl.replaceChildren(frag);
537
+ if (type === 'scroll-fill')
538
+ this.updateScrollFill();
539
+ return;
540
+ }
541
+ // Text-rotate: 여러 텍스트를 세로로 쌓아 일정 간격으로 위로 롤링하며 순환한다.
542
+ if (type === 'text-rotate') {
543
+ const texts = this.getRotateTexts();
544
+ const list = texts.length ? texts : [text];
545
+ const track = document.createElement('span');
546
+ track.className = `${CLASS}__rotate-track`;
547
+ const build = (t) => {
548
+ const s = document.createElement('span');
549
+ s.className = `${CLASS}__rotate-item`;
550
+ s.textContent = t;
551
+ return s;
552
+ };
553
+ list.forEach((t) => track.appendChild(build(t)));
554
+ // 마지막 → 첫 항목으로 끊김 없이 순환하도록 첫 항목 복제본을 덧붙인다.
555
+ if (list.length > 1)
556
+ track.appendChild(build(list[0]));
557
+ this.layerEl.replaceChildren(track);
558
+ return;
559
+ }
560
+ // Roll: 동일 텍스트 2개를 세로로 쌓고 hover 시 위로 굴려 교체한다.
561
+ if (type === 'roll') {
562
+ const track = document.createElement('span');
563
+ track.className = `${CLASS}__roll-track`;
564
+ const first = document.createElement('span');
565
+ first.className = `${CLASS}__roll-item`;
566
+ first.textContent = text;
567
+ const second = first.cloneNode(true);
568
+ track.append(first, second);
569
+ this.layerEl.replaceChildren(track);
570
+ return;
571
+ }
572
+ // Typing: 타이핑된 부분 텍스트 뒤에 인라인 캐럿을 붙여 텍스트를 따라가게 한다.
573
+ // 캐럿은 타이핑 중(isAnimating)에만 표시하고, 완료되면 제거한다.
574
+ if (type === 'typing') {
575
+ this.layerEl.textContent = this.displayText;
576
+ if (this.isAnimating) {
577
+ const caret = document.createElement('span');
578
+ caret.className = `${CLASS}__caret`;
579
+ caret.setAttribute('aria-hidden', 'true');
580
+ this.layerEl.appendChild(caret);
581
+ }
582
+ return;
583
+ }
584
+ if ((type === 'wave' || type === 'shake') && visible) {
585
+ this.layerEl.replaceChildren(...text.split('').map((char, index) => {
586
+ const span = document.createElement('span');
587
+ span.style.animationDelay = `${index * 0.05}s`;
588
+ span.style.display = 'inline-block';
589
+ span.textContent = char === ' ' ? '\u00A0' : char;
590
+ return span;
591
+ }));
592
+ return;
593
+ }
594
+ this.layerEl.textContent = this.displayText || (visible ? text : '');
595
+ }
596
+ }
597
+ if (!customElements.get('db-animation-text')) {
598
+ customElements.define('db-animation-text', DbAnimationText);
599
+ }
600
+
601
+ export { DbAnimationText };