@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,266 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const SIZES = ['s', 'm', 'l'];
|
|
4
|
-
const VARIANTS = ['default', 'outlined', 'filled'];
|
|
5
|
-
class DbDropzone extends HTMLElement {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.internalDragOver = false;
|
|
9
|
-
this.handleFileInputChange = () => {
|
|
10
|
-
this.emitFiles(this.fileInput?.files ?? null);
|
|
11
|
-
if (this.fileInput)
|
|
12
|
-
this.fileInput.value = '';
|
|
13
|
-
};
|
|
14
|
-
this.handleDragOver = (event) => {
|
|
15
|
-
event.preventDefault();
|
|
16
|
-
event.stopPropagation();
|
|
17
|
-
if (this.isDisabled())
|
|
18
|
-
return;
|
|
19
|
-
this.internalDragOver = true;
|
|
20
|
-
this.syncClasses();
|
|
21
|
-
this.dispatchEvent(new CustomEvent('db-drag-over', { bubbles: true, composed: true, detail: { event } }));
|
|
22
|
-
};
|
|
23
|
-
this.handleDragLeave = (event) => {
|
|
24
|
-
event.preventDefault();
|
|
25
|
-
event.stopPropagation();
|
|
26
|
-
if (this.isDisabled())
|
|
27
|
-
return;
|
|
28
|
-
this.internalDragOver = false;
|
|
29
|
-
this.syncClasses();
|
|
30
|
-
this.dispatchEvent(new CustomEvent('db-drag-leave', { bubbles: true, composed: true, detail: { event } }));
|
|
31
|
-
};
|
|
32
|
-
this.handleDrop = (event) => {
|
|
33
|
-
event.preventDefault();
|
|
34
|
-
event.stopPropagation();
|
|
35
|
-
if (this.isDisabled())
|
|
36
|
-
return;
|
|
37
|
-
this.internalDragOver = false;
|
|
38
|
-
this.syncClasses();
|
|
39
|
-
this.emitFiles(event.dataTransfer?.files ?? null);
|
|
40
|
-
this.dispatchEvent(new CustomEvent('db-drop', { bubbles: true, composed: true, detail: { event } }));
|
|
41
|
-
};
|
|
42
|
-
this.handleClick = (event) => {
|
|
43
|
-
if (this.isDisabled())
|
|
44
|
-
return;
|
|
45
|
-
if (event.target.closest('.designbase-wc-dropzone__button'))
|
|
46
|
-
return;
|
|
47
|
-
this.fileInput?.click();
|
|
48
|
-
this.dispatchEvent(new CustomEvent('db-click', { bubbles: true, composed: true, detail: { event } }));
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
static get observedAttributes() {
|
|
52
|
-
return [
|
|
53
|
-
'size',
|
|
54
|
-
'variant',
|
|
55
|
-
'show-icon',
|
|
56
|
-
'icon',
|
|
57
|
-
'image',
|
|
58
|
-
'title',
|
|
59
|
-
'description',
|
|
60
|
-
'button-text',
|
|
61
|
-
'show-button',
|
|
62
|
-
'accept',
|
|
63
|
-
'max-size',
|
|
64
|
-
'multiple',
|
|
65
|
-
'drag-over',
|
|
66
|
-
'disabled',
|
|
67
|
-
'readonly',
|
|
68
|
-
];
|
|
69
|
-
}
|
|
70
|
-
connectedCallback() {
|
|
71
|
-
this.ensureInput();
|
|
72
|
-
this.sync();
|
|
73
|
-
this.addEventListener('dragover', this.handleDragOver);
|
|
74
|
-
this.addEventListener('dragleave', this.handleDragLeave);
|
|
75
|
-
this.addEventListener('drop', this.handleDrop);
|
|
76
|
-
this.addEventListener('click', this.handleClick);
|
|
77
|
-
}
|
|
78
|
-
disconnectedCallback() {
|
|
79
|
-
this.removeEventListener('dragover', this.handleDragOver);
|
|
80
|
-
this.removeEventListener('dragleave', this.handleDragLeave);
|
|
81
|
-
this.removeEventListener('drop', this.handleDrop);
|
|
82
|
-
this.removeEventListener('click', this.handleClick);
|
|
83
|
-
}
|
|
84
|
-
attributeChangedCallback() {
|
|
85
|
-
if (this.isConnected)
|
|
86
|
-
this.sync();
|
|
87
|
-
}
|
|
88
|
-
ensureInput() {
|
|
89
|
-
if (this.fileInput)
|
|
90
|
-
return;
|
|
91
|
-
this.fileInput = document.createElement('input');
|
|
92
|
-
this.fileInput.type = 'file';
|
|
93
|
-
this.fileInput.style.display = 'none';
|
|
94
|
-
this.fileInput.setAttribute('data-wc-internal', '');
|
|
95
|
-
this.fileInput.addEventListener('change', this.handleFileInputChange);
|
|
96
|
-
this.append(this.fileInput);
|
|
97
|
-
}
|
|
98
|
-
isDisabled() {
|
|
99
|
-
return this.hasAttribute('disabled') || this.hasAttribute('readonly');
|
|
100
|
-
}
|
|
101
|
-
isDragOver() {
|
|
102
|
-
if (this.hasAttribute('drag-over')) {
|
|
103
|
-
return this.getAttribute('drag-over') !== 'false';
|
|
104
|
-
}
|
|
105
|
-
return this.internalDragOver;
|
|
106
|
-
}
|
|
107
|
-
validateFile(file) {
|
|
108
|
-
const accept = this.getAttribute('accept');
|
|
109
|
-
if (accept) {
|
|
110
|
-
const acceptedTypes = accept.split(',').map((type) => type.trim());
|
|
111
|
-
const fileType = file.type;
|
|
112
|
-
const fileExtension = `.${file.name.split('.').pop()?.toLowerCase()}`;
|
|
113
|
-
const isValidType = acceptedTypes.some((type) => {
|
|
114
|
-
if (type.startsWith('.'))
|
|
115
|
-
return fileExtension === type.toLowerCase();
|
|
116
|
-
return fileType === type || fileType.startsWith(type.replace('*', ''));
|
|
117
|
-
});
|
|
118
|
-
if (!isValidType)
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
const maxSize = Number(this.getAttribute('max-size') || 0);
|
|
122
|
-
if (maxSize > 0 && file.size > maxSize)
|
|
123
|
-
return false;
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
emitFiles(files) {
|
|
127
|
-
if (!files || files.length === 0)
|
|
128
|
-
return;
|
|
129
|
-
const validFiles = Array.from(files).filter((file) => this.validateFile(file));
|
|
130
|
-
if (!validFiles.length)
|
|
131
|
-
return;
|
|
132
|
-
this.dispatchEvent(new CustomEvent('db-file-select', {
|
|
133
|
-
bubbles: true,
|
|
134
|
-
composed: true,
|
|
135
|
-
detail: { files: validFiles },
|
|
136
|
-
}));
|
|
137
|
-
}
|
|
138
|
-
getDescriptionText() {
|
|
139
|
-
const description = this.getAttribute('description');
|
|
140
|
-
if (description)
|
|
141
|
-
return description;
|
|
142
|
-
const accept = this.getAttribute('accept');
|
|
143
|
-
if (!accept)
|
|
144
|
-
return '모든 파일 형식 지원';
|
|
145
|
-
const types = accept.split(',').map((type) => {
|
|
146
|
-
const trimmed = type.trim();
|
|
147
|
-
if (trimmed.startsWith('.'))
|
|
148
|
-
return trimmed.toUpperCase();
|
|
149
|
-
if (trimmed.includes('*'))
|
|
150
|
-
return trimmed.replace('*', '').toUpperCase();
|
|
151
|
-
return trimmed;
|
|
152
|
-
});
|
|
153
|
-
let desc = types.join(', ');
|
|
154
|
-
const maxSize = Number(this.getAttribute('max-size') || 0);
|
|
155
|
-
if (maxSize > 0) {
|
|
156
|
-
const k = 1024;
|
|
157
|
-
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
158
|
-
const i = Math.floor(Math.log(maxSize) / Math.log(k));
|
|
159
|
-
const sizeText = `${parseFloat((maxSize / k ** i).toFixed(2))} ${sizes[i]}`;
|
|
160
|
-
desc += ` (최대 ${sizeText})`;
|
|
161
|
-
}
|
|
162
|
-
return desc;
|
|
163
|
-
}
|
|
164
|
-
collectChildren() {
|
|
165
|
-
return Array.from(this.children).filter((child) => child !== this.fileInput && !child.hasAttribute('data-wc-internal'));
|
|
166
|
-
}
|
|
167
|
-
syncClasses() {
|
|
168
|
-
const size = this.getAttribute('size') || 'm';
|
|
169
|
-
const variant = this.getAttribute('variant') || 'default';
|
|
170
|
-
const safeSize = SIZES.includes(size) ? size : 'm';
|
|
171
|
-
const safeVariant = VARIANTS.includes(variant) ? variant : 'default';
|
|
172
|
-
this.className = [
|
|
173
|
-
'designbase-wc-dropzone',
|
|
174
|
-
`designbase-wc-dropzone--size-${safeSize}`,
|
|
175
|
-
`designbase-wc-dropzone--variant-${safeVariant}`,
|
|
176
|
-
this.isDragOver() && 'designbase-wc-dropzone--drag-over',
|
|
177
|
-
this.hasAttribute('disabled') && 'designbase-wc-dropzone--disabled',
|
|
178
|
-
this.hasAttribute('readonly') && 'designbase-wc-dropzone--readonly',
|
|
179
|
-
]
|
|
180
|
-
.filter(Boolean)
|
|
181
|
-
.join(' ');
|
|
182
|
-
}
|
|
183
|
-
sync() {
|
|
184
|
-
this.ensureInput();
|
|
185
|
-
this.syncClasses();
|
|
186
|
-
const accept = this.getAttribute('accept');
|
|
187
|
-
const multiple = this.hasAttribute('multiple');
|
|
188
|
-
if (this.fileInput) {
|
|
189
|
-
if (accept)
|
|
190
|
-
this.fileInput.setAttribute('accept', accept);
|
|
191
|
-
else
|
|
192
|
-
this.fileInput.removeAttribute('accept');
|
|
193
|
-
this.fileInput.toggleAttribute('multiple', multiple);
|
|
194
|
-
this.fileInput.disabled = this.isDisabled();
|
|
195
|
-
}
|
|
196
|
-
const userChildren = this.collectChildren();
|
|
197
|
-
const defaultContent = this.querySelector(':scope > .designbase-wc-dropzone__content[data-wc-internal]');
|
|
198
|
-
if (userChildren.length) {
|
|
199
|
-
defaultContent?.remove();
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
let content = defaultContent;
|
|
203
|
-
if (!content) {
|
|
204
|
-
content = document.createElement('div');
|
|
205
|
-
content.className = 'designbase-wc-dropzone__content';
|
|
206
|
-
content.setAttribute('data-wc-internal', '');
|
|
207
|
-
this.append(content);
|
|
208
|
-
}
|
|
209
|
-
content.replaceChildren();
|
|
210
|
-
const size = this.getAttribute('size') || 'm';
|
|
211
|
-
const safeSize = SIZES.includes(size) ? size : 'm';
|
|
212
|
-
const image = this.getAttribute('image');
|
|
213
|
-
const showIcon = this.getAttribute('show-icon') !== 'false';
|
|
214
|
-
const iconName = this.getAttribute('icon') || 'gallery';
|
|
215
|
-
const title = this.getAttribute('title') || '파일을 드래그하여 업로드하거나 클릭하여 선택하세요';
|
|
216
|
-
const description = this.getDescriptionText();
|
|
217
|
-
const showButton = this.hasAttribute('show-button');
|
|
218
|
-
const buttonText = this.getAttribute('button-text') || '파일 선택';
|
|
219
|
-
if (image) {
|
|
220
|
-
const imageWrap = document.createElement('div');
|
|
221
|
-
imageWrap.className = 'designbase-wc-dropzone__image';
|
|
222
|
-
const img = document.createElement('img');
|
|
223
|
-
img.src = image;
|
|
224
|
-
img.alt = 'Upload illustration';
|
|
225
|
-
imageWrap.append(img);
|
|
226
|
-
content.append(imageWrap);
|
|
227
|
-
}
|
|
228
|
-
else if (showIcon) {
|
|
229
|
-
const iconWrap = document.createElement('div');
|
|
230
|
-
iconWrap.className = 'designbase-wc-dropzone__icon';
|
|
231
|
-
const iconSize = safeSize === 's' ? 32 : safeSize === 'l' ? 56 : 48;
|
|
232
|
-
iconWrap.append(createDbIcon(iconName, iconSize));
|
|
233
|
-
content.append(iconWrap);
|
|
234
|
-
}
|
|
235
|
-
if (title) {
|
|
236
|
-
const titleEl = document.createElement('div');
|
|
237
|
-
titleEl.className = 'designbase-wc-dropzone__title';
|
|
238
|
-
titleEl.textContent = title;
|
|
239
|
-
content.append(titleEl);
|
|
240
|
-
}
|
|
241
|
-
if (description) {
|
|
242
|
-
const descriptionEl = document.createElement('div');
|
|
243
|
-
descriptionEl.className = 'designbase-wc-dropzone__description';
|
|
244
|
-
descriptionEl.textContent = description;
|
|
245
|
-
content.append(descriptionEl);
|
|
246
|
-
}
|
|
247
|
-
if (showButton) {
|
|
248
|
-
const button = document.createElement('button');
|
|
249
|
-
button.type = 'button';
|
|
250
|
-
button.className = 'designbase-wc-dropzone__button';
|
|
251
|
-
button.textContent = buttonText;
|
|
252
|
-
button.disabled = this.isDisabled();
|
|
253
|
-
button.addEventListener('click', (event) => {
|
|
254
|
-
event.stopPropagation();
|
|
255
|
-
if (!this.isDisabled())
|
|
256
|
-
this.fileInput?.click();
|
|
257
|
-
});
|
|
258
|
-
content.append(button);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
if (!customElements.get('db-dropzone')) {
|
|
263
|
-
customElements.define('db-dropzone', DbDropzone);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export { DbDropzone };
|
|
1
|
+
import{createDbIcon as e}from"./db-icons.js";const t=["s","m","l"],i=["default","outlined","filled"];class DbDropzone extends HTMLElement{constructor(){super(...arguments),this.internalDragOver=!1,this.handleFileInputChange=()=>{this.emitFiles(this.fileInput?.files??null),this.fileInput&&(this.fileInput.value="")},this.handleDragOver=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||(this.internalDragOver=!0,this.syncClasses(),this.dispatchEvent(new CustomEvent("db-drag-over",{bubbles:!0,composed:!0,detail:{event:e}})))},this.handleDragLeave=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||(this.internalDragOver=!1,this.syncClasses(),this.dispatchEvent(new CustomEvent("db-drag-leave",{bubbles:!0,composed:!0,detail:{event:e}})))},this.handleDrop=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||(this.internalDragOver=!1,this.syncClasses(),this.emitFiles(e.dataTransfer?.files??null),this.dispatchEvent(new CustomEvent("db-drop",{bubbles:!0,composed:!0,detail:{event:e}})))},this.handleClick=e=>{this.isDisabled()||e.target.closest(".designbase-wc-dropzone__button")||(this.fileInput?.click(),this.dispatchEvent(new CustomEvent("db-click",{bubbles:!0,composed:!0,detail:{event:e}})))}}static get observedAttributes(){return["size","variant","show-icon","icon","image","title","description","button-text","show-button","accept","max-size","multiple","drag-over","disabled","readonly"]}connectedCallback(){this.ensureInput(),this.sync(),this.addEventListener("dragover",this.handleDragOver),this.addEventListener("dragleave",this.handleDragLeave),this.addEventListener("drop",this.handleDrop),this.addEventListener("click",this.handleClick)}disconnectedCallback(){this.removeEventListener("dragover",this.handleDragOver),this.removeEventListener("dragleave",this.handleDragLeave),this.removeEventListener("drop",this.handleDrop),this.removeEventListener("click",this.handleClick)}attributeChangedCallback(){this.isConnected&&this.sync()}ensureInput(){this.fileInput||(this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.style.display="none",this.fileInput.setAttribute("data-wc-internal",""),this.fileInput.addEventListener("change",this.handleFileInputChange),this.append(this.fileInput))}isDisabled(){return this.hasAttribute("disabled")||this.hasAttribute("readonly")}isDragOver(){return this.hasAttribute("drag-over")?"false"!==this.getAttribute("drag-over"):this.internalDragOver}validateFile(e){const t=this.getAttribute("accept");if(t){const i=t.split(",").map(e=>e.trim()),s=e.type,n=`.${e.name.split(".").pop()?.toLowerCase()}`;if(!i.some(e=>e.startsWith(".")?n===e.toLowerCase():s===e||s.startsWith(e.replace("*",""))))return!1}const i=Number(this.getAttribute("max-size")||0);return!(i>0&&e.size>i)}emitFiles(e){if(!e||0===e.length)return;const t=Array.from(e).filter(e=>this.validateFile(e));t.length&&this.dispatchEvent(new CustomEvent("db-file-select",{bubbles:!0,composed:!0,detail:{files:t}}))}getDescriptionText(){const e=this.getAttribute("description");if(e)return e;const t=this.getAttribute("accept");if(!t)return"모든 파일 형식 지원";let i=t.split(",").map(e=>{const t=e.trim();return t.startsWith(".")?t.toUpperCase():t.includes("*")?t.replace("*","").toUpperCase():t}).join(", ");const s=Number(this.getAttribute("max-size")||0);if(s>0){const e=1024,t=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(s)/Math.log(e));i+=` (최대 ${`${parseFloat((s/e**n).toFixed(2))} ${t[n]}`})`}return i}collectChildren(){return Array.from(this.children).filter(e=>e!==this.fileInput&&!e.hasAttribute("data-wc-internal"))}syncClasses(){const e=this.getAttribute("size")||"m",s=this.getAttribute("variant")||"default",n=t.includes(e)?e:"m",a=i.includes(s)?s:"default";this.className=["designbase-wc-dropzone",`designbase-wc-dropzone--size-${n}`,`designbase-wc-dropzone--variant-${a}`,this.isDragOver()&&"designbase-wc-dropzone--drag-over",this.hasAttribute("disabled")&&"designbase-wc-dropzone--disabled",this.hasAttribute("readonly")&&"designbase-wc-dropzone--readonly"].filter(Boolean).join(" ")}sync(){this.ensureInput(),this.syncClasses();const i=this.getAttribute("accept"),s=this.hasAttribute("multiple");this.fileInput&&(i?this.fileInput.setAttribute("accept",i):this.fileInput.removeAttribute("accept"),this.fileInput.toggleAttribute("multiple",s),this.fileInput.disabled=this.isDisabled());const n=this.collectChildren(),a=this.querySelector(":scope > .designbase-wc-dropzone__content[data-wc-internal]");if(n.length)return void a?.remove();let r=a;r||(r=document.createElement("div"),r.className="designbase-wc-dropzone__content",r.setAttribute("data-wc-internal",""),this.append(r)),r.replaceChildren();const l=this.getAttribute("size")||"m",o=t.includes(l)?l:"m",d=this.getAttribute("image"),c="false"!==this.getAttribute("show-icon"),h=this.getAttribute("icon")||"gallery",p=this.getAttribute("title")||"파일을 드래그하여 업로드하거나 클릭하여 선택하세요",u=this.getDescriptionText(),b=this.hasAttribute("show-button"),g=this.getAttribute("button-text")||"파일 선택";if(d){const e=document.createElement("div");e.className="designbase-wc-dropzone__image";const t=document.createElement("img");t.src=d,t.alt="Upload illustration",e.append(t),r.append(e)}else if(c){const t=document.createElement("div");t.className="designbase-wc-dropzone__icon";const i="s"===o?32:"l"===o?56:48;t.append(e(h,i)),r.append(t)}if(p){const e=document.createElement("div");e.className="designbase-wc-dropzone__title",e.textContent=p,r.append(e)}if(u){const e=document.createElement("div");e.className="designbase-wc-dropzone__description",e.textContent=u,r.append(e)}if(b){const e=document.createElement("button");e.type="button",e.className="designbase-wc-dropzone__button",e.textContent=g,e.disabled=this.isDisabled(),e.addEventListener("click",e=>{e.stopPropagation(),this.isDisabled()||this.fileInput?.click()}),r.append(e)}}}customElements.get("db-dropzone")||customElements.define("db-dropzone",DbDropzone);export{DbDropzone};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import './db-button.js';
|
|
2
|
+
import './db-input.js';
|
|
3
|
+
import './db-otp-input.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ui-wc — db-email-verify (수동 작성, 자동 동기화 대상 아님)
|
|
7
|
+
*
|
|
8
|
+
* 이메일 인증: code(OTP) 모드 / confirm(메일함 확인) 모드.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare const SIZES: readonly ["s", "m", "l"];
|
|
12
|
+
type Size = (typeof SIZES)[number];
|
|
13
|
+
declare class DbEmailVerify extends HTMLElement {
|
|
14
|
+
static get observedAttributes(): string[];
|
|
15
|
+
private built;
|
|
16
|
+
private timerId;
|
|
17
|
+
private remaining;
|
|
18
|
+
private emailInput;
|
|
19
|
+
private sendBtn;
|
|
20
|
+
private otpInput;
|
|
21
|
+
private timerEl;
|
|
22
|
+
private resendBtn;
|
|
23
|
+
private verifyBtn;
|
|
24
|
+
private confirmBtn;
|
|
25
|
+
private codeBlock;
|
|
26
|
+
private confirmBlock;
|
|
27
|
+
private verifiedBlock;
|
|
28
|
+
private emailRow;
|
|
29
|
+
private errorEl;
|
|
30
|
+
private closeBtn?;
|
|
31
|
+
get mode(): 'code' | 'confirm';
|
|
32
|
+
set mode(v: 'code' | 'confirm');
|
|
33
|
+
get size(): Size;
|
|
34
|
+
set size(v: Size);
|
|
35
|
+
get step(): 'email' | 'code' | 'sent' | 'verified';
|
|
36
|
+
set step(v: 'email' | 'code' | 'sent' | 'verified');
|
|
37
|
+
get email(): string;
|
|
38
|
+
set email(v: string);
|
|
39
|
+
get countdown(): number;
|
|
40
|
+
set countdown(v: number);
|
|
41
|
+
connectedCallback(): void;
|
|
42
|
+
disconnectedCallback(): void;
|
|
43
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
44
|
+
startCodeStep(): void;
|
|
45
|
+
/** 수동 제어 모드에서 재전송 성공 후 카운트다운을 다시 시작합니다. */
|
|
46
|
+
restartCountdown(): void;
|
|
47
|
+
markSent(): void;
|
|
48
|
+
markVerified(): void;
|
|
49
|
+
private clearTimer;
|
|
50
|
+
private startTimer;
|
|
51
|
+
private renderTimer;
|
|
52
|
+
private build;
|
|
53
|
+
private sync;
|
|
54
|
+
private isEmailValid;
|
|
55
|
+
private requestVerify;
|
|
56
|
+
private setEmphasizedText;
|
|
57
|
+
}
|
|
58
|
+
declare global {
|
|
59
|
+
interface HTMLElementTagNameMap {
|
|
60
|
+
'db-email-verify': DbEmailVerify;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { DbEmailVerify };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createDbIcon as t}from"./db-icons.js";import"./db-button.js";import"./db-input.js";import"./db-otp-input.js";const e=["s","m","l"];function el(t,e){const i=document.createElement(t);return e&&(i.className=e),i}class DbEmailVerify extends HTMLElement{constructor(){super(...arguments),this.built=!1,this.timerId=null,this.remaining=0}static get observedAttributes(){return["mode","email","code","step","size","disabled","error","error-message","countdown","title","description","send-label","resend-label","verify-label","confirm-label","code-length","closable","manual","sending","verifying","auto-submit"]}get mode(){return"confirm"===this.getAttribute("mode")?"confirm":"code"}set mode(t){this.setAttribute("mode",t)}get size(){return function pick(t,e,i){return t.includes(e)?e:i}(e,this.getAttribute("size"),"m")}set size(t){this.setAttribute("size",t)}get step(){const t=this.getAttribute("step");return"code"===t||"sent"===t||"verified"===t?t:"email"}set step(t){this.setAttribute("step",t)}get email(){return this.getAttribute("email")||""}set email(t){this.setAttribute("email",t)}get countdown(){const t=Number(this.getAttribute("countdown")||180);return Number.isFinite(t)&&t>0?t:180}set countdown(t){this.setAttribute("countdown",String(t))}connectedCallback(){this.build(),this.sync(),"code"===this.mode&&"code"===this.step&&this.startTimer(this.countdown)}disconnectedCallback(){this.clearTimer()}attributeChangedCallback(t,e,i){this.built&&(this.sync(),"step"!==t&&"mode"!==t||e===i||("code"===this.mode&&"code"===this.step?this.startTimer(this.countdown):this.clearTimer()))}startCodeStep(){"code"!==this.mode&&(this.mode="code"),"code"===this.step?this.startTimer(this.countdown):this.step="code",requestAnimationFrame(()=>this.otpInput?.focus?.())}restartCountdown(){"code"===this.mode&&"code"===this.step&&this.startTimer(this.countdown)}markSent(){this.step="sent",this.clearTimer()}markVerified(){this.step="verified",this.clearTimer()}clearTimer(){this.timerId&&clearInterval(this.timerId),this.timerId=null,this.remaining=0}startTimer(t){this.clearTimer(),this.remaining=t,this.renderTimer(),this.timerId=setInterval(()=>{this.remaining-=1,this.renderTimer(),this.remaining<=0&&(this.clearTimer(),this.resendBtn.disabled=!1,this.dispatchEvent(new CustomEvent("db-countdown-complete",{bubbles:!0,composed:!0})))},1e3)}renderTimer(){const t=Math.max(0,Math.floor(this.remaining/60)),e=Math.max(0,this.remaining%60);this.timerEl.textContent=`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}`,this.timerEl.setAttribute("aria-label",`남은 시간 ${t}분 ${e}초`),this.resendBtn.disabled=this.remaining>0||this.hasAttribute("disabled")}build(){if(this.built)return;this.built=!0;const e="designbase-wc-email-verify";this.replaceChildren();const i=el("div",`${e}__shell`),s=el("div",`${e}__top`),n=el("span",`${e}__eyebrow`);n.dataset.role="eyebrow",this.closeBtn=el("button",`${e}__close`),this.closeBtn.type="button",this.closeBtn.setAttribute("aria-label","닫기"),this.closeBtn.append(t("close",18)),this.closeBtn.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("db-close",{bubbles:!0,composed:!0}))}),s.append(n,this.closeBtn);const r=el("div",`${e}__header`),o=el("h3",`${e}__title`);o.dataset.role="title";const d=el("p",`${e}__description`);d.dataset.role="description",r.append(o,d),this.emailRow=el("div",`${e}__email-row`),this.emailInput=document.createElement("db-input"),this.emailInput.setAttribute("type","email"),this.emailInput.setAttribute("label","이메일"),this.emailInput.setAttribute("placeholder","name@example.com"),this.emailInput.setAttribute("full-width",""),this.emailInput.setAttribute("start-icon","mail"),this.emailInput.addEventListener("db-input",t=>{t.stopPropagation();const e=String(t.detail?.value??this.emailInput.value??"");this.setAttribute("email",e),this.dispatchEvent(new CustomEvent("db-email-change",{detail:{email:e},bubbles:!0,composed:!0}))}),this.sendBtn=document.createElement("db-button"),this.sendBtn.setAttribute("variant","primary"),this.sendBtn.addEventListener("db-click",t=>{t.stopPropagation(),this.isEmailValid()&&(this.dispatchEvent(new CustomEvent("db-send-code",{detail:{email:this.email,mode:this.mode},bubbles:!0,composed:!0})),this.hasAttribute("manual")||("confirm"===this.mode?this.markSent():this.startCodeStep()))}),this.emailRow.append(this.emailInput,this.sendBtn),this.codeBlock=el("div",`${e}__code`);const a=el("div",`${e}__code-head`),l=el("span",`${e}__code-label`);l.textContent="인증 코드",this.timerEl=el("span",`${e}__timer`),a.append(l,this.timerEl),this.otpInput=document.createElement("db-otp-input"),this.otpInput.addEventListener("db-change",t=>{t.stopPropagation();const e=String(t.detail?.value||"");this.setAttribute("code",e),this.dispatchEvent(new CustomEvent("db-code-change",{detail:{code:e},bubbles:!0,composed:!0}))}),this.otpInput.addEventListener("db-complete",t=>{t.stopPropagation();const e=String(t.detail?.value||"");this.dispatchEvent(new CustomEvent("db-code-complete",{detail:{code:e,email:this.email},bubbles:!0,composed:!0})),this.hasAttribute("auto-submit")&&this.requestVerify()});const h=el("div",`${e}__code-actions`);this.resendBtn=el("button",`${e}__resend`),this.resendBtn.type="button",this.resendBtn.addEventListener("click",()=>{this.resendBtn.disabled||(this.dispatchEvent(new CustomEvent("db-resend",{detail:{email:this.email},bubbles:!0,composed:!0})),this.hasAttribute("manual")||this.startTimer(this.countdown))}),this.verifyBtn=document.createElement("db-button"),this.verifyBtn.setAttribute("variant","primary"),this.verifyBtn.setAttribute("full-width",""),this.verifyBtn.addEventListener("db-click",t=>{t.stopPropagation(),this.requestVerify()}),h.append(this.resendBtn,this.verifyBtn),this.codeBlock.append(a,this.otpInput,h),this.confirmBlock=el("div",`${e}__confirm`);const c=el("div",`${e}__confirm-icon`);c.append(t("mail",40));const m=el("span",`${e}__confirm-badge`);m.append(t("circle-checked",16)),c.append(m);const u=el("h4",`${e}__confirm-title`);u.dataset.role="confirm-title";const b=el("p",`${e}__confirm-desc`);b.dataset.role="confirm-desc",this.confirmBtn=document.createElement("db-button"),this.confirmBtn.setAttribute("variant","primary"),this.confirmBtn.setAttribute("full-width",""),this.confirmBtn.addEventListener("db-click",t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("db-confirm",{detail:{email:this.email},bubbles:!0,composed:!0}))});const p=el("button",`${e}__resend`);p.type="button",p.dataset.role="confirm-resend",p.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("db-resend",{detail:{email:this.email},bubbles:!0,composed:!0}))}),this.confirmBlock.append(c,u,b,this.confirmBtn,p),this.verifiedBlock=el("div",`${e}__confirm`);const f=el("div",`${e}__confirm-icon`);f.append(t("circle-checked",40));const v=el("h4",`${e}__confirm-title`);v.textContent="이메일 인증 완료";const g=el("p",`${e}__confirm-desc`);g.dataset.role="verified-desc",this.verifiedBlock.append(f,v,g),this.errorEl=el("p",`${e}__error`),this.errorEl.hidden=!0,i.append(s,r,this.emailRow,this.codeBlock,this.confirmBlock,this.verifiedBlock,this.errorEl),this.append(i)}sync(){const t="designbase-wc-email-verify",e=this.size,i=this.mode,s=this.step,n=this.hasAttribute("disabled"),r=this.getAttribute("code-length")||"6",o=this.email;this.className=[t,`${t}--${e}`,`${t}--mode-${i}`,`${t}--step-${s}`,n&&`${t}--disabled`,this.hasAttribute("error")&&`${t}--error`].filter(Boolean).join(" ");this.querySelector('[data-role="eyebrow"]').textContent="confirm"===i?"회원가입":"이메일 인증";const d=this.querySelector('[data-role="title"]'),a=this.querySelector('[data-role="description"]');d.textContent=this.getAttribute("title")||("confirm"===i?"이메일을 확인해 주세요":"이메일 인증");const l=this.getAttribute("description");l?a.textContent=l:"confirm"===i?this.setEmphasizedText(a,"",o||"your@email.com"," 으로 인증 링크를 보냈어요."):this.setEmphasizedText(a,"인증 코드를 ",o||"이메일"," 로 보내 드릴게요."),this.closeBtn&&(this.closeBtn.hidden=!this.hasAttribute("closable")),this.emailInput.value=o,this.emailInput.setAttribute("size",e),this.emailInput.toggleAttribute("disabled",n||"code"===s||"sent"===s||"verified"===s),this.sendBtn.setAttribute("size",e),this.sendBtn.textContent=this.getAttribute("send-label")||("confirm"===i?"인증 메일 보내기":"인증번호 받기"),this.sendBtn.toggleAttribute("disabled",n||!this.isEmailValid()||"email"!==s),this.sendBtn.toggleAttribute("loading",this.hasAttribute("sending")),this.otpInput.setAttribute("length",r),this.otpInput.setAttribute("size",e),this.otpInput.setAttribute("value",this.getAttribute("code")||""),this.otpInput.toggleAttribute("disabled",n||"code"!==s),this.resendBtn.textContent=this.getAttribute("resend-label")||"재전송",this.verifyBtn.setAttribute("size",e),this.verifyBtn.textContent=this.getAttribute("verify-label")||"인증하기",this.verifyBtn.toggleAttribute("disabled",n||"code"!==s||(this.getAttribute("code")||"").length!==Number(r)),this.verifyBtn.toggleAttribute("loading",this.hasAttribute("verifying"));const h=this.querySelector('[data-role="confirm-title"]'),c=this.querySelector('[data-role="confirm-desc"]');h.textContent="메일함을 확인해 주세요!",this.setEmphasizedText(c,"",o||"your@email.com"," 으로 보낸 링크를 클릭하면 인증이 완료됩니다."),this.confirmBtn.setAttribute("size",e),this.confirmBtn.textContent=this.getAttribute("confirm-label")||"확인";const m=this.querySelector('[data-role="confirm-resend"]');m&&(m.textContent="메일 다시 보내기");const u=this.querySelector('[data-role="verified-desc"]');this.setEmphasizedText(u,"",o||"your@email.com"," 주소가 인증되었습니다."),this.emailRow.hidden="confirm"===i&&("sent"===s||"verified"===s)||"code"===i&&"verified"===s,this.codeBlock.hidden=!("code"===i&&"code"===s),this.confirmBlock.hidden=!("confirm"===i&&("sent"===s||"verified"===s)),this.verifiedBlock.hidden=!("code"===i&&"verified"===s);const b=this.getAttribute("error-message")||"";this.errorEl.textContent=b,this.errorEl.hidden=!this.hasAttribute("error")||!b}isEmailValid(){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(this.email.trim())}requestVerify(){const t=(this.getAttribute("code")||this.otpInput.value).replace(/\D/g,""),e=Number(this.getAttribute("code-length")||6);"code"!==this.step||t.length!==e||this.hasAttribute("disabled")||this.dispatchEvent(new CustomEvent("db-verify",{detail:{email:this.email,code:t},bubbles:!0,composed:!0}))}setEmphasizedText(t,e,i,s){const n=document.createElement("strong");n.textContent=i,t.replaceChildren(document.createTextNode(e),n,document.createTextNode(s))}}customElements.get("db-email-verify")||customElements.define("db-email-verify",DbEmailVerify);export{DbEmailVerify};
|
|
@@ -1,97 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
class DbEmptyState extends HTMLElement {
|
|
4
|
-
static get observedAttributes() {
|
|
5
|
-
return ['variant', 'size', 'title', 'description', 'action-text', 'secondary-action-text', 'image', 'image-alt'];
|
|
6
|
-
}
|
|
7
|
-
connectedCallback() {
|
|
8
|
-
this.render();
|
|
9
|
-
}
|
|
10
|
-
attributeChangedCallback() {
|
|
11
|
-
this.render();
|
|
12
|
-
}
|
|
13
|
-
getIconName(variant) {
|
|
14
|
-
if (variant === 'no-results')
|
|
15
|
-
return 'search';
|
|
16
|
-
if (variant === 'no-access')
|
|
17
|
-
return 'user';
|
|
18
|
-
if (variant === 'error')
|
|
19
|
-
return 'cloud-close';
|
|
20
|
-
if (variant === 'onboarding')
|
|
21
|
-
return 'bulb';
|
|
22
|
-
return 'plus';
|
|
23
|
-
}
|
|
24
|
-
render() {
|
|
25
|
-
const variant = this.getAttribute('variant') || 'no-data';
|
|
26
|
-
const size = this.getAttribute('size') || 'm';
|
|
27
|
-
const title = this.getAttribute('title') || '';
|
|
28
|
-
const description = this.getAttribute('description') || '';
|
|
29
|
-
const actionText = this.getAttribute('action-text');
|
|
30
|
-
const secondaryActionText = this.getAttribute('secondary-action-text');
|
|
31
|
-
const image = this.getAttribute('image');
|
|
32
|
-
const imageAlt = this.getAttribute('image-alt') || title;
|
|
33
|
-
const iconSize = size === 's' ? 24 : size === 'l' ? 48 : 32;
|
|
34
|
-
this.className = `designbase-wc-empty-state designbase-wc-empty-state--${variant} designbase-wc-empty-state--${size}`;
|
|
35
|
-
this.setAttribute('role', 'status');
|
|
36
|
-
this.setAttribute('aria-live', 'polite');
|
|
37
|
-
this.replaceChildren();
|
|
38
|
-
const content = document.createElement('div');
|
|
39
|
-
content.className = 'designbase-wc-empty-state__content';
|
|
40
|
-
if (image) {
|
|
41
|
-
const imageWrap = document.createElement('div');
|
|
42
|
-
imageWrap.className = 'designbase-wc-empty-state__image';
|
|
43
|
-
const imageElement = document.createElement('img');
|
|
44
|
-
imageElement.className = 'designbase-wc-empty-state__image-element';
|
|
45
|
-
imageElement.src = image;
|
|
46
|
-
imageElement.alt = imageAlt;
|
|
47
|
-
imageWrap.append(imageElement);
|
|
48
|
-
content.append(imageWrap);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
const icon = document.createElement('div');
|
|
52
|
-
icon.className = 'designbase-wc-empty-state__icon';
|
|
53
|
-
icon.append(createDbIcon(this.getIconName(variant), iconSize));
|
|
54
|
-
content.append(icon);
|
|
55
|
-
}
|
|
56
|
-
const heading = document.createElement('h3');
|
|
57
|
-
heading.className = 'designbase-wc-empty-state__title';
|
|
58
|
-
heading.textContent = title;
|
|
59
|
-
content.append(heading);
|
|
60
|
-
if (description) {
|
|
61
|
-
const body = document.createElement('p');
|
|
62
|
-
body.className = 'designbase-wc-empty-state__description';
|
|
63
|
-
body.textContent = description;
|
|
64
|
-
content.append(body);
|
|
65
|
-
}
|
|
66
|
-
if (actionText || secondaryActionText) {
|
|
67
|
-
const actions = document.createElement('div');
|
|
68
|
-
actions.className = 'designbase-wc-empty-state__actions';
|
|
69
|
-
if (actionText) {
|
|
70
|
-
const action = document.createElement('db-button');
|
|
71
|
-
action.setAttribute('variant', variant === 'onboarding' ? 'primary' : 'secondary');
|
|
72
|
-
action.setAttribute('size', size);
|
|
73
|
-
action.textContent = actionText;
|
|
74
|
-
action.addEventListener('db-click', () => {
|
|
75
|
-
this.dispatchEvent(new CustomEvent('db-action', { bubbles: true, composed: true }));
|
|
76
|
-
});
|
|
77
|
-
actions.append(action);
|
|
78
|
-
}
|
|
79
|
-
if (secondaryActionText) {
|
|
80
|
-
const action = document.createElement('db-button');
|
|
81
|
-
action.setAttribute('variant', 'tertiary');
|
|
82
|
-
action.setAttribute('size', size);
|
|
83
|
-
action.textContent = secondaryActionText;
|
|
84
|
-
action.addEventListener('db-click', () => {
|
|
85
|
-
this.dispatchEvent(new CustomEvent('db-secondary-action', { bubbles: true, composed: true }));
|
|
86
|
-
});
|
|
87
|
-
actions.append(action);
|
|
88
|
-
}
|
|
89
|
-
content.append(actions);
|
|
90
|
-
}
|
|
91
|
-
this.append(content);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (!customElements.get('db-empty-state'))
|
|
95
|
-
customElements.define('db-empty-state', DbEmptyState);
|
|
96
|
-
|
|
97
|
-
export { DbEmptyState };
|
|
1
|
+
import{createDbIcon as t}from"./db-icons.js";class DbEmptyState extends HTMLElement{static get observedAttributes(){return["variant","size","title","description","action-text","secondary-action-text","image","image-alt"]}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}getIconName(t){return"no-results"===t?"search":"no-access"===t?"user":"error"===t?"cloud-close":"onboarding"===t?"bulb":"plus"}render(){const e=this.getAttribute("variant")||"no-data",s=this.getAttribute("size")||"m",a=this.getAttribute("title")||"",n=this.getAttribute("description")||"",i=this.getAttribute("action-text"),c=this.getAttribute("secondary-action-text"),d=this.getAttribute("image"),o=this.getAttribute("image-alt")||a,r="s"===s?24:"l"===s?48:32;this.className=`designbase-wc-empty-state designbase-wc-empty-state--${e} designbase-wc-empty-state--${s}`,this.setAttribute("role","status"),this.setAttribute("aria-live","polite"),this.replaceChildren();const m=document.createElement("div");if(m.className="designbase-wc-empty-state__content",d){const t=document.createElement("div");t.className="designbase-wc-empty-state__image";const e=document.createElement("img");e.className="designbase-wc-empty-state__image-element",e.src=d,e.alt=o,t.append(e),m.append(t)}else{const s=document.createElement("div");s.className="designbase-wc-empty-state__icon",s.append(t(this.getIconName(e),r)),m.append(s)}const b=document.createElement("h3");if(b.className="designbase-wc-empty-state__title",b.textContent=a,m.append(b),n){const t=document.createElement("p");t.className="designbase-wc-empty-state__description",t.textContent=n,m.append(t)}if(i||c){const t=document.createElement("div");if(t.className="designbase-wc-empty-state__actions",i){const a=document.createElement("db-button");a.setAttribute("variant","onboarding"===e?"primary":"secondary"),a.setAttribute("size",s),a.textContent=i,a.addEventListener("db-click",()=>{this.dispatchEvent(new CustomEvent("db-action",{bubbles:!0,composed:!0}))}),t.append(a)}if(c){const e=document.createElement("db-button");e.setAttribute("variant","tertiary"),e.setAttribute("size",s),e.textContent=c,e.addEventListener("db-click",()=>{this.dispatchEvent(new CustomEvent("db-secondary-action",{bubbles:!0,composed:!0}))}),t.append(e)}m.append(t)}this.append(m)}}customElements.get("db-empty-state")||customElements.define("db-empty-state",DbEmptyState);export{DbEmptyState};
|