@designbasekorea/ui-wc 0.5.6 → 0.6.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 (202) hide show
  1. package/dist/chunks/lottie-0e23d630.js +1 -0
  2. package/dist/esm/components/animation-background/canvas-controller.js +1 -121
  3. package/dist/esm/components/animation-background/controls.js +1 -180
  4. package/dist/esm/components/animation-background/graphite-controller.js +1 -196
  5. package/dist/esm/components/animation-background/graphite-presets.js +1 -42
  6. package/dist/esm/components/animation-background/graphite-shader.js +1 -111
  7. package/dist/esm/components/animation-background/layers.js +1 -369
  8. package/dist/esm/components/animation-background/lumina-presets.js +1 -53
  9. package/dist/esm/components/animation-background/lumina-shaders.js +1 -181
  10. package/dist/esm/components/animation-background/lumina-utils.js +1 -60
  11. package/dist/esm/components/animation-background/particle-defaults.js +1 -36
  12. package/dist/esm/components/animation-background/renderers.js +1 -167
  13. package/dist/esm/components/animation-background/shader-controller.js +1 -154
  14. package/dist/esm/components/color-picker-utils.js +1 -134
  15. package/dist/esm/components/date-picker-utils.js +1 -140
  16. package/dist/esm/components/db-accordion.js +1 -304
  17. package/dist/esm/components/db-ad-banner.js +1 -455
  18. package/dist/esm/components/db-ai-chat-list.d.ts +43 -0
  19. package/dist/esm/components/db-ai-chat-list.js +1 -0
  20. package/dist/esm/components/db-ai-chat.d.ts +159 -0
  21. package/dist/esm/components/db-ai-chat.js +1 -0
  22. package/dist/esm/components/db-alert.js +1 -149
  23. package/dist/esm/components/db-animation-background.js +1 -486
  24. package/dist/esm/components/db-animation-text.js +1 -601
  25. package/dist/esm/components/db-app-badge.js +1 -88
  26. package/dist/esm/components/db-audio-player.js +1 -752
  27. package/dist/esm/components/db-avatar.js +1 -188
  28. package/dist/esm/components/db-backdrop.js +1 -139
  29. package/dist/esm/components/db-badge.js +1 -91
  30. package/dist/esm/components/db-banner.js +1 -188
  31. package/dist/esm/components/db-bottom-navigation.js +1 -146
  32. package/dist/esm/components/db-bottom-sheet.js +1 -481
  33. package/dist/esm/components/db-breadcrumbs.js +1 -329
  34. package/dist/esm/components/db-button.js +1 -316
  35. package/dist/esm/components/db-calendar.js +1 -675
  36. package/dist/esm/components/db-card.js +1 -265
  37. package/dist/esm/components/db-carousel.js +1 -264
  38. package/dist/esm/components/db-chat-composer.d.ts +134 -0
  39. package/dist/esm/components/db-chat-composer.js +1 -0
  40. package/dist/esm/components/db-chat-list.d.ts +47 -0
  41. package/dist/esm/components/db-chat-list.js +1 -0
  42. package/dist/esm/components/db-chat-message.d.ts +39 -0
  43. package/dist/esm/components/db-chat-message.js +1 -0
  44. package/dist/esm/components/db-chat-orb.d.ts +99 -0
  45. package/dist/esm/components/db-chat-orb.js +1 -0
  46. package/dist/esm/components/db-chat-room.d.ts +71 -0
  47. package/dist/esm/components/db-chat-room.js +1 -0
  48. package/dist/esm/components/db-chat-suggestions.d.ts +44 -0
  49. package/dist/esm/components/db-chat-suggestions.js +1 -0
  50. package/dist/esm/components/db-chat-typing.d.ts +22 -0
  51. package/dist/esm/components/db-chat-typing.js +1 -0
  52. package/dist/esm/components/db-chat-welcome.d.ts +32 -0
  53. package/dist/esm/components/db-chat-welcome.js +1 -0
  54. package/dist/esm/components/db-chat-widget.d.ts +146 -0
  55. package/dist/esm/components/db-chat-widget.js +1 -0
  56. package/dist/esm/components/db-checkbox.js +1 -202
  57. package/dist/esm/components/db-chip.js +1 -104
  58. package/dist/esm/components/db-code-block.js +1 -304
  59. package/dist/esm/components/db-color-picker.js +1 -746
  60. package/dist/esm/components/db-confirm.js +1 -191
  61. package/dist/esm/components/db-container.js +1 -39
  62. package/dist/esm/components/db-context-menu.js +1 -265
  63. package/dist/esm/components/db-countdown.js +1 -146
  64. package/dist/esm/components/db-cursor-follower.js +1 -173
  65. package/dist/esm/components/db-date-picker.js +1 -837
  66. package/dist/esm/components/db-divider.js +1 -66
  67. package/dist/esm/components/db-download-progress.d.ts +89 -0
  68. package/dist/esm/components/db-download-progress.js +1 -0
  69. package/dist/esm/components/db-drawer.js +1 -245
  70. package/dist/esm/components/db-dropdown.js +1 -493
  71. package/dist/esm/components/db-dropzone.js +1 -266
  72. package/dist/esm/components/db-email-verify.d.ts +62 -0
  73. package/dist/esm/components/db-email-verify.js +1 -0
  74. package/dist/esm/components/db-empty-state.js +1 -97
  75. package/dist/esm/components/db-file-uploader.js +1 -256
  76. package/dist/esm/components/db-floating-action-button.js +1 -139
  77. package/dist/esm/components/db-footer.js +1 -385
  78. package/dist/esm/components/db-form.js +1 -566
  79. package/dist/esm/components/db-gantt.js +1 -882
  80. package/dist/esm/components/db-gradient.js +1 -133
  81. package/dist/esm/components/db-grid-background.js +1 -909
  82. package/dist/esm/components/db-grid.js +1 -73
  83. package/dist/esm/components/db-icons.d.ts +3 -0
  84. package/dist/esm/components/db-icons.js +1 -82
  85. package/dist/esm/components/db-image-list.js +1 -214
  86. package/dist/esm/components/db-image-placeholder.js +1 -96
  87. package/dist/esm/components/db-image.js +1 -289
  88. package/dist/esm/components/db-indicator.js +1 -517
  89. package/dist/esm/components/db-input.js +1 -420
  90. package/dist/esm/components/db-kanban.js +1 -538
  91. package/dist/esm/components/db-label.js +1 -66
  92. package/dist/esm/components/db-lightbox.js +1 -372
  93. package/dist/esm/components/db-list.js +1 -340
  94. package/dist/esm/components/db-logo-svg.js +1 -72
  95. package/dist/esm/components/db-logo.js +1 -106
  96. package/dist/esm/components/db-lottie.js +1 -109
  97. package/dist/esm/components/db-markdown-editor.js +1 -458
  98. package/dist/esm/components/db-marquee.js +1 -402
  99. package/dist/esm/components/db-masonry.js +1 -94
  100. package/dist/esm/components/db-menu-item.js +1 -211
  101. package/dist/esm/components/db-modal.js +1 -522
  102. package/dist/esm/components/db-navbar.js +1 -680
  103. package/dist/esm/components/db-onboarding-modal.js +1 -322
  104. package/dist/esm/components/db-otp-input.d.ts +53 -0
  105. package/dist/esm/components/db-otp-input.js +1 -0
  106. package/dist/esm/components/db-page-header.js +1 -312
  107. package/dist/esm/components/db-pagination.js +1 -271
  108. package/dist/esm/components/db-phone-verify.d.ts +61 -0
  109. package/dist/esm/components/db-phone-verify.js +1 -0
  110. package/dist/esm/components/db-popover.js +1 -580
  111. package/dist/esm/components/db-progress-step.js +1 -166
  112. package/dist/esm/components/db-progress.js +1 -171
  113. package/dist/esm/components/db-progressbar.js +1 -72
  114. package/dist/esm/components/db-radio.js +1 -172
  115. package/dist/esm/components/db-random-gradient.js +1 -121
  116. package/dist/esm/components/db-range-slider.js +1 -811
  117. package/dist/esm/components/db-rating.js +1 -325
  118. package/dist/esm/components/db-reorder.js +1 -286
  119. package/dist/esm/components/db-resizable-panels.js +1 -282
  120. package/dist/esm/components/db-scroll-area.js +1 -126
  121. package/dist/esm/components/db-search-bar.js +1 -668
  122. package/dist/esm/components/db-section-app-download.js +1 -101
  123. package/dist/esm/components/db-section-contact.js +1 -102
  124. package/dist/esm/components/db-section-cta.js +1 -150
  125. package/dist/esm/components/db-section-faq.js +1 -120
  126. package/dist/esm/components/db-section-feature-grid.js +1 -137
  127. package/dist/esm/components/db-section-feature.js +1 -179
  128. package/dist/esm/components/db-section-hero.js +1 -243
  129. package/dist/esm/components/db-section-logo-cloud.js +1 -138
  130. package/dist/esm/components/db-section-pricing.js +1 -166
  131. package/dist/esm/components/db-section-stats.js +1 -129
  132. package/dist/esm/components/db-section-testimonials.js +1 -252
  133. package/dist/esm/components/db-section.js +1 -385
  134. package/dist/esm/components/db-segment-control.js +1 -231
  135. package/dist/esm/components/db-select.js +1 -571
  136. package/dist/esm/components/db-share-icons.js +1 -40
  137. package/dist/esm/components/db-share.js +1 -489
  138. package/dist/esm/components/db-sidebar.js +1 -1068
  139. package/dist/esm/components/db-skeleton.js +1 -94
  140. package/dist/esm/components/db-spinner.js +1 -102
  141. package/dist/esm/components/db-split-view.js +1 -297
  142. package/dist/esm/components/db-stack.js +1 -46
  143. package/dist/esm/components/db-stat.js +1 -218
  144. package/dist/esm/components/db-stepper.js +1 -398
  145. package/dist/esm/components/db-table.js +1 -412
  146. package/dist/esm/components/db-tabs.js +1 -335
  147. package/dist/esm/components/db-testimonial.d.ts +2 -0
  148. package/dist/esm/components/db-testimonial.js +1 -162
  149. package/dist/esm/components/db-textarea.js +1 -233
  150. package/dist/esm/components/db-time-picker.js +1 -523
  151. package/dist/esm/components/db-timeline.js +1 -174
  152. package/dist/esm/components/db-toast.js +1 -158
  153. package/dist/esm/components/db-toggle.js +1 -162
  154. package/dist/esm/components/db-toolbar.js +1 -94
  155. package/dist/esm/components/db-tooltip.js +1 -440
  156. package/dist/esm/components/db-top-banner.js +1 -121
  157. package/dist/esm/components/db-tutorial.js +1 -324
  158. package/dist/esm/components/db-two-factor.d.ts +60 -0
  159. package/dist/esm/components/db-two-factor.js +1 -0
  160. package/dist/esm/components/db-video-player.js +1 -503
  161. package/dist/esm/components/db-youtube-player.js +1 -194
  162. package/dist/esm/components/highlight-code.js +1 -65
  163. package/dist/esm/components/input-validation.js +1 -50
  164. package/dist/esm/components/marketing-block-host-utils.js +1 -9
  165. package/dist/esm/components/number-scrub.js +1 -117
  166. package/dist/esm/components/random-gradient-palettes.js +1 -67
  167. package/dist/esm/components/section-block-header-utils.js +1 -48
  168. package/dist/esm/helpers/confirm.js +1 -52
  169. package/dist/esm/helpers/toast.js +1 -73
  170. package/dist/esm/index.d.ts +16 -0
  171. package/dist/esm/index.js +1 -111
  172. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-bash.js +1 -0
  173. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-clike.js +1 -0
  174. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-css.js +1 -0
  175. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-javascript.js +1 -0
  176. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-json.js +1 -0
  177. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-jsx.js +1 -0
  178. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-markup.js +1 -0
  179. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-scss.js +1 -0
  180. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-tsx.js +1 -0
  181. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-typescript.js +1 -0
  182. package/dist/index.cjs +1 -55414
  183. package/dist/index.css +1 -1
  184. package/dist/index.d.ts +1091 -2
  185. package/dist/index.esm.js +1 -38284
  186. package/dist/react/chunks/lottie-14e7addb.js +1 -0
  187. package/dist/react/index.cjs +1 -56503
  188. package/dist/react/index.d.ts +1620 -54
  189. package/dist/react/index.esm.js +1 -39373
  190. package/package.json +1 -1
  191. package/dist/chunks/lottie-e273b936.js +0 -17032
  192. package/dist/esm/node_modules/prismjs/components/prism-bash.js +0 -235
  193. package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -31
  194. package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -64
  195. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -172
  196. package/dist/esm/node_modules/prismjs/components/prism-json.js +0 -27
  197. package/dist/esm/node_modules/prismjs/components/prism-jsx.js +0 -143
  198. package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -186
  199. package/dist/esm/node_modules/prismjs/components/prism-scss.js +0 -81
  200. package/dist/esm/node_modules/prismjs/components/prism-tsx.js +0 -15
  201. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -60
  202. package/dist/react/chunks/lottie-72a4c6d4.js +0 -17032
