@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,96 +1 @@
|
|
|
1
|
-
class DbImagePlaceholder extends HTMLElement {
|
|
2
|
-
constructor() {
|
|
3
|
-
super(...arguments);
|
|
4
|
-
this.handleClick = () => {
|
|
5
|
-
if (!this.hasAttribute('clickable'))
|
|
6
|
-
return;
|
|
7
|
-
this.dispatchEvent(new CustomEvent('db-click', { bubbles: true, composed: true }));
|
|
8
|
-
};
|
|
9
|
-
this.handleKeyDown = (e) => {
|
|
10
|
-
if (!this.hasAttribute('clickable'))
|
|
11
|
-
return;
|
|
12
|
-
if (e.key !== 'Enter' && e.key !== ' ')
|
|
13
|
-
return;
|
|
14
|
-
e.preventDefault();
|
|
15
|
-
this.handleClick();
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
static get observedAttributes() {
|
|
19
|
-
return [
|
|
20
|
-
'label',
|
|
21
|
-
'show-label',
|
|
22
|
-
'pattern-size',
|
|
23
|
-
'pattern-color',
|
|
24
|
-
'background-color',
|
|
25
|
-
'width',
|
|
26
|
-
'height',
|
|
27
|
-
'aspect-ratio',
|
|
28
|
-
'hover-effect',
|
|
29
|
-
'clickable',
|
|
30
|
-
];
|
|
31
|
-
}
|
|
32
|
-
connectedCallback() {
|
|
33
|
-
this.addEventListener('click', this.handleClick);
|
|
34
|
-
this.addEventListener('keydown', this.handleKeyDown);
|
|
35
|
-
this.render();
|
|
36
|
-
}
|
|
37
|
-
disconnectedCallback() {
|
|
38
|
-
this.removeEventListener('click', this.handleClick);
|
|
39
|
-
this.removeEventListener('keydown', this.handleKeyDown);
|
|
40
|
-
}
|
|
41
|
-
attributeChangedCallback() {
|
|
42
|
-
this.render();
|
|
43
|
-
}
|
|
44
|
-
render() {
|
|
45
|
-
const label = this.getAttribute('label') || '';
|
|
46
|
-
const showLabel = this.hasAttribute('show-label');
|
|
47
|
-
const patternSize = Number(this.getAttribute('pattern-size') || 20);
|
|
48
|
-
const patternColor = this.getAttribute('pattern-color') || '#f3f3f3';
|
|
49
|
-
const backgroundColor = this.getAttribute('background-color') || '#e7e7e7';
|
|
50
|
-
const width = this.getAttribute('width') || '100%';
|
|
51
|
-
const height = this.getAttribute('height') || '';
|
|
52
|
-
const aspectRatio = this.getAttribute('aspect-ratio') || '';
|
|
53
|
-
const hoverEffect = this.hasAttribute('hover-effect');
|
|
54
|
-
const clickable = this.hasAttribute('clickable');
|
|
55
|
-
this.className = [
|
|
56
|
-
'designbase-wc-image-placeholder',
|
|
57
|
-
hoverEffect && 'designbase-wc-image-placeholder--hover',
|
|
58
|
-
clickable && 'designbase-wc-image-placeholder--clickable',
|
|
59
|
-
]
|
|
60
|
-
.filter(Boolean)
|
|
61
|
-
.join(' ');
|
|
62
|
-
this.style.width = width;
|
|
63
|
-
this.style.height = height;
|
|
64
|
-
this.style.aspectRatio = aspectRatio;
|
|
65
|
-
if (clickable) {
|
|
66
|
-
this.setAttribute('role', 'button');
|
|
67
|
-
this.setAttribute('tabindex', '0');
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.removeAttribute('role');
|
|
71
|
-
this.removeAttribute('tabindex');
|
|
72
|
-
}
|
|
73
|
-
this.replaceChildren();
|
|
74
|
-
const pattern = document.createElement('div');
|
|
75
|
-
pattern.className = 'designbase-wc-image-placeholder__pattern';
|
|
76
|
-
pattern.style.setProperty('--db-placeholder-bg', backgroundColor);
|
|
77
|
-
pattern.style.setProperty('--db-placeholder-pattern', patternColor);
|
|
78
|
-
pattern.style.setProperty('--db-placeholder-size', `${patternSize}px`);
|
|
79
|
-
pattern.style.setProperty('--db-placeholder-half-size', `${patternSize / 2}px`);
|
|
80
|
-
this.append(pattern);
|
|
81
|
-
if (showLabel && label) {
|
|
82
|
-
const labelWrap = document.createElement('div');
|
|
83
|
-
labelWrap.className = 'designbase-wc-image-placeholder__label-wrap';
|
|
84
|
-
const labelEl = document.createElement('span');
|
|
85
|
-
labelEl.className = 'designbase-wc-image-placeholder__label';
|
|
86
|
-
labelEl.textContent = label;
|
|
87
|
-
labelWrap.append(labelEl);
|
|
88
|
-
this.append(labelWrap);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (!customElements.get('db-image-placeholder')) {
|
|
93
|
-
customElements.define('db-image-placeholder', DbImagePlaceholder);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export { DbImagePlaceholder };
|
|
1
|
+
class DbImagePlaceholder extends HTMLElement{constructor(){super(...arguments),this.handleClick=()=>{this.hasAttribute("clickable")&&this.dispatchEvent(new CustomEvent("db-click",{bubbles:!0,composed:!0}))},this.handleKeyDown=e=>{this.hasAttribute("clickable")&&("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleClick()))}}static get observedAttributes(){return["label","show-label","pattern-size","pattern-color","background-color","width","height","aspect-ratio","hover-effect","clickable"]}connectedCallback(){this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown),this.render()}disconnectedCallback(){this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown)}attributeChangedCallback(){this.render()}render(){const e=this.getAttribute("label")||"",t=this.hasAttribute("show-label"),i=Number(this.getAttribute("pattern-size")||20),s=this.getAttribute("pattern-color")||"#f3f3f3",a=this.getAttribute("background-color")||"#e7e7e7",l=this.getAttribute("width")||"100%",r=this.getAttribute("height")||"",c=this.getAttribute("aspect-ratio")||"",h=this.hasAttribute("hover-effect"),n=this.hasAttribute("clickable");this.className=["designbase-wc-image-placeholder",h&&"designbase-wc-image-placeholder--hover",n&&"designbase-wc-image-placeholder--clickable"].filter(Boolean).join(" "),this.style.width=l,this.style.height=r,this.style.aspectRatio=c,n?(this.setAttribute("role","button"),this.setAttribute("tabindex","0")):(this.removeAttribute("role"),this.removeAttribute("tabindex")),this.replaceChildren();const o=document.createElement("div");if(o.className="designbase-wc-image-placeholder__pattern",o.style.setProperty("--db-placeholder-bg",a),o.style.setProperty("--db-placeholder-pattern",s),o.style.setProperty("--db-placeholder-size",`${i}px`),o.style.setProperty("--db-placeholder-half-size",i/2+"px"),this.append(o),t&&e){const t=document.createElement("div");t.className="designbase-wc-image-placeholder__label-wrap";const i=document.createElement("span");i.className="designbase-wc-image-placeholder__label",i.textContent=e,t.append(i),this.append(t)}}}customElements.get("db-image-placeholder")||customElements.define("db-image-placeholder",DbImagePlaceholder);export{DbImagePlaceholder};
|
|
@@ -1,289 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const RATIOS = ['1:1', '16:9', '4:3', '3:2', '3:4', '2:1', 'auto'];
|
|
4
|
-
const FITS = ['cover', 'contain', 'fill', 'none', 'scale-down'];
|
|
5
|
-
const LOADINGS = ['lazy', 'eager'];
|
|
6
|
-
const PLACEHOLDERS = ['skeleton', 'blur', 'none'];
|
|
7
|
-
const ROUNDED = ['s', 'm', 'l', 'full'];
|
|
8
|
-
const SHADOWS = ['s', 'm', 'l'];
|
|
9
|
-
class DbImage extends HTMLElement {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(...arguments);
|
|
12
|
-
this.imageState = 'loading';
|
|
13
|
-
this.currentSrc = '';
|
|
14
|
-
this.showPlaceholder = false;
|
|
15
|
-
this.imgEl = null;
|
|
16
|
-
this.placeholderEl = null;
|
|
17
|
-
this.errorEl = null;
|
|
18
|
-
this.initialized = false;
|
|
19
|
-
this.handleLoad = () => {
|
|
20
|
-
if (this.imageState === 'loaded')
|
|
21
|
-
return;
|
|
22
|
-
this.imageState = 'loaded';
|
|
23
|
-
this.showPlaceholder = false;
|
|
24
|
-
this.syncVisualState();
|
|
25
|
-
this.dispatchEvent(new CustomEvent('db-load', { bubbles: true, composed: true }));
|
|
26
|
-
};
|
|
27
|
-
this.handleError = () => {
|
|
28
|
-
const fallbackSrc = this.getAttribute('fallback-src') || '';
|
|
29
|
-
if (fallbackSrc && this.currentSrc !== fallbackSrc) {
|
|
30
|
-
this.currentSrc = fallbackSrc;
|
|
31
|
-
this.imageState = 'loading';
|
|
32
|
-
this.updateImageSource();
|
|
33
|
-
this.syncVisualState();
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
this.imageState = 'error';
|
|
37
|
-
this.showPlaceholder = false;
|
|
38
|
-
this.syncVisualState();
|
|
39
|
-
this.dispatchEvent(new CustomEvent('db-error', { bubbles: true, composed: true }));
|
|
40
|
-
};
|
|
41
|
-
this.handleClick = () => {
|
|
42
|
-
if (!this.hasAttribute('clickable'))
|
|
43
|
-
return;
|
|
44
|
-
this.dispatchEvent(new CustomEvent('db-click', { bubbles: true, composed: true }));
|
|
45
|
-
};
|
|
46
|
-
this.handleKeyDown = (e) => {
|
|
47
|
-
if (!this.hasAttribute('clickable'))
|
|
48
|
-
return;
|
|
49
|
-
if (e.key !== 'Enter' && e.key !== ' ')
|
|
50
|
-
return;
|
|
51
|
-
e.preventDefault();
|
|
52
|
-
this.handleClick();
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
static get observedAttributes() {
|
|
56
|
-
return [
|
|
57
|
-
'src',
|
|
58
|
-
'alt',
|
|
59
|
-
'ratio',
|
|
60
|
-
'fit',
|
|
61
|
-
'loading',
|
|
62
|
-
'fallback-src',
|
|
63
|
-
'placeholder',
|
|
64
|
-
'rounded',
|
|
65
|
-
'width',
|
|
66
|
-
'height',
|
|
67
|
-
'max-width',
|
|
68
|
-
'max-height',
|
|
69
|
-
'full-width',
|
|
70
|
-
'full-height',
|
|
71
|
-
'shadow',
|
|
72
|
-
'hover',
|
|
73
|
-
'clickable',
|
|
74
|
-
];
|
|
75
|
-
}
|
|
76
|
-
connectedCallback() {
|
|
77
|
-
this.addEventListener('click', this.handleClick);
|
|
78
|
-
this.addEventListener('keydown', this.handleKeyDown);
|
|
79
|
-
this.resetFromAttributes();
|
|
80
|
-
this.ensureStructure();
|
|
81
|
-
this.syncVisualState();
|
|
82
|
-
}
|
|
83
|
-
disconnectedCallback() {
|
|
84
|
-
this.removeEventListener('click', this.handleClick);
|
|
85
|
-
this.removeEventListener('keydown', this.handleKeyDown);
|
|
86
|
-
}
|
|
87
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
88
|
-
if (oldValue === newValue && name !== 'src') {
|
|
89
|
-
this.syncVisualState();
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (name === 'src') {
|
|
93
|
-
const nextSrc = newValue || '';
|
|
94
|
-
if (nextSrc !== this.currentSrc) {
|
|
95
|
-
this.currentSrc = nextSrc;
|
|
96
|
-
this.imageState = 'loading';
|
|
97
|
-
const placeholder = this.getAttribute('placeholder') || 'none';
|
|
98
|
-
this.showPlaceholder = placeholder !== 'none';
|
|
99
|
-
this.updateImageSource();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (name === 'placeholder') {
|
|
103
|
-
this.showPlaceholder = (newValue || 'none') !== 'none' && this.imageState === 'loading';
|
|
104
|
-
}
|
|
105
|
-
this.ensureStructure();
|
|
106
|
-
this.syncVisualState();
|
|
107
|
-
}
|
|
108
|
-
resetFromAttributes() {
|
|
109
|
-
this.currentSrc = this.getAttribute('src') || '';
|
|
110
|
-
const placeholder = this.getAttribute('placeholder') || 'none';
|
|
111
|
-
this.showPlaceholder = placeholder !== 'none';
|
|
112
|
-
this.imageState = 'loading';
|
|
113
|
-
}
|
|
114
|
-
getRoundedClass() {
|
|
115
|
-
const rounded = this.getAttribute('rounded');
|
|
116
|
-
if (!rounded)
|
|
117
|
-
return '';
|
|
118
|
-
if (rounded === 'true' || rounded === '')
|
|
119
|
-
return 'designbase-wc-image--rounded';
|
|
120
|
-
if (rounded === 's')
|
|
121
|
-
return 'designbase-wc-image--rounded-sm';
|
|
122
|
-
if (rounded === 'm')
|
|
123
|
-
return 'designbase-wc-image--rounded-md';
|
|
124
|
-
if (rounded === 'l')
|
|
125
|
-
return 'designbase-wc-image--rounded-lg';
|
|
126
|
-
if (ROUNDED.includes(rounded)) {
|
|
127
|
-
if (rounded === 'full')
|
|
128
|
-
return 'designbase-wc-image--rounded-full';
|
|
129
|
-
return `designbase-wc-image--rounded-${rounded}`;
|
|
130
|
-
}
|
|
131
|
-
return '';
|
|
132
|
-
}
|
|
133
|
-
getShadowClass() {
|
|
134
|
-
const shadow = this.getAttribute('shadow');
|
|
135
|
-
if (!shadow)
|
|
136
|
-
return '';
|
|
137
|
-
if (shadow === 'true' || shadow === '')
|
|
138
|
-
return 'designbase-wc-image--shadow';
|
|
139
|
-
if (SHADOWS.includes(shadow)) {
|
|
140
|
-
return `designbase-wc-image--shadow-${shadow}`;
|
|
141
|
-
}
|
|
142
|
-
return '';
|
|
143
|
-
}
|
|
144
|
-
getRatioClass() {
|
|
145
|
-
const ratio = this.getAttribute('ratio') || 'auto';
|
|
146
|
-
if (ratio === 'auto')
|
|
147
|
-
return 'designbase-wc-image--ratio-auto';
|
|
148
|
-
if (RATIOS.includes(ratio)) {
|
|
149
|
-
return `designbase-wc-image--ratio-${ratio.replace(':', '-')}`;
|
|
150
|
-
}
|
|
151
|
-
return 'designbase-wc-image--ratio-auto';
|
|
152
|
-
}
|
|
153
|
-
applyContainerStyle() {
|
|
154
|
-
const style = this.style;
|
|
155
|
-
const fullWidth = this.hasAttribute('full-width');
|
|
156
|
-
const fullHeight = this.hasAttribute('full-height');
|
|
157
|
-
const width = this.getAttribute('width');
|
|
158
|
-
const height = this.getAttribute('height');
|
|
159
|
-
const maxWidth = this.getAttribute('max-width');
|
|
160
|
-
const maxHeight = this.getAttribute('max-height');
|
|
161
|
-
style.width = fullWidth ? '100%' : width || '';
|
|
162
|
-
style.height = fullHeight ? '100%' : height || '';
|
|
163
|
-
style.maxWidth = maxWidth || '';
|
|
164
|
-
style.maxHeight = maxHeight || '';
|
|
165
|
-
}
|
|
166
|
-
ensureStructure() {
|
|
167
|
-
if (!this.initialized) {
|
|
168
|
-
this.placeholderEl = document.createElement('div');
|
|
169
|
-
this.placeholderEl.className = 'designbase-wc-image__placeholder';
|
|
170
|
-
this.errorEl = document.createElement('div');
|
|
171
|
-
this.errorEl.className = 'designbase-wc-image__error';
|
|
172
|
-
this.errorEl.append(createDbIcon('gallery', 20));
|
|
173
|
-
const errorText = document.createElement('span');
|
|
174
|
-
errorText.className = 'designbase-wc-image__error-text';
|
|
175
|
-
this.errorEl.append(errorText);
|
|
176
|
-
this.imgEl = document.createElement('img');
|
|
177
|
-
this.imgEl.className = 'designbase-wc-image__img';
|
|
178
|
-
this.imgEl.draggable = false;
|
|
179
|
-
this.imgEl.addEventListener('load', this.handleLoad);
|
|
180
|
-
this.imgEl.addEventListener('error', this.handleError);
|
|
181
|
-
this.append(this.placeholderEl, this.errorEl, this.imgEl);
|
|
182
|
-
this.initialized = true;
|
|
183
|
-
}
|
|
184
|
-
this.updateImageSource();
|
|
185
|
-
this.updatePlaceholderContent();
|
|
186
|
-
this.updateErrorContent();
|
|
187
|
-
}
|
|
188
|
-
updateImageSource() {
|
|
189
|
-
if (!this.imgEl)
|
|
190
|
-
return;
|
|
191
|
-
const alt = this.getAttribute('alt') || '';
|
|
192
|
-
const rawLoading = this.getAttribute('loading') || 'lazy';
|
|
193
|
-
const loading = LOADINGS.includes(rawLoading) ? rawLoading : 'lazy';
|
|
194
|
-
this.imgEl.alt = alt;
|
|
195
|
-
this.imgEl.loading = loading;
|
|
196
|
-
const resolvedSrc = this.currentSrc;
|
|
197
|
-
if (!resolvedSrc) {
|
|
198
|
-
this.imgEl.removeAttribute('src');
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
const absoluteSrc = new URL(resolvedSrc, window.location.href).href;
|
|
202
|
-
if (this.imgEl.src !== absoluteSrc) {
|
|
203
|
-
this.imgEl.src = resolvedSrc;
|
|
204
|
-
}
|
|
205
|
-
else if (this.imgEl.complete && this.imgEl.naturalWidth > 0 && this.imageState === 'loading') {
|
|
206
|
-
this.handleLoad();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
updatePlaceholderContent() {
|
|
210
|
-
if (!this.placeholderEl)
|
|
211
|
-
return;
|
|
212
|
-
const placeholder = this.getAttribute('placeholder') || 'none';
|
|
213
|
-
const placeholderMode = PLACEHOLDERS.includes(placeholder)
|
|
214
|
-
? placeholder
|
|
215
|
-
: 'none';
|
|
216
|
-
this.placeholderEl.className = [
|
|
217
|
-
'designbase-wc-image__placeholder',
|
|
218
|
-
`designbase-wc-image__placeholder--${placeholderMode}`,
|
|
219
|
-
].join(' ');
|
|
220
|
-
this.placeholderEl.replaceChildren();
|
|
221
|
-
if (placeholderMode === 'skeleton') {
|
|
222
|
-
const skeleton = document.createElement('div');
|
|
223
|
-
skeleton.className = 'designbase-wc-image__skeleton';
|
|
224
|
-
this.placeholderEl.append(skeleton);
|
|
225
|
-
}
|
|
226
|
-
if (placeholderMode === 'blur') {
|
|
227
|
-
const blur = document.createElement('div');
|
|
228
|
-
blur.className = 'designbase-wc-image__blur';
|
|
229
|
-
this.placeholderEl.append(blur);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
updateErrorContent() {
|
|
233
|
-
if (!this.errorEl)
|
|
234
|
-
return;
|
|
235
|
-
const errorText = this.errorEl.querySelector('.designbase-wc-image__error-text');
|
|
236
|
-
if (errorText) {
|
|
237
|
-
errorText.textContent = this.getAttribute('alt') || '이미지를 불러올 수 없습니다';
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
syncVisualState() {
|
|
241
|
-
const rawFit = this.getAttribute('fit') || 'cover';
|
|
242
|
-
const fit = FITS.includes(rawFit) ? rawFit : 'cover';
|
|
243
|
-
const clickable = this.hasAttribute('clickable');
|
|
244
|
-
const hover = this.hasAttribute('hover');
|
|
245
|
-
this.className = [
|
|
246
|
-
'designbase-wc-image',
|
|
247
|
-
this.getRatioClass(),
|
|
248
|
-
`designbase-wc-image--fit-${fit}`,
|
|
249
|
-
this.getRoundedClass(),
|
|
250
|
-
this.getShadowClass(),
|
|
251
|
-
hover && 'designbase-wc-image--hover',
|
|
252
|
-
this.hasAttribute('full-width') && 'designbase-wc-image--full-width',
|
|
253
|
-
this.hasAttribute('full-height') && 'designbase-wc-image--full-height',
|
|
254
|
-
clickable && 'designbase-wc-image--clickable',
|
|
255
|
-
this.imageState === 'loading' && 'designbase-wc-image--loading',
|
|
256
|
-
this.imageState === 'error' && 'designbase-wc-image--error',
|
|
257
|
-
]
|
|
258
|
-
.filter(Boolean)
|
|
259
|
-
.join(' ');
|
|
260
|
-
this.applyContainerStyle();
|
|
261
|
-
if (clickable) {
|
|
262
|
-
this.setAttribute('role', 'button');
|
|
263
|
-
this.setAttribute('tabindex', '0');
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
this.removeAttribute('role');
|
|
267
|
-
this.removeAttribute('tabindex');
|
|
268
|
-
}
|
|
269
|
-
if (this.placeholderEl) {
|
|
270
|
-
const visible = this.showPlaceholder && this.imageState === 'loading';
|
|
271
|
-
this.placeholderEl.classList.toggle('designbase-wc-image__placeholder--visible', visible);
|
|
272
|
-
this.placeholderEl.hidden = !visible;
|
|
273
|
-
}
|
|
274
|
-
if (this.errorEl) {
|
|
275
|
-
const visible = this.imageState === 'error';
|
|
276
|
-
this.errorEl.hidden = !visible;
|
|
277
|
-
}
|
|
278
|
-
if (this.imgEl) {
|
|
279
|
-
const visible = Boolean(this.currentSrc) && this.imageState !== 'error';
|
|
280
|
-
this.imgEl.hidden = !visible;
|
|
281
|
-
this.imgEl.classList.toggle('designbase-wc-image__img--loaded', this.imageState === 'loaded');
|
|
282
|
-
this.imgEl.classList.toggle('designbase-wc-image__img--error', this.imageState === 'error');
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
if (!customElements.get('db-image'))
|
|
287
|
-
customElements.define('db-image', DbImage);
|
|
288
|
-
|
|
289
|
-
export { DbImage };
|
|
1
|
+
import{createDbIcon as e}from"./db-icons.js";const t=["1:1","16:9","4:3","3:2","3:4","2:1","auto"],i=["cover","contain","fill","none","scale-down"],s=["lazy","eager"],a=["skeleton","blur","none"],l=["s","m","l","full"],r=["s","m","l"];class DbImage extends HTMLElement{constructor(){super(...arguments),this.imageState="loading",this.currentSrc="",this.showPlaceholder=!1,this.imgEl=null,this.placeholderEl=null,this.errorEl=null,this.initialized=!1,this.handleLoad=()=>{"loaded"!==this.imageState&&(this.imageState="loaded",this.showPlaceholder=!1,this.syncVisualState(),this.dispatchEvent(new CustomEvent("db-load",{bubbles:!0,composed:!0})))},this.handleError=()=>{const e=this.getAttribute("fallback-src")||"";if(e&&this.currentSrc!==e)return this.currentSrc=e,this.imageState="loading",this.updateImageSource(),void this.syncVisualState();this.imageState="error",this.showPlaceholder=!1,this.syncVisualState(),this.dispatchEvent(new CustomEvent("db-error",{bubbles:!0,composed:!0}))},this.handleClick=()=>{this.hasAttribute("clickable")&&this.dispatchEvent(new CustomEvent("db-click",{bubbles:!0,composed:!0}))},this.handleKeyDown=e=>{this.hasAttribute("clickable")&&("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleClick()))}}static get observedAttributes(){return["src","alt","ratio","fit","loading","fallback-src","placeholder","rounded","width","height","max-width","max-height","full-width","full-height","shadow","hover","clickable"]}connectedCallback(){this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown),this.resetFromAttributes(),this.ensureStructure(),this.syncVisualState()}disconnectedCallback(){this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown)}attributeChangedCallback(e,t,i){if(t!==i||"src"===e){if("src"===e){const e=i||"";if(e!==this.currentSrc){this.currentSrc=e,this.imageState="loading";const t=this.getAttribute("placeholder")||"none";this.showPlaceholder="none"!==t,this.updateImageSource()}}"placeholder"===e&&(this.showPlaceholder="none"!==(i||"none")&&"loading"===this.imageState),this.ensureStructure(),this.syncVisualState()}else this.syncVisualState()}resetFromAttributes(){this.currentSrc=this.getAttribute("src")||"";const e=this.getAttribute("placeholder")||"none";this.showPlaceholder="none"!==e,this.imageState="loading"}getRoundedClass(){const e=this.getAttribute("rounded");return e?"true"===e||""===e?"designbase-wc-image--rounded":"s"===e?"designbase-wc-image--rounded-sm":"m"===e?"designbase-wc-image--rounded-md":"l"===e?"designbase-wc-image--rounded-lg":l.includes(e)?"full"===e?"designbase-wc-image--rounded-full":`designbase-wc-image--rounded-${e}`:"":""}getShadowClass(){const e=this.getAttribute("shadow");return e?"true"===e||""===e?"designbase-wc-image--shadow":r.includes(e)?`designbase-wc-image--shadow-${e}`:"":""}getRatioClass(){const e=this.getAttribute("ratio")||"auto";return"auto"===e?"designbase-wc-image--ratio-auto":t.includes(e)?`designbase-wc-image--ratio-${e.replace(":","-")}`:"designbase-wc-image--ratio-auto"}applyContainerStyle(){const e=this.style,t=this.hasAttribute("full-width"),i=this.hasAttribute("full-height"),s=this.getAttribute("width"),a=this.getAttribute("height"),l=this.getAttribute("max-width"),r=this.getAttribute("max-height");e.width=t?"100%":s||"",e.height=i?"100%":a||"",e.maxWidth=l||"",e.maxHeight=r||""}ensureStructure(){if(!this.initialized){this.placeholderEl=document.createElement("div"),this.placeholderEl.className="designbase-wc-image__placeholder",this.errorEl=document.createElement("div"),this.errorEl.className="designbase-wc-image__error",this.errorEl.append(e("gallery",20));const t=document.createElement("span");t.className="designbase-wc-image__error-text",this.errorEl.append(t),this.imgEl=document.createElement("img"),this.imgEl.className="designbase-wc-image__img",this.imgEl.draggable=!1,this.imgEl.addEventListener("load",this.handleLoad),this.imgEl.addEventListener("error",this.handleError),this.append(this.placeholderEl,this.errorEl,this.imgEl),this.initialized=!0}this.updateImageSource(),this.updatePlaceholderContent(),this.updateErrorContent()}updateImageSource(){if(!this.imgEl)return;const e=this.getAttribute("alt")||"",t=this.getAttribute("loading")||"lazy",i=s.includes(t)?t:"lazy";this.imgEl.alt=e,this.imgEl.loading=i;const a=this.currentSrc;if(!a)return void this.imgEl.removeAttribute("src");const l=new URL(a,window.location.href).href;this.imgEl.src!==l?this.imgEl.src=a:this.imgEl.complete&&this.imgEl.naturalWidth>0&&"loading"===this.imageState&&this.handleLoad()}updatePlaceholderContent(){if(!this.placeholderEl)return;const e=this.getAttribute("placeholder")||"none",t=a.includes(e)?e:"none";if(this.placeholderEl.className=["designbase-wc-image__placeholder",`designbase-wc-image__placeholder--${t}`].join(" "),this.placeholderEl.replaceChildren(),"skeleton"===t){const e=document.createElement("div");e.className="designbase-wc-image__skeleton",this.placeholderEl.append(e)}if("blur"===t){const e=document.createElement("div");e.className="designbase-wc-image__blur",this.placeholderEl.append(e)}}updateErrorContent(){if(!this.errorEl)return;const e=this.errorEl.querySelector(".designbase-wc-image__error-text");e&&(e.textContent=this.getAttribute("alt")||"이미지를 불러올 수 없습니다")}syncVisualState(){const e=this.getAttribute("fit")||"cover",t=i.includes(e)?e:"cover",s=this.hasAttribute("clickable"),a=this.hasAttribute("hover");if(this.className=["designbase-wc-image",this.getRatioClass(),`designbase-wc-image--fit-${t}`,this.getRoundedClass(),this.getShadowClass(),a&&"designbase-wc-image--hover",this.hasAttribute("full-width")&&"designbase-wc-image--full-width",this.hasAttribute("full-height")&&"designbase-wc-image--full-height",s&&"designbase-wc-image--clickable","loading"===this.imageState&&"designbase-wc-image--loading","error"===this.imageState&&"designbase-wc-image--error"].filter(Boolean).join(" "),this.applyContainerStyle(),s?(this.setAttribute("role","button"),this.setAttribute("tabindex","0")):(this.removeAttribute("role"),this.removeAttribute("tabindex")),this.placeholderEl){const e=this.showPlaceholder&&"loading"===this.imageState;this.placeholderEl.classList.toggle("designbase-wc-image__placeholder--visible",e),this.placeholderEl.hidden=!e}if(this.errorEl){const e="error"===this.imageState;this.errorEl.hidden=!e}if(this.imgEl){const e=Boolean(this.currentSrc)&&"error"!==this.imageState;this.imgEl.hidden=!e,this.imgEl.classList.toggle("designbase-wc-image__img--loaded","loaded"===this.imageState),this.imgEl.classList.toggle("designbase-wc-image__img--error","error"===this.imageState)}}}customElements.get("db-image")||customElements.define("db-image",DbImage);export{DbImage};
|