@m3e/web 2.2.2 → 2.3.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 +2 -0
- package/dist/all.js +775 -2
- package/dist/all.js.map +1 -1
- package/dist/all.min.js +45 -45
- package/dist/all.min.js.map +1 -1
- package/dist/core.js +22 -1
- package/dist/core.js.map +1 -1
- package/dist/core.min.js +1 -1
- package/dist/core.min.js.map +1 -1
- package/dist/css-custom-data.json +410 -300
- package/dist/custom-elements.json +13138 -11756
- package/dist/html-custom-data.json +228 -140
- package/dist/skeleton.js +153 -0
- package/dist/skeleton.js.map +1 -0
- package/dist/skeleton.min.js +7 -0
- package/dist/skeleton.min.js.map +1 -0
- package/dist/split-pane.js +627 -0
- package/dist/split-pane.js.map +1 -0
- package/dist/split-pane.min.js +7 -0
- package/dist/split-pane.min.js.map +1 -0
- package/dist/src/all.d.ts +2 -0
- package/dist/src/all.d.ts.map +1 -1
- package/dist/src/core/shared/utils/index.d.ts +1 -0
- package/dist/src/core/shared/utils/index.d.ts.map +1 -1
- package/dist/src/core/shared/utils/waitForUpgrade.d.ts +6 -0
- package/dist/src/core/shared/utils/waitForUpgrade.d.ts.map +1 -0
- package/dist/src/skeleton/SkeletonAnimation.d.ts +3 -0
- package/dist/src/skeleton/SkeletonAnimation.d.ts.map +1 -0
- package/dist/src/skeleton/SkeletonElement.d.ts +73 -0
- package/dist/src/skeleton/SkeletonElement.d.ts.map +1 -0
- package/dist/src/skeleton/SkeletonShape.d.ts +3 -0
- package/dist/src/skeleton/SkeletonShape.d.ts.map +1 -0
- package/dist/src/skeleton/index.d.ts +4 -0
- package/dist/src/skeleton/index.d.ts.map +1 -0
- package/dist/src/split-pane/SplitPaneElement.d.ts +163 -0
- package/dist/src/split-pane/SplitPaneElement.d.ts.map +1 -0
- package/dist/src/split-pane/SplitPaneOrientation.d.ts +3 -0
- package/dist/src/split-pane/SplitPaneOrientation.d.ts.map +1 -0
- package/dist/src/split-pane/index.d.ts +3 -0
- package/dist/src/split-pane/index.d.ts.map +1 -0
- package/package.json +11 -1
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* Copyright (c) 2025 matraic
|
|
4
|
+
* See LICENSE file in the project root for full license text.
|
|
5
|
+
*/
|
|
6
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet, __decorate } from 'tslib';
|
|
7
|
+
import { LitElement, html, css, unsafeCSS } from 'lit';
|
|
8
|
+
import { state, query, property } from 'lit/decorators.js';
|
|
9
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
|
+
import { FormAssociated, Disabled, ReconnectedCallback, AttachInternals, PressedController, setCustomState, MutationController, formValue, deleteCustomState, prefersReducedMotion, addCustomState, registerStyleSheet, DesignToken, spaceSeparatedStringConverter, customElement } from '@m3e/web/core';
|
|
11
|
+
import { M3eBreakpointObserver, Breakpoint } from '@m3e/web/core/layout';
|
|
12
|
+
import { M3eDirectionality } from '@m3e/web/core/bidi';
|
|
13
|
+
|
|
14
|
+
var _M3eSplitPaneElement_instances, _M3eSplitPaneElement_breakpointUnobserve, _M3eSplitPaneElement_dragPos, _M3eSplitPaneElement_valueChanged, _M3eSplitPaneElement_cachedSize, _M3eSplitPaneElement_snapAnimation, _M3eSplitPaneElement_pressedController, _M3eSplitPaneElement_startMutationController, _M3eSplitPaneElement_endMutationController, _M3eSplitPaneElement_renderDragHandle, _M3eSplitPaneElement_handleStartSlotChange, _M3eSplitPaneElement_handleEndSlotChange, _M3eSplitPaneElement_handleSlotChange, _M3eSplitPaneElement_updatePaneVisibility, _M3eSplitPaneElement_hasVisibleElements, _M3eSplitPaneElement_initialize, _M3eSplitPaneElement_initBreakpointMonitoring, _M3eSplitPaneElement_updateOrientation, _M3eSplitPaneElement_clearOrientation, _M3eSplitPaneElement_handlePointerDown, _M3eSplitPaneElement_handlePointerMove, _M3eSplitPaneElement_handlePointerUp, _M3eSplitPaneElement_handleKeyDown, _M3eSplitPaneElement_changeValue, _M3eSplitPaneElement_getClosestDetent, _M3eSplitPaneElement_getNextHigherDetent, _M3eSplitPaneElement_getNextLowerDetent, _M3eSplitPaneElement_computeDetent, _M3eSplitPaneElement_clearSnapAnimation, _M3eSplitPaneElement_snapToValue, _M3eSplitPaneElement_cycleDetent;
|
|
15
|
+
/**
|
|
16
|
+
* A dual-view layout that separates content with a movable drag handle.
|
|
17
|
+
* @description
|
|
18
|
+
* The `m3e-split-pane` component delivers a Material 3-inspired split view with a
|
|
19
|
+
* movable drag handle, enabling responsive layout composition and pane resizing.
|
|
20
|
+
* It supports keyboard interaction, adaptive orientation, and optional detent snapping
|
|
21
|
+
* for consistent, accessible content distribution.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* The following example illustrates the basic use of the `m3e-split-pane` with start and end content.
|
|
25
|
+
* In this example, the start pane occupies 25% of the available width.
|
|
26
|
+
* ```html
|
|
27
|
+
* <m3e-split-pane value="25">
|
|
28
|
+
* <m3e-card slot="start"></m3e-card>
|
|
29
|
+
* <m3e-card slot="end"></m3e-card>
|
|
30
|
+
* </m3e-split-pane>
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* The next example demonstrates minimum and maximum constraints, where the start pane
|
|
35
|
+
* may shrink to 25% but cannot grow beyond 50% of the available space.
|
|
36
|
+
* ```html
|
|
37
|
+
* <m3e-split-pane value="25" min="25" max="50">
|
|
38
|
+
* <m3e-card slot="start"></m3e-card>
|
|
39
|
+
* <m3e-card slot="end"></m3e-card>
|
|
40
|
+
* </m3e-split-pane>
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* The next example demonstrates percentage‑based detents, allowing the drag handle to snap at
|
|
45
|
+
* 0%, 25%, 50%, 75%, and 100% of the available space.
|
|
46
|
+
* ```html
|
|
47
|
+
* <m3e-split-pane value="50" detents="0 25 50 75 100">
|
|
48
|
+
* <m3e-card slot="start"></m3e-card>
|
|
49
|
+
* <m3e-card slot="end"></m3e-card>
|
|
50
|
+
* </m3e-split-pane>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @tag m3e-split-pane
|
|
54
|
+
*
|
|
55
|
+
* @slot start - Renders content at the logical start side of the pane.
|
|
56
|
+
* @slot end - Renders content at the logical end side of the pane.
|
|
57
|
+
*
|
|
58
|
+
* @attr detents - Detents (discrete sizes) the start pane can snap to.
|
|
59
|
+
* @attr label - The accessible label given to the moveable drag handle.
|
|
60
|
+
* @attr max - A fractional value, between 0 and 100, indicating the maximum size of the start pane.
|
|
61
|
+
* @attr min - A fractional value, between 0 and 100, indicating the minimum size of the start pane.
|
|
62
|
+
* @attr orientation - The orientation of the split.
|
|
63
|
+
* @attr step - A fractional value, between 0 and 100, indicating the increment by which to adjust the value when resized via keyboard.
|
|
64
|
+
* @attr value - A fractional value, between 0 and 100, indicating the size of the start pane.
|
|
65
|
+
* @attr wrap-detents - Whether cycling through detents will wrap.
|
|
66
|
+
*
|
|
67
|
+
* @fires input - Fired continuously while the user adjusts the drag handle.
|
|
68
|
+
* @fires change - Fired when the user finishes adjusting the drag handle.
|
|
69
|
+
*
|
|
70
|
+
* @cssprop --m3e-split-pane-drag-handle-hover-color - Color used for the drag handle hover state.
|
|
71
|
+
* @cssprop --m3e-split-pane-drag-handle-hover-opacity - Opacity used for the drag handle hover state.
|
|
72
|
+
* @cssprop --m3e-split-pane-drag-handle-focus-color - Color used for the drag handle focus state.
|
|
73
|
+
* @cssprop --m3e-split-pane-drag-handle-focus-opacity - Opacity used for the drag handle focus state.
|
|
74
|
+
* @cssprop --m3e-split-pane-drag-handle-color - Background color of the drag handle when not pressed.
|
|
75
|
+
* @cssprop --m3e-split-pane-drag-handle-shape - Corner shape of the drag handle when not pressed.
|
|
76
|
+
* @cssprop --m3e-split-pane-drag-handle-pressed-color - Background color of the drag handle when pressed.
|
|
77
|
+
* @cssprop --m3e-split-pane-drag-handle-pressed-shape - Corner shape of the drag handle when pressed.
|
|
78
|
+
* @cssprop --m3e-split-pane-drag-handle-container-width - Width of the drag handle container.
|
|
79
|
+
* @cssprop --m3e-split-pane-drag-handle-width - Thickness of the drag handle when not pressed.
|
|
80
|
+
* @cssprop --m3e-split-pane-drag-handle-height - Length of the drag handle when not pressed.
|
|
81
|
+
* @cssprop --m3e-split-pane-drag-handle-pressed-width - Thickness of the drag handle when pressed.
|
|
82
|
+
* @cssprop --m3e-split-pane-drag-handle-pressed-height - Length of the drag handle when pressed.
|
|
83
|
+
*/
|
|
84
|
+
let M3eSplitPaneElement = class M3eSplitPaneElement extends FormAssociated(Disabled(ReconnectedCallback(AttachInternals(LitElement)))) {
|
|
85
|
+
constructor() {
|
|
86
|
+
super(...arguments);
|
|
87
|
+
_M3eSplitPaneElement_instances.add(this);
|
|
88
|
+
/** @private */
|
|
89
|
+
_M3eSplitPaneElement_breakpointUnobserve.set(this, void 0);
|
|
90
|
+
/** @private */
|
|
91
|
+
_M3eSplitPaneElement_dragPos.set(this, 0);
|
|
92
|
+
/** @private */
|
|
93
|
+
_M3eSplitPaneElement_valueChanged.set(this, false);
|
|
94
|
+
/** @private */
|
|
95
|
+
_M3eSplitPaneElement_cachedSize.set(this, 0);
|
|
96
|
+
/** @private */
|
|
97
|
+
_M3eSplitPaneElement_snapAnimation.set(this, void 0);
|
|
98
|
+
/** @private */
|
|
99
|
+
_M3eSplitPaneElement_pressedController.set(this, new PressedController(this, {
|
|
100
|
+
target: null,
|
|
101
|
+
isPressedKey: key => key === " ",
|
|
102
|
+
minPressedDuration: 150,
|
|
103
|
+
callback: pressed => setCustomState(this, "-pressed", pressed && !this.disabled)
|
|
104
|
+
}));
|
|
105
|
+
/** @private */
|
|
106
|
+
_M3eSplitPaneElement_startMutationController.set(this, new MutationController(this, {
|
|
107
|
+
target: null,
|
|
108
|
+
config: {
|
|
109
|
+
attributeFilter: ["hidden"]
|
|
110
|
+
},
|
|
111
|
+
callback: () => __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_updatePaneVisibility).call(this, "start")
|
|
112
|
+
}));
|
|
113
|
+
/** @private */
|
|
114
|
+
_M3eSplitPaneElement_endMutationController.set(this, new MutationController(this, {
|
|
115
|
+
target: null,
|
|
116
|
+
config: {
|
|
117
|
+
attributeFilter: ["hidden"]
|
|
118
|
+
},
|
|
119
|
+
callback: () => __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_updatePaneVisibility).call(this, "end")
|
|
120
|
+
}));
|
|
121
|
+
/**
|
|
122
|
+
* A fractional value, between 0 and 100, indicating the size of the start pane.
|
|
123
|
+
* @default 50
|
|
124
|
+
*/
|
|
125
|
+
this.value = 50;
|
|
126
|
+
/**
|
|
127
|
+
* A fractional value, between 0 and 100, indicating the minimum size of the start pane.
|
|
128
|
+
* @default 0
|
|
129
|
+
*/
|
|
130
|
+
this.min = 0;
|
|
131
|
+
/**
|
|
132
|
+
* A fractional value, between 0 and 100, indicating the maximum size of the start pane.
|
|
133
|
+
* @default 100
|
|
134
|
+
*/
|
|
135
|
+
this.max = 100;
|
|
136
|
+
/**
|
|
137
|
+
* A fractional value, between 0 and 100, indicating the increment by which to adjust the value when resized via keyboard.
|
|
138
|
+
* @default 1
|
|
139
|
+
*/
|
|
140
|
+
this.step = 1;
|
|
141
|
+
/**
|
|
142
|
+
* Detents (discrete sizes) the start pane can snap to.
|
|
143
|
+
* @default []
|
|
144
|
+
*/
|
|
145
|
+
this.detents = [];
|
|
146
|
+
/**
|
|
147
|
+
* Whether cycling through detents will wrap.
|
|
148
|
+
* @default false
|
|
149
|
+
*/
|
|
150
|
+
this.wrapDetents = false;
|
|
151
|
+
/**
|
|
152
|
+
* The orientation of the split.
|
|
153
|
+
* @default "horizontal"
|
|
154
|
+
*/
|
|
155
|
+
this.orientation = "horizontal";
|
|
156
|
+
/**
|
|
157
|
+
* The accessible label given to the movable drag handle.
|
|
158
|
+
* @default "Resize panes"
|
|
159
|
+
*/
|
|
160
|
+
this.label = "Resize panes";
|
|
161
|
+
/** A function used to generates human readable text for the accessible value (`aria-valuetext`) of the drag handle. */
|
|
162
|
+
this.valueFormatter = (value, orientation, dir) => {
|
|
163
|
+
value = Math.round(value);
|
|
164
|
+
if (value >= 48 && value <= 52) {
|
|
165
|
+
return "Panes equally sized";
|
|
166
|
+
}
|
|
167
|
+
switch (value) {
|
|
168
|
+
case 0:
|
|
169
|
+
return orientation === "horizontal" ? dir === "ltr" ? "Left pane collapsed" : "Right pane collapsed" : "Top pane collapsed";
|
|
170
|
+
case 100:
|
|
171
|
+
return orientation === "horizontal" ? dir === "ltr" ? "Right pane collapsed" : "Left pane collapsed" : "Bottom pane collapsed";
|
|
172
|
+
default:
|
|
173
|
+
return orientation === "horizontal" ? dir === "ltr" ? `Left pane ${value}%, right pane ${100 - value}%` : `Left pane ${100 - value}%, right pane ${value}%` : `Top pane ${value}%, bottom pane ${100 - value}%`;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/** The current orientation of the split. */
|
|
178
|
+
get currentOrientation() {
|
|
179
|
+
return this._orientation ?? (this.orientation !== "vertical" ? "horizontal" : "vertical");
|
|
180
|
+
}
|
|
181
|
+
/** @inheritdoc */
|
|
182
|
+
get [(_M3eSplitPaneElement_breakpointUnobserve = new WeakMap(), _M3eSplitPaneElement_dragPos = new WeakMap(), _M3eSplitPaneElement_valueChanged = new WeakMap(), _M3eSplitPaneElement_cachedSize = new WeakMap(), _M3eSplitPaneElement_snapAnimation = new WeakMap(), _M3eSplitPaneElement_pressedController = new WeakMap(), _M3eSplitPaneElement_startMutationController = new WeakMap(), _M3eSplitPaneElement_endMutationController = new WeakMap(), _M3eSplitPaneElement_instances = new WeakSet(), formValue)]() {
|
|
183
|
+
return this.value?.toString() ?? null;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Moves the drag handle to the collapsed position. If detents exist, snaps to the collapsed detent.
|
|
187
|
+
* If no detents exist, moves to the minimum allowed value.
|
|
188
|
+
*/
|
|
189
|
+
collapse() {
|
|
190
|
+
this.snapToValue(this.min);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Moves the drag handle to the expanded position. If detents exist, snaps to the expanded detent.
|
|
194
|
+
* If no detents exist, moves to the maximum allowed value.
|
|
195
|
+
*/
|
|
196
|
+
expand() {
|
|
197
|
+
this.snapToValue(this.max);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Moves the drag handle to the specified position. If detents exist, snaps to the closest detent.
|
|
201
|
+
* If no detents exist, moves to the specified value.
|
|
202
|
+
* @param {number} value A fractional value, between 0 and 100, indicating the size of the start pane.
|
|
203
|
+
*/
|
|
204
|
+
snapToValue(value) {
|
|
205
|
+
const detent = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getClosestDetent).call(this, value);
|
|
206
|
+
value = detent > -1 ? __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[detent]) : value;
|
|
207
|
+
if (!__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f")) {
|
|
208
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, value);
|
|
209
|
+
} else {
|
|
210
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_changeValue).call(this, value);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/** @inheritdoc */
|
|
214
|
+
disconnectedCallback() {
|
|
215
|
+
super.disconnectedCallback();
|
|
216
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_clearOrientation).call(this);
|
|
217
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_pressedController, "f").unobserve(this._dragHandle);
|
|
218
|
+
}
|
|
219
|
+
/** @inheritdoc */
|
|
220
|
+
reconnectedCallback() {
|
|
221
|
+
super.reconnectedCallback();
|
|
222
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_initialize).call(this);
|
|
223
|
+
if (this.orientation === "auto") {
|
|
224
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_initBreakpointMonitoring).call(this);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/** @inheritdoc */
|
|
228
|
+
willUpdate(changedProperties) {
|
|
229
|
+
super.willUpdate(changedProperties);
|
|
230
|
+
if (changedProperties.has("orientation")) {
|
|
231
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_breakpointUnobserve, "f")?.call(this);
|
|
232
|
+
if (this.orientation === "auto") {
|
|
233
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_initBreakpointMonitoring).call(this);
|
|
234
|
+
} else {
|
|
235
|
+
this._orientation = undefined;
|
|
236
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_updateOrientation).call(this);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/** @inheritdoc */
|
|
241
|
+
updated(_changedProperties) {
|
|
242
|
+
super.updated(_changedProperties);
|
|
243
|
+
if (_changedProperties.has("value")) {
|
|
244
|
+
this._base.style.setProperty("--_split-pane-value", `${this.value}%`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/** @inheritdoc */
|
|
248
|
+
firstUpdated(_changedProperties) {
|
|
249
|
+
super.firstUpdated(_changedProperties);
|
|
250
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_initialize).call(this);
|
|
251
|
+
}
|
|
252
|
+
/** @inheritdoc */
|
|
253
|
+
render() {
|
|
254
|
+
return html`<div class="base"><div class="start" id="start" ?inert="${this.value <= 0}"><slot name="start" @slotchange="${__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_handleStartSlotChange)}"></slot></div>${__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_renderDragHandle).call(this)}<div class="end" ?inert="${this.value >= 100}"><slot name="end" @slotchange="${__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_handleEndSlotChange)}"></slot></div></div>`;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
_M3eSplitPaneElement_renderDragHandle = function _M3eSplitPaneElement_renderDragHandle() {
|
|
258
|
+
return html`<div id="drag-handle" class="drag-handle" role="separator" ?hidden="${this.disabled}" tabindex="0" aria-label="${this.label}" aria-controls="start" aria-orientation="${this.currentOrientation === "horizontal" ? "vertical" : "horizontal"}" aria-valuemin="${this.min}" aria-valuemax="${this.max}" aria-valuenow="${this.value}" aria-valuetext="${ifDefined(this.valueFormatter?.(this.value, this.currentOrientation, M3eDirectionality.current))}" @pointerdown="${__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_handlePointerDown)}" @pointerup="${__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_handlePointerUp)}" @pointermove="${__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_handlePointerMove)}" @keydown="${__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_handleKeyDown)}" @dblclick="${__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_cycleDetent)}"><div class="handle"><m3e-focus-ring for="drag-handle"></m3e-focus-ring><m3e-state-layer for="drag-handle"></m3e-state-layer></div><div class="touch"></div></div>`;
|
|
259
|
+
};
|
|
260
|
+
_M3eSplitPaneElement_handleStartSlotChange = function _M3eSplitPaneElement_handleStartSlotChange(e) {
|
|
261
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_handleSlotChange).call(this, e.target, __classPrivateFieldGet(this, _M3eSplitPaneElement_startMutationController, "f"), "-with-start");
|
|
262
|
+
};
|
|
263
|
+
_M3eSplitPaneElement_handleEndSlotChange = function _M3eSplitPaneElement_handleEndSlotChange(e) {
|
|
264
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_handleSlotChange).call(this, e.target, __classPrivateFieldGet(this, _M3eSplitPaneElement_endMutationController, "f"), "-with-end");
|
|
265
|
+
};
|
|
266
|
+
_M3eSplitPaneElement_handleSlotChange = function _M3eSplitPaneElement_handleSlotChange(slot, mutationController, state) {
|
|
267
|
+
for (const target of mutationController.targets) {
|
|
268
|
+
mutationController.unobserve(target);
|
|
269
|
+
}
|
|
270
|
+
const assignedElements = new Array();
|
|
271
|
+
setCustomState(this, state, __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_hasVisibleElements).call(this, slot, assignedElements));
|
|
272
|
+
for (const element of assignedElements) {
|
|
273
|
+
if (element instanceof HTMLElement) {
|
|
274
|
+
mutationController.observe(element);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
_M3eSplitPaneElement_updatePaneVisibility = function _M3eSplitPaneElement_updatePaneVisibility(pane) {
|
|
279
|
+
setCustomState(this, `-with-${pane}`, __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_hasVisibleElements).call(this, this.shadowRoot?.querySelector(`slot[name='${pane}']`)));
|
|
280
|
+
};
|
|
281
|
+
_M3eSplitPaneElement_hasVisibleElements = function _M3eSplitPaneElement_hasVisibleElements(slot, assignedElements) {
|
|
282
|
+
assignedElements = assignedElements ?? [];
|
|
283
|
+
assignedElements.push(...(slot?.assignedElements({
|
|
284
|
+
flatten: true
|
|
285
|
+
}) ?? []));
|
|
286
|
+
return assignedElements.length > 0 && !assignedElements.every(x => x.hasAttribute("hidden"));
|
|
287
|
+
};
|
|
288
|
+
_M3eSplitPaneElement_initialize = function _M3eSplitPaneElement_initialize() {
|
|
289
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_pressedController, "f").observe(this._dragHandle);
|
|
290
|
+
};
|
|
291
|
+
_M3eSplitPaneElement_initBreakpointMonitoring = function _M3eSplitPaneElement_initBreakpointMonitoring() {
|
|
292
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_breakpointUnobserve, M3eBreakpointObserver.observe([Breakpoint.XSmall], matches => {
|
|
293
|
+
this._orientation = matches.get(Breakpoint.XSmall) ? "vertical" : "horizontal";
|
|
294
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_updateOrientation).call(this);
|
|
295
|
+
}), "f");
|
|
296
|
+
};
|
|
297
|
+
_M3eSplitPaneElement_updateOrientation = function _M3eSplitPaneElement_updateOrientation() {
|
|
298
|
+
setCustomState(this, "-vertical", this.currentOrientation === "vertical");
|
|
299
|
+
};
|
|
300
|
+
_M3eSplitPaneElement_clearOrientation = function _M3eSplitPaneElement_clearOrientation() {
|
|
301
|
+
deleteCustomState(this, "-vertical");
|
|
302
|
+
this._orientation = undefined;
|
|
303
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_breakpointUnobserve, "f")?.call(this);
|
|
304
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_breakpointUnobserve, undefined, "f");
|
|
305
|
+
};
|
|
306
|
+
_M3eSplitPaneElement_handlePointerDown = function _M3eSplitPaneElement_handlePointerDown(e) {
|
|
307
|
+
if (e.pointerType === "mouse" && e.button > 1) return;
|
|
308
|
+
if (this.disabled) return;
|
|
309
|
+
this._dragHandle.setPointerCapture(e.pointerId);
|
|
310
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_valueChanged, false, "f");
|
|
311
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_dragPos, this.currentOrientation === "vertical" ? e.clientY : e.clientX, "f");
|
|
312
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_cachedSize, this.currentOrientation === "vertical" ? this.clientHeight : this.clientWidth, "f");
|
|
313
|
+
};
|
|
314
|
+
_M3eSplitPaneElement_handlePointerMove = function _M3eSplitPaneElement_handlePointerMove(e) {
|
|
315
|
+
if (!this._dragHandle.hasPointerCapture(e.pointerId)) return;
|
|
316
|
+
const pos = this.currentOrientation === "vertical" ? e.clientY : e.clientX;
|
|
317
|
+
let delta = __classPrivateFieldGet(this, _M3eSplitPaneElement_cachedSize, "f") > 0 ? (pos - __classPrivateFieldGet(this, _M3eSplitPaneElement_dragPos, "f")) / __classPrivateFieldGet(this, _M3eSplitPaneElement_cachedSize, "f") * 100 : 0;
|
|
318
|
+
if (M3eDirectionality.current === "rtl" && this.currentOrientation !== "vertical") {
|
|
319
|
+
delta = -delta;
|
|
320
|
+
}
|
|
321
|
+
if (__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_changeValue).call(this, this.value + delta, false)) {
|
|
322
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_dragPos, pos, "f");
|
|
323
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_valueChanged, true, "f");
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
_M3eSplitPaneElement_handlePointerUp = function _M3eSplitPaneElement_handlePointerUp(e) {
|
|
327
|
+
if (e.pointerType === "mouse" && e.button > 1) return;
|
|
328
|
+
if (this._dragHandle.hasPointerCapture(e.pointerId)) {
|
|
329
|
+
this._dragHandle.releasePointerCapture(e.pointerId);
|
|
330
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_dragPos, 0, "f");
|
|
331
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_cachedSize, 0, "f");
|
|
332
|
+
const detent = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getClosestDetent).call(this, this.value);
|
|
333
|
+
if (detent >= 0) {
|
|
334
|
+
const value = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[detent]);
|
|
335
|
+
if (value !== undefined) {
|
|
336
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, value, false);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (__classPrivateFieldGet(this, _M3eSplitPaneElement_valueChanged, "f")) {
|
|
340
|
+
this.dispatchEvent(new Event("change", {
|
|
341
|
+
bubbles: true,
|
|
342
|
+
composed: true
|
|
343
|
+
}));
|
|
344
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_valueChanged, false, "f");
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
_M3eSplitPaneElement_handleKeyDown = function _M3eSplitPaneElement_handleKeyDown(e) {
|
|
349
|
+
const ltr = M3eDirectionality.current === "ltr" || this.currentOrientation === "vertical";
|
|
350
|
+
switch (e.key) {
|
|
351
|
+
case "Up":
|
|
352
|
+
case "ArrowUp":
|
|
353
|
+
case "Left":
|
|
354
|
+
case "ArrowLeft":
|
|
355
|
+
{
|
|
356
|
+
e.preventDefault();
|
|
357
|
+
const detent = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getClosestDetent).call(this, this.value);
|
|
358
|
+
if (detent >= 0) {
|
|
359
|
+
const nextDetent = ltr ? __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getNextLowerDetent).call(this, detent) : __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getNextHigherDetent).call(this, detent);
|
|
360
|
+
if (nextDetent !== detent && !__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f")) {
|
|
361
|
+
const value = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[nextDetent]);
|
|
362
|
+
if (value !== undefined) {
|
|
363
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, value);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
} else if (this.step > 1) {
|
|
367
|
+
if (!__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f")) {
|
|
368
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, this.value + (ltr ? -this.step : this.step));
|
|
369
|
+
}
|
|
370
|
+
} else {
|
|
371
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_changeValue).call(this, this.value + (ltr ? -this.step : this.step));
|
|
372
|
+
}
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
case "Down":
|
|
376
|
+
case "ArrowDown":
|
|
377
|
+
case "Right":
|
|
378
|
+
case "ArrowRight":
|
|
379
|
+
{
|
|
380
|
+
e.preventDefault();
|
|
381
|
+
const detent = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getClosestDetent).call(this, this.value);
|
|
382
|
+
if (detent >= 0) {
|
|
383
|
+
const nextDetent = ltr ? __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getNextHigherDetent).call(this, detent) : __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getNextLowerDetent).call(this, detent);
|
|
384
|
+
if (nextDetent !== detent && !__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f")) {
|
|
385
|
+
const value = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[nextDetent]);
|
|
386
|
+
if (value !== undefined) {
|
|
387
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, value);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
} else if (this.step > 1) {
|
|
391
|
+
if (!__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f")) {
|
|
392
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, this.value + (ltr ? this.step : -this.step));
|
|
393
|
+
}
|
|
394
|
+
} else {
|
|
395
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_changeValue).call(this, this.value + (ltr ? this.step : -this.step));
|
|
396
|
+
}
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
case "Home":
|
|
400
|
+
{
|
|
401
|
+
e.preventDefault();
|
|
402
|
+
if (!__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f")) {
|
|
403
|
+
const next = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getClosestDetent).call(this, this.min);
|
|
404
|
+
if (next > -1) {
|
|
405
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[next]));
|
|
406
|
+
} else {
|
|
407
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, this.min);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
case "End":
|
|
413
|
+
{
|
|
414
|
+
e.preventDefault();
|
|
415
|
+
if (!__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f")) {
|
|
416
|
+
const next = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getClosestDetent).call(this, this.max);
|
|
417
|
+
if (next > -1) {
|
|
418
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[next]));
|
|
419
|
+
} else {
|
|
420
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, this.max);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
case "PageUp":
|
|
426
|
+
{
|
|
427
|
+
e.preventDefault();
|
|
428
|
+
if (!__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f")) {
|
|
429
|
+
const detent = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getClosestDetent).call(this, this.value);
|
|
430
|
+
if (detent >= 0) {
|
|
431
|
+
const nextDetent = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getNextLowerDetent).call(this, detent);
|
|
432
|
+
if (nextDetent !== detent) {
|
|
433
|
+
const value = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[nextDetent]);
|
|
434
|
+
if (value !== undefined) {
|
|
435
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, value);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
} else {
|
|
439
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, this.value - Math.max(10, this.step));
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
case "PageDown":
|
|
445
|
+
{
|
|
446
|
+
e.preventDefault();
|
|
447
|
+
if (!__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f")) {
|
|
448
|
+
const detent = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getClosestDetent).call(this, this.value);
|
|
449
|
+
if (detent >= 0) {
|
|
450
|
+
const nextDetent = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getNextHigherDetent).call(this, detent);
|
|
451
|
+
if (nextDetent !== detent) {
|
|
452
|
+
const value = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[nextDetent]);
|
|
453
|
+
if (value !== undefined) {
|
|
454
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, value);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
} else {
|
|
458
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, this.value + Math.max(10, this.step));
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
case "Enter":
|
|
464
|
+
if (!__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f")) {
|
|
465
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_cycleDetent).call(this);
|
|
466
|
+
}
|
|
467
|
+
break;
|
|
468
|
+
case " ":
|
|
469
|
+
e.preventDefault();
|
|
470
|
+
if (!__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f")) {
|
|
471
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_cycleDetent).call(this);
|
|
472
|
+
}
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
_M3eSplitPaneElement_changeValue = function _M3eSplitPaneElement_changeValue(value, emitChange = true) {
|
|
477
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_clearSnapAnimation).call(this);
|
|
478
|
+
value = Math.max(this.min, Math.min(this.max, value));
|
|
479
|
+
if (value != this.value) {
|
|
480
|
+
const prev = this.value;
|
|
481
|
+
this.value = value;
|
|
482
|
+
if (this.dispatchEvent(new Event("input", {
|
|
483
|
+
bubbles: true,
|
|
484
|
+
composed: true,
|
|
485
|
+
cancelable: true
|
|
486
|
+
}))) {
|
|
487
|
+
this._base.style.setProperty("--_split-pane-value", `${this.value}%`);
|
|
488
|
+
if (emitChange) {
|
|
489
|
+
this.dispatchEvent(new Event("change", {
|
|
490
|
+
bubbles: true,
|
|
491
|
+
composed: true
|
|
492
|
+
}));
|
|
493
|
+
}
|
|
494
|
+
return true;
|
|
495
|
+
} else {
|
|
496
|
+
this.value = prev;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return false;
|
|
500
|
+
};
|
|
501
|
+
_M3eSplitPaneElement_getClosestDetent = function _M3eSplitPaneElement_getClosestDetent(value) {
|
|
502
|
+
let closestDetent = -1;
|
|
503
|
+
let closestDistance = Infinity;
|
|
504
|
+
for (let i = 0; i < this.detents.length; i++) {
|
|
505
|
+
const detent = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[i]);
|
|
506
|
+
if (detent === undefined) continue;
|
|
507
|
+
const distance = Math.abs(value - detent);
|
|
508
|
+
if (distance < closestDistance) {
|
|
509
|
+
closestDistance = distance;
|
|
510
|
+
closestDetent = i;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return closestDetent;
|
|
514
|
+
};
|
|
515
|
+
_M3eSplitPaneElement_getNextHigherDetent = function _M3eSplitPaneElement_getNextHigherDetent(detentIndex) {
|
|
516
|
+
const currentValue = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[detentIndex]);
|
|
517
|
+
if (currentValue === undefined) return detentIndex;
|
|
518
|
+
let value = Infinity;
|
|
519
|
+
let nextDetent = detentIndex;
|
|
520
|
+
for (let i = 0; i < this.detents.length; i++) {
|
|
521
|
+
if (i === detentIndex) continue;
|
|
522
|
+
const detent = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[i]);
|
|
523
|
+
if (detent === undefined) continue;
|
|
524
|
+
if (detent > currentValue && detent < value) {
|
|
525
|
+
value = detent;
|
|
526
|
+
nextDetent = i;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return nextDetent;
|
|
530
|
+
};
|
|
531
|
+
_M3eSplitPaneElement_getNextLowerDetent = function _M3eSplitPaneElement_getNextLowerDetent(detentIndex) {
|
|
532
|
+
const currentValue = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[detentIndex]);
|
|
533
|
+
if (currentValue === undefined) return detentIndex;
|
|
534
|
+
let value = -Infinity;
|
|
535
|
+
let nextDetent = detentIndex;
|
|
536
|
+
for (let i = 0; i < this.detents.length; i++) {
|
|
537
|
+
if (i === detentIndex) continue;
|
|
538
|
+
const detent = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[i]);
|
|
539
|
+
if (detent === undefined) continue;
|
|
540
|
+
if (detent < currentValue && detent > value) {
|
|
541
|
+
value = detent;
|
|
542
|
+
nextDetent = i;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return nextDetent;
|
|
546
|
+
};
|
|
547
|
+
_M3eSplitPaneElement_computeDetent = function _M3eSplitPaneElement_computeDetent(detent) {
|
|
548
|
+
const value = detent.endsWith("px") ? this.clientWidth / parseFloat(detent) : parseFloat(detent);
|
|
549
|
+
return !isNaN(value) ? value : undefined;
|
|
550
|
+
};
|
|
551
|
+
_M3eSplitPaneElement_clearSnapAnimation = function _M3eSplitPaneElement_clearSnapAnimation() {
|
|
552
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f")?.cancel();
|
|
553
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_snapAnimation, undefined, "f");
|
|
554
|
+
};
|
|
555
|
+
_M3eSplitPaneElement_snapToValue = function _M3eSplitPaneElement_snapToValue(value, emitChange = true) {
|
|
556
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_clearSnapAnimation).call(this);
|
|
557
|
+
value = Math.max(this.min, Math.min(this.max, value));
|
|
558
|
+
if (value === this.value) return;
|
|
559
|
+
if (!prefersReducedMotion()) {
|
|
560
|
+
addCustomState(this, "-animating");
|
|
561
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_snapAnimation, this._base.animate([{
|
|
562
|
+
"--_split-pane-value": `${this.value}%`
|
|
563
|
+
}, {
|
|
564
|
+
"--_split-pane-value": `${value}%`
|
|
565
|
+
}], {
|
|
566
|
+
duration: 250,
|
|
567
|
+
easing: "cubic-bezier(0.2, 0.0, 0, 1.0)"
|
|
568
|
+
}), "f");
|
|
569
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_snapAnimation, "f").onfinish = () => {
|
|
570
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_changeValue).call(this, value, emitChange);
|
|
571
|
+
__classPrivateFieldSet(this, _M3eSplitPaneElement_snapAnimation, undefined, "f");
|
|
572
|
+
deleteCustomState(this, "-animating");
|
|
573
|
+
};
|
|
574
|
+
} else {
|
|
575
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_changeValue).call(this, value, emitChange);
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
_M3eSplitPaneElement_cycleDetent = function _M3eSplitPaneElement_cycleDetent() {
|
|
579
|
+
if (this.detents.length === 0) return;
|
|
580
|
+
const detent = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getClosestDetent).call(this, this.value);
|
|
581
|
+
if (detent === -1) return;
|
|
582
|
+
let next = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getNextHigherDetent).call(this, detent);
|
|
583
|
+
if (next === detent && this.wrapDetents) {
|
|
584
|
+
next = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_getClosestDetent).call(this, 0);
|
|
585
|
+
if (next === -1) return;
|
|
586
|
+
}
|
|
587
|
+
const value = __classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_computeDetent).call(this, this.detents[next]);
|
|
588
|
+
if (value !== undefined) {
|
|
589
|
+
__classPrivateFieldGet(this, _M3eSplitPaneElement_instances, "m", _M3eSplitPaneElement_snapToValue).call(this, value);
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
(() => {
|
|
593
|
+
registerStyleSheet(css`@property --_split-pane-value { syntax: "<length-percentage>"; inherits: true; initial-value: 50%; }</length-percentage>`);
|
|
594
|
+
})();
|
|
595
|
+
/** The styles of the element. */
|
|
596
|
+
M3eSplitPaneElement.styles = css`:host { display: block; } .base { display: flex; width: 100%; height: 100%; overflow: hidden; } :host(:not(:state(-vertical))) .base { flex-direction: row; } :host(:state(-vertical)) .base { flex-direction: column; } :host(:state(-with-start):state(-with-end)) .base:not(:has(.drag-handle[hidden])) .start { flex: 0 1 calc(var(--_split-pane-value) - calc(var(--m3e-split-pane-drag-handle-container-width, 1.5rem) / 2)); } :host(:state(-with-start):state(-with-end)) .base:has(.drag-handle[hidden]) .start { flex: 0 1 var(--_split-pane-value); } :host(:not(:state(-with-end))) .start { flex: 1 1 auto; } :host(:state(-with-end)) .end { flex: 1 1 auto; } :host(:not(:state(-with-end))) .end { display: none; } :host(:not(:state(-animating))) .start[inert], :host(:not(:state(-animating))) .end[inert] { visibility: hidden; } .drag-handle { flex: none; display: flex; align-items: center; justify-content: center; outline: none; touch-action: none; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); --m3e-state-layer-hover-color: var(--m3e-split-pane-drag-handle-hover-color, ${DesignToken.color.onSurface}); --m3e-state-layer-hover-opacity: var(--m3e-split-pane-drag-handle-hover-opacity, 8%); --m3e-state-layer-focus-color: var(--m3e-split-pane-drag-handle-focus-color, ${DesignToken.color.onSurface}); --m3e-state-layer-focus-opacity: var(--m3e-split-pane-drag-handle-focus-opacity, 10%); } :host(:is(:not(:state(-with-start)), :not(:state(-with-end)))) .drag-handle, .drag-handle[hidden] { display: none; } :host(:not(:state(-pressed))) .drag-handle:not([aria-disabled]) { cursor: grab; } :host(:state(-pressed)) .drag-handle:not([aria-disabled]) { cursor: grabbing; } .handle { position: relative; transition: ${unsafeCSS(`background-color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard},
|
|
597
|
+
width ${DesignToken.motion.spring.fastEffects}, height ${DesignToken.motion.spring.fastEffects}`)}; } .touch { z-index: 1; position: absolute; height: 3rem; width: 3rem; margin: auto; touch-action: none; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } :host(:not(:state(-pressed))) .handle { background-color: var(--m3e-split-pane-drag-handle-color, ${DesignToken.color.outline}); border-radius: var(--m3e-split-pane-drag-handle-shape, ${DesignToken.shape.corner.full}); } :host(:state(-pressed)) .handle { background-color: var(--m3e-split-pane-drag-handle-pressed-color, ${DesignToken.color.onSurface}); border-radius: var(--m3e-split-pane-drag-handle-pressed-shape, ${DesignToken.shape.corner.medium}); } :host(:not(:state(-vertical))) .drag-handle { flex-direction: column; width: var(--m3e-split-pane-drag-handle-container-width, 1.5rem); } :host(:not(:state(-vertical)):not(:state(-pressed))) .handle { width: var(--m3e-split-pane-drag-handle-width, 0.25rem); height: var(--m3e-split-pane-drag-handle-height, 3rem); } :host(:not(:state(-vertical)):state(-pressed)) .handle { width: var(--m3e-split-pane-drag-handle-pressed-width, 0.75rem); height: var(--m3e-split-pane-drag-handle-pressed-height, 3.25rem); } :host(:state(-vertical)) .drag-handle { height: var(--m3e-split-pane-drag-handle-container-width, 1.5rem); } :host(:state(-vertical):not(:state(-pressed))) .handle { width: var(--m3e-split-pane-drag-handle-height, 3rem); height: var(--m3e-split-pane-drag-handle-width, 0.25rem); } :host(:state(-vertical):state(-pressed)) .handle { width: var(--m3e-split-pane-drag-handle-pressed-height, 3.25rem); height: var(--m3e-split-pane-drag-handle-pressed-width, 0.75rem); } @media (prefers-reduced-motion) { .handle { transition: none; } } @media (forced-colors: active) { :host(:state(-pressed)) .handle, :host(:not(:state(-pressed))) .handle { background-color: ButtonText; } }`;
|
|
598
|
+
__decorate([state()], M3eSplitPaneElement.prototype, "_orientation", void 0);
|
|
599
|
+
__decorate([query(".base")], M3eSplitPaneElement.prototype, "_base", void 0);
|
|
600
|
+
__decorate([query(".drag-handle")], M3eSplitPaneElement.prototype, "_dragHandle", void 0);
|
|
601
|
+
__decorate([property({
|
|
602
|
+
type: Number
|
|
603
|
+
})], M3eSplitPaneElement.prototype, "value", void 0);
|
|
604
|
+
__decorate([property({
|
|
605
|
+
type: Number
|
|
606
|
+
})], M3eSplitPaneElement.prototype, "min", void 0);
|
|
607
|
+
__decorate([property({
|
|
608
|
+
type: Number
|
|
609
|
+
})], M3eSplitPaneElement.prototype, "max", void 0);
|
|
610
|
+
__decorate([property({
|
|
611
|
+
type: Number
|
|
612
|
+
})], M3eSplitPaneElement.prototype, "step", void 0);
|
|
613
|
+
__decorate([property({
|
|
614
|
+
attribute: "detents",
|
|
615
|
+
converter: spaceSeparatedStringConverter
|
|
616
|
+
})], M3eSplitPaneElement.prototype, "detents", void 0);
|
|
617
|
+
__decorate([property({
|
|
618
|
+
attribute: "wrap-detents",
|
|
619
|
+
type: Boolean
|
|
620
|
+
})], M3eSplitPaneElement.prototype, "wrapDetents", void 0);
|
|
621
|
+
__decorate([property()], M3eSplitPaneElement.prototype, "orientation", void 0);
|
|
622
|
+
__decorate([property()], M3eSplitPaneElement.prototype, "label", void 0);
|
|
623
|
+
__decorate([property()], M3eSplitPaneElement.prototype, "valueFormatter", void 0);
|
|
624
|
+
M3eSplitPaneElement = __decorate([customElement("m3e-split-pane")], M3eSplitPaneElement);
|
|
625
|
+
|
|
626
|
+
export { M3eSplitPaneElement };
|
|
627
|
+
//# sourceMappingURL=split-pane.js.map
|