@designbasekorea/ui-wc 0.5.6 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/lottie-35a9b0f5.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 +64 -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 +63 -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.d.ts +20 -0
- 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 +71 -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/prismjs/components/prism-bash.js +1 -235
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +1 -31
- package/dist/esm/node_modules/prismjs/components/prism-css.js +1 -64
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +1 -172
- package/dist/esm/node_modules/prismjs/components/prism-json.js +1 -27
- package/dist/esm/node_modules/prismjs/components/prism-jsx.js +1 -143
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +1 -186
- package/dist/esm/node_modules/prismjs/components/prism-scss.js +1 -81
- package/dist/esm/node_modules/prismjs/components/prism-tsx.js +1 -15
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +1 -60
- package/dist/index.cjs +1 -55414
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1125 -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 +1637 -21
- package/dist/react/index.esm.js +1 -39373
- package/package.json +2 -2
- package/dist/chunks/lottie-e273b936.js +0 -17032
- package/dist/react/chunks/lottie-72a4c6d4.js +0 -17032
|
@@ -1,312 +1 @@
|
|
|
1
|
-
const
|
|
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 };
|
|
1
|
+
const e=["default","minimal"],t=["center","left"];class DbPageHeader extends HTMLElement{constructor(){super(...arguments),this.internalTabId="",this.isRendering=!1,this.handleBack=()=>{const e=new CustomEvent("db-back",{bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(e),e.defaultPrevented||function navigatePageHeaderBack(e="/"){if("undefined"==typeof window)return;const t=window.history.state?.idx;if("number"==typeof t&&t>0)return void window.history.back();(()=>{try{return!!document.referrer&&new URL(document.referrer).origin===window.location.origin}catch{return!1}})()||window.history.length>1?window.history.back():window.location.assign(e)}(this.getAttribute("back-fallback-href")||"/")},this.handleTabChange=e=>{const t=e.detail,a=t?.selectedId??this.parseTabs()[t?.index??0]?.id??String(t?.index??0);this.hasAttribute("selected-tab-id")||(this.internalTabId=a),this.dispatchEvent(new CustomEvent("db-tab-change",{bubbles:!0,composed:!0,detail:{tabId:a}}))}}static get observedAttributes(){return["title","subtitle","description","breadcrumbs","variant","show-back-button","back-fallback-href","back-label","tabs","selected-tab-id","default-selected-tab-id","align"]}connectedCallback(){this.syncDefaultTab(),this.render(),this.childObserver=new MutationObserver(()=>{this.isRendering||this.hasPendingSlottedChildren()&&this.render()}),this.childObserver.observe(this,{childList:!0})}disconnectedCallback(){this.childObserver?.disconnect()}attributeChangedCallback(e){this.isConnected&&("default-selected-tab-id"!==e&&"tabs"!==e||this.syncDefaultTab(),this.render())}hasPendingSlottedChildren(){return Array.from(this.children).some(e=>{const t=e.getAttribute("slot");return"actions"===t||"meta"===t||"description"===t})}syncDefaultTab(){if(this.internalTabId)return;const e=this.parseTabs(),t=this.getAttribute("default-selected-tab-id");this.internalTabId=t||e[0]?.id||""}parseTabs(){try{const e=JSON.parse(this.getAttribute("tabs")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}parseBreadcrumbs(){try{const e=JSON.parse(this.getAttribute("breadcrumbs")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}getActiveTabId(){return this.getAttribute("selected-tab-id")||this.internalTabId}getVariant(){const t=this.getAttribute("variant")||"default";return e.includes(t)?t:"default"}getAlign(){const e=this.getAttribute("align")||"center";return t.includes(e)?e:"center"}collectActions(){const e=Array.from(this.querySelectorAll(':scope > [slot="actions"]'));if(e.length)return e;const t=this.querySelector(".designbase-wc-page-header__cta");if(t?.children.length)return Array.from(t.children);const a=this.querySelector(".designbase-wc-page-header__actions");return a?.children.length?Array.from(a.children):[]}collectMeta(){const e=Array.from(this.querySelectorAll(':scope > [slot="meta"]'));if(e.length)return e;const t=this.querySelector(".designbase-wc-page-header__meta");return t?.children.length?Array.from(t.children):[]}renderMinimalAside(e,t){if(!e.length&&!t.length)return null;const a=document.createElement("div");if(a.className="designbase-wc-page-header__aside",e.length){const t=document.createElement("div");t.className="designbase-wc-page-header__meta",e.forEach(e=>t.append(e)),a.append(t)}if(t.length){const e=document.createElement("div");e.className="designbase-wc-page-header__cta",t.forEach(t=>e.append(t)),a.append(e)}return a}collectDescriptionSlot(){const e=this.querySelector(':scope > [slot="description"]');if(e)return e;const t=this.querySelector(":scope .designbase-wc-page-header__description"),a=t?.firstElementChild;return a||null}renderTitleBlock(e){const t=document.createDocumentFragment(),a=this.getAttribute("title")||"",n=this.getAttribute("subtitle"),s=document.createElement("h1");if(s.className="designbase-wc-page-header__title",s.textContent=a,t.append(s),n){const e=document.createElement("h2");e.className="designbase-wc-page-header__subtitle",e.textContent=n,t.append(e)}const i=this.getAttribute("description");if(e||i){const a=document.createElement("div");a.className="designbase-wc-page-header__description",e?a.append(e):a.textContent=i,t.append(a)}return t}render(){this.isRendering=!0;const e=this.collectActions(),t=this.collectMeta(),a=this.collectDescriptionSlot(),n="minimal"===this.getVariant(),s=this.getAlign(),i=this.parseBreadcrumbs(),r=this.parseTabs(),c=r.length>0,d=this.hasAttribute("show-back-button");if(this.className=["designbase-wc-page-header",n?"designbase-wc-page-header--minimal":`designbase-wc-page-header--${s}`,n&&c?"designbase-wc-page-header--has-tabs":""].filter(Boolean).join(" "),this.replaceChildren(),i.length){const e=document.createElement("div");e.className="designbase-wc-page-header__breadcrumbs";const t=document.createElement("db-breadcrumbs");t.setAttribute("size","s"),t.setAttribute("items",JSON.stringify(i)),e.append(t),this.append(e)}const l=document.createElement("div");l.className="designbase-wc-page-header__main";const o=document.createElement("div");if(o.className="designbase-wc-page-header__content",n&&d){const e=document.createElement("div");e.className="designbase-wc-page-header__title-row";const t=document.createElement("db-button");t.className="designbase-wc-page-header__back-button",t.setAttribute("variant","tertiary"),t.setAttribute("size","m"),t.setAttribute("icon-only",""),t.setAttribute("start-icon","chevron-left"),t.setAttribute("aria-label",this.getAttribute("back-label")||"뒤로가기"),t.setAttribute("tooltip",this.getAttribute("back-label")||"뒤로가기"),t.addEventListener("db-click",this.handleBack),e.append(t);const n=document.createElement("div");n.className="designbase-wc-page-header__title-group",n.append(this.renderTitleBlock(a)),e.append(n),o.append(e)}else o.append(this.renderTitleBlock(a));if(l.append(o),n){const a=this.renderMinimalAside(t,e);a&&l.append(a)}if(this.append(l),!n&&e.length){const t=document.createElement("div");t.className="designbase-wc-page-header__actions",e.forEach(e=>t.append(e)),this.append(t)}this.renderMinimalTabs(n,c,r),queueMicrotask(()=>{this.isRendering=!1})}renderMinimalTabs(e,t,a){if(!e||!t)return;const n=document.createElement("div");n.className="designbase-wc-page-header__toolbar";const s=document.createElement("div");s.className="designbase-wc-page-header__tabs";const i=document.createElement("db-tabs");i.setAttribute("size","m"),i.setAttribute("items",JSON.stringify(a)),i.setAttribute("selected-id",this.getActiveTabId()),i.addEventListener("db-change",this.handleTabChange),s.append(i),n.append(s),this.append(n)}}customElements.get("db-page-header")||customElements.define("db-page-header",DbPageHeader);export{DbPageHeader};
|
|
@@ -1,271 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
class DbPagination extends HTMLElement {
|
|
4
|
-
static get observedAttributes() {
|
|
5
|
-
return [
|
|
6
|
-
'current-page',
|
|
7
|
-
'total-pages',
|
|
8
|
-
'total-items',
|
|
9
|
-
'page-size',
|
|
10
|
-
'page-size-options',
|
|
11
|
-
'size',
|
|
12
|
-
'variant',
|
|
13
|
-
'alignment',
|
|
14
|
-
'show-first-last',
|
|
15
|
-
'show-previous-next',
|
|
16
|
-
'show-page-size-selector',
|
|
17
|
-
'show-total',
|
|
18
|
-
'sibling-count',
|
|
19
|
-
'boundary-count',
|
|
20
|
-
'disabled',
|
|
21
|
-
'full-width',
|
|
22
|
-
];
|
|
23
|
-
}
|
|
24
|
-
get currentPage() {
|
|
25
|
-
return Number(this.getAttribute('current-page') || 1);
|
|
26
|
-
}
|
|
27
|
-
set currentPage(value) {
|
|
28
|
-
this.setAttribute('current-page', String(value));
|
|
29
|
-
}
|
|
30
|
-
get totalPages() {
|
|
31
|
-
return Number(this.getAttribute('total-pages') || 1);
|
|
32
|
-
}
|
|
33
|
-
set totalPages(value) {
|
|
34
|
-
this.setAttribute('total-pages', String(value));
|
|
35
|
-
}
|
|
36
|
-
connectedCallback() {
|
|
37
|
-
this.render();
|
|
38
|
-
}
|
|
39
|
-
attributeChangedCallback() {
|
|
40
|
-
if (!this.isConnected)
|
|
41
|
-
return;
|
|
42
|
-
this.render();
|
|
43
|
-
}
|
|
44
|
-
iconSize() {
|
|
45
|
-
const size = this.getAttribute('size') || 'm';
|
|
46
|
-
if (size === 's')
|
|
47
|
-
return 12;
|
|
48
|
-
if (size === 'l')
|
|
49
|
-
return 16;
|
|
50
|
-
return 14;
|
|
51
|
-
}
|
|
52
|
-
render() {
|
|
53
|
-
const size = this.getAttribute('size') || 'm';
|
|
54
|
-
const variant = this.getAttribute('variant') || 'default';
|
|
55
|
-
const alignment = this.getAttribute('alignment') || 'center';
|
|
56
|
-
const disabled = this.hasAttribute('disabled');
|
|
57
|
-
const showFirstLast = this.hasAttribute('show-first-last');
|
|
58
|
-
const showPreviousNext = this.getAttribute('show-previous-next') !== 'false';
|
|
59
|
-
const showPageSizeSelector = this.hasAttribute('show-page-size-selector');
|
|
60
|
-
const showTotal = this.hasAttribute('show-total');
|
|
61
|
-
const fullWidth = this.hasAttribute('full-width') || showPageSizeSelector || showTotal;
|
|
62
|
-
const totalItems = Number(this.getAttribute('total-items') || 0);
|
|
63
|
-
const pageSize = Number(this.getAttribute('page-size') || 10);
|
|
64
|
-
const currentPage = this.currentPage;
|
|
65
|
-
const totalPages = this.totalPages;
|
|
66
|
-
const isFirstPage = currentPage <= 1;
|
|
67
|
-
const isLastPage = currentPage >= totalPages;
|
|
68
|
-
this.className = [
|
|
69
|
-
'designbase-wc-pagination',
|
|
70
|
-
`designbase-wc-pagination--${size}`,
|
|
71
|
-
`designbase-wc-pagination--${variant}`,
|
|
72
|
-
`designbase-wc-pagination--${alignment}`,
|
|
73
|
-
disabled && 'designbase-wc-pagination--disabled',
|
|
74
|
-
fullWidth && 'designbase-wc-pagination--full-width',
|
|
75
|
-
]
|
|
76
|
-
.filter(Boolean)
|
|
77
|
-
.join(' ');
|
|
78
|
-
this.setAttribute('role', 'navigation');
|
|
79
|
-
this.setAttribute('aria-label', '페이지 네비게이션');
|
|
80
|
-
this.replaceChildren();
|
|
81
|
-
const container = document.createElement('div');
|
|
82
|
-
container.className = [
|
|
83
|
-
'designbase-wc-pagination__container',
|
|
84
|
-
fullWidth && 'designbase-wc-pagination__container--full-width',
|
|
85
|
-
]
|
|
86
|
-
.filter(Boolean)
|
|
87
|
-
.join(' ');
|
|
88
|
-
if (showTotal && totalItems > 0) {
|
|
89
|
-
const totalEl = document.createElement('div');
|
|
90
|
-
totalEl.className = 'designbase-wc-pagination__total';
|
|
91
|
-
totalEl.textContent = this.getTotalLabel(totalItems, pageSize, currentPage);
|
|
92
|
-
container.append(totalEl);
|
|
93
|
-
}
|
|
94
|
-
const nav = document.createElement('nav');
|
|
95
|
-
nav.className = 'designbase-wc-pagination__nav';
|
|
96
|
-
nav.setAttribute('aria-label', '페이지 네비게이션');
|
|
97
|
-
const list = document.createElement('ul');
|
|
98
|
-
list.className = 'designbase-wc-pagination__list';
|
|
99
|
-
if (showFirstLast && !isFirstPage) {
|
|
100
|
-
list.append(this.createIconButton('arrow-bar-left', 1, '첫 페이지로 이동', 'first'));
|
|
101
|
-
}
|
|
102
|
-
if (showPreviousNext && !isFirstPage) {
|
|
103
|
-
list.append(this.createIconButton('chevron-left', currentPage - 1, '이전 페이지로 이동', 'previous'));
|
|
104
|
-
}
|
|
105
|
-
this.getPageNumbers().forEach((page, index) => {
|
|
106
|
-
if (page === '...') {
|
|
107
|
-
const item = document.createElement('li');
|
|
108
|
-
item.className = 'designbase-wc-pagination__ellipsis';
|
|
109
|
-
const text = document.createElement('span');
|
|
110
|
-
text.className = 'designbase-wc-pagination__ellipsis-text';
|
|
111
|
-
text.textContent = '...';
|
|
112
|
-
item.append(text);
|
|
113
|
-
list.append(item);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
if (typeof page !== 'number')
|
|
117
|
-
return;
|
|
118
|
-
list.append(this.createPageButton(page, disabled));
|
|
119
|
-
});
|
|
120
|
-
if (showPreviousNext && !isLastPage) {
|
|
121
|
-
list.append(this.createIconButton('chevron-right', currentPage + 1, '다음 페이지로 이동', 'next'));
|
|
122
|
-
}
|
|
123
|
-
if (showFirstLast && !isLastPage) {
|
|
124
|
-
list.append(this.createIconButton('arrow-bar-right', totalPages, '마지막 페이지로 이동', 'last'));
|
|
125
|
-
}
|
|
126
|
-
nav.append(list);
|
|
127
|
-
container.append(nav);
|
|
128
|
-
if (showPageSizeSelector) {
|
|
129
|
-
container.append(this.createPageSizeSelector(size, pageSize, disabled));
|
|
130
|
-
}
|
|
131
|
-
this.append(container);
|
|
132
|
-
}
|
|
133
|
-
getPageSizeOptions() {
|
|
134
|
-
const raw = this.getAttribute('page-size-options');
|
|
135
|
-
if (!raw)
|
|
136
|
-
return [10, 20, 50, 100];
|
|
137
|
-
try {
|
|
138
|
-
const parsed = JSON.parse(raw);
|
|
139
|
-
if (Array.isArray(parsed)) {
|
|
140
|
-
return parsed.map((value) => Number(value)).filter((value) => !Number.isNaN(value));
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
catch {
|
|
144
|
-
// ignore invalid JSON
|
|
145
|
-
}
|
|
146
|
-
return [10, 20, 50, 100];
|
|
147
|
-
}
|
|
148
|
-
getTotalLabel(totalItems, pageSize, currentPage) {
|
|
149
|
-
const start = (currentPage - 1) * pageSize + 1;
|
|
150
|
-
const end = Math.min(currentPage * pageSize, totalItems);
|
|
151
|
-
return `${start}-${end} / ${totalItems}개`;
|
|
152
|
-
}
|
|
153
|
-
createPageSizeSelector(size, pageSize, disabled) {
|
|
154
|
-
const wrapper = document.createElement('div');
|
|
155
|
-
wrapper.className = 'designbase-wc-pagination__page-size';
|
|
156
|
-
const label = document.createElement('label');
|
|
157
|
-
label.className = 'designbase-wc-pagination__page-size-label';
|
|
158
|
-
const text = document.createElement('span');
|
|
159
|
-
text.className = 'designbase-wc-pagination__page-size-text';
|
|
160
|
-
text.textContent = '페이지당';
|
|
161
|
-
const select = document.createElement('db-select');
|
|
162
|
-
select.className = 'designbase-wc-pagination__page-size-select';
|
|
163
|
-
select.setAttribute('size', size);
|
|
164
|
-
select.setAttribute('show-clear-button', 'false');
|
|
165
|
-
select.setAttribute('searchable', 'false');
|
|
166
|
-
select.setAttribute('options', JSON.stringify(this.getPageSizeOptions().map((option) => ({
|
|
167
|
-
value: String(option),
|
|
168
|
-
label: String(option),
|
|
169
|
-
}))));
|
|
170
|
-
select.setAttribute('value', String(pageSize));
|
|
171
|
-
if (disabled)
|
|
172
|
-
select.setAttribute('disabled', '');
|
|
173
|
-
select.addEventListener('db-change', (event) => {
|
|
174
|
-
const detail = event.detail;
|
|
175
|
-
const nextSize = Number(detail?.value);
|
|
176
|
-
if (Number.isNaN(nextSize) || nextSize === pageSize)
|
|
177
|
-
return;
|
|
178
|
-
this.setAttribute('page-size', String(nextSize));
|
|
179
|
-
this.dispatchEvent(new CustomEvent('db-page-size-change', {
|
|
180
|
-
detail: { pageSize: nextSize },
|
|
181
|
-
bubbles: true,
|
|
182
|
-
composed: true,
|
|
183
|
-
}));
|
|
184
|
-
});
|
|
185
|
-
label.append(text, select);
|
|
186
|
-
wrapper.append(label);
|
|
187
|
-
return wrapper;
|
|
188
|
-
}
|
|
189
|
-
getPageNumbers() {
|
|
190
|
-
const siblingCount = Number(this.getAttribute('sibling-count') || 1);
|
|
191
|
-
const boundaryCount = Number(this.getAttribute('boundary-count') || 1);
|
|
192
|
-
const totalPages = this.totalPages;
|
|
193
|
-
const currentPage = this.currentPage;
|
|
194
|
-
const totalNumbers = siblingCount * 2 + 3;
|
|
195
|
-
const totalBlocks = totalNumbers + 2;
|
|
196
|
-
if (totalPages <= totalBlocks) {
|
|
197
|
-
return Array.from({ length: totalPages }, (_, index) => index + 1);
|
|
198
|
-
}
|
|
199
|
-
const leftSiblingIndex = Math.max(currentPage - siblingCount, boundaryCount);
|
|
200
|
-
const rightSiblingIndex = Math.min(currentPage + siblingCount, totalPages - boundaryCount + 1);
|
|
201
|
-
const shouldShowLeftDots = leftSiblingIndex > boundaryCount + 2;
|
|
202
|
-
const shouldShowRightDots = rightSiblingIndex < totalPages - boundaryCount - 1;
|
|
203
|
-
if (!shouldShowLeftDots && shouldShowRightDots) {
|
|
204
|
-
const leftItemCount = 3 + 2 * siblingCount;
|
|
205
|
-
return [...Array.from({ length: leftItemCount }, (_, index) => index + 1), '...', totalPages];
|
|
206
|
-
}
|
|
207
|
-
if (shouldShowLeftDots && !shouldShowRightDots) {
|
|
208
|
-
const rightItemCount = 3 + 2 * siblingCount;
|
|
209
|
-
return [
|
|
210
|
-
1,
|
|
211
|
-
'...',
|
|
212
|
-
...Array.from({ length: rightItemCount }, (_, index) => totalPages - rightItemCount + index + 1),
|
|
213
|
-
];
|
|
214
|
-
}
|
|
215
|
-
if (shouldShowLeftDots && shouldShowRightDots) {
|
|
216
|
-
const middleRange = Array.from({ length: rightSiblingIndex - leftSiblingIndex + 1 }, (_, index) => leftSiblingIndex + index);
|
|
217
|
-
return [1, '...', ...middleRange, '...', totalPages];
|
|
218
|
-
}
|
|
219
|
-
return Array.from({ length: totalPages }, (_, index) => index + 1);
|
|
220
|
-
}
|
|
221
|
-
createPageButton(page, disabled) {
|
|
222
|
-
const isActive = page === this.currentPage;
|
|
223
|
-
const item = document.createElement('li');
|
|
224
|
-
item.className = 'designbase-wc-pagination__item';
|
|
225
|
-
const button = document.createElement('button');
|
|
226
|
-
button.type = 'button';
|
|
227
|
-
button.className = [
|
|
228
|
-
'designbase-wc-pagination__button',
|
|
229
|
-
isActive && 'designbase-wc-pagination__button--active',
|
|
230
|
-
]
|
|
231
|
-
.filter(Boolean)
|
|
232
|
-
.join(' ');
|
|
233
|
-
button.textContent = String(page);
|
|
234
|
-
button.disabled = disabled;
|
|
235
|
-
if (isActive)
|
|
236
|
-
button.setAttribute('aria-current', 'page');
|
|
237
|
-
button.setAttribute('aria-label', `페이지 ${page}로 이동`);
|
|
238
|
-
button.addEventListener('click', () => this.select(page));
|
|
239
|
-
item.append(button);
|
|
240
|
-
return item;
|
|
241
|
-
}
|
|
242
|
-
createIconButton(iconName, page, label, modifier) {
|
|
243
|
-
const item = document.createElement('li');
|
|
244
|
-
item.className = 'designbase-wc-pagination__item';
|
|
245
|
-
const button = document.createElement('button');
|
|
246
|
-
button.type = 'button';
|
|
247
|
-
button.className = `designbase-wc-pagination__button designbase-wc-pagination__button--${modifier}`;
|
|
248
|
-
button.disabled = this.hasAttribute('disabled');
|
|
249
|
-
button.setAttribute('aria-label', label);
|
|
250
|
-
button.append(createDbIcon(iconName, this.iconSize()));
|
|
251
|
-
button.addEventListener('click', () => this.select(page));
|
|
252
|
-
item.append(button);
|
|
253
|
-
return item;
|
|
254
|
-
}
|
|
255
|
-
select(page) {
|
|
256
|
-
if (this.hasAttribute('disabled') || page === this.currentPage || page < 1 || page > this.totalPages) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
this.currentPage = page;
|
|
260
|
-
this.dispatchEvent(new CustomEvent('db-change', {
|
|
261
|
-
detail: { page },
|
|
262
|
-
bubbles: true,
|
|
263
|
-
composed: true,
|
|
264
|
-
}));
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (!customElements.get('db-pagination')) {
|
|
268
|
-
customElements.define('db-pagination', DbPagination);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export { DbPagination };
|
|
1
|
+
import{createDbIcon as t}from"./db-icons.js";class DbPagination extends HTMLElement{static get observedAttributes(){return["current-page","total-pages","total-items","page-size","page-size-options","size","variant","alignment","show-first-last","show-previous-next","show-page-size-selector","show-total","sibling-count","boundary-count","disabled","full-width"]}get currentPage(){return Number(this.getAttribute("current-page")||1)}set currentPage(t){this.setAttribute("current-page",String(t))}get totalPages(){return Number(this.getAttribute("total-pages")||1)}set totalPages(t){this.setAttribute("total-pages",String(t))}connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}iconSize(){const t=this.getAttribute("size")||"m";return"s"===t?12:"l"===t?16:14}render(){const t=this.getAttribute("size")||"m",e=this.getAttribute("variant")||"default",a=this.getAttribute("alignment")||"center",i=this.hasAttribute("disabled"),n=this.hasAttribute("show-first-last"),s="false"!==this.getAttribute("show-previous-next"),r=this.hasAttribute("show-page-size-selector"),o=this.hasAttribute("show-total"),c=this.hasAttribute("full-width")||r||o,l=Number(this.getAttribute("total-items")||0),g=Number(this.getAttribute("page-size")||10),u=this.currentPage,b=this.totalPages,d=u<=1,p=u>=b;this.className=["designbase-wc-pagination",`designbase-wc-pagination--${t}`,`designbase-wc-pagination--${e}`,`designbase-wc-pagination--${a}`,i&&"designbase-wc-pagination--disabled",c&&"designbase-wc-pagination--full-width"].filter(Boolean).join(" "),this.setAttribute("role","navigation"),this.setAttribute("aria-label","페이지 네비게이션"),this.replaceChildren();const h=document.createElement("div");if(h.className=["designbase-wc-pagination__container",c&&"designbase-wc-pagination__container--full-width"].filter(Boolean).join(" "),o&&l>0){const t=document.createElement("div");t.className="designbase-wc-pagination__total",t.textContent=this.getTotalLabel(l,g,u),h.append(t)}const m=document.createElement("nav");m.className="designbase-wc-pagination__nav",m.setAttribute("aria-label","페이지 네비게이션");const A=document.createElement("ul");A.className="designbase-wc-pagination__list",n&&!d&&A.append(this.createIconButton("arrow-bar-left",1,"첫 페이지로 이동","first")),s&&!d&&A.append(this.createIconButton("chevron-left",u-1,"이전 페이지로 이동","previous")),this.getPageNumbers().forEach((t,e)=>{if("..."===t){const t=document.createElement("li");t.className="designbase-wc-pagination__ellipsis";const e=document.createElement("span");return e.className="designbase-wc-pagination__ellipsis-text",e.textContent="...",t.append(e),void A.append(t)}"number"==typeof t&&A.append(this.createPageButton(t,i))}),s&&!p&&A.append(this.createIconButton("chevron-right",u+1,"다음 페이지로 이동","next")),n&&!p&&A.append(this.createIconButton("arrow-bar-right",b,"마지막 페이지로 이동","last")),m.append(A),h.append(m),r&&h.append(this.createPageSizeSelector(t,g,i)),this.append(h)}getPageSizeOptions(){const t=this.getAttribute("page-size-options");if(!t)return[10,20,50,100];try{const e=JSON.parse(t);if(Array.isArray(e))return e.map(t=>Number(t)).filter(t=>!Number.isNaN(t))}catch{}return[10,20,50,100]}getTotalLabel(t,e,a){return`${(a-1)*e+1}-${Math.min(a*e,t)} / ${t}개`}createPageSizeSelector(t,e,a){const i=document.createElement("div");i.className="designbase-wc-pagination__page-size";const n=document.createElement("label");n.className="designbase-wc-pagination__page-size-label";const s=document.createElement("span");s.className="designbase-wc-pagination__page-size-text",s.textContent="페이지당";const r=document.createElement("db-select");return r.className="designbase-wc-pagination__page-size-select",r.setAttribute("size",t),r.setAttribute("show-clear-button","false"),r.setAttribute("searchable","false"),r.setAttribute("options",JSON.stringify(this.getPageSizeOptions().map(t=>({value:String(t),label:String(t)})))),r.setAttribute("value",String(e)),a&&r.setAttribute("disabled",""),r.addEventListener("db-change",t=>{const a=t.detail,i=Number(a?.value);Number.isNaN(i)||i===e||(this.setAttribute("page-size",String(i)),this.dispatchEvent(new CustomEvent("db-page-size-change",{detail:{pageSize:i},bubbles:!0,composed:!0})))}),n.append(s,r),i.append(n),i}getPageNumbers(){const t=Number(this.getAttribute("sibling-count")||1),e=Number(this.getAttribute("boundary-count")||1),a=this.totalPages,i=this.currentPage;if(a<=2*t+3+2)return Array.from({length:a},(t,e)=>e+1);const n=Math.max(i-t,e),s=Math.min(i+t,a-e+1),r=n>e+2,o=s<a-e-1;if(!r&&o){const e=3+2*t;return[...Array.from({length:e},(t,e)=>e+1),"...",a]}if(r&&!o){const e=3+2*t;return[1,"...",...Array.from({length:e},(t,i)=>a-e+i+1)]}if(r&&o){return[1,"...",...Array.from({length:s-n+1},(t,e)=>n+e),"...",a]}return Array.from({length:a},(t,e)=>e+1)}createPageButton(t,e){const a=t===this.currentPage,i=document.createElement("li");i.className="designbase-wc-pagination__item";const n=document.createElement("button");return n.type="button",n.className=["designbase-wc-pagination__button",a&&"designbase-wc-pagination__button--active"].filter(Boolean).join(" "),n.textContent=String(t),n.disabled=e,a&&n.setAttribute("aria-current","page"),n.setAttribute("aria-label",`페이지 ${t}로 이동`),n.addEventListener("click",()=>this.select(t)),i.append(n),i}createIconButton(e,a,i,n){const s=document.createElement("li");s.className="designbase-wc-pagination__item";const r=document.createElement("button");return r.type="button",r.className=`designbase-wc-pagination__button designbase-wc-pagination__button--${n}`,r.disabled=this.hasAttribute("disabled"),r.setAttribute("aria-label",i),r.append(t(e,this.iconSize())),r.addEventListener("click",()=>this.select(a)),s.append(r),s}select(t){this.hasAttribute("disabled")||t===this.currentPage||t<1||t>this.totalPages||(this.currentPage=t,this.dispatchEvent(new CustomEvent("db-change",{detail:{page:t},bubbles:!0,composed:!0})))}}customElements.get("db-pagination")||customElements.define("db-pagination",DbPagination);export{DbPagination};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import './db-button.js';
|
|
2
|
+
import './db-input.js';
|
|
3
|
+
import './db-otp-input.js';
|
|
4
|
+
import './db-select.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ui-wc — db-phone-verify (수동 작성, 자동 동기화 대상 아님)
|
|
8
|
+
*
|
|
9
|
+
* 한국형 휴대폰 본인인증: 통신사 → 번호 → 인증번호 발송 → OTP + 타이머/재전송.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare const SIZES: readonly ["s", "m", "l"];
|
|
13
|
+
type Size = (typeof SIZES)[number];
|
|
14
|
+
declare class DbPhoneVerify extends HTMLElement {
|
|
15
|
+
static get observedAttributes(): string[];
|
|
16
|
+
private built;
|
|
17
|
+
private timerId;
|
|
18
|
+
private remaining;
|
|
19
|
+
private carrierSelect;
|
|
20
|
+
private phoneInput;
|
|
21
|
+
private sendBtn;
|
|
22
|
+
private otpInput;
|
|
23
|
+
private timerEl;
|
|
24
|
+
private resendBtn;
|
|
25
|
+
private verifyBtn;
|
|
26
|
+
private codeBlock;
|
|
27
|
+
private errorEl;
|
|
28
|
+
get size(): Size;
|
|
29
|
+
set size(v: Size);
|
|
30
|
+
get step(): 'phone' | 'code' | 'verified';
|
|
31
|
+
set step(v: 'phone' | 'code' | 'verified');
|
|
32
|
+
get phone(): string;
|
|
33
|
+
set phone(v: string);
|
|
34
|
+
get carrier(): string;
|
|
35
|
+
set carrier(v: string);
|
|
36
|
+
get code(): string;
|
|
37
|
+
set code(v: string);
|
|
38
|
+
get countdown(): number;
|
|
39
|
+
set countdown(v: number);
|
|
40
|
+
connectedCallback(): void;
|
|
41
|
+
disconnectedCallback(): void;
|
|
42
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
43
|
+
/** 인증번호 발송 단계로 전환하고 타이머를 시작합니다. */
|
|
44
|
+
startCodeStep(): void;
|
|
45
|
+
/** 수동 제어 모드에서 재전송 성공 후 카운트다운을 다시 시작합니다. */
|
|
46
|
+
restartCountdown(): void;
|
|
47
|
+
/** 인증 완료 상태로 전환합니다. */
|
|
48
|
+
markVerified(): void;
|
|
49
|
+
private clearTimer;
|
|
50
|
+
private startTimer;
|
|
51
|
+
private renderTimer;
|
|
52
|
+
private build;
|
|
53
|
+
private sync;
|
|
54
|
+
private isPhoneValid;
|
|
55
|
+
private requestVerify;
|
|
56
|
+
}
|
|
57
|
+
declare global {
|
|
58
|
+
interface HTMLElementTagNameMap {
|
|
59
|
+
'db-phone-verify': DbPhoneVerify;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { DbPhoneVerify };
|