@designbasekorea/ui-wc 0.5.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/lottie-0e23d630.js +1 -0
- package/dist/esm/components/animation-background/canvas-controller.js +1 -121
- package/dist/esm/components/animation-background/controls.js +1 -180
- package/dist/esm/components/animation-background/graphite-controller.js +1 -196
- package/dist/esm/components/animation-background/graphite-presets.js +1 -42
- package/dist/esm/components/animation-background/graphite-shader.js +1 -111
- package/dist/esm/components/animation-background/layers.js +1 -369
- package/dist/esm/components/animation-background/lumina-presets.js +1 -53
- package/dist/esm/components/animation-background/lumina-shaders.js +1 -181
- package/dist/esm/components/animation-background/lumina-utils.js +1 -60
- package/dist/esm/components/animation-background/particle-defaults.js +1 -36
- package/dist/esm/components/animation-background/renderers.js +1 -167
- package/dist/esm/components/animation-background/shader-controller.js +1 -154
- package/dist/esm/components/color-picker-utils.js +1 -134
- package/dist/esm/components/date-picker-utils.js +1 -140
- package/dist/esm/components/db-accordion.js +1 -304
- package/dist/esm/components/db-ad-banner.js +1 -455
- package/dist/esm/components/db-ai-chat-list.d.ts +43 -0
- package/dist/esm/components/db-ai-chat-list.js +1 -0
- package/dist/esm/components/db-ai-chat.d.ts +159 -0
- package/dist/esm/components/db-ai-chat.js +1 -0
- package/dist/esm/components/db-alert.js +1 -149
- package/dist/esm/components/db-animation-background.js +1 -486
- package/dist/esm/components/db-animation-text.js +1 -601
- package/dist/esm/components/db-app-badge.js +1 -88
- package/dist/esm/components/db-audio-player.js +1 -752
- package/dist/esm/components/db-avatar.js +1 -188
- package/dist/esm/components/db-backdrop.js +1 -139
- package/dist/esm/components/db-badge.js +1 -91
- package/dist/esm/components/db-banner.js +1 -188
- package/dist/esm/components/db-bottom-navigation.js +1 -146
- package/dist/esm/components/db-bottom-sheet.js +1 -481
- package/dist/esm/components/db-breadcrumbs.js +1 -329
- package/dist/esm/components/db-button.js +1 -316
- package/dist/esm/components/db-calendar.js +1 -675
- package/dist/esm/components/db-card.js +1 -265
- package/dist/esm/components/db-carousel.js +1 -264
- package/dist/esm/components/db-chat-composer.d.ts +134 -0
- package/dist/esm/components/db-chat-composer.js +1 -0
- package/dist/esm/components/db-chat-list.d.ts +47 -0
- package/dist/esm/components/db-chat-list.js +1 -0
- package/dist/esm/components/db-chat-message.d.ts +39 -0
- package/dist/esm/components/db-chat-message.js +1 -0
- package/dist/esm/components/db-chat-orb.d.ts +99 -0
- package/dist/esm/components/db-chat-orb.js +1 -0
- package/dist/esm/components/db-chat-room.d.ts +71 -0
- package/dist/esm/components/db-chat-room.js +1 -0
- package/dist/esm/components/db-chat-suggestions.d.ts +44 -0
- package/dist/esm/components/db-chat-suggestions.js +1 -0
- package/dist/esm/components/db-chat-typing.d.ts +22 -0
- package/dist/esm/components/db-chat-typing.js +1 -0
- package/dist/esm/components/db-chat-welcome.d.ts +32 -0
- package/dist/esm/components/db-chat-welcome.js +1 -0
- package/dist/esm/components/db-chat-widget.d.ts +146 -0
- package/dist/esm/components/db-chat-widget.js +1 -0
- package/dist/esm/components/db-checkbox.js +1 -202
- package/dist/esm/components/db-chip.js +1 -104
- package/dist/esm/components/db-code-block.js +1 -304
- package/dist/esm/components/db-color-picker.js +1 -746
- package/dist/esm/components/db-confirm.js +1 -191
- package/dist/esm/components/db-container.js +1 -39
- package/dist/esm/components/db-context-menu.js +1 -265
- package/dist/esm/components/db-countdown.js +1 -146
- package/dist/esm/components/db-cursor-follower.js +1 -173
- package/dist/esm/components/db-date-picker.js +1 -837
- package/dist/esm/components/db-divider.js +1 -66
- package/dist/esm/components/db-download-progress.d.ts +89 -0
- package/dist/esm/components/db-download-progress.js +1 -0
- package/dist/esm/components/db-drawer.js +1 -245
- package/dist/esm/components/db-dropdown.js +1 -493
- package/dist/esm/components/db-dropzone.js +1 -266
- package/dist/esm/components/db-email-verify.d.ts +62 -0
- package/dist/esm/components/db-email-verify.js +1 -0
- package/dist/esm/components/db-empty-state.js +1 -97
- package/dist/esm/components/db-file-uploader.js +1 -256
- package/dist/esm/components/db-floating-action-button.js +1 -139
- package/dist/esm/components/db-footer.js +1 -385
- package/dist/esm/components/db-form.js +1 -566
- package/dist/esm/components/db-gantt.js +1 -882
- package/dist/esm/components/db-gradient.js +1 -133
- package/dist/esm/components/db-grid-background.js +1 -909
- package/dist/esm/components/db-grid.js +1 -73
- package/dist/esm/components/db-icons.d.ts +3 -0
- package/dist/esm/components/db-icons.js +1 -82
- package/dist/esm/components/db-image-list.js +1 -214
- package/dist/esm/components/db-image-placeholder.js +1 -96
- package/dist/esm/components/db-image.js +1 -289
- package/dist/esm/components/db-indicator.js +1 -517
- package/dist/esm/components/db-input.js +1 -420
- package/dist/esm/components/db-kanban.js +1 -538
- package/dist/esm/components/db-label.js +1 -66
- package/dist/esm/components/db-lightbox.js +1 -372
- package/dist/esm/components/db-list.js +1 -340
- package/dist/esm/components/db-logo-svg.js +1 -72
- package/dist/esm/components/db-logo.js +1 -106
- package/dist/esm/components/db-lottie.js +1 -109
- package/dist/esm/components/db-markdown-editor.js +1 -458
- package/dist/esm/components/db-marquee.js +1 -402
- package/dist/esm/components/db-masonry.js +1 -94
- package/dist/esm/components/db-menu-item.js +1 -211
- package/dist/esm/components/db-modal.js +1 -522
- package/dist/esm/components/db-navbar.js +1 -680
- package/dist/esm/components/db-onboarding-modal.js +1 -322
- package/dist/esm/components/db-otp-input.d.ts +53 -0
- package/dist/esm/components/db-otp-input.js +1 -0
- package/dist/esm/components/db-page-header.js +1 -312
- package/dist/esm/components/db-pagination.js +1 -271
- package/dist/esm/components/db-phone-verify.d.ts +61 -0
- package/dist/esm/components/db-phone-verify.js +1 -0
- package/dist/esm/components/db-popover.js +1 -580
- package/dist/esm/components/db-progress-step.js +1 -166
- package/dist/esm/components/db-progress.js +1 -171
- package/dist/esm/components/db-progressbar.js +1 -72
- package/dist/esm/components/db-radio.js +1 -172
- package/dist/esm/components/db-random-gradient.js +1 -121
- package/dist/esm/components/db-range-slider.js +1 -811
- package/dist/esm/components/db-rating.js +1 -325
- package/dist/esm/components/db-reorder.js +1 -286
- package/dist/esm/components/db-resizable-panels.js +1 -282
- package/dist/esm/components/db-scroll-area.js +1 -126
- package/dist/esm/components/db-search-bar.js +1 -668
- package/dist/esm/components/db-section-app-download.js +1 -101
- package/dist/esm/components/db-section-contact.js +1 -102
- package/dist/esm/components/db-section-cta.js +1 -150
- package/dist/esm/components/db-section-faq.js +1 -120
- package/dist/esm/components/db-section-feature-grid.js +1 -137
- package/dist/esm/components/db-section-feature.js +1 -179
- package/dist/esm/components/db-section-hero.js +1 -243
- package/dist/esm/components/db-section-logo-cloud.js +1 -138
- package/dist/esm/components/db-section-pricing.js +1 -166
- package/dist/esm/components/db-section-stats.js +1 -129
- package/dist/esm/components/db-section-testimonials.js +1 -252
- package/dist/esm/components/db-section.js +1 -385
- package/dist/esm/components/db-segment-control.js +1 -231
- package/dist/esm/components/db-select.js +1 -571
- package/dist/esm/components/db-share-icons.js +1 -40
- package/dist/esm/components/db-share.js +1 -489
- package/dist/esm/components/db-sidebar.js +1 -1068
- package/dist/esm/components/db-skeleton.js +1 -94
- package/dist/esm/components/db-spinner.js +1 -102
- package/dist/esm/components/db-split-view.js +1 -297
- package/dist/esm/components/db-stack.js +1 -46
- package/dist/esm/components/db-stat.js +1 -218
- package/dist/esm/components/db-stepper.js +1 -398
- package/dist/esm/components/db-table.js +1 -412
- package/dist/esm/components/db-tabs.js +1 -335
- package/dist/esm/components/db-testimonial.d.ts +2 -0
- package/dist/esm/components/db-testimonial.js +1 -162
- package/dist/esm/components/db-textarea.js +1 -233
- package/dist/esm/components/db-time-picker.js +1 -523
- package/dist/esm/components/db-timeline.js +1 -174
- package/dist/esm/components/db-toast.js +1 -158
- package/dist/esm/components/db-toggle.js +1 -162
- package/dist/esm/components/db-toolbar.js +1 -94
- package/dist/esm/components/db-tooltip.js +1 -440
- package/dist/esm/components/db-top-banner.js +1 -121
- package/dist/esm/components/db-tutorial.js +1 -324
- package/dist/esm/components/db-two-factor.d.ts +60 -0
- package/dist/esm/components/db-two-factor.js +1 -0
- package/dist/esm/components/db-video-player.js +1 -503
- package/dist/esm/components/db-youtube-player.js +1 -194
- package/dist/esm/components/highlight-code.js +1 -65
- package/dist/esm/components/input-validation.js +1 -50
- package/dist/esm/components/marketing-block-host-utils.js +1 -9
- package/dist/esm/components/number-scrub.js +1 -117
- package/dist/esm/components/random-gradient-palettes.js +1 -67
- package/dist/esm/components/section-block-header-utils.js +1 -48
- package/dist/esm/helpers/confirm.js +1 -52
- package/dist/esm/helpers/toast.js +1 -73
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +1 -111
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-bash.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-clike.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-css.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-javascript.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-json.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-jsx.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-markup.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-scss.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-tsx.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-typescript.js +1 -0
- package/dist/index.cjs +1 -55414
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1091 -2
- package/dist/index.esm.js +1 -38284
- package/dist/react/chunks/lottie-14e7addb.js +1 -0
- package/dist/react/index.cjs +1 -56503
- package/dist/react/index.d.ts +1620 -54
- package/dist/react/index.esm.js +1 -39373
- package/package.json +1 -1
- package/dist/chunks/lottie-e273b936.js +0 -17032
- package/dist/esm/node_modules/prismjs/components/prism-bash.js +0 -235
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -31
- package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -64
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -172
- package/dist/esm/node_modules/prismjs/components/prism-json.js +0 -27
- package/dist/esm/node_modules/prismjs/components/prism-jsx.js +0 -143
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -186
- package/dist/esm/node_modules/prismjs/components/prism-scss.js +0 -81
- package/dist/esm/node_modules/prismjs/components/prism-tsx.js +0 -15
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -60
- package/dist/react/chunks/lottie-72a4c6d4.js +0 -17032
|
@@ -1,174 +1 @@
|
|
|
1
|
-
import
|
|
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
|
+
import{isDbIconName as e,createDbIcon as t}from"./db-icons.js";const i="designbase-wc-timeline";class DbTimeline extends HTMLElement{static get observedAttributes(){return["items","type","variant","size","color","clickable","full-width","disabled"]}connectedCallback(){this.style.display="block",this.render()}attributeChangedCallback(){this.isConnected&&this.render()}get items(){try{return JSON.parse(this.getAttribute("items")||"[]")}catch{return[]}}set items(e){this.setAttribute("items","string"==typeof e?e:JSON.stringify(e))}getItemPosition(e){return"left"===(this.getAttribute("type")||"alternate")||e%2==0?"left":"right"}handleItemClick(e,t){this.hasAttribute("disabled")||e.disabled||!this.hasAttribute("clickable")||this.dispatchEvent(new CustomEvent("db-item-click",{bubbles:!0,composed:!0,detail:{item:e,index:t}}))}render(){const n=this.getAttribute("type")||"alternate",s=this.getAttribute("variant")||"default",a=this.getAttribute("size")||"m",l=this.getAttribute("color")||"primary",c=this.hasAttribute("clickable"),d=this.hasAttribute("disabled"),o=this.items;this.className=[i,`${i}--${n}`,`${i}--${s}`,`${i}--${a}`,c&&`${i}--clickable`,this.hasAttribute("full-width")&&`${i}--full-width`,d&&`${i}--disabled`].filter(Boolean).join(" "),this.replaceChildren();const r=document.createElement("div");r.className=`${i}__container`,o.forEach((n,m)=>{const b=this.getItemPosition(m),u=m===o.length-1,p=c&&!d&&!n.disabled,h=n.color||l,_=n.status||"pending",$=document.createElement("div");$.className=[`${i}__item`,`${i}__item--${b}`,`${i}__item--${h}`,p&&`${i}__item--clickable`,n.disabled&&`${i}__item--disabled`].filter(Boolean).join(" ");const v=document.createElement("div");if(v.className=`${i}__indicator-container`,"active"===_&&!n.icon&&void 0===n.number){const e=document.createElement("div");e.className=`${i}__pulse`,v.append(e)}const E=document.createElement("div");if(E.className=[`${i}__dot`,`${i}__dot--${h}`,`${i}__dot--${s}`,`${i}__dot--${_}`,p&&`${i}__dot--clickable`,n.icon&&`${i}__dot--with-icon`,void 0!==n.number&&!n.icon&&`${i}__dot--with-number`].filter(Boolean).join(" "),p&&(E.tabIndex=0,E.setAttribute("role","button"),E.setAttribute("aria-label",n.title?`${n.title} 타임라인 점`:`타임라인 점 ${m+1}`),E.addEventListener("click",()=>this.handleItemClick(n,m)),E.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleItemClick(n,m))})),n.icon&&e(n.icon)){const e=document.createElement("div");e.className=`${i}__icon`,e.append(t(n.icon,"s"===a?14:"l"===a?20:16)),E.append(e)}else if(void 0!==n.number){const e=document.createElement("span");e.className=`${i}__number`,e.textContent=String(n.number),E.append(e)}if(v.append(E),!u){const e=document.createElement("div");e.className=`${i}__connector`,v.append(e)}const f=document.createElement("div");if(f.className=[`${i}__content`,`${i}__content--${b}`].join(" "),n.timestamp){const e=document.createElement("div");e.className=`${i}__timestamp`,e.textContent=n.timestamp,f.append(e)}const k=document.createElement("div");if(k.className=`${i}__content-inner`,p&&(k.tabIndex=0,k.setAttribute("role","button"),k.setAttribute("aria-label",n.title?`${n.title} 타임라인 아이템`:`타임라인 아이템 ${m+1}`),k.addEventListener("click",()=>this.handleItemClick(n,m)),k.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleItemClick(n,m))})),n.title){const e=document.createElement("h3");e.className=`${i}__title`,e.textContent=n.title,k.append(e)}if(n.description){const e=document.createElement("p");e.className=`${i}__description`,e.textContent=n.description,k.append(e)}f.append(k),$.append(v,f),r.append($)}),this.append(r)}}customElements.get("db-timeline")||customElements.define("db-timeline",DbTimeline);export{DbTimeline};
|
|
@@ -1,158 +1 @@
|
|
|
1
|
-
import
|
|
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
|
+
import{createDbIcon as t}from"./db-icons.js";class DbToast extends HTMLElement{constructor(){super(...arguments),this.timeoutId=null,this.progressInterval=null,this.closeTimerId=null,this.closed=!1}static get observedAttributes(){return["toast-id","status","title","description","duration","show-close","show-progress","auto-remove"]}connectedCallback(){this.closed=!1,this.render(),this.startTimers(),requestAnimationFrame(()=>this.classList.add("designbase-wc-toast--visible"))}disconnectedCallback(){this.clearTimers(),this.closeTimerId&&clearTimeout(this.closeTimerId),this.closeTimerId=null}attributeChangedCallback(t){if(!this.isConnected||this.closed)return;const e=this.classList.contains("designbase-wc-toast--visible");this.render(),e&&requestAnimationFrame(()=>this.classList.add("designbase-wc-toast--visible")),"duration"!==t&&"show-progress"!==t||(this.clearTimers(),this.startTimers())}clearTimers(){this.timeoutId&&clearTimeout(this.timeoutId),this.progressInterval&&clearInterval(this.progressInterval),this.timeoutId=null,this.progressInterval=null}startTimers(){const t=Number(this.getAttribute("duration")??"5000");if(!Number.isFinite(t)||t<=0)return;if("false"!==this.getAttribute("show-progress")&&this.hasAttribute("show-progress")){const e=this.querySelector(".designbase-wc-toast__progress-bar");e&&(e.style.width="0%");const s=Date.now();return void(this.progressInterval=setInterval(()=>{const i=Date.now()-s,o=Math.min(100,i/t*100);e&&(e.style.width=`${o}%`),o>=100&&this.close()},16))}this.timeoutId=setTimeout(()=>this.close(),t)}close(){this.closed||(this.closed=!0,this.clearTimers(),this.classList.remove("designbase-wc-toast--visible"),this.classList.add("designbase-wc-toast--closing"),this.closeTimerId&&clearTimeout(this.closeTimerId),this.closeTimerId=setTimeout(()=>{this.dispatchEvent(new CustomEvent("db-close",{bubbles:!0,composed:!0,detail:{id:this.getAttribute("toast-id")||""}}));("true"===this.getAttribute("auto-remove")||this.hasAttribute("auto-remove")&&"false"!==this.getAttribute("auto-remove"))&&this.remove()},300))}iconForStatus(t){return"success"===t?"circle-checked":"warning"===t?"warning-filled":"error"===t?"error-filled":"info-filled"}render(){const e=this.getAttribute("status")||"info",s=this.getAttribute("title")||"",i=this.getAttribute("description")||"",o="false"!==this.getAttribute("show-close"),r="false"!==this.getAttribute("show-progress")&&this.hasAttribute("show-progress");if(this.className=["designbase-wc-toast",`designbase-wc-toast--${e}`,this.closed&&"designbase-wc-toast--closing"].filter(Boolean).join(" "),this.setAttribute("role","alert"),this.setAttribute("aria-live","assertive"),this.replaceChildren(),r){const t=document.createElement("div");t.className="designbase-wc-toast__progress";const e=document.createElement("div");e.className="designbase-wc-toast__progress-bar",e.style.width="0%",t.append(e),this.append(t)}const a=document.createElement("div");a.className=`designbase-wc-toast__icon designbase-wc-toast__icon--${e}`,a.append(t(this.iconForStatus(e),20));const n=document.createElement("div");n.className="designbase-wc-toast__content";const c=document.createElement("div");if(c.className="designbase-wc-toast__title",c.textContent=s,n.append(c),i){const t=document.createElement("div");t.className="designbase-wc-toast__description",t.textContent=i,n.append(t)}if(this.append(a,n),o){const e=document.createElement("button");e.type="button",e.className="designbase-wc-toast__close-button",e.setAttribute("aria-label","토스트 닫기"),e.append(t("close",20)),e.addEventListener("click",()=>this.close()),this.append(e)}}}customElements.get("db-toast")||customElements.define("db-toast",DbToast);export{DbToast};
|
|
@@ -1,162 +1 @@
|
|
|
1
|
-
const
|
|
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
|
+
const t=["s","m","l"];class DbToggle extends HTMLElement{constructor(){super(...arguments),this.internals=this.attachInternals(),this.built=!1,this.handleClick=()=>{if(this.disabled||this.readOnly)return;const t=!this.checked;this.toggleAttribute("checked",t),this.syncFormValue(),this.syncState(),this.dispatchEvent(new Event("change",{bubbles:!0})),this.dispatchEvent(new CustomEvent("db-change",{detail:{checked:t,selected:t},bubbles:!0,composed:!0}))}}static get observedAttributes(){return["checked","selected","default-checked","default-selected","size","disabled","readonly","has-label","name","value"]}get checked(){return this.hasAttribute("checked")||this.hasAttribute("selected")}set checked(t){this.toggleAttribute("checked",t),this.syncFormValue(),this.syncClasses()}get name(){return this.getAttribute("name")??""}set name(t){this.setAttribute("name",t)}get disabled(){return this.hasAttribute("disabled")}set disabled(t){this.toggleAttribute("disabled",t),this.root&&(this.root.disabled=t),this.syncClasses()}get readOnly(){return this.hasAttribute("readonly")}set readOnly(t){this.toggleAttribute("readonly",t),this.syncClasses()}get size(){return this.getAttribute("size")||"m"}set size(t){this.setAttribute("size",t)}connectedCallback(){this.style.display="contents",this.built||this.build(),this.syncState()}attributeChangedCallback(){this.built&&this.syncState()}formResetCallback(){const t=this.hasAttribute("default-checked")||this.hasAttribute("default-selected");this.toggleAttribute("checked",t),this.syncFormValue(),this.syncState()}formDisabledCallback(t){this.toggleAttribute("disabled",t),this.root&&(this.root.disabled=t),this.syncClasses()}get hasLabel(){return!this.hasAttribute("has-label")||"false"!==this.getAttribute("has-label")}syncFormValue(){const t=this.hasAttribute("checked")||this.hasAttribute("selected");this.internals.setFormValue(t?this.getAttribute("value")||"on":null)}build(){this.root=document.createElement("button"),this.root.type="button",this.root.className="designbase-wc-toggle";const t=document.createElement("span");t.className="designbase-wc-toggle__track",t.setAttribute("aria-hidden","true");const e=document.createElement("span");for(e.className="designbase-wc-toggle__thumb",t.appendChild(e),this.labelEl=document.createElement("span"),this.labelEl.className="designbase-wc-toggle__label";this.firstChild;)this.labelEl.appendChild(this.firstChild);this.root.append(t,this.labelEl),this.appendChild(this.root),this.root.addEventListener("click",this.handleClick),this.built=!0}syncState(){this.root&&(this.root.disabled=this.disabled,this.syncFormValue(),this.hasLabel?this.labelEl?.removeAttribute("hidden"):this.labelEl?.setAttribute("hidden",""),this.syncClasses())}syncClasses(){if(!this.root)return;const e=t.includes(this.size)?this.size:"m",s=this.hasLabel&&Boolean(this.labelEl?.textContent?.trim()),i=this.hasAttribute("checked")||this.hasAttribute("selected")||!this.hasAttribute("checked")&&!this.hasAttribute("selected")&&(this.hasAttribute("default-checked")||this.hasAttribute("default-selected"));this.root.className=["designbase-wc-toggle",`designbase-wc-toggle--${e}`,i&&"designbase-wc-toggle--selected",this.disabled&&"designbase-wc-toggle--disabled",this.readOnly&&"designbase-wc-toggle--readonly",!s&&"designbase-wc-toggle--no-label"].filter(Boolean).join(" "),this.root.setAttribute("aria-pressed",String(i))}}DbToggle.formAssociated=!0,customElements.get("db-toggle")||customElements.define("db-toggle",DbToggle);export{DbToggle};
|
|
@@ -1,94 +1 @@
|
|
|
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 };
|
|
1
|
+
class DbToolbar extends HTMLElement{static get observedAttributes(){return["items","size","variant","position","full-width","shadow","rounded","fixed"]}get items(){try{return JSON.parse(this.getAttribute("items")||"[]")}catch{return[]}}set items(t){this.setAttribute("items","string"==typeof t?t:JSON.stringify(t))}connectedCallback(){this.render()}attributeChangedCallback(t){"items"!==t?this.syncHostClasses():this.render()}syncHostClasses(){const t=this.getAttribute("size")||"m",e=this.getAttribute("variant")||"default",s=this.getAttribute("position")||"top";this.className=["designbase-wc-toolbar",`designbase-wc-toolbar--size-${t}`,`designbase-wc-toolbar--variant-${e}`,`designbase-wc-toolbar--position-${s}`,this.hasAttribute("full-width")&&"designbase-wc-toolbar--full-width",this.hasAttribute("fixed")&&"designbase-wc-toolbar--fixed",this.hasAttribute("shadow")&&"designbase-wc-toolbar--shadow",this.hasAttribute("rounded")&&"designbase-wc-toolbar--rounded"].filter(Boolean).join(" ")}render(){this.syncHostClasses(),this.setAttribute("role","toolbar");let t=this.querySelector(".designbase-wc-toolbar__content");t?t.replaceChildren():(t=document.createElement("div"),t.className="designbase-wc-toolbar__content",this.replaceChildren(t));const e=document.createElement("div");e.className="designbase-wc-toolbar__group",t.append(e),this.items.forEach(t=>{if("separator"===t.type){const t=document.createElement("div");return t.className="designbase-wc-toolbar__item designbase-wc-toolbar__item--separator",t.setAttribute("role","separator"),void e.append(t)}const s=document.createElement("button");s.type="button",s.className=["designbase-wc-toolbar__item","designbase-wc-toolbar__item--button",t.active&&"designbase-wc-toolbar__item--active",t.disabled&&"designbase-wc-toolbar__item--disabled"].filter(Boolean).join(" "),s.textContent=t.label||t.id,s.disabled=Boolean(t.disabled),t.tooltip&&(s.title=t.tooltip),s.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("db-item-click",{detail:{item:t},bubbles:!0,composed:!0}))}),e.append(s)})}}customElements.get("db-toolbar")||customElements.define("db-toolbar",DbToolbar);export{DbToolbar};
|