@designbasekorea/ui-wc 0.5.6 → 0.6.1

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 (193) hide show
  1. package/dist/chunks/lottie-35a9b0f5.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 +64 -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 +63 -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.d.ts +20 -0
  139. package/dist/esm/components/db-sidebar.js +1 -1068
  140. package/dist/esm/components/db-skeleton.js +1 -94
  141. package/dist/esm/components/db-spinner.js +1 -102
  142. package/dist/esm/components/db-split-view.js +1 -297
  143. package/dist/esm/components/db-stack.js +1 -46
  144. package/dist/esm/components/db-stat.js +1 -218
  145. package/dist/esm/components/db-stepper.js +1 -398
  146. package/dist/esm/components/db-table.js +1 -412
  147. package/dist/esm/components/db-tabs.js +1 -335
  148. package/dist/esm/components/db-testimonial.d.ts +2 -0
  149. package/dist/esm/components/db-testimonial.js +1 -162
  150. package/dist/esm/components/db-textarea.js +1 -233
  151. package/dist/esm/components/db-time-picker.js +1 -523
  152. package/dist/esm/components/db-timeline.js +1 -174
  153. package/dist/esm/components/db-toast.js +1 -158
  154. package/dist/esm/components/db-toggle.js +1 -162
  155. package/dist/esm/components/db-toolbar.js +1 -94
  156. package/dist/esm/components/db-tooltip.js +1 -440
  157. package/dist/esm/components/db-top-banner.js +1 -121
  158. package/dist/esm/components/db-tutorial.js +1 -324
  159. package/dist/esm/components/db-two-factor.d.ts +71 -0
  160. package/dist/esm/components/db-two-factor.js +1 -0
  161. package/dist/esm/components/db-video-player.js +1 -503
  162. package/dist/esm/components/db-youtube-player.js +1 -194
  163. package/dist/esm/components/highlight-code.js +1 -65
  164. package/dist/esm/components/input-validation.js +1 -50
  165. package/dist/esm/components/marketing-block-host-utils.js +1 -9
  166. package/dist/esm/components/number-scrub.js +1 -117
  167. package/dist/esm/components/random-gradient-palettes.js +1 -67
  168. package/dist/esm/components/section-block-header-utils.js +1 -48
  169. package/dist/esm/helpers/confirm.js +1 -52
  170. package/dist/esm/helpers/toast.js +1 -73
  171. package/dist/esm/index.d.ts +16 -0
  172. package/dist/esm/index.js +1 -111
  173. package/dist/esm/node_modules/prismjs/components/prism-bash.js +1 -235
  174. package/dist/esm/node_modules/prismjs/components/prism-clike.js +1 -31
  175. package/dist/esm/node_modules/prismjs/components/prism-css.js +1 -64
  176. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +1 -172
  177. package/dist/esm/node_modules/prismjs/components/prism-json.js +1 -27
  178. package/dist/esm/node_modules/prismjs/components/prism-jsx.js +1 -143
  179. package/dist/esm/node_modules/prismjs/components/prism-markup.js +1 -186
  180. package/dist/esm/node_modules/prismjs/components/prism-scss.js +1 -81
  181. package/dist/esm/node_modules/prismjs/components/prism-tsx.js +1 -15
  182. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +1 -60
  183. package/dist/index.cjs +1 -55414
  184. package/dist/index.css +1 -1
  185. package/dist/index.d.ts +1125 -2
  186. package/dist/index.esm.js +1 -38284
  187. package/dist/react/chunks/lottie-14e7addb.js +1 -0
  188. package/dist/react/index.cjs +1 -56503
  189. package/dist/react/index.d.ts +1637 -21
  190. package/dist/react/index.esm.js +1 -39373
  191. package/package.json +2 -2
  192. package/dist/chunks/lottie-e273b936.js +0 -17032
  193. package/dist/react/chunks/lottie-72a4c6d4.js +0 -17032
