@designbasekorea/ui-wc 0.5.3 → 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 (156) 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.d.ts +1 -1
  153. package/dist/react/index.esm.js +39373 -1
  154. package/package.json +1 -1
  155. package/dist/chunks/lottie-2d1f6278.js +0 -1
  156. package/dist/react/chunks/lottie-14e7addb.js +0 -1
@@ -1 +1,335 @@
1
- import{createDbIcon as t}from"./db-icons.js";const e=["s","m","l"],s=["horizontal","vertical"],i=["default","pills"];class DbTabs extends HTMLElement{constructor(){super(...arguments),this.tabButtons=[],this.inactivePanels=document.createDocumentFragment(),this.isRendering=!1,this.handleListScroll=()=>{if(!this.list)return;const t=this.list.scrollWidth>this.list.clientWidth,e=this.list.scrollLeft+this.list.clientWidth>=this.list.scrollWidth-5;this.list.classList.toggle("designbase-wc-tabs__list--show-gradient",t&&!e&&"horizontal"===this.orientation)}}static get observedAttributes(){return["labels","items","active-index","selected-id","orientation","size","variant","full-width"]}get labels(){const t=this.tabItems.map(t=>t.label);return t.length?t:(this.getAttribute("labels")||"").split(",").map(t=>t.trim()).filter(Boolean)}set labels(t){this.setAttribute("labels",Array.isArray(t)?t.join(","):t)}get tabItems(){try{const t=JSON.parse(this.getAttribute("items")||"[]");return Array.isArray(t)?t:[]}catch{return[]}}get items(){return this.tabItems}set items(t){this.setAttribute("items","string"==typeof t?t:JSON.stringify(t))}set tabItems(t){this.setAttribute("items","string"==typeof t?t:JSON.stringify(t))}get activeIndex(){const t=this.getAttribute("selected-id");if(t){const e=this.tabItems.findIndex((e,s)=>(e.id||String(s))===t);if(e>=0)return e}return Number(this.getAttribute("active-index")||0)}set activeIndex(t){this.setAttribute("active-index",String(t))}get orientation(){return this.getAttribute("orientation")||"horizontal"}set orientation(t){this.setAttribute("orientation",t)}get size(){return this.getAttribute("size")||"m"}set size(t){this.setAttribute("size",t)}get variant(){return this.getAttribute("variant")||"default"}set variant(t){this.setAttribute("variant",t)}get fullWidth(){return this.hasAttribute("full-width")}set fullWidth(t){this.toggleAttribute("full-width",Boolean(t))}connectedCallback(){this.render(),this.list?.addEventListener("scroll",this.handleListScroll,{passive:!0}),window.addEventListener("resize",this.handleListScroll),this.childObserver=new MutationObserver(t=>{if(this.isRendering)return;t.some(t=>Array.from(t.addedNodes).some(t=>t instanceof HTMLElement&&(t.hasAttribute("slot")||void 0!==t.dataset.panelIndex)))&&this.render()}),this.childObserver.observe(this,{childList:!0})}disconnectedCallback(){this.list?.removeEventListener("scroll",this.handleListScroll),window.removeEventListener("resize",this.handleListScroll),this.childObserver?.disconnect()}attributeChangedCallback(){this.isConnected&&this.render()}collectPanelContent(){const t=new Map,register=(e,s)=>{if(!(e instanceof HTMLElement)||"SLOT"===e.tagName)return;t.has(s)||t.set(s,[]);const i=t.get(s);i.includes(e)||i.push(e)};return Array.from(this.children).forEach(t=>{const e=t.getAttribute("slot")?.match(/^panel-(\d+)$/);if(e)return void register(t,Number(e[1]));const s=t.dataset.panelIndex;void 0!==s&&register(t,Number(s))}),this.panel?.querySelectorAll(":scope > .designbase-wc-tabs__panel-inner > [data-panel-index]").forEach(t=>{t instanceof HTMLElement&&register(t,Number(t.dataset.panelIndex))}),Array.from(this.inactivePanels.children).forEach(t=>{t instanceof HTMLElement&&void 0!==t.dataset.panelIndex&&register(t,Number(t.dataset.panelIndex))}),t}render(){this.isRendering=!0;const a=this.collectPanelContent(),n=this.labels,r=this.tabItems,l=Math.min(Math.max(this.activeIndex,0),Math.max(n.length-1,0)),d=e.includes(this.size)?this.size:"m",o=s.includes(this.orientation)?this.orientation:"horizontal",c=i.includes(this.variant)?this.variant:"default",h="default"===c;this.className=["designbase-wc-tabs",`designbase-wc-tabs--${o}`,`designbase-wc-tabs--${d}`,`designbase-wc-tabs--${c}`,this.fullWidth&&"designbase-wc-tabs--full-width"].filter(Boolean).join(" "),this.querySelectorAll(":scope > .designbase-wc-tabs__list, :scope > .designbase-wc-tabs__panel").forEach(t=>t.remove()),this.list=document.createElement("div"),this.list.className=["designbase-wc-tabs__list",`designbase-wc-tabs__list--${o}`,this.fullWidth&&"designbase-wc-tabs__list--full-width"].filter(Boolean).join(" "),this.list.setAttribute("role","tablist"),this.list.setAttribute("aria-orientation",o),this.list.setAttribute("aria-label","탭 목록"),this.tabButtons=[],n.forEach((e,s)=>{const i=r[s],a=Boolean(i?.disabled),n=s===l,o=document.createElement("button");if(o.type="button",o.className=["designbase-wc-tabs__tab",n&&"designbase-wc-tabs__tab--selected",a&&"designbase-wc-tabs__tab--disabled"].filter(Boolean).join(" "),o.setAttribute("role","tab"),o.setAttribute("aria-selected",String(n)),o.setAttribute("aria-controls",`panel-${s}`),o.id=`tab-${s}`,o.tabIndex=n?0:-1,o.disabled=a,i?.icon){const e=document.createElement("span");e.className="designbase-wc-tabs__tab-icon";const s="s"===d?16:"l"===d?20:18;e.append(t(i.icon,s)),o.append(e)}const c=document.createElement("span");c.className="designbase-wc-tabs__tab-label",c.textContent=e,o.append(c),o.addEventListener("click",()=>this.select(s)),o.addEventListener("keydown",t=>this.handleKeyDown(t,s)),this.list?.append(o),this.tabButtons.push(o)}),h?(this.indicator=document.createElement("span"),this.indicator.className="designbase-wc-tabs__indicator designbase-wc-tabs__indicator--no-transition",this.list.append(this.indicator),requestAnimationFrame(()=>this.updateIndicator(!1))):this.indicator=void 0,this.panel=document.createElement("div"),this.panel.className="designbase-wc-tabs__panel",this.panel.setAttribute("role","tabpanel"),this.panel.id=`panel-${l}`,this.panel.setAttribute("aria-labelledby",`tab-${l}`),this.panel.tabIndex=0;const b=document.createElement("div");b.className="designbase-wc-tabs__panel-inner",a.forEach((t,e)=>{t.forEach(t=>{t.removeAttribute("slot"),t.dataset.panelIndex=String(e),e===l?b.append(t):this.inactivePanels.append(t)})}),this.panel.append(b),this.append(this.list,this.panel),requestAnimationFrame(()=>{this.handleListScroll(),h&&this.updateIndicator(!1)}),this.isRendering=!1}select(t){const e=this.labels,s=this.tabItems;if(!e[t]||s[t]?.disabled)return;this.activeIndex=t;const i=s[t]?.id||String(t);this.setAttribute("selected-id",i),this.dispatchEvent(new CustomEvent("db-change",{detail:{index:t,label:e[t],id:i},bubbles:!0,composed:!0})),this.render()}handleKeyDown(t,e){const s=this.labels,i=this.tabItems;let a=e;if("ArrowRight"===t.key||"ArrowDown"===t.key)a=(e+1)%s.length;else if("ArrowLeft"===t.key||"ArrowUp"===t.key)a=(e-1+s.length)%s.length;else if("Home"===t.key)a=0;else{if("End"!==t.key)return"Enter"===t.key||" "===t.key?(t.preventDefault(),void this.select(e)):void 0;a=s.length-1}t.preventDefault();let n=0;for(;i[a]?.disabled&&n<s.length;)a="ArrowLeft"===t.key||"ArrowUp"===t.key?(a-1+s.length)%s.length:(a+1)%s.length,n+=1;this.tabButtons[a]?.focus()}updateIndicator(t=!1){const e=this.list?.querySelector(".designbase-wc-tabs__tab--selected");if(!e||!this.indicator)return;const s="vertical"===this.orientation;this.indicator.classList.toggle("designbase-wc-tabs__indicator--no-transition",!t),this.indicator.classList.add(s?"designbase-wc-tabs__indicator--vertical":"designbase-wc-tabs__indicator--horizontal"),this.indicator.classList.add("designbase-wc-tabs__indicator--ready"),s?(this.indicator.style.width="2px",this.indicator.style.height=`${e.offsetHeight}px`,this.indicator.style.transform=`translate3d(0, ${e.offsetTop}px, 0)`):(this.indicator.style.width=`${e.offsetWidth}px`,this.indicator.style.height="2px",this.indicator.style.transform=`translate3d(${e.offsetLeft}px, 0, 0)`)}}customElements.get("db-tabs")||customElements.define("db-tabs",DbTabs);export{DbTabs};
1
+ import { createDbIcon } from './db-icons.js';
2
+
3
+ const SIZES = ['s', 'm', 'l'];
4
+ const ORIENTATIONS = ['horizontal', 'vertical'];
5
+ const VARIANTS = ['default', 'pills'];
6
+ class DbTabs extends HTMLElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.tabButtons = [];
10
+ this.inactivePanels = document.createDocumentFragment();
11
+ this.isRendering = false;
12
+ this.handleListScroll = () => {
13
+ if (!this.list)
14
+ return;
15
+ const isScrollable = this.list.scrollWidth > this.list.clientWidth;
16
+ const isScrolledToEnd = this.list.scrollLeft + this.list.clientWidth >= this.list.scrollWidth - 5;
17
+ this.list.classList.toggle('designbase-wc-tabs__list--show-gradient', isScrollable && !isScrolledToEnd && this.orientation === 'horizontal');
18
+ };
19
+ }
20
+ static get observedAttributes() {
21
+ return ['labels', 'items', 'active-index', 'selected-id', 'orientation', 'size', 'variant', 'full-width'];
22
+ }
23
+ get labels() {
24
+ const fromItems = this.tabItems.map((item) => item.label);
25
+ if (fromItems.length)
26
+ return fromItems;
27
+ return (this.getAttribute('labels') || '')
28
+ .split(',')
29
+ .map((label) => label.trim())
30
+ .filter(Boolean);
31
+ }
32
+ set labels(value) {
33
+ this.setAttribute('labels', Array.isArray(value) ? value.join(',') : value);
34
+ }
35
+ get tabItems() {
36
+ try {
37
+ const parsed = JSON.parse(this.getAttribute('items') || '[]');
38
+ return Array.isArray(parsed) ? parsed : [];
39
+ }
40
+ catch {
41
+ return [];
42
+ }
43
+ }
44
+ get items() {
45
+ return this.tabItems;
46
+ }
47
+ set items(value) {
48
+ this.setAttribute('items', typeof value === 'string' ? value : JSON.stringify(value));
49
+ }
50
+ set tabItems(value) {
51
+ this.setAttribute('items', typeof value === 'string' ? value : JSON.stringify(value));
52
+ }
53
+ get activeIndex() {
54
+ const selectedId = this.getAttribute('selected-id');
55
+ if (selectedId) {
56
+ const index = this.tabItems.findIndex((item, idx) => (item.id || String(idx)) === selectedId);
57
+ if (index >= 0)
58
+ return index;
59
+ }
60
+ return Number(this.getAttribute('active-index') || 0);
61
+ }
62
+ set activeIndex(value) {
63
+ this.setAttribute('active-index', String(value));
64
+ }
65
+ get orientation() {
66
+ return this.getAttribute('orientation') || 'horizontal';
67
+ }
68
+ set orientation(value) {
69
+ this.setAttribute('orientation', value);
70
+ }
71
+ get size() {
72
+ return this.getAttribute('size') || 'm';
73
+ }
74
+ set size(value) {
75
+ this.setAttribute('size', value);
76
+ }
77
+ get variant() {
78
+ return this.getAttribute('variant') || 'default';
79
+ }
80
+ set variant(value) {
81
+ this.setAttribute('variant', value);
82
+ }
83
+ get fullWidth() {
84
+ return this.hasAttribute('full-width');
85
+ }
86
+ set fullWidth(value) {
87
+ this.toggleAttribute('full-width', Boolean(value));
88
+ }
89
+ connectedCallback() {
90
+ this.render();
91
+ this.list?.addEventListener('scroll', this.handleListScroll, { passive: true });
92
+ window.addEventListener('resize', this.handleListScroll);
93
+ this.childObserver = new MutationObserver((mutations) => {
94
+ if (this.isRendering)
95
+ return;
96
+ const hasPanelChange = mutations.some((mutation) => Array.from(mutation.addedNodes).some((node) => node instanceof HTMLElement &&
97
+ (node.hasAttribute('slot') || node.dataset.panelIndex !== undefined)));
98
+ if (hasPanelChange)
99
+ this.render();
100
+ });
101
+ this.childObserver.observe(this, { childList: true });
102
+ }
103
+ disconnectedCallback() {
104
+ this.list?.removeEventListener('scroll', this.handleListScroll);
105
+ window.removeEventListener('resize', this.handleListScroll);
106
+ this.childObserver?.disconnect();
107
+ }
108
+ attributeChangedCallback() {
109
+ if (!this.isConnected)
110
+ return;
111
+ this.render();
112
+ }
113
+ collectPanelContent() {
114
+ const map = new Map();
115
+ const register = (node, index) => {
116
+ if (!(node instanceof HTMLElement) || node.tagName === 'SLOT')
117
+ return;
118
+ if (!map.has(index))
119
+ map.set(index, []);
120
+ const list = map.get(index);
121
+ if (!list.includes(node))
122
+ list.push(node);
123
+ };
124
+ Array.from(this.children).forEach((child) => {
125
+ const slotMatch = child.getAttribute('slot')?.match(/^panel-(\d+)$/);
126
+ if (slotMatch) {
127
+ register(child, Number(slotMatch[1]));
128
+ return;
129
+ }
130
+ const panelIndex = child.dataset.panelIndex;
131
+ if (panelIndex !== undefined)
132
+ register(child, Number(panelIndex));
133
+ });
134
+ this.panel
135
+ ?.querySelectorAll(':scope > .designbase-wc-tabs__panel-inner > [data-panel-index]')
136
+ .forEach((child) => {
137
+ if (child instanceof HTMLElement) {
138
+ register(child, Number(child.dataset.panelIndex));
139
+ }
140
+ });
141
+ Array.from(this.inactivePanels.children).forEach((child) => {
142
+ if (child instanceof HTMLElement && child.dataset.panelIndex !== undefined) {
143
+ register(child, Number(child.dataset.panelIndex));
144
+ }
145
+ });
146
+ return map;
147
+ }
148
+ render() {
149
+ this.isRendering = true;
150
+ const panelContent = this.collectPanelContent();
151
+ const labels = this.labels;
152
+ const tabItems = this.tabItems;
153
+ const activeIndex = Math.min(Math.max(this.activeIndex, 0), Math.max(labels.length - 1, 0));
154
+ const resolvedSize = SIZES.includes(this.size) ? this.size : 'm';
155
+ const resolvedOrientation = ORIENTATIONS.includes(this.orientation)
156
+ ? this.orientation
157
+ : 'horizontal';
158
+ const resolvedVariant = VARIANTS.includes(this.variant)
159
+ ? this.variant
160
+ : 'default';
161
+ const showIndicator = resolvedVariant === 'default';
162
+ this.className = [
163
+ 'designbase-wc-tabs',
164
+ `designbase-wc-tabs--${resolvedOrientation}`,
165
+ `designbase-wc-tabs--${resolvedSize}`,
166
+ `designbase-wc-tabs--${resolvedVariant}`,
167
+ this.fullWidth && 'designbase-wc-tabs--full-width',
168
+ ]
169
+ .filter(Boolean)
170
+ .join(' ');
171
+ this.querySelectorAll(':scope > .designbase-wc-tabs__list, :scope > .designbase-wc-tabs__panel').forEach((node) => node.remove());
172
+ this.list = document.createElement('div');
173
+ this.list.className = [
174
+ 'designbase-wc-tabs__list',
175
+ `designbase-wc-tabs__list--${resolvedOrientation}`,
176
+ this.fullWidth && 'designbase-wc-tabs__list--full-width',
177
+ ]
178
+ .filter(Boolean)
179
+ .join(' ');
180
+ this.list.setAttribute('role', 'tablist');
181
+ this.list.setAttribute('aria-orientation', resolvedOrientation);
182
+ this.list.setAttribute('aria-label', '탭 목록');
183
+ this.tabButtons = [];
184
+ labels.forEach((label, index) => {
185
+ const config = tabItems[index];
186
+ const disabled = Boolean(config?.disabled);
187
+ const isSelected = index === activeIndex;
188
+ const button = document.createElement('button');
189
+ button.type = 'button';
190
+ button.className = [
191
+ 'designbase-wc-tabs__tab',
192
+ isSelected && 'designbase-wc-tabs__tab--selected',
193
+ disabled && 'designbase-wc-tabs__tab--disabled',
194
+ ]
195
+ .filter(Boolean)
196
+ .join(' ');
197
+ button.setAttribute('role', 'tab');
198
+ button.setAttribute('aria-selected', String(isSelected));
199
+ button.setAttribute('aria-controls', `panel-${index}`);
200
+ button.id = `tab-${index}`;
201
+ button.tabIndex = isSelected ? 0 : -1;
202
+ button.disabled = disabled;
203
+ if (config?.icon) {
204
+ const iconWrap = document.createElement('span');
205
+ iconWrap.className = 'designbase-wc-tabs__tab-icon';
206
+ const iconSize = resolvedSize === 's' ? 16 : resolvedSize === 'l' ? 20 : 18;
207
+ iconWrap.append(createDbIcon(config.icon, iconSize));
208
+ button.append(iconWrap);
209
+ }
210
+ const labelEl = document.createElement('span');
211
+ labelEl.className = 'designbase-wc-tabs__tab-label';
212
+ labelEl.textContent = label;
213
+ button.append(labelEl);
214
+ button.addEventListener('click', () => this.select(index));
215
+ button.addEventListener('keydown', (event) => this.handleKeyDown(event, index));
216
+ this.list?.append(button);
217
+ this.tabButtons.push(button);
218
+ });
219
+ if (showIndicator) {
220
+ this.indicator = document.createElement('span');
221
+ this.indicator.className = 'designbase-wc-tabs__indicator designbase-wc-tabs__indicator--no-transition';
222
+ this.list.append(this.indicator);
223
+ requestAnimationFrame(() => this.updateIndicator(false));
224
+ }
225
+ else {
226
+ this.indicator = undefined;
227
+ }
228
+ this.panel = document.createElement('div');
229
+ this.panel.className = 'designbase-wc-tabs__panel';
230
+ this.panel.setAttribute('role', 'tabpanel');
231
+ this.panel.id = `panel-${activeIndex}`;
232
+ this.panel.setAttribute('aria-labelledby', `tab-${activeIndex}`);
233
+ this.panel.tabIndex = 0;
234
+ const panelInner = document.createElement('div');
235
+ panelInner.className = 'designbase-wc-tabs__panel-inner';
236
+ panelContent.forEach((nodes, index) => {
237
+ nodes.forEach((node) => {
238
+ node.removeAttribute('slot');
239
+ node.dataset.panelIndex = String(index);
240
+ if (index === activeIndex) {
241
+ panelInner.append(node);
242
+ }
243
+ else {
244
+ this.inactivePanels.append(node);
245
+ }
246
+ });
247
+ });
248
+ this.panel.append(panelInner);
249
+ this.append(this.list, this.panel);
250
+ requestAnimationFrame(() => {
251
+ this.handleListScroll();
252
+ if (showIndicator)
253
+ this.updateIndicator(false);
254
+ });
255
+ this.isRendering = false;
256
+ }
257
+ select(index) {
258
+ const labels = this.labels;
259
+ const tabItems = this.tabItems;
260
+ if (!labels[index] || tabItems[index]?.disabled)
261
+ return;
262
+ this.activeIndex = index;
263
+ const id = tabItems[index]?.id || String(index);
264
+ this.setAttribute('selected-id', id);
265
+ this.dispatchEvent(new CustomEvent('db-change', {
266
+ detail: { index, label: labels[index], id },
267
+ bubbles: true,
268
+ composed: true,
269
+ }));
270
+ this.render();
271
+ }
272
+ handleKeyDown(event, index) {
273
+ const labels = this.labels;
274
+ const tabItems = this.tabItems;
275
+ let nextIndex = index;
276
+ if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {
277
+ nextIndex = (index + 1) % labels.length;
278
+ }
279
+ else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {
280
+ nextIndex = (index - 1 + labels.length) % labels.length;
281
+ }
282
+ else if (event.key === 'Home') {
283
+ nextIndex = 0;
284
+ }
285
+ else if (event.key === 'End') {
286
+ nextIndex = labels.length - 1;
287
+ }
288
+ else if (event.key === 'Enter' || event.key === ' ') {
289
+ event.preventDefault();
290
+ this.select(index);
291
+ return;
292
+ }
293
+ else {
294
+ return;
295
+ }
296
+ event.preventDefault();
297
+ let attempts = 0;
298
+ while (tabItems[nextIndex]?.disabled && attempts < labels.length) {
299
+ if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {
300
+ nextIndex = (nextIndex - 1 + labels.length) % labels.length;
301
+ }
302
+ else {
303
+ nextIndex = (nextIndex + 1) % labels.length;
304
+ }
305
+ attempts += 1;
306
+ }
307
+ this.tabButtons[nextIndex]?.focus();
308
+ }
309
+ updateIndicator(animate = false) {
310
+ const active = this.list?.querySelector('.designbase-wc-tabs__tab--selected');
311
+ if (!active || !this.indicator)
312
+ return;
313
+ const isVertical = this.orientation === 'vertical';
314
+ this.indicator.classList.toggle('designbase-wc-tabs__indicator--no-transition', !animate);
315
+ this.indicator.classList.add(isVertical
316
+ ? 'designbase-wc-tabs__indicator--vertical'
317
+ : 'designbase-wc-tabs__indicator--horizontal');
318
+ this.indicator.classList.add('designbase-wc-tabs__indicator--ready');
319
+ if (isVertical) {
320
+ this.indicator.style.width = '2px';
321
+ this.indicator.style.height = `${active.offsetHeight}px`;
322
+ this.indicator.style.transform = `translate3d(0, ${active.offsetTop}px, 0)`;
323
+ }
324
+ else {
325
+ this.indicator.style.width = `${active.offsetWidth}px`;
326
+ this.indicator.style.height = '2px';
327
+ this.indicator.style.transform = `translate3d(${active.offsetLeft}px, 0, 0)`;
328
+ }
329
+ }
330
+ }
331
+ if (!customElements.get('db-tabs')) {
332
+ customElements.define('db-tabs', DbTabs);
333
+ }
334
+
335
+ export { DbTabs };
@@ -1 +1,162 @@
1
- const t="designbase-wc-testimonial",e=["list","card"];class DbTestimonial extends HTMLElement{constructor(){super(...arguments),this.built=!1}static get observedAttributes(){return["quote","author","role","company","avatar","avatar-initials","rating","max-rating","variant","align"]}connectedCallback(){this.built||(this.built=!0,this.build()),this.updateUI()}attributeChangedCallback(){this.built&&this.updateUI()}build(){this.innerEl=document.createElement("div"),this.quoteEl=document.createElement("p"),this.quoteEl.className=`${t}__quote`,this.footerEl=document.createElement("div"),this.footerEl.className=`${t}__footer`,this.avatarWrapEl=document.createElement("div"),this.avatarWrapEl.className=`${t}__avatar`,this.avatarEl=document.createElement("db-avatar"),this.avatarEl.className=`${t}__avatar-image`,this.avatarWrapEl.append(this.avatarEl);const e=document.createElement("div");e.className=`${t}__meta`,this.authorEl=document.createElement("span"),this.authorEl.className=`${t}__author`,this.roleEl=document.createElement("span"),this.roleEl.className=`${t}__role`,this.ratingEl=document.createElement("db-rating"),this.ratingEl.className=`${t}__rating`,this.ratingEl.setAttribute("display","stars"),this.ratingEl.setAttribute("variant","inline"),this.ratingEl.setAttribute("allow-half",""),this.ratingEl.setAttribute("readonly",""),this.ratingEl.setAttribute("hover-effect","false"),this.ratingEl.setAttribute("color","primary"),this.ratingEl.hidden=!0,e.append(this.authorEl,this.roleEl,this.ratingEl),this.footerEl.append(this.avatarWrapEl,e),this.extraEl=document.createElement("div"),this.extraEl.className=`${t}__extra`,this.extraEl.hidden=!0,this.innerEl.append(this.quoteEl,this.footerEl,this.extraEl),this.append(this.innerEl)}getVariant(){const t=this.getAttribute("variant")||"card";return e.includes(t)?t:"card"}getAvatarSize(){return"list"===this.getVariant()?"s":"m"}syncExtraContent(){if(!this.extraEl)return;const t=Array.from(this.childNodes).filter(t=>t!==this.innerEl&&(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE&&t.textContent?.trim()));if(0===t.length)return this.extraEl.hidden=!0,void this.extraEl.replaceChildren();this.extraEl.hidden=!1,this.extraEl.replaceChildren(...t.map(t=>t.cloneNode(!0)))}updateUI(){const e=this.getAttribute("quote")||"",i=this.getAttribute("author")||"",a=this.getAttribute("role")||"",r=this.getAttribute("company")||"",s=this.getAttribute("avatar")||"",l=this.getAttribute("avatar-initials")||"",n=this.getAttribute("rating"),h=Number(this.getAttribute("max-rating")||5),o=null!==n&&""!==n?function clampRating(t,e){if("number"==typeof t&&!Number.isNaN(t))return t<0?0:t>e?e:Math.round(10*t)/10}(Number(n),h):void 0,E=this.getVariant(),u=this.getAttribute("align")||"left",d=[t,`${t}--variant-${E}`,"left"!==u?`${t}--align-${u}`:""].filter(Boolean).join(" ");this.className=d,this.innerEl&&(this.innerEl.className=`${t}__inner`),this.quoteEl&&(this.quoteEl.textContent=e?`“${e}”`:""),this.authorEl&&(this.authorEl.textContent=i);const c=[a,r].filter(Boolean).join(" · ");this.roleEl&&(this.roleEl.textContent=c,this.roleEl.hidden=!c);const m=Boolean(s||l);this.avatarWrapEl&&(this.avatarWrapEl.hidden=!m),this.avatarEl&&m&&(this.avatarEl.setAttribute("size",this.getAvatarSize()),s?this.avatarEl.setAttribute("src",s):this.avatarEl.removeAttribute("src"),l?this.avatarEl.setAttribute("initials",l):this.avatarEl.removeAttribute("initials"),this.avatarEl.setAttribute("alt",`${i} 프로필 이미지`)),this.ratingEl&&("number"==typeof o?(this.ratingEl.hidden=!1,this.ratingEl.setAttribute("value",String(o)),this.ratingEl.setAttribute("max-value",String(h)),this.ratingEl.setAttribute("size","s")):this.ratingEl.hidden=!0),this.syncExtraContent()}}customElements.get("db-testimonial")||customElements.define("db-testimonial",DbTestimonial);export{DbTestimonial};
1
+ const CLASS = 'designbase-wc-testimonial';
2
+ const VARIANTS = ['list', 'card'];
3
+ function clampRating(rating, maxRating) {
4
+ if (typeof rating !== 'number' || Number.isNaN(rating))
5
+ return undefined;
6
+ if (rating < 0)
7
+ return 0;
8
+ if (rating > maxRating)
9
+ return maxRating;
10
+ return Math.round(rating * 10) / 10;
11
+ }
12
+ class DbTestimonial extends HTMLElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.built = false;
16
+ }
17
+ static get observedAttributes() {
18
+ return [
19
+ 'quote',
20
+ 'author',
21
+ 'role',
22
+ 'company',
23
+ 'avatar',
24
+ 'avatar-initials',
25
+ 'rating',
26
+ 'max-rating',
27
+ 'variant',
28
+ 'align',
29
+ ];
30
+ }
31
+ connectedCallback() {
32
+ if (!this.built) {
33
+ this.built = true;
34
+ this.build();
35
+ }
36
+ this.updateUI();
37
+ }
38
+ attributeChangedCallback() {
39
+ if (!this.built)
40
+ return;
41
+ this.updateUI();
42
+ }
43
+ build() {
44
+ this.innerEl = document.createElement('div');
45
+ this.quoteEl = document.createElement('p');
46
+ this.quoteEl.className = `${CLASS}__quote`;
47
+ this.footerEl = document.createElement('div');
48
+ this.footerEl.className = `${CLASS}__footer`;
49
+ this.avatarWrapEl = document.createElement('div');
50
+ this.avatarWrapEl.className = `${CLASS}__avatar`;
51
+ this.avatarEl = document.createElement('db-avatar');
52
+ this.avatarEl.className = `${CLASS}__avatar-image`;
53
+ this.avatarWrapEl.append(this.avatarEl);
54
+ const meta = document.createElement('div');
55
+ meta.className = `${CLASS}__meta`;
56
+ this.authorEl = document.createElement('span');
57
+ this.authorEl.className = `${CLASS}__author`;
58
+ this.roleEl = document.createElement('span');
59
+ this.roleEl.className = `${CLASS}__role`;
60
+ this.ratingEl = document.createElement('db-rating');
61
+ this.ratingEl.className = `${CLASS}__rating`;
62
+ this.ratingEl.setAttribute('display', 'stars');
63
+ this.ratingEl.setAttribute('variant', 'inline');
64
+ this.ratingEl.setAttribute('allow-half', '');
65
+ this.ratingEl.setAttribute('readonly', '');
66
+ this.ratingEl.setAttribute('hover-effect', 'false');
67
+ this.ratingEl.setAttribute('color', 'primary');
68
+ this.ratingEl.hidden = true;
69
+ meta.append(this.authorEl, this.roleEl, this.ratingEl);
70
+ this.footerEl.append(this.avatarWrapEl, meta);
71
+ this.extraEl = document.createElement('div');
72
+ this.extraEl.className = `${CLASS}__extra`;
73
+ this.extraEl.hidden = true;
74
+ this.innerEl.append(this.quoteEl, this.footerEl, this.extraEl);
75
+ this.append(this.innerEl);
76
+ }
77
+ getVariant() {
78
+ const value = this.getAttribute('variant') || 'card';
79
+ return VARIANTS.includes(value) ? value : 'card';
80
+ }
81
+ getAvatarSize() {
82
+ return this.getVariant() === 'list' ? 's' : 'm';
83
+ }
84
+ syncExtraContent() {
85
+ if (!this.extraEl)
86
+ return;
87
+ const slotted = Array.from(this.childNodes).filter((node) => node !== this.innerEl &&
88
+ (node.nodeType === Node.ELEMENT_NODE ||
89
+ (node.nodeType === Node.TEXT_NODE && node.textContent?.trim())));
90
+ if (slotted.length === 0) {
91
+ this.extraEl.hidden = true;
92
+ this.extraEl.replaceChildren();
93
+ return;
94
+ }
95
+ this.extraEl.hidden = false;
96
+ this.extraEl.replaceChildren(...slotted.map((node) => node.cloneNode(true)));
97
+ }
98
+ updateUI() {
99
+ const quote = this.getAttribute('quote') || '';
100
+ const author = this.getAttribute('author') || '';
101
+ const role = this.getAttribute('role') || '';
102
+ const company = this.getAttribute('company') || '';
103
+ const avatar = this.getAttribute('avatar') || '';
104
+ const avatarInitials = this.getAttribute('avatar-initials') || '';
105
+ const ratingRaw = this.getAttribute('rating');
106
+ const maxRating = Number(this.getAttribute('max-rating') || 5);
107
+ const rating = ratingRaw !== null && ratingRaw !== '' ? clampRating(Number(ratingRaw), maxRating) : undefined;
108
+ const variant = this.getVariant();
109
+ const align = this.getAttribute('align') || 'left';
110
+ const className = [
111
+ CLASS,
112
+ `${CLASS}--variant-${variant}`,
113
+ align !== 'left' ? `${CLASS}--align-${align}` : '',
114
+ ]
115
+ .filter(Boolean)
116
+ .join(' ');
117
+ this.className = className;
118
+ if (this.innerEl)
119
+ this.innerEl.className = `${CLASS}__inner`;
120
+ if (this.quoteEl) {
121
+ this.quoteEl.textContent = quote ? `“${quote}”` : '';
122
+ }
123
+ if (this.authorEl)
124
+ this.authorEl.textContent = author;
125
+ const roleText = [role, company].filter(Boolean).join(' · ');
126
+ if (this.roleEl) {
127
+ this.roleEl.textContent = roleText;
128
+ this.roleEl.hidden = !roleText;
129
+ }
130
+ const shouldRenderAvatar = Boolean(avatar || avatarInitials);
131
+ if (this.avatarWrapEl)
132
+ this.avatarWrapEl.hidden = !shouldRenderAvatar;
133
+ if (this.avatarEl && shouldRenderAvatar) {
134
+ this.avatarEl.setAttribute('size', this.getAvatarSize());
135
+ if (avatar)
136
+ this.avatarEl.setAttribute('src', avatar);
137
+ else
138
+ this.avatarEl.removeAttribute('src');
139
+ if (avatarInitials)
140
+ this.avatarEl.setAttribute('initials', avatarInitials);
141
+ else
142
+ this.avatarEl.removeAttribute('initials');
143
+ this.avatarEl.setAttribute('alt', `${author} 프로필 이미지`);
144
+ }
145
+ if (this.ratingEl) {
146
+ if (typeof rating === 'number') {
147
+ this.ratingEl.hidden = false;
148
+ this.ratingEl.setAttribute('value', String(rating));
149
+ this.ratingEl.setAttribute('max-value', String(maxRating));
150
+ this.ratingEl.setAttribute('size', 's');
151
+ }
152
+ else {
153
+ this.ratingEl.hidden = true;
154
+ }
155
+ }
156
+ this.syncExtraContent();
157
+ }
158
+ }
159
+ if (!customElements.get('db-testimonial'))
160
+ customElements.define('db-testimonial', DbTestimonial);
161
+
162
+ export { DbTestimonial };