@designbasekorea/ui-wc 0.5.3 → 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.d.ts +1 -1
- package/dist/react/index.esm.js +39373 -1
- package/package.json +1 -1
- package/dist/chunks/lottie-2d1f6278.js +0 -1
- package/dist/react/chunks/lottie-14e7addb.js +0 -1
|
@@ -1 +1,282 @@
|
|
|
1
|
-
const
|
|
1
|
+
const DIRECTIONS = ['both', 'horizontal', 'vertical'];
|
|
2
|
+
const HANDLE_POSITIONS = ['bottom-right', 'bottom-left', 'top-right', 'top-left', 'right', 'bottom'];
|
|
3
|
+
class DbResizablePanels extends HTMLElement {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.isResizing = false;
|
|
7
|
+
this.startSize = { width: 0, height: 0 };
|
|
8
|
+
this.startPos = { x: 0, y: 0 };
|
|
9
|
+
this.currentSize = { width: 0, height: 0 };
|
|
10
|
+
this.onMouseDown = (event) => {
|
|
11
|
+
event.preventDefault();
|
|
12
|
+
this.startResize(event.clientX, event.clientY);
|
|
13
|
+
document.addEventListener('mousemove', this.onMouseMove);
|
|
14
|
+
document.addEventListener('mouseup', this.onMouseUp);
|
|
15
|
+
};
|
|
16
|
+
this.onTouchStart = (event) => {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
const touch = event.touches[0];
|
|
19
|
+
this.startResize(touch.clientX, touch.clientY);
|
|
20
|
+
document.addEventListener('touchmove', this.onTouchMove, { passive: false });
|
|
21
|
+
document.addEventListener('touchend', this.onTouchEnd);
|
|
22
|
+
};
|
|
23
|
+
this.onMouseMove = (event) => {
|
|
24
|
+
this.applyResize(event.clientX, event.clientY);
|
|
25
|
+
};
|
|
26
|
+
this.onTouchMove = (event) => {
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
const touch = event.touches[0];
|
|
29
|
+
this.applyResize(touch.clientX, touch.clientY);
|
|
30
|
+
};
|
|
31
|
+
this.onMouseUp = () => {
|
|
32
|
+
this.endResize();
|
|
33
|
+
document.removeEventListener('mousemove', this.onMouseMove);
|
|
34
|
+
document.removeEventListener('mouseup', this.onMouseUp);
|
|
35
|
+
};
|
|
36
|
+
this.onTouchEnd = () => {
|
|
37
|
+
this.endResize();
|
|
38
|
+
document.removeEventListener('touchmove', this.onTouchMove);
|
|
39
|
+
document.removeEventListener('touchend', this.onTouchEnd);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
static get observedAttributes() {
|
|
43
|
+
return [
|
|
44
|
+
'initial-width',
|
|
45
|
+
'initial-height',
|
|
46
|
+
'min-width',
|
|
47
|
+
'min-height',
|
|
48
|
+
'max-width',
|
|
49
|
+
'max-height',
|
|
50
|
+
'direction',
|
|
51
|
+
'handle-position',
|
|
52
|
+
'handle-size',
|
|
53
|
+
'handle-color',
|
|
54
|
+
'handle-hover-color',
|
|
55
|
+
'snap-to-grid',
|
|
56
|
+
'show-guides',
|
|
57
|
+
'show-size-indicator',
|
|
58
|
+
'show-constraints',
|
|
59
|
+
'show-border',
|
|
60
|
+
'shadow',
|
|
61
|
+
'background-color',
|
|
62
|
+
'border-radius',
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
connectedCallback() {
|
|
66
|
+
this.ensureStructure();
|
|
67
|
+
this.initializeSize();
|
|
68
|
+
this.render();
|
|
69
|
+
}
|
|
70
|
+
attributeChangedCallback() {
|
|
71
|
+
this.render();
|
|
72
|
+
}
|
|
73
|
+
getBool(name, fallback = false) {
|
|
74
|
+
if (!this.hasAttribute(name))
|
|
75
|
+
return fallback;
|
|
76
|
+
const value = this.getAttribute(name);
|
|
77
|
+
return value === '' || value === 'true';
|
|
78
|
+
}
|
|
79
|
+
getNumber(name, fallback) {
|
|
80
|
+
const value = Number(this.getAttribute(name) ?? fallback);
|
|
81
|
+
return Number.isFinite(value) ? value : fallback;
|
|
82
|
+
}
|
|
83
|
+
getDirection() {
|
|
84
|
+
const value = this.getAttribute('direction');
|
|
85
|
+
return value && DIRECTIONS.includes(value) ? value : 'both';
|
|
86
|
+
}
|
|
87
|
+
getHandlePosition() {
|
|
88
|
+
const value = this.getAttribute('handle-position');
|
|
89
|
+
return value && HANDLE_POSITIONS.includes(value) ? value : 'bottom-right';
|
|
90
|
+
}
|
|
91
|
+
initializeSize() {
|
|
92
|
+
const parentRect = this.parentElement?.getBoundingClientRect();
|
|
93
|
+
if (!parentRect)
|
|
94
|
+
return;
|
|
95
|
+
const initialWidth = this.getAttribute('initial-width') || '100%';
|
|
96
|
+
const initialHeight = this.getAttribute('initial-height') || '100%';
|
|
97
|
+
this.currentSize = {
|
|
98
|
+
width: typeof initialWidth === 'string' && initialWidth.endsWith('%')
|
|
99
|
+
? (parentRect.width * Number(initialWidth.replace('%', ''))) / 100
|
|
100
|
+
: Number(initialWidth) || parentRect.width,
|
|
101
|
+
height: typeof initialHeight === 'string' && initialHeight.endsWith('%')
|
|
102
|
+
? (parentRect.height * Number(initialHeight.replace('%', ''))) / 100
|
|
103
|
+
: Number(initialHeight) || parentRect.height,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
getMinSize() {
|
|
107
|
+
return { width: this.getNumber('min-width', 200), height: this.getNumber('min-height', 150) };
|
|
108
|
+
}
|
|
109
|
+
getMaxSize() {
|
|
110
|
+
const parentRect = this.parentElement?.getBoundingClientRect();
|
|
111
|
+
if (!parentRect)
|
|
112
|
+
return { width: Number.POSITIVE_INFINITY, height: Number.POSITIVE_INFINITY };
|
|
113
|
+
const maxWidth = this.getAttribute('max-width') || '100vw';
|
|
114
|
+
const maxHeight = this.getAttribute('max-height') || '100vh';
|
|
115
|
+
const toSize = (value, viewport, parent) => {
|
|
116
|
+
if (value === '100vw' || value === '100vh')
|
|
117
|
+
return viewport;
|
|
118
|
+
if (value === '100%')
|
|
119
|
+
return parent;
|
|
120
|
+
const num = Number(value);
|
|
121
|
+
return Number.isFinite(num) ? num : Number.POSITIVE_INFINITY;
|
|
122
|
+
};
|
|
123
|
+
return {
|
|
124
|
+
width: toSize(maxWidth, window.innerWidth, parentRect.width),
|
|
125
|
+
height: toSize(maxHeight, window.innerHeight, parentRect.height),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
ensureStructure() {
|
|
129
|
+
if (this.container)
|
|
130
|
+
return;
|
|
131
|
+
this.container = document.createElement('div');
|
|
132
|
+
this.container.className = 'designbase-wc-resizable-panels';
|
|
133
|
+
this.guidesEl = document.createElement('div');
|
|
134
|
+
this.guidesEl.className = 'designbase-wc-resizable-panels__guides';
|
|
135
|
+
const hGuide = document.createElement('div');
|
|
136
|
+
hGuide.className = 'designbase-wc-resizable-panels__guide designbase-wc-resizable-panels__guide--horizontal';
|
|
137
|
+
const vGuide = document.createElement('div');
|
|
138
|
+
vGuide.className = 'designbase-wc-resizable-panels__guide designbase-wc-resizable-panels__guide--vertical';
|
|
139
|
+
this.guidesEl.append(hGuide, vGuide);
|
|
140
|
+
this.sizeIndicatorEl = document.createElement('div');
|
|
141
|
+
this.sizeIndicatorEl.className = 'designbase-wc-resizable-panels__size-indicator';
|
|
142
|
+
this.constraintsEl = document.createElement('div');
|
|
143
|
+
this.constraintsEl.className = 'designbase-wc-resizable-panels__constraints';
|
|
144
|
+
this.contentEl = document.createElement('div');
|
|
145
|
+
this.contentEl.className = 'designbase-wc-resizable-panels__content';
|
|
146
|
+
this.handleEl = document.createElement('div');
|
|
147
|
+
this.handleEl.className = 'designbase-wc-resizable-panels__handle';
|
|
148
|
+
this.handleEl.addEventListener('mousedown', this.onMouseDown);
|
|
149
|
+
this.handleEl.addEventListener('touchstart', this.onTouchStart, { passive: false });
|
|
150
|
+
this.container.append(this.guidesEl, this.sizeIndicatorEl, this.constraintsEl, this.contentEl, this.handleEl);
|
|
151
|
+
this.replaceChildren(this.container);
|
|
152
|
+
}
|
|
153
|
+
startResize(x, y) {
|
|
154
|
+
this.isResizing = true;
|
|
155
|
+
this.startSize = { ...this.currentSize };
|
|
156
|
+
this.startPos = { x, y };
|
|
157
|
+
this.dispatchEvent(new CustomEvent('db-resize-start', { detail: this.currentSize, bubbles: true, composed: true }));
|
|
158
|
+
this.render();
|
|
159
|
+
}
|
|
160
|
+
applyResize(clientX, clientY) {
|
|
161
|
+
if (!this.isResizing)
|
|
162
|
+
return;
|
|
163
|
+
const deltaX = clientX - this.startPos.x;
|
|
164
|
+
const deltaY = clientY - this.startPos.y;
|
|
165
|
+
const direction = this.getDirection();
|
|
166
|
+
let width = this.startSize.width;
|
|
167
|
+
let height = this.startSize.height;
|
|
168
|
+
if (direction === 'both' || direction === 'horizontal')
|
|
169
|
+
width += deltaX;
|
|
170
|
+
if (direction === 'both' || direction === 'vertical')
|
|
171
|
+
height += deltaY;
|
|
172
|
+
const snap = this.getNumber('snap-to-grid', 0);
|
|
173
|
+
if (snap > 0) {
|
|
174
|
+
width = Math.round(width / snap) * snap;
|
|
175
|
+
height = Math.round(height / snap) * snap;
|
|
176
|
+
}
|
|
177
|
+
const min = this.getMinSize();
|
|
178
|
+
const max = this.getMaxSize();
|
|
179
|
+
width = Math.max(min.width, Math.min(max.width, width));
|
|
180
|
+
height = Math.max(min.height, Math.min(max.height, height));
|
|
181
|
+
this.currentSize = { width, height };
|
|
182
|
+
this.dispatchEvent(new CustomEvent('db-resize', { detail: this.currentSize, bubbles: true, composed: true }));
|
|
183
|
+
this.dispatchEvent(new CustomEvent('db-size-change', { detail: this.currentSize, bubbles: true, composed: true }));
|
|
184
|
+
this.render();
|
|
185
|
+
}
|
|
186
|
+
endResize() {
|
|
187
|
+
if (!this.isResizing)
|
|
188
|
+
return;
|
|
189
|
+
this.isResizing = false;
|
|
190
|
+
this.dispatchEvent(new CustomEvent('db-resize-end', { detail: this.currentSize, bubbles: true, composed: true }));
|
|
191
|
+
this.render();
|
|
192
|
+
}
|
|
193
|
+
renderHandleStyle() {
|
|
194
|
+
if (!this.handleEl)
|
|
195
|
+
return;
|
|
196
|
+
const direction = this.getDirection();
|
|
197
|
+
const position = this.getHandlePosition();
|
|
198
|
+
const color = this.getAttribute('handle-color');
|
|
199
|
+
const hoverColor = this.getAttribute('handle-hover-color');
|
|
200
|
+
if (color)
|
|
201
|
+
this.handleEl.style.setProperty('--db-resize-handle-color', color);
|
|
202
|
+
else
|
|
203
|
+
this.handleEl.style.removeProperty('--db-resize-handle-color');
|
|
204
|
+
if (hoverColor)
|
|
205
|
+
this.handleEl.style.setProperty('--db-resize-handle-hover-color', hoverColor);
|
|
206
|
+
else
|
|
207
|
+
this.handleEl.style.removeProperty('--db-resize-handle-hover-color');
|
|
208
|
+
this.handleEl.style.top = '';
|
|
209
|
+
this.handleEl.style.right = '';
|
|
210
|
+
this.handleEl.style.bottom = '';
|
|
211
|
+
this.handleEl.style.left = '';
|
|
212
|
+
this.handleEl.style.transform = '';
|
|
213
|
+
this.handleEl.style.width = '';
|
|
214
|
+
this.handleEl.style.height = '';
|
|
215
|
+
this.handleEl.style.backgroundColor = '';
|
|
216
|
+
this.handleEl.onmouseenter = null;
|
|
217
|
+
this.handleEl.onmouseleave = null;
|
|
218
|
+
let variant = `corner-${position}`;
|
|
219
|
+
if (direction === 'vertical') {
|
|
220
|
+
variant = 'edge-bottom';
|
|
221
|
+
}
|
|
222
|
+
else if (direction === 'horizontal') {
|
|
223
|
+
variant = 'edge-right';
|
|
224
|
+
}
|
|
225
|
+
this.handleEl.className = `designbase-wc-resizable-panels__handle designbase-wc-resizable-panels__handle--${variant}`;
|
|
226
|
+
this.handleEl.setAttribute('role', 'separator');
|
|
227
|
+
this.handleEl.setAttribute('aria-label', '크기 조절');
|
|
228
|
+
this.handleEl.replaceChildren();
|
|
229
|
+
}
|
|
230
|
+
render() {
|
|
231
|
+
this.ensureStructure();
|
|
232
|
+
if (!this.container || !this.contentEl || !this.guidesEl || !this.sizeIndicatorEl || !this.constraintsEl)
|
|
233
|
+
return;
|
|
234
|
+
const classes = [
|
|
235
|
+
'designbase-wc-resizable-panels',
|
|
236
|
+
this.isResizing && 'designbase-wc-resizable-panels--resizing',
|
|
237
|
+
this.getBool('show-border', true) && 'designbase-wc-resizable-panels--border',
|
|
238
|
+
this.getBool('shadow', true) && 'designbase-wc-resizable-panels--shadow',
|
|
239
|
+
]
|
|
240
|
+
.filter(Boolean)
|
|
241
|
+
.join(' ');
|
|
242
|
+
this.container.className = classes;
|
|
243
|
+
this.container.style.width = `${this.currentSize.width}px`;
|
|
244
|
+
this.container.style.height = `${this.currentSize.height}px`;
|
|
245
|
+
const bg = this.getAttribute('background-color');
|
|
246
|
+
this.container.style.backgroundColor = bg || '';
|
|
247
|
+
const radius = this.getAttribute('border-radius') || '8px';
|
|
248
|
+
this.container.style.borderRadius = /^\d+$/.test(radius) ? `${radius}px` : radius;
|
|
249
|
+
if (this.contentEl.children.length === 0) {
|
|
250
|
+
const childNodes = Array.from(this.childNodes).filter((node) => node !== this.container);
|
|
251
|
+
this.contentEl.append(...childNodes);
|
|
252
|
+
}
|
|
253
|
+
this.guidesEl.style.display = this.getBool('show-guides', true) && this.isResizing ? '' : 'none';
|
|
254
|
+
this.sizeIndicatorEl.style.display = this.getBool('show-size-indicator', true) && this.isResizing ? '' : 'none';
|
|
255
|
+
this.sizeIndicatorEl.textContent = `${Math.round(this.currentSize.width)} × ${Math.round(this.currentSize.height)}`;
|
|
256
|
+
this.constraintsEl.style.display = this.getBool('show-constraints', true) && this.isResizing ? '' : 'none';
|
|
257
|
+
this.constraintsEl.replaceChildren();
|
|
258
|
+
if (this.constraintsEl.style.display !== 'none') {
|
|
259
|
+
const min = this.getMinSize();
|
|
260
|
+
const max = this.getMaxSize();
|
|
261
|
+
if (this.currentSize.width <= min.width)
|
|
262
|
+
this.constraintsEl.append(this.makeConstraint('최소 너비 도달', 'min'));
|
|
263
|
+
if (this.currentSize.height <= min.height)
|
|
264
|
+
this.constraintsEl.append(this.makeConstraint('최소 높이 도달', 'min'));
|
|
265
|
+
if (this.currentSize.width >= max.width)
|
|
266
|
+
this.constraintsEl.append(this.makeConstraint('최대 너비 도달', 'max'));
|
|
267
|
+
if (this.currentSize.height >= max.height)
|
|
268
|
+
this.constraintsEl.append(this.makeConstraint('최대 높이 도달', 'max'));
|
|
269
|
+
}
|
|
270
|
+
this.renderHandleStyle();
|
|
271
|
+
}
|
|
272
|
+
makeConstraint(text, kind) {
|
|
273
|
+
const el = document.createElement('div');
|
|
274
|
+
el.className = `designbase-wc-resizable-panels__constraint designbase-wc-resizable-panels__constraint--${kind}`;
|
|
275
|
+
el.textContent = text;
|
|
276
|
+
return el;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (!customElements.get('db-resizable-panels'))
|
|
280
|
+
customElements.define('db-resizable-panels', DbResizablePanels);
|
|
281
|
+
|
|
282
|
+
export { DbResizablePanels };
|
|
@@ -1 +1,126 @@
|
|
|
1
|
-
const
|
|
1
|
+
const DIRECTIONS = ['vertical', 'horizontal', 'both'];
|
|
2
|
+
const SCROLLBAR_STYLES = ['auto', 'thin', 'none'];
|
|
3
|
+
class DbScrollArea extends HTMLElement {
|
|
4
|
+
static get observedAttributes() {
|
|
5
|
+
return [
|
|
6
|
+
'direction',
|
|
7
|
+
'scrollbar-style',
|
|
8
|
+
'max-height',
|
|
9
|
+
'max-width',
|
|
10
|
+
'min-height',
|
|
11
|
+
'min-width',
|
|
12
|
+
'full-width',
|
|
13
|
+
'full-height',
|
|
14
|
+
'always-show-scrollbar',
|
|
15
|
+
'scrollbar-color',
|
|
16
|
+
'scrollbar-track-color',
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
this.ensureStructure();
|
|
21
|
+
this.sync();
|
|
22
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
23
|
+
this.syncViewportSize();
|
|
24
|
+
this.syncScrollState();
|
|
25
|
+
});
|
|
26
|
+
this.resizeObserver.observe(this);
|
|
27
|
+
if (this.contentEl)
|
|
28
|
+
this.resizeObserver.observe(this.contentEl);
|
|
29
|
+
this.observer = new MutationObserver(() => this.syncChildren());
|
|
30
|
+
this.observer.observe(this, { childList: true, subtree: true });
|
|
31
|
+
}
|
|
32
|
+
disconnectedCallback() {
|
|
33
|
+
this.resizeObserver?.disconnect();
|
|
34
|
+
this.observer?.disconnect();
|
|
35
|
+
}
|
|
36
|
+
attributeChangedCallback() {
|
|
37
|
+
if (this.isConnected)
|
|
38
|
+
this.sync();
|
|
39
|
+
}
|
|
40
|
+
ensureStructure() {
|
|
41
|
+
if (!this.contentEl) {
|
|
42
|
+
this.contentEl = document.createElement('div');
|
|
43
|
+
this.contentEl.className = 'designbase-wc-scroll-area__content';
|
|
44
|
+
this.contentEl.setAttribute('data-wc-internal', '');
|
|
45
|
+
}
|
|
46
|
+
if (!this.contentEl.isConnected) {
|
|
47
|
+
this.append(this.contentEl);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
collectContentNodes() {
|
|
51
|
+
return Array.from(this.children).filter((child) => child !== this.contentEl && !child.hasAttribute('data-wc-internal'));
|
|
52
|
+
}
|
|
53
|
+
syncChildren() {
|
|
54
|
+
const nodes = this.collectContentNodes();
|
|
55
|
+
if (nodes.length) {
|
|
56
|
+
this.contentEl?.append(...nodes);
|
|
57
|
+
}
|
|
58
|
+
this.syncScrollState();
|
|
59
|
+
}
|
|
60
|
+
toCssSize(value) {
|
|
61
|
+
if (!value)
|
|
62
|
+
return undefined;
|
|
63
|
+
if (value.includes('px') || value.includes('%') || value.includes('vh') || value.includes('rem')) {
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
const numeric = Number(value);
|
|
67
|
+
return Number.isFinite(numeric) ? `${numeric}px` : value;
|
|
68
|
+
}
|
|
69
|
+
syncScrollState() {
|
|
70
|
+
const viewport = this.contentEl;
|
|
71
|
+
if (!viewport)
|
|
72
|
+
return;
|
|
73
|
+
const hasVertical = viewport.scrollHeight > viewport.clientHeight;
|
|
74
|
+
const hasHorizontal = viewport.scrollWidth > viewport.clientWidth;
|
|
75
|
+
this.classList.toggle('designbase-wc-scroll-area--has-vertical', hasVertical);
|
|
76
|
+
this.classList.toggle('designbase-wc-scroll-area--has-horizontal', hasHorizontal);
|
|
77
|
+
}
|
|
78
|
+
syncViewportSize() {
|
|
79
|
+
if (!this.contentEl)
|
|
80
|
+
return;
|
|
81
|
+
const maxHeight = this.toCssSize(this.getAttribute('max-height')) || this.style.maxHeight || undefined;
|
|
82
|
+
const maxWidth = this.toCssSize(this.getAttribute('max-width')) || this.style.maxWidth || undefined;
|
|
83
|
+
const minHeight = this.toCssSize(this.getAttribute('min-height')) || this.style.minHeight || undefined;
|
|
84
|
+
const minWidth = this.toCssSize(this.getAttribute('min-width')) || this.style.minWidth || undefined;
|
|
85
|
+
this.contentEl.style.maxHeight = maxHeight || '';
|
|
86
|
+
this.contentEl.style.maxWidth = maxWidth || '';
|
|
87
|
+
this.contentEl.style.minHeight = minHeight || '';
|
|
88
|
+
this.contentEl.style.minWidth = minWidth || '';
|
|
89
|
+
}
|
|
90
|
+
sync() {
|
|
91
|
+
this.ensureStructure();
|
|
92
|
+
const direction = this.getAttribute('direction') || 'vertical';
|
|
93
|
+
const scrollbarStyle = this.getAttribute('scrollbar-style') || 'auto';
|
|
94
|
+
const safeDirection = DIRECTIONS.includes(direction) ? direction : 'vertical';
|
|
95
|
+
const safeScrollbar = SCROLLBAR_STYLES.includes(scrollbarStyle)
|
|
96
|
+
? scrollbarStyle
|
|
97
|
+
: 'auto';
|
|
98
|
+
this.className = [
|
|
99
|
+
'designbase-wc-scroll-area',
|
|
100
|
+
`designbase-wc-scroll-area--direction-${safeDirection}`,
|
|
101
|
+
`designbase-wc-scroll-area--scrollbar-${safeScrollbar}`,
|
|
102
|
+
this.hasAttribute('full-width') && 'designbase-wc-scroll-area--full-width',
|
|
103
|
+
this.hasAttribute('full-height') && 'designbase-wc-scroll-area--full-height',
|
|
104
|
+
this.hasAttribute('always-show-scrollbar') && 'designbase-wc-scroll-area--always-show',
|
|
105
|
+
]
|
|
106
|
+
.filter(Boolean)
|
|
107
|
+
.join(' ');
|
|
108
|
+
const scrollbarColor = this.getAttribute('scrollbar-color');
|
|
109
|
+
const scrollbarTrackColor = this.getAttribute('scrollbar-track-color');
|
|
110
|
+
if (scrollbarColor)
|
|
111
|
+
this.style.setProperty('--scrollbar-color', scrollbarColor);
|
|
112
|
+
else
|
|
113
|
+
this.style.removeProperty('--scrollbar-color');
|
|
114
|
+
if (scrollbarTrackColor)
|
|
115
|
+
this.style.setProperty('--scrollbar-track-color', scrollbarTrackColor);
|
|
116
|
+
else
|
|
117
|
+
this.style.removeProperty('--scrollbar-track-color');
|
|
118
|
+
this.syncViewportSize();
|
|
119
|
+
this.syncChildren();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!customElements.get('db-scroll-area')) {
|
|
123
|
+
customElements.define('db-scroll-area', DbScrollArea);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { DbScrollArea };
|