@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.
- package/dist/chunks/lottie-0e23d630.js +1 -0
- package/dist/esm/components/animation-background/canvas-controller.js +1 -121
- package/dist/esm/components/animation-background/controls.js +1 -180
- package/dist/esm/components/animation-background/graphite-controller.js +1 -196
- package/dist/esm/components/animation-background/graphite-presets.js +1 -42
- package/dist/esm/components/animation-background/graphite-shader.js +1 -111
- package/dist/esm/components/animation-background/layers.js +1 -369
- package/dist/esm/components/animation-background/lumina-presets.js +1 -53
- package/dist/esm/components/animation-background/lumina-shaders.js +1 -181
- package/dist/esm/components/animation-background/lumina-utils.js +1 -60
- package/dist/esm/components/animation-background/particle-defaults.js +1 -36
- package/dist/esm/components/animation-background/renderers.js +1 -167
- package/dist/esm/components/animation-background/shader-controller.js +1 -154
- package/dist/esm/components/color-picker-utils.js +1 -134
- package/dist/esm/components/date-picker-utils.js +1 -140
- package/dist/esm/components/db-accordion.js +1 -304
- package/dist/esm/components/db-ad-banner.js +1 -455
- package/dist/esm/components/db-ai-chat-list.d.ts +43 -0
- package/dist/esm/components/db-ai-chat-list.js +1 -0
- package/dist/esm/components/db-ai-chat.d.ts +159 -0
- package/dist/esm/components/db-ai-chat.js +1 -0
- package/dist/esm/components/db-alert.js +1 -149
- package/dist/esm/components/db-animation-background.js +1 -486
- package/dist/esm/components/db-animation-text.js +1 -601
- package/dist/esm/components/db-app-badge.js +1 -88
- package/dist/esm/components/db-audio-player.js +1 -752
- package/dist/esm/components/db-avatar.js +1 -188
- package/dist/esm/components/db-backdrop.js +1 -139
- package/dist/esm/components/db-badge.js +1 -91
- package/dist/esm/components/db-banner.js +1 -188
- package/dist/esm/components/db-bottom-navigation.js +1 -146
- package/dist/esm/components/db-bottom-sheet.js +1 -481
- package/dist/esm/components/db-breadcrumbs.js +1 -329
- package/dist/esm/components/db-button.js +1 -316
- package/dist/esm/components/db-calendar.js +1 -675
- package/dist/esm/components/db-card.js +1 -265
- package/dist/esm/components/db-carousel.js +1 -264
- package/dist/esm/components/db-chat-composer.d.ts +134 -0
- package/dist/esm/components/db-chat-composer.js +1 -0
- package/dist/esm/components/db-chat-list.d.ts +47 -0
- package/dist/esm/components/db-chat-list.js +1 -0
- package/dist/esm/components/db-chat-message.d.ts +39 -0
- package/dist/esm/components/db-chat-message.js +1 -0
- package/dist/esm/components/db-chat-orb.d.ts +99 -0
- package/dist/esm/components/db-chat-orb.js +1 -0
- package/dist/esm/components/db-chat-room.d.ts +71 -0
- package/dist/esm/components/db-chat-room.js +1 -0
- package/dist/esm/components/db-chat-suggestions.d.ts +44 -0
- package/dist/esm/components/db-chat-suggestions.js +1 -0
- package/dist/esm/components/db-chat-typing.d.ts +22 -0
- package/dist/esm/components/db-chat-typing.js +1 -0
- package/dist/esm/components/db-chat-welcome.d.ts +32 -0
- package/dist/esm/components/db-chat-welcome.js +1 -0
- package/dist/esm/components/db-chat-widget.d.ts +146 -0
- package/dist/esm/components/db-chat-widget.js +1 -0
- package/dist/esm/components/db-checkbox.js +1 -202
- package/dist/esm/components/db-chip.js +1 -104
- package/dist/esm/components/db-code-block.js +1 -304
- package/dist/esm/components/db-color-picker.js +1 -746
- package/dist/esm/components/db-confirm.js +1 -191
- package/dist/esm/components/db-container.js +1 -39
- package/dist/esm/components/db-context-menu.js +1 -265
- package/dist/esm/components/db-countdown.js +1 -146
- package/dist/esm/components/db-cursor-follower.js +1 -173
- package/dist/esm/components/db-date-picker.js +1 -837
- package/dist/esm/components/db-divider.js +1 -66
- package/dist/esm/components/db-download-progress.d.ts +89 -0
- package/dist/esm/components/db-download-progress.js +1 -0
- package/dist/esm/components/db-drawer.js +1 -245
- package/dist/esm/components/db-dropdown.js +1 -493
- package/dist/esm/components/db-dropzone.js +1 -266
- package/dist/esm/components/db-email-verify.d.ts +62 -0
- package/dist/esm/components/db-email-verify.js +1 -0
- package/dist/esm/components/db-empty-state.js +1 -97
- package/dist/esm/components/db-file-uploader.js +1 -256
- package/dist/esm/components/db-floating-action-button.js +1 -139
- package/dist/esm/components/db-footer.js +1 -385
- package/dist/esm/components/db-form.js +1 -566
- package/dist/esm/components/db-gantt.js +1 -882
- package/dist/esm/components/db-gradient.js +1 -133
- package/dist/esm/components/db-grid-background.js +1 -909
- package/dist/esm/components/db-grid.js +1 -73
- package/dist/esm/components/db-icons.d.ts +3 -0
- package/dist/esm/components/db-icons.js +1 -82
- package/dist/esm/components/db-image-list.js +1 -214
- package/dist/esm/components/db-image-placeholder.js +1 -96
- package/dist/esm/components/db-image.js +1 -289
- package/dist/esm/components/db-indicator.js +1 -517
- package/dist/esm/components/db-input.js +1 -420
- package/dist/esm/components/db-kanban.js +1 -538
- package/dist/esm/components/db-label.js +1 -66
- package/dist/esm/components/db-lightbox.js +1 -372
- package/dist/esm/components/db-list.js +1 -340
- package/dist/esm/components/db-logo-svg.js +1 -72
- package/dist/esm/components/db-logo.js +1 -106
- package/dist/esm/components/db-lottie.js +1 -109
- package/dist/esm/components/db-markdown-editor.js +1 -458
- package/dist/esm/components/db-marquee.js +1 -402
- package/dist/esm/components/db-masonry.js +1 -94
- package/dist/esm/components/db-menu-item.js +1 -211
- package/dist/esm/components/db-modal.js +1 -522
- package/dist/esm/components/db-navbar.js +1 -680
- package/dist/esm/components/db-onboarding-modal.js +1 -322
- package/dist/esm/components/db-otp-input.d.ts +53 -0
- package/dist/esm/components/db-otp-input.js +1 -0
- package/dist/esm/components/db-page-header.js +1 -312
- package/dist/esm/components/db-pagination.js +1 -271
- package/dist/esm/components/db-phone-verify.d.ts +61 -0
- package/dist/esm/components/db-phone-verify.js +1 -0
- package/dist/esm/components/db-popover.js +1 -580
- package/dist/esm/components/db-progress-step.js +1 -166
- package/dist/esm/components/db-progress.js +1 -171
- package/dist/esm/components/db-progressbar.js +1 -72
- package/dist/esm/components/db-radio.js +1 -172
- package/dist/esm/components/db-random-gradient.js +1 -121
- package/dist/esm/components/db-range-slider.js +1 -811
- package/dist/esm/components/db-rating.js +1 -325
- package/dist/esm/components/db-reorder.js +1 -286
- package/dist/esm/components/db-resizable-panels.js +1 -282
- package/dist/esm/components/db-scroll-area.js +1 -126
- package/dist/esm/components/db-search-bar.js +1 -668
- package/dist/esm/components/db-section-app-download.js +1 -101
- package/dist/esm/components/db-section-contact.js +1 -102
- package/dist/esm/components/db-section-cta.js +1 -150
- package/dist/esm/components/db-section-faq.js +1 -120
- package/dist/esm/components/db-section-feature-grid.js +1 -137
- package/dist/esm/components/db-section-feature.js +1 -179
- package/dist/esm/components/db-section-hero.js +1 -243
- package/dist/esm/components/db-section-logo-cloud.js +1 -138
- package/dist/esm/components/db-section-pricing.js +1 -166
- package/dist/esm/components/db-section-stats.js +1 -129
- package/dist/esm/components/db-section-testimonials.js +1 -252
- package/dist/esm/components/db-section.js +1 -385
- package/dist/esm/components/db-segment-control.js +1 -231
- package/dist/esm/components/db-select.js +1 -571
- package/dist/esm/components/db-share-icons.js +1 -40
- package/dist/esm/components/db-share.js +1 -489
- package/dist/esm/components/db-sidebar.js +1 -1068
- package/dist/esm/components/db-skeleton.js +1 -94
- package/dist/esm/components/db-spinner.js +1 -102
- package/dist/esm/components/db-split-view.js +1 -297
- package/dist/esm/components/db-stack.js +1 -46
- package/dist/esm/components/db-stat.js +1 -218
- package/dist/esm/components/db-stepper.js +1 -398
- package/dist/esm/components/db-table.js +1 -412
- package/dist/esm/components/db-tabs.js +1 -335
- package/dist/esm/components/db-testimonial.d.ts +2 -0
- package/dist/esm/components/db-testimonial.js +1 -162
- package/dist/esm/components/db-textarea.js +1 -233
- package/dist/esm/components/db-time-picker.js +1 -523
- package/dist/esm/components/db-timeline.js +1 -174
- package/dist/esm/components/db-toast.js +1 -158
- package/dist/esm/components/db-toggle.js +1 -162
- package/dist/esm/components/db-toolbar.js +1 -94
- package/dist/esm/components/db-tooltip.js +1 -440
- package/dist/esm/components/db-top-banner.js +1 -121
- package/dist/esm/components/db-tutorial.js +1 -324
- package/dist/esm/components/db-two-factor.d.ts +60 -0
- package/dist/esm/components/db-two-factor.js +1 -0
- package/dist/esm/components/db-video-player.js +1 -503
- package/dist/esm/components/db-youtube-player.js +1 -194
- package/dist/esm/components/highlight-code.js +1 -65
- package/dist/esm/components/input-validation.js +1 -50
- package/dist/esm/components/marketing-block-host-utils.js +1 -9
- package/dist/esm/components/number-scrub.js +1 -117
- package/dist/esm/components/random-gradient-palettes.js +1 -67
- package/dist/esm/components/section-block-header-utils.js +1 -48
- package/dist/esm/helpers/confirm.js +1 -52
- package/dist/esm/helpers/toast.js +1 -73
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +1 -111
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-bash.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-clike.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-css.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-javascript.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-json.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-jsx.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-markup.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-scss.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-tsx.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-typescript.js +1 -0
- package/dist/index.cjs +1 -55414
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1091 -2
- package/dist/index.esm.js +1 -38284
- package/dist/react/chunks/lottie-14e7addb.js +1 -0
- package/dist/react/index.cjs +1 -56503
- package/dist/react/index.d.ts +1620 -54
- package/dist/react/index.esm.js +1 -39373
- package/package.json +1 -1
- package/dist/chunks/lottie-e273b936.js +0 -17032
- package/dist/esm/node_modules/prismjs/components/prism-bash.js +0 -235
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -31
- package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -64
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -172
- package/dist/esm/node_modules/prismjs/components/prism-json.js +0 -27
- package/dist/esm/node_modules/prismjs/components/prism-jsx.js +0 -143
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -186
- package/dist/esm/node_modules/prismjs/components/prism-scss.js +0 -81
- package/dist/esm/node_modules/prismjs/components/prism-tsx.js +0 -15
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -60
- package/dist/react/chunks/lottie-72a4c6d4.js +0 -17032
|
@@ -1,455 +1 @@
|
|
|
1
|
-
import { createDbIcon } from './db-icons.js';
|
|
2
|
-
|
|
3
|
-
const CLASS = 'designbase-wc-ad-banner';
|
|
4
|
-
const DEFAULT_TITLES = {
|
|
5
|
-
hero: '지금 바로 시작하세요',
|
|
6
|
-
topbar: '🎉 신규 가입 시 10,000원 적립금 증정!',
|
|
7
|
-
card: '프리미엄 멤버십',
|
|
8
|
-
floating: '오늘만 특가!',
|
|
9
|
-
};
|
|
10
|
-
const DEFAULT_SUBTITLES = {
|
|
11
|
-
hero: '최대 50% 할인된 가격으로 프리미엄 서비스를 경험해보세요. 기간 한정 특별 혜택!',
|
|
12
|
-
topbar: '오늘 하루만 특별 혜택',
|
|
13
|
-
card: '무제한 서비스 이용권을 특별가에 만나보세요',
|
|
14
|
-
floating: '장바구니에 담긴 상품 추가 20% 할인',
|
|
15
|
-
};
|
|
16
|
-
const DEFAULT_CTA = {
|
|
17
|
-
hero: '자세히 보기',
|
|
18
|
-
topbar: '지금 가입하기',
|
|
19
|
-
card: '알아보기',
|
|
20
|
-
floating: '할인받기',
|
|
21
|
-
};
|
|
22
|
-
const TYPE_ICONS = {
|
|
23
|
-
hero: 'star',
|
|
24
|
-
topbar: 'trending-up',
|
|
25
|
-
card: 'star-filled',
|
|
26
|
-
floating: 'cart',
|
|
27
|
-
};
|
|
28
|
-
const VARIANT_SCHEMES = {
|
|
29
|
-
primary: 'primary',
|
|
30
|
-
secondary: 'secondary',
|
|
31
|
-
success: 'success',
|
|
32
|
-
warning: 'warning',
|
|
33
|
-
error: 'error',
|
|
34
|
-
};
|
|
35
|
-
class DbAdBanner extends HTMLElement {
|
|
36
|
-
constructor() {
|
|
37
|
-
super(...arguments);
|
|
38
|
-
this.built = false;
|
|
39
|
-
this.visible = true;
|
|
40
|
-
this.progress = 100;
|
|
41
|
-
}
|
|
42
|
-
static get observedAttributes() {
|
|
43
|
-
return [
|
|
44
|
-
'type',
|
|
45
|
-
'variant',
|
|
46
|
-
'size',
|
|
47
|
-
'title',
|
|
48
|
-
'subtitle',
|
|
49
|
-
'cta-text',
|
|
50
|
-
'image',
|
|
51
|
-
'image-alt',
|
|
52
|
-
'href',
|
|
53
|
-
'target',
|
|
54
|
-
'auto-close',
|
|
55
|
-
'close-delay',
|
|
56
|
-
'background',
|
|
57
|
-
'animation-type',
|
|
58
|
-
'grid-type',
|
|
59
|
-
'use-random-gradient',
|
|
60
|
-
'gradient-scheme',
|
|
61
|
-
'gradient-tone',
|
|
62
|
-
'gradient-animated',
|
|
63
|
-
'countdown-end-date',
|
|
64
|
-
'show-countdown',
|
|
65
|
-
'open',
|
|
66
|
-
];
|
|
67
|
-
}
|
|
68
|
-
connectedCallback() {
|
|
69
|
-
this.style.display = 'block';
|
|
70
|
-
if (!this.built) {
|
|
71
|
-
this.built = true;
|
|
72
|
-
this.build();
|
|
73
|
-
}
|
|
74
|
-
this.updateUI();
|
|
75
|
-
}
|
|
76
|
-
disconnectedCallback() {
|
|
77
|
-
this.stopAutoClose();
|
|
78
|
-
}
|
|
79
|
-
attributeChangedCallback(name) {
|
|
80
|
-
if (!this.built)
|
|
81
|
-
return;
|
|
82
|
-
if (name === 'open') {
|
|
83
|
-
this.visible = this.getAttribute('open') !== 'false';
|
|
84
|
-
}
|
|
85
|
-
this.updateUI();
|
|
86
|
-
}
|
|
87
|
-
getBool(name, fallback = false) {
|
|
88
|
-
if (!this.hasAttribute(name))
|
|
89
|
-
return fallback;
|
|
90
|
-
const value = this.getAttribute(name);
|
|
91
|
-
return value === '' || value === 'true';
|
|
92
|
-
}
|
|
93
|
-
getType() {
|
|
94
|
-
const type = this.getAttribute('type') || 'hero';
|
|
95
|
-
return ['hero', 'topbar', 'card', 'floating'].includes(type) ? type : 'hero';
|
|
96
|
-
}
|
|
97
|
-
getVariant() {
|
|
98
|
-
const variant = this.getAttribute('variant') || 'primary';
|
|
99
|
-
return ['primary', 'secondary', 'success', 'warning', 'error'].includes(variant)
|
|
100
|
-
? variant
|
|
101
|
-
: 'primary';
|
|
102
|
-
}
|
|
103
|
-
getSize() {
|
|
104
|
-
const size = this.getAttribute('size') || 'm';
|
|
105
|
-
return ['s', 'm', 'l'].includes(size) ? size : 'm';
|
|
106
|
-
}
|
|
107
|
-
ctaButtonSize(type, size) {
|
|
108
|
-
if (type === 'card')
|
|
109
|
-
return 's';
|
|
110
|
-
if (type === 'floating')
|
|
111
|
-
return size === 's' ? 's' : 'm';
|
|
112
|
-
return size;
|
|
113
|
-
}
|
|
114
|
-
build() {
|
|
115
|
-
this.rootEl = document.createElement('div');
|
|
116
|
-
this.contentEl = document.createElement('div');
|
|
117
|
-
this.contentEl.className = `${CLASS}__content`;
|
|
118
|
-
this.closeBtn = document.createElement('button');
|
|
119
|
-
this.closeBtn.type = 'button';
|
|
120
|
-
this.closeBtn.className = `${CLASS}__close`;
|
|
121
|
-
this.closeBtn.setAttribute('aria-label', '닫기');
|
|
122
|
-
this.closeBtn.append(createDbIcon('close', 16));
|
|
123
|
-
this.closeBtn.addEventListener('click', (event) => {
|
|
124
|
-
event.stopPropagation();
|
|
125
|
-
this.handleClose();
|
|
126
|
-
});
|
|
127
|
-
this.imageEl = document.createElement('img');
|
|
128
|
-
this.imageEl.className = `${CLASS}__image`;
|
|
129
|
-
this.imageEl.loading = 'lazy';
|
|
130
|
-
const mainEl = document.createElement('div');
|
|
131
|
-
mainEl.className = `${CLASS}__main`;
|
|
132
|
-
this.mainEl = mainEl;
|
|
133
|
-
this.iconEl = document.createElement('div');
|
|
134
|
-
this.iconEl.className = `${CLASS}__icon`;
|
|
135
|
-
this.labelEl = document.createElement('span');
|
|
136
|
-
this.labelEl.className = `${CLASS}__label`;
|
|
137
|
-
this.labelEl.textContent = '특별 이벤트';
|
|
138
|
-
this.badgeEl = document.createElement('span');
|
|
139
|
-
this.badgeEl.className = `${CLASS}__badge`;
|
|
140
|
-
this.badgeEl.textContent = 'HOT DEAL';
|
|
141
|
-
this.titleEl = document.createElement('h2');
|
|
142
|
-
this.titleEl.className = `${CLASS}__title`;
|
|
143
|
-
this.subtitleEl = document.createElement('p');
|
|
144
|
-
this.subtitleEl.className = `${CLASS}__subtitle`;
|
|
145
|
-
const textEl = document.createElement('div');
|
|
146
|
-
textEl.className = `${CLASS}__text`;
|
|
147
|
-
this.textEl = textEl;
|
|
148
|
-
this.countdownWrapEl = document.createElement('div');
|
|
149
|
-
this.countdownWrapEl.className = `${CLASS}__countdown`;
|
|
150
|
-
textEl.append(this.titleEl, this.subtitleEl);
|
|
151
|
-
this.actionsEl = document.createElement('div');
|
|
152
|
-
this.actionsEl.className = `${CLASS}__actions`;
|
|
153
|
-
this.ctaEl = document.createElement('db-button');
|
|
154
|
-
this.ctaEl.className = `${CLASS}__cta`;
|
|
155
|
-
this.ctaEl.setAttribute('variant', 'primary');
|
|
156
|
-
this.ctaEl.setAttribute('end-icon', 'arrow-right');
|
|
157
|
-
this.ctaEl.addEventListener('click', (event) => {
|
|
158
|
-
event.stopPropagation();
|
|
159
|
-
this.dispatchEvent(new CustomEvent('db-cta-click', { bubbles: true, composed: true }));
|
|
160
|
-
});
|
|
161
|
-
this.actionsEl.append(this.ctaEl);
|
|
162
|
-
mainEl.append(textEl, this.actionsEl);
|
|
163
|
-
this.progressEl = document.createElement('div');
|
|
164
|
-
this.progressEl.className = `${CLASS}__progress`;
|
|
165
|
-
this.progressBarEl = document.createElement('div');
|
|
166
|
-
this.progressBarEl.className = `${CLASS}__progress-bar`;
|
|
167
|
-
this.progressEl.append(this.progressBarEl);
|
|
168
|
-
this.contentEl.append(this.closeBtn, mainEl, this.progressEl);
|
|
169
|
-
this.rootEl.append(this.contentEl);
|
|
170
|
-
this.append(this.rootEl);
|
|
171
|
-
// topbar 는 전체가 링크처럼 동작 (href 없을 때도 db-cta-click 발행)
|
|
172
|
-
this.contentEl.addEventListener('click', (event) => {
|
|
173
|
-
if (this.getType() !== 'topbar')
|
|
174
|
-
return;
|
|
175
|
-
if (event.target?.closest(`.${CLASS}__close`))
|
|
176
|
-
return;
|
|
177
|
-
this.dispatchEvent(new CustomEvent('db-cta-click', { bubbles: true, composed: true }));
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
handleClose() {
|
|
181
|
-
this.visible = false;
|
|
182
|
-
this.style.display = 'none';
|
|
183
|
-
this.setAttribute('open', 'false');
|
|
184
|
-
this.stopAutoClose();
|
|
185
|
-
this.dispatchEvent(new CustomEvent('db-close', { bubbles: true, composed: true }));
|
|
186
|
-
}
|
|
187
|
-
stopAutoClose() {
|
|
188
|
-
if (this.autoCloseTimer) {
|
|
189
|
-
window.clearInterval(this.autoCloseTimer);
|
|
190
|
-
this.autoCloseTimer = undefined;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
startAutoClose(delay) {
|
|
194
|
-
this.stopAutoClose();
|
|
195
|
-
this.progress = 100;
|
|
196
|
-
this.autoCloseTimer = window.setInterval(() => {
|
|
197
|
-
this.progress -= 100 / (delay / 100);
|
|
198
|
-
if (this.progressBarEl) {
|
|
199
|
-
this.progressBarEl.style.width = `${Math.max(this.progress, 0)}%`;
|
|
200
|
-
}
|
|
201
|
-
if (this.progress <= 0) {
|
|
202
|
-
this.handleClose();
|
|
203
|
-
}
|
|
204
|
-
}, 100);
|
|
205
|
-
}
|
|
206
|
-
getBackground() {
|
|
207
|
-
const explicit = this.getAttribute('background');
|
|
208
|
-
if (explicit && ['solid', 'gradient', 'animation', 'grid'].includes(explicit)) {
|
|
209
|
-
return explicit;
|
|
210
|
-
}
|
|
211
|
-
return this.getBool('use-random-gradient') ? 'gradient' : 'solid';
|
|
212
|
-
}
|
|
213
|
-
ensureAnimBg() {
|
|
214
|
-
if (!this.animBgEl) {
|
|
215
|
-
const wrap = document.createElement('div');
|
|
216
|
-
wrap.className = `${CLASS}__backdrop`;
|
|
217
|
-
const inner = document.createElement('db-animation-background');
|
|
218
|
-
inner.className = `${CLASS}__anim-bg`;
|
|
219
|
-
inner.setAttribute('width', '100%');
|
|
220
|
-
inner.setAttribute('height', '100%');
|
|
221
|
-
wrap.append(inner);
|
|
222
|
-
this.animBgEl = wrap;
|
|
223
|
-
this.animBgInner = inner;
|
|
224
|
-
}
|
|
225
|
-
return this.animBgEl;
|
|
226
|
-
}
|
|
227
|
-
ensureGridBg() {
|
|
228
|
-
if (!this.gridBgEl) {
|
|
229
|
-
const wrap = document.createElement('div');
|
|
230
|
-
wrap.className = `${CLASS}__backdrop`;
|
|
231
|
-
const inner = document.createElement('db-grid-background');
|
|
232
|
-
inner.className = `${CLASS}__grid-bg`;
|
|
233
|
-
inner.setAttribute('width', '100%');
|
|
234
|
-
inner.setAttribute('height', '100%');
|
|
235
|
-
wrap.append(inner);
|
|
236
|
-
this.gridBgEl = wrap;
|
|
237
|
-
this.gridBgInner = inner;
|
|
238
|
-
}
|
|
239
|
-
return this.gridBgEl;
|
|
240
|
-
}
|
|
241
|
-
/** 이전 배경 모드의 백드롭 엘리먼트를 정리한다. */
|
|
242
|
-
clearBackdrop(keep) {
|
|
243
|
-
if (keep !== 'gradient' && this.gradientEl) {
|
|
244
|
-
this.gradientEl.remove();
|
|
245
|
-
this.gradientEl = undefined;
|
|
246
|
-
}
|
|
247
|
-
if (keep !== 'animation' && this.animBgEl) {
|
|
248
|
-
this.animBgEl.remove();
|
|
249
|
-
this.animBgEl = undefined;
|
|
250
|
-
this.animBgInner = undefined;
|
|
251
|
-
}
|
|
252
|
-
if (keep !== 'grid' && this.gridBgEl) {
|
|
253
|
-
this.gridBgEl.remove();
|
|
254
|
-
this.gridBgEl = undefined;
|
|
255
|
-
this.gridBgInner = undefined;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
renderBackground(background, variant) {
|
|
259
|
-
if (!this.rootEl || !this.contentEl)
|
|
260
|
-
return;
|
|
261
|
-
this.clearBackdrop(background);
|
|
262
|
-
if (background === 'gradient') {
|
|
263
|
-
if (!this.gradientEl) {
|
|
264
|
-
this.gradientEl = document.createElement('db-random-gradient');
|
|
265
|
-
this.gradientEl.className = `${CLASS}__gradient-bg`;
|
|
266
|
-
this.gradientEl.setAttribute('height', '100%');
|
|
267
|
-
this.gradientEl.setAttribute('width', '100%');
|
|
268
|
-
}
|
|
269
|
-
const gradientTone = this.getAttribute('gradient-tone') || 'vivid';
|
|
270
|
-
const gradientAnimated = !this.hasAttribute('gradient-animated') || this.getAttribute('gradient-animated') !== 'false';
|
|
271
|
-
this.gradientEl.setAttribute('scheme', this.getAttribute('gradient-scheme') || VARIANT_SCHEMES[variant]);
|
|
272
|
-
this.gradientEl.setAttribute('tone', gradientTone);
|
|
273
|
-
this.gradientEl.setAttribute('animated', gradientAnimated ? 'true' : 'false');
|
|
274
|
-
if (this.gradientEl.parentElement !== this.rootEl) {
|
|
275
|
-
this.rootEl.replaceChildren(this.gradientEl);
|
|
276
|
-
}
|
|
277
|
-
if (this.contentEl.parentElement !== this.gradientEl) {
|
|
278
|
-
this.gradientEl.append(this.contentEl);
|
|
279
|
-
}
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
// solid / animation / grid → 백드롭은 절대 위치 형제, 콘텐츠는 그 위에
|
|
283
|
-
const layers = [];
|
|
284
|
-
if (background === 'animation') {
|
|
285
|
-
const wrap = this.ensureAnimBg();
|
|
286
|
-
this.animBgInner?.setAttribute('type', this.getAttribute('animation-type') || 'graphite');
|
|
287
|
-
this.animBgInner?.setAttribute('theme', 'dark');
|
|
288
|
-
layers.push(wrap);
|
|
289
|
-
}
|
|
290
|
-
else if (background === 'grid') {
|
|
291
|
-
const wrap = this.ensureGridBg();
|
|
292
|
-
this.gridBgInner?.setAttribute('type', this.getAttribute('grid-type') || 'lines');
|
|
293
|
-
this.gridBgInner?.setAttribute('color', 'var(--db-text-inverse-primary)');
|
|
294
|
-
this.gridBgInner?.setAttribute('opacity', '0.18');
|
|
295
|
-
this.gridBgInner?.setAttribute('fade', 'vignette');
|
|
296
|
-
this.gridBgInner?.setAttribute('animated', '');
|
|
297
|
-
layers.push(wrap);
|
|
298
|
-
}
|
|
299
|
-
// 구조가 이미 올바르면 재삽입하지 않는다 (백드롭 캔버스 애니메이션 재시작 방지)
|
|
300
|
-
const desired = [...layers, this.contentEl];
|
|
301
|
-
const current = Array.from(this.rootEl.children);
|
|
302
|
-
const same = current.length === desired.length && desired.every((node, i) => current[i] === node);
|
|
303
|
-
if (!same) {
|
|
304
|
-
this.rootEl.replaceChildren(...desired);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
/** 장식 아이콘은 card 타입에서만 사용한다. */
|
|
308
|
-
syncIcon(type) {
|
|
309
|
-
if (!this.mainEl || !this.textEl || !this.iconEl)
|
|
310
|
-
return;
|
|
311
|
-
if (type !== 'card') {
|
|
312
|
-
this.iconEl.remove();
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
this.iconEl.replaceChildren(createDbIcon(TYPE_ICONS.card, 32));
|
|
316
|
-
if (this.iconEl.parentElement !== this.mainEl) {
|
|
317
|
-
this.mainEl.insertBefore(this.iconEl, this.textEl);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
/** floating 타입에서만 텍스트 상단에 배지 칩을 노출한다. */
|
|
321
|
-
syncBadge(type) {
|
|
322
|
-
if (!this.textEl || !this.badgeEl)
|
|
323
|
-
return;
|
|
324
|
-
if (type !== 'floating') {
|
|
325
|
-
this.badgeEl.remove();
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
if (this.badgeEl.parentElement !== this.textEl) {
|
|
329
|
-
this.textEl.insertBefore(this.badgeEl, this.textEl.firstChild);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
/** floating 타입에서 배너 이미지를 콘텐츠 상단(패딩 밖)에 렌더한다. */
|
|
333
|
-
syncImage(type, src) {
|
|
334
|
-
if (!this.contentEl || !this.imageEl || !this.mainEl)
|
|
335
|
-
return;
|
|
336
|
-
if (type !== 'floating' || !src) {
|
|
337
|
-
this.imageEl.remove();
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
this.imageEl.src = src;
|
|
341
|
-
this.imageEl.alt = this.getAttribute('image-alt') || '';
|
|
342
|
-
if (this.imageEl.parentElement !== this.contentEl) {
|
|
343
|
-
this.contentEl.insertBefore(this.imageEl, this.mainEl);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
/** topbar 타입에서 href 가 있으면 전체를 덮는 링크 오버레이를 렌더한다. */
|
|
347
|
-
syncLink(type, href) {
|
|
348
|
-
if (!this.contentEl)
|
|
349
|
-
return;
|
|
350
|
-
if (type !== 'topbar' || !href) {
|
|
351
|
-
this.linkEl?.remove();
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
if (!this.linkEl) {
|
|
355
|
-
this.linkEl = document.createElement('a');
|
|
356
|
-
this.linkEl.className = `${CLASS}__link`;
|
|
357
|
-
}
|
|
358
|
-
this.linkEl.setAttribute('href', href);
|
|
359
|
-
const target = this.getAttribute('target');
|
|
360
|
-
if (target)
|
|
361
|
-
this.linkEl.setAttribute('target', target);
|
|
362
|
-
else
|
|
363
|
-
this.linkEl.removeAttribute('target');
|
|
364
|
-
this.linkEl.setAttribute('aria-label', this.titleEl?.textContent || '배너 링크');
|
|
365
|
-
if (this.linkEl.parentElement !== this.contentEl) {
|
|
366
|
-
this.contentEl.append(this.linkEl);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
/** show-countdown + end-date 가 있을 때만 카운트다운을 마운트한다. */
|
|
370
|
-
syncCountdown(show, endDate) {
|
|
371
|
-
if (!this.textEl || !this.countdownWrapEl)
|
|
372
|
-
return;
|
|
373
|
-
if (!show || !endDate) {
|
|
374
|
-
this.countdownWrapEl.remove();
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
if (!this.countdownEl) {
|
|
378
|
-
this.countdownEl = document.createElement('db-countdown');
|
|
379
|
-
this.countdownEl.setAttribute('size', 's');
|
|
380
|
-
this.countdownEl.setAttribute('variant', 'compact');
|
|
381
|
-
this.countdownEl.setAttribute('show-labels', 'false');
|
|
382
|
-
this.countdownWrapEl.replaceChildren(this.countdownEl);
|
|
383
|
-
}
|
|
384
|
-
this.countdownEl.setAttribute('end-date', endDate);
|
|
385
|
-
if (this.countdownWrapEl.parentElement !== this.textEl) {
|
|
386
|
-
this.textEl.append(this.countdownWrapEl);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
updateUI() {
|
|
390
|
-
if (!this.visible || this.getAttribute('open') === 'false') {
|
|
391
|
-
this.style.display = 'none';
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
this.style.display = 'block';
|
|
395
|
-
const type = this.getType();
|
|
396
|
-
const variant = this.getVariant();
|
|
397
|
-
const size = this.getSize();
|
|
398
|
-
const title = this.getAttribute('title') || DEFAULT_TITLES[type];
|
|
399
|
-
const subtitle = this.getAttribute('subtitle') || DEFAULT_SUBTITLES[type];
|
|
400
|
-
const ctaText = this.getAttribute('cta-text') || DEFAULT_CTA[type];
|
|
401
|
-
const autoClose = this.getBool('auto-close');
|
|
402
|
-
const closeDelay = Math.max(Number(this.getAttribute('close-delay') || 5000), 1000);
|
|
403
|
-
const background = this.getBackground();
|
|
404
|
-
const gradientTone = this.getAttribute('gradient-tone') || 'vivid';
|
|
405
|
-
const showCountdown = this.getBool('show-countdown');
|
|
406
|
-
const countdownEndDate = this.getAttribute('countdown-end-date');
|
|
407
|
-
if (this.rootEl) {
|
|
408
|
-
this.rootEl.className = [
|
|
409
|
-
CLASS,
|
|
410
|
-
`${CLASS}--type-${type}`,
|
|
411
|
-
`${CLASS}--variant-${variant}`,
|
|
412
|
-
`${CLASS}--size-${size}`,
|
|
413
|
-
`${CLASS}--bg-${background}`,
|
|
414
|
-
autoClose && `${CLASS}--auto-close`,
|
|
415
|
-
background === 'gradient' && `${CLASS}--with-gradient`,
|
|
416
|
-
background === 'gradient' && gradientTone === 'light' && `${CLASS}--gradient-light`,
|
|
417
|
-
]
|
|
418
|
-
.filter(Boolean)
|
|
419
|
-
.join(' ');
|
|
420
|
-
}
|
|
421
|
-
this.renderBackground(background, variant);
|
|
422
|
-
this.syncIcon(type);
|
|
423
|
-
this.syncBadge(type);
|
|
424
|
-
this.syncImage(type, this.getAttribute('image'));
|
|
425
|
-
this.syncLink(type, this.getAttribute('href'));
|
|
426
|
-
if (this.titleEl)
|
|
427
|
-
this.titleEl.textContent = title;
|
|
428
|
-
if (this.subtitleEl)
|
|
429
|
-
this.subtitleEl.textContent = subtitle;
|
|
430
|
-
this.syncCountdown(showCountdown, countdownEndDate);
|
|
431
|
-
// topbar 는 전체가 링크이므로 CTA 버튼을 숨긴다.
|
|
432
|
-
if (this.actionsEl)
|
|
433
|
-
this.actionsEl.hidden = type === 'topbar';
|
|
434
|
-
if (this.ctaEl) {
|
|
435
|
-
this.ctaEl.textContent = ctaText;
|
|
436
|
-
this.ctaEl.setAttribute('size', this.ctaButtonSize(type, size));
|
|
437
|
-
if (type === 'floating')
|
|
438
|
-
this.ctaEl.setAttribute('full-width', '');
|
|
439
|
-
else
|
|
440
|
-
this.ctaEl.removeAttribute('full-width');
|
|
441
|
-
}
|
|
442
|
-
if (this.progressEl)
|
|
443
|
-
this.progressEl.hidden = !autoClose;
|
|
444
|
-
if (this.progressBarEl && autoClose) {
|
|
445
|
-
this.progressBarEl.style.width = `${this.progress}%`;
|
|
446
|
-
}
|
|
447
|
-
this.stopAutoClose();
|
|
448
|
-
if (autoClose)
|
|
449
|
-
this.startAutoClose(closeDelay);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
if (!customElements.get('db-ad-banner'))
|
|
453
|
-
customElements.define('db-ad-banner', DbAdBanner);
|
|
454
|
-
|
|
455
|
-
export { DbAdBanner };
|
|
1
|
+
import{createDbIcon as t}from"./db-icons.js";const e="designbase-wc-ad-banner",i={hero:"지금 바로 시작하세요",topbar:"🎉 신규 가입 시 10,000원 적립금 증정!",card:"프리미엄 멤버십",floating:"오늘만 특가!"},s={hero:"최대 50% 할인된 가격으로 프리미엄 서비스를 경험해보세요. 기간 한정 특별 혜택!",topbar:"오늘 하루만 특별 혜택",card:"무제한 서비스 이용권을 특별가에 만나보세요",floating:"장바구니에 담긴 상품 추가 20% 할인"},n={hero:"자세히 보기",topbar:"지금 가입하기",card:"알아보기",floating:"할인받기"},r="star-filled",a={primary:"primary",secondary:"secondary",success:"success",warning:"warning",error:"error"};class DbAdBanner extends HTMLElement{constructor(){super(...arguments),this.built=!1,this.visible=!0,this.progress=100}static get observedAttributes(){return["type","variant","size","title","subtitle","cta-text","image","image-alt","href","target","auto-close","close-delay","background","animation-type","grid-type","use-random-gradient","gradient-scheme","gradient-tone","gradient-animated","countdown-end-date","show-countdown","open"]}connectedCallback(){this.style.display="block",this.built||(this.built=!0,this.build()),this.updateUI()}disconnectedCallback(){this.stopAutoClose()}attributeChangedCallback(t){this.built&&("open"===t&&(this.visible="false"!==this.getAttribute("open")),this.updateUI())}getBool(t,e=!1){if(!this.hasAttribute(t))return e;const i=this.getAttribute(t);return""===i||"true"===i}getType(){const t=this.getAttribute("type")||"hero";return["hero","topbar","card","floating"].includes(t)?t:"hero"}getVariant(){const t=this.getAttribute("variant")||"primary";return["primary","secondary","success","warning","error"].includes(t)?t:"primary"}getSize(){const t=this.getAttribute("size")||"m";return["s","m","l"].includes(t)?t:"m"}ctaButtonSize(t,e){return"card"===t?"s":"floating"===t?"s"===e?"s":"m":e}build(){this.rootEl=document.createElement("div"),this.contentEl=document.createElement("div"),this.contentEl.className=`${e}__content`,this.closeBtn=document.createElement("button"),this.closeBtn.type="button",this.closeBtn.className=`${e}__close`,this.closeBtn.setAttribute("aria-label","닫기"),this.closeBtn.append(t("close",16)),this.closeBtn.addEventListener("click",t=>{t.stopPropagation(),this.handleClose()}),this.imageEl=document.createElement("img"),this.imageEl.className=`${e}__image`,this.imageEl.loading="lazy";const i=document.createElement("div");i.className=`${e}__main`,this.mainEl=i,this.iconEl=document.createElement("div"),this.iconEl.className=`${e}__icon`,this.labelEl=document.createElement("span"),this.labelEl.className=`${e}__label`,this.labelEl.textContent="특별 이벤트",this.badgeEl=document.createElement("span"),this.badgeEl.className=`${e}__badge`,this.badgeEl.textContent="HOT DEAL",this.titleEl=document.createElement("h2"),this.titleEl.className=`${e}__title`,this.subtitleEl=document.createElement("p"),this.subtitleEl.className=`${e}__subtitle`;const s=document.createElement("div");s.className=`${e}__text`,this.textEl=s,this.countdownWrapEl=document.createElement("div"),this.countdownWrapEl.className=`${e}__countdown`,s.append(this.titleEl,this.subtitleEl),this.actionsEl=document.createElement("div"),this.actionsEl.className=`${e}__actions`,this.ctaEl=document.createElement("db-button"),this.ctaEl.className=`${e}__cta`,this.ctaEl.setAttribute("variant","primary"),this.ctaEl.setAttribute("end-icon","arrow-right"),this.ctaEl.addEventListener("click",t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("db-cta-click",{bubbles:!0,composed:!0}))}),this.actionsEl.append(this.ctaEl),i.append(s,this.actionsEl),this.progressEl=document.createElement("div"),this.progressEl.className=`${e}__progress`,this.progressBarEl=document.createElement("div"),this.progressBarEl.className=`${e}__progress-bar`,this.progressEl.append(this.progressBarEl),this.contentEl.append(this.closeBtn,i,this.progressEl),this.rootEl.append(this.contentEl),this.append(this.rootEl),this.contentEl.addEventListener("click",t=>{"topbar"===this.getType()&&(t.target?.closest(`.${e}__close`)||this.dispatchEvent(new CustomEvent("db-cta-click",{bubbles:!0,composed:!0})))})}handleClose(){this.visible=!1,this.style.display="none",this.setAttribute("open","false"),this.stopAutoClose(),this.dispatchEvent(new CustomEvent("db-close",{bubbles:!0,composed:!0}))}stopAutoClose(){this.autoCloseTimer&&(window.clearInterval(this.autoCloseTimer),this.autoCloseTimer=void 0)}startAutoClose(t){this.stopAutoClose(),this.progress=100,this.autoCloseTimer=window.setInterval(()=>{this.progress-=100/(t/100),this.progressBarEl&&(this.progressBarEl.style.width=`${Math.max(this.progress,0)}%`),this.progress<=0&&this.handleClose()},100)}getBackground(){const t=this.getAttribute("background");return t&&["solid","gradient","animation","grid"].includes(t)?t:this.getBool("use-random-gradient")?"gradient":"solid"}ensureAnimBg(){if(!this.animBgEl){const t=document.createElement("div");t.className=`${e}__backdrop`;const i=document.createElement("db-animation-background");i.className=`${e}__anim-bg`,i.setAttribute("width","100%"),i.setAttribute("height","100%"),t.append(i),this.animBgEl=t,this.animBgInner=i}return this.animBgEl}ensureGridBg(){if(!this.gridBgEl){const t=document.createElement("div");t.className=`${e}__backdrop`;const i=document.createElement("db-grid-background");i.className=`${e}__grid-bg`,i.setAttribute("width","100%"),i.setAttribute("height","100%"),t.append(i),this.gridBgEl=t,this.gridBgInner=i}return this.gridBgEl}clearBackdrop(t){"gradient"!==t&&this.gradientEl&&(this.gradientEl.remove(),this.gradientEl=void 0),"animation"!==t&&this.animBgEl&&(this.animBgEl.remove(),this.animBgEl=void 0,this.animBgInner=void 0),"grid"!==t&&this.gridBgEl&&(this.gridBgEl.remove(),this.gridBgEl=void 0,this.gridBgInner=void 0)}renderBackground(t,i){if(!this.rootEl||!this.contentEl)return;if(this.clearBackdrop(t),"gradient"===t){this.gradientEl||(this.gradientEl=document.createElement("db-random-gradient"),this.gradientEl.className=`${e}__gradient-bg`,this.gradientEl.setAttribute("height","100%"),this.gradientEl.setAttribute("width","100%"));const t=this.getAttribute("gradient-tone")||"vivid",s=!this.hasAttribute("gradient-animated")||"false"!==this.getAttribute("gradient-animated");return this.gradientEl.setAttribute("scheme",this.getAttribute("gradient-scheme")||a[i]),this.gradientEl.setAttribute("tone",t),this.gradientEl.setAttribute("animated",s?"true":"false"),this.gradientEl.parentElement!==this.rootEl&&this.rootEl.replaceChildren(this.gradientEl),void(this.contentEl.parentElement!==this.gradientEl&&this.gradientEl.append(this.contentEl))}const s=[];if("animation"===t){const t=this.ensureAnimBg();this.animBgInner?.setAttribute("type",this.getAttribute("animation-type")||"graphite"),this.animBgInner?.setAttribute("theme","dark"),s.push(t)}else if("grid"===t){const t=this.ensureGridBg();this.gridBgInner?.setAttribute("type",this.getAttribute("grid-type")||"lines"),this.gridBgInner?.setAttribute("color","var(--db-text-inverse-primary)"),this.gridBgInner?.setAttribute("opacity","0.18"),this.gridBgInner?.setAttribute("fade","vignette"),this.gridBgInner?.setAttribute("animated",""),s.push(t)}const n=[...s,this.contentEl],r=Array.from(this.rootEl.children);r.length===n.length&&n.every((t,e)=>r[e]===t)||this.rootEl.replaceChildren(...n)}syncIcon(e){this.mainEl&&this.textEl&&this.iconEl&&("card"===e?(this.iconEl.replaceChildren(t(r,32)),this.iconEl.parentElement!==this.mainEl&&this.mainEl.insertBefore(this.iconEl,this.textEl)):this.iconEl.remove())}syncBadge(t){this.textEl&&this.badgeEl&&("floating"===t?this.badgeEl.parentElement!==this.textEl&&this.textEl.insertBefore(this.badgeEl,this.textEl.firstChild):this.badgeEl.remove())}syncImage(t,e){this.contentEl&&this.imageEl&&this.mainEl&&("floating"===t&&e?(this.imageEl.src=e,this.imageEl.alt=this.getAttribute("image-alt")||"",this.imageEl.parentElement!==this.contentEl&&this.contentEl.insertBefore(this.imageEl,this.mainEl)):this.imageEl.remove())}syncLink(t,i){if(!this.contentEl)return;if("topbar"!==t||!i)return void this.linkEl?.remove();this.linkEl||(this.linkEl=document.createElement("a"),this.linkEl.className=`${e}__link`),this.linkEl.setAttribute("href",i);const s=this.getAttribute("target");s?this.linkEl.setAttribute("target",s):this.linkEl.removeAttribute("target"),this.linkEl.setAttribute("aria-label",this.titleEl?.textContent||"배너 링크"),this.linkEl.parentElement!==this.contentEl&&this.contentEl.append(this.linkEl)}syncCountdown(t,e){this.textEl&&this.countdownWrapEl&&(t&&e?(this.countdownEl||(this.countdownEl=document.createElement("db-countdown"),this.countdownEl.setAttribute("size","s"),this.countdownEl.setAttribute("variant","compact"),this.countdownEl.setAttribute("show-labels","false"),this.countdownWrapEl.replaceChildren(this.countdownEl)),this.countdownEl.setAttribute("end-date",e),this.countdownWrapEl.parentElement!==this.textEl&&this.textEl.append(this.countdownWrapEl)):this.countdownWrapEl.remove())}updateUI(){if(!this.visible||"false"===this.getAttribute("open"))return void(this.style.display="none");this.style.display="block";const t=this.getType(),r=this.getVariant(),a=this.getSize(),l=this.getAttribute("title")||i[t],o=this.getAttribute("subtitle")||s[t],h=this.getAttribute("cta-text")||n[t],c=this.getBool("auto-close"),d=Math.max(Number(this.getAttribute("close-delay")||5e3),1e3),g=this.getBackground(),E=this.getAttribute("gradient-tone")||"vivid",u=this.getBool("show-countdown"),m=this.getAttribute("countdown-end-date");this.rootEl&&(this.rootEl.className=[e,`${e}--type-${t}`,`${e}--variant-${r}`,`${e}--size-${a}`,`${e}--bg-${g}`,c&&`${e}--auto-close`,"gradient"===g&&`${e}--with-gradient`,"gradient"===g&&"light"===E&&`${e}--gradient-light`].filter(Boolean).join(" ")),this.renderBackground(g,r),this.syncIcon(t),this.syncBadge(t),this.syncImage(t,this.getAttribute("image")),this.syncLink(t,this.getAttribute("href")),this.titleEl&&(this.titleEl.textContent=l),this.subtitleEl&&(this.subtitleEl.textContent=o),this.syncCountdown(u,m),this.actionsEl&&(this.actionsEl.hidden="topbar"===t),this.ctaEl&&(this.ctaEl.textContent=h,this.ctaEl.setAttribute("size",this.ctaButtonSize(t,a)),"floating"===t?this.ctaEl.setAttribute("full-width",""):this.ctaEl.removeAttribute("full-width")),this.progressEl&&(this.progressEl.hidden=!c),this.progressBarEl&&c&&(this.progressBarEl.style.width=`${this.progress}%`),this.stopAutoClose(),c&&this.startAutoClose(d)}}customElements.get("db-ad-banner")||customElements.define("db-ad-banner",DbAdBanner);export{DbAdBanner};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DbIconName } from './db-icons.js';
|
|
2
|
+
|
|
3
|
+
interface DbAiChatItem {
|
|
4
|
+
id: string;
|
|
5
|
+
/** 대화 제목 */
|
|
6
|
+
title: string;
|
|
7
|
+
/** 그룹 라벨 (예: '오늘', '어제', '지난 7일'). 없으면 '최근 항목' */
|
|
8
|
+
group?: string;
|
|
9
|
+
/** 행 아이콘(선택) */
|
|
10
|
+
icon?: DbIconName;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* AI 대화 이력 목록. 상단 '새 대화' 버튼 + 그룹별 최근 대화 리스트로 구성됩니다.
|
|
14
|
+
* (사람 간 대화 목록은 `db-chat-list` 를 사용하세요.)
|
|
15
|
+
*
|
|
16
|
+
* @fires db-new - 새 대화 시작
|
|
17
|
+
* @fires db-select - 대화 선택 (detail: { id, title })
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const list = document.querySelector('db-ai-chat-list');
|
|
21
|
+
* list.items = [{ id:'1', title:'다운로드 진행바 컴포넌트', group:'오늘' }];
|
|
22
|
+
* list.addEventListener('db-new', () => {});
|
|
23
|
+
* list.addEventListener('db-select', (e) => console.log(e.detail.id));
|
|
24
|
+
*/
|
|
25
|
+
declare class DbAiChatList extends HTMLElement {
|
|
26
|
+
static get observedAttributes(): string[];
|
|
27
|
+
private _items;
|
|
28
|
+
get items(): DbAiChatItem[];
|
|
29
|
+
set items(v: DbAiChatItem[]);
|
|
30
|
+
get selectedId(): string;
|
|
31
|
+
set selectedId(v: string);
|
|
32
|
+
connectedCallback(): void;
|
|
33
|
+
attributeChangedCallback(): void;
|
|
34
|
+
private render;
|
|
35
|
+
}
|
|
36
|
+
declare global {
|
|
37
|
+
interface HTMLElementTagNameMap {
|
|
38
|
+
'db-ai-chat-list': DbAiChatList;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { DbAiChatList };
|
|
43
|
+
export type { DbAiChatItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createDbIcon as t,isDbIconName as e}from"./db-icons.js";class DbAiChatList extends HTMLElement{constructor(){super(...arguments),this._items=[]}static get observedAttributes(){return["selected-id","new-label","title-label"]}get items(){return this._items}set items(t){this._items=Array.isArray(t)?t:[],this.render()}get selectedId(){return this.getAttribute("selected-id")||""}set selectedId(t){t?this.setAttribute("selected-id",t):this.removeAttribute("selected-id")}connectedCallback(){if(!this._items.length&&this.hasAttribute("items"))try{this._items=JSON.parse(this.getAttribute("items")||"[]")}catch{this._items=[]}this.render()}attributeChangedCallback(){this.render()}render(){this.className="designbase-wc-ai-chat-list",this.replaceChildren();const s=document.createElement("button");s.type="button",s.className="designbase-wc-ai-chat-list__new";const i=document.createElement("span");i.className="designbase-wc-ai-chat-list__new-icon",i.append(t("plus",18));const n=document.createElement("span");if(n.textContent=this.getAttribute("new-label")||"새 대화",s.append(i,n),s.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("db-new",{bubbles:!0,composed:!0}))}),this.append(s),!this._items.length)return;const a=new Map,c=this.getAttribute("title-label")||"최근 항목";for(const t of this._items){const e=t.group||c;a.has(e)||a.set(e,[]),a.get(e).push(t)}const d=this.selectedId,l=document.createElement("div");l.className="designbase-wc-ai-chat-list__scroll";for(const[s,i]of a){const n=document.createElement("div");n.className="designbase-wc-ai-chat-list__group";const a=document.createElement("div");a.className="designbase-wc-ai-chat-list__group-title",a.textContent=s,n.append(a);for(const s of i){const i=document.createElement("button");if(i.type="button",i.className=["designbase-wc-ai-chat-list__item",s.id===d&&"designbase-wc-ai-chat-list__item--selected"].filter(Boolean).join(" "),s.icon&&e(s.icon)){const e=document.createElement("span");e.className="designbase-wc-ai-chat-list__item-icon",e.append(t(s.icon,16)),i.append(e)}const a=document.createElement("span");a.className="designbase-wc-ai-chat-list__item-title",a.textContent=s.title,i.append(a),i.addEventListener("click",()=>{this.selectedId=s.id,this.dispatchEvent(new CustomEvent("db-select",{detail:{id:s.id,title:s.title},bubbles:!0,composed:!0}))}),n.append(i)}l.append(n)}this.append(l)}}customElements.get("db-ai-chat-list")||customElements.define("db-ai-chat-list",DbAiChatList);export{DbAiChatList};
|