@rcarls/rc-splitter 0.6.0 → 0.7.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/CHANGELOG.md +116 -0
- package/README.md +22 -14
- package/dist/custom-elements.json +89 -8
- package/dist/rc-splitter-_P5HsZI9.js +437 -0
- package/dist/rc-splitter-_P5HsZI9.js.map +1 -0
- package/dist/rc-splitter-define.js +3 -1
- package/dist/rc-splitter-define.js.map +1 -1
- package/dist/rc-splitter.js +3 -2
- package/dist/types/packages/rc-splitter/src/rc-splitter.d.ts +45 -8
- package/package.json +2 -2
- package/dist/rc-splitter-CJTLxYi3.js +0 -608
- package/dist/rc-splitter-CJTLxYi3.js.map +0 -1
|
@@ -1,608 +0,0 @@
|
|
|
1
|
-
import { css as f, LitElement as m, html as p, nothing as g } from "lit";
|
|
2
|
-
import { property as l, state as c, query as _, queryAssignedElements as v } from "lit/decorators.js";
|
|
3
|
-
import { DragGestureController as y, findNextSnapIndex as b, findNearestSnapIndex as x, keyNavigation as V, keyInteraction as M } from "@rcarls/rc-common";
|
|
4
|
-
const z = f`
|
|
5
|
-
*,
|
|
6
|
-
*::before,
|
|
7
|
-
*::after {
|
|
8
|
-
box-sizing: border-box;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
:host {
|
|
12
|
-
--rc-splitter-separator-size: 6px;
|
|
13
|
-
|
|
14
|
-
position: relative;
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: row;
|
|
17
|
-
align-items: stretch;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
:host([orientation='vertical']) {
|
|
21
|
-
flex-direction: column;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
:host([hidden]) {
|
|
25
|
-
display: none;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* because :has(:focus-visible) doesn't work across slot boundary */
|
|
29
|
-
:host([data-interaction-mode='keyboard']):focus-within {
|
|
30
|
-
outline: auto;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
::slotted(*) {
|
|
34
|
-
width: 100%;
|
|
35
|
-
height: 100%;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
#separator {
|
|
39
|
-
grid-column: separator;
|
|
40
|
-
flex: 0 0 var(--rc-splitter-separator-size, 6px);
|
|
41
|
-
display: flex;
|
|
42
|
-
flex-direction: column;
|
|
43
|
-
justify-content: center;
|
|
44
|
-
background-color: var(
|
|
45
|
-
--rc-splitter-separator-color,
|
|
46
|
-
color-mix(in srgb, ButtonBorder 35%, Canvas 65%)
|
|
47
|
-
);
|
|
48
|
-
border-left: var(
|
|
49
|
-
--rc-splitter-separator-border-inline-start,
|
|
50
|
-
var(--rc-splitter-keyline, 1px solid ButtonBorder)
|
|
51
|
-
);
|
|
52
|
-
border-right: var(
|
|
53
|
-
--rc-splitter-separator-border-inline-end,
|
|
54
|
-
var(--rc-splitter-keyline, 1px solid ButtonBorder)
|
|
55
|
-
);
|
|
56
|
-
/* z-index: 1 as a flex item stacks separator above pane siblings so the
|
|
57
|
-
::after touch-target circle (which extends past the strip) is hittable */
|
|
58
|
-
z-index: 1;
|
|
59
|
-
/* Required for collapse-button absolute positioning */
|
|
60
|
-
position: relative;
|
|
61
|
-
|
|
62
|
-
:host([orientation='vertical']) & {
|
|
63
|
-
flex-direction: row;
|
|
64
|
-
border-left: unset;
|
|
65
|
-
border-right: unset;
|
|
66
|
-
border-top: var(
|
|
67
|
-
--rc-splitter-separator-border-block-start,
|
|
68
|
-
var(--rc-splitter-keyline, 1px solid ButtonBorder)
|
|
69
|
-
);
|
|
70
|
-
border-bottom: var(
|
|
71
|
-
--rc-splitter-separator-border-block-end,
|
|
72
|
-
var(--rc-splitter-keyline, 1px solid ButtonBorder)
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
#collapse-button {
|
|
78
|
-
/* Positioned at the start of the separator strip, centered on the cross
|
|
79
|
-
axis. The button intentionally protrudes into the primary pane so it
|
|
80
|
-
is visible and hittable at a reasonable size even on narrow strips. */
|
|
81
|
-
position: absolute;
|
|
82
|
-
top: var(--rc-splitter-collapse-button-offset, 8px);
|
|
83
|
-
left: 50%;
|
|
84
|
-
transform: translateX(-50%);
|
|
85
|
-
width: var(--rc-splitter-collapse-button-size, 20px);
|
|
86
|
-
height: var(--rc-splitter-collapse-button-size, 20px);
|
|
87
|
-
display: flex;
|
|
88
|
-
align-items: center;
|
|
89
|
-
justify-content: center;
|
|
90
|
-
padding: 0;
|
|
91
|
-
border: 1px solid var(--rc-splitter-collapse-button-border, ButtonBorder);
|
|
92
|
-
border-radius: 50%;
|
|
93
|
-
background: var(--rc-splitter-collapse-button-bg, Canvas);
|
|
94
|
-
color: var(--rc-splitter-collapse-button-color, ButtonText);
|
|
95
|
-
cursor: pointer;
|
|
96
|
-
line-height: 1;
|
|
97
|
-
|
|
98
|
-
&:hover {
|
|
99
|
-
background: var(--rc-splitter-collapse-button-hover-bg, ButtonFace);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
&:focus-visible {
|
|
103
|
-
outline: 2px solid Highlight;
|
|
104
|
-
outline-offset: 2px;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
:host([orientation='vertical']) & {
|
|
108
|
-
top: 50%;
|
|
109
|
-
left: var(--rc-splitter-collapse-button-offset, 8px);
|
|
110
|
-
transform: translateY(-50%);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
#separator-handle {
|
|
115
|
-
touch-action: none;
|
|
116
|
-
width: 100%;
|
|
117
|
-
height: var(--rc-splitter-separator-handle-size, 100%);
|
|
118
|
-
cursor: col-resize;
|
|
119
|
-
display: flex;
|
|
120
|
-
align-items: center;
|
|
121
|
-
justify-content: center;
|
|
122
|
-
/* Required so ::after is positioned relative to this element */
|
|
123
|
-
position: relative;
|
|
124
|
-
|
|
125
|
-
/* ── Visual drag indicator ─────────────────────────────────────────────
|
|
126
|
-
Default: 3-dot vertical grip (horizontal splitter / vertical bar).
|
|
127
|
-
Themes override via --rc-splitter-handle-pattern (background-image) and
|
|
128
|
-
--rc-splitter-handle-fill (background-color). */
|
|
129
|
-
&::before {
|
|
130
|
-
content: '';
|
|
131
|
-
display: block;
|
|
132
|
-
width: var(--rc-splitter-handle-thickness, 4px);
|
|
133
|
-
height: 100%;
|
|
134
|
-
background-color: var(--rc-splitter-handle-fill, transparent);
|
|
135
|
-
background-image: var(
|
|
136
|
-
--rc-splitter-handle-pattern,
|
|
137
|
-
radial-gradient(
|
|
138
|
-
circle 1px at 50% calc(50% - 5px),
|
|
139
|
-
var(--rc-splitter-handle-color, ButtonBorder) 100%,
|
|
140
|
-
transparent 100%
|
|
141
|
-
),
|
|
142
|
-
radial-gradient(
|
|
143
|
-
circle 1px at 50% 50%,
|
|
144
|
-
var(--rc-splitter-handle-color, ButtonBorder) 100%,
|
|
145
|
-
transparent 100%
|
|
146
|
-
),
|
|
147
|
-
radial-gradient(
|
|
148
|
-
circle 1px at 50% calc(50% + 5px),
|
|
149
|
-
var(--rc-splitter-handle-color, ButtonBorder) 100%,
|
|
150
|
-
transparent 100%
|
|
151
|
-
)
|
|
152
|
-
);
|
|
153
|
-
border-radius: var(--rc-splitter-handle-border-radius, 0);
|
|
154
|
-
pointer-events: none;
|
|
155
|
-
transition: background-color var(--rc-splitter-handle-transition, 0ms);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/* Hover highlight stays on the visual indicator only, never the full strip */
|
|
159
|
-
&:hover::before {
|
|
160
|
-
background-color: var(--rc-splitter-handle-hover-fill, transparent);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/* ── Touch target circle ───────────────────────────────────────────────
|
|
164
|
-
24 px diameter transparent circle, centered on the handle. Invisible
|
|
165
|
-
and non-interactive for mouse/keyboard. On coarse-pointer (touch)
|
|
166
|
-
devices the circle becomes hittable, giving a WCAG-compliant touch
|
|
167
|
-
target without widening the visual separator. */
|
|
168
|
-
&::after {
|
|
169
|
-
content: '';
|
|
170
|
-
position: absolute;
|
|
171
|
-
width: 24px;
|
|
172
|
-
height: 24px;
|
|
173
|
-
border-radius: 50%;
|
|
174
|
-
top: 50%;
|
|
175
|
-
left: 50%;
|
|
176
|
-
transform: translate(-50%, -50%);
|
|
177
|
-
pointer-events: none;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
:host([orientation='vertical']) & {
|
|
181
|
-
width: var(--rc-splitter-separator-handle-size, 100%);
|
|
182
|
-
height: 100%;
|
|
183
|
-
cursor: row-resize;
|
|
184
|
-
|
|
185
|
-
/* Horizontal 3-dot grip (vertical splitter / horizontal bar) */
|
|
186
|
-
&::before {
|
|
187
|
-
width: 100%;
|
|
188
|
-
height: var(--rc-splitter-handle-thickness, 4px);
|
|
189
|
-
background-image: var(
|
|
190
|
-
--rc-splitter-handle-pattern,
|
|
191
|
-
radial-gradient(
|
|
192
|
-
circle 1px at calc(50% - 5px) 50%,
|
|
193
|
-
var(--rc-splitter-handle-color, ButtonBorder) 100%,
|
|
194
|
-
transparent 100%
|
|
195
|
-
),
|
|
196
|
-
radial-gradient(
|
|
197
|
-
circle 1px at 50% 50%,
|
|
198
|
-
var(--rc-splitter-handle-color, ButtonBorder) 100%,
|
|
199
|
-
transparent 100%
|
|
200
|
-
),
|
|
201
|
-
radial-gradient(
|
|
202
|
-
circle 1px at calc(50% + 5px) 50%,
|
|
203
|
-
var(--rc-splitter-handle-color, ButtonBorder) 100%,
|
|
204
|
-
transparent 100%
|
|
205
|
-
)
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
:host([fixed]) & {
|
|
211
|
-
pointer-events: none;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/* Activate the touch target circle only on coarse-pointer (touch) devices */
|
|
216
|
-
@media (any-pointer: coarse) {
|
|
217
|
-
#separator-handle::after {
|
|
218
|
-
pointer-events: auto;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
#primary,
|
|
223
|
-
#secondary {
|
|
224
|
-
overflow: hidden;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
#primary {
|
|
228
|
-
grid-column: primary;
|
|
229
|
-
flex: 0 0 auto;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
#secondary {
|
|
233
|
-
grid-column: secondary;
|
|
234
|
-
flex: 1;
|
|
235
|
-
}
|
|
236
|
-
`;
|
|
237
|
-
var w = Object.defineProperty, S = Object.getOwnPropertyDescriptor, s = (d, t, e, i) => {
|
|
238
|
-
for (var r = i > 1 ? void 0 : i ? S(t, e) : t, o = d.length - 1, n; o >= 0; o--)
|
|
239
|
-
(n = d[o]) && (r = (i ? n(t, e, r) : n(r)) || r);
|
|
240
|
-
return i && r && w(t, e, r), r;
|
|
241
|
-
};
|
|
242
|
-
const $ = 24, k = 200, C = "cubic-bezier(0.4, 0, 0.2, 1)", u = class u extends m {
|
|
243
|
-
constructor() {
|
|
244
|
-
super(...arguments), this.label = "Splitter", this.orientation = "horizontal", this.mode = "length", this.step = 1, this.min = 0, this.max = void 0, this._valueInitialized = !1, this._value = 0, this.fixed = !1, this.collapsible = !1, this.snapPoints = "", this.swipeVelocity = 500, this._minValue = 0, this._maxValue = 0, this._lastValue = 0, this._initialMax = 0, this._gestureStartValue = 0, this._gestureRestoreValue = 0, this._activeSnapAnimation = null, this._reducedMotion = typeof window < "u" ? window.matchMedia("(prefers-reduced-motion: reduce)") : null, this._gesture = new y(this, {
|
|
245
|
-
target: () => this._$separatorHandle,
|
|
246
|
-
axis: this.orientation === "horizontal" ? "x" : "y",
|
|
247
|
-
focusOnStart: !0,
|
|
248
|
-
onStart: (t) => this._onGestureStart(t),
|
|
249
|
-
onMove: (t) => this._onGestureMove(t),
|
|
250
|
-
onEnd: (t) => this._onGestureEnd(t),
|
|
251
|
-
onCancel: () => this._onGestureCancel()
|
|
252
|
-
}), this._resizeObserver = new ResizeObserver(() => this._onResize());
|
|
253
|
-
}
|
|
254
|
-
set value(t) {
|
|
255
|
-
const e = this._hostValue;
|
|
256
|
-
this._hostValue = t, this._initialMax && this._setValue(t, !1), this.requestUpdate("value", e);
|
|
257
|
-
}
|
|
258
|
-
/** The current splitter value, corresponding to the separator position, in either pixels or percentage points depending on `mode`. */
|
|
259
|
-
get value() {
|
|
260
|
-
return this._value;
|
|
261
|
-
}
|
|
262
|
-
set defaultValue(t) {
|
|
263
|
-
const e = this._defaultValue;
|
|
264
|
-
this._defaultValue = t, !this._initialMax && this._hostValue === void 0 && t !== void 0 && this._setValue(t, !1), this.requestUpdate("defaultValue", e);
|
|
265
|
-
}
|
|
266
|
-
/** Initial uncontrolled splitter value. */
|
|
267
|
-
get defaultValue() {
|
|
268
|
-
return this._defaultValue;
|
|
269
|
-
}
|
|
270
|
-
get _effectiveMin() {
|
|
271
|
-
return Math.max(this._minValue, this.min);
|
|
272
|
-
}
|
|
273
|
-
get _effectiveMax() {
|
|
274
|
-
return Math.min(this._maxValue, this.max ?? this._maxValue);
|
|
275
|
-
}
|
|
276
|
-
/** True once initialized and the primary pane is at its effective minimum. */
|
|
277
|
-
get _isCollapsed() {
|
|
278
|
-
return this._initialMax > 0 && this.value <= this._effectiveMin;
|
|
279
|
-
}
|
|
280
|
-
_toggleCollapse() {
|
|
281
|
-
this._setUserValue(this._isCollapsed ? this._lastValue : this._effectiveMin);
|
|
282
|
-
}
|
|
283
|
-
_onCollapseButtonClick() {
|
|
284
|
-
this._toggleCollapse();
|
|
285
|
-
}
|
|
286
|
-
_onCollapseKeydown(t) {
|
|
287
|
-
if (!this.collapsible || this.fixed || !t.ctrlKey && !t.metaKey)
|
|
288
|
-
return;
|
|
289
|
-
(this.orientation === "horizontal" ? t.key === "ArrowLeft" || t.key === "ArrowRight" : t.key === "ArrowUp" || t.key === "ArrowDown") && (t.preventDefault(), t.stopImmediatePropagation(), this._toggleCollapse());
|
|
290
|
-
}
|
|
291
|
-
get _collapseButtonIcon() {
|
|
292
|
-
const e = this.orientation === "horizontal" ? this._isCollapsed ? "M 3 1 L 7 5 L 3 9" : "M 7 1 L 3 5 L 7 9" : this._isCollapsed ? "M 1 3 L 5 7 L 9 3" : "M 1 7 L 5 3 L 9 7";
|
|
293
|
-
return p`<svg
|
|
294
|
-
aria-hidden="true"
|
|
295
|
-
viewBox="0 0 10 10"
|
|
296
|
-
width="10"
|
|
297
|
-
height="10"
|
|
298
|
-
fill="none"
|
|
299
|
-
stroke="currentColor"
|
|
300
|
-
stroke-width="1.5"
|
|
301
|
-
stroke-linecap="round"
|
|
302
|
-
stroke-linejoin="round"
|
|
303
|
-
>
|
|
304
|
-
<path d=${e} />
|
|
305
|
-
</svg>`;
|
|
306
|
-
}
|
|
307
|
-
_setValue(t, e) {
|
|
308
|
-
const i = this._value;
|
|
309
|
-
this._value = Math.min(
|
|
310
|
-
Math.max(Math.round(t / this.step) * this.step, this._effectiveMin),
|
|
311
|
-
this._effectiveMax
|
|
312
|
-
), e && this._value !== i && this.dispatchEvent(
|
|
313
|
-
new CustomEvent("rc-splitter-change", {
|
|
314
|
-
bubbles: !0,
|
|
315
|
-
composed: !0,
|
|
316
|
-
detail: { value: this._value, valueText: this.valueText }
|
|
317
|
-
})
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
_setUserValue(t) {
|
|
321
|
-
this._valueInitialized = !0, this._hostValue = void 0, this._value > this._effectiveMin && (this._lastValue = this._value), this._setValue(t, !0);
|
|
322
|
-
}
|
|
323
|
-
/** A human-readable string representation of the value. */
|
|
324
|
-
get valueText() {
|
|
325
|
-
return `${this.value}${this.mode === "percent" ? "%" : "px"}`;
|
|
326
|
-
}
|
|
327
|
-
_onKeyboardResize(t) {
|
|
328
|
-
if (!this.fixed)
|
|
329
|
-
switch (t) {
|
|
330
|
-
case "next":
|
|
331
|
-
this._setUserValue(this.value + this.step);
|
|
332
|
-
break;
|
|
333
|
-
case "prev":
|
|
334
|
-
this._setUserValue(this.value - this.step);
|
|
335
|
-
break;
|
|
336
|
-
case "next-large":
|
|
337
|
-
this._setUserValue(this.value + this.step * 10);
|
|
338
|
-
break;
|
|
339
|
-
case "prev-large":
|
|
340
|
-
this._setUserValue(this.value - this.step * 10);
|
|
341
|
-
break;
|
|
342
|
-
case "start":
|
|
343
|
-
this._setUserValue(this._effectiveMin);
|
|
344
|
-
break;
|
|
345
|
-
case "end":
|
|
346
|
-
this._setUserValue(this._effectiveMax);
|
|
347
|
-
break;
|
|
348
|
-
case "toggle":
|
|
349
|
-
this._setUserValue(
|
|
350
|
-
this.value === this._effectiveMin ? this._lastValue : this._effectiveMin
|
|
351
|
-
);
|
|
352
|
-
break;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
_onPointerResize(t) {
|
|
356
|
-
if (this.fixed)
|
|
357
|
-
return;
|
|
358
|
-
const e = this.getBoundingClientRect();
|
|
359
|
-
this.orientation === "vertical" ? this._setUserValue((t.clientY - e.top) / e.height * this._maxValue) : this._setUserValue((t.clientX - e.left) / e.width * this._maxValue);
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Settles at a declared snap point by zero-based index.
|
|
363
|
-
*
|
|
364
|
-
* Finite fractional indices are truncated and clamped. Calls without valid
|
|
365
|
-
* snap points or with a non-finite index have no effect.
|
|
366
|
-
*
|
|
367
|
-
* @param index - zero-based index into `snapPoints`
|
|
368
|
-
* @param behavior - whether to animate the movement
|
|
369
|
-
*/
|
|
370
|
-
snapTo(t, e = "animated") {
|
|
371
|
-
const i = this._resolvedSnapPoints();
|
|
372
|
-
if (!Number.isFinite(t) || i.length === 0)
|
|
373
|
-
return;
|
|
374
|
-
const r = Math.max(0, Math.min(Math.trunc(t), i.length - 1));
|
|
375
|
-
this._settleToValue(i[r], e);
|
|
376
|
-
}
|
|
377
|
-
_onGestureStart(t) {
|
|
378
|
-
this._activeSnapAnimation?.cancel(), this._activeSnapAnimation = null, this._gestureStartValue = this.value, this._gestureRestoreValue = this._lastValue;
|
|
379
|
-
}
|
|
380
|
-
_onGestureMove(t) {
|
|
381
|
-
this._onPointerResize({ clientX: t.x, clientY: t.y });
|
|
382
|
-
}
|
|
383
|
-
_onGestureEnd(t) {
|
|
384
|
-
const e = this.orientation === "horizontal" ? t.deltaX : t.deltaY, i = this.orientation === "horizontal" ? t.velocityX : t.velocityY, r = Math.abs(e) >= $ && Math.abs(i) >= this.swipeVelocity;
|
|
385
|
-
if (r && this.collapsible) {
|
|
386
|
-
if (i < 0) {
|
|
387
|
-
const h = this._gestureRestoreValue > this._effectiveMin ? this._gestureRestoreValue : this._gestureStartValue;
|
|
388
|
-
this._settleToValue(this._effectiveMin, "animated"), this._lastValue = h;
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
if (this._gestureStartValue <= this._effectiveMin) {
|
|
392
|
-
this._settleToValue(
|
|
393
|
-
Math.max(this._gestureRestoreValue, this._effectiveMin),
|
|
394
|
-
"animated"
|
|
395
|
-
);
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
const o = this._resolvedSnapPoints();
|
|
400
|
-
if (o.length === 0)
|
|
401
|
-
return;
|
|
402
|
-
const n = r ? b(o, this._gestureStartValue, i > 0 ? 1 : -1) : x(o, this.value);
|
|
403
|
-
n >= 0 && this._settleToValue(o[n], "animated");
|
|
404
|
-
}
|
|
405
|
-
_onGestureCancel() {
|
|
406
|
-
this._activeSnapAnimation?.cancel(), this._activeSnapAnimation = null;
|
|
407
|
-
}
|
|
408
|
-
_resolvedSnapPoints() {
|
|
409
|
-
return this.snapPoints.trim() ? this.snapPoints.trim().split(/\s+/).map(Number).filter(Number.isFinite).map((t) => Math.min(Math.max(t, this._effectiveMin), this._effectiveMax)).filter((t, e, i) => e === 0 || t !== i[e - 1]) : [];
|
|
410
|
-
}
|
|
411
|
-
async _settleToValue(t, e) {
|
|
412
|
-
const i = this._$primary, r = this.orientation === "horizontal" ? i.getBoundingClientRect().width : i.getBoundingClientRect().height;
|
|
413
|
-
if (this._activeSnapAnimation?.cancel(), this._activeSnapAnimation = null, this._setUserValue(t), await this.updateComplete, e === "instant" || this._reducedMotion?.matches)
|
|
414
|
-
return;
|
|
415
|
-
const o = this.orientation === "horizontal" ? i.getBoundingClientRect().width : i.getBoundingClientRect().height;
|
|
416
|
-
if (r === o)
|
|
417
|
-
return;
|
|
418
|
-
const n = this.orientation === "horizontal" ? "width" : "height", h = i.animate(
|
|
419
|
-
[{ [n]: `${r}px` }, { [n]: `${o}px` }],
|
|
420
|
-
{
|
|
421
|
-
duration: this._snapDuration(),
|
|
422
|
-
easing: C
|
|
423
|
-
}
|
|
424
|
-
);
|
|
425
|
-
this._activeSnapAnimation = h;
|
|
426
|
-
try {
|
|
427
|
-
await h.finished;
|
|
428
|
-
} catch {
|
|
429
|
-
} finally {
|
|
430
|
-
this._activeSnapAnimation === h && (this._activeSnapAnimation = null);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
_snapDuration() {
|
|
434
|
-
const t = getComputedStyle(this).getPropertyValue("--rc-splitter-snap-duration").trim(), e = Number.parseFloat(t);
|
|
435
|
-
return Number.isFinite(e) ? e : k;
|
|
436
|
-
}
|
|
437
|
-
_onPrimaryChange(t) {
|
|
438
|
-
queueMicrotask(() => {
|
|
439
|
-
this._$primaryElements.length < 2 || this._$primaryElements.slice(1).forEach((e) => e.setAttribute("slot", "secondary"));
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
_onSecondaryChange(t) {
|
|
443
|
-
queueMicrotask(() => {
|
|
444
|
-
!this._$secondaryElements.length || this._$primaryElements.length || this._$secondaryElements.at(0)?.removeAttribute("slot");
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
_measureHostSize(t) {
|
|
448
|
-
const e = this.getBoundingClientRect(), i = t === "inline" ? e.width : e.height;
|
|
449
|
-
if (i > 0)
|
|
450
|
-
return Math.ceil(i);
|
|
451
|
-
const r = getComputedStyle(this), o = t === "inline" ? r.width : r.height, n = Number.parseFloat(o);
|
|
452
|
-
return Number.isFinite(n) ? Math.ceil(n) : 0;
|
|
453
|
-
}
|
|
454
|
-
_onResize() {
|
|
455
|
-
const t = this._$primaryElements.at(0), e = this._$primary.style.getPropertyValue("display");
|
|
456
|
-
globalThis.requestAnimationFrame(() => {
|
|
457
|
-
this._$primary.style.setProperty("display", "contents");
|
|
458
|
-
const i = t?.getBoundingClientRect() ?? this.getBoundingClientRect();
|
|
459
|
-
if (this.mode !== "percent") {
|
|
460
|
-
const r = this.orientation === "horizontal" ? (
|
|
461
|
-
// For horizontal splitters, just take the host width...
|
|
462
|
-
this._measureHostSize("inline")
|
|
463
|
-
) : (
|
|
464
|
-
// ...otherwise try to use the first lightDOM element's auto height, and cache it
|
|
465
|
-
this._initialMax || Math.ceil(i.height) || this._measureHostSize("block")
|
|
466
|
-
);
|
|
467
|
-
(r > 0 || !this._initialMax) && (this._maxValue = r);
|
|
468
|
-
} else
|
|
469
|
-
this._maxValue = 100;
|
|
470
|
-
this._initialMax ? this._hostValue !== void 0 ? this._setValue(this._hostValue, !1) : this._setValue(this.value, !1) : (this._initialMax = this._maxValue, this._setValue(
|
|
471
|
-
this._valueInitialized ? this._value : this._hostValue ?? this.defaultValue ?? this._maxValue / 2,
|
|
472
|
-
!1
|
|
473
|
-
)), e ? this._$primary.style.setProperty("display", e) : this._$primary.style.removeProperty("display");
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
connectedCallback() {
|
|
477
|
-
super.connectedCallback(), this._resizeObserver.observe(this);
|
|
478
|
-
}
|
|
479
|
-
disconnectedCallback() {
|
|
480
|
-
this._resizeObserver.disconnect(), this._activeSnapAnimation?.cancel(), this._activeSnapAnimation = null, super.disconnectedCallback();
|
|
481
|
-
}
|
|
482
|
-
firstUpdated() {
|
|
483
|
-
this._onResize();
|
|
484
|
-
}
|
|
485
|
-
updated() {
|
|
486
|
-
this._gesture.setOptions({
|
|
487
|
-
axis: this.orientation === "horizontal" ? "x" : "y",
|
|
488
|
-
target: () => this._$separatorHandle
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
render() {
|
|
492
|
-
return p`
|
|
493
|
-
<div
|
|
494
|
-
id="primary"
|
|
495
|
-
part="primary"
|
|
496
|
-
aria-label=${this.label}
|
|
497
|
-
style=${this.orientation === "horizontal" ? `width: ${this.valueText}` : `height: ${this.valueText}`}
|
|
498
|
-
?hidden=${this.value === this._minValue}
|
|
499
|
-
>
|
|
500
|
-
<slot @slotchange=${this._onPrimaryChange}></slot>
|
|
501
|
-
</div>
|
|
502
|
-
|
|
503
|
-
<div id="separator" part="separator">
|
|
504
|
-
${this.collapsible && this._$secondaryElements.length && !this.fixed ? p`<button
|
|
505
|
-
id="collapse-button"
|
|
506
|
-
part="collapse-button"
|
|
507
|
-
aria-label=${this._isCollapsed ? `Expand ${this.label}` : `Collapse ${this.label}`}
|
|
508
|
-
aria-expanded=${String(!this._isCollapsed)}
|
|
509
|
-
aria-controls="primary"
|
|
510
|
-
@click=${this._onCollapseButtonClick}
|
|
511
|
-
>
|
|
512
|
-
${this._collapseButtonIcon}
|
|
513
|
-
</button>` : g}
|
|
514
|
-
<div
|
|
515
|
-
id="separator-handle"
|
|
516
|
-
role="separator"
|
|
517
|
-
tabindex="0"
|
|
518
|
-
part="separator-handle"
|
|
519
|
-
aria-labelledby="primary"
|
|
520
|
-
aria-controls="primary"
|
|
521
|
-
aria-orientation=${this.orientation === "horizontal" ? "vertical" : "horizontal"}
|
|
522
|
-
aria-valuenow=${this.value}
|
|
523
|
-
aria-valuetext=${this.valueText}
|
|
524
|
-
aria-valuemin=${this._effectiveMin}
|
|
525
|
-
aria-valuemax=${this._effectiveMax}
|
|
526
|
-
@keydown=${this._onCollapseKeydown}
|
|
527
|
-
${V(this._onKeyboardResize)}
|
|
528
|
-
${M()}
|
|
529
|
-
?hidden=${!this._$secondaryElements.length}
|
|
530
|
-
></div>
|
|
531
|
-
</div>
|
|
532
|
-
|
|
533
|
-
<aside
|
|
534
|
-
id="secondary"
|
|
535
|
-
part="secondary"
|
|
536
|
-
?hidden=${!this._$secondaryElements.length || this.value === this._maxValue}
|
|
537
|
-
>
|
|
538
|
-
<slot name="secondary" @slotchange=${this._onSecondaryChange}></slot>
|
|
539
|
-
</aside>
|
|
540
|
-
`;
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
u.styles = [z];
|
|
544
|
-
let a = u;
|
|
545
|
-
s([
|
|
546
|
-
l({ type: String })
|
|
547
|
-
], a.prototype, "label", 2);
|
|
548
|
-
s([
|
|
549
|
-
l({ type: String, reflect: !0 })
|
|
550
|
-
], a.prototype, "orientation", 2);
|
|
551
|
-
s([
|
|
552
|
-
l({ type: String, reflect: !0 })
|
|
553
|
-
], a.prototype, "mode", 2);
|
|
554
|
-
s([
|
|
555
|
-
l({ type: Number })
|
|
556
|
-
], a.prototype, "step", 2);
|
|
557
|
-
s([
|
|
558
|
-
l({ type: Number })
|
|
559
|
-
], a.prototype, "min", 2);
|
|
560
|
-
s([
|
|
561
|
-
l({ type: Number })
|
|
562
|
-
], a.prototype, "max", 2);
|
|
563
|
-
s([
|
|
564
|
-
l({ type: Number })
|
|
565
|
-
], a.prototype, "value", 1);
|
|
566
|
-
s([
|
|
567
|
-
l({ type: Number, attribute: "default-value" })
|
|
568
|
-
], a.prototype, "defaultValue", 1);
|
|
569
|
-
s([
|
|
570
|
-
c()
|
|
571
|
-
], a.prototype, "_value", 2);
|
|
572
|
-
s([
|
|
573
|
-
l({ type: Boolean })
|
|
574
|
-
], a.prototype, "fixed", 2);
|
|
575
|
-
s([
|
|
576
|
-
l({ type: Boolean })
|
|
577
|
-
], a.prototype, "collapsible", 2);
|
|
578
|
-
s([
|
|
579
|
-
l({ type: String, attribute: "snap-points" })
|
|
580
|
-
], a.prototype, "snapPoints", 2);
|
|
581
|
-
s([
|
|
582
|
-
l({ type: Number, attribute: "swipe-velocity" })
|
|
583
|
-
], a.prototype, "swipeVelocity", 2);
|
|
584
|
-
s([
|
|
585
|
-
c()
|
|
586
|
-
], a.prototype, "_minValue", 2);
|
|
587
|
-
s([
|
|
588
|
-
c()
|
|
589
|
-
], a.prototype, "_maxValue", 2);
|
|
590
|
-
s([
|
|
591
|
-
c()
|
|
592
|
-
], a.prototype, "_lastValue", 2);
|
|
593
|
-
s([
|
|
594
|
-
_("#primary", !0)
|
|
595
|
-
], a.prototype, "_$primary", 2);
|
|
596
|
-
s([
|
|
597
|
-
_("#separator-handle")
|
|
598
|
-
], a.prototype, "_$separatorHandle", 2);
|
|
599
|
-
s([
|
|
600
|
-
v()
|
|
601
|
-
], a.prototype, "_$primaryElements", 2);
|
|
602
|
-
s([
|
|
603
|
-
v({ slot: "secondary" })
|
|
604
|
-
], a.prototype, "_$secondaryElements", 2);
|
|
605
|
-
export {
|
|
606
|
-
a as R
|
|
607
|
-
};
|
|
608
|
-
//# sourceMappingURL=rc-splitter-CJTLxYi3.js.map
|