@oscarpalmer/oui 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/badge.css +13 -13
- package/dist/css/button.css +9 -9
- package/dist/css/color.css +99 -99
- package/dist/css/content.css +10 -12
- package/dist/css/flex.css +39 -39
- package/dist/css/form.css +47 -60
- package/dist/css/message.css +10 -6
- package/dist/css/reset.css +178 -57
- package/dist/css/table.css +4 -4
- package/dist/css/tooltip.css +26 -1
- package/dist/js/attributable.full.js +36 -0
- package/dist/js/attributable.js +30 -45
- package/dist/js/floatable.full.js +398 -0
- package/dist/js/floatable.js +254 -169
- package/dist/js/focus-trap/embedded.full.js +408 -0
- package/dist/js/focus-trap/embedded.js +131 -131
- package/dist/js/focus-trap/standalone.full.js +447 -0
- package/dist/js/focus-trap/standalone.js +4 -4
- package/dist/js/index.js +3 -4
- package/dist/js/oui.full.js +1573 -0
- package/dist/js/popover.full.js +760 -0
- package/dist/js/popover.js +84 -163
- package/dist/js/splitter.full.js +769 -0
- package/dist/js/splitter.js +264 -246
- package/dist/js/tooltip.full.js +613 -0
- package/dist/js/tooltip.js +160 -151
- package/package.json +35 -63
- package/src/css/a11y.scss +1 -1
- package/src/css/badge.scss +23 -19
- package/src/css/button.scss +9 -9
- package/src/css/color.scss +99 -99
- package/src/css/content.scss +6 -9
- package/src/css/flex.scss +21 -20
- package/src/css/form.scss +47 -62
- package/src/css/message.scss +11 -12
- package/src/css/mixins.scss +16 -10
- package/src/css/popover.scss +2 -2
- package/src/css/reset.scss +181 -55
- package/src/css/splitter.scss +15 -13
- package/src/css/table.scss +11 -11
- package/src/css/tooltip.scss +31 -2
- package/src/js/attributable.ts +3 -10
- package/src/js/floatable.ts +370 -141
- package/src/js/focus-trap/embedded.ts +141 -74
- package/src/js/focus-trap/standalone.ts +4 -4
- package/src/js/index.ts +1 -0
- package/src/js/popover.ts +52 -122
- package/src/js/splitter.ts +248 -131
- package/src/js/tooltip.ts +143 -68
- package/types/floatable.d.ts +17 -10
- package/types/focus-trap/embedded.d.ts +18 -5
- package/types/index.d.ts +1 -0
- package/types/popover.d.ts +2 -0
- package/types/splitter.d.ts +13 -1
- package/types/tooltip.d.ts +2 -1
- package/dist/css/value.css +0 -1
- package/dist/js/attributable.cjs +0 -51
- package/dist/js/floatable.cjs +0 -176
- package/dist/js/focus-trap/embedded.cjs +0 -150
- package/dist/js/focus-trap/standalone.cjs +0 -8
- package/dist/js/index.cjs +0 -6
- package/dist/js/popover.cjs +0 -166
- package/dist/js/splitter.cjs +0 -272
- package/dist/js/tooltip.cjs +0 -166
- package/types/attributable.d.cts +0 -5
- package/types/floatable.d.cts +0 -20
- package/types/focus-trap/embedded.d.cts +0 -15
- package/types/focus-trap/standalone.d.cts +0 -3
- package/types/index.d.cts +0 -14
- package/types/popover.d.cts +0 -14
- package/types/splitter.d.cts +0 -10
- package/types/tooltip.d.cts +0 -3
package/dist/js/splitter.js
CHANGED
|
@@ -1,272 +1,290 @@
|
|
|
1
|
+
import { getPosition, on } from "@oscarpalmer/toretto/event";
|
|
2
|
+
import { findAncestor } from "@oscarpalmer/toretto/find";
|
|
3
|
+
import { clamp } from "@oscarpalmer/atoms/number";
|
|
1
4
|
import { isNullableOrWhitespace } from "@oscarpalmer/atoms/is";
|
|
2
5
|
import { round } from "@oscarpalmer/atoms/math";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
6
|
+
import { toggleStyles } from "@oscarpalmer/toretto/style";
|
|
7
|
+
import supportsTouch from "@oscarpalmer/toretto/touch";
|
|
8
|
+
var OuiSplitterElement = class extends HTMLElement {
|
|
9
|
+
static observedAttributes = [
|
|
10
|
+
"max",
|
|
11
|
+
"min",
|
|
12
|
+
"size",
|
|
13
|
+
"type"
|
|
14
|
+
];
|
|
15
|
+
#splitter;
|
|
16
|
+
get max() {
|
|
17
|
+
return this.#splitter.values.max;
|
|
18
|
+
}
|
|
19
|
+
set max(value) {
|
|
20
|
+
this.setAttribute("max", String(value));
|
|
21
|
+
}
|
|
22
|
+
get min() {
|
|
23
|
+
return this.#splitter.values.min;
|
|
24
|
+
}
|
|
25
|
+
set min(value) {
|
|
26
|
+
this.setAttribute("min", String(value));
|
|
27
|
+
}
|
|
28
|
+
get size() {
|
|
29
|
+
return this.#splitter.values.now.current;
|
|
30
|
+
}
|
|
31
|
+
set size(value) {
|
|
32
|
+
this.setAttribute("size", String(value));
|
|
33
|
+
}
|
|
34
|
+
get type() {
|
|
35
|
+
return this.getAttribute("type") ?? "vertical";
|
|
36
|
+
}
|
|
37
|
+
set type(value) {
|
|
38
|
+
this.setAttribute("type", value);
|
|
39
|
+
}
|
|
40
|
+
constructor() {
|
|
41
|
+
super();
|
|
42
|
+
const panels = [...this.children].filter((child) => child instanceof HTMLElement);
|
|
43
|
+
if (panels.length !== 2) throw new Error(`${SELECTOR} must have exactly two panels.`);
|
|
44
|
+
this.#splitter = new Splitter(this, panels);
|
|
45
|
+
}
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
this.#splitter.updateConnections(1);
|
|
48
|
+
}
|
|
49
|
+
disconnectedCallback() {
|
|
50
|
+
this.#splitter.updateConnections(0);
|
|
51
|
+
}
|
|
52
|
+
attributeChangedCallback(name) {
|
|
53
|
+
switch (name) {
|
|
54
|
+
case "max":
|
|
55
|
+
case "min":
|
|
56
|
+
case "size":
|
|
57
|
+
this.#splitter.updateValues();
|
|
58
|
+
break;
|
|
59
|
+
case "type":
|
|
60
|
+
this.#splitter.updateOrientation();
|
|
61
|
+
break;
|
|
62
|
+
default: break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var index = 0;
|
|
67
|
+
var Splitter = class {
|
|
68
|
+
element;
|
|
69
|
+
handle;
|
|
70
|
+
panels;
|
|
71
|
+
rectangle;
|
|
72
|
+
separator;
|
|
73
|
+
types;
|
|
74
|
+
values;
|
|
75
|
+
constructor(element, panels) {
|
|
76
|
+
this.element = element;
|
|
77
|
+
this.panels = panels;
|
|
78
|
+
if (isNullableOrWhitespace(element.id)) element.id = `oui_splitter_${++index}`;
|
|
79
|
+
this.values = getValues(element);
|
|
80
|
+
this.handle = createHandle();
|
|
81
|
+
this.rectangle = element.getBoundingClientRect();
|
|
82
|
+
this.separator = createSeparator(this);
|
|
83
|
+
this.separator.append(this.handle);
|
|
84
|
+
panels[0].insertAdjacentElement("afterend", this.separator);
|
|
85
|
+
this.updateOrientation();
|
|
86
|
+
this.updateValues();
|
|
87
|
+
}
|
|
88
|
+
updateConnections(add) {
|
|
89
|
+
const method = METHODS_CONNECT[add];
|
|
90
|
+
MAPPED_ELEMENTS[method](this.element, this);
|
|
91
|
+
MAPPED_ELEMENTS[method](this.handle, this);
|
|
92
|
+
MAPPED_ELEMENTS[method](this.separator, this);
|
|
93
|
+
if (this.types.auto) RESIZE_OBSERVER[METHODS_OBSERVE[add]](this.element);
|
|
94
|
+
}
|
|
95
|
+
updateOrientation() {
|
|
96
|
+
this.types = getTypes(this);
|
|
97
|
+
if (this.types.auto) RESIZE_OBSERVER.observe(this.element);
|
|
98
|
+
else RESIZE_OBSERVER.unobserve(this.element);
|
|
99
|
+
if (this.types.horizontal) this.element.setAttribute(ATTRIBUTE_HORIZONTAL, "");
|
|
100
|
+
else this.element.removeAttribute(ATTRIBUTE_HORIZONTAL);
|
|
101
|
+
setAriaOrientation(this);
|
|
102
|
+
}
|
|
103
|
+
updateValues() {
|
|
104
|
+
this.values = getValues(this.element);
|
|
105
|
+
requestAnimationFrame(() => {
|
|
106
|
+
setSize(this, this.values.now.current);
|
|
107
|
+
setAriaValue(this);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
59
111
|
function createHandle() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
112
|
+
const handle = document.createElement("span");
|
|
113
|
+
handle.setAttribute("aria-hidden", "true");
|
|
114
|
+
handle.setAttribute(ATTRIBUTE_HANDLE, "");
|
|
115
|
+
return handle;
|
|
64
116
|
}
|
|
65
|
-
function createSeparator(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
117
|
+
function createSeparator(splitter$1) {
|
|
118
|
+
const separator = document.createElement("div");
|
|
119
|
+
separator.role = "separator";
|
|
120
|
+
separator.tabIndex = 0;
|
|
121
|
+
separator.setAttribute("aria-controls", splitter$1.element.id);
|
|
122
|
+
separator.setAttribute("aria-label", "Resize panels");
|
|
123
|
+
separator.setAttribute(ATTRIBUTE_SEPARATOR, "");
|
|
124
|
+
return separator;
|
|
73
125
|
}
|
|
74
126
|
function getContained(min, value, max) {
|
|
75
|
-
|
|
127
|
+
return round(clamp(value, min, max), VALUE_DECIMALS);
|
|
76
128
|
}
|
|
77
|
-
function getSize(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return getContained(splitter2.values.min, fraction, splitter2.values.max);
|
|
129
|
+
function getSize(splitter$1, value) {
|
|
130
|
+
const { height, left, top, width } = splitter$1.rectangle;
|
|
131
|
+
const fraction = (value - (splitter$1.types.horizontal ? top : left)) / (splitter$1.types.horizontal ? height : width);
|
|
132
|
+
return getContained(splitter$1.values.min, fraction, splitter$1.values.max);
|
|
82
133
|
}
|
|
83
|
-
function getTypes(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
auto: false,
|
|
99
|
-
horizontal: false
|
|
100
|
-
};
|
|
134
|
+
function getTypes(splitter$1, width, height) {
|
|
135
|
+
const type = splitter$1.element.getAttribute("type")?.trim() ?? "";
|
|
136
|
+
if (type === "horizontal") return {
|
|
137
|
+
auto: false,
|
|
138
|
+
horizontal: true
|
|
139
|
+
};
|
|
140
|
+
if (type === "auto") return {
|
|
141
|
+
auto: true,
|
|
142
|
+
horizontal: (height ?? splitter$1.rectangle.height) > (width ?? splitter$1.rectangle.width)
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
auto: false,
|
|
146
|
+
horizontal: false
|
|
147
|
+
};
|
|
101
148
|
}
|
|
102
149
|
function getValue(element, name, defaultValue) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return defaultValue;
|
|
110
|
-
}
|
|
111
|
-
return parsed < 0 ? defaultValue : parsed > 1 ? parsed / 100 : parsed;
|
|
150
|
+
const value = element.getAttribute(name);
|
|
151
|
+
if (isNullableOrWhitespace(value)) return defaultValue;
|
|
152
|
+
const parsed = Number.parseFloat(value);
|
|
153
|
+
if (Number.isNaN(parsed)) return defaultValue;
|
|
154
|
+
if (parsed < 0) return defaultValue;
|
|
155
|
+
return parsed > 1 ? parsed / NAVIGATION_MAXIMUM_TOTAL : parsed;
|
|
112
156
|
}
|
|
113
157
|
function getValues(element) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
);
|
|
127
|
-
values.now.current = value;
|
|
128
|
-
values.now.previous = value;
|
|
129
|
-
return values;
|
|
158
|
+
const values = {
|
|
159
|
+
max: getValue(element, "max", NAVIGATION_MAXIMUM_PERCENTAGE),
|
|
160
|
+
min: getValue(element, "min", NAVIGATION_MINIMUM_PERCENTAGE),
|
|
161
|
+
now: {
|
|
162
|
+
current: .5,
|
|
163
|
+
previous: .5
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const value = getContained(values.min, getValue(element, "size", values.now.current), values.max);
|
|
167
|
+
values.now.current = value;
|
|
168
|
+
values.now.previous = value;
|
|
169
|
+
return values;
|
|
130
170
|
}
|
|
131
171
|
function onEnd(reset) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
splitter = void 0;
|
|
172
|
+
if (splitter == null) return;
|
|
173
|
+
splitter.handle.removeAttribute(ATTRIBUTE_ACTIVE);
|
|
174
|
+
splitter.separator.removeAttribute(ATTRIBUTE_ACTIVE);
|
|
175
|
+
if (reset) setSize(splitter, splitter.values.now.previous);
|
|
176
|
+
else splitter.values.now.previous = splitter.values.now.current;
|
|
177
|
+
splitter = void 0;
|
|
178
|
+
STYLING_TOGGLER.remove();
|
|
142
179
|
}
|
|
143
180
|
function onKeydown(event) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
181
|
+
switch (true) {
|
|
182
|
+
case KEYS_ALL.has(event.key):
|
|
183
|
+
onNavigate(event);
|
|
184
|
+
break;
|
|
185
|
+
case event.key === "Escape":
|
|
186
|
+
onEnd(true);
|
|
187
|
+
break;
|
|
188
|
+
default: break;
|
|
189
|
+
}
|
|
152
190
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
splitter.separator.setAttribute("oui-splitter-active", "");
|
|
165
|
-
splitter.rectangle = splitter.element.getBoundingClientRect();
|
|
191
|
+
function onNavigate(event) {
|
|
192
|
+
const splitter$1 = MAPPED_ELEMENTS.get(findAncestor(event.target, "[oui-splitter-separator]"));
|
|
193
|
+
if (splitter$1 == null) return;
|
|
194
|
+
const { types, values } = splitter$1;
|
|
195
|
+
if (KEYS_ABSOLUTE.has(event.key)) {
|
|
196
|
+
setSize(splitter$1, event.key === "End" ? values.max : values.min, true);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (types.horizontal && !KEYS_HORIZONTAL.has(event.key) || !(types.horizontal || KEYS_VERTICAL.has(event.key))) return;
|
|
200
|
+
const offset = KEYS_NEGATIVE.has(event.key) ? -1 : 1;
|
|
201
|
+
setSize(splitter$1, getContained(values.min, values.now.current + offset * NAVIGATION_MODIFIER, values.max), true);
|
|
166
202
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
203
|
+
function onObservation(entries) {
|
|
204
|
+
if (frame != null) cancelAnimationFrame(frame);
|
|
205
|
+
frame = requestAnimationFrame(() => {
|
|
206
|
+
for (const entry of entries) {
|
|
207
|
+
const splitter$1 = MAPPED_ELEMENTS.get(entry.target);
|
|
208
|
+
if (splitter$1 == null) return;
|
|
209
|
+
splitter$1.types = getTypes(splitter$1, entry.contentRect.width, entry.contentRect.height);
|
|
210
|
+
if (splitter$1.types.horizontal) splitter$1.element.setAttribute(ATTRIBUTE_HORIZONTAL, "");
|
|
211
|
+
else splitter$1.element.removeAttribute(ATTRIBUTE_HORIZONTAL);
|
|
212
|
+
setAriaOrientation(splitter$1);
|
|
213
|
+
}
|
|
214
|
+
frame = void 0;
|
|
215
|
+
});
|
|
179
216
|
}
|
|
180
|
-
function
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
217
|
+
function onPointerdown(event) {
|
|
218
|
+
if (event.type === "mousedown" && supportsTouch.value || event.type === "touchstart" && !supportsTouch.value) return;
|
|
219
|
+
splitter = MAPPED_ELEMENTS.get(findAncestor(event.target, SELECTOR_HANDLE));
|
|
220
|
+
if (splitter == null) return;
|
|
221
|
+
if (supportsTouch.value) event.preventDefault();
|
|
222
|
+
splitter.handle.setAttribute(ATTRIBUTE_ACTIVE, "");
|
|
223
|
+
splitter.separator.setAttribute(ATTRIBUTE_ACTIVE, "");
|
|
224
|
+
splitter.rectangle = splitter.element.getBoundingClientRect();
|
|
225
|
+
STYLING_TOGGLER.set();
|
|
184
226
|
}
|
|
185
|
-
function
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (splitter2 == null) {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
if (absoluteKeys.has(event.key)) {
|
|
196
|
-
setSize(
|
|
197
|
-
splitter2,
|
|
198
|
-
event.key === "End" ? splitter2.values.max : splitter2.values.min,
|
|
199
|
-
true
|
|
200
|
-
);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (splitter2.types.horizontal && !horizontalKeys.has(event.key) || !splitter2.types.horizontal && !verticalKeys.has(event.key)) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
const modifier = negativeKeys.has(event.key) ? -1 : 1;
|
|
207
|
-
setSize(splitter2, splitter2.values.now.current + modifier * 0.05, true);
|
|
227
|
+
function onPointermove(event) {
|
|
228
|
+
if (splitter == null) return;
|
|
229
|
+
const position = getPosition(event);
|
|
230
|
+
if (position != null) {
|
|
231
|
+
splitter.values.now.current = getSize(splitter, splitter.types.horizontal ? position.y : position.x);
|
|
232
|
+
setSize(splitter, splitter.values.now.current);
|
|
233
|
+
}
|
|
208
234
|
}
|
|
209
|
-
function
|
|
210
|
-
|
|
211
|
-
cancelAnimationFrame(frame);
|
|
212
|
-
}
|
|
213
|
-
frame = requestAnimationFrame(() => {
|
|
214
|
-
for (const entry of entries) {
|
|
215
|
-
const splitter2 = mapped.get(entry.target);
|
|
216
|
-
if (splitter2 == null) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
splitter2.types = getTypes(
|
|
220
|
-
splitter2,
|
|
221
|
-
entry.contentRect.width,
|
|
222
|
-
entry.contentRect.height
|
|
223
|
-
);
|
|
224
|
-
if (splitter2.types.horizontal) {
|
|
225
|
-
splitter2.element.setAttribute("oui-splitter-horizontal", "");
|
|
226
|
-
} else {
|
|
227
|
-
splitter2.element.removeAttribute("oui-splitter-horizontal");
|
|
228
|
-
}
|
|
229
|
-
setAriaOrientation(splitter2);
|
|
230
|
-
}
|
|
231
|
-
frame = void 0;
|
|
232
|
-
});
|
|
235
|
+
function onPointerup() {
|
|
236
|
+
if (splitter != null) onEnd(false);
|
|
233
237
|
}
|
|
234
|
-
function setAriaOrientation(
|
|
235
|
-
|
|
236
|
-
"aria-orientation",
|
|
237
|
-
splitter2.types.horizontal ? "horizontal" : "vertical"
|
|
238
|
-
);
|
|
238
|
+
function setAriaOrientation(splitter$1) {
|
|
239
|
+
splitter$1.separator.setAttribute("aria-orientation", splitter$1.types.horizontal ? "horizontal" : "vertical");
|
|
239
240
|
}
|
|
240
|
-
function setAriaValue(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
"aria-valuenow",
|
|
245
|
-
String(splitter2.values.now.current)
|
|
246
|
-
);
|
|
241
|
+
function setAriaValue(splitter$1) {
|
|
242
|
+
splitter$1.separator.setAttribute("aria-valuemax", String(splitter$1.values.max));
|
|
243
|
+
splitter$1.separator.setAttribute("aria-valuemin", String(splitter$1.values.min));
|
|
244
|
+
splitter$1.separator.setAttribute("aria-valuenow", String(splitter$1.values.now.current));
|
|
247
245
|
}
|
|
248
|
-
function setSize(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
splitter2.element.style.setProperty("--oui-splitter-size", `${size}`);
|
|
254
|
-
setAriaValue(splitter2);
|
|
246
|
+
function setSize(splitter$1, size, previous) {
|
|
247
|
+
splitter$1.values.now.current = size;
|
|
248
|
+
if (previous) splitter$1.values.now.previous = size;
|
|
249
|
+
splitter$1.element.style.setProperty("--oui-splitter-size", `${size}`);
|
|
250
|
+
setAriaValue(splitter$1);
|
|
255
251
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
252
|
+
var SELECTOR = "oui-splitter";
|
|
253
|
+
var ATTRIBUTE_ACTIVE = `${SELECTOR}-active`;
|
|
254
|
+
var ATTRIBUTE_HANDLE = `${SELECTOR}-handle`;
|
|
255
|
+
var ATTRIBUTE_HORIZONTAL = `${SELECTOR}-horizontal`;
|
|
256
|
+
var ATTRIBUTE_SEPARATOR = `${SELECTOR}-separator`;
|
|
257
|
+
var KEYS_ABSOLUTE = new Set(["End", "Home"]);
|
|
258
|
+
var KEYS_HORIZONTAL = new Set(["ArrowDown", "ArrowUp"]);
|
|
259
|
+
var KEYS_NEGATIVE = new Set(["ArrowLeft", "ArrowUp"]);
|
|
260
|
+
var KEYS_VERTICAL = new Set(["ArrowLeft", "ArrowRight"]);
|
|
261
|
+
var KEYS_ALL = new Set([
|
|
262
|
+
...KEYS_ABSOLUTE,
|
|
263
|
+
...KEYS_HORIZONTAL,
|
|
264
|
+
...KEYS_VERTICAL
|
|
265
|
+
]);
|
|
266
|
+
var MAPPED_ELEMENTS = /* @__PURE__ */ new WeakMap();
|
|
267
|
+
var METHODS_CONNECT = ["delete", "set"];
|
|
268
|
+
var METHODS_OBSERVE = ["unobserve", "observe"];
|
|
269
|
+
var NAVIGATION_MAXIMUM_PERCENTAGE = .9;
|
|
270
|
+
var NAVIGATION_MAXIMUM_TOTAL = 100;
|
|
271
|
+
var NAVIGATION_MINIMUM_PERCENTAGE = .1;
|
|
272
|
+
var NAVIGATION_MODIFIER = .05;
|
|
273
|
+
var RESIZE_OBSERVER = new ResizeObserver(onObservation);
|
|
274
|
+
var SELECTOR_HANDLE = `[${ATTRIBUTE_HANDLE}]`;
|
|
275
|
+
var STYLING_TOGGLER = toggleStyles(document.body, {
|
|
276
|
+
touchAction: "none",
|
|
277
|
+
userSelect: "none",
|
|
278
|
+
webkitUserSelect: "none"
|
|
279
|
+
});
|
|
280
|
+
var VALUE_DECIMALS = 6;
|
|
281
|
+
var frame;
|
|
282
|
+
var splitter;
|
|
283
|
+
customElements.define(SELECTOR, OuiSplitterElement);
|
|
266
284
|
on(document, "keydown", onKeydown);
|
|
267
|
-
on(document, "mousedown",
|
|
268
|
-
on(document, "
|
|
269
|
-
on(document, "
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
};
|
|
285
|
+
on(document, "mousedown", onPointerdown);
|
|
286
|
+
on(document, "pointermove", onPointermove);
|
|
287
|
+
on(document, "pointerup", onPointerup);
|
|
288
|
+
on(document, "touchcancel", onPointerup, { passive: false });
|
|
289
|
+
on(document, "touchstart", onPointerdown, { passive: false });
|
|
290
|
+
export { OuiSplitterElement };
|