@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,265 @@
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
+ 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 +1,264 @@
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};
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 };