@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,94 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const SIZES = ['xs', 's', 'm', 'l', 'xl'];
|
|
3
|
-
function getDefaultSize(variant, size) {
|
|
4
|
-
if (variant === 'circular') {
|
|
5
|
-
switch (size) {
|
|
6
|
-
case 'xs': return '16px';
|
|
7
|
-
case 's': return '24px';
|
|
8
|
-
case 'l': return '48px';
|
|
9
|
-
case 'xl': return '64px';
|
|
10
|
-
default: return '32px';
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
switch (size) {
|
|
14
|
-
case 'xs': return '12px';
|
|
15
|
-
case 's': return '16px';
|
|
16
|
-
case 'l': return '24px';
|
|
17
|
-
case 'xl': return '32px';
|
|
18
|
-
default: return '20px';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function getTextLineHeight(size) {
|
|
22
|
-
switch (size) {
|
|
23
|
-
case 'xs': return '12px';
|
|
24
|
-
case 's': return '16px';
|
|
25
|
-
case 'l': return '24px';
|
|
26
|
-
case 'xl': return '32px';
|
|
27
|
-
default: return '20px';
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function toCssSize(value) {
|
|
31
|
-
return /^\d+$/.test(value) ? `${value}px` : value;
|
|
32
|
-
}
|
|
33
|
-
class DbSkeleton extends HTMLElement {
|
|
34
|
-
static get observedAttributes() {
|
|
35
|
-
return ['variant', 'size', 'width', 'height', 'animation', 'lines', 'line-spacing', 'last-line-width', 'aria-label'];
|
|
36
|
-
}
|
|
37
|
-
connectedCallback() {
|
|
38
|
-
this.render();
|
|
39
|
-
}
|
|
40
|
-
attributeChangedCallback() {
|
|
41
|
-
if (!this.isConnected)
|
|
42
|
-
return;
|
|
43
|
-
this.render();
|
|
44
|
-
}
|
|
45
|
-
render() {
|
|
46
|
-
const variant = this.getAttribute('variant') || 'text';
|
|
47
|
-
const size = this.getAttribute('size') || 'm';
|
|
48
|
-
const animation = this.getAttribute('animation') || 'pulse';
|
|
49
|
-
const lines = Number(this.getAttribute('lines') || 1);
|
|
50
|
-
const width = this.getAttribute('width');
|
|
51
|
-
const height = this.getAttribute('height');
|
|
52
|
-
const lineSpacing = this.getAttribute('line-spacing') || '8px';
|
|
53
|
-
const lastLineWidth = this.getAttribute('last-line-width') || '60%';
|
|
54
|
-
const resolvedVariant = VARIANTS.includes(variant) ? variant : 'text';
|
|
55
|
-
const resolvedSize = SIZES.includes(size) ? size : 'm';
|
|
56
|
-
const nextClassName = [
|
|
57
|
-
'designbase-wc-skeleton',
|
|
58
|
-
`designbase-wc-skeleton--${resolvedVariant}`,
|
|
59
|
-
`designbase-wc-skeleton--${resolvedSize}`,
|
|
60
|
-
`designbase-wc-skeleton--${animation}`,
|
|
61
|
-
(width || height) && 'designbase-wc-skeleton--custom-size',
|
|
62
|
-
]
|
|
63
|
-
.filter(Boolean)
|
|
64
|
-
.join(' ');
|
|
65
|
-
if (this.className !== nextClassName) {
|
|
66
|
-
this.className = nextClassName;
|
|
67
|
-
}
|
|
68
|
-
const nextAriaLabel = this.getAttribute('aria-label') ?? `${resolvedVariant} 스켈레톤 로딩 중`;
|
|
69
|
-
if (this.getAttribute('aria-label') !== nextAriaLabel) {
|
|
70
|
-
this.setAttribute('aria-label', nextAriaLabel);
|
|
71
|
-
}
|
|
72
|
-
this.setAttribute('role', 'status');
|
|
73
|
-
this.setAttribute('aria-live', 'polite');
|
|
74
|
-
this.replaceChildren();
|
|
75
|
-
this.style.width = width ? toCssSize(width) : (resolvedVariant === 'circular' ? getDefaultSize(resolvedVariant, resolvedSize) : '100%');
|
|
76
|
-
this.style.height = height
|
|
77
|
-
? toCssSize(height)
|
|
78
|
-
: (resolvedVariant === 'circular' ? getDefaultSize(resolvedVariant, resolvedSize) : getTextLineHeight(resolvedSize));
|
|
79
|
-
if (resolvedVariant === 'text' && lines > 1) {
|
|
80
|
-
for (let index = 1; index < lines; index += 1) {
|
|
81
|
-
const line = document.createElement('div');
|
|
82
|
-
line.className = 'designbase-wc-skeleton__line';
|
|
83
|
-
line.style.marginTop = toCssSize(lineSpacing);
|
|
84
|
-
if (index === lines - 1)
|
|
85
|
-
line.style.width = toCssSize(lastLineWidth);
|
|
86
|
-
this.append(line);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (!customElements.get('db-skeleton'))
|
|
92
|
-
customElements.define('db-skeleton', DbSkeleton);
|
|
93
|
-
|
|
94
|
-
export { DbSkeleton };
|
|
1
|
+
const e=["text","circular","rectangular","rounded"],t=["xs","s","m","l","xl"];function getDefaultSize(e,t){if("circular"===e)switch(t){case"xs":return"16px";case"s":return"24px";case"l":return"48px";case"xl":return"64px";default:return"32px"}switch(t){case"xs":return"12px";case"s":return"16px";case"l":return"24px";case"xl":return"32px";default:return"20px"}}function toCssSize(e){return/^\d+$/.test(e)?`${e}px`:e}class DbSkeleton extends HTMLElement{static get observedAttributes(){return["variant","size","width","height","animation","lines","line-spacing","last-line-width","aria-label"]}connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}render(){const s=this.getAttribute("variant")||"text",i=this.getAttribute("size")||"m",n=this.getAttribute("animation")||"pulse",r=Number(this.getAttribute("lines")||1),a=this.getAttribute("width"),l=this.getAttribute("height"),c=this.getAttribute("line-spacing")||"8px",u=this.getAttribute("last-line-width")||"60%",o=e.includes(s)?s:"text",h=t.includes(i)?i:"m",d=["designbase-wc-skeleton",`designbase-wc-skeleton--${o}`,`designbase-wc-skeleton--${h}`,`designbase-wc-skeleton--${n}`,(a||l)&&"designbase-wc-skeleton--custom-size"].filter(Boolean).join(" ");this.className!==d&&(this.className=d);const b=this.getAttribute("aria-label")??`${o} 스켈레톤 로딩 중`;if(this.getAttribute("aria-label")!==b&&this.setAttribute("aria-label",b),this.setAttribute("role","status"),this.setAttribute("aria-live","polite"),this.replaceChildren(),this.style.width=a?toCssSize(a):"circular"===o?getDefaultSize(o,h):"100%",this.style.height=l?toCssSize(l):"circular"===o?getDefaultSize(o,h):function getTextLineHeight(e){switch(e){case"xs":return"12px";case"s":return"16px";case"l":return"24px";case"xl":return"32px";default:return"20px"}}(h),"text"===o&&r>1)for(let e=1;e<r;e+=1){const t=document.createElement("div");t.className="designbase-wc-skeleton__line",t.style.marginTop=toCssSize(c),e===r-1&&(t.style.width=toCssSize(u)),this.append(t)}}}customElements.get("db-skeleton")||customElements.define("db-skeleton",DbSkeleton);export{DbSkeleton};
|
|
@@ -1,102 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const SIZES = ['xs', 's', 'm', 'l', 'xl'];
|
|
3
|
-
class DbSpinner extends HTMLElement {
|
|
4
|
-
static get observedAttributes() {
|
|
5
|
-
return ['type', 'size', 'color', 'speed', 'label', 'show-label'];
|
|
6
|
-
}
|
|
7
|
-
get type() {
|
|
8
|
-
return this.getAttribute('type') || 'circular';
|
|
9
|
-
}
|
|
10
|
-
set type(value) {
|
|
11
|
-
this.setAttribute('type', value);
|
|
12
|
-
}
|
|
13
|
-
get size() {
|
|
14
|
-
return this.getAttribute('size') || 'm';
|
|
15
|
-
}
|
|
16
|
-
set size(value) {
|
|
17
|
-
this.setAttribute('size', value);
|
|
18
|
-
}
|
|
19
|
-
get color() {
|
|
20
|
-
return this.getAttribute('color') || '';
|
|
21
|
-
}
|
|
22
|
-
set color(value) {
|
|
23
|
-
if (value)
|
|
24
|
-
this.setAttribute('color', value);
|
|
25
|
-
else
|
|
26
|
-
this.removeAttribute('color');
|
|
27
|
-
}
|
|
28
|
-
get speed() {
|
|
29
|
-
return Number(this.getAttribute('speed') || 1);
|
|
30
|
-
}
|
|
31
|
-
set speed(value) {
|
|
32
|
-
this.setAttribute('speed', String(value));
|
|
33
|
-
}
|
|
34
|
-
get label() {
|
|
35
|
-
return this.getAttribute('label') || '로딩 중...';
|
|
36
|
-
}
|
|
37
|
-
set label(value) {
|
|
38
|
-
this.setAttribute('label', value);
|
|
39
|
-
}
|
|
40
|
-
get showLabel() {
|
|
41
|
-
return this.hasAttribute('show-label');
|
|
42
|
-
}
|
|
43
|
-
set showLabel(value) {
|
|
44
|
-
this.toggleAttribute('show-label', value);
|
|
45
|
-
}
|
|
46
|
-
connectedCallback() {
|
|
47
|
-
this.render();
|
|
48
|
-
}
|
|
49
|
-
attributeChangedCallback() {
|
|
50
|
-
this.render();
|
|
51
|
-
}
|
|
52
|
-
render() {
|
|
53
|
-
this.className = Array.from(this.classList)
|
|
54
|
-
.filter((className) => !className.startsWith('designbase-wc-spinner'))
|
|
55
|
-
.join(' ');
|
|
56
|
-
this.classList.add('designbase-wc-spinner');
|
|
57
|
-
this.classList.add(`designbase-wc-spinner--${TYPES.includes(this.type) ? this.type : 'circular'}`);
|
|
58
|
-
this.classList.add(`designbase-wc-spinner--${SIZES.includes(this.size) ? this.size : 'm'}`);
|
|
59
|
-
this.setAttribute('role', 'status');
|
|
60
|
-
this.setAttribute('aria-live', 'polite');
|
|
61
|
-
this.setAttribute('aria-busy', 'true');
|
|
62
|
-
if (this.showLabel)
|
|
63
|
-
this.setAttribute('aria-label', this.label);
|
|
64
|
-
this.style.setProperty('--spinner-speed', `${this.speed}s`);
|
|
65
|
-
if (this.color)
|
|
66
|
-
this.style.setProperty('--spinner-color', this.color);
|
|
67
|
-
else
|
|
68
|
-
this.style.removeProperty('--spinner-color');
|
|
69
|
-
this.innerHTML = `${this.renderSpinner()}${this.showLabel && this.label
|
|
70
|
-
? `<span class="designbase-wc-spinner__label" aria-hidden="true">${this.escape(this.label)}</span>`
|
|
71
|
-
: ''}`;
|
|
72
|
-
}
|
|
73
|
-
renderSpinner() {
|
|
74
|
-
switch (this.type) {
|
|
75
|
-
case 'dots':
|
|
76
|
-
return '<span class="designbase-wc-spinner__dots" aria-hidden="true"><span class="designbase-wc-spinner__dot"></span><span class="designbase-wc-spinner__dot"></span><span class="designbase-wc-spinner__dot"></span></span>';
|
|
77
|
-
case 'bars':
|
|
78
|
-
return '<span class="designbase-wc-spinner__bars" aria-hidden="true"><span class="designbase-wc-spinner__bar"></span><span class="designbase-wc-spinner__bar"></span><span class="designbase-wc-spinner__bar"></span><span class="designbase-wc-spinner__bar"></span><span class="designbase-wc-spinner__bar"></span></span>';
|
|
79
|
-
case 'pulse':
|
|
80
|
-
return '<span class="designbase-wc-spinner__pulse" aria-hidden="true"></span>';
|
|
81
|
-
case 'ripple':
|
|
82
|
-
return '<span class="designbase-wc-spinner__ripple" aria-hidden="true"><span class="designbase-wc-spinner__ripple-circle"></span><span class="designbase-wc-spinner__ripple-circle"></span></span>';
|
|
83
|
-
case 'circular':
|
|
84
|
-
default:
|
|
85
|
-
return '<svg class="designbase-wc-spinner__circular" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><circle class="designbase-wc-spinner__circular-track" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" fill="none"></circle><circle class="designbase-wc-spinner__circular-indicator" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"></circle></svg>';
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
escape(value) {
|
|
89
|
-
return value.replace(/[&<>"']/g, (char) => ({
|
|
90
|
-
'&': '&',
|
|
91
|
-
'<': '<',
|
|
92
|
-
'>': '>',
|
|
93
|
-
'"': '"',
|
|
94
|
-
"'": ''',
|
|
95
|
-
}[char] || char));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (!customElements.get('db-spinner')) {
|
|
99
|
-
customElements.define('db-spinner', DbSpinner);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export { DbSpinner };
|
|
1
|
+
const s=["circular","dots","bars","pulse","ripple"],e=["xs","s","m","l","xl"];class DbSpinner extends HTMLElement{static get observedAttributes(){return["type","size","color","speed","label","show-label"]}get type(){return this.getAttribute("type")||"circular"}set type(s){this.setAttribute("type",s)}get size(){return this.getAttribute("size")||"m"}set size(s){this.setAttribute("size",s)}get color(){return this.getAttribute("color")||""}set color(s){s?this.setAttribute("color",s):this.removeAttribute("color")}get speed(){return Number(this.getAttribute("speed")||1)}set speed(s){this.setAttribute("speed",String(s))}get label(){return this.getAttribute("label")||"로딩 중..."}set label(s){this.setAttribute("label",s)}get showLabel(){return this.hasAttribute("show-label")}set showLabel(s){this.toggleAttribute("show-label",s)}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}render(){this.className=Array.from(this.classList).filter(s=>!s.startsWith("designbase-wc-spinner")).join(" "),this.classList.add("designbase-wc-spinner"),this.classList.add(`designbase-wc-spinner--${s.includes(this.type)?this.type:"circular"}`),this.classList.add(`designbase-wc-spinner--${e.includes(this.size)?this.size:"m"}`),this.setAttribute("role","status"),this.setAttribute("aria-live","polite"),this.setAttribute("aria-busy","true"),this.showLabel&&this.setAttribute("aria-label",this.label),this.style.setProperty("--spinner-speed",`${this.speed}s`),this.color?this.style.setProperty("--spinner-color",this.color):this.style.removeProperty("--spinner-color"),this.innerHTML=`${this.renderSpinner()}${this.showLabel&&this.label?`<span class="designbase-wc-spinner__label" aria-hidden="true">${this.escape(this.label)}</span>`:""}`}renderSpinner(){switch(this.type){case"dots":return'<span class="designbase-wc-spinner__dots" aria-hidden="true"><span class="designbase-wc-spinner__dot"></span><span class="designbase-wc-spinner__dot"></span><span class="designbase-wc-spinner__dot"></span></span>';case"bars":return'<span class="designbase-wc-spinner__bars" aria-hidden="true"><span class="designbase-wc-spinner__bar"></span><span class="designbase-wc-spinner__bar"></span><span class="designbase-wc-spinner__bar"></span><span class="designbase-wc-spinner__bar"></span><span class="designbase-wc-spinner__bar"></span></span>';case"pulse":return'<span class="designbase-wc-spinner__pulse" aria-hidden="true"></span>';case"ripple":return'<span class="designbase-wc-spinner__ripple" aria-hidden="true"><span class="designbase-wc-spinner__ripple-circle"></span><span class="designbase-wc-spinner__ripple-circle"></span></span>';default:return'<svg class="designbase-wc-spinner__circular" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><circle class="designbase-wc-spinner__circular-track" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" fill="none"></circle><circle class="designbase-wc-spinner__circular-indicator" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"></circle></svg>'}}escape(s){return s.replace(/[&<>"']/g,s=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[s]||s))}}customElements.get("db-spinner")||customElements.define("db-spinner",DbSpinner);export{DbSpinner};
|
|
@@ -1,297 +1 @@
|
|
|
1
|
-
class DbSplitView extends HTMLElement {
|
|
2
|
-
constructor() {
|
|
3
|
-
super(...arguments);
|
|
4
|
-
this.panelSizes = [];
|
|
5
|
-
this.draggingIndex = null;
|
|
6
|
-
this.panelSources = [];
|
|
7
|
-
this.isSyncing = false;
|
|
8
|
-
this.isObserving = false;
|
|
9
|
-
this.handleMouseDown = (index) => (event) => {
|
|
10
|
-
event.preventDefault();
|
|
11
|
-
this.draggingIndex = index;
|
|
12
|
-
document.body.style.cursor = this.getDirection() === 'horizontal' ? 'col-resize' : 'row-resize';
|
|
13
|
-
document.body.style.userSelect = 'none';
|
|
14
|
-
};
|
|
15
|
-
this.handleMouseMove = (event) => {
|
|
16
|
-
if (this.draggingIndex === null)
|
|
17
|
-
return;
|
|
18
|
-
if (!this.panelSources.length)
|
|
19
|
-
return;
|
|
20
|
-
const direction = this.getDirection();
|
|
21
|
-
const mode = this.getMode();
|
|
22
|
-
const splitterSize = this.getSplitterSize();
|
|
23
|
-
const rect = this.getBoundingClientRect();
|
|
24
|
-
const panel = this.panelSources[this.draggingIndex];
|
|
25
|
-
if (!panel)
|
|
26
|
-
return;
|
|
27
|
-
const config = this.readPanelConfig(panel, this.draggingIndex, this.panelSources.length);
|
|
28
|
-
let newSize = this.panelSizes[this.draggingIndex];
|
|
29
|
-
if (direction === 'horizontal') {
|
|
30
|
-
const containerWidth = rect.width;
|
|
31
|
-
const mouseX = event.clientX - rect.left;
|
|
32
|
-
let offsetX = 0;
|
|
33
|
-
for (let i = 0; i < this.draggingIndex; i++) {
|
|
34
|
-
const size = this.panelSizes[i];
|
|
35
|
-
offsetX += mode === 'fixed' ? size : size * containerWidth;
|
|
36
|
-
offsetX += splitterSize;
|
|
37
|
-
}
|
|
38
|
-
const rawSize = mouseX - offsetX;
|
|
39
|
-
if (mode === 'fixed') {
|
|
40
|
-
newSize = Math.max(config.minSize || 0, Math.min(config.maxSize || containerWidth, rawSize));
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
newSize = rawSize / containerWidth;
|
|
44
|
-
const minSplit = config.minSize ? config.minSize / containerWidth : 0;
|
|
45
|
-
const maxSplit = config.maxSize ? config.maxSize / containerWidth : 1;
|
|
46
|
-
newSize = Math.max(minSplit, Math.min(maxSplit, newSize));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
const containerHeight = rect.height;
|
|
51
|
-
const mouseY = event.clientY - rect.top;
|
|
52
|
-
let offsetY = 0;
|
|
53
|
-
for (let i = 0; i < this.draggingIndex; i++) {
|
|
54
|
-
const size = this.panelSizes[i];
|
|
55
|
-
offsetY += mode === 'fixed' ? size : size * containerHeight;
|
|
56
|
-
offsetY += splitterSize;
|
|
57
|
-
}
|
|
58
|
-
const rawSize = mouseY - offsetY;
|
|
59
|
-
if (mode === 'fixed') {
|
|
60
|
-
newSize = Math.max(config.minSize || 0, Math.min(config.maxSize || containerHeight, rawSize));
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
newSize = rawSize / containerHeight;
|
|
64
|
-
const minSplit = config.minSize ? config.minSize / containerHeight : 0;
|
|
65
|
-
const maxSplit = config.maxSize ? config.maxSize / containerHeight : 1;
|
|
66
|
-
newSize = Math.max(minSplit, Math.min(maxSplit, newSize));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
this.panelSizes[this.draggingIndex] = newSize;
|
|
70
|
-
this.applyPanelSizes();
|
|
71
|
-
this.classList.toggle('designbase-wc-split-view--dragging', true);
|
|
72
|
-
};
|
|
73
|
-
this.handleMouseUp = () => {
|
|
74
|
-
if (this.draggingIndex === null)
|
|
75
|
-
return;
|
|
76
|
-
this.draggingIndex = null;
|
|
77
|
-
document.body.style.cursor = '';
|
|
78
|
-
document.body.style.userSelect = '';
|
|
79
|
-
this.classList.toggle('designbase-wc-split-view--dragging', false);
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
static get observedAttributes() {
|
|
83
|
-
return ['direction', 'mode', 'splitter-size', 'splitter-color', 'splitter-hover-color', 'gap', 'full-width', 'full-height'];
|
|
84
|
-
}
|
|
85
|
-
connectedCallback() {
|
|
86
|
-
this.style.display = 'flex';
|
|
87
|
-
this.style.boxSizing = 'border-box';
|
|
88
|
-
this.collectPanelSources();
|
|
89
|
-
this.initPanelSizes();
|
|
90
|
-
this.sync();
|
|
91
|
-
this.observer = new MutationObserver(() => {
|
|
92
|
-
if (this.isSyncing)
|
|
93
|
-
return;
|
|
94
|
-
this.collectPanelSources();
|
|
95
|
-
this.initPanelSizes();
|
|
96
|
-
this.sync();
|
|
97
|
-
});
|
|
98
|
-
this.startObserving();
|
|
99
|
-
document.addEventListener('mousemove', this.handleMouseMove);
|
|
100
|
-
document.addEventListener('mouseup', this.handleMouseUp);
|
|
101
|
-
}
|
|
102
|
-
disconnectedCallback() {
|
|
103
|
-
this.stopObserving();
|
|
104
|
-
document.removeEventListener('mousemove', this.handleMouseMove);
|
|
105
|
-
document.removeEventListener('mouseup', this.handleMouseUp);
|
|
106
|
-
this.draggingIndex = null;
|
|
107
|
-
document.body.style.cursor = '';
|
|
108
|
-
document.body.style.userSelect = '';
|
|
109
|
-
}
|
|
110
|
-
startObserving() {
|
|
111
|
-
if (!this.observer || this.isObserving)
|
|
112
|
-
return;
|
|
113
|
-
this.observer.observe(this, { childList: true });
|
|
114
|
-
this.isObserving = true;
|
|
115
|
-
}
|
|
116
|
-
stopObserving() {
|
|
117
|
-
if (!this.observer || !this.isObserving)
|
|
118
|
-
return;
|
|
119
|
-
this.observer.disconnect();
|
|
120
|
-
this.isObserving = false;
|
|
121
|
-
}
|
|
122
|
-
attributeChangedCallback() {
|
|
123
|
-
if (this.isConnected)
|
|
124
|
-
this.sync();
|
|
125
|
-
}
|
|
126
|
-
collectPanelSources() {
|
|
127
|
-
this.panelSources = [];
|
|
128
|
-
// Keep tracking original panel nodes even after wrapping.
|
|
129
|
-
const slotted = Array.from(this.querySelectorAll('[slot="panel"]'));
|
|
130
|
-
if (slotted.length) {
|
|
131
|
-
this.panelSources = slotted;
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const wrapped = Array.from(this.querySelectorAll(':scope > .designbase-wc-split-view__panel > .designbase-wc-split-view__panel-body'));
|
|
135
|
-
if (wrapped.length) {
|
|
136
|
-
this.panelSources = wrapped
|
|
137
|
-
.map((body) => body.firstElementChild)
|
|
138
|
-
.filter((node) => node instanceof HTMLElement);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
readPanelConfig(element, index, total) {
|
|
142
|
-
const sizeAttr = element.getAttribute('data-size');
|
|
143
|
-
const minSizeAttr = element.getAttribute('data-min-size');
|
|
144
|
-
const maxSizeAttr = element.getAttribute('data-max-size');
|
|
145
|
-
const mode = this.getMode();
|
|
146
|
-
let size;
|
|
147
|
-
if (sizeAttr != null && sizeAttr !== '') {
|
|
148
|
-
size = Number(sizeAttr);
|
|
149
|
-
}
|
|
150
|
-
return {
|
|
151
|
-
size: size !== undefined && Number.isFinite(size)
|
|
152
|
-
? size
|
|
153
|
-
: mode === 'ratio'
|
|
154
|
-
? 1 / total
|
|
155
|
-
: 200,
|
|
156
|
-
minSize: minSizeAttr ? Number(minSizeAttr) : undefined,
|
|
157
|
-
maxSize: maxSizeAttr ? Number(maxSizeAttr) : undefined,
|
|
158
|
-
resizable: element.getAttribute('data-resizable') !== 'false',
|
|
159
|
-
flexible: element.hasAttribute('data-flexible') ||
|
|
160
|
-
(element.getAttribute('data-flexible') !== 'false' && index === total - 1),
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
initPanelSizes() {
|
|
164
|
-
const total = this.panelSources.length;
|
|
165
|
-
if (!total)
|
|
166
|
-
return;
|
|
167
|
-
if (this.panelSizes.length === total)
|
|
168
|
-
return;
|
|
169
|
-
const mode = this.getMode();
|
|
170
|
-
this.panelSizes = this.panelSources.map((panel, index) => {
|
|
171
|
-
const config = this.readPanelConfig(panel, index, total);
|
|
172
|
-
return config.size ?? (mode === 'ratio' ? 1 / total : 200);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
getDirection() {
|
|
176
|
-
const value = this.getAttribute('direction') || 'horizontal';
|
|
177
|
-
return value === 'vertical' ? 'vertical' : 'horizontal';
|
|
178
|
-
}
|
|
179
|
-
getMode() {
|
|
180
|
-
const value = this.getAttribute('mode') || 'ratio';
|
|
181
|
-
return value === 'fixed' ? 'fixed' : 'ratio';
|
|
182
|
-
}
|
|
183
|
-
getSplitterSize() {
|
|
184
|
-
return Number(this.getAttribute('splitter-size') || 4);
|
|
185
|
-
}
|
|
186
|
-
getGap() {
|
|
187
|
-
return Number(this.getAttribute('gap') || 0);
|
|
188
|
-
}
|
|
189
|
-
applyPanelSizes() {
|
|
190
|
-
if (!this.panelSources.length)
|
|
191
|
-
return;
|
|
192
|
-
const direction = this.getDirection();
|
|
193
|
-
const mode = this.getMode();
|
|
194
|
-
const panels = Array.from(this.querySelectorAll(':scope > .designbase-wc-split-view__panel'));
|
|
195
|
-
panels.forEach((panelEl, index) => {
|
|
196
|
-
const source = this.panelSources[index];
|
|
197
|
-
if (!source)
|
|
198
|
-
return;
|
|
199
|
-
const config = this.readPanelConfig(source, index, this.panelSources.length);
|
|
200
|
-
const size = this.panelSizes[index];
|
|
201
|
-
const isFlexible = config.flexible;
|
|
202
|
-
panelEl.style.width = '';
|
|
203
|
-
panelEl.style.height = '';
|
|
204
|
-
panelEl.style.flexBasis = '';
|
|
205
|
-
panelEl.style.flexGrow = '';
|
|
206
|
-
panelEl.style.flexShrink = '';
|
|
207
|
-
panelEl.style.minHeight = '';
|
|
208
|
-
panelEl.style.minWidth = '';
|
|
209
|
-
if (isFlexible) {
|
|
210
|
-
panelEl.style.flex = '1 1 0';
|
|
211
|
-
if (direction === 'vertical')
|
|
212
|
-
panelEl.style.minHeight = '0';
|
|
213
|
-
else
|
|
214
|
-
panelEl.style.minWidth = '0';
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
const basis = mode === 'fixed' ? `${size}px` : `${size * 100}%`;
|
|
218
|
-
panelEl.style.flex = `0 0 ${basis}`;
|
|
219
|
-
}
|
|
220
|
-
panelEl.classList.toggle('designbase-wc-split-view__panel--flexible', Boolean(isFlexible));
|
|
221
|
-
panelEl.classList.toggle('designbase-wc-split-view__panel--fixed', !isFlexible);
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
sync() {
|
|
225
|
-
this.isSyncing = true;
|
|
226
|
-
this.stopObserving();
|
|
227
|
-
this.collectPanelSources();
|
|
228
|
-
this.initPanelSizes();
|
|
229
|
-
if (!this.panelSources.length) {
|
|
230
|
-
this.isSyncing = false;
|
|
231
|
-
this.startObserving();
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
const direction = this.getDirection();
|
|
235
|
-
const mode = this.getMode();
|
|
236
|
-
const gap = this.getGap();
|
|
237
|
-
const splitterSize = this.getSplitterSize();
|
|
238
|
-
const splitterColor = this.getAttribute('splitter-color');
|
|
239
|
-
const splitterHoverColor = this.getAttribute('splitter-hover-color');
|
|
240
|
-
this.className = [
|
|
241
|
-
'designbase-wc-split-view',
|
|
242
|
-
`designbase-wc-split-view--direction-${direction}`,
|
|
243
|
-
`designbase-wc-split-view--mode-${mode}`,
|
|
244
|
-
this.hasAttribute('full-width') && 'designbase-wc-split-view--full-width',
|
|
245
|
-
this.hasAttribute('full-height') && 'designbase-wc-split-view--full-height',
|
|
246
|
-
this.draggingIndex !== null && 'designbase-wc-split-view--dragging',
|
|
247
|
-
]
|
|
248
|
-
.filter(Boolean)
|
|
249
|
-
.join(' ');
|
|
250
|
-
this.style.setProperty('--splitter-size', `${splitterSize}px`);
|
|
251
|
-
if (splitterColor)
|
|
252
|
-
this.style.setProperty('--splitter-color', splitterColor);
|
|
253
|
-
else
|
|
254
|
-
this.style.removeProperty('--splitter-color');
|
|
255
|
-
if (splitterHoverColor)
|
|
256
|
-
this.style.setProperty('--splitter-hover-color', splitterHoverColor);
|
|
257
|
-
else
|
|
258
|
-
this.style.removeProperty('--splitter-hover-color');
|
|
259
|
-
if (gap > 0)
|
|
260
|
-
this.style.gap = `${gap}px`;
|
|
261
|
-
else
|
|
262
|
-
this.style.gap = '';
|
|
263
|
-
const existingPanels = Array.from(this.querySelectorAll(':scope > .designbase-wc-split-view__panel'));
|
|
264
|
-
const existingSplitters = Array.from(this.querySelectorAll(':scope > .designbase-wc-split-view__splitter'));
|
|
265
|
-
existingPanels.forEach((node) => node.remove());
|
|
266
|
-
existingSplitters.forEach((node) => node.remove());
|
|
267
|
-
this.panelSources.forEach((source, index) => {
|
|
268
|
-
const config = this.readPanelConfig(source, index, this.panelSources.length);
|
|
269
|
-
const isLast = index === this.panelSources.length - 1;
|
|
270
|
-
const isResizable = config.resizable !== false && !isLast;
|
|
271
|
-
const panelEl = document.createElement('div');
|
|
272
|
-
panelEl.className = 'designbase-wc-split-view__panel';
|
|
273
|
-
const body = document.createElement('div');
|
|
274
|
-
body.className = 'designbase-wc-split-view__panel-body';
|
|
275
|
-
if (source.parentElement !== body) {
|
|
276
|
-
body.append(source);
|
|
277
|
-
}
|
|
278
|
-
panelEl.append(body);
|
|
279
|
-
this.append(panelEl);
|
|
280
|
-
if (!isLast && isResizable && gap === 0) {
|
|
281
|
-
const splitter = document.createElement('div');
|
|
282
|
-
splitter.className = `designbase-wc-split-view__splitter designbase-wc-split-view__splitter--direction-${direction}`;
|
|
283
|
-
splitter.style.cursor = direction === 'horizontal' ? 'col-resize' : 'row-resize';
|
|
284
|
-
splitter.addEventListener('mousedown', this.handleMouseDown(index));
|
|
285
|
-
this.append(splitter);
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
this.applyPanelSizes();
|
|
289
|
-
this.isSyncing = false;
|
|
290
|
-
this.startObserving();
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
if (!customElements.get('db-split-view')) {
|
|
294
|
-
customElements.define('db-split-view', DbSplitView);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export { DbSplitView };
|
|
1
|
+
class DbSplitView extends HTMLElement{constructor(){super(...arguments),this.panelSizes=[],this.draggingIndex=null,this.panelSources=[],this.isSyncing=!1,this.isObserving=!1,this.handleMouseDown=e=>t=>{t.preventDefault(),this.draggingIndex=e,document.body.style.cursor="horizontal"===this.getDirection()?"col-resize":"row-resize",document.body.style.userSelect="none"},this.handleMouseMove=e=>{if(null===this.draggingIndex)return;if(!this.panelSources.length)return;const t=this.getDirection(),i=this.getMode(),s=this.getSplitterSize(),n=this.getBoundingClientRect(),l=this.panelSources[this.draggingIndex];if(!l)return;const r=this.readPanelConfig(l,this.draggingIndex,this.panelSources.length);let o=this.panelSizes[this.draggingIndex];if("horizontal"===t){const t=n.width,l=e.clientX-n.left;let a=0;for(let e=0;e<this.draggingIndex;e++){const n=this.panelSizes[e];a+="fixed"===i?n:n*t,a+=s}const h=l-a;if("fixed"===i)o=Math.max(r.minSize||0,Math.min(r.maxSize||t,h));else{o=h/t;const e=r.minSize?r.minSize/t:0,i=r.maxSize?r.maxSize/t:1;o=Math.max(e,Math.min(i,o))}}else{const t=n.height,l=e.clientY-n.top;let a=0;for(let e=0;e<this.draggingIndex;e++){const n=this.panelSizes[e];a+="fixed"===i?n:n*t,a+=s}const h=l-a;if("fixed"===i)o=Math.max(r.minSize||0,Math.min(r.maxSize||t,h));else{o=h/t;const e=r.minSize?r.minSize/t:0,i=r.maxSize?r.maxSize/t:1;o=Math.max(e,Math.min(i,o))}}this.panelSizes[this.draggingIndex]=o,this.applyPanelSizes(),this.classList.toggle("designbase-wc-split-view--dragging",!0)},this.handleMouseUp=()=>{null!==this.draggingIndex&&(this.draggingIndex=null,document.body.style.cursor="",document.body.style.userSelect="",this.classList.toggle("designbase-wc-split-view--dragging",!1))}}static get observedAttributes(){return["direction","mode","splitter-size","splitter-color","splitter-hover-color","gap","full-width","full-height"]}connectedCallback(){this.style.display="flex",this.style.boxSizing="border-box",this.collectPanelSources(),this.initPanelSizes(),this.sync(),this.observer=new MutationObserver(()=>{this.isSyncing||(this.collectPanelSources(),this.initPanelSizes(),this.sync())}),this.startObserving(),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}disconnectedCallback(){this.stopObserving(),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),this.draggingIndex=null,document.body.style.cursor="",document.body.style.userSelect=""}startObserving(){this.observer&&!this.isObserving&&(this.observer.observe(this,{childList:!0}),this.isObserving=!0)}stopObserving(){this.observer&&this.isObserving&&(this.observer.disconnect(),this.isObserving=!1)}attributeChangedCallback(){this.isConnected&&this.sync()}collectPanelSources(){this.panelSources=[];const e=Array.from(this.querySelectorAll('[slot="panel"]'));if(e.length)return void(this.panelSources=e);const t=Array.from(this.querySelectorAll(":scope > .designbase-wc-split-view__panel > .designbase-wc-split-view__panel-body"));t.length&&(this.panelSources=t.map(e=>e.firstElementChild).filter(e=>e instanceof HTMLElement))}readPanelConfig(e,t,i){const s=e.getAttribute("data-size"),n=e.getAttribute("data-min-size"),l=e.getAttribute("data-max-size"),r=this.getMode();let o;return null!=s&&""!==s&&(o=Number(s)),{size:void 0!==o&&Number.isFinite(o)?o:"ratio"===r?1/i:200,minSize:n?Number(n):void 0,maxSize:l?Number(l):void 0,resizable:"false"!==e.getAttribute("data-resizable"),flexible:e.hasAttribute("data-flexible")||"false"!==e.getAttribute("data-flexible")&&t===i-1}}initPanelSizes(){const e=this.panelSources.length;if(!e)return;if(this.panelSizes.length===e)return;const t=this.getMode();this.panelSizes=this.panelSources.map((i,s)=>this.readPanelConfig(i,s,e).size??("ratio"===t?1/e:200))}getDirection(){return"vertical"===(this.getAttribute("direction")||"horizontal")?"vertical":"horizontal"}getMode(){return"fixed"===(this.getAttribute("mode")||"ratio")?"fixed":"ratio"}getSplitterSize(){return Number(this.getAttribute("splitter-size")||4)}getGap(){return Number(this.getAttribute("gap")||0)}applyPanelSizes(){if(!this.panelSources.length)return;const e=this.getDirection(),t=this.getMode();Array.from(this.querySelectorAll(":scope > .designbase-wc-split-view__panel")).forEach((i,s)=>{const n=this.panelSources[s];if(!n)return;const l=this.readPanelConfig(n,s,this.panelSources.length),r=this.panelSizes[s],o=l.flexible;if(i.style.width="",i.style.height="",i.style.flexBasis="",i.style.flexGrow="",i.style.flexShrink="",i.style.minHeight="",i.style.minWidth="",o)i.style.flex="1 1 0","vertical"===e?i.style.minHeight="0":i.style.minWidth="0";else{const e="fixed"===t?`${r}px`:100*r+"%";i.style.flex=`0 0 ${e}`}i.classList.toggle("designbase-wc-split-view__panel--flexible",Boolean(o)),i.classList.toggle("designbase-wc-split-view__panel--fixed",!o)})}sync(){if(this.isSyncing=!0,this.stopObserving(),this.collectPanelSources(),this.initPanelSizes(),!this.panelSources.length)return this.isSyncing=!1,void this.startObserving();const e=this.getDirection(),t=this.getMode(),i=this.getGap(),s=this.getSplitterSize(),n=this.getAttribute("splitter-color"),l=this.getAttribute("splitter-hover-color");this.className=["designbase-wc-split-view",`designbase-wc-split-view--direction-${e}`,`designbase-wc-split-view--mode-${t}`,this.hasAttribute("full-width")&&"designbase-wc-split-view--full-width",this.hasAttribute("full-height")&&"designbase-wc-split-view--full-height",null!==this.draggingIndex&&"designbase-wc-split-view--dragging"].filter(Boolean).join(" "),this.style.setProperty("--splitter-size",`${s}px`),n?this.style.setProperty("--splitter-color",n):this.style.removeProperty("--splitter-color"),l?this.style.setProperty("--splitter-hover-color",l):this.style.removeProperty("--splitter-hover-color"),this.style.gap=i>0?`${i}px`:"";const r=Array.from(this.querySelectorAll(":scope > .designbase-wc-split-view__panel")),o=Array.from(this.querySelectorAll(":scope > .designbase-wc-split-view__splitter"));r.forEach(e=>e.remove()),o.forEach(e=>e.remove()),this.panelSources.forEach((t,s)=>{const n=this.readPanelConfig(t,s,this.panelSources.length),l=s===this.panelSources.length-1,r=!1!==n.resizable&&!l,o=document.createElement("div");o.className="designbase-wc-split-view__panel";const a=document.createElement("div");if(a.className="designbase-wc-split-view__panel-body",t.parentElement!==a&&a.append(t),o.append(a),this.append(o),!l&&r&&0===i){const t=document.createElement("div");t.className=`designbase-wc-split-view__splitter designbase-wc-split-view__splitter--direction-${e}`,t.style.cursor="horizontal"===e?"col-resize":"row-resize",t.addEventListener("mousedown",this.handleMouseDown(s)),this.append(t)}}),this.applyPanelSizes(),this.isSyncing=!1,this.startObserving()}}customElements.get("db-split-view")||customElements.define("db-split-view",DbSplitView);export{DbSplitView};
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const ALIGNMENTS = ['start', 'center', 'end', 'stretch'];
|
|
3
|
-
const JUSTIFY = ['start', 'center', 'end', 'space-between', 'space-around', 'space-evenly'];
|
|
4
|
-
const SPACINGS = ['none', 'xs', 's', 'm', 'l', 'xl'];
|
|
5
|
-
class DbStack extends HTMLElement {
|
|
6
|
-
static get observedAttributes() {
|
|
7
|
-
return ['direction', 'alignment', 'justify', 'spacing', 'full-width', 'full-height', 'wrap'];
|
|
8
|
-
}
|
|
9
|
-
connectedCallback() {
|
|
10
|
-
this.syncClasses();
|
|
11
|
-
}
|
|
12
|
-
attributeChangedCallback() {
|
|
13
|
-
this.syncClasses();
|
|
14
|
-
}
|
|
15
|
-
syncClasses() {
|
|
16
|
-
const direction = this.getAttribute('direction') || 'vertical';
|
|
17
|
-
const alignment = this.getAttribute('alignment') || 'start';
|
|
18
|
-
const justify = this.getAttribute('justify') || 'start';
|
|
19
|
-
const spacing = this.getAttribute('spacing') || 'm';
|
|
20
|
-
const spacingAlias = {
|
|
21
|
-
none: 'none',
|
|
22
|
-
xs: 'xs',
|
|
23
|
-
s: 'sm',
|
|
24
|
-
m: 'md',
|
|
25
|
-
l: 'lg',
|
|
26
|
-
xl: 'xl',
|
|
27
|
-
};
|
|
28
|
-
const safeSpacing = SPACINGS.includes(spacing) ? spacing : 'm';
|
|
29
|
-
this.className = [
|
|
30
|
-
'designbase-wc-stack',
|
|
31
|
-
`designbase-wc-stack--direction-${DIRECTIONS.includes(direction) ? direction : 'vertical'}`,
|
|
32
|
-
`designbase-wc-stack--alignment-${ALIGNMENTS.includes(alignment) ? alignment : 'start'}`,
|
|
33
|
-
`designbase-wc-stack--justify-${JUSTIFY.includes(justify) ? justify : 'start'}`,
|
|
34
|
-
`designbase-wc-stack--spacing-${spacingAlias[safeSpacing] || 'md'}`,
|
|
35
|
-
this.hasAttribute('full-width') && 'designbase-wc-stack--full-width',
|
|
36
|
-
this.hasAttribute('full-height') && 'designbase-wc-stack--full-height',
|
|
37
|
-
this.hasAttribute('wrap') && 'designbase-wc-stack--wrap',
|
|
38
|
-
]
|
|
39
|
-
.filter(Boolean)
|
|
40
|
-
.join(' ');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (!customElements.get('db-stack'))
|
|
44
|
-
customElements.define('db-stack', DbStack);
|
|
45
|
-
|
|
46
|
-
export { DbStack };
|
|
1
|
+
const t=["vertical","horizontal"],s=["start","center","end","stretch"],e=["start","center","end","space-between","space-around","space-evenly"],a=["none","xs","s","m","l","xl"];class DbStack extends HTMLElement{static get observedAttributes(){return["direction","alignment","justify","spacing","full-width","full-height","wrap"]}connectedCallback(){this.syncClasses()}attributeChangedCallback(){this.syncClasses()}syncClasses(){const i=this.getAttribute("direction")||"vertical",c=this.getAttribute("alignment")||"start",n=this.getAttribute("justify")||"start",l=this.getAttribute("spacing")||"m",r=a.includes(l)?l:"m";this.className=["designbase-wc-stack",`designbase-wc-stack--direction-${t.includes(i)?i:"vertical"}`,`designbase-wc-stack--alignment-${s.includes(c)?c:"start"}`,`designbase-wc-stack--justify-${e.includes(n)?n:"start"}`,`designbase-wc-stack--spacing-${{none:"none",xs:"xs",s:"sm",m:"md",l:"lg",xl:"xl"}[r]||"md"}`,this.hasAttribute("full-width")&&"designbase-wc-stack--full-width",this.hasAttribute("full-height")&&"designbase-wc-stack--full-height",this.hasAttribute("wrap")&&"designbase-wc-stack--wrap"].filter(Boolean).join(" ")}}customElements.get("db-stack")||customElements.define("db-stack",DbStack);export{DbStack};
|