@designbasekorea/ui-wc 0.5.5 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/lottie-e273b936.js +17032 -0
- package/dist/esm/components/animation-background/canvas-controller.js +121 -1
- package/dist/esm/components/animation-background/controls.js +180 -1
- package/dist/esm/components/animation-background/graphite-controller.js +196 -1
- package/dist/esm/components/animation-background/graphite-presets.js +42 -1
- package/dist/esm/components/animation-background/graphite-shader.js +111 -1
- package/dist/esm/components/animation-background/layers.js +369 -1
- package/dist/esm/components/animation-background/lumina-presets.js +53 -1
- package/dist/esm/components/animation-background/lumina-shaders.js +181 -1
- package/dist/esm/components/animation-background/lumina-utils.js +60 -1
- package/dist/esm/components/animation-background/particle-defaults.js +36 -1
- package/dist/esm/components/animation-background/renderers.js +167 -1
- package/dist/esm/components/animation-background/shader-controller.js +154 -1
- package/dist/esm/components/color-picker-utils.js +134 -1
- package/dist/esm/components/date-picker-utils.js +140 -1
- package/dist/esm/components/db-accordion.js +304 -1
- package/dist/esm/components/db-ad-banner.js +455 -1
- package/dist/esm/components/db-alert.js +149 -1
- package/dist/esm/components/db-animation-background.js +486 -1
- package/dist/esm/components/db-animation-text.js +601 -1
- package/dist/esm/components/db-app-badge.js +88 -1
- package/dist/esm/components/db-audio-player.js +752 -1
- package/dist/esm/components/db-avatar.js +188 -1
- package/dist/esm/components/db-backdrop.js +139 -1
- package/dist/esm/components/db-badge.js +91 -1
- package/dist/esm/components/db-banner.js +188 -1
- package/dist/esm/components/db-bottom-navigation.js +146 -1
- package/dist/esm/components/db-bottom-sheet.js +481 -1
- package/dist/esm/components/db-breadcrumbs.js +329 -1
- package/dist/esm/components/db-button.js +316 -1
- package/dist/esm/components/db-calendar.js +675 -1
- package/dist/esm/components/db-card.js +265 -1
- package/dist/esm/components/db-carousel.js +264 -1
- package/dist/esm/components/db-checkbox.js +202 -1
- package/dist/esm/components/db-chip.js +104 -1
- package/dist/esm/components/db-code-block.js +304 -1
- package/dist/esm/components/db-color-picker.js +746 -1
- package/dist/esm/components/db-confirm.js +191 -1
- package/dist/esm/components/db-container.js +39 -1
- package/dist/esm/components/db-context-menu.js +265 -1
- package/dist/esm/components/db-countdown.js +146 -1
- package/dist/esm/components/db-cursor-follower.js +173 -1
- package/dist/esm/components/db-date-picker.js +837 -1
- package/dist/esm/components/db-divider.js +66 -1
- package/dist/esm/components/db-drawer.js +245 -1
- package/dist/esm/components/db-dropdown.js +493 -1
- package/dist/esm/components/db-dropzone.js +266 -1
- package/dist/esm/components/db-empty-state.js +97 -1
- package/dist/esm/components/db-file-uploader.js +256 -1
- package/dist/esm/components/db-floating-action-button.js +139 -1
- package/dist/esm/components/db-footer.js +385 -1
- package/dist/esm/components/db-form.js +566 -1
- package/dist/esm/components/db-gantt.js +882 -1
- package/dist/esm/components/db-gradient.js +133 -1
- package/dist/esm/components/db-grid-background.js +909 -1
- package/dist/esm/components/db-grid.js +73 -1
- package/dist/esm/components/db-icons.js +82 -1
- package/dist/esm/components/db-image-list.js +214 -1
- package/dist/esm/components/db-image-placeholder.js +96 -1
- package/dist/esm/components/db-image.js +289 -1
- package/dist/esm/components/db-indicator.js +517 -1
- package/dist/esm/components/db-input.js +420 -1
- package/dist/esm/components/db-kanban.js +538 -1
- package/dist/esm/components/db-label.js +66 -1
- package/dist/esm/components/db-lightbox.js +372 -1
- package/dist/esm/components/db-list.js +340 -1
- package/dist/esm/components/db-logo-svg.js +72 -1
- package/dist/esm/components/db-logo.js +106 -1
- package/dist/esm/components/db-lottie.js +109 -1
- package/dist/esm/components/db-markdown-editor.js +458 -1
- package/dist/esm/components/db-marquee.js +402 -1
- package/dist/esm/components/db-masonry.js +94 -1
- package/dist/esm/components/db-menu-item.js +211 -1
- package/dist/esm/components/db-modal.js +522 -1
- package/dist/esm/components/db-navbar.js +680 -1
- package/dist/esm/components/db-onboarding-modal.js +322 -1
- package/dist/esm/components/db-page-header.js +312 -1
- package/dist/esm/components/db-pagination.js +271 -1
- package/dist/esm/components/db-popover.js +580 -1
- package/dist/esm/components/db-progress-step.js +166 -1
- package/dist/esm/components/db-progress.js +171 -1
- package/dist/esm/components/db-progressbar.js +72 -1
- package/dist/esm/components/db-radio.js +172 -1
- package/dist/esm/components/db-random-gradient.js +121 -1
- package/dist/esm/components/db-range-slider.js +811 -1
- package/dist/esm/components/db-rating.js +325 -1
- package/dist/esm/components/db-reorder.js +286 -1
- package/dist/esm/components/db-resizable-panels.js +282 -1
- package/dist/esm/components/db-scroll-area.js +126 -1
- package/dist/esm/components/db-search-bar.js +668 -1
- package/dist/esm/components/db-section-app-download.js +101 -1
- package/dist/esm/components/db-section-contact.js +102 -1
- package/dist/esm/components/db-section-cta.js +150 -1
- package/dist/esm/components/db-section-faq.js +120 -1
- package/dist/esm/components/db-section-feature-grid.js +137 -1
- package/dist/esm/components/db-section-feature.js +179 -1
- package/dist/esm/components/db-section-hero.js +243 -1
- package/dist/esm/components/db-section-logo-cloud.js +138 -1
- package/dist/esm/components/db-section-pricing.js +166 -1
- package/dist/esm/components/db-section-stats.js +129 -1
- package/dist/esm/components/db-section-testimonials.js +252 -1
- package/dist/esm/components/db-section.js +385 -1
- package/dist/esm/components/db-segment-control.js +231 -1
- package/dist/esm/components/db-select.js +571 -1
- package/dist/esm/components/db-share-icons.js +40 -1
- package/dist/esm/components/db-share.js +489 -1
- package/dist/esm/components/db-sidebar.js +1068 -1
- package/dist/esm/components/db-skeleton.js +94 -1
- package/dist/esm/components/db-spinner.js +102 -1
- package/dist/esm/components/db-split-view.js +297 -1
- package/dist/esm/components/db-stack.js +46 -1
- package/dist/esm/components/db-stat.js +218 -1
- package/dist/esm/components/db-stepper.js +398 -1
- package/dist/esm/components/db-table.js +412 -1
- package/dist/esm/components/db-tabs.js +335 -1
- package/dist/esm/components/db-testimonial.js +162 -1
- package/dist/esm/components/db-textarea.js +233 -1
- package/dist/esm/components/db-time-picker.js +523 -1
- package/dist/esm/components/db-timeline.js +174 -1
- package/dist/esm/components/db-toast.js +158 -1
- package/dist/esm/components/db-toggle.js +162 -1
- package/dist/esm/components/db-toolbar.js +94 -1
- package/dist/esm/components/db-tooltip.js +440 -1
- package/dist/esm/components/db-top-banner.js +121 -1
- package/dist/esm/components/db-tutorial.js +324 -1
- package/dist/esm/components/db-video-player.js +503 -1
- package/dist/esm/components/db-youtube-player.js +194 -1
- package/dist/esm/components/highlight-code.js +65 -1
- package/dist/esm/components/input-validation.js +50 -1
- package/dist/esm/components/marketing-block-host-utils.js +9 -1
- package/dist/esm/components/number-scrub.js +117 -1
- package/dist/esm/components/random-gradient-palettes.js +67 -1
- package/dist/esm/components/section-block-header-utils.js +48 -1
- package/dist/esm/helpers/confirm.js +52 -1
- package/dist/esm/helpers/toast.js +73 -1
- package/dist/esm/index.js +111 -1
- package/dist/esm/node_modules/prismjs/components/prism-bash.js +235 -1
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +31 -1
- package/dist/esm/node_modules/prismjs/components/prism-css.js +64 -1
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +172 -1
- package/dist/esm/node_modules/prismjs/components/prism-json.js +27 -1
- package/dist/esm/node_modules/prismjs/components/prism-jsx.js +143 -1
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +186 -1
- package/dist/esm/node_modules/prismjs/components/prism-scss.js +81 -1
- package/dist/esm/node_modules/prismjs/components/prism-tsx.js +15 -1
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +60 -1
- package/dist/index.cjs +55414 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.js +38284 -1
- package/dist/react/chunks/lottie-72a4c6d4.js +17032 -0
- package/dist/react/index.cjs +56503 -1
- package/dist/react/index.esm.js +39373 -1
- package/package.json +1 -1
- package/dist/chunks/lottie-2637aa0f.js +0 -1
- package/dist/react/chunks/lottie-14e7addb.js +0 -1
|
@@ -1 +1,174 @@
|
|
|
1
|
-
import{isDbIconName
|
|
1
|
+
import { isDbIconName, createDbIcon } from './db-icons.js';
|
|
2
|
+
|
|
3
|
+
const CLASS = 'designbase-wc-timeline';
|
|
4
|
+
class DbTimeline extends HTMLElement {
|
|
5
|
+
static get observedAttributes() {
|
|
6
|
+
return ['items', 'type', 'variant', 'size', 'color', 'clickable', 'full-width', 'disabled'];
|
|
7
|
+
}
|
|
8
|
+
connectedCallback() {
|
|
9
|
+
this.style.display = 'block';
|
|
10
|
+
this.render();
|
|
11
|
+
}
|
|
12
|
+
attributeChangedCallback() {
|
|
13
|
+
if (this.isConnected)
|
|
14
|
+
this.render();
|
|
15
|
+
}
|
|
16
|
+
get items() {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(this.getAttribute('items') || '[]');
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
set items(value) {
|
|
25
|
+
this.setAttribute('items', typeof value === 'string' ? value : JSON.stringify(value));
|
|
26
|
+
}
|
|
27
|
+
getItemPosition(index) {
|
|
28
|
+
const type = this.getAttribute('type') || 'alternate';
|
|
29
|
+
if (type === 'left')
|
|
30
|
+
return 'left';
|
|
31
|
+
return index % 2 === 0 ? 'left' : 'right';
|
|
32
|
+
}
|
|
33
|
+
handleItemClick(item, index) {
|
|
34
|
+
if (this.hasAttribute('disabled') || item.disabled || !this.hasAttribute('clickable'))
|
|
35
|
+
return;
|
|
36
|
+
this.dispatchEvent(new CustomEvent('db-item-click', {
|
|
37
|
+
bubbles: true,
|
|
38
|
+
composed: true,
|
|
39
|
+
detail: { item, index },
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
render() {
|
|
43
|
+
const type = this.getAttribute('type') || 'alternate';
|
|
44
|
+
const variant = this.getAttribute('variant') || 'default';
|
|
45
|
+
const size = this.getAttribute('size') || 'm';
|
|
46
|
+
const color = this.getAttribute('color') || 'primary';
|
|
47
|
+
const clickable = this.hasAttribute('clickable');
|
|
48
|
+
const disabled = this.hasAttribute('disabled');
|
|
49
|
+
const items = this.items;
|
|
50
|
+
this.className = [
|
|
51
|
+
CLASS,
|
|
52
|
+
`${CLASS}--${type}`,
|
|
53
|
+
`${CLASS}--${variant}`,
|
|
54
|
+
`${CLASS}--${size}`,
|
|
55
|
+
clickable && `${CLASS}--clickable`,
|
|
56
|
+
this.hasAttribute('full-width') && `${CLASS}--full-width`,
|
|
57
|
+
disabled && `${CLASS}--disabled`,
|
|
58
|
+
]
|
|
59
|
+
.filter(Boolean)
|
|
60
|
+
.join(' ');
|
|
61
|
+
this.replaceChildren();
|
|
62
|
+
const container = document.createElement('div');
|
|
63
|
+
container.className = `${CLASS}__container`;
|
|
64
|
+
items.forEach((item, index) => {
|
|
65
|
+
const itemPosition = this.getItemPosition(index);
|
|
66
|
+
const isLast = index === items.length - 1;
|
|
67
|
+
const isClickable = clickable && !disabled && !item.disabled;
|
|
68
|
+
const itemColor = item.color || color;
|
|
69
|
+
const itemStatus = item.status || 'pending';
|
|
70
|
+
const itemEl = document.createElement('div');
|
|
71
|
+
itemEl.className = [
|
|
72
|
+
`${CLASS}__item`,
|
|
73
|
+
`${CLASS}__item--${itemPosition}`,
|
|
74
|
+
`${CLASS}__item--${itemColor}`,
|
|
75
|
+
isClickable && `${CLASS}__item--clickable`,
|
|
76
|
+
item.disabled && `${CLASS}__item--disabled`,
|
|
77
|
+
]
|
|
78
|
+
.filter(Boolean)
|
|
79
|
+
.join(' ');
|
|
80
|
+
const indicatorContainer = document.createElement('div');
|
|
81
|
+
indicatorContainer.className = `${CLASS}__indicator-container`;
|
|
82
|
+
if (itemStatus === 'active' && !item.icon && item.number === undefined) {
|
|
83
|
+
const pulse = document.createElement('div');
|
|
84
|
+
pulse.className = `${CLASS}__pulse`;
|
|
85
|
+
indicatorContainer.append(pulse);
|
|
86
|
+
}
|
|
87
|
+
const dot = document.createElement('div');
|
|
88
|
+
dot.className = [
|
|
89
|
+
`${CLASS}__dot`,
|
|
90
|
+
`${CLASS}__dot--${itemColor}`,
|
|
91
|
+
`${CLASS}__dot--${variant}`,
|
|
92
|
+
`${CLASS}__dot--${itemStatus}`,
|
|
93
|
+
isClickable && `${CLASS}__dot--clickable`,
|
|
94
|
+
item.icon && `${CLASS}__dot--with-icon`,
|
|
95
|
+
item.number !== undefined && !item.icon && `${CLASS}__dot--with-number`,
|
|
96
|
+
]
|
|
97
|
+
.filter(Boolean)
|
|
98
|
+
.join(' ');
|
|
99
|
+
if (isClickable) {
|
|
100
|
+
dot.tabIndex = 0;
|
|
101
|
+
dot.setAttribute('role', 'button');
|
|
102
|
+
dot.setAttribute('aria-label', item.title ? `${item.title} 타임라인 점` : `타임라인 점 ${index + 1}`);
|
|
103
|
+
dot.addEventListener('click', () => this.handleItemClick(item, index));
|
|
104
|
+
dot.addEventListener('keydown', (event) => {
|
|
105
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
this.handleItemClick(item, index);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (item.icon && isDbIconName(item.icon)) {
|
|
112
|
+
const iconWrap = document.createElement('div');
|
|
113
|
+
iconWrap.className = `${CLASS}__icon`;
|
|
114
|
+
iconWrap.append(createDbIcon(item.icon, size === 's' ? 14 : size === 'l' ? 20 : 16));
|
|
115
|
+
dot.append(iconWrap);
|
|
116
|
+
}
|
|
117
|
+
else if (item.number !== undefined) {
|
|
118
|
+
const number = document.createElement('span');
|
|
119
|
+
number.className = `${CLASS}__number`;
|
|
120
|
+
number.textContent = String(item.number);
|
|
121
|
+
dot.append(number);
|
|
122
|
+
}
|
|
123
|
+
indicatorContainer.append(dot);
|
|
124
|
+
if (!isLast) {
|
|
125
|
+
const connector = document.createElement('div');
|
|
126
|
+
connector.className = `${CLASS}__connector`;
|
|
127
|
+
indicatorContainer.append(connector);
|
|
128
|
+
}
|
|
129
|
+
const content = document.createElement('div');
|
|
130
|
+
content.className = [`${CLASS}__content`, `${CLASS}__content--${itemPosition}`].join(' ');
|
|
131
|
+
if (item.timestamp) {
|
|
132
|
+
const timestamp = document.createElement('div');
|
|
133
|
+
timestamp.className = `${CLASS}__timestamp`;
|
|
134
|
+
timestamp.textContent = item.timestamp;
|
|
135
|
+
content.append(timestamp);
|
|
136
|
+
}
|
|
137
|
+
const contentInner = document.createElement('div');
|
|
138
|
+
contentInner.className = `${CLASS}__content-inner`;
|
|
139
|
+
if (isClickable) {
|
|
140
|
+
contentInner.tabIndex = 0;
|
|
141
|
+
contentInner.setAttribute('role', 'button');
|
|
142
|
+
contentInner.setAttribute('aria-label', item.title ? `${item.title} 타임라인 아이템` : `타임라인 아이템 ${index + 1}`);
|
|
143
|
+
contentInner.addEventListener('click', () => this.handleItemClick(item, index));
|
|
144
|
+
contentInner.addEventListener('keydown', (event) => {
|
|
145
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
this.handleItemClick(item, index);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
if (item.title) {
|
|
152
|
+
const title = document.createElement('h3');
|
|
153
|
+
title.className = `${CLASS}__title`;
|
|
154
|
+
title.textContent = item.title;
|
|
155
|
+
contentInner.append(title);
|
|
156
|
+
}
|
|
157
|
+
if (item.description) {
|
|
158
|
+
const description = document.createElement('p');
|
|
159
|
+
description.className = `${CLASS}__description`;
|
|
160
|
+
description.textContent = item.description;
|
|
161
|
+
contentInner.append(description);
|
|
162
|
+
}
|
|
163
|
+
content.append(contentInner);
|
|
164
|
+
itemEl.append(indicatorContainer, content);
|
|
165
|
+
container.append(itemEl);
|
|
166
|
+
});
|
|
167
|
+
this.append(container);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (!customElements.get('db-timeline')) {
|
|
171
|
+
customElements.define('db-timeline', DbTimeline);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export { DbTimeline };
|
|
@@ -1 +1,158 @@
|
|
|
1
|
-
import{createDbIcon
|
|
1
|
+
import { createDbIcon } from './db-icons.js';
|
|
2
|
+
|
|
3
|
+
const CLOSE_ANIMATION_MS = 300;
|
|
4
|
+
class DbToast extends HTMLElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.timeoutId = null;
|
|
8
|
+
this.progressInterval = null;
|
|
9
|
+
this.closeTimerId = null;
|
|
10
|
+
this.closed = false;
|
|
11
|
+
}
|
|
12
|
+
static get observedAttributes() {
|
|
13
|
+
return ['toast-id', 'status', 'title', 'description', 'duration', 'show-close', 'show-progress', 'auto-remove'];
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
this.closed = false;
|
|
17
|
+
this.render();
|
|
18
|
+
this.startTimers();
|
|
19
|
+
requestAnimationFrame(() => this.classList.add('designbase-wc-toast--visible'));
|
|
20
|
+
}
|
|
21
|
+
disconnectedCallback() {
|
|
22
|
+
this.clearTimers();
|
|
23
|
+
if (this.closeTimerId)
|
|
24
|
+
clearTimeout(this.closeTimerId);
|
|
25
|
+
this.closeTimerId = null;
|
|
26
|
+
}
|
|
27
|
+
attributeChangedCallback(name) {
|
|
28
|
+
if (!this.isConnected || this.closed)
|
|
29
|
+
return;
|
|
30
|
+
const wasVisible = this.classList.contains('designbase-wc-toast--visible');
|
|
31
|
+
this.render();
|
|
32
|
+
if (wasVisible) {
|
|
33
|
+
requestAnimationFrame(() => this.classList.add('designbase-wc-toast--visible'));
|
|
34
|
+
}
|
|
35
|
+
if (name === 'duration' || name === 'show-progress') {
|
|
36
|
+
this.clearTimers();
|
|
37
|
+
this.startTimers();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
clearTimers() {
|
|
41
|
+
if (this.timeoutId)
|
|
42
|
+
clearTimeout(this.timeoutId);
|
|
43
|
+
if (this.progressInterval)
|
|
44
|
+
clearInterval(this.progressInterval);
|
|
45
|
+
this.timeoutId = null;
|
|
46
|
+
this.progressInterval = null;
|
|
47
|
+
}
|
|
48
|
+
startTimers() {
|
|
49
|
+
const duration = Number(this.getAttribute('duration') ?? '5000');
|
|
50
|
+
if (!Number.isFinite(duration) || duration <= 0)
|
|
51
|
+
return;
|
|
52
|
+
const showProgress = this.getAttribute('show-progress') !== 'false' && this.hasAttribute('show-progress');
|
|
53
|
+
if (showProgress) {
|
|
54
|
+
const bar = this.querySelector('.designbase-wc-toast__progress-bar');
|
|
55
|
+
if (bar)
|
|
56
|
+
bar.style.width = '0%';
|
|
57
|
+
const start = Date.now();
|
|
58
|
+
this.progressInterval = setInterval(() => {
|
|
59
|
+
const elapsed = Date.now() - start;
|
|
60
|
+
const progress = Math.min(100, (elapsed / duration) * 100);
|
|
61
|
+
if (bar)
|
|
62
|
+
bar.style.width = `${progress}%`;
|
|
63
|
+
if (progress >= 100)
|
|
64
|
+
this.close();
|
|
65
|
+
}, 16);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.timeoutId = setTimeout(() => this.close(), duration);
|
|
69
|
+
}
|
|
70
|
+
/** 토스트를 닫고(애니메이션 포함) auto-remove 설정 시 DOM에서 제거합니다. */
|
|
71
|
+
close() {
|
|
72
|
+
if (this.closed)
|
|
73
|
+
return;
|
|
74
|
+
this.closed = true;
|
|
75
|
+
this.clearTimers();
|
|
76
|
+
this.classList.remove('designbase-wc-toast--visible');
|
|
77
|
+
this.classList.add('designbase-wc-toast--closing');
|
|
78
|
+
if (this.closeTimerId)
|
|
79
|
+
clearTimeout(this.closeTimerId);
|
|
80
|
+
this.closeTimerId = setTimeout(() => {
|
|
81
|
+
this.dispatchEvent(new CustomEvent('db-close', {
|
|
82
|
+
bubbles: true,
|
|
83
|
+
composed: true,
|
|
84
|
+
detail: { id: this.getAttribute('toast-id') || '' },
|
|
85
|
+
}));
|
|
86
|
+
const autoRemove = this.getAttribute('auto-remove') === 'true' ||
|
|
87
|
+
(this.hasAttribute('auto-remove') && this.getAttribute('auto-remove') !== 'false');
|
|
88
|
+
if (autoRemove) {
|
|
89
|
+
this.remove();
|
|
90
|
+
}
|
|
91
|
+
}, CLOSE_ANIMATION_MS);
|
|
92
|
+
}
|
|
93
|
+
iconForStatus(status) {
|
|
94
|
+
if (status === 'success')
|
|
95
|
+
return 'circle-checked';
|
|
96
|
+
if (status === 'warning')
|
|
97
|
+
return 'warning-filled';
|
|
98
|
+
if (status === 'error')
|
|
99
|
+
return 'error-filled';
|
|
100
|
+
return 'info-filled';
|
|
101
|
+
}
|
|
102
|
+
render() {
|
|
103
|
+
const status = this.getAttribute('status') || 'info';
|
|
104
|
+
const title = this.getAttribute('title') || '';
|
|
105
|
+
const description = this.getAttribute('description') || '';
|
|
106
|
+
const showClose = this.getAttribute('show-close') !== 'false';
|
|
107
|
+
const showProgress = this.getAttribute('show-progress') !== 'false' && this.hasAttribute('show-progress');
|
|
108
|
+
this.className = [
|
|
109
|
+
'designbase-wc-toast',
|
|
110
|
+
`designbase-wc-toast--${status}`,
|
|
111
|
+
this.closed && 'designbase-wc-toast--closing',
|
|
112
|
+
]
|
|
113
|
+
.filter(Boolean)
|
|
114
|
+
.join(' ');
|
|
115
|
+
this.setAttribute('role', 'alert');
|
|
116
|
+
this.setAttribute('aria-live', 'assertive');
|
|
117
|
+
this.replaceChildren();
|
|
118
|
+
if (showProgress) {
|
|
119
|
+
const progress = document.createElement('div');
|
|
120
|
+
progress.className = 'designbase-wc-toast__progress';
|
|
121
|
+
const bar = document.createElement('div');
|
|
122
|
+
bar.className = 'designbase-wc-toast__progress-bar';
|
|
123
|
+
bar.style.width = '0%';
|
|
124
|
+
progress.append(bar);
|
|
125
|
+
this.append(progress);
|
|
126
|
+
}
|
|
127
|
+
const icon = document.createElement('div');
|
|
128
|
+
icon.className = `designbase-wc-toast__icon designbase-wc-toast__icon--${status}`;
|
|
129
|
+
icon.append(createDbIcon(this.iconForStatus(status), 20));
|
|
130
|
+
const content = document.createElement('div');
|
|
131
|
+
content.className = 'designbase-wc-toast__content';
|
|
132
|
+
const titleEl = document.createElement('div');
|
|
133
|
+
titleEl.className = 'designbase-wc-toast__title';
|
|
134
|
+
titleEl.textContent = title;
|
|
135
|
+
content.append(titleEl);
|
|
136
|
+
if (description) {
|
|
137
|
+
const desc = document.createElement('div');
|
|
138
|
+
desc.className = 'designbase-wc-toast__description';
|
|
139
|
+
desc.textContent = description;
|
|
140
|
+
content.append(desc);
|
|
141
|
+
}
|
|
142
|
+
this.append(icon, content);
|
|
143
|
+
if (showClose) {
|
|
144
|
+
const close = document.createElement('button');
|
|
145
|
+
close.type = 'button';
|
|
146
|
+
close.className = 'designbase-wc-toast__close-button';
|
|
147
|
+
close.setAttribute('aria-label', '토스트 닫기');
|
|
148
|
+
close.append(createDbIcon('close', 20));
|
|
149
|
+
close.addEventListener('click', () => this.close());
|
|
150
|
+
this.append(close);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (!customElements.get('db-toast')) {
|
|
155
|
+
customElements.define('db-toast', DbToast);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export { DbToast };
|
|
@@ -1 +1,162 @@
|
|
|
1
|
-
const
|
|
1
|
+
const SIZES = ['s', 'm', 'l'];
|
|
2
|
+
class DbToggle extends HTMLElement {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.internals = this.attachInternals();
|
|
6
|
+
this.built = false;
|
|
7
|
+
this.handleClick = () => {
|
|
8
|
+
if (this.disabled || this.readOnly)
|
|
9
|
+
return;
|
|
10
|
+
const next = !this.checked;
|
|
11
|
+
this.toggleAttribute('checked', next);
|
|
12
|
+
this.syncFormValue();
|
|
13
|
+
this.syncState();
|
|
14
|
+
this.dispatchEvent(new Event('change', { bubbles: true }));
|
|
15
|
+
this.dispatchEvent(new CustomEvent('db-change', {
|
|
16
|
+
detail: { checked: next, selected: next },
|
|
17
|
+
bubbles: true,
|
|
18
|
+
composed: true,
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
static get observedAttributes() {
|
|
23
|
+
return [
|
|
24
|
+
'checked',
|
|
25
|
+
'selected',
|
|
26
|
+
'default-checked',
|
|
27
|
+
'default-selected',
|
|
28
|
+
'size',
|
|
29
|
+
'disabled',
|
|
30
|
+
'readonly',
|
|
31
|
+
'has-label',
|
|
32
|
+
'name',
|
|
33
|
+
'value',
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
get checked() {
|
|
37
|
+
return this.hasAttribute('checked') || this.hasAttribute('selected');
|
|
38
|
+
}
|
|
39
|
+
set checked(value) {
|
|
40
|
+
this.toggleAttribute('checked', value);
|
|
41
|
+
this.syncFormValue();
|
|
42
|
+
this.syncClasses();
|
|
43
|
+
}
|
|
44
|
+
get name() {
|
|
45
|
+
return this.getAttribute('name') ?? '';
|
|
46
|
+
}
|
|
47
|
+
set name(value) {
|
|
48
|
+
this.setAttribute('name', value);
|
|
49
|
+
}
|
|
50
|
+
get disabled() {
|
|
51
|
+
return this.hasAttribute('disabled');
|
|
52
|
+
}
|
|
53
|
+
set disabled(value) {
|
|
54
|
+
this.toggleAttribute('disabled', value);
|
|
55
|
+
if (this.root)
|
|
56
|
+
this.root.disabled = value;
|
|
57
|
+
this.syncClasses();
|
|
58
|
+
}
|
|
59
|
+
get readOnly() {
|
|
60
|
+
return this.hasAttribute('readonly');
|
|
61
|
+
}
|
|
62
|
+
set readOnly(value) {
|
|
63
|
+
this.toggleAttribute('readonly', value);
|
|
64
|
+
this.syncClasses();
|
|
65
|
+
}
|
|
66
|
+
get size() {
|
|
67
|
+
return this.getAttribute('size') || 'm';
|
|
68
|
+
}
|
|
69
|
+
set size(value) {
|
|
70
|
+
this.setAttribute('size', value);
|
|
71
|
+
}
|
|
72
|
+
connectedCallback() {
|
|
73
|
+
this.style.display = 'contents';
|
|
74
|
+
if (!this.built) {
|
|
75
|
+
this.build();
|
|
76
|
+
}
|
|
77
|
+
this.syncState();
|
|
78
|
+
}
|
|
79
|
+
attributeChangedCallback() {
|
|
80
|
+
if (!this.built)
|
|
81
|
+
return;
|
|
82
|
+
this.syncState();
|
|
83
|
+
}
|
|
84
|
+
formResetCallback() {
|
|
85
|
+
const defaultChecked = this.hasAttribute('default-checked') || this.hasAttribute('default-selected');
|
|
86
|
+
this.toggleAttribute('checked', defaultChecked);
|
|
87
|
+
this.syncFormValue();
|
|
88
|
+
this.syncState();
|
|
89
|
+
}
|
|
90
|
+
formDisabledCallback(disabled) {
|
|
91
|
+
this.toggleAttribute('disabled', disabled);
|
|
92
|
+
if (this.root)
|
|
93
|
+
this.root.disabled = disabled;
|
|
94
|
+
this.syncClasses();
|
|
95
|
+
}
|
|
96
|
+
get hasLabel() {
|
|
97
|
+
return !this.hasAttribute('has-label') || this.getAttribute('has-label') !== 'false';
|
|
98
|
+
}
|
|
99
|
+
syncFormValue() {
|
|
100
|
+
const checked = this.hasAttribute('checked') || this.hasAttribute('selected');
|
|
101
|
+
this.internals.setFormValue(checked ? (this.getAttribute('value') || 'on') : null);
|
|
102
|
+
}
|
|
103
|
+
build() {
|
|
104
|
+
this.root = document.createElement('button');
|
|
105
|
+
this.root.type = 'button';
|
|
106
|
+
this.root.className = 'designbase-wc-toggle';
|
|
107
|
+
const track = document.createElement('span');
|
|
108
|
+
track.className = 'designbase-wc-toggle__track';
|
|
109
|
+
track.setAttribute('aria-hidden', 'true');
|
|
110
|
+
const thumb = document.createElement('span');
|
|
111
|
+
thumb.className = 'designbase-wc-toggle__thumb';
|
|
112
|
+
track.appendChild(thumb);
|
|
113
|
+
this.labelEl = document.createElement('span');
|
|
114
|
+
this.labelEl.className = 'designbase-wc-toggle__label';
|
|
115
|
+
while (this.firstChild) {
|
|
116
|
+
this.labelEl.appendChild(this.firstChild);
|
|
117
|
+
}
|
|
118
|
+
this.root.append(track, this.labelEl);
|
|
119
|
+
this.appendChild(this.root);
|
|
120
|
+
this.root.addEventListener('click', this.handleClick);
|
|
121
|
+
this.built = true;
|
|
122
|
+
}
|
|
123
|
+
syncState() {
|
|
124
|
+
if (!this.root)
|
|
125
|
+
return;
|
|
126
|
+
this.root.disabled = this.disabled;
|
|
127
|
+
this.syncFormValue();
|
|
128
|
+
if (this.hasLabel) {
|
|
129
|
+
this.labelEl?.removeAttribute('hidden');
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
this.labelEl?.setAttribute('hidden', '');
|
|
133
|
+
}
|
|
134
|
+
this.syncClasses();
|
|
135
|
+
}
|
|
136
|
+
syncClasses() {
|
|
137
|
+
if (!this.root)
|
|
138
|
+
return;
|
|
139
|
+
const size = SIZES.includes(this.size) ? this.size : 'm';
|
|
140
|
+
const hasLabelText = this.hasLabel && Boolean(this.labelEl?.textContent?.trim());
|
|
141
|
+
const checked = this.hasAttribute('checked')
|
|
142
|
+
|| this.hasAttribute('selected')
|
|
143
|
+
|| (!this.hasAttribute('checked')
|
|
144
|
+
&& !this.hasAttribute('selected')
|
|
145
|
+
&& (this.hasAttribute('default-checked') || this.hasAttribute('default-selected')));
|
|
146
|
+
this.root.className = [
|
|
147
|
+
'designbase-wc-toggle',
|
|
148
|
+
`designbase-wc-toggle--${size}`,
|
|
149
|
+
checked && 'designbase-wc-toggle--selected',
|
|
150
|
+
this.disabled && 'designbase-wc-toggle--disabled',
|
|
151
|
+
this.readOnly && 'designbase-wc-toggle--readonly',
|
|
152
|
+
!hasLabelText && 'designbase-wc-toggle--no-label',
|
|
153
|
+
].filter(Boolean).join(' ');
|
|
154
|
+
this.root.setAttribute('aria-pressed', String(checked));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
DbToggle.formAssociated = true;
|
|
158
|
+
if (!customElements.get('db-toggle')) {
|
|
159
|
+
customElements.define('db-toggle', DbToggle);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export { DbToggle };
|
|
@@ -1 +1,94 @@
|
|
|
1
|
-
class DbToolbar extends HTMLElement
|
|
1
|
+
class DbToolbar extends HTMLElement {
|
|
2
|
+
static get observedAttributes() {
|
|
3
|
+
return ['items', 'size', 'variant', 'position', 'full-width', 'shadow', 'rounded', 'fixed'];
|
|
4
|
+
}
|
|
5
|
+
get items() {
|
|
6
|
+
try {
|
|
7
|
+
return JSON.parse(this.getAttribute('items') || '[]');
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
set items(value) {
|
|
14
|
+
this.setAttribute('items', typeof value === 'string' ? value : JSON.stringify(value));
|
|
15
|
+
}
|
|
16
|
+
connectedCallback() {
|
|
17
|
+
this.render();
|
|
18
|
+
}
|
|
19
|
+
attributeChangedCallback(name) {
|
|
20
|
+
if (name === 'items') {
|
|
21
|
+
this.render();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.syncHostClasses();
|
|
25
|
+
}
|
|
26
|
+
syncHostClasses() {
|
|
27
|
+
const size = this.getAttribute('size') || 'm';
|
|
28
|
+
const variant = this.getAttribute('variant') || 'default';
|
|
29
|
+
const position = this.getAttribute('position') || 'top';
|
|
30
|
+
this.className = [
|
|
31
|
+
'designbase-wc-toolbar',
|
|
32
|
+
`designbase-wc-toolbar--size-${size}`,
|
|
33
|
+
`designbase-wc-toolbar--variant-${variant}`,
|
|
34
|
+
`designbase-wc-toolbar--position-${position}`,
|
|
35
|
+
this.hasAttribute('full-width') && 'designbase-wc-toolbar--full-width',
|
|
36
|
+
this.hasAttribute('fixed') && 'designbase-wc-toolbar--fixed',
|
|
37
|
+
this.hasAttribute('shadow') && 'designbase-wc-toolbar--shadow',
|
|
38
|
+
this.hasAttribute('rounded') && 'designbase-wc-toolbar--rounded',
|
|
39
|
+
]
|
|
40
|
+
.filter(Boolean)
|
|
41
|
+
.join(' ');
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
this.syncHostClasses();
|
|
45
|
+
this.setAttribute('role', 'toolbar');
|
|
46
|
+
let content = this.querySelector('.designbase-wc-toolbar__content');
|
|
47
|
+
if (!content) {
|
|
48
|
+
content = document.createElement('div');
|
|
49
|
+
content.className = 'designbase-wc-toolbar__content';
|
|
50
|
+
this.replaceChildren(content);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
content.replaceChildren();
|
|
54
|
+
}
|
|
55
|
+
const group = document.createElement('div');
|
|
56
|
+
group.className = 'designbase-wc-toolbar__group';
|
|
57
|
+
content.append(group);
|
|
58
|
+
this.items.forEach((item) => {
|
|
59
|
+
if (item.type === 'separator') {
|
|
60
|
+
const separator = document.createElement('div');
|
|
61
|
+
separator.className = 'designbase-wc-toolbar__item designbase-wc-toolbar__item--separator';
|
|
62
|
+
separator.setAttribute('role', 'separator');
|
|
63
|
+
group.append(separator);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const button = document.createElement('button');
|
|
67
|
+
button.type = 'button';
|
|
68
|
+
button.className = [
|
|
69
|
+
'designbase-wc-toolbar__item',
|
|
70
|
+
'designbase-wc-toolbar__item--button',
|
|
71
|
+
item.active && 'designbase-wc-toolbar__item--active',
|
|
72
|
+
item.disabled && 'designbase-wc-toolbar__item--disabled',
|
|
73
|
+
]
|
|
74
|
+
.filter(Boolean)
|
|
75
|
+
.join(' ');
|
|
76
|
+
button.textContent = item.label || item.id;
|
|
77
|
+
button.disabled = Boolean(item.disabled);
|
|
78
|
+
if (item.tooltip)
|
|
79
|
+
button.title = item.tooltip;
|
|
80
|
+
button.addEventListener('click', () => {
|
|
81
|
+
this.dispatchEvent(new CustomEvent('db-item-click', {
|
|
82
|
+
detail: { item },
|
|
83
|
+
bubbles: true,
|
|
84
|
+
composed: true,
|
|
85
|
+
}));
|
|
86
|
+
});
|
|
87
|
+
group.append(button);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (!customElements.get('db-toolbar'))
|
|
92
|
+
customElements.define('db-toolbar', DbToolbar);
|
|
93
|
+
|
|
94
|
+
export { DbToolbar };
|