@oscarpalmer/oui 0.19.0 → 0.21.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/a11y.css +0 -1
- package/dist/css/form.css +0 -1
- package/dist/css/popover.css +22 -0
- package/dist/css/reset.css +8 -8
- package/dist/css/table.css +1 -1
- package/dist/css/tooltip.css +43 -0
- package/dist/js/focus-trap/embedded.d.mts +26 -0
- package/dist/js/focus-trap/{embedded.js → embedded.mjs} +11 -9
- package/dist/js/focus-trap/standalone.d.mts +1 -0
- package/dist/js/focus-trap/{standalone.js → standalone.mjs} +5 -2
- package/dist/js/index.d.mts +4 -0
- package/dist/js/index.mjs +7 -0
- package/dist/js/internal/attributable.d.mts +4 -0
- package/dist/js/{attributable.full.js → internal/attributable.mjs} +8 -1
- package/dist/js/internal/draggable.d.mts +2 -0
- package/dist/js/internal/draggable.mjs +212 -0
- package/dist/js/internal/floatable.d.mts +26 -0
- package/dist/js/{floatable.js → internal/floatable.mjs} +73 -50
- package/dist/js/movable-BEo2LbUI.d.mts +101 -0
- package/dist/js/movable.d.mts +2 -0
- package/dist/js/movable.mjs +152 -0
- package/dist/js/popover.d.mts +20 -0
- package/dist/js/{popover.js → popover.mjs} +10 -8
- package/dist/js/sortable.d.mts +2 -0
- package/dist/js/sortable.mjs +243 -0
- package/dist/js/splitter.d.mts +25 -0
- package/dist/js/{splitter.js → splitter.mjs} +62 -60
- package/dist/js/tooltip.d.mts +4 -0
- package/dist/js/{tooltip.js → tooltip.mjs} +22 -20
- package/package.json +66 -69
- package/src/css/mixins.scss +30 -1
- package/src/css/popover.scss +6 -1
- package/src/css/reset.scss +4 -4
- package/src/css/table.scss +1 -1
- package/src/css/tooltip.scss +55 -1
- package/src/js/focus-trap/embedded.ts +4 -10
- package/src/js/focus-trap/standalone.ts +1 -1
- package/src/js/index.ts +3 -1
- package/src/js/{attributable.ts → internal/attributable.ts} +11 -1
- package/src/js/internal/draggable.ts +515 -0
- package/src/js/{floatable.ts → internal/floatable.ts} +141 -63
- package/src/js/movable.ts +260 -0
- package/src/js/popover.ts +1 -1
- package/src/js/sortable.ts +467 -0
- package/src/js/splitter.ts +3 -9
- package/src/js/tooltip.ts +11 -9
- package/dist/js/attributable.js +0 -36
- package/dist/js/floatable.full.js +0 -398
- package/dist/js/focus-trap/embedded.full.js +0 -408
- package/dist/js/focus-trap/standalone.full.js +0 -447
- package/dist/js/index.js +0 -5
- package/dist/js/oui.full.js +0 -1573
- package/dist/js/popover.full.js +0 -760
- package/dist/js/splitter.full.js +0 -769
- package/dist/js/tooltip.full.js +0 -613
- package/types/attributable.d.ts +0 -1
- package/types/floatable.d.ts +0 -24
- package/types/focus-trap/embedded.d.ts +0 -24
- package/types/focus-trap/standalone.d.ts +0 -1
- package/types/index.d.ts +0 -4
- package/types/popover.d.ts +0 -17
- package/types/splitter.d.ts +0 -23
- package/types/tooltip.d.ts +0 -2
package/dist/js/splitter.full.js
DELETED
|
@@ -1,769 +0,0 @@
|
|
|
1
|
-
function isNumber(value) {
|
|
2
|
-
return typeof value === "number" && !Number.isNaN(value);
|
|
3
|
-
}
|
|
4
|
-
function isPlainObject(value) {
|
|
5
|
-
if (value === null || typeof value !== "object") return false;
|
|
6
|
-
if (Symbol.toStringTag in value || Symbol.iterator in value) return false;
|
|
7
|
-
const prototype = Object.getPrototypeOf(value);
|
|
8
|
-
return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
|
|
9
|
-
}
|
|
10
|
-
function compact(array, strict) {
|
|
11
|
-
if (!Array.isArray(array)) return [];
|
|
12
|
-
if (strict === true) return array.filter(Boolean);
|
|
13
|
-
const { length } = array;
|
|
14
|
-
const compacted = [];
|
|
15
|
-
for (let index$1 = 0; index$1 < length; index$1 += 1) {
|
|
16
|
-
const item = array[index$1];
|
|
17
|
-
if (item != null) compacted.push(item);
|
|
18
|
-
}
|
|
19
|
-
return compacted;
|
|
20
|
-
}
|
|
21
|
-
function getString(value) {
|
|
22
|
-
if (typeof value === "string") return value;
|
|
23
|
-
if (value == null) return "";
|
|
24
|
-
if (typeof value === "function") return getString(value());
|
|
25
|
-
if (typeof value !== "object") return String(value);
|
|
26
|
-
const asString = String(value.valueOf?.() ?? value);
|
|
27
|
-
return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
|
|
28
|
-
}
|
|
29
|
-
function join(value, delimiter) {
|
|
30
|
-
return compact(value).map(getString).join(typeof delimiter === "string" ? delimiter : "");
|
|
31
|
-
}
|
|
32
|
-
function words(value) {
|
|
33
|
-
return typeof value === "string" ? value.match(EXPRESSION_WORDS) ?? [] : [];
|
|
34
|
-
}
|
|
35
|
-
var EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
36
|
-
function isNullableOrWhitespace(value) {
|
|
37
|
-
return value == null || EXPRESSION_WHITESPACE.test(getString(value));
|
|
38
|
-
}
|
|
39
|
-
var EXPRESSION_WHITESPACE = /^\s*$/;
|
|
40
|
-
function round(value, decimals) {
|
|
41
|
-
if (typeof value !== "number") return NaN;
|
|
42
|
-
if (typeof decimals !== "number" || decimals < 1) return Math.round(value);
|
|
43
|
-
const mod = 10 ** decimals;
|
|
44
|
-
return Math.round((value + Number.EPSILON) * mod) / mod;
|
|
45
|
-
}
|
|
46
|
-
function clamp(value, minimum, maximum, loop) {
|
|
47
|
-
if (![
|
|
48
|
-
value,
|
|
49
|
-
minimum,
|
|
50
|
-
maximum
|
|
51
|
-
].every(isNumber)) return NaN;
|
|
52
|
-
if (value < minimum) return loop === true ? maximum : minimum;
|
|
53
|
-
return value > maximum ? loop === true ? minimum : maximum : value;
|
|
54
|
-
}
|
|
55
|
-
function noop() {}
|
|
56
|
-
function calculate() {
|
|
57
|
-
return new Promise((resolve) => {
|
|
58
|
-
const values = [];
|
|
59
|
-
let last;
|
|
60
|
-
function step(now) {
|
|
61
|
-
if (last != null) values.push(now - last);
|
|
62
|
-
last = now;
|
|
63
|
-
if (values.length >= TOTAL) resolve(values.sort().slice(TRIM_PART, -TRIM_PART).reduce((first, second) => first + second, 0) / (values.length - TRIM_TOTAL));
|
|
64
|
-
else requestAnimationFrame(step);
|
|
65
|
-
}
|
|
66
|
-
requestAnimationFrame(step);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
var TOTAL = 10;
|
|
70
|
-
var TRIM_PART = 2;
|
|
71
|
-
var TRIM_TOTAL = 4;
|
|
72
|
-
await calculate();
|
|
73
|
-
var SizedMap = class extends Map {
|
|
74
|
-
#maximumSize;
|
|
75
|
-
get full() {
|
|
76
|
-
return this.size >= this.#maximumSize;
|
|
77
|
-
}
|
|
78
|
-
get maximum() {
|
|
79
|
-
return this.#maximumSize;
|
|
80
|
-
}
|
|
81
|
-
constructor(first, second) {
|
|
82
|
-
const maximum = getMaximum(first, second);
|
|
83
|
-
super();
|
|
84
|
-
this.#maximumSize = maximum;
|
|
85
|
-
if (Array.isArray(first)) {
|
|
86
|
-
const { length } = first;
|
|
87
|
-
if (length <= maximum) for (let index$1 = 0; index$1 < length; index$1 += 1) this.set(...first[index$1]);
|
|
88
|
-
else for (let index$1 = 0; index$1 < maximum; index$1 += 1) this.set(...first[length - maximum + index$1]);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
get(key) {
|
|
92
|
-
const value = super.get(key);
|
|
93
|
-
if (value !== void 0 || this.has(key)) this.set(key, value);
|
|
94
|
-
return value;
|
|
95
|
-
}
|
|
96
|
-
set(key, value) {
|
|
97
|
-
if (this.has(key)) this.delete(key);
|
|
98
|
-
else if (this.size >= this.#maximumSize) this.delete(this.keys().next().value);
|
|
99
|
-
return super.set(key, value);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
function getMaximum(first, second) {
|
|
103
|
-
let actual;
|
|
104
|
-
if (typeof first === "number") actual = first;
|
|
105
|
-
else actual = typeof second === "number" ? second : MAXIMUM_DEFAULT;
|
|
106
|
-
return clamp(actual, 1, MAXIMUM_ABSOLUTE);
|
|
107
|
-
}
|
|
108
|
-
var MAXIMUM_ABSOLUTE = 16777216;
|
|
109
|
-
var MAXIMUM_DEFAULT = 1048576;
|
|
110
|
-
var Memoized = class {
|
|
111
|
-
#state;
|
|
112
|
-
get maximum() {
|
|
113
|
-
return this.#state.cache?.maximum ?? NaN;
|
|
114
|
-
}
|
|
115
|
-
get size() {
|
|
116
|
-
return this.#state.cache?.size ?? NaN;
|
|
117
|
-
}
|
|
118
|
-
constructor(callback, options) {
|
|
119
|
-
const cache = new SizedMap(options.cacheSize);
|
|
120
|
-
const getter = (...parameters) => {
|
|
121
|
-
const key = options.cacheKey?.(...parameters) ?? (parameters.length === 1 ? parameters[0] : join(parameters.map(getString), "_"));
|
|
122
|
-
if (cache.has(key)) return cache.get(key);
|
|
123
|
-
const value = callback(...parameters);
|
|
124
|
-
cache.set(key, value);
|
|
125
|
-
return value;
|
|
126
|
-
};
|
|
127
|
-
this.#state = {
|
|
128
|
-
cache,
|
|
129
|
-
getter
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
clear() {
|
|
133
|
-
this.#state.cache?.clear();
|
|
134
|
-
}
|
|
135
|
-
delete(key) {
|
|
136
|
-
return this.#state.cache?.delete(key) ?? false;
|
|
137
|
-
}
|
|
138
|
-
destroy() {
|
|
139
|
-
this.#state.cache?.clear();
|
|
140
|
-
this.#state.cache = void 0;
|
|
141
|
-
this.#state.getter = void 0;
|
|
142
|
-
}
|
|
143
|
-
get(key) {
|
|
144
|
-
return this.#state.cache?.get(key);
|
|
145
|
-
}
|
|
146
|
-
has(key) {
|
|
147
|
-
return this.#state.cache?.has(key) ?? false;
|
|
148
|
-
}
|
|
149
|
-
run(...parameters) {
|
|
150
|
-
if (this.#state.cache == null || this.#state.getter == null) throw new Error("The Memoized instance has been destroyed");
|
|
151
|
-
return this.#state.getter(...parameters);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
function getMemoizationOptions(input) {
|
|
155
|
-
const { cacheKey, cacheSize } = isPlainObject(input) ? input : {};
|
|
156
|
-
return {
|
|
157
|
-
cacheKey: typeof cacheKey === "function" ? cacheKey : void 0,
|
|
158
|
-
cacheSize: typeof cacheSize === "number" && cacheSize > 0 ? cacheSize : DEFAULT_CACHE_SIZE
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
function memoize(callback, options) {
|
|
162
|
-
return new Memoized(callback, getMemoizationOptions(options));
|
|
163
|
-
}
|
|
164
|
-
var DEFAULT_CACHE_SIZE = 1024;
|
|
165
|
-
function camelCase(value) {
|
|
166
|
-
return toCase("camel", value, true, false);
|
|
167
|
-
}
|
|
168
|
-
function capitalize(value) {
|
|
169
|
-
if (typeof value !== "string" || value.length === 0) return "";
|
|
170
|
-
memoizedCapitalize ??= memoize((v) => v.length === 1 ? v.toLocaleUpperCase() : `${v.charAt(0).toLocaleUpperCase()}${v.slice(1).toLocaleLowerCase()}`);
|
|
171
|
-
return memoizedCapitalize.run(value);
|
|
172
|
-
}
|
|
173
|
-
function toCase(type, value, capitalizeAny, capitalizeFirst) {
|
|
174
|
-
memoizers[type] ??= memoize(toCaseCallback.bind({
|
|
175
|
-
type,
|
|
176
|
-
capitalizeAny,
|
|
177
|
-
capitalizeFirst
|
|
178
|
-
}));
|
|
179
|
-
return memoizers[type].run(value);
|
|
180
|
-
}
|
|
181
|
-
function toCaseCallback(value) {
|
|
182
|
-
if (typeof value !== "string") return "";
|
|
183
|
-
if (value.length < 1) return value;
|
|
184
|
-
const { capitalizeAny, capitalizeFirst, type } = this;
|
|
185
|
-
const parts = words(value);
|
|
186
|
-
const partsLength = parts.length;
|
|
187
|
-
const result = [];
|
|
188
|
-
for (let partIndex = 0; partIndex < partsLength; partIndex += 1) {
|
|
189
|
-
const items = parts[partIndex].replace(EXPRESSION_ACRONYM, (full, one, two, three) => three === "s" ? full : `${one}-${two}${three}`).replace(EXPRESSION_CAMEL_CASE, REPLACEMENT_CAMEL_CASE).split("-");
|
|
190
|
-
const itemsLength = items.length;
|
|
191
|
-
const partResult = [];
|
|
192
|
-
let itemCount = 0;
|
|
193
|
-
for (let itemIndex = 0; itemIndex < itemsLength; itemIndex += 1) {
|
|
194
|
-
const item = items[itemIndex];
|
|
195
|
-
if (item.length === 0) continue;
|
|
196
|
-
if (!capitalizeAny || itemCount === 0 && partIndex === 0 && !capitalizeFirst) partResult.push(item.toLocaleLowerCase());
|
|
197
|
-
else partResult.push(capitalize(item));
|
|
198
|
-
itemCount += 1;
|
|
199
|
-
}
|
|
200
|
-
result.push(join(partResult, delimiters[type]));
|
|
201
|
-
}
|
|
202
|
-
return join(result, delimiters[type]);
|
|
203
|
-
}
|
|
204
|
-
var EXPRESSION_CAMEL_CASE = /(\p{Ll})(\p{Lu})/gu;
|
|
205
|
-
var EXPRESSION_ACRONYM = /(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu;
|
|
206
|
-
var REPLACEMENT_CAMEL_CASE = "$1-$2";
|
|
207
|
-
var delimiters = {
|
|
208
|
-
camel: "",
|
|
209
|
-
kebab: "-",
|
|
210
|
-
pascal: "",
|
|
211
|
-
snake: "_"
|
|
212
|
-
};
|
|
213
|
-
var memoizers = {};
|
|
214
|
-
var memoizedCapitalize;
|
|
215
|
-
function getBoolean(value, defaultValue) {
|
|
216
|
-
return typeof value === "boolean" ? value : defaultValue ?? false;
|
|
217
|
-
}
|
|
218
|
-
function getStyleValue(element, property, computed) {
|
|
219
|
-
const name = camelCase(property);
|
|
220
|
-
return computed ? getComputedStyle(element)[name] : element.style[name];
|
|
221
|
-
}
|
|
222
|
-
function isEventTarget(value) {
|
|
223
|
-
return typeof value === "object" && value != null && typeof value.addEventListener === "function" && typeof value.removeEventListener === "function" && typeof value.dispatchEvent === "function";
|
|
224
|
-
}
|
|
225
|
-
function isHTMLOrSVGElement(value) {
|
|
226
|
-
return value instanceof HTMLElement || value instanceof SVGElement;
|
|
227
|
-
}
|
|
228
|
-
function addDelegatedHandler(doc, type, name, passive) {
|
|
229
|
-
if (DELEGATED.has(name)) return;
|
|
230
|
-
DELEGATED.add(name);
|
|
231
|
-
doc.addEventListener(type, passive ? HANDLER_PASSIVE : HANDLER_ACTIVE, { passive });
|
|
232
|
-
}
|
|
233
|
-
function addDelegatedListener(target, type, name, listener, passive) {
|
|
234
|
-
target[name] ??= /* @__PURE__ */ new Set();
|
|
235
|
-
target[name].add(listener);
|
|
236
|
-
addDelegatedHandler(document, type, name, passive);
|
|
237
|
-
return () => {
|
|
238
|
-
removeDelegatedListener(target, name, listener);
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
function delegatedEventHandler(event) {
|
|
242
|
-
const key = `${EVENT_PREFIX}${event.type}${this ? EVENT_SUFFIX_PASSIVE : EVENT_SUFFIX_ACTIVE}`;
|
|
243
|
-
const items = event.composedPath();
|
|
244
|
-
const { length } = items;
|
|
245
|
-
let target = items[0];
|
|
246
|
-
Object.defineProperties(event, {
|
|
247
|
-
currentTarget: {
|
|
248
|
-
configurable: true,
|
|
249
|
-
get() {
|
|
250
|
-
return target;
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
target: {
|
|
254
|
-
configurable: true,
|
|
255
|
-
value: target
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
for (let index$1 = 0; index$1 < length; index$1 += 1) {
|
|
259
|
-
const item = items[index$1];
|
|
260
|
-
const listeners = item[key];
|
|
261
|
-
if (item.disabled || listeners == null) continue;
|
|
262
|
-
target = item;
|
|
263
|
-
for (const listener of listeners) {
|
|
264
|
-
listener.call(item, event);
|
|
265
|
-
if (event.cancelBubble) return;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
function getDelegatedName(target, type, options) {
|
|
270
|
-
if (isEventTarget(target) && EVENT_TYPES.has(type) && !options.capture && !options.once && options.signal == null) return `${EVENT_PREFIX}${type}${options.passive ? EVENT_SUFFIX_PASSIVE : EVENT_SUFFIX_ACTIVE}`;
|
|
271
|
-
}
|
|
272
|
-
function removeDelegatedListener(target, name, listener) {
|
|
273
|
-
const handlers = target[name];
|
|
274
|
-
if (handlers == null || !handlers.has(listener)) return false;
|
|
275
|
-
handlers.delete(listener);
|
|
276
|
-
if (handlers.size === 0) target[name] = void 0;
|
|
277
|
-
return true;
|
|
278
|
-
}
|
|
279
|
-
var DELEGATED = /* @__PURE__ */ new Set();
|
|
280
|
-
var EVENT_PREFIX = "@";
|
|
281
|
-
var EVENT_SUFFIX_ACTIVE = ":active";
|
|
282
|
-
var EVENT_SUFFIX_PASSIVE = ":passive";
|
|
283
|
-
var EVENT_TYPES = new Set([
|
|
284
|
-
"beforeinput",
|
|
285
|
-
"click",
|
|
286
|
-
"dblclick",
|
|
287
|
-
"contextmenu",
|
|
288
|
-
"focusin",
|
|
289
|
-
"focusout",
|
|
290
|
-
"input",
|
|
291
|
-
"keydown",
|
|
292
|
-
"keyup",
|
|
293
|
-
"mousedown",
|
|
294
|
-
"mousemove",
|
|
295
|
-
"mouseout",
|
|
296
|
-
"mouseover",
|
|
297
|
-
"mouseup",
|
|
298
|
-
"pointerdown",
|
|
299
|
-
"pointermove",
|
|
300
|
-
"pointerout",
|
|
301
|
-
"pointerover",
|
|
302
|
-
"pointerup",
|
|
303
|
-
"touchend",
|
|
304
|
-
"touchmove",
|
|
305
|
-
"touchstart"
|
|
306
|
-
]);
|
|
307
|
-
var HANDLER_ACTIVE = delegatedEventHandler.bind(false);
|
|
308
|
-
var HANDLER_PASSIVE = delegatedEventHandler.bind(true);
|
|
309
|
-
function createEventOptions(options) {
|
|
310
|
-
return {
|
|
311
|
-
capture: getBoolean(options?.capture),
|
|
312
|
-
once: getBoolean(options?.once),
|
|
313
|
-
passive: getBoolean(options?.passive, true),
|
|
314
|
-
signal: options?.signal instanceof AbortSignal ? options.signal : void 0
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
function getPosition(event) {
|
|
318
|
-
let x;
|
|
319
|
-
let y;
|
|
320
|
-
if (event instanceof MouseEvent) {
|
|
321
|
-
x = event.clientX;
|
|
322
|
-
y = event.clientY;
|
|
323
|
-
} else if (event instanceof TouchEvent) {
|
|
324
|
-
x = event.touches[0]?.clientX;
|
|
325
|
-
y = event.touches[0]?.clientY;
|
|
326
|
-
}
|
|
327
|
-
return typeof x === "number" && typeof y === "number" ? {
|
|
328
|
-
x,
|
|
329
|
-
y
|
|
330
|
-
} : void 0;
|
|
331
|
-
}
|
|
332
|
-
function on(target, type, listener, options) {
|
|
333
|
-
if (!isEventTarget(target) || typeof type !== "string" || typeof listener !== "function") return noop;
|
|
334
|
-
const extended = createEventOptions(options);
|
|
335
|
-
const delegated = getDelegatedName(target, type, extended);
|
|
336
|
-
if (delegated != null) return addDelegatedListener(target, type, delegated, listener, extended.passive);
|
|
337
|
-
target.addEventListener(type, listener, extended);
|
|
338
|
-
if (extended.once) return noop;
|
|
339
|
-
return () => {
|
|
340
|
-
target.removeEventListener(type, listener, extended);
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
function findAncestor(origin, selector) {
|
|
344
|
-
if (!(origin instanceof Element) || selector == null) return null;
|
|
345
|
-
if (typeof selector === "string") {
|
|
346
|
-
if (origin.matches?.(selector)) return origin;
|
|
347
|
-
return origin.closest(selector);
|
|
348
|
-
}
|
|
349
|
-
if (typeof selector !== "function") return null;
|
|
350
|
-
if (selector(origin)) return origin;
|
|
351
|
-
let parent = origin.parentElement;
|
|
352
|
-
while (parent != null && !selector(parent)) {
|
|
353
|
-
if (parent === document.body) return null;
|
|
354
|
-
parent = parent.parentElement;
|
|
355
|
-
}
|
|
356
|
-
return parent;
|
|
357
|
-
}
|
|
358
|
-
new Set([
|
|
359
|
-
Node.ELEMENT_NODE,
|
|
360
|
-
Node.TEXT_NODE,
|
|
361
|
-
Node.PROCESSING_INSTRUCTION_NODE,
|
|
362
|
-
Node.COMMENT_NODE,
|
|
363
|
-
Node.DOCUMENT_TYPE_NODE
|
|
364
|
-
]);
|
|
365
|
-
Object.freeze([
|
|
366
|
-
"async",
|
|
367
|
-
"autofocus",
|
|
368
|
-
"autoplay",
|
|
369
|
-
"checked",
|
|
370
|
-
"controls",
|
|
371
|
-
"default",
|
|
372
|
-
"defer",
|
|
373
|
-
"disabled",
|
|
374
|
-
"formnovalidate",
|
|
375
|
-
"hidden",
|
|
376
|
-
"inert",
|
|
377
|
-
"ismap",
|
|
378
|
-
"itemscope",
|
|
379
|
-
"loop",
|
|
380
|
-
"multiple",
|
|
381
|
-
"muted",
|
|
382
|
-
"nomodule",
|
|
383
|
-
"novalidate",
|
|
384
|
-
"open",
|
|
385
|
-
"playsinline",
|
|
386
|
-
"readonly",
|
|
387
|
-
"required",
|
|
388
|
-
"reversed",
|
|
389
|
-
"selected"
|
|
390
|
-
]);
|
|
391
|
-
document.createElement("form");
|
|
392
|
-
function setElementValues(element, first, second, third, callback) {
|
|
393
|
-
if (!isHTMLOrSVGElement(element)) return;
|
|
394
|
-
if (typeof first === "string") {
|
|
395
|
-
callback(element, first, second, third);
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
const isArray = Array.isArray(first);
|
|
399
|
-
if (!isArray && !(typeof first === "object" && first !== null)) return;
|
|
400
|
-
const entries = isArray ? first : Object.entries(first).map(([name, value]) => ({
|
|
401
|
-
name,
|
|
402
|
-
value
|
|
403
|
-
}));
|
|
404
|
-
const { length } = entries;
|
|
405
|
-
for (let index$1 = 0; index$1 < length; index$1 += 1) {
|
|
406
|
-
const entry = entries[index$1];
|
|
407
|
-
if (typeof entry === "object" && typeof entry?.name === "string") callback(element, entry.name, entry.value, third);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
function updateElementValue(element, key, value, set, remove, isBoolean, json) {
|
|
411
|
-
if (isBoolean ? value == null : isNullableOrWhitespace(value)) remove.call(element, key);
|
|
412
|
-
else set.call(element, key, json ? JSON.stringify(value) : String(value));
|
|
413
|
-
}
|
|
414
|
-
function getStyles(element, properties, computed) {
|
|
415
|
-
const styles = {};
|
|
416
|
-
if (!(isHTMLOrSVGElement(element) && Array.isArray(properties))) return styles;
|
|
417
|
-
const { length } = properties;
|
|
418
|
-
for (let index$1 = 0; index$1 < length; index$1 += 1) {
|
|
419
|
-
const property = properties[index$1];
|
|
420
|
-
if (typeof property === "string") styles[property] = getStyleValue(element, property, computed === true);
|
|
421
|
-
}
|
|
422
|
-
return styles;
|
|
423
|
-
}
|
|
424
|
-
function setStyles(element, styles) {
|
|
425
|
-
setElementValues(element, styles, null, null, updateStyleProperty);
|
|
426
|
-
}
|
|
427
|
-
function toggleStyles(element, styles) {
|
|
428
|
-
function toggle(set) {
|
|
429
|
-
hasSet = set;
|
|
430
|
-
let next;
|
|
431
|
-
if (set) {
|
|
432
|
-
values = getStyles(element, keys);
|
|
433
|
-
next = styles;
|
|
434
|
-
} else {
|
|
435
|
-
next = { ...values };
|
|
436
|
-
values = {};
|
|
437
|
-
for (const key of keys) values[key] = void 0;
|
|
438
|
-
}
|
|
439
|
-
setStyles(element, next);
|
|
440
|
-
}
|
|
441
|
-
const keys = Object.keys(styles);
|
|
442
|
-
let hasSet = false;
|
|
443
|
-
let values = {};
|
|
444
|
-
return {
|
|
445
|
-
set() {
|
|
446
|
-
if (!hasSet) toggle(true);
|
|
447
|
-
},
|
|
448
|
-
remove() {
|
|
449
|
-
if (hasSet) toggle(false);
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
function updateStyleProperty(element, key, value) {
|
|
454
|
-
updateElementValue(element, key, value, function(property, style) {
|
|
455
|
-
this.style[property] = style;
|
|
456
|
-
}, function(property) {
|
|
457
|
-
this.style[property] = "";
|
|
458
|
-
}, false, false);
|
|
459
|
-
}
|
|
460
|
-
function getSupport() {
|
|
461
|
-
if (window == null || navigator == null) return false;
|
|
462
|
-
if ("matchMedia" in window) {
|
|
463
|
-
const media = matchMedia?.("(pointer: coarse)");
|
|
464
|
-
if (typeof media?.matches === "boolean" && media.matches) return true;
|
|
465
|
-
}
|
|
466
|
-
if ("ontouchstart" in window) return true;
|
|
467
|
-
if (typeof navigator.maxTouchPoints === "number" && navigator.maxTouchPoints > 0) return true;
|
|
468
|
-
if (typeof navigator.msMaxTouchPoints === "number" && navigator.msMaxTouchPoints > 0) return true;
|
|
469
|
-
return false;
|
|
470
|
-
}
|
|
471
|
-
var touch_default = (() => {
|
|
472
|
-
let support = getSupport();
|
|
473
|
-
const instance = Object.create({
|
|
474
|
-
get() {
|
|
475
|
-
return support;
|
|
476
|
-
},
|
|
477
|
-
update() {
|
|
478
|
-
support = getSupport();
|
|
479
|
-
return support;
|
|
480
|
-
}
|
|
481
|
-
});
|
|
482
|
-
Object.defineProperty(instance, "value", { get() {
|
|
483
|
-
return support;
|
|
484
|
-
} });
|
|
485
|
-
return instance;
|
|
486
|
-
})();
|
|
487
|
-
var OuiSplitterElement = class extends HTMLElement {
|
|
488
|
-
static observedAttributes = [
|
|
489
|
-
"max",
|
|
490
|
-
"min",
|
|
491
|
-
"size",
|
|
492
|
-
"type"
|
|
493
|
-
];
|
|
494
|
-
#splitter;
|
|
495
|
-
get max() {
|
|
496
|
-
return this.#splitter.values.max;
|
|
497
|
-
}
|
|
498
|
-
set max(value) {
|
|
499
|
-
this.setAttribute("max", String(value));
|
|
500
|
-
}
|
|
501
|
-
get min() {
|
|
502
|
-
return this.#splitter.values.min;
|
|
503
|
-
}
|
|
504
|
-
set min(value) {
|
|
505
|
-
this.setAttribute("min", String(value));
|
|
506
|
-
}
|
|
507
|
-
get size() {
|
|
508
|
-
return this.#splitter.values.now.current;
|
|
509
|
-
}
|
|
510
|
-
set size(value) {
|
|
511
|
-
this.setAttribute("size", String(value));
|
|
512
|
-
}
|
|
513
|
-
get type() {
|
|
514
|
-
return this.getAttribute("type") ?? "vertical";
|
|
515
|
-
}
|
|
516
|
-
set type(value) {
|
|
517
|
-
this.setAttribute("type", value);
|
|
518
|
-
}
|
|
519
|
-
constructor() {
|
|
520
|
-
super();
|
|
521
|
-
const panels = [...this.children].filter((child) => child instanceof HTMLElement);
|
|
522
|
-
if (panels.length !== 2) throw new Error(`${SELECTOR} must have exactly two panels.`);
|
|
523
|
-
this.#splitter = new Splitter(this, panels);
|
|
524
|
-
}
|
|
525
|
-
connectedCallback() {
|
|
526
|
-
this.#splitter.updateConnections(1);
|
|
527
|
-
}
|
|
528
|
-
disconnectedCallback() {
|
|
529
|
-
this.#splitter.updateConnections(0);
|
|
530
|
-
}
|
|
531
|
-
attributeChangedCallback(name) {
|
|
532
|
-
switch (name) {
|
|
533
|
-
case "max":
|
|
534
|
-
case "min":
|
|
535
|
-
case "size":
|
|
536
|
-
this.#splitter.updateValues();
|
|
537
|
-
break;
|
|
538
|
-
case "type":
|
|
539
|
-
this.#splitter.updateOrientation();
|
|
540
|
-
break;
|
|
541
|
-
default: break;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
let index = 0;
|
|
546
|
-
var Splitter = class {
|
|
547
|
-
element;
|
|
548
|
-
handle;
|
|
549
|
-
panels;
|
|
550
|
-
rectangle;
|
|
551
|
-
separator;
|
|
552
|
-
types;
|
|
553
|
-
values;
|
|
554
|
-
constructor(element, panels) {
|
|
555
|
-
this.element = element;
|
|
556
|
-
this.panels = panels;
|
|
557
|
-
if (isNullableOrWhitespace(element.id)) element.id = `oui_splitter_${++index}`;
|
|
558
|
-
this.values = getValues(element);
|
|
559
|
-
this.handle = createHandle();
|
|
560
|
-
this.rectangle = element.getBoundingClientRect();
|
|
561
|
-
this.separator = createSeparator(this);
|
|
562
|
-
this.separator.append(this.handle);
|
|
563
|
-
panels[0].insertAdjacentElement("afterend", this.separator);
|
|
564
|
-
this.updateOrientation();
|
|
565
|
-
this.updateValues();
|
|
566
|
-
}
|
|
567
|
-
updateConnections(add) {
|
|
568
|
-
const method = METHODS_CONNECT[add];
|
|
569
|
-
MAPPED_ELEMENTS[method](this.element, this);
|
|
570
|
-
MAPPED_ELEMENTS[method](this.handle, this);
|
|
571
|
-
MAPPED_ELEMENTS[method](this.separator, this);
|
|
572
|
-
if (this.types.auto) RESIZE_OBSERVER[METHODS_OBSERVE[add]](this.element);
|
|
573
|
-
}
|
|
574
|
-
updateOrientation() {
|
|
575
|
-
this.types = getTypes(this);
|
|
576
|
-
if (this.types.auto) RESIZE_OBSERVER.observe(this.element);
|
|
577
|
-
else RESIZE_OBSERVER.unobserve(this.element);
|
|
578
|
-
if (this.types.horizontal) this.element.setAttribute(ATTRIBUTE_HORIZONTAL, "");
|
|
579
|
-
else this.element.removeAttribute(ATTRIBUTE_HORIZONTAL);
|
|
580
|
-
setAriaOrientation(this);
|
|
581
|
-
}
|
|
582
|
-
updateValues() {
|
|
583
|
-
this.values = getValues(this.element);
|
|
584
|
-
requestAnimationFrame(() => {
|
|
585
|
-
setSize(this, this.values.now.current);
|
|
586
|
-
setAriaValue(this);
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
};
|
|
590
|
-
function createHandle() {
|
|
591
|
-
const handle = document.createElement("span");
|
|
592
|
-
handle.setAttribute("aria-hidden", "true");
|
|
593
|
-
handle.setAttribute(ATTRIBUTE_HANDLE, "");
|
|
594
|
-
return handle;
|
|
595
|
-
}
|
|
596
|
-
function createSeparator(splitter$1) {
|
|
597
|
-
const separator = document.createElement("div");
|
|
598
|
-
separator.role = "separator";
|
|
599
|
-
separator.tabIndex = 0;
|
|
600
|
-
separator.setAttribute("aria-controls", splitter$1.element.id);
|
|
601
|
-
separator.setAttribute("aria-label", "Resize panels");
|
|
602
|
-
separator.setAttribute(ATTRIBUTE_SEPARATOR, "");
|
|
603
|
-
return separator;
|
|
604
|
-
}
|
|
605
|
-
function getContained(min, value, max) {
|
|
606
|
-
return round(clamp(value, min, max), VALUE_DECIMALS);
|
|
607
|
-
}
|
|
608
|
-
function getSize(splitter$1, value) {
|
|
609
|
-
const { height, left, top, width } = splitter$1.rectangle;
|
|
610
|
-
const fraction = (value - (splitter$1.types.horizontal ? top : left)) / (splitter$1.types.horizontal ? height : width);
|
|
611
|
-
return getContained(splitter$1.values.min, fraction, splitter$1.values.max);
|
|
612
|
-
}
|
|
613
|
-
function getTypes(splitter$1, width, height) {
|
|
614
|
-
const type = splitter$1.element.getAttribute("type")?.trim() ?? "";
|
|
615
|
-
if (type === "horizontal") return {
|
|
616
|
-
auto: false,
|
|
617
|
-
horizontal: true
|
|
618
|
-
};
|
|
619
|
-
if (type === "auto") return {
|
|
620
|
-
auto: true,
|
|
621
|
-
horizontal: (height ?? splitter$1.rectangle.height) > (width ?? splitter$1.rectangle.width)
|
|
622
|
-
};
|
|
623
|
-
return {
|
|
624
|
-
auto: false,
|
|
625
|
-
horizontal: false
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
function getValue(element, name, defaultValue) {
|
|
629
|
-
const value = element.getAttribute(name);
|
|
630
|
-
if (isNullableOrWhitespace(value)) return defaultValue;
|
|
631
|
-
const parsed = Number.parseFloat(value);
|
|
632
|
-
if (Number.isNaN(parsed)) return defaultValue;
|
|
633
|
-
if (parsed < 0) return defaultValue;
|
|
634
|
-
return parsed > 1 ? parsed / NAVIGATION_MAXIMUM_TOTAL : parsed;
|
|
635
|
-
}
|
|
636
|
-
function getValues(element) {
|
|
637
|
-
const values = {
|
|
638
|
-
max: getValue(element, "max", NAVIGATION_MAXIMUM_PERCENTAGE),
|
|
639
|
-
min: getValue(element, "min", NAVIGATION_MINIMUM_PERCENTAGE),
|
|
640
|
-
now: {
|
|
641
|
-
current: .5,
|
|
642
|
-
previous: .5
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
const value = getContained(values.min, getValue(element, "size", values.now.current), values.max);
|
|
646
|
-
values.now.current = value;
|
|
647
|
-
values.now.previous = value;
|
|
648
|
-
return values;
|
|
649
|
-
}
|
|
650
|
-
function onEnd(reset) {
|
|
651
|
-
if (splitter == null) return;
|
|
652
|
-
splitter.handle.removeAttribute(ATTRIBUTE_ACTIVE);
|
|
653
|
-
splitter.separator.removeAttribute(ATTRIBUTE_ACTIVE);
|
|
654
|
-
if (reset) setSize(splitter, splitter.values.now.previous);
|
|
655
|
-
else splitter.values.now.previous = splitter.values.now.current;
|
|
656
|
-
splitter = void 0;
|
|
657
|
-
STYLING_TOGGLER.remove();
|
|
658
|
-
}
|
|
659
|
-
function onKeydown(event) {
|
|
660
|
-
switch (true) {
|
|
661
|
-
case KEYS_ALL.has(event.key):
|
|
662
|
-
onNavigate(event);
|
|
663
|
-
break;
|
|
664
|
-
case event.key === "Escape":
|
|
665
|
-
onEnd(true);
|
|
666
|
-
break;
|
|
667
|
-
default: break;
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
function onNavigate(event) {
|
|
671
|
-
const splitter$1 = MAPPED_ELEMENTS.get(findAncestor(event.target, "[oui-splitter-separator]"));
|
|
672
|
-
if (splitter$1 == null) return;
|
|
673
|
-
const { types, values } = splitter$1;
|
|
674
|
-
if (KEYS_ABSOLUTE.has(event.key)) {
|
|
675
|
-
setSize(splitter$1, event.key === "End" ? values.max : values.min, true);
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
if (types.horizontal && !KEYS_HORIZONTAL.has(event.key) || !(types.horizontal || KEYS_VERTICAL.has(event.key))) return;
|
|
679
|
-
const offset = KEYS_NEGATIVE.has(event.key) ? -1 : 1;
|
|
680
|
-
setSize(splitter$1, getContained(values.min, values.now.current + offset * NAVIGATION_MODIFIER, values.max), true);
|
|
681
|
-
}
|
|
682
|
-
function onObservation(entries) {
|
|
683
|
-
if (frame != null) cancelAnimationFrame(frame);
|
|
684
|
-
frame = requestAnimationFrame(() => {
|
|
685
|
-
for (const entry of entries) {
|
|
686
|
-
const splitter$1 = MAPPED_ELEMENTS.get(entry.target);
|
|
687
|
-
if (splitter$1 == null) return;
|
|
688
|
-
splitter$1.types = getTypes(splitter$1, entry.contentRect.width, entry.contentRect.height);
|
|
689
|
-
if (splitter$1.types.horizontal) splitter$1.element.setAttribute(ATTRIBUTE_HORIZONTAL, "");
|
|
690
|
-
else splitter$1.element.removeAttribute(ATTRIBUTE_HORIZONTAL);
|
|
691
|
-
setAriaOrientation(splitter$1);
|
|
692
|
-
}
|
|
693
|
-
frame = void 0;
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
function onPointerdown(event) {
|
|
697
|
-
if (event.type === "mousedown" && touch_default.value || event.type === "touchstart" && !touch_default.value) return;
|
|
698
|
-
splitter = MAPPED_ELEMENTS.get(findAncestor(event.target, SELECTOR_HANDLE));
|
|
699
|
-
if (splitter == null) return;
|
|
700
|
-
if (touch_default.value) event.preventDefault();
|
|
701
|
-
splitter.handle.setAttribute(ATTRIBUTE_ACTIVE, "");
|
|
702
|
-
splitter.separator.setAttribute(ATTRIBUTE_ACTIVE, "");
|
|
703
|
-
splitter.rectangle = splitter.element.getBoundingClientRect();
|
|
704
|
-
STYLING_TOGGLER.set();
|
|
705
|
-
}
|
|
706
|
-
function onPointermove(event) {
|
|
707
|
-
if (splitter == null) return;
|
|
708
|
-
const position = getPosition(event);
|
|
709
|
-
if (position != null) {
|
|
710
|
-
splitter.values.now.current = getSize(splitter, splitter.types.horizontal ? position.y : position.x);
|
|
711
|
-
setSize(splitter, splitter.values.now.current);
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
function onPointerup() {
|
|
715
|
-
if (splitter != null) onEnd(false);
|
|
716
|
-
}
|
|
717
|
-
function setAriaOrientation(splitter$1) {
|
|
718
|
-
splitter$1.separator.setAttribute("aria-orientation", splitter$1.types.horizontal ? "horizontal" : "vertical");
|
|
719
|
-
}
|
|
720
|
-
function setAriaValue(splitter$1) {
|
|
721
|
-
splitter$1.separator.setAttribute("aria-valuemax", String(splitter$1.values.max));
|
|
722
|
-
splitter$1.separator.setAttribute("aria-valuemin", String(splitter$1.values.min));
|
|
723
|
-
splitter$1.separator.setAttribute("aria-valuenow", String(splitter$1.values.now.current));
|
|
724
|
-
}
|
|
725
|
-
function setSize(splitter$1, size, previous) {
|
|
726
|
-
splitter$1.values.now.current = size;
|
|
727
|
-
if (previous) splitter$1.values.now.previous = size;
|
|
728
|
-
splitter$1.element.style.setProperty("--oui-splitter-size", `${size}`);
|
|
729
|
-
setAriaValue(splitter$1);
|
|
730
|
-
}
|
|
731
|
-
const SELECTOR = "oui-splitter";
|
|
732
|
-
const ATTRIBUTE_ACTIVE = `${SELECTOR}-active`;
|
|
733
|
-
const ATTRIBUTE_HANDLE = `${SELECTOR}-handle`;
|
|
734
|
-
const ATTRIBUTE_HORIZONTAL = `${SELECTOR}-horizontal`;
|
|
735
|
-
const ATTRIBUTE_SEPARATOR = `${SELECTOR}-separator`;
|
|
736
|
-
const KEYS_ABSOLUTE = new Set(["End", "Home"]);
|
|
737
|
-
const KEYS_HORIZONTAL = new Set(["ArrowDown", "ArrowUp"]);
|
|
738
|
-
const KEYS_NEGATIVE = new Set(["ArrowLeft", "ArrowUp"]);
|
|
739
|
-
const KEYS_VERTICAL = new Set(["ArrowLeft", "ArrowRight"]);
|
|
740
|
-
const KEYS_ALL = new Set([
|
|
741
|
-
...KEYS_ABSOLUTE,
|
|
742
|
-
...KEYS_HORIZONTAL,
|
|
743
|
-
...KEYS_VERTICAL
|
|
744
|
-
]);
|
|
745
|
-
const MAPPED_ELEMENTS = /* @__PURE__ */ new WeakMap();
|
|
746
|
-
const METHODS_CONNECT = ["delete", "set"];
|
|
747
|
-
const METHODS_OBSERVE = ["unobserve", "observe"];
|
|
748
|
-
const NAVIGATION_MAXIMUM_PERCENTAGE = .9;
|
|
749
|
-
const NAVIGATION_MAXIMUM_TOTAL = 100;
|
|
750
|
-
const NAVIGATION_MINIMUM_PERCENTAGE = .1;
|
|
751
|
-
const NAVIGATION_MODIFIER = .05;
|
|
752
|
-
const RESIZE_OBSERVER = new ResizeObserver(onObservation);
|
|
753
|
-
const SELECTOR_HANDLE = `[${ATTRIBUTE_HANDLE}]`;
|
|
754
|
-
const STYLING_TOGGLER = toggleStyles(document.body, {
|
|
755
|
-
touchAction: "none",
|
|
756
|
-
userSelect: "none",
|
|
757
|
-
webkitUserSelect: "none"
|
|
758
|
-
});
|
|
759
|
-
const VALUE_DECIMALS = 6;
|
|
760
|
-
let frame;
|
|
761
|
-
let splitter;
|
|
762
|
-
customElements.define(SELECTOR, OuiSplitterElement);
|
|
763
|
-
on(document, "keydown", onKeydown);
|
|
764
|
-
on(document, "mousedown", onPointerdown);
|
|
765
|
-
on(document, "pointermove", onPointermove);
|
|
766
|
-
on(document, "pointerup", onPointerup);
|
|
767
|
-
on(document, "touchcancel", onPointerup, { passive: false });
|
|
768
|
-
on(document, "touchstart", onPointerdown, { passive: false });
|
|
769
|
-
export { OuiSplitterElement };
|