@@ -1,265 +1 @@
1
- const VARIANTS = ['default', 'flat'];
2
- const SIZES = ['s', 'm', 'l'];
3
- class DbCard extends HTMLElement {
4
- constructor() {
5
- super(...arguments);
6
- this.selectCheckbox = null;
7
- this.imageNode = null;
8
- this.handleClick = (event) => {
9
- if (this.disabled || this.loading) {
10
- event.preventDefault();
11
- event.stopPropagation();
12
- return;
13
- }
14
- if (this.clickable) {
15
- this.dispatchEvent(new CustomEvent('db-click', { bubbles: true, composed: true }));
16
- }
17
- };
18
- this.handleKeyDown = (event) => {
19
- if (!this.clickable || (event.key !== 'Enter' && event.key !== ' '))
20
- return;
21
- event.preventDefault();
22
- this.click();
23
- };
24
- this.handleSelect = (event) => {
25
- event?.stopPropagation();
26
- if (this.disabled || this.loading || !this.selectable)
27
- return;
28
- const next = !this.selected;
29
- this.toggleAttribute('selected', next);
30
- if (this.selectCheckbox) {
31
- if (next)
32
- this.selectCheckbox.setAttribute('checked', '');
33
- else
34
- this.selectCheckbox.removeAttribute('checked');
35
- }
36
- this.dispatchEvent(new CustomEvent('db-select', {
37
- bubbles: true,
38
- composed: true,
39
- detail: { selected: next },
40
- }));
41
- };
42
- }
43
- static get observedAttributes() {
44
- return [
45
- 'variant',
46
- 'size',
47
- 'full-width',
48
- 'clickable',
49
- 'hoverable',
50
- 'selectable',
51
- 'selected',
52
- 'disabled',
53
- 'loading',
54
- 'image',
55
- 'image-alt',
56
- ];
57
- }
58
- get variant() {
59
- return this.getAttribute('variant') || 'default';
60
- }
61
- set variant(value) {
62
- this.setAttribute('variant', value);
63
- }
64
- get size() {
65
- return this.getAttribute('size') || 'm';
66
- }
67
- set size(value) {
68
- this.setAttribute('size', value);
69
- }
70
- get clickable() {
71
- return this.hasAttribute('clickable');
72
- }
73
- set clickable(value) {
74
- this.toggleAttribute('clickable', value);
75
- }
76
- get disabled() {
77
- return this.hasAttribute('disabled');
78
- }
79
- set disabled(value) {
80
- this.toggleAttribute('disabled', value);
81
- }
82
- get loading() {
83
- return this.hasAttribute('loading');
84
- }
85
- set loading(value) {
86
- this.toggleAttribute('loading', value);
87
- }
88
- get fullWidth() {
89
- return this.hasAttribute('full-width');
90
- }
91
- set fullWidth(value) {
92
- this.toggleAttribute('full-width', value);
93
- }
94
- get hoverable() {
95
- return this.hasAttribute('hoverable');
96
- }
97
- set hoverable(value) {
98
- this.toggleAttribute('hoverable', value);
99
- }
100
- get selectable() {
101
- return this.hasAttribute('selectable');
102
- }
103
- set selectable(value) {
104
- this.toggleAttribute('selectable', value);
105
- }
106
- get selected() {
107
- return this.hasAttribute('selected');
108
- }
109
- set selected(value) {
110
- this.toggleAttribute('selected', value);
111
- }
112
- connectedCallback() {
113
- this.addEventListener('click', this.handleClick);
114
- this.addEventListener('keydown', this.handleKeyDown);
115
- this.sync();
116
- }
117
- disconnectedCallback() {
118
- this.removeEventListener('click', this.handleClick);
119
- this.removeEventListener('keydown', this.handleKeyDown);
120
- }
121
- attributeChangedCallback(name) {
122
- if (!this.isConnected)
123
- return;
124
- this.sync();
125
- if (name === 'selected' && this.selectCheckbox) {
126
- if (this.selected)
127
- this.selectCheckbox.setAttribute('checked', '');
128
- else
129
- this.selectCheckbox.removeAttribute('checked');
130
- }
131
- }
132
- hasMediaSection() {
133
- const imageSrc = this.getAttribute('image');
134
- if (imageSrc)
135
- return true;
136
- return (this.querySelector(':scope > .designbase-wc-card__thumbnail, :scope > .designbase-wc-card__media, :scope > [slot="media"], :scope > [slot="thumbnail"]') !== null);
137
- }
138
- hasFooterSection() {
139
- return this.querySelector(':scope > .designbase-wc-card__footer, :scope > [slot="footer"]') !== null;
140
- }
141
- syncImageMedia() {
142
- const imageSrc = this.getAttribute('image');
143
- const userMedia = this.querySelector(':scope > .designbase-wc-card__thumbnail, :scope > .designbase-wc-card__media, :scope > [slot="media"], :scope > [slot="thumbnail"]');
144
- if (!imageSrc) {
145
- if (this.imageNode) {
146
- this.imageNode.remove();
147
- this.imageNode = null;
148
- }
149
- return;
150
- }
151
- if (userMedia && userMedia !== this.imageNode) {
152
- if (this.imageNode) {
153
- this.imageNode.remove();
154
- this.imageNode = null;
155
- }
156
- return;
157
- }
158
- if (!this.imageNode) {
159
- this.imageNode = document.createElement('div');
160
- this.imageNode.className = 'designbase-wc-card__media designbase-wc-card__thumbnail';
161
- this.imageNode.setAttribute('slot', 'media');
162
- const img = document.createElement('img');
163
- img.className = 'designbase-wc-card__thumbnail-image';
164
- this.imageNode.append(img);
165
- const first = this.querySelector(':scope > .designbase-wc-card__body, :scope > [slot="body"], :scope > .designbase-wc-card__footer, :scope > [slot="footer"]');
166
- if (first)
167
- this.insertBefore(this.imageNode, first);
168
- else
169
- this.insertBefore(this.imageNode, this.firstChild);
170
- }
171
- const img = this.imageNode.querySelector('img');
172
- if (img) {
173
- img.src = imageSrc;
174
- img.alt = this.getAttribute('image-alt') || '';
175
- }
176
- }
177
- sync() {
178
- this.syncImageMedia();
179
- this.syncAttributes();
180
- this.syncOverlays();
181
- }
182
- syncOverlays() {
183
- const existingLoading = this.querySelector(':scope > .designbase-wc-card__loading-overlay');
184
- const existingSelect = this.querySelector(':scope > .designbase-wc-card__select-overlay');
185
- if (this.loading) {
186
- if (!existingLoading) {
187
- const overlay = document.createElement('div');
188
- overlay.className = 'designbase-wc-card__loading-overlay';
189
- overlay.setAttribute('aria-live', 'polite');
190
- overlay.setAttribute('aria-busy', 'true');
191
- const spinner = document.createElement('div');
192
- spinner.className = 'designbase-wc-card__loading-spinner';
193
- overlay.append(spinner);
194
- this.append(overlay);
195
- }
196
- }
197
- else {
198
- existingLoading?.remove();
199
- }
200
- if (this.selectable) {
201
- if (!existingSelect) {
202
- const overlay = document.createElement('div');
203
- overlay.className = 'designbase-wc-card__select-overlay';
204
- overlay.addEventListener('click', (event) => this.handleSelect(event));
205
- const checkbox = document.createElement('db-checkbox');
206
- checkbox.className = 'designbase-wc-card__select-checkbox';
207
- checkbox.setAttribute('size', 's');
208
- checkbox.setAttribute('has-label', 'false');
209
- checkbox.setAttribute('aria-label', '카드 선택');
210
- if (this.selected)
211
- checkbox.setAttribute('checked', '');
212
- checkbox.addEventListener('click', (event) => event.stopPropagation());
213
- checkbox.addEventListener('db-change', (event) => {
214
- event.stopPropagation();
215
- this.handleSelect();
216
- });
217
- overlay.append(checkbox);
218
- this.append(overlay);
219
- this.selectCheckbox = checkbox;
220
- }
221
- else if (this.selectCheckbox) {
222
- if (this.selected)
223
- this.selectCheckbox.setAttribute('checked', '');
224
- else
225
- this.selectCheckbox.removeAttribute('checked');
226
- }
227
- }
228
- else {
229
- existingSelect?.remove();
230
- this.selectCheckbox = null;
231
- }
232
- }
233
- syncAttributes() {
234
- this.classList.add('designbase-wc-card');
235
- this.setAttribute('aria-disabled', String(this.disabled || this.loading));
236
- if (this.clickable && !this.disabled && !this.loading) {
237
- this.setAttribute('role', 'button');
238
- if (!this.hasAttribute('tabindex'))
239
- this.setAttribute('tabindex', '0');
240
- }
241
- else {
242
- this.removeAttribute('role');
243
- this.removeAttribute('tabindex');
244
- }
245
- VARIANTS.forEach((variant) => this.classList.remove(`designbase-wc-card--${variant}`));
246
- SIZES.forEach((size) => this.classList.remove(`designbase-wc-card--${size}`));
247
- this.classList.add(`designbase-wc-card--${VARIANTS.includes(this.variant) ? this.variant : 'default'}`);
248
- this.classList.add(`designbase-wc-card--${SIZES.includes(this.size) ? this.size : 'm'}`);
249
- this.classList.toggle('designbase-wc-card--full-width', this.hasAttribute('full-width'));
250
- this.classList.toggle('designbase-wc-card--clickable', this.clickable);
251
- this.classList.toggle('designbase-wc-card--hoverable', this.hasAttribute('hoverable'));
252
- this.classList.toggle('designbase-wc-card--selectable', this.hasAttribute('selectable'));
253
- this.classList.toggle('designbase-wc-card--selected', this.hasAttribute('selected'));
254
- this.classList.toggle('designbase-wc-card--disabled', this.disabled);
255
- this.classList.toggle('designbase-wc-card--loading', this.loading);
256
- this.classList.toggle('designbase-wc-card--with-media', this.hasMediaSection());
257
- this.classList.toggle('designbase-wc-card--with-thumbnail', this.hasMediaSection());
258
- this.classList.toggle('designbase-wc-card--with-footer', this.hasFooterSection());
259
- }
260
- }
261
- if (!customElements.get('db-card')) {
262
- customElements.define('db-card', DbCard);
263
- }
264
-
265
- export { DbCard };
1
+ const e=["default","flat"],t=["s","m","l"];class DbCard extends HTMLElement{constructor(){super(...arguments),this.selectCheckbox=null,this.imageNode=null,this.handleClick=e=>{if(this.disabled||this.loading)return e.preventDefault(),void e.stopPropagation();this.clickable&&this.dispatchEvent(new CustomEvent("db-click",{bubbles:!0,composed:!0}))},this.handleKeyDown=e=>{!this.clickable||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.click())},this.handleSelect=e=>{if(e?.stopPropagation(),this.disabled||this.loading||!this.selectable)return;const t=!this.selected;this.toggleAttribute("selected",t),this.selectCheckbox&&(t?this.selectCheckbox.setAttribute("checked",""):this.selectCheckbox.removeAttribute("checked")),this.dispatchEvent(new CustomEvent("db-select",{bubbles:!0,composed:!0,detail:{selected:t}}))}}static get observedAttributes(){return["variant","size","full-width","clickable","hoverable","selectable","selected","disabled","loading","image","image-alt"]}get variant(){return this.getAttribute("variant")||"default"}set variant(e){this.setAttribute("variant",e)}get size(){return this.getAttribute("size")||"m"}set size(e){this.setAttribute("size",e)}get clickable(){return this.hasAttribute("clickable")}set clickable(e){this.toggleAttribute("clickable",e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e)}get loading(){return this.hasAttribute("loading")}set loading(e){this.toggleAttribute("loading",e)}get fullWidth(){return this.hasAttribute("full-width")}set fullWidth(e){this.toggleAttribute("full-width",e)}get hoverable(){return this.hasAttribute("hoverable")}set hoverable(e){this.toggleAttribute("hoverable",e)}get selectable(){return this.hasAttribute("selectable")}set selectable(e){this.toggleAttribute("selectable",e)}get selected(){return this.hasAttribute("selected")}set selected(e){this.toggleAttribute("selected",e)}connectedCallback(){this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown),this.sync()}disconnectedCallback(){this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown)}attributeChangedCallback(e){this.isConnected&&(this.sync(),"selected"===e&&this.selectCheckbox&&(this.selected?this.selectCheckbox.setAttribute("checked",""):this.selectCheckbox.removeAttribute("checked")))}hasMediaSection(){return!!this.getAttribute("image")||null!==this.querySelector(':scope > .designbase-wc-card__thumbnail, :scope > .designbase-wc-card__media, :scope > [slot="media"], :scope > [slot="thumbnail"]')}hasFooterSection(){return null!==this.querySelector(':scope > .designbase-wc-card__footer, :scope > [slot="footer"]')}syncImageMedia(){const e=this.getAttribute("image"),t=this.querySelector(':scope > .designbase-wc-card__thumbnail, :scope > .designbase-wc-card__media, :scope > [slot="media"], :scope > [slot="thumbnail"]');if(!e)return void(this.imageNode&&(this.imageNode.remove(),this.imageNode=null));if(t&&t!==this.imageNode)return void(this.imageNode&&(this.imageNode.remove(),this.imageNode=null));if(!this.imageNode){this.imageNode=document.createElement("div"),this.imageNode.className="designbase-wc-card__media designbase-wc-card__thumbnail",this.imageNode.setAttribute("slot","media");const e=document.createElement("img");e.className="designbase-wc-card__thumbnail-image",this.imageNode.append(e);const t=this.querySelector(':scope > .designbase-wc-card__body, :scope > [slot="body"], :scope > .designbase-wc-card__footer, :scope > [slot="footer"]');t?this.insertBefore(this.imageNode,t):this.insertBefore(this.imageNode,this.firstChild)}const s=this.imageNode.querySelector("img");s&&(s.src=e,s.alt=this.getAttribute("image-alt")||"")}sync(){this.syncImageMedia(),this.syncAttributes(),this.syncOverlays()}syncOverlays(){const e=this.querySelector(":scope > .designbase-wc-card__loading-overlay"),t=this.querySelector(":scope > .designbase-wc-card__select-overlay");if(this.loading){if(!e){const e=document.createElement("div");e.className="designbase-wc-card__loading-overlay",e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true");const t=document.createElement("div");t.className="designbase-wc-card__loading-spinner",e.append(t),this.append(e)}}else e?.remove();if(this.selectable)if(t)this.selectCheckbox&&(this.selected?this.selectCheckbox.setAttribute("checked",""):this.selectCheckbox.removeAttribute("checked"));else{const e=document.createElement("div");e.className="designbase-wc-card__select-overlay",e.addEventListener("click",e=>this.handleSelect(e));const t=document.createElement("db-checkbox");t.className="designbase-wc-card__select-checkbox",t.setAttribute("size","s"),t.setAttribute("has-label","false"),t.setAttribute("aria-label","카드 선택"),this.selected&&t.setAttribute("checked",""),t.addEventListener("click",e=>e.stopPropagation()),t.addEventListener("db-change",e=>{e.stopPropagation(),this.handleSelect()}),e.append(t),this.append(e),this.selectCheckbox=t}else t?.remove(),this.selectCheckbox=null}syncAttributes(){this.classList.add("designbase-wc-card"),this.setAttribute("aria-disabled",String(this.disabled||this.loading)),!this.clickable||this.disabled||this.loading?(this.removeAttribute("role"),this.removeAttribute("tabindex")):(this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0")),e.forEach(e=>this.classList.remove(`designbase-wc-card--${e}`)),t.forEach(e=>this.classList.remove(`designbase-wc-card--${e}`)),this.classList.add(`designbase-wc-card--${e.includes(this.variant)?this.variant:"default"}`),this.classList.add(`designbase-wc-card--${t.includes(this.size)?this.size:"m"}`),this.classList.toggle("designbase-wc-card--full-width",this.hasAttribute("full-width")),this.classList.toggle("designbase-wc-card--clickable",this.clickable),this.classList.toggle("designbase-wc-card--hoverable",this.hasAttribute("hoverable")),this.classList.toggle("designbase-wc-card--selectable",this.hasAttribute("selectable")),this.classList.toggle("designbase-wc-card--selected",this.hasAttribute("selected")),this.classList.toggle("designbase-wc-card--disabled",this.disabled),this.classList.toggle("designbase-wc-card--loading",this.loading),this.classList.toggle("designbase-wc-card--with-media",this.hasMediaSection()),this.classList.toggle("designbase-wc-card--with-thumbnail",this.hasMediaSection()),this.classList.toggle("designbase-wc-card--with-footer",this.hasFooterSection())}}customElements.get("db-card")||customElements.define("db-card",DbCard);export{DbCard};
@@ -1,264 +1 @@
1
- import { createDbIcon } from './db-icons.js';
2
-
3
- class DbCarousel extends HTMLElement {
4
- constructor() {
5
- super(...arguments);
6
- this.currentIndex = 0;
7
- this.timer = null;
8
- this.isAutoPlaying = false;
9
- }
10
- static get observedAttributes() {
11
- return [
12
- 'items',
13
- 'size',
14
- 'variant',
15
- 'theme',
16
- 'transition',
17
- 'auto-play',
18
- 'auto-play-interval',
19
- 'infinite',
20
- 'show-navigation',
21
- 'show-indicators',
22
- 'indicator-style',
23
- 'show-auto-play-control',
24
- 'show-title',
25
- 'show-description',
26
- 'disabled',
27
- 'readonly',
28
- ];
29
- }
30
- get items() {
31
- try {
32
- const parsed = JSON.parse(this.getAttribute('items') || '[]');
33
- return Array.isArray(parsed) ? parsed : [];
34
- }
35
- catch {
36
- return [];
37
- }
38
- }
39
- set items(value) {
40
- this.setAttribute('items', typeof value === 'string' ? value : JSON.stringify(value));
41
- }
42
- connectedCallback() {
43
- this.style.display = 'block';
44
- this.clampCurrentIndex();
45
- this.isAutoPlaying = this.getBool('auto-play');
46
- this.startAutoPlay();
47
- this.render();
48
- }
49
- disconnectedCallback() {
50
- this.stopAutoPlay();
51
- }
52
- attributeChangedCallback(name) {
53
- if (name === 'items')
54
- this.clampCurrentIndex();
55
- if (name === 'auto-play' || name === 'auto-play-interval') {
56
- this.isAutoPlaying = this.getBool('auto-play');
57
- this.startAutoPlay();
58
- }
59
- this.render();
60
- }
61
- getBool(name, fallback = false) {
62
- if (!this.hasAttribute(name))
63
- return fallback;
64
- const value = this.getAttribute(name);
65
- return value === '' || value === 'true';
66
- }
67
- clampCurrentIndex() {
68
- if (this.currentIndex >= this.items.length)
69
- this.currentIndex = 0;
70
- }
71
- stopAutoPlay() {
72
- if (this.timer) {
73
- window.clearInterval(this.timer);
74
- this.timer = null;
75
- }
76
- }
77
- startAutoPlay() {
78
- this.stopAutoPlay();
79
- if (!this.isAutoPlaying || this.items.length <= 1)
80
- return;
81
- const interval = Math.max(1000, Number(this.getAttribute('auto-play-interval') || 5000));
82
- this.timer = window.setInterval(() => this.goToNext(), interval);
83
- }
84
- getIndicatorType() {
85
- const useIndicatorAutoplay = this.getBool('show-auto-play-control', true) && this.getBool('show-indicators', true) && this.items.length > 1;
86
- if (useIndicatorAutoplay)
87
- return 'combined';
88
- const style = this.getAttribute('indicator-style') || 'dots';
89
- if (style === 'lines')
90
- return 'line';
91
- if (style === 'numbers')
92
- return 'numbers';
93
- return 'dots';
94
- }
95
- getIndicatorSize() {
96
- const size = this.getAttribute('size') || 'm';
97
- return size === 'l' || size === 'xl' ? 'm' : 's';
98
- }
99
- goTo(index) {
100
- if (index < 0 || index >= this.items.length)
101
- return;
102
- this.currentIndex = index;
103
- this.dispatchEvent(new CustomEvent('db-slide-change', { detail: { index }, bubbles: true, composed: true }));
104
- this.render();
105
- }
106
- goToPrev() {
107
- if (this.items.length === 0)
108
- return;
109
- const infinite = this.getBool('infinite', true);
110
- const next = this.currentIndex - 1;
111
- if (next < 0)
112
- this.goTo(infinite ? this.items.length - 1 : 0);
113
- else
114
- this.goTo(next);
115
- }
116
- goToNext() {
117
- if (this.items.length === 0)
118
- return;
119
- const infinite = this.getBool('infinite', true);
120
- const next = this.currentIndex + 1;
121
- if (next >= this.items.length)
122
- this.goTo(infinite ? 0 : this.items.length - 1);
123
- else
124
- this.goTo(next);
125
- }
126
- render() {
127
- const size = this.getAttribute('size') || 'm';
128
- const variant = this.getAttribute('variant') || 'default';
129
- const theme = this.getAttribute('theme') || 'light';
130
- const transition = this.getAttribute('transition') || 'slide';
131
- const showNavigation = this.getBool('show-navigation', true);
132
- const showIndicators = this.getBool('show-indicators', true);
133
- const showAutoPlayControl = this.getBool('show-auto-play-control', true);
134
- const showTitle = this.getBool('show-title', true);
135
- const showDescription = this.getBool('show-description', true);
136
- const disabled = this.getBool('disabled');
137
- const readonly = this.getBool('readonly');
138
- const indicatorStyle = this.getAttribute('indicator-style') || 'dots';
139
- const useIndicatorAutoplay = showAutoPlayControl && showIndicators && this.items.length > 1;
140
- this.className = [
141
- 'designbase-wc-carousel',
142
- `designbase-wc-carousel--size-${size}`,
143
- `designbase-wc-carousel--variant-${variant}`,
144
- `designbase-wc-carousel--theme-${theme}`,
145
- `designbase-wc-carousel--transition-${transition}`,
146
- `designbase-wc-carousel--indicator-${indicatorStyle}`,
147
- disabled && 'designbase-wc-carousel--disabled',
148
- readonly && 'designbase-wc-carousel--readonly',
149
- ]
150
- .filter(Boolean)
151
- .join(' ');
152
- const container = document.createElement('div');
153
- container.className = 'designbase-wc-carousel__container';
154
- const track = document.createElement('div');
155
- track.className = 'designbase-wc-carousel__track';
156
- track.style.transform = `translateX(-${this.currentIndex * 100}%)`;
157
- this.items.forEach((item, index) => {
158
- const slide = document.createElement('div');
159
- slide.className = `designbase-wc-carousel__slide${index === this.currentIndex ? ' designbase-wc-carousel__slide--active' : ''}`;
160
- slide.style.flex = '0 0 100%';
161
- slide.style.width = '100%';
162
- slide.style.height = '100%';
163
- slide.style.minWidth = '0';
164
- const captionColor = item.image ? '#ffffff' : '';
165
- if (captionColor)
166
- slide.style.color = captionColor;
167
- if (item.image) {
168
- const imageWrap = document.createElement('div');
169
- imageWrap.className = 'designbase-wc-carousel__slide-image';
170
- const image = document.createElement('img');
171
- image.className = 'designbase-wc-carousel__slide-img';
172
- image.src = item.image;
173
- image.alt = item.alt || item.title || `Slide ${index + 1}`;
174
- imageWrap.append(image);
175
- slide.append(imageWrap);
176
- }
177
- if ((showTitle && item.title) || (showDescription && item.description)) {
178
- const info = document.createElement('div');
179
- info.className = 'designbase-wc-carousel__slide-info';
180
- if (captionColor)
181
- info.style.color = captionColor;
182
- if (showTitle && item.title) {
183
- const title = document.createElement('h3');
184
- title.className = 'designbase-wc-carousel__slide-title';
185
- title.textContent = item.title;
186
- if (captionColor)
187
- title.style.color = captionColor;
188
- info.append(title);
189
- }
190
- if (showDescription && item.description) {
191
- const description = document.createElement('p');
192
- description.className = 'designbase-wc-carousel__slide-description';
193
- description.textContent = item.description;
194
- if (captionColor)
195
- description.style.color = captionColor;
196
- info.append(description);
197
- }
198
- slide.append(info);
199
- }
200
- slide.addEventListener('click', () => {
201
- this.dispatchEvent(new CustomEvent('db-item-click', { detail: { item, index }, bubbles: true, composed: true }));
202
- });
203
- track.append(slide);
204
- });
205
- container.append(track);
206
- if (showNavigation && this.items.length > 1) {
207
- const prev = document.createElement('button');
208
- prev.className = 'designbase-wc-carousel__nav-button designbase-wc-carousel__nav-button--prev';
209
- prev.type = 'button';
210
- prev.append(createDbIcon('chevron-left', 20));
211
- prev.disabled = disabled || readonly;
212
- prev.addEventListener('click', () => this.goToPrev());
213
- const next = document.createElement('button');
214
- next.className = 'designbase-wc-carousel__nav-button designbase-wc-carousel__nav-button--next';
215
- next.type = 'button';
216
- next.append(createDbIcon('chevron-right', 20));
217
- next.disabled = disabled || readonly;
218
- next.addEventListener('click', () => this.goToNext());
219
- container.append(prev, next);
220
- }
221
- const children = [container];
222
- if (showIndicators && this.items.length > 1) {
223
- const controls = document.createElement('div');
224
- controls.className = 'designbase-wc-carousel__controls';
225
- const indicators = document.createElement('div');
226
- indicators.className = 'designbase-wc-carousel__indicators';
227
- const indicator = document.createElement('db-indicator');
228
- indicator.setAttribute('current', String(this.currentIndex));
229
- indicator.setAttribute('total', String(this.items.length));
230
- indicator.setAttribute('type', this.getIndicatorType());
231
- indicator.setAttribute('size', this.getIndicatorSize());
232
- indicator.setAttribute('clickable', '');
233
- if (useIndicatorAutoplay) {
234
- indicator.setAttribute('timer', '');
235
- indicator.setAttribute('timer-duration', String(Math.max(1000, Number(this.getAttribute('auto-play-interval') || 5000))));
236
- indicator.setAttribute('auto-roll', 'false');
237
- if (this.isAutoPlaying)
238
- indicator.setAttribute('playing', '');
239
- else
240
- indicator.removeAttribute('playing');
241
- if (disabled || readonly)
242
- indicator.setAttribute('playback-disabled', '');
243
- }
244
- indicator.addEventListener('db-step-click', ((event) => {
245
- const customEvent = event;
246
- this.goTo(customEvent.detail.index);
247
- }));
248
- indicator.addEventListener('db-playing-change', ((event) => {
249
- const customEvent = event;
250
- this.isAutoPlaying = customEvent.detail.playing;
251
- this.startAutoPlay();
252
- this.render();
253
- }));
254
- indicators.append(indicator);
255
- controls.append(indicators);
256
- children.push(controls);
257
- }
258
- this.replaceChildren(...children);
259
- }
260
- }
261
- if (!customElements.get('db-carousel'))
262
- customElements.define('db-carousel', DbCarousel);
263
-
264
- export { DbCarousel };
1
+ import{createDbIcon as t}from"./db-icons.js";class DbCarousel extends HTMLElement{constructor(){super(...arguments),this.currentIndex=0,this.timer=null,this.isAutoPlaying=!1}static get observedAttributes(){return["items","size","variant","theme","transition","auto-play","auto-play-interval","infinite","show-navigation","show-indicators","indicator-style","show-auto-play-control","show-title","show-description","disabled","readonly"]}get items(){try{const t=JSON.parse(this.getAttribute("items")||"[]");return Array.isArray(t)?t:[]}catch{return[]}}set items(t){this.setAttribute("items","string"==typeof t?t:JSON.stringify(t))}connectedCallback(){this.style.display="block",this.clampCurrentIndex(),this.isAutoPlaying=this.getBool("auto-play"),this.startAutoPlay(),this.render()}disconnectedCallback(){this.stopAutoPlay()}attributeChangedCallback(t){"items"===t&&this.clampCurrentIndex(),"auto-play"!==t&&"auto-play-interval"!==t||(this.isAutoPlaying=this.getBool("auto-play"),this.startAutoPlay()),this.render()}getBool(t,e=!1){if(!this.hasAttribute(t))return e;const s=this.getAttribute(t);return""===s||"true"===s}clampCurrentIndex(){this.currentIndex>=this.items.length&&(this.currentIndex=0)}stopAutoPlay(){this.timer&&(window.clearInterval(this.timer),this.timer=null)}startAutoPlay(){if(this.stopAutoPlay(),!this.isAutoPlaying||this.items.length<=1)return;const t=Math.max(1e3,Number(this.getAttribute("auto-play-interval")||5e3));this.timer=window.setInterval(()=>this.goToNext(),t)}getIndicatorType(){if(this.getBool("show-auto-play-control",!0)&&this.getBool("show-indicators",!0)&&this.items.length>1)return"combined";const t=this.getAttribute("indicator-style")||"dots";return"lines"===t?"line":"numbers"===t?"numbers":"dots"}getIndicatorSize(){const t=this.getAttribute("size")||"m";return"l"===t||"xl"===t?"m":"s"}goTo(t){t<0||t>=this.items.length||(this.currentIndex=t,this.dispatchEvent(new CustomEvent("db-slide-change",{detail:{index:t},bubbles:!0,composed:!0})),this.render())}goToPrev(){if(0===this.items.length)return;const t=this.getBool("infinite",!0),e=this.currentIndex-1;e<0?this.goTo(t?this.items.length-1:0):this.goTo(e)}goToNext(){if(0===this.items.length)return;const t=this.getBool("infinite",!0),e=this.currentIndex+1;e>=this.items.length?this.goTo(t?0:this.items.length-1):this.goTo(e)}render(){const e=this.getAttribute("size")||"m",s=this.getAttribute("variant")||"default",i=this.getAttribute("theme")||"light",n=this.getAttribute("transition")||"slide",a=this.getBool("show-navigation",!0),o=this.getBool("show-indicators",!0),r=this.getBool("show-auto-play-control",!0),l=this.getBool("show-title",!0),c=this.getBool("show-description",!0),d=this.getBool("disabled"),u=this.getBool("readonly"),h=this.getAttribute("indicator-style")||"dots",g=r&&o&&this.items.length>1;this.className=["designbase-wc-carousel",`designbase-wc-carousel--size-${e}`,`designbase-wc-carousel--variant-${s}`,`designbase-wc-carousel--theme-${i}`,`designbase-wc-carousel--transition-${n}`,`designbase-wc-carousel--indicator-${h}`,d&&"designbase-wc-carousel--disabled",u&&"designbase-wc-carousel--readonly"].filter(Boolean).join(" ");const m=document.createElement("div");m.className="designbase-wc-carousel__container";const b=document.createElement("div");if(b.className="designbase-wc-carousel__track",b.style.transform=`translateX(-${100*this.currentIndex}%)`,this.items.forEach((t,e)=>{const s=document.createElement("div");s.className="designbase-wc-carousel__slide"+(e===this.currentIndex?" designbase-wc-carousel__slide--active":""),s.style.flex="0 0 100%",s.style.width="100%",s.style.height="100%",s.style.minWidth="0";const i=t.image?"#ffffff":"";if(i&&(s.style.color=i),t.image){const i=document.createElement("div");i.className="designbase-wc-carousel__slide-image";const n=document.createElement("img");n.className="designbase-wc-carousel__slide-img",n.src=t.image,n.alt=t.alt||t.title||`Slide ${e+1}`,i.append(n),s.append(i)}if(l&&t.title||c&&t.description){const e=document.createElement("div");if(e.className="designbase-wc-carousel__slide-info",i&&(e.style.color=i),l&&t.title){const s=document.createElement("h3");s.className="designbase-wc-carousel__slide-title",s.textContent=t.title,i&&(s.style.color=i),e.append(s)}if(c&&t.description){const s=document.createElement("p");s.className="designbase-wc-carousel__slide-description",s.textContent=t.description,i&&(s.style.color=i),e.append(s)}s.append(e)}s.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("db-item-click",{detail:{item:t,index:e},bubbles:!0,composed:!0}))}),b.append(s)}),m.append(b),a&&this.items.length>1){const e=document.createElement("button");e.className="designbase-wc-carousel__nav-button designbase-wc-carousel__nav-button--prev",e.type="button",e.append(t("chevron-left",20)),e.disabled=d||u,e.addEventListener("click",()=>this.goToPrev());const s=document.createElement("button");s.className="designbase-wc-carousel__nav-button designbase-wc-carousel__nav-button--next",s.type="button",s.append(t("chevron-right",20)),s.disabled=d||u,s.addEventListener("click",()=>this.goToNext()),m.append(e,s)}const p=[m];if(o&&this.items.length>1){const t=document.createElement("div");t.className="designbase-wc-carousel__controls";const e=document.createElement("div");e.className="designbase-wc-carousel__indicators";const s=document.createElement("db-indicator");s.setAttribute("current",String(this.currentIndex)),s.setAttribute("total",String(this.items.length)),s.setAttribute("type",this.getIndicatorType()),s.setAttribute("size",this.getIndicatorSize()),s.setAttribute("clickable",""),g&&(s.setAttribute("timer",""),s.setAttribute("timer-duration",String(Math.max(1e3,Number(this.getAttribute("auto-play-interval")||5e3)))),s.setAttribute("auto-roll","false"),this.isAutoPlaying?s.setAttribute("playing",""):s.removeAttribute("playing"),(d||u)&&s.setAttribute("playback-disabled","")),s.addEventListener("db-step-click",t=>{const e=t;this.goTo(e.detail.index)}),s.addEventListener("db-playing-change",t=>{const e=t;this.isAutoPlaying=e.detail.playing,this.startAutoPlay(),this.render()}),e.append(s),t.append(e),p.push(t)}this.replaceChildren(...p)}}customElements.get("db-carousel")||customElements.define("db-carousel",DbCarousel);export{DbCarousel};