@luzmo/lucero 2.0.1 → 2.1.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/README.md +1 -0
- package/components/index.cjs +1 -1
- package/components/index.js +8 -7
- package/components/split-view/index.cjs +18 -0
- package/components/split-view/index.d.ts +7 -0
- package/components/split-view/index.js +25 -0
- package/components/split-view/split-view-model.d.ts +12 -0
- package/components/split-view/split-view.d.ts +106 -0
- package/components/split-view-5uMSU_b7.cjs +43 -0
- package/components/split-view-FxpiSCem.js +359 -0
- package/custom-elements.json +1 -1
- package/index.d.ts +1 -0
- package/package.json +7 -1
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/*! * Lucero - The design system for Luzmo.
|
|
2
|
+
*
|
|
3
|
+
* Copyright © 2025 Luzmo
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Lucero (“Luzmo Design System”) must be used according to the Luzmo Terms of Service.
|
|
6
|
+
* This license allows users with a current active Luzmo account to use Lucero.
|
|
7
|
+
* This license terminates automatically if a user no longer has an active Luzmo account.
|
|
8
|
+
* Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
|
|
9
|
+
*
|
|
10
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
12
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
13
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
14
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
|
+
* SOFTWARE.
|
|
17
|
+
* */
|
|
18
|
+
import { t as e } from "./decorate-CkCg3wfh.js";
|
|
19
|
+
import { t } from "./focusable-DuP0-Kuy.js";
|
|
20
|
+
import { html as n, nothing as r, unsafeCSS as i } from "lit";
|
|
21
|
+
import { property as a, query as o } from "lit/decorators.js";
|
|
22
|
+
//#region src/components/split-view/split-view-model.ts
|
|
23
|
+
function s(e, t) {
|
|
24
|
+
let n = Math.max(0, t.primaryMin, e - t.secondaryMax), r = Math.min(e, t.primaryMax, e - t.secondaryMin);
|
|
25
|
+
if (n <= r) return {
|
|
26
|
+
min: n,
|
|
27
|
+
max: r
|
|
28
|
+
};
|
|
29
|
+
let i = Math.min(e, Math.max(0, e / 2));
|
|
30
|
+
return {
|
|
31
|
+
min: i,
|
|
32
|
+
max: i
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function c(e, t) {
|
|
36
|
+
return Math.min(t.max, Math.max(t.min, e));
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/components/split-view/split-view.module.scss?inline
|
|
40
|
+
var l = ":host{min-block-size:0;min-inline-size:0;display:flex;position:relative}:host([vertical]){flex-direction:column}slot{display:contents}::slotted(*){min-block-size:0;min-inline-size:0}::slotted(:nth-child(n+3)){display:none!important}.separator{cursor:col-resize;block-size:100%;inline-size:var(--split-view-target-size);touch-action:none;z-index:1;outline:none;justify-content:center;align-items:center;display:flex;position:absolute;inset-block-start:0;inset-inline-start:calc(var(--splitter-position,0) * 1px - var(--split-view-target-size) / 2)}:host([vertical]) .separator{block-size:var(--split-view-target-size);cursor:row-resize;inline-size:100%;inset-block-start:calc(var(--splitter-position,0) * 1px - var(--split-view-target-size) / 2);inset-inline-start:0}.separator .divider{background-color:var(--luzmo-split-view-divider-color,var(--split-view-divider-color));block-size:100%;inline-size:var(--luzmo-split-view-divider-thickness,var(--split-view-divider-thickness));pointer-events:none}.separator .handle{background-color:var(--luzmo-split-view-divider-color,var(--split-view-handle-color));block-size:var(--split-view-handle-length);border-radius:var(--split-view-handle-radius);inline-size:var(--split-view-handle-thickness);pointer-events:none;display:none;position:absolute}:host([resizable]) .separator .handle{display:block}:host([vertical]) .separator .divider{block-size:var(--luzmo-split-view-divider-thickness,var(--split-view-divider-thickness));inline-size:100%}:host([vertical]) .separator .handle{block-size:var(--split-view-handle-thickness);inline-size:var(--split-view-handle-length)}:host(:not([vertical])) .separator.start-edge{inset-inline-start:0}:host(:not([vertical])) .separator.end-edge{inset-inline-start:calc(100% - var(--split-view-target-size))}:host(:not([vertical])) .separator.start-edge .divider,:host(:not([vertical])) .separator.end-edge .divider,:host([vertical]) .separator.start-edge .divider,:host([vertical]) .separator.end-edge .divider{position:absolute}:host(:not([vertical])) .separator.start-edge .divider{inset-inline-start:0}:host(:not([vertical])) .separator.start-edge .handle{inset-inline-start:calc(var(--split-view-focus-width) + var(--split-view-focus-offset))}:host(:not([vertical])) .separator.end-edge .divider{inset-inline-end:0}:host(:not([vertical])) .separator.end-edge .handle{inset-inline-end:calc(var(--split-view-focus-width) + var(--split-view-focus-offset))}:host([vertical]) .separator.start-edge{inset-block-start:0}:host([vertical]) .separator.end-edge{inset-block-start:calc(100% - var(--split-view-target-size))}:host([vertical]) .separator.start-edge .divider{inset-block-start:0}:host([vertical]) .separator.start-edge .handle{inset-block-start:calc(var(--split-view-focus-width) + var(--split-view-focus-offset))}:host([vertical]) .separator.end-edge .divider{inset-block-end:0}:host([vertical]) .separator.end-edge .handle{inset-block-end:calc(var(--split-view-focus-width) + var(--split-view-focus-offset))}:host([resizable]:not([disabled])) .separator:hover .divider,:host([resizable]:not([disabled])) .separator:hover .handle{background-color:var(--luzmo-split-view-divider-color-hover,var(--split-view-divider-color-hover))}:host([dragging]) .separator .divider,:host([dragging]) .separator .handle{background-color:var(--luzmo-split-view-divider-color-active,var(--split-view-divider-color-active))}.separator:focus-visible .divider{background-color:var(--luzmo-split-view-focus-color,var(--split-view-focus-color))}.separator:focus-visible .handle{outline:var(--split-view-focus-width) solid var(--luzmo-split-view-focus-color,var(--split-view-focus-color));outline-offset:var(--split-view-focus-offset)}:host(:not([resizable])) .separator,:host([disabled]) .separator{cursor:default}@media (forced-colors:active){:host{--highcontrast-split-view-divider-color:CanvasText;--highcontrast-split-view-focus-color:Highlight}.separator .divider,.separator .handle{background-color:var(--highcontrast-split-view-divider-color,var(--luzmo-split-view-divider-color,var(--split-view-divider-color)))}:host([resizable]:not([disabled])) .separator:hover .divider,:host([resizable]:not([disabled])) .separator:hover .handle,:host([dragging]) .separator .divider,:host([dragging]) .separator .handle{background-color:highlight}.separator:focus-visible .divider{background-color:var(--highcontrast-split-view-focus-color,var(--luzmo-split-view-focus-color,var(--split-view-focus-color)))}.separator:focus-visible .handle{outline-color:var(--highcontrast-split-view-focus-color,var(--luzmo-split-view-focus-color,var(--split-view-focus-color)))}}:host{--split-view-divider-color:var(--luzmo-border-color-full);--split-view-divider-color-hover:var(--luzmo-primary-hover);--split-view-divider-color-active:var(--luzmo-primary-down);--split-view-divider-thickness:var(--luzmo-border-width);--split-view-focus-color:var(--luzmo-primary-focus);--split-view-target-size:var(--luzmo-component-height-xs);--split-view-focus-offset:var(--luzmo-border-width);--split-view-focus-width:var(--luzmo-indicator-width,1px);--split-view-handle-color:var(--luzmo-font-color-extra-dimmed);--split-view-handle-length:var(--luzmo-component-height);--split-view-handle-thickness:var(--luzmo-spacing-2);--split-view-handle-radius:var(--luzmo-border-radius-full)}", u = 3840, d = 10, f = 50, p = 50, m = 0, h = class extends t {
|
|
41
|
+
constructor(...e) {
|
|
42
|
+
super(...e), this.vertical = !1, this.collapsible = !1, this.label = "Resize panels", this.primarySize = "50%", this._primaryMin = 0, this._primaryMax = u, this._secondaryMin = 0, this._secondaryMax = u, this._resizable = !1, this._splitterPos = 0, this._viewSize = 0, this._minPos = 0, this._maxPos = 0, this._enoughChildren = !1, this._positionInitialized = !1, this._initialSplitterPosSupplied = !1, this._activePanes = [], this._restorePositionOnReconnect = !1, this._paneInlineStyles = /* @__PURE__ */ new Map(), this._dragChanged = !1;
|
|
43
|
+
}
|
|
44
|
+
static get styles() {
|
|
45
|
+
let e = super.styles;
|
|
46
|
+
return [...Array.isArray(e) ? e : e ? [e] : [], i(l)];
|
|
47
|
+
}
|
|
48
|
+
set resizable(e) {
|
|
49
|
+
let t = !!e;
|
|
50
|
+
if (t === this._resizable) return;
|
|
51
|
+
let n = this._resizable;
|
|
52
|
+
this._resizable = t, t || this._cancelDrag(), this.requestUpdate("resizable", n);
|
|
53
|
+
}
|
|
54
|
+
get resizable() {
|
|
55
|
+
return this._resizable;
|
|
56
|
+
}
|
|
57
|
+
set primaryMin(e) {
|
|
58
|
+
let t = this._normalizeBound(e, 0);
|
|
59
|
+
if (t === this._primaryMin) return;
|
|
60
|
+
let n = this._primaryMin;
|
|
61
|
+
this._primaryMin = t, this.requestUpdate("primaryMin", n);
|
|
62
|
+
}
|
|
63
|
+
get primaryMin() {
|
|
64
|
+
return this._primaryMin;
|
|
65
|
+
}
|
|
66
|
+
set primaryMax(e) {
|
|
67
|
+
let t = this._normalizeBound(e, u);
|
|
68
|
+
if (t === this._primaryMax) return;
|
|
69
|
+
let n = this._primaryMax;
|
|
70
|
+
this._primaryMax = t, this.requestUpdate("primaryMax", n);
|
|
71
|
+
}
|
|
72
|
+
get primaryMax() {
|
|
73
|
+
return this._primaryMax;
|
|
74
|
+
}
|
|
75
|
+
set secondaryMin(e) {
|
|
76
|
+
let t = this._normalizeBound(e, 0);
|
|
77
|
+
if (t === this._secondaryMin) return;
|
|
78
|
+
let n = this._secondaryMin;
|
|
79
|
+
this._secondaryMin = t, this.requestUpdate("secondaryMin", n);
|
|
80
|
+
}
|
|
81
|
+
get secondaryMin() {
|
|
82
|
+
return this._secondaryMin;
|
|
83
|
+
}
|
|
84
|
+
set secondaryMax(e) {
|
|
85
|
+
let t = this._normalizeBound(e, u);
|
|
86
|
+
if (t === this._secondaryMax) return;
|
|
87
|
+
let n = this._secondaryMax;
|
|
88
|
+
this._secondaryMax = t, this.requestUpdate("secondaryMax", n);
|
|
89
|
+
}
|
|
90
|
+
get secondaryMax() {
|
|
91
|
+
return this._secondaryMax;
|
|
92
|
+
}
|
|
93
|
+
set splitterPos(e) {
|
|
94
|
+
this._positionInitialized || (this._initialSplitterPosSupplied = !0);
|
|
95
|
+
let t = Number.isFinite(e) ? e : 0, n = this.collapsible && (t === 0 || t === this._viewSize), r = this._positionInitialized && !n ? this._clampPosition(t) : t;
|
|
96
|
+
if (r === this._splitterPos) return;
|
|
97
|
+
let i = this._splitterPos;
|
|
98
|
+
this._splitterPos = r, this.requestUpdate("splitterPos", i);
|
|
99
|
+
}
|
|
100
|
+
get splitterPos() {
|
|
101
|
+
return this._splitterPos;
|
|
102
|
+
}
|
|
103
|
+
get focusElement() {
|
|
104
|
+
return this._separator ?? this;
|
|
105
|
+
}
|
|
106
|
+
connectedCallback() {
|
|
107
|
+
this._positionInitialized || (this._initialSplitterPosSupplied = this._initialSplitterPosSupplied || this.hasAttribute("splitter-pos")), super.connectedCallback(), typeof ResizeObserver < "u" && (this._resizeObserver ??= new ResizeObserver(() => {
|
|
108
|
+
this._recalculate(!1);
|
|
109
|
+
}), this._resizeObserver.observe(this)), this.updateComplete.then(() => {
|
|
110
|
+
this.isConnected && this.handleSlotChange();
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
disconnectedCallback() {
|
|
114
|
+
this._cancelDrag(!1), this._resizeObserver?.disconnect(), this._restorePaneStyles(), this._activePanes = [], this._restorePositionOnReconnect = !0, this._clearControlledElementId(), this._controlledElement = void 0, super.disconnectedCallback();
|
|
115
|
+
}
|
|
116
|
+
_normalizeBound(e, t) {
|
|
117
|
+
return Number.isFinite(e) && e >= 0 ? e : t;
|
|
118
|
+
}
|
|
119
|
+
_measureView() {
|
|
120
|
+
let e = this.getBoundingClientRect();
|
|
121
|
+
return this.vertical ? e.height : e.width;
|
|
122
|
+
}
|
|
123
|
+
_calculateBounds() {
|
|
124
|
+
this._viewSize = this._measureView();
|
|
125
|
+
let e = s(this._viewSize, {
|
|
126
|
+
primaryMin: this.primaryMin,
|
|
127
|
+
primaryMax: this.primaryMax,
|
|
128
|
+
secondaryMin: this.secondaryMin,
|
|
129
|
+
secondaryMax: this.secondaryMax
|
|
130
|
+
});
|
|
131
|
+
this._minPos = e.min, this._maxPos = e.max;
|
|
132
|
+
}
|
|
133
|
+
_clampPosition(e) {
|
|
134
|
+
return c(e, {
|
|
135
|
+
min: this._minPos,
|
|
136
|
+
max: this._maxPos
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
_resolveInitialPosition() {
|
|
140
|
+
let e = this.primarySize.trim();
|
|
141
|
+
if (/^\d+(?:\.\d+)?(?:px)?$/.test(e)) return Number.parseFloat(e);
|
|
142
|
+
if (/^\d+(?:\.\d+)?%$/.test(e)) return Number.parseFloat(e) / 100 * this._viewSize;
|
|
143
|
+
if (e === "auto" && this._controlledElement) {
|
|
144
|
+
let e = Number.parseFloat(this._controlledElement.style.getPropertyValue(this.vertical ? "block-size" : "inline-size"));
|
|
145
|
+
if (Number.isFinite(e) && e > 0) return e;
|
|
146
|
+
let t = Number.parseFloat(getComputedStyle(this._controlledElement).getPropertyValue(this.vertical ? "height" : "width"));
|
|
147
|
+
if (Number.isFinite(t) && t > 0) return t;
|
|
148
|
+
let n = this._controlledElement.getBoundingClientRect(), r = this.vertical ? n.height : n.width;
|
|
149
|
+
if (Number.isFinite(r) && r > 0) return r;
|
|
150
|
+
}
|
|
151
|
+
return this._viewSize / 2;
|
|
152
|
+
}
|
|
153
|
+
_applyPaneSizes() {
|
|
154
|
+
let [e, t] = this._activePanes, n = Math.round(this.splitterPos), r = Math.round(this._viewSize);
|
|
155
|
+
e && (e.style.flex = `0 0 ${n}px`, e.style.display = r > 0 && n <= 0 ? "none" : this._paneInlineStyles.get(e)?.display ?? ""), t && (t.style.flex = "1 1 0", t.style.display = r > 0 && n >= r ? "none" : this._paneInlineStyles.get(t)?.display ?? "");
|
|
156
|
+
}
|
|
157
|
+
_restorePaneStyles() {
|
|
158
|
+
for (let [e, t] of this._paneInlineStyles) e.style.display = t.display, e.style.flex = t.flex;
|
|
159
|
+
this._paneInlineStyles.clear();
|
|
160
|
+
}
|
|
161
|
+
_setActivePanes(e) {
|
|
162
|
+
let t = e.slice(0, 2), n = t.length !== this._activePanes.length || t.some((e, t) => e !== this._activePanes[t]);
|
|
163
|
+
if (n && (this._restorePaneStyles(), this._activePanes = t), n || this._paneInlineStyles.size === 0) for (let e of t) this._paneInlineStyles.set(e, {
|
|
164
|
+
display: e.style.display,
|
|
165
|
+
flex: e.style.flex
|
|
166
|
+
});
|
|
167
|
+
return n;
|
|
168
|
+
}
|
|
169
|
+
_recalculate(e) {
|
|
170
|
+
if (!this.isConnected || !this._enoughChildren) return;
|
|
171
|
+
let t = this._viewSize, n = this._positionInitialized && this.collapsible && this.splitterPos === 0, r = this._positionInitialized && this.collapsible && t > 0 && this.splitterPos === t;
|
|
172
|
+
this._calculateBounds();
|
|
173
|
+
let i;
|
|
174
|
+
this._positionInitialized ? i = e ? this._resolveInitialPosition() : n ? 0 : r ? this._viewSize : this._clampPosition(this.splitterPos) : (i = this._initialSplitterPosSupplied ? this.splitterPos : this._resolveInitialPosition(), this._positionInitialized = !0), this.splitterPos = i, this._applyPaneSizes();
|
|
175
|
+
}
|
|
176
|
+
_syncAriaControls() {
|
|
177
|
+
!this._separator || !this._controlledElement || (this._separator.ariaControlsElements = [this._controlledElement]);
|
|
178
|
+
}
|
|
179
|
+
_clearControlledElementId() {
|
|
180
|
+
this._controlledElement && this._controlledElement.id === this._controlledElementGeneratedId && this._controlledElement.removeAttribute("id"), this._controlledElementGeneratedId = void 0;
|
|
181
|
+
}
|
|
182
|
+
handleSlotChange() {
|
|
183
|
+
let e = this._paneSlot?.assignedElements() ?? [], t = this._setActivePanes(e), n = e[0];
|
|
184
|
+
n !== this._controlledElement && (this._clearControlledElementId(), this._controlledElement = n), this._controlledElement && !this._controlledElement.id && (m += 1, this._controlledElementGeneratedId = `luzmo-split-view-pane-${m}`, this._controlledElement.id = this._controlledElementGeneratedId);
|
|
185
|
+
let r = this._enoughChildren, i = e.length >= 2;
|
|
186
|
+
if (i !== this._enoughChildren && (this._enoughChildren = i, this.requestUpdate()), i) {
|
|
187
|
+
let e = !r || t && !this._restorePositionOnReconnect;
|
|
188
|
+
this._restorePositionOnReconnect = !1, this.updateComplete.then(() => {
|
|
189
|
+
this._recalculate(e), this._syncAriaControls();
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
_dispatchValueEvent(e) {
|
|
194
|
+
this.dispatchEvent(new Event(e, {
|
|
195
|
+
bubbles: !0,
|
|
196
|
+
composed: !0
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
_setPosition(e, t = {}) {
|
|
200
|
+
let n = this._clampPosition(e);
|
|
201
|
+
return this.collapsible && t.collapse && (e <= 0 && (n = 0), e >= this._viewSize && (n = this._viewSize)), n === this.splitterPos ? !1 : (this.splitterPos > 0 && this.splitterPos < this._viewSize && (this._lastExpandedPosition = this.splitterPos), this.splitterPos = n, this._applyPaneSizes(), (t.emit ?? !0) && this._dispatchValueEvent("input"), !0);
|
|
202
|
+
}
|
|
203
|
+
handleKeydown(e) {
|
|
204
|
+
if (!this.resizable || this.disabled) return;
|
|
205
|
+
let t;
|
|
206
|
+
switch (e.key) {
|
|
207
|
+
case "ArrowLeft":
|
|
208
|
+
this.vertical || (t = this.splitterPos + (this.isLTR ? -10 : d));
|
|
209
|
+
break;
|
|
210
|
+
case "ArrowRight":
|
|
211
|
+
this.vertical || (t = this.splitterPos + (this.isLTR ? d : -10));
|
|
212
|
+
break;
|
|
213
|
+
case "ArrowUp":
|
|
214
|
+
this.vertical && (t = this.splitterPos - d);
|
|
215
|
+
break;
|
|
216
|
+
case "ArrowDown":
|
|
217
|
+
this.vertical && (t = this.splitterPos + d);
|
|
218
|
+
break;
|
|
219
|
+
case "PageUp":
|
|
220
|
+
t = this.splitterPos + (this.vertical ? -50 : f);
|
|
221
|
+
break;
|
|
222
|
+
case "PageDown":
|
|
223
|
+
t = this.splitterPos + (this.vertical ? f : -50);
|
|
224
|
+
break;
|
|
225
|
+
case "Home":
|
|
226
|
+
t = this.collapsible ? 0 : this._minPos;
|
|
227
|
+
break;
|
|
228
|
+
case "End":
|
|
229
|
+
t = this.collapsible ? this._viewSize : this._maxPos;
|
|
230
|
+
break;
|
|
231
|
+
case "Enter":
|
|
232
|
+
if (!this.collapsible) return;
|
|
233
|
+
t = this.splitterPos === 0 ? this._lastExpandedPosition ?? this._viewSize / 2 : 0;
|
|
234
|
+
break;
|
|
235
|
+
default: return;
|
|
236
|
+
}
|
|
237
|
+
t !== void 0 && (e.preventDefault(), this._setPosition(t, { collapse: !0 }) && this._dispatchValueEvent("change"));
|
|
238
|
+
}
|
|
239
|
+
_capturePointer(e, t) {
|
|
240
|
+
try {
|
|
241
|
+
e.setPointerCapture(t), this._capturedPointer = {
|
|
242
|
+
target: e,
|
|
243
|
+
pointerId: t
|
|
244
|
+
};
|
|
245
|
+
} catch {
|
|
246
|
+
this._capturedPointer = void 0;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
_releasePointer() {
|
|
250
|
+
let e = this._capturedPointer;
|
|
251
|
+
this._capturedPointer = void 0, e?.target.hasPointerCapture(e.pointerId) && e.target.releasePointerCapture(e.pointerId);
|
|
252
|
+
}
|
|
253
|
+
handlePointerDown(e) {
|
|
254
|
+
!this.resizable || this.disabled || e.button !== 0 || this._dragStartPosition !== void 0 || (this._dragPointerId = e.pointerId, this._dragStartPosition = this.splitterPos, this._dragChanged = !1, this.toggleAttribute("dragging", !0), this._capturePointer(e.currentTarget, e.pointerId));
|
|
255
|
+
}
|
|
256
|
+
_pointerPosition(e) {
|
|
257
|
+
let t = this.getBoundingClientRect();
|
|
258
|
+
return this.vertical ? e.clientY - t.top : this.isLTR ? e.clientX - t.left : t.right - e.clientX;
|
|
259
|
+
}
|
|
260
|
+
handlePointerMove(e) {
|
|
261
|
+
if (this._dragPointerId !== e.pointerId || this._dragStartPosition === void 0 || !this.resizable || this.disabled) return;
|
|
262
|
+
let t = this._pointerPosition(e);
|
|
263
|
+
this.collapsible && t < this._minPos - p && (t = 0), this.collapsible && t > this._maxPos + p && (t = this._viewSize), this._setPosition(t, { collapse: !0 }) && (this._dragChanged = !0);
|
|
264
|
+
}
|
|
265
|
+
_finishDrag() {
|
|
266
|
+
this._dragPointerId = void 0, this._releasePointer(), this._dragStartPosition = void 0, this._dragChanged = !1, this.toggleAttribute("dragging", !1);
|
|
267
|
+
}
|
|
268
|
+
handlePointerUp(e) {
|
|
269
|
+
if (this._dragPointerId !== e.pointerId || this._dragStartPosition === void 0) return;
|
|
270
|
+
let t = this._dragChanged;
|
|
271
|
+
this._finishDrag(), t && this._dispatchValueEvent("change");
|
|
272
|
+
}
|
|
273
|
+
_cancelDrag(e = !0) {
|
|
274
|
+
if (this._dragStartPosition === void 0) return;
|
|
275
|
+
let t = this._dragStartPosition, n = this._dragChanged;
|
|
276
|
+
this._finishDrag(), e && n && this._setPosition(t, { collapse: !0 });
|
|
277
|
+
}
|
|
278
|
+
handlePointerCancel(e) {
|
|
279
|
+
this._dragPointerId === e.pointerId && this._cancelDrag();
|
|
280
|
+
}
|
|
281
|
+
render() {
|
|
282
|
+
return n`
|
|
283
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
284
|
+
${this._enoughChildren ? n`
|
|
285
|
+
<div
|
|
286
|
+
class="separator ${this.splitterPos <= 0 ? "start-edge" : this._viewSize > 0 && this.splitterPos >= this._viewSize ? "end-edge" : ""}"
|
|
287
|
+
role="separator"
|
|
288
|
+
aria-label=${this.label}
|
|
289
|
+
aria-disabled=${this.resizable ? this.disabled ? "true" : "false" : r}
|
|
290
|
+
aria-orientation=${this.vertical ? "horizontal" : "vertical"}
|
|
291
|
+
aria-valuemin=${this.resizable ? this._positionAsPercentage(this.collapsible ? 0 : this._minPos) : r}
|
|
292
|
+
aria-valuemax=${this.resizable ? this._positionAsPercentage(this.collapsible ? this._viewSize : this._maxPos) : r}
|
|
293
|
+
aria-valuenow=${this.resizable ? this._positionAsPercentage(this.splitterPos) : r}
|
|
294
|
+
tabindex=${this.resizable ? this.disabled ? "-1" : "0" : r}
|
|
295
|
+
style=${`--splitter-position: ${this.splitterPos}`}
|
|
296
|
+
@keydown=${this.handleKeydown}
|
|
297
|
+
@pointerdown=${this.handlePointerDown}
|
|
298
|
+
@pointermove=${this.handlePointerMove}
|
|
299
|
+
@pointerup=${this.handlePointerUp}
|
|
300
|
+
@pointercancel=${this.handlePointerCancel}
|
|
301
|
+
@lostpointercapture=${this.handlePointerCancel}
|
|
302
|
+
>
|
|
303
|
+
<span class="divider" aria-hidden="true"></span>
|
|
304
|
+
<span class="handle" aria-hidden="true"></span>
|
|
305
|
+
</div>
|
|
306
|
+
` : r}
|
|
307
|
+
`;
|
|
308
|
+
}
|
|
309
|
+
_positionAsPercentage(e) {
|
|
310
|
+
return String(this._viewSize > 0 ? Math.round(e / this._viewSize * 100) : 0);
|
|
311
|
+
}
|
|
312
|
+
willUpdate(e) {
|
|
313
|
+
super.willUpdate(e), (e.has("vertical") || e.has("primaryMin") || e.has("primaryMax") || e.has("secondaryMin") || e.has("secondaryMax") || e.has("collapsible")) && this._recalculate(!1), e.has("primarySize") && this._recalculate(!0);
|
|
314
|
+
}
|
|
315
|
+
updated(e) {
|
|
316
|
+
super.updated(e), e.has("splitterPos") && this._applyPaneSizes(), this._syncAriaControls(), e.has("disabled") && this.disabled && this._cancelDrag();
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/components/split-view/index.ts
|
|
321
|
+
e([a({
|
|
322
|
+
type: Boolean,
|
|
323
|
+
reflect: !0
|
|
324
|
+
})], h.prototype, "vertical", void 0), e([a({
|
|
325
|
+
type: Boolean,
|
|
326
|
+
reflect: !0
|
|
327
|
+
})], h.prototype, "resizable", null), e([a({
|
|
328
|
+
type: Boolean,
|
|
329
|
+
reflect: !0
|
|
330
|
+
})], h.prototype, "collapsible", void 0), e([a({
|
|
331
|
+
type: String,
|
|
332
|
+
reflect: !0
|
|
333
|
+
})], h.prototype, "label", void 0), e([a({
|
|
334
|
+
type: Number,
|
|
335
|
+
reflect: !0,
|
|
336
|
+
attribute: "primary-min"
|
|
337
|
+
})], h.prototype, "primaryMin", null), e([a({
|
|
338
|
+
type: Number,
|
|
339
|
+
reflect: !0,
|
|
340
|
+
attribute: "primary-max"
|
|
341
|
+
})], h.prototype, "primaryMax", null), e([a({
|
|
342
|
+
type: Number,
|
|
343
|
+
reflect: !0,
|
|
344
|
+
attribute: "secondary-min"
|
|
345
|
+
})], h.prototype, "secondaryMin", null), e([a({
|
|
346
|
+
type: Number,
|
|
347
|
+
reflect: !0,
|
|
348
|
+
attribute: "secondary-max"
|
|
349
|
+
})], h.prototype, "secondaryMax", null), e([a({
|
|
350
|
+
type: String,
|
|
351
|
+
reflect: !0,
|
|
352
|
+
attribute: "primary-size"
|
|
353
|
+
})], h.prototype, "primarySize", void 0), e([a({
|
|
354
|
+
type: Number,
|
|
355
|
+
reflect: !0,
|
|
356
|
+
attribute: "splitter-pos"
|
|
357
|
+
})], h.prototype, "splitterPos", null), e([o("slot")], h.prototype, "_paneSlot", void 0), e([o("[role=\"separator\"]")], h.prototype, "_separator", void 0), typeof customElements < "u" && !customElements.get("luzmo-split-view") && customElements.define("luzmo-split-view", h);
|
|
358
|
+
//#endregion
|
|
359
|
+
export { h as t };
|