@@ -1,335 +1 @@
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
+ 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};
@@ -3,6 +3,8 @@ declare class DbTestimonial extends HTMLElement {
3
3
  private built;
4
4
  private innerEl?;
5
5
  private quoteEl?;
6
+ private backgroundEl?;
7
+ private logoEl?;
6
8
  private footerEl?;
7
9
  private extraEl?;
8
10
  private avatarWrapEl?;
@@ -1,162 +1 @@
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 };
1
+ const t="designbase-wc-testimonial",e=["list","card","logo","image","text"];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","logo","logo-alt","image","image-alt","tone","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.backgroundEl=document.createElement("img"),this.backgroundEl.className=`${t}__background`,this.backgroundEl.hidden=!0,this.logoEl=document.createElement("img"),this.logoEl.className=`${t}__logo`,this.logoEl.hidden=!0,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.logoEl,this.quoteEl,this.footerEl,this.extraEl),this.append(this.backgroundEl,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"),o=Number(this.getAttribute("max-rating")||5),h=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),o):void 0,E=this.getVariant(),u=this.getAttribute("logo")||"",d=this.getAttribute("logo-alt")||"",g=this.getAttribute("image")||"",c=this.getAttribute("image-alt")||"",m=this.getAttribute("tone")||"violet",b=this.getAttribute("align")||"left",v=[t,`${t}--variant-${E}`,`${t}--tone-${m}`,"left"!==b?`${t}--align-${b}`:""].filter(Boolean).join(" ");this.className=v,this.innerEl&&(this.innerEl.className=`${t}__inner`),this.quoteEl&&(this.quoteEl.textContent=e?`“${e}”`:""),this.backgroundEl&&(this.backgroundEl.hidden="image"!==E||!g,g&&(this.backgroundEl.src=g,this.backgroundEl.alt=c)),this.logoEl&&(this.logoEl.hidden="logo"!==E||!u,u&&(this.logoEl.src=u,this.logoEl.alt=d)),this.authorEl&&(this.authorEl.textContent=i);const p=[a,r].filter(Boolean).join(" · ");this.roleEl&&(this.roleEl.textContent=p,this.roleEl.hidden=!p);const A=Boolean(s||l);this.avatarWrapEl&&(this.avatarWrapEl.hidden=!A),this.avatarEl&&A&&(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 h?(this.ratingEl.hidden=!1,this.ratingEl.setAttribute("value",String(h)),this.ratingEl.setAttribute("max-value",String(o)),this.ratingEl.setAttribute("size","s")):this.ratingEl.hidden=!0),this.syncExtraContent()}}customElements.get("db-testimonial")||customElements.define("db-testimonial",DbTestimonial);export{DbTestimonial};