@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,188 @@
|
|
|
1
|
-
import{createDbIcon
|
|
1
|
+
import { createDbIcon } from './db-icons.js';
|
|
2
|
+
|
|
3
|
+
const SIZES = ['xs', 's', 'm', 'l', 'xl', '2xl'];
|
|
4
|
+
const VARIANTS = ['default', 'primary', 'success', 'warning', 'danger', 'info'];
|
|
5
|
+
const STATUSES = ['online', 'offline', 'away', 'busy'];
|
|
6
|
+
const LIGHT_COLORS = ['#E3F2FD', '#F3E5F5', '#E8F5E8', '#FFF3E0', '#FCE4EC', '#E0F2F1', '#FFF8E1', '#F1F8E9', '#E8EAF6', '#FFEBEE'];
|
|
7
|
+
const DARK_COLORS = ['#1976D2', '#7B1FA2', '#388E3C', '#F57C00', '#C2185B', '#00796B', '#F9A825', '#689F38', '#3F51B5', '#D32F2F'];
|
|
8
|
+
function initialsColor(text) {
|
|
9
|
+
let hash = 0;
|
|
10
|
+
for (let i = 0; i < text.length; i++) {
|
|
11
|
+
hash = text.charCodeAt(i) + ((hash << 5) - hash);
|
|
12
|
+
}
|
|
13
|
+
const index = Math.abs(hash) % LIGHT_COLORS.length;
|
|
14
|
+
return { backgroundColor: LIGHT_COLORS[index], color: DARK_COLORS[index] };
|
|
15
|
+
}
|
|
16
|
+
function iconSize(size) {
|
|
17
|
+
if (size === 'xs')
|
|
18
|
+
return 12;
|
|
19
|
+
if (size === 's')
|
|
20
|
+
return 16;
|
|
21
|
+
if (size === 'm')
|
|
22
|
+
return 20;
|
|
23
|
+
if (size === 'l')
|
|
24
|
+
return 24;
|
|
25
|
+
if (size === 'xl')
|
|
26
|
+
return 32;
|
|
27
|
+
return 40;
|
|
28
|
+
}
|
|
29
|
+
class DbAvatar extends HTMLElement {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.imageFailed = false;
|
|
33
|
+
this.imageLoaded = false;
|
|
34
|
+
this.handleClick = () => {
|
|
35
|
+
if (this.hasAttribute('disabled') || !this.hasAttribute('clickable'))
|
|
36
|
+
return;
|
|
37
|
+
this.dispatchEvent(new CustomEvent('db-click', { bubbles: true, composed: true }));
|
|
38
|
+
};
|
|
39
|
+
this.handleKeyDown = (event) => {
|
|
40
|
+
if (!this.hasAttribute('clickable') || this.hasAttribute('disabled'))
|
|
41
|
+
return;
|
|
42
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
this.handleClick();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
static get observedAttributes() {
|
|
49
|
+
return [
|
|
50
|
+
'src',
|
|
51
|
+
'alt',
|
|
52
|
+
'initials',
|
|
53
|
+
'size',
|
|
54
|
+
'variant',
|
|
55
|
+
'status',
|
|
56
|
+
'disabled',
|
|
57
|
+
'clickable',
|
|
58
|
+
'badge',
|
|
59
|
+
'badge-max-count',
|
|
60
|
+
'badge-variant',
|
|
61
|
+
'badge-style',
|
|
62
|
+
'badge-text',
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
connectedCallback() {
|
|
66
|
+
this.render();
|
|
67
|
+
this.addEventListener('click', this.handleClick);
|
|
68
|
+
this.addEventListener('keydown', this.handleKeyDown);
|
|
69
|
+
}
|
|
70
|
+
disconnectedCallback() {
|
|
71
|
+
this.removeEventListener('click', this.handleClick);
|
|
72
|
+
this.removeEventListener('keydown', this.handleKeyDown);
|
|
73
|
+
}
|
|
74
|
+
attributeChangedCallback(name) {
|
|
75
|
+
if (name === 'src') {
|
|
76
|
+
this.imageFailed = false;
|
|
77
|
+
this.imageLoaded = false;
|
|
78
|
+
}
|
|
79
|
+
this.render();
|
|
80
|
+
}
|
|
81
|
+
render() {
|
|
82
|
+
const size = SIZES.includes((this.getAttribute('size') || 'm'))
|
|
83
|
+
? this.getAttribute('size') || 'm'
|
|
84
|
+
: 'm';
|
|
85
|
+
const variant = VARIANTS.includes((this.getAttribute('variant') || 'default'))
|
|
86
|
+
? this.getAttribute('variant') || 'default'
|
|
87
|
+
: 'default';
|
|
88
|
+
const disabled = this.hasAttribute('disabled');
|
|
89
|
+
const clickable = this.hasAttribute('clickable');
|
|
90
|
+
const src = this.getAttribute('src');
|
|
91
|
+
const initials = this.getAttribute('initials') || '';
|
|
92
|
+
const showImage = Boolean(src && !this.imageFailed);
|
|
93
|
+
const showLoading = showImage && !this.imageLoaded;
|
|
94
|
+
this.className = [
|
|
95
|
+
'designbase-wc-avatar',
|
|
96
|
+
`designbase-wc-avatar--${size}`,
|
|
97
|
+
`designbase-wc-avatar--${variant}`,
|
|
98
|
+
clickable && 'designbase-wc-avatar--clickable',
|
|
99
|
+
disabled && 'designbase-wc-avatar--disabled',
|
|
100
|
+
showLoading && 'designbase-wc-avatar--loading',
|
|
101
|
+
]
|
|
102
|
+
.filter(Boolean)
|
|
103
|
+
.join(' ');
|
|
104
|
+
if (clickable && !disabled) {
|
|
105
|
+
this.setAttribute('role', 'button');
|
|
106
|
+
this.tabIndex = 0;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.removeAttribute('role');
|
|
110
|
+
this.removeAttribute('tabindex');
|
|
111
|
+
}
|
|
112
|
+
this.toggleAttribute('aria-disabled', disabled);
|
|
113
|
+
this.replaceChildren();
|
|
114
|
+
if (showLoading) {
|
|
115
|
+
const loading = document.createElement('div');
|
|
116
|
+
loading.className = 'designbase-wc-avatar__loading';
|
|
117
|
+
const skeleton = document.createElement('div');
|
|
118
|
+
skeleton.className = 'designbase-wc-avatar__skeleton';
|
|
119
|
+
loading.append(skeleton);
|
|
120
|
+
this.append(loading);
|
|
121
|
+
}
|
|
122
|
+
if (showImage) {
|
|
123
|
+
const image = document.createElement('img');
|
|
124
|
+
image.className = 'designbase-wc-avatar__image';
|
|
125
|
+
image.src = src;
|
|
126
|
+
image.alt = this.getAttribute('alt') || '아바타 이미지';
|
|
127
|
+
image.loading = 'lazy';
|
|
128
|
+
image.addEventListener('load', () => {
|
|
129
|
+
this.imageLoaded = true;
|
|
130
|
+
this.classList.remove('designbase-wc-avatar--loading');
|
|
131
|
+
this.querySelector('.designbase-wc-avatar__loading')?.remove();
|
|
132
|
+
});
|
|
133
|
+
image.addEventListener('error', () => {
|
|
134
|
+
this.imageFailed = true;
|
|
135
|
+
this.imageLoaded = false;
|
|
136
|
+
this.render();
|
|
137
|
+
});
|
|
138
|
+
this.append(image);
|
|
139
|
+
}
|
|
140
|
+
else if (initials) {
|
|
141
|
+
const initialsEl = document.createElement('div');
|
|
142
|
+
initialsEl.className = 'designbase-wc-avatar__initials';
|
|
143
|
+
if (variant === 'default') {
|
|
144
|
+
const colors = initialsColor(initials);
|
|
145
|
+
initialsEl.style.backgroundColor = colors.backgroundColor;
|
|
146
|
+
initialsEl.style.color = colors.color;
|
|
147
|
+
}
|
|
148
|
+
initialsEl.textContent = initials.charAt(0).toUpperCase();
|
|
149
|
+
this.append(initialsEl);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const iconWrap = document.createElement('div');
|
|
153
|
+
iconWrap.className = 'designbase-wc-avatar__icon';
|
|
154
|
+
iconWrap.append(createDbIcon('user', iconSize(size)));
|
|
155
|
+
this.append(iconWrap);
|
|
156
|
+
}
|
|
157
|
+
const status = this.getAttribute('status') || '';
|
|
158
|
+
if (STATUSES.includes(status)) {
|
|
159
|
+
const statusElement = document.createElement('span');
|
|
160
|
+
statusElement.className = `designbase-wc-avatar__status designbase-wc-avatar__status--${status}`;
|
|
161
|
+
this.append(statusElement);
|
|
162
|
+
}
|
|
163
|
+
if (this.hasAttribute('badge')) {
|
|
164
|
+
const badgeWrap = document.createElement('div');
|
|
165
|
+
badgeWrap.className = 'designbase-wc-avatar__badge';
|
|
166
|
+
const badge = document.createElement('db-badge');
|
|
167
|
+
badge.setAttribute('count', this.getAttribute('badge') || '0');
|
|
168
|
+
const badgeStyle = this.getAttribute('badge-style') || 'number';
|
|
169
|
+
badge.setAttribute('badge-style', badgeStyle);
|
|
170
|
+
if (this.hasAttribute('badge-max-count')) {
|
|
171
|
+
badge.setAttribute('max-count', this.getAttribute('badge-max-count'));
|
|
172
|
+
}
|
|
173
|
+
badge.setAttribute('variant', this.getAttribute('badge-variant') || 'danger');
|
|
174
|
+
if (this.hasAttribute('badge-text')) {
|
|
175
|
+
badge.textContent = this.getAttribute('badge-text');
|
|
176
|
+
}
|
|
177
|
+
const badgeSize = size === 'xl' || size === '2xl' ? 'm' : 's';
|
|
178
|
+
badge.setAttribute('size', badgeSize);
|
|
179
|
+
badgeWrap.append(badge);
|
|
180
|
+
this.append(badgeWrap);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (!customElements.get('db-avatar')) {
|
|
185
|
+
customElements.define('db-avatar', DbAvatar);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { DbAvatar };
|
|
@@ -1 +1,139 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ANIMATIONS = ['fade', 'slide', 'zoom', 'none'];
|
|
2
|
+
class DbBackdrop extends HTMLElement {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.keyHandler = null;
|
|
6
|
+
this.handlePortalClick = (event) => {
|
|
7
|
+
if (event.target !== this.portal)
|
|
8
|
+
return;
|
|
9
|
+
if (this.getAttribute('disable-backdrop-click') === 'true')
|
|
10
|
+
return;
|
|
11
|
+
this.dispatchEvent(new CustomEvent('db-click', { bubbles: true, composed: true }));
|
|
12
|
+
this.dispatchEvent(new CustomEvent('db-close', { bubbles: true, composed: true }));
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
static get observedAttributes() {
|
|
16
|
+
return [
|
|
17
|
+
'open',
|
|
18
|
+
'blur',
|
|
19
|
+
'opacity',
|
|
20
|
+
'blur-amount',
|
|
21
|
+
'animation',
|
|
22
|
+
'animation-duration',
|
|
23
|
+
'z-index',
|
|
24
|
+
'background-color',
|
|
25
|
+
'disable-backdrop-click',
|
|
26
|
+
'disable-escape-key-down',
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
get open() {
|
|
30
|
+
return this.hasAttribute('open') && this.getAttribute('open') !== 'false';
|
|
31
|
+
}
|
|
32
|
+
set open(value) {
|
|
33
|
+
if (value)
|
|
34
|
+
this.setAttribute('open', '');
|
|
35
|
+
else
|
|
36
|
+
this.removeAttribute('open');
|
|
37
|
+
}
|
|
38
|
+
connectedCallback() {
|
|
39
|
+
this.style.display = 'contents';
|
|
40
|
+
this.syncOpenState();
|
|
41
|
+
}
|
|
42
|
+
disconnectedCallback() {
|
|
43
|
+
this.detachListeners();
|
|
44
|
+
this.portal?.remove();
|
|
45
|
+
this.portal = undefined;
|
|
46
|
+
document.body.style.overflow = '';
|
|
47
|
+
}
|
|
48
|
+
attributeChangedCallback() {
|
|
49
|
+
if (!this.isConnected)
|
|
50
|
+
return;
|
|
51
|
+
this.syncOpenState();
|
|
52
|
+
}
|
|
53
|
+
isOpen() {
|
|
54
|
+
return this.open;
|
|
55
|
+
}
|
|
56
|
+
syncOpenState() {
|
|
57
|
+
if (this.isOpen()) {
|
|
58
|
+
this.render();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
document.body.style.overflow = '';
|
|
62
|
+
this.detachListeners();
|
|
63
|
+
this.portal?.remove();
|
|
64
|
+
}
|
|
65
|
+
collectChildren() {
|
|
66
|
+
return Array.from(this.children).filter((child) => !child.hasAttribute('data-wc-internal'));
|
|
67
|
+
}
|
|
68
|
+
attachListeners() {
|
|
69
|
+
if (this.keyHandler)
|
|
70
|
+
return;
|
|
71
|
+
this.keyHandler = (event) => {
|
|
72
|
+
if (event.key !== 'Escape')
|
|
73
|
+
return;
|
|
74
|
+
if (this.getAttribute('disable-escape-key-down') === 'true')
|
|
75
|
+
return;
|
|
76
|
+
this.dispatchEvent(new CustomEvent('db-click', { bubbles: true, composed: true }));
|
|
77
|
+
this.dispatchEvent(new CustomEvent('db-close', { bubbles: true, composed: true }));
|
|
78
|
+
};
|
|
79
|
+
document.addEventListener('keydown', this.keyHandler);
|
|
80
|
+
}
|
|
81
|
+
detachListeners() {
|
|
82
|
+
if (!this.keyHandler)
|
|
83
|
+
return;
|
|
84
|
+
document.removeEventListener('keydown', this.keyHandler);
|
|
85
|
+
this.keyHandler = null;
|
|
86
|
+
}
|
|
87
|
+
render() {
|
|
88
|
+
if (!this.isOpen()) {
|
|
89
|
+
this.syncOpenState();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const blur = this.hasAttribute('blur');
|
|
93
|
+
const opacity = this.getAttribute('opacity') || '0.5';
|
|
94
|
+
const blurAmount = this.getAttribute('blur-amount') || '4';
|
|
95
|
+
const animation = ANIMATIONS.includes((this.getAttribute('animation') || 'fade'))
|
|
96
|
+
? this.getAttribute('animation') || 'fade'
|
|
97
|
+
: 'fade';
|
|
98
|
+
const animationDuration = this.getAttribute('animation-duration') || '300';
|
|
99
|
+
const zIndex = this.getAttribute('z-index') || '1000';
|
|
100
|
+
const backgroundColor = this.getAttribute('background-color');
|
|
101
|
+
const userChildren = this.collectChildren();
|
|
102
|
+
document.body.style.overflow = 'hidden';
|
|
103
|
+
this.attachListeners();
|
|
104
|
+
if (!this.portal) {
|
|
105
|
+
this.portal = document.createElement('div');
|
|
106
|
+
this.portal.setAttribute('data-wc-internal', '');
|
|
107
|
+
this.portal.addEventListener('click', this.handlePortalClick);
|
|
108
|
+
}
|
|
109
|
+
this.portal.className = [
|
|
110
|
+
'designbase-wc-backdrop',
|
|
111
|
+
`designbase-wc-backdrop--${animation}`,
|
|
112
|
+
'designbase-wc-backdrop--open',
|
|
113
|
+
blur ? 'designbase-wc-backdrop--blur' : '',
|
|
114
|
+
]
|
|
115
|
+
.filter(Boolean)
|
|
116
|
+
.join(' ');
|
|
117
|
+
this.portal.setAttribute('role', 'presentation');
|
|
118
|
+
this.portal.setAttribute('aria-hidden', 'false');
|
|
119
|
+
this.portal.style.setProperty('--backdrop-opacity', opacity);
|
|
120
|
+
this.portal.style.setProperty('--backdrop-blur-amount', `${blurAmount}px`);
|
|
121
|
+
this.portal.style.setProperty('--backdrop-animation-duration', `${animationDuration}ms`);
|
|
122
|
+
this.portal.style.setProperty('--backdrop-z-index', zIndex);
|
|
123
|
+
if (backgroundColor) {
|
|
124
|
+
this.portal.style.backgroundColor = backgroundColor;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
this.portal.style.removeProperty('background-color');
|
|
128
|
+
}
|
|
129
|
+
this.portal.replaceChildren(...userChildren);
|
|
130
|
+
if (!this.portal.isConnected) {
|
|
131
|
+
document.body.append(this.portal);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (!customElements.get('db-backdrop')) {
|
|
136
|
+
customElements.define('db-backdrop', DbBackdrop);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export { DbBackdrop };
|
|
@@ -1 +1,91 @@
|
|
|
1
|
-
const
|
|
1
|
+
const CLASS = 'designbase-wc-badge';
|
|
2
|
+
const VARIANTS = ['primary', 'secondary', 'info', 'success', 'warning', 'danger'];
|
|
3
|
+
const SIZES = ['s', 'm', 'l'];
|
|
4
|
+
const STYLES = ['dot', 'number', 'text', 'outlined'];
|
|
5
|
+
class DbBadge extends HTMLElement {
|
|
6
|
+
static get observedAttributes() {
|
|
7
|
+
return ['variant', 'size', 'badge-style', 'count', 'max-count', 'disabled'];
|
|
8
|
+
}
|
|
9
|
+
get variant() {
|
|
10
|
+
return this.getAttribute('variant') || 'primary';
|
|
11
|
+
}
|
|
12
|
+
set variant(value) {
|
|
13
|
+
this.setAttribute('variant', value);
|
|
14
|
+
}
|
|
15
|
+
get size() {
|
|
16
|
+
return this.getAttribute('size') || 'm';
|
|
17
|
+
}
|
|
18
|
+
set size(value) {
|
|
19
|
+
this.setAttribute('size', value);
|
|
20
|
+
}
|
|
21
|
+
get badgeStyle() {
|
|
22
|
+
return this.getAttribute('badge-style') || 'text';
|
|
23
|
+
}
|
|
24
|
+
set badgeStyle(value) {
|
|
25
|
+
this.setAttribute('badge-style', value);
|
|
26
|
+
}
|
|
27
|
+
get count() {
|
|
28
|
+
const value = this.getAttribute('count');
|
|
29
|
+
return value === null ? undefined : Number(value);
|
|
30
|
+
}
|
|
31
|
+
set count(value) {
|
|
32
|
+
if (value === undefined)
|
|
33
|
+
this.removeAttribute('count');
|
|
34
|
+
else
|
|
35
|
+
this.setAttribute('count', String(value));
|
|
36
|
+
}
|
|
37
|
+
get maxCount() {
|
|
38
|
+
return Number(this.getAttribute('max-count') || 99);
|
|
39
|
+
}
|
|
40
|
+
set maxCount(value) {
|
|
41
|
+
this.setAttribute('max-count', String(value));
|
|
42
|
+
}
|
|
43
|
+
get disabled() {
|
|
44
|
+
return this.hasAttribute('disabled');
|
|
45
|
+
}
|
|
46
|
+
set disabled(value) {
|
|
47
|
+
this.toggleAttribute('disabled', value);
|
|
48
|
+
}
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
this.syncAttributes();
|
|
51
|
+
}
|
|
52
|
+
attributeChangedCallback(name, _oldValue, _newValue) {
|
|
53
|
+
if (name === 'count' || name === 'max-count' || name === 'badge-style') {
|
|
54
|
+
this.syncContent();
|
|
55
|
+
}
|
|
56
|
+
this.syncAttributes();
|
|
57
|
+
}
|
|
58
|
+
syncAttributes() {
|
|
59
|
+
this.classList.add(CLASS);
|
|
60
|
+
this.setAttribute('aria-disabled', String(this.disabled));
|
|
61
|
+
this.syncEnum('variant', this.variant, VARIANTS);
|
|
62
|
+
this.syncEnum('size', this.size, SIZES);
|
|
63
|
+
this.syncEnum('style', this.badgeStyle, STYLES);
|
|
64
|
+
this.classList.toggle(`${CLASS}--disabled`, this.disabled);
|
|
65
|
+
this.syncContent();
|
|
66
|
+
}
|
|
67
|
+
syncContent() {
|
|
68
|
+
if (this.badgeStyle === 'number' && this.count !== undefined) {
|
|
69
|
+
this.textContent =
|
|
70
|
+
this.count > this.maxCount ? `${this.maxCount}+` : String(this.count);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (this.badgeStyle === 'dot') {
|
|
74
|
+
this.textContent = '';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
syncEnum(name, value, values) {
|
|
78
|
+
values.forEach((item) => this.classList.remove(`${CLASS}--${item}`));
|
|
79
|
+
if (values.includes(value)) {
|
|
80
|
+
this.classList.add(`${CLASS}--${value}`);
|
|
81
|
+
}
|
|
82
|
+
else if (name === 'style') {
|
|
83
|
+
this.classList.add(`${CLASS}--text`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (!customElements.get('db-badge')) {
|
|
88
|
+
customElements.define('db-badge', DbBadge);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { DbBadge };
|
|
@@ -1 +1,188 @@
|
|
|
1
|
-
import{createDbIcon
|
|
1
|
+
import { createDbIcon } from './db-icons.js';
|
|
2
|
+
|
|
3
|
+
const BUTTON_VARIANT_MAP = {
|
|
4
|
+
primary: 'primary',
|
|
5
|
+
secondary: 'secondary',
|
|
6
|
+
outline: 'tertiary',
|
|
7
|
+
ghost: 'ghost',
|
|
8
|
+
};
|
|
9
|
+
const BUTTON_SIZE_MAP = {
|
|
10
|
+
s: 's',
|
|
11
|
+
sm: 's',
|
|
12
|
+
m: 'm',
|
|
13
|
+
md: 'm',
|
|
14
|
+
l: 'l',
|
|
15
|
+
lg: 'l',
|
|
16
|
+
};
|
|
17
|
+
class DbBanner extends HTMLElement {
|
|
18
|
+
static get observedAttributes() {
|
|
19
|
+
return [
|
|
20
|
+
'title',
|
|
21
|
+
'description',
|
|
22
|
+
'icon',
|
|
23
|
+
'image',
|
|
24
|
+
'image-alt',
|
|
25
|
+
'actions',
|
|
26
|
+
'size',
|
|
27
|
+
'variant',
|
|
28
|
+
'background-image',
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
connectedCallback() {
|
|
32
|
+
this.render();
|
|
33
|
+
}
|
|
34
|
+
attributeChangedCallback() {
|
|
35
|
+
this.render();
|
|
36
|
+
}
|
|
37
|
+
parseActions() {
|
|
38
|
+
const raw = this.getAttribute('actions');
|
|
39
|
+
if (!raw)
|
|
40
|
+
return [];
|
|
41
|
+
try {
|
|
42
|
+
const parsed = JSON.parse(raw);
|
|
43
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
getIconSize(size) {
|
|
50
|
+
if (size === 's')
|
|
51
|
+
return 16;
|
|
52
|
+
if (size === 'l')
|
|
53
|
+
return 24;
|
|
54
|
+
return 20;
|
|
55
|
+
}
|
|
56
|
+
getActionIconSize(size) {
|
|
57
|
+
if (size === 's')
|
|
58
|
+
return 16;
|
|
59
|
+
if (size === 'l')
|
|
60
|
+
return 20;
|
|
61
|
+
return 18;
|
|
62
|
+
}
|
|
63
|
+
resolveIconName(icon) {
|
|
64
|
+
if (!icon)
|
|
65
|
+
return undefined;
|
|
66
|
+
if (icon in { close: 1, 'info-filled': 1 })
|
|
67
|
+
return icon;
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
createActionControl(action, index, actionVariant, actionSize) {
|
|
71
|
+
const iconName = this.resolveIconName(action.icon);
|
|
72
|
+
const iconOnly = Boolean(action.iconOnly && iconName);
|
|
73
|
+
const bindClick = (element) => {
|
|
74
|
+
element.addEventListener('db-click', () => {
|
|
75
|
+
this.dispatchEvent(new CustomEvent('db-action', {
|
|
76
|
+
bubbles: true,
|
|
77
|
+
composed: true,
|
|
78
|
+
detail: { index, action },
|
|
79
|
+
}));
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
if (action.href) {
|
|
83
|
+
const link = document.createElement('a');
|
|
84
|
+
link.className = `designbase-wc-button designbase-wc-button--${actionVariant} designbase-wc-button--${actionSize}`;
|
|
85
|
+
if (iconOnly)
|
|
86
|
+
link.classList.add('designbase-wc-button--icon-only');
|
|
87
|
+
link.href = action.href;
|
|
88
|
+
link.setAttribute('aria-label', action.text);
|
|
89
|
+
if (iconOnly && iconName) {
|
|
90
|
+
link.append(createDbIcon(iconName, this.getActionIconSize(actionSize)));
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
link.textContent = action.text;
|
|
94
|
+
}
|
|
95
|
+
if (action.external) {
|
|
96
|
+
link.target = '_blank';
|
|
97
|
+
link.rel = 'noopener noreferrer';
|
|
98
|
+
}
|
|
99
|
+
return link;
|
|
100
|
+
}
|
|
101
|
+
const button = document.createElement('db-button');
|
|
102
|
+
button.setAttribute('variant', actionVariant);
|
|
103
|
+
button.setAttribute('size', actionSize);
|
|
104
|
+
if (iconOnly) {
|
|
105
|
+
button.setAttribute('icon-only', '');
|
|
106
|
+
button.setAttribute('aria-label', action.text);
|
|
107
|
+
if (iconName)
|
|
108
|
+
button.append(createDbIcon(iconName, this.getActionIconSize(actionSize)));
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
button.textContent = action.text;
|
|
112
|
+
}
|
|
113
|
+
bindClick(button);
|
|
114
|
+
return button;
|
|
115
|
+
}
|
|
116
|
+
render() {
|
|
117
|
+
const title = this.getAttribute('title') || '';
|
|
118
|
+
const description = this.getAttribute('description') || '';
|
|
119
|
+
const iconName = this.getAttribute('icon');
|
|
120
|
+
const image = this.getAttribute('image');
|
|
121
|
+
const imageAlt = this.getAttribute('image-alt') || title || 'Banner image';
|
|
122
|
+
const size = this.getAttribute('size') || 'm';
|
|
123
|
+
const variant = this.getAttribute('variant') || 'primary';
|
|
124
|
+
const backgroundImage = this.getAttribute('background-image');
|
|
125
|
+
const actions = this.parseActions();
|
|
126
|
+
this.className = `designbase-wc-banner designbase-wc-banner--${size} designbase-wc-banner--${variant}`;
|
|
127
|
+
this.replaceChildren();
|
|
128
|
+
if (variant === 'image' && backgroundImage) {
|
|
129
|
+
const background = document.createElement('div');
|
|
130
|
+
background.className = 'designbase-wc-banner__background';
|
|
131
|
+
background.style.backgroundImage = `url(${backgroundImage})`;
|
|
132
|
+
background.style.backgroundSize = 'cover';
|
|
133
|
+
background.style.backgroundPosition = 'center';
|
|
134
|
+
background.style.backgroundRepeat = 'no-repeat';
|
|
135
|
+
this.append(background);
|
|
136
|
+
const overlay = document.createElement('div');
|
|
137
|
+
overlay.className = 'designbase-wc-banner__overlay';
|
|
138
|
+
this.append(overlay);
|
|
139
|
+
}
|
|
140
|
+
const container = document.createElement('div');
|
|
141
|
+
container.className = 'designbase-wc-banner__container';
|
|
142
|
+
if (iconName) {
|
|
143
|
+
const iconWrap = document.createElement('div');
|
|
144
|
+
iconWrap.className = 'designbase-wc-banner__icon';
|
|
145
|
+
iconWrap.append(createDbIcon(iconName, this.getIconSize(size)));
|
|
146
|
+
container.append(iconWrap);
|
|
147
|
+
}
|
|
148
|
+
if (image) {
|
|
149
|
+
const imageWrap = document.createElement('div');
|
|
150
|
+
imageWrap.className = 'designbase-wc-banner__image';
|
|
151
|
+
const imageElement = document.createElement('img');
|
|
152
|
+
imageElement.src = image;
|
|
153
|
+
imageElement.alt = imageAlt;
|
|
154
|
+
imageWrap.append(imageElement);
|
|
155
|
+
container.append(imageWrap);
|
|
156
|
+
}
|
|
157
|
+
const content = document.createElement('div');
|
|
158
|
+
content.className = 'designbase-wc-banner__content';
|
|
159
|
+
if (title) {
|
|
160
|
+
const heading = document.createElement('h3');
|
|
161
|
+
heading.className = 'designbase-wc-banner__title';
|
|
162
|
+
heading.textContent = title;
|
|
163
|
+
content.append(heading);
|
|
164
|
+
}
|
|
165
|
+
if (description) {
|
|
166
|
+
const body = document.createElement('p');
|
|
167
|
+
body.className = 'designbase-wc-banner__description';
|
|
168
|
+
body.textContent = description;
|
|
169
|
+
content.append(body);
|
|
170
|
+
}
|
|
171
|
+
container.append(content);
|
|
172
|
+
if (actions.length > 0) {
|
|
173
|
+
const actionsWrap = document.createElement('div');
|
|
174
|
+
actionsWrap.className = 'designbase-wc-banner__actions';
|
|
175
|
+
actions.forEach((action, index) => {
|
|
176
|
+
const actionVariant = BUTTON_VARIANT_MAP[action.variant || 'primary'] || 'primary';
|
|
177
|
+
const actionSize = BUTTON_SIZE_MAP[action.size || 'sm'] || 's';
|
|
178
|
+
actionsWrap.append(this.createActionControl(action, index, actionVariant, actionSize));
|
|
179
|
+
});
|
|
180
|
+
container.append(actionsWrap);
|
|
181
|
+
}
|
|
182
|
+
this.append(container);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (!customElements.get('db-banner'))
|
|
186
|
+
customElements.define('db-banner', DbBanner);
|
|
187
|
+
|
|
188
|
+
export { DbBanner };
|