@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.
- package/dist/chunks/lottie-e273b936.js +17032 -0
- package/dist/esm/components/animation-background/canvas-controller.js +121 -1
- package/dist/esm/components/animation-background/controls.js +180 -1
- package/dist/esm/components/animation-background/graphite-controller.js +196 -1
- package/dist/esm/components/animation-background/graphite-presets.js +42 -1
- package/dist/esm/components/animation-background/graphite-shader.js +111 -1
- package/dist/esm/components/animation-background/layers.js +369 -1
- package/dist/esm/components/animation-background/lumina-presets.js +53 -1
- package/dist/esm/components/animation-background/lumina-shaders.js +181 -1
- package/dist/esm/components/animation-background/lumina-utils.js +60 -1
- package/dist/esm/components/animation-background/particle-defaults.js +36 -1
- package/dist/esm/components/animation-background/renderers.js +167 -1
- package/dist/esm/components/animation-background/shader-controller.js +154 -1
- package/dist/esm/components/color-picker-utils.js +134 -1
- package/dist/esm/components/date-picker-utils.js +140 -1
- package/dist/esm/components/db-accordion.js +304 -1
- package/dist/esm/components/db-ad-banner.js +455 -1
- package/dist/esm/components/db-alert.js +149 -1
- package/dist/esm/components/db-animation-background.js +486 -1
- package/dist/esm/components/db-animation-text.js +601 -1
- package/dist/esm/components/db-app-badge.js +88 -1
- package/dist/esm/components/db-audio-player.js +752 -1
- package/dist/esm/components/db-avatar.js +188 -1
- package/dist/esm/components/db-backdrop.js +139 -1
- package/dist/esm/components/db-badge.js +91 -1
- package/dist/esm/components/db-banner.js +188 -1
- package/dist/esm/components/db-bottom-navigation.js +146 -1
- package/dist/esm/components/db-bottom-sheet.js +481 -1
- package/dist/esm/components/db-breadcrumbs.js +329 -1
- package/dist/esm/components/db-button.js +316 -1
- package/dist/esm/components/db-calendar.js +675 -1
- package/dist/esm/components/db-card.js +265 -1
- package/dist/esm/components/db-carousel.js +264 -1
- package/dist/esm/components/db-checkbox.js +202 -1
- package/dist/esm/components/db-chip.js +104 -1
- package/dist/esm/components/db-code-block.js +304 -1
- package/dist/esm/components/db-color-picker.js +746 -1
- package/dist/esm/components/db-confirm.js +191 -1
- package/dist/esm/components/db-container.js +39 -1
- package/dist/esm/components/db-context-menu.js +265 -1
- package/dist/esm/components/db-countdown.js +146 -1
- package/dist/esm/components/db-cursor-follower.js +173 -1
- package/dist/esm/components/db-date-picker.js +837 -1
- package/dist/esm/components/db-divider.js +66 -1
- package/dist/esm/components/db-drawer.js +245 -1
- package/dist/esm/components/db-dropdown.js +493 -1
- package/dist/esm/components/db-dropzone.js +266 -1
- package/dist/esm/components/db-empty-state.js +97 -1
- package/dist/esm/components/db-file-uploader.js +256 -1
- package/dist/esm/components/db-floating-action-button.js +139 -1
- package/dist/esm/components/db-footer.js +385 -1
- package/dist/esm/components/db-form.js +566 -1
- package/dist/esm/components/db-gantt.js +882 -1
- package/dist/esm/components/db-gradient.js +133 -1
- package/dist/esm/components/db-grid-background.js +909 -1
- package/dist/esm/components/db-grid.js +73 -1
- package/dist/esm/components/db-icons.js +82 -1
- package/dist/esm/components/db-image-list.js +214 -1
- package/dist/esm/components/db-image-placeholder.js +96 -1
- package/dist/esm/components/db-image.js +289 -1
- package/dist/esm/components/db-indicator.js +517 -1
- package/dist/esm/components/db-input.js +420 -1
- package/dist/esm/components/db-kanban.js +538 -1
- package/dist/esm/components/db-label.js +66 -1
- package/dist/esm/components/db-lightbox.js +372 -1
- package/dist/esm/components/db-list.js +340 -1
- package/dist/esm/components/db-logo-svg.js +72 -1
- package/dist/esm/components/db-logo.js +106 -1
- package/dist/esm/components/db-lottie.js +109 -1
- package/dist/esm/components/db-markdown-editor.js +458 -1
- package/dist/esm/components/db-marquee.js +402 -1
- package/dist/esm/components/db-masonry.js +94 -1
- package/dist/esm/components/db-menu-item.js +211 -1
- package/dist/esm/components/db-modal.js +522 -1
- package/dist/esm/components/db-navbar.js +680 -1
- package/dist/esm/components/db-onboarding-modal.js +322 -1
- package/dist/esm/components/db-page-header.js +312 -1
- package/dist/esm/components/db-pagination.js +271 -1
- package/dist/esm/components/db-popover.js +580 -1
- package/dist/esm/components/db-progress-step.js +166 -1
- package/dist/esm/components/db-progress.js +171 -1
- package/dist/esm/components/db-progressbar.js +72 -1
- package/dist/esm/components/db-radio.js +172 -1
- package/dist/esm/components/db-random-gradient.js +121 -1
- package/dist/esm/components/db-range-slider.js +811 -1
- package/dist/esm/components/db-rating.js +325 -1
- package/dist/esm/components/db-reorder.js +286 -1
- package/dist/esm/components/db-resizable-panels.js +282 -1
- package/dist/esm/components/db-scroll-area.js +126 -1
- package/dist/esm/components/db-search-bar.js +668 -1
- package/dist/esm/components/db-section-app-download.js +101 -1
- package/dist/esm/components/db-section-contact.js +102 -1
- package/dist/esm/components/db-section-cta.js +150 -1
- package/dist/esm/components/db-section-faq.js +120 -1
- package/dist/esm/components/db-section-feature-grid.js +137 -1
- package/dist/esm/components/db-section-feature.js +179 -1
- package/dist/esm/components/db-section-hero.js +243 -1
- package/dist/esm/components/db-section-logo-cloud.js +138 -1
- package/dist/esm/components/db-section-pricing.js +166 -1
- package/dist/esm/components/db-section-stats.js +129 -1
- package/dist/esm/components/db-section-testimonials.js +252 -1
- package/dist/esm/components/db-section.js +385 -1
- package/dist/esm/components/db-segment-control.js +231 -1
- package/dist/esm/components/db-select.js +571 -1
- package/dist/esm/components/db-share-icons.js +40 -1
- package/dist/esm/components/db-share.js +489 -1
- package/dist/esm/components/db-sidebar.js +1068 -1
- package/dist/esm/components/db-skeleton.js +94 -1
- package/dist/esm/components/db-spinner.js +102 -1
- package/dist/esm/components/db-split-view.js +297 -1
- package/dist/esm/components/db-stack.js +46 -1
- package/dist/esm/components/db-stat.js +218 -1
- package/dist/esm/components/db-stepper.js +398 -1
- package/dist/esm/components/db-table.js +412 -1
- package/dist/esm/components/db-tabs.js +335 -1
- package/dist/esm/components/db-testimonial.js +162 -1
- package/dist/esm/components/db-textarea.js +233 -1
- package/dist/esm/components/db-time-picker.js +523 -1
- package/dist/esm/components/db-timeline.js +174 -1
- package/dist/esm/components/db-toast.js +158 -1
- package/dist/esm/components/db-toggle.js +162 -1
- package/dist/esm/components/db-toolbar.js +94 -1
- package/dist/esm/components/db-tooltip.js +440 -1
- package/dist/esm/components/db-top-banner.js +121 -1
- package/dist/esm/components/db-tutorial.js +324 -1
- package/dist/esm/components/db-video-player.js +503 -1
- package/dist/esm/components/db-youtube-player.js +194 -1
- package/dist/esm/components/highlight-code.js +65 -1
- package/dist/esm/components/input-validation.js +50 -1
- package/dist/esm/components/marketing-block-host-utils.js +9 -1
- package/dist/esm/components/number-scrub.js +117 -1
- package/dist/esm/components/random-gradient-palettes.js +67 -1
- package/dist/esm/components/section-block-header-utils.js +48 -1
- package/dist/esm/helpers/confirm.js +52 -1
- package/dist/esm/helpers/toast.js +73 -1
- package/dist/esm/index.js +111 -1
- package/dist/esm/node_modules/prismjs/components/prism-bash.js +235 -1
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +31 -1
- package/dist/esm/node_modules/prismjs/components/prism-css.js +64 -1
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +172 -1
- package/dist/esm/node_modules/prismjs/components/prism-json.js +27 -1
- package/dist/esm/node_modules/prismjs/components/prism-jsx.js +143 -1
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +186 -1
- package/dist/esm/node_modules/prismjs/components/prism-scss.js +81 -1
- package/dist/esm/node_modules/prismjs/components/prism-tsx.js +15 -1
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +60 -1
- package/dist/index.cjs +55414 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.js +38284 -1
- package/dist/react/chunks/lottie-72a4c6d4.js +17032 -0
- package/dist/react/index.cjs +56503 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.esm.js +39373 -1
- package/package.json +1 -1
- package/dist/chunks/lottie-2d1f6278.js +0 -1
- package/dist/react/chunks/lottie-14e7addb.js +0 -1
|
@@ -1 +1,322 @@
|
|
|
1
|
-
import{createDbIcon
|
|
1
|
+
import { createDbIcon } from './db-icons.js';
|
|
2
|
+
|
|
3
|
+
class DbOnboardingModal extends HTMLElement {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.internalStep = 0;
|
|
7
|
+
this.keyHandler = null;
|
|
8
|
+
this.isMounted = false;
|
|
9
|
+
this.handlePrev = () => {
|
|
10
|
+
if (this.getCurrentStep() > 0)
|
|
11
|
+
this.goToStep(this.getCurrentStep() - 1);
|
|
12
|
+
};
|
|
13
|
+
this.handleNext = () => {
|
|
14
|
+
const steps = this.getSteps();
|
|
15
|
+
const current = this.getCurrentStep();
|
|
16
|
+
if (current >= steps.length - 1) {
|
|
17
|
+
this.dispatchEvent(new CustomEvent('db-complete', { bubbles: true, composed: true }));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.goToStep(current + 1);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
static get observedAttributes() {
|
|
24
|
+
return [
|
|
25
|
+
'open',
|
|
26
|
+
'steps',
|
|
27
|
+
'current-step',
|
|
28
|
+
'show-close-button',
|
|
29
|
+
'show-indicator',
|
|
30
|
+
'indicator-type',
|
|
31
|
+
'indicator-size',
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
get open() {
|
|
35
|
+
return this.hasAttribute('open') && this.getAttribute('open') !== 'false';
|
|
36
|
+
}
|
|
37
|
+
set open(value) {
|
|
38
|
+
if (value)
|
|
39
|
+
this.setAttribute('open', '');
|
|
40
|
+
else
|
|
41
|
+
this.removeAttribute('open');
|
|
42
|
+
}
|
|
43
|
+
get steps() {
|
|
44
|
+
return this.parseSteps();
|
|
45
|
+
}
|
|
46
|
+
set steps(value) {
|
|
47
|
+
const next = typeof value === 'string' ? value : JSON.stringify(value);
|
|
48
|
+
if (this.getAttribute('steps') === next)
|
|
49
|
+
return;
|
|
50
|
+
this.setAttribute('steps', next);
|
|
51
|
+
}
|
|
52
|
+
connectedCallback() {
|
|
53
|
+
this.style.display = 'contents';
|
|
54
|
+
this.syncStepFromAttribute();
|
|
55
|
+
this.syncOpenState();
|
|
56
|
+
}
|
|
57
|
+
disconnectedCallback() {
|
|
58
|
+
this.detachKeyHandler();
|
|
59
|
+
this.unmount();
|
|
60
|
+
}
|
|
61
|
+
attributeChangedCallback(name) {
|
|
62
|
+
if (!this.isConnected)
|
|
63
|
+
return;
|
|
64
|
+
if (name === 'open') {
|
|
65
|
+
this.syncOpenState();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (name === 'current-step') {
|
|
69
|
+
this.syncStepFromAttribute();
|
|
70
|
+
}
|
|
71
|
+
if (name === 'steps') {
|
|
72
|
+
if (this.isOpenRequested()) {
|
|
73
|
+
if (!this.isMounted)
|
|
74
|
+
this.syncOpenState();
|
|
75
|
+
else
|
|
76
|
+
this.render();
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (this.isMounted)
|
|
81
|
+
this.render();
|
|
82
|
+
}
|
|
83
|
+
isOpenRequested() {
|
|
84
|
+
return this.open;
|
|
85
|
+
}
|
|
86
|
+
parseSteps() {
|
|
87
|
+
const raw = this.getAttribute('steps');
|
|
88
|
+
if (!raw)
|
|
89
|
+
return [];
|
|
90
|
+
try {
|
|
91
|
+
const parsed = JSON.parse(raw);
|
|
92
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
syncStepFromAttribute() {
|
|
99
|
+
if (!this.hasAttribute('current-step'))
|
|
100
|
+
return;
|
|
101
|
+
const next = Number(this.getAttribute('current-step') || 0);
|
|
102
|
+
if (Number.isFinite(next))
|
|
103
|
+
this.internalStep = Math.max(0, next);
|
|
104
|
+
}
|
|
105
|
+
getSteps() {
|
|
106
|
+
return this.parseSteps();
|
|
107
|
+
}
|
|
108
|
+
getCurrentStep() {
|
|
109
|
+
const steps = this.getSteps();
|
|
110
|
+
if (!steps.length)
|
|
111
|
+
return 0;
|
|
112
|
+
return Math.min(Math.max(this.internalStep, 0), steps.length - 1);
|
|
113
|
+
}
|
|
114
|
+
close() {
|
|
115
|
+
this.open = false;
|
|
116
|
+
this.dispatchEvent(new CustomEvent('db-close', { bubbles: true, composed: true }));
|
|
117
|
+
}
|
|
118
|
+
emitStepChange(step) {
|
|
119
|
+
this.dispatchEvent(new CustomEvent('db-step-change', {
|
|
120
|
+
bubbles: true,
|
|
121
|
+
composed: true,
|
|
122
|
+
detail: { step },
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
goToStep(step) {
|
|
126
|
+
const steps = this.getSteps();
|
|
127
|
+
if (!steps.length)
|
|
128
|
+
return;
|
|
129
|
+
const next = Math.min(Math.max(step, 0), steps.length - 1);
|
|
130
|
+
this.internalStep = next;
|
|
131
|
+
this.emitStepChange(next);
|
|
132
|
+
this.render();
|
|
133
|
+
}
|
|
134
|
+
attachKeyHandler() {
|
|
135
|
+
if (this.keyHandler)
|
|
136
|
+
return;
|
|
137
|
+
this.keyHandler = (event) => {
|
|
138
|
+
if (event.key === 'Escape') {
|
|
139
|
+
this.close();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (event.key === 'ArrowLeft' && this.getCurrentStep() > 0) {
|
|
143
|
+
this.handlePrev();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (event.key === 'ArrowRight' && this.getCurrentStep() < this.getSteps().length - 1) {
|
|
147
|
+
this.handleNext();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
document.addEventListener('keydown', this.keyHandler);
|
|
151
|
+
}
|
|
152
|
+
detachKeyHandler() {
|
|
153
|
+
if (!this.keyHandler)
|
|
154
|
+
return;
|
|
155
|
+
document.removeEventListener('keydown', this.keyHandler);
|
|
156
|
+
this.keyHandler = null;
|
|
157
|
+
}
|
|
158
|
+
syncOpenState() {
|
|
159
|
+
if (this.isOpenRequested()) {
|
|
160
|
+
this.mount();
|
|
161
|
+
this.attachKeyHandler();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this.detachKeyHandler();
|
|
165
|
+
this.unmount();
|
|
166
|
+
}
|
|
167
|
+
mount() {
|
|
168
|
+
if (!this.root) {
|
|
169
|
+
this.root = document.createElement('div');
|
|
170
|
+
this.root.className = 'designbase-wc-onboarding-modal';
|
|
171
|
+
this.root.setAttribute('role', 'dialog');
|
|
172
|
+
this.root.setAttribute('aria-modal', 'true');
|
|
173
|
+
this.root.tabIndex = -1;
|
|
174
|
+
this.ensureStructure();
|
|
175
|
+
}
|
|
176
|
+
if (!this.root.isConnected) {
|
|
177
|
+
document.body.append(this.root);
|
|
178
|
+
}
|
|
179
|
+
this.isMounted = true;
|
|
180
|
+
this.render();
|
|
181
|
+
}
|
|
182
|
+
unmount() {
|
|
183
|
+
this.isMounted = false;
|
|
184
|
+
this.root?.remove();
|
|
185
|
+
}
|
|
186
|
+
ensureStructure() {
|
|
187
|
+
if (!this.root)
|
|
188
|
+
return;
|
|
189
|
+
if (this.contentEl && this.root.contains(this.contentEl))
|
|
190
|
+
return;
|
|
191
|
+
this.overlayEl = undefined;
|
|
192
|
+
this.contentEl = undefined;
|
|
193
|
+
this.closeButtonEl = undefined;
|
|
194
|
+
this.mainEl = undefined;
|
|
195
|
+
this.imageWrapEl = undefined;
|
|
196
|
+
this.imageEl = undefined;
|
|
197
|
+
this.textEl = undefined;
|
|
198
|
+
this.titleEl = undefined;
|
|
199
|
+
this.descriptionEl = undefined;
|
|
200
|
+
this.navigationEl = undefined;
|
|
201
|
+
this.prevButtonEl = undefined;
|
|
202
|
+
this.nextButtonEl = undefined;
|
|
203
|
+
this.indicatorEl = undefined;
|
|
204
|
+
this.root.replaceChildren();
|
|
205
|
+
this.overlayEl = document.createElement('div');
|
|
206
|
+
this.overlayEl.className = 'designbase-wc-onboarding-modal__overlay';
|
|
207
|
+
this.overlayEl.addEventListener('click', () => this.close());
|
|
208
|
+
this.contentEl = document.createElement('div');
|
|
209
|
+
this.contentEl.className = 'designbase-wc-onboarding-modal__content';
|
|
210
|
+
this.closeButtonEl = document.createElement('button');
|
|
211
|
+
this.closeButtonEl.type = 'button';
|
|
212
|
+
this.closeButtonEl.className = 'designbase-wc-onboarding-modal__close-button';
|
|
213
|
+
this.closeButtonEl.setAttribute('aria-label', '닫기');
|
|
214
|
+
this.closeButtonEl.append(createDbIcon('close', 20));
|
|
215
|
+
this.closeButtonEl.addEventListener('click', () => this.close());
|
|
216
|
+
this.mainEl = document.createElement('div');
|
|
217
|
+
this.mainEl.className = 'designbase-wc-onboarding-modal__main';
|
|
218
|
+
this.imageWrapEl = document.createElement('div');
|
|
219
|
+
this.imageWrapEl.className = 'designbase-wc-onboarding-modal__image';
|
|
220
|
+
this.imageEl = document.createElement('img');
|
|
221
|
+
this.imageWrapEl.append(this.imageEl);
|
|
222
|
+
this.textEl = document.createElement('div');
|
|
223
|
+
this.textEl.className = 'designbase-wc-onboarding-modal__text';
|
|
224
|
+
this.titleEl = document.createElement('h2');
|
|
225
|
+
this.titleEl.id = 'onboarding-title';
|
|
226
|
+
this.titleEl.className = 'designbase-wc-onboarding-modal__title';
|
|
227
|
+
this.descriptionEl = document.createElement('p');
|
|
228
|
+
this.descriptionEl.id = 'onboarding-description';
|
|
229
|
+
this.descriptionEl.className = 'designbase-wc-onboarding-modal__description';
|
|
230
|
+
this.textEl.append(this.titleEl, this.descriptionEl);
|
|
231
|
+
this.mainEl.append(this.imageWrapEl, this.textEl);
|
|
232
|
+
this.navigationEl = document.createElement('div');
|
|
233
|
+
this.navigationEl.className = 'designbase-wc-onboarding-modal__navigation';
|
|
234
|
+
this.prevButtonEl = document.createElement('db-button');
|
|
235
|
+
this.prevButtonEl.setAttribute('variant', 'secondary');
|
|
236
|
+
this.prevButtonEl.setAttribute('size', 'm');
|
|
237
|
+
this.prevButtonEl.setAttribute('start-icon', 'chevron-left');
|
|
238
|
+
this.prevButtonEl.setAttribute('aria-label', '이전');
|
|
239
|
+
this.prevButtonEl.addEventListener('db-click', this.handlePrev);
|
|
240
|
+
this.indicatorEl = document.createElement('db-indicator');
|
|
241
|
+
this.indicatorEl.addEventListener('db-step-click', (event) => {
|
|
242
|
+
const detail = event.detail;
|
|
243
|
+
this.goToStep(detail.index ?? detail.current);
|
|
244
|
+
});
|
|
245
|
+
this.nextButtonEl = document.createElement('db-button');
|
|
246
|
+
this.nextButtonEl.setAttribute('variant', 'primary');
|
|
247
|
+
this.nextButtonEl.setAttribute('size', 'm');
|
|
248
|
+
this.nextButtonEl.addEventListener('db-click', this.handleNext);
|
|
249
|
+
this.navigationEl.append(this.prevButtonEl, this.indicatorEl, this.nextButtonEl);
|
|
250
|
+
this.contentEl.append(this.closeButtonEl, this.mainEl, this.navigationEl);
|
|
251
|
+
this.root.append(this.overlayEl, this.contentEl);
|
|
252
|
+
}
|
|
253
|
+
render() {
|
|
254
|
+
if (!this.root || !this.isMounted)
|
|
255
|
+
return;
|
|
256
|
+
this.ensureStructure();
|
|
257
|
+
const steps = this.getSteps();
|
|
258
|
+
const current = this.getCurrentStep();
|
|
259
|
+
const step = steps[current];
|
|
260
|
+
if (!step)
|
|
261
|
+
return;
|
|
262
|
+
const showCloseButton = !this.hasAttribute('show-close-button') || this.getAttribute('show-close-button') !== 'false';
|
|
263
|
+
const showIndicator = !this.hasAttribute('show-indicator') || this.getAttribute('show-indicator') !== 'false';
|
|
264
|
+
const indicatorType = this.getAttribute('indicator-type') || 'dots';
|
|
265
|
+
const indicatorSize = this.getAttribute('indicator-size') || 'm';
|
|
266
|
+
const isFirst = current === 0;
|
|
267
|
+
const isLast = current === steps.length - 1;
|
|
268
|
+
this.root.setAttribute('aria-labelledby', 'onboarding-title');
|
|
269
|
+
this.root.setAttribute('aria-describedby', 'onboarding-description');
|
|
270
|
+
if (this.closeButtonEl)
|
|
271
|
+
this.closeButtonEl.style.display = showCloseButton ? '' : 'none';
|
|
272
|
+
if (this.imageWrapEl && this.imageEl) {
|
|
273
|
+
if (step.image) {
|
|
274
|
+
this.imageEl.src = step.image;
|
|
275
|
+
this.imageEl.alt = step.title || '온보딩 이미지';
|
|
276
|
+
this.imageWrapEl.style.display = '';
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
this.imageWrapEl.style.display = 'none';
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (this.titleEl) {
|
|
283
|
+
this.titleEl.textContent = step.title || '';
|
|
284
|
+
this.titleEl.style.display = step.title ? '' : 'none';
|
|
285
|
+
}
|
|
286
|
+
if (this.descriptionEl) {
|
|
287
|
+
this.descriptionEl.textContent = step.description || '';
|
|
288
|
+
this.descriptionEl.style.display = step.description ? '' : 'none';
|
|
289
|
+
}
|
|
290
|
+
if (this.prevButtonEl) {
|
|
291
|
+
this.prevButtonEl.textContent = '이전';
|
|
292
|
+
if (isFirst)
|
|
293
|
+
this.prevButtonEl.setAttribute('disabled', '');
|
|
294
|
+
else
|
|
295
|
+
this.prevButtonEl.removeAttribute('disabled');
|
|
296
|
+
}
|
|
297
|
+
if (this.nextButtonEl) {
|
|
298
|
+
this.nextButtonEl.textContent = isLast ? '완료' : '다음';
|
|
299
|
+
this.nextButtonEl.setAttribute('aria-label', isLast ? '완료' : '다음');
|
|
300
|
+
if (isLast)
|
|
301
|
+
this.nextButtonEl.removeAttribute('end-icon');
|
|
302
|
+
else
|
|
303
|
+
this.nextButtonEl.setAttribute('end-icon', 'chevron-right');
|
|
304
|
+
}
|
|
305
|
+
if (this.indicatorEl) {
|
|
306
|
+
const shouldShowIndicator = showIndicator && steps.length > 1;
|
|
307
|
+
this.indicatorEl.style.display = shouldShowIndicator ? '' : 'none';
|
|
308
|
+
if (shouldShowIndicator) {
|
|
309
|
+
this.indicatorEl.setAttribute('total', String(steps.length));
|
|
310
|
+
this.indicatorEl.setAttribute('current', String(current));
|
|
311
|
+
this.indicatorEl.setAttribute('indicator-type', indicatorType);
|
|
312
|
+
this.indicatorEl.setAttribute('size', indicatorSize);
|
|
313
|
+
this.indicatorEl.setAttribute('clickable', '');
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (!customElements.get('db-onboarding-modal')) {
|
|
319
|
+
customElements.define('db-onboarding-modal', DbOnboardingModal);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export { DbOnboardingModal };
|
|
@@ -1 +1,312 @@
|
|
|
1
|
-
const
|
|
1
|
+
const VARIANTS = ['default', 'minimal'];
|
|
2
|
+
const ALIGNS = ['center', 'left'];
|
|
3
|
+
function navigatePageHeaderBack(fallbackHref = '/') {
|
|
4
|
+
if (typeof window === 'undefined')
|
|
5
|
+
return;
|
|
6
|
+
const historyIdx = window.history.state?.idx;
|
|
7
|
+
if (typeof historyIdx === 'number' && historyIdx > 0) {
|
|
8
|
+
window.history.back();
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const hasSameOriginReferrer = (() => {
|
|
12
|
+
try {
|
|
13
|
+
if (!document.referrer)
|
|
14
|
+
return false;
|
|
15
|
+
return new URL(document.referrer).origin === window.location.origin;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
})();
|
|
21
|
+
if (hasSameOriginReferrer) {
|
|
22
|
+
window.history.back();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (window.history.length > 1) {
|
|
26
|
+
window.history.back();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
window.location.assign(fallbackHref);
|
|
30
|
+
}
|
|
31
|
+
class DbPageHeader extends HTMLElement {
|
|
32
|
+
constructor() {
|
|
33
|
+
super(...arguments);
|
|
34
|
+
this.internalTabId = '';
|
|
35
|
+
this.isRendering = false;
|
|
36
|
+
this.handleBack = () => {
|
|
37
|
+
const event = new CustomEvent('db-back', { bubbles: true, composed: true, cancelable: true });
|
|
38
|
+
this.dispatchEvent(event);
|
|
39
|
+
if (event.defaultPrevented)
|
|
40
|
+
return;
|
|
41
|
+
navigatePageHeaderBack(this.getAttribute('back-fallback-href') || '/');
|
|
42
|
+
};
|
|
43
|
+
this.handleTabChange = (event) => {
|
|
44
|
+
const detail = event.detail;
|
|
45
|
+
const tabId = detail?.selectedId ??
|
|
46
|
+
this.parseTabs()[detail?.index ?? 0]?.id ??
|
|
47
|
+
String(detail?.index ?? 0);
|
|
48
|
+
if (!this.hasAttribute('selected-tab-id')) {
|
|
49
|
+
this.internalTabId = tabId;
|
|
50
|
+
}
|
|
51
|
+
this.dispatchEvent(new CustomEvent('db-tab-change', {
|
|
52
|
+
bubbles: true,
|
|
53
|
+
composed: true,
|
|
54
|
+
detail: { tabId },
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
static get observedAttributes() {
|
|
59
|
+
return [
|
|
60
|
+
'title',
|
|
61
|
+
'subtitle',
|
|
62
|
+
'description',
|
|
63
|
+
'breadcrumbs',
|
|
64
|
+
'variant',
|
|
65
|
+
'show-back-button',
|
|
66
|
+
'back-fallback-href',
|
|
67
|
+
'back-label',
|
|
68
|
+
'tabs',
|
|
69
|
+
'selected-tab-id',
|
|
70
|
+
'default-selected-tab-id',
|
|
71
|
+
'align',
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
connectedCallback() {
|
|
75
|
+
this.syncDefaultTab();
|
|
76
|
+
this.render();
|
|
77
|
+
this.childObserver = new MutationObserver(() => {
|
|
78
|
+
if (this.isRendering)
|
|
79
|
+
return;
|
|
80
|
+
if (!this.hasPendingSlottedChildren())
|
|
81
|
+
return;
|
|
82
|
+
this.render();
|
|
83
|
+
});
|
|
84
|
+
this.childObserver.observe(this, { childList: true });
|
|
85
|
+
}
|
|
86
|
+
disconnectedCallback() {
|
|
87
|
+
this.childObserver?.disconnect();
|
|
88
|
+
}
|
|
89
|
+
attributeChangedCallback(name) {
|
|
90
|
+
if (!this.isConnected)
|
|
91
|
+
return;
|
|
92
|
+
if (name === 'default-selected-tab-id' || name === 'tabs') {
|
|
93
|
+
this.syncDefaultTab();
|
|
94
|
+
}
|
|
95
|
+
this.render();
|
|
96
|
+
}
|
|
97
|
+
/** React가 slot 자식을 host에 다시 붙였는지 감지 */
|
|
98
|
+
hasPendingSlottedChildren() {
|
|
99
|
+
return Array.from(this.children).some((child) => {
|
|
100
|
+
const slot = child.getAttribute('slot');
|
|
101
|
+
return slot === 'actions' || slot === 'meta' || slot === 'description';
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
syncDefaultTab() {
|
|
105
|
+
if (this.internalTabId)
|
|
106
|
+
return;
|
|
107
|
+
const tabs = this.parseTabs();
|
|
108
|
+
const defaultId = this.getAttribute('default-selected-tab-id');
|
|
109
|
+
this.internalTabId = defaultId || tabs[0]?.id || '';
|
|
110
|
+
}
|
|
111
|
+
parseTabs() {
|
|
112
|
+
try {
|
|
113
|
+
const parsed = JSON.parse(this.getAttribute('tabs') || '[]');
|
|
114
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
parseBreadcrumbs() {
|
|
121
|
+
try {
|
|
122
|
+
const parsed = JSON.parse(this.getAttribute('breadcrumbs') || '[]');
|
|
123
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
getActiveTabId() {
|
|
130
|
+
return this.getAttribute('selected-tab-id') || this.internalTabId;
|
|
131
|
+
}
|
|
132
|
+
getVariant() {
|
|
133
|
+
const raw = this.getAttribute('variant') || 'default';
|
|
134
|
+
return VARIANTS.includes(raw) ? raw : 'default';
|
|
135
|
+
}
|
|
136
|
+
getAlign() {
|
|
137
|
+
const raw = this.getAttribute('align') || 'center';
|
|
138
|
+
return ALIGNS.includes(raw) ? raw : 'center';
|
|
139
|
+
}
|
|
140
|
+
collectActions() {
|
|
141
|
+
const direct = Array.from(this.querySelectorAll(':scope > [slot="actions"]'));
|
|
142
|
+
if (direct.length)
|
|
143
|
+
return direct;
|
|
144
|
+
// aside > cta 로 이미 배치된 경우 (재렌더)
|
|
145
|
+
const cta = this.querySelector('.designbase-wc-page-header__cta');
|
|
146
|
+
if (cta?.children.length)
|
|
147
|
+
return Array.from(cta.children);
|
|
148
|
+
const actions = this.querySelector('.designbase-wc-page-header__actions');
|
|
149
|
+
if (actions?.children.length)
|
|
150
|
+
return Array.from(actions.children);
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
collectMeta() {
|
|
154
|
+
const direct = Array.from(this.querySelectorAll(':scope > [slot="meta"]'));
|
|
155
|
+
if (direct.length)
|
|
156
|
+
return direct;
|
|
157
|
+
// aside > meta 로 이미 배치된 경우 (재렌더)
|
|
158
|
+
const meta = this.querySelector('.designbase-wc-page-header__meta');
|
|
159
|
+
if (meta?.children.length)
|
|
160
|
+
return Array.from(meta.children);
|
|
161
|
+
return [];
|
|
162
|
+
}
|
|
163
|
+
renderMinimalAside(savedMeta, savedActions) {
|
|
164
|
+
if (!savedMeta.length && !savedActions.length)
|
|
165
|
+
return null;
|
|
166
|
+
const aside = document.createElement('div');
|
|
167
|
+
aside.className = 'designbase-wc-page-header__aside';
|
|
168
|
+
if (savedMeta.length) {
|
|
169
|
+
const meta = document.createElement('div');
|
|
170
|
+
meta.className = 'designbase-wc-page-header__meta';
|
|
171
|
+
savedMeta.forEach((node) => meta.append(node));
|
|
172
|
+
aside.append(meta);
|
|
173
|
+
}
|
|
174
|
+
if (savedActions.length) {
|
|
175
|
+
const cta = document.createElement('div');
|
|
176
|
+
cta.className = 'designbase-wc-page-header__cta';
|
|
177
|
+
savedActions.forEach((node) => cta.append(node));
|
|
178
|
+
aside.append(cta);
|
|
179
|
+
}
|
|
180
|
+
return aside;
|
|
181
|
+
}
|
|
182
|
+
collectDescriptionSlot() {
|
|
183
|
+
const slotted = this.querySelector(':scope > [slot="description"]');
|
|
184
|
+
if (slotted)
|
|
185
|
+
return slotted;
|
|
186
|
+
const description = this.querySelector(':scope .designbase-wc-page-header__description');
|
|
187
|
+
const child = description?.firstElementChild;
|
|
188
|
+
return child || null;
|
|
189
|
+
}
|
|
190
|
+
renderTitleBlock(descriptionSlot) {
|
|
191
|
+
const fragment = document.createDocumentFragment();
|
|
192
|
+
const title = this.getAttribute('title') || '';
|
|
193
|
+
const subtitle = this.getAttribute('subtitle');
|
|
194
|
+
const titleEl = document.createElement('h1');
|
|
195
|
+
titleEl.className = 'designbase-wc-page-header__title';
|
|
196
|
+
titleEl.textContent = title;
|
|
197
|
+
fragment.append(titleEl);
|
|
198
|
+
if (subtitle) {
|
|
199
|
+
const subtitleEl = document.createElement('h2');
|
|
200
|
+
subtitleEl.className = 'designbase-wc-page-header__subtitle';
|
|
201
|
+
subtitleEl.textContent = subtitle;
|
|
202
|
+
fragment.append(subtitleEl);
|
|
203
|
+
}
|
|
204
|
+
const description = this.getAttribute('description');
|
|
205
|
+
if (descriptionSlot || description) {
|
|
206
|
+
const descriptionEl = document.createElement('div');
|
|
207
|
+
descriptionEl.className = 'designbase-wc-page-header__description';
|
|
208
|
+
if (descriptionSlot) {
|
|
209
|
+
descriptionEl.append(descriptionSlot);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
descriptionEl.textContent = description;
|
|
213
|
+
}
|
|
214
|
+
fragment.append(descriptionEl);
|
|
215
|
+
}
|
|
216
|
+
return fragment;
|
|
217
|
+
}
|
|
218
|
+
render() {
|
|
219
|
+
this.isRendering = true;
|
|
220
|
+
const savedActions = this.collectActions();
|
|
221
|
+
const savedMeta = this.collectMeta();
|
|
222
|
+
const savedDescription = this.collectDescriptionSlot();
|
|
223
|
+
const variant = this.getVariant();
|
|
224
|
+
const isMinimal = variant === 'minimal';
|
|
225
|
+
const align = this.getAlign();
|
|
226
|
+
const breadcrumbs = this.parseBreadcrumbs();
|
|
227
|
+
const tabs = this.parseTabs();
|
|
228
|
+
const hasTabs = tabs.length > 0;
|
|
229
|
+
const showBackButton = this.hasAttribute('show-back-button');
|
|
230
|
+
this.className = [
|
|
231
|
+
'designbase-wc-page-header',
|
|
232
|
+
isMinimal ? 'designbase-wc-page-header--minimal' : `designbase-wc-page-header--${align}`,
|
|
233
|
+
isMinimal && hasTabs ? 'designbase-wc-page-header--has-tabs' : '',
|
|
234
|
+
]
|
|
235
|
+
.filter(Boolean)
|
|
236
|
+
.join(' ');
|
|
237
|
+
this.replaceChildren();
|
|
238
|
+
if (breadcrumbs.length) {
|
|
239
|
+
const breadcrumbsWrap = document.createElement('div');
|
|
240
|
+
breadcrumbsWrap.className = 'designbase-wc-page-header__breadcrumbs';
|
|
241
|
+
const crumbs = document.createElement('db-breadcrumbs');
|
|
242
|
+
crumbs.setAttribute('size', 's');
|
|
243
|
+
crumbs.setAttribute('items', JSON.stringify(breadcrumbs));
|
|
244
|
+
breadcrumbsWrap.append(crumbs);
|
|
245
|
+
this.append(breadcrumbsWrap);
|
|
246
|
+
}
|
|
247
|
+
const main = document.createElement('div');
|
|
248
|
+
main.className = 'designbase-wc-page-header__main';
|
|
249
|
+
const content = document.createElement('div');
|
|
250
|
+
content.className = 'designbase-wc-page-header__content';
|
|
251
|
+
if (isMinimal && showBackButton) {
|
|
252
|
+
const titleRow = document.createElement('div');
|
|
253
|
+
titleRow.className = 'designbase-wc-page-header__title-row';
|
|
254
|
+
const backButton = document.createElement('db-button');
|
|
255
|
+
backButton.className = 'designbase-wc-page-header__back-button';
|
|
256
|
+
backButton.setAttribute('variant', 'tertiary');
|
|
257
|
+
backButton.setAttribute('size', 'm');
|
|
258
|
+
backButton.setAttribute('icon-only', '');
|
|
259
|
+
backButton.setAttribute('start-icon', 'chevron-left');
|
|
260
|
+
backButton.setAttribute('aria-label', this.getAttribute('back-label') || '뒤로가기');
|
|
261
|
+
backButton.setAttribute('tooltip', this.getAttribute('back-label') || '뒤로가기');
|
|
262
|
+
backButton.addEventListener('db-click', this.handleBack);
|
|
263
|
+
titleRow.append(backButton);
|
|
264
|
+
const titleGroup = document.createElement('div');
|
|
265
|
+
titleGroup.className = 'designbase-wc-page-header__title-group';
|
|
266
|
+
titleGroup.append(this.renderTitleBlock(savedDescription));
|
|
267
|
+
titleRow.append(titleGroup);
|
|
268
|
+
content.append(titleRow);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
content.append(this.renderTitleBlock(savedDescription));
|
|
272
|
+
}
|
|
273
|
+
main.append(content);
|
|
274
|
+
if (isMinimal) {
|
|
275
|
+
const aside = this.renderMinimalAside(savedMeta, savedActions);
|
|
276
|
+
if (aside)
|
|
277
|
+
main.append(aside);
|
|
278
|
+
}
|
|
279
|
+
this.append(main);
|
|
280
|
+
if (!isMinimal && savedActions.length) {
|
|
281
|
+
const actionsWrap = document.createElement('div');
|
|
282
|
+
actionsWrap.className = 'designbase-wc-page-header__actions';
|
|
283
|
+
savedActions.forEach((node) => actionsWrap.append(node));
|
|
284
|
+
this.append(actionsWrap);
|
|
285
|
+
}
|
|
286
|
+
this.renderMinimalTabs(isMinimal, hasTabs, tabs);
|
|
287
|
+
queueMicrotask(() => {
|
|
288
|
+
this.isRendering = false;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
renderMinimalTabs(isMinimal, hasTabs, tabs) {
|
|
292
|
+
if (!isMinimal || !hasTabs)
|
|
293
|
+
return;
|
|
294
|
+
const toolbar = document.createElement('div');
|
|
295
|
+
toolbar.className = 'designbase-wc-page-header__toolbar';
|
|
296
|
+
const tabsWrap = document.createElement('div');
|
|
297
|
+
tabsWrap.className = 'designbase-wc-page-header__tabs';
|
|
298
|
+
const tabsEl = document.createElement('db-tabs');
|
|
299
|
+
tabsEl.setAttribute('size', 'm');
|
|
300
|
+
tabsEl.setAttribute('items', JSON.stringify(tabs));
|
|
301
|
+
tabsEl.setAttribute('selected-id', this.getActiveTabId());
|
|
302
|
+
tabsEl.addEventListener('db-change', this.handleTabChange);
|
|
303
|
+
tabsWrap.append(tabsEl);
|
|
304
|
+
toolbar.append(tabsWrap);
|
|
305
|
+
this.append(toolbar);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (!customElements.get('db-page-header')) {
|
|
309
|
+
customElements.define('db-page-header', DbPageHeader);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export { DbPageHeader };
|