@oscarpalmer/oui 0.28.0 → 0.29.1
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/js/dialog.d.mts +1 -1
- package/dist/js/dialog.mjs +19 -20
- package/dist/js/{draggable-zszaW1qS.d.mts → draggable-fIYXd8eO.d.mts} +3 -3
- package/dist/js/floatable/floatable.embedded.d.mts +2 -2
- package/dist/js/floatable/floatable.embedded.mjs +17 -16
- package/dist/js/floatable/floatable.standalone.d.mts +1 -1
- package/dist/js/{floatable.embedded-YxGwzgbE.d.mts → floatable.embedded-DUR8bQBK.d.mts} +1 -2
- package/dist/js/focus-trap/focus-trap.embedded.mjs +6 -5
- package/dist/js/index.d.mts +2 -2
- package/dist/js/index.mjs +1 -0
- package/dist/js/internal/attributable.mjs +3 -4
- package/dist/js/internal/draggable.d.mts +1 -1
- package/dist/js/internal/draggable.mjs +11 -8
- package/dist/js/internal/navigable.d.mts +32 -0
- package/dist/js/internal/navigable.mjs +107 -0
- package/dist/js/menu.d.mts +1 -0
- package/dist/js/menu.mjs +168 -0
- package/dist/js/movable/movable.embedded.d.mts +1 -1
- package/dist/js/movable/movable.embedded.mjs +8 -13
- package/dist/js/movable/movable.standalone.d.mts +1 -1
- package/dist/js/popover.d.mts +1 -1
- package/dist/js/popover.mjs +28 -13
- package/dist/js/resizable/resizable.embedded.mjs +16 -11
- package/dist/js/sortable/sortable.embedded.d.mts +1 -1
- package/dist/js/sortable/sortable.embedded.mjs +15 -13
- package/dist/js/sortable/sortable.standalone.d.mts +1 -1
- package/dist/js/splitter.mjs +29 -25
- package/dist/js/toolbar.mjs +12 -88
- package/dist/js/tooltip.d.mts +1 -1
- package/dist/js/tooltip.mjs +12 -17
- package/package.json +7 -3
- package/src/js/dialog.ts +22 -26
- package/src/js/floatable/floatable.embedded.ts +19 -18
- package/src/js/focus-trap/focus-trap.embedded.ts +6 -5
- package/src/js/index.ts +1 -0
- package/src/js/internal/attributable.ts +3 -5
- package/src/js/internal/draggable.ts +12 -9
- package/src/js/internal/navigable.ts +247 -0
- package/src/js/menu.ts +345 -0
- package/src/js/movable/movable.embedded.ts +10 -13
- package/src/js/popover.ts +42 -16
- package/src/js/resizable/resizable.embedded.ts +17 -10
- package/src/js/sortable/sortable.embedded.ts +17 -22
- package/src/js/splitter.ts +40 -35
- package/src/js/toolbar.ts +27 -178
- package/src/js/tooltip.ts +18 -30
package/src/js/popover.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {getAria, setAria} from '@oscarpalmer/toretto/aria';
|
|
2
|
+
import {setAttribute} from '@oscarpalmer/toretto/attribute';
|
|
1
3
|
import {on} from '@oscarpalmer/toretto/event';
|
|
2
4
|
import {isHTMLOrSVGElement} from '@oscarpalmer/toretto/is';
|
|
3
5
|
import type {RemovableEventListener} from '@oscarpalmer/toretto/models';
|
|
@@ -34,6 +36,8 @@ class OuiPopover {
|
|
|
34
36
|
constructor(state: OuiPopoverState) {
|
|
35
37
|
this.#state = state;
|
|
36
38
|
|
|
39
|
+
initialize(state);
|
|
40
|
+
|
|
37
41
|
this.#state.floatable.update();
|
|
38
42
|
}
|
|
39
43
|
|
|
@@ -93,6 +97,18 @@ function destroyPopover(state: OuiPopoverState): void {
|
|
|
93
97
|
state.popover = undefined as never;
|
|
94
98
|
}
|
|
95
99
|
|
|
100
|
+
function getId(element: HTMLElement, value?: string): string {
|
|
101
|
+
let {id} = element;
|
|
102
|
+
|
|
103
|
+
if (id == null || id.trim().length === 0) {
|
|
104
|
+
id = value == null ? `oui_popover_${++index}` : `${value}_toggle`;
|
|
105
|
+
|
|
106
|
+
element.id = id;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return id;
|
|
110
|
+
}
|
|
111
|
+
|
|
96
112
|
/**
|
|
97
113
|
* Get the _OuiPopover_ for an element
|
|
98
114
|
*
|
|
@@ -109,29 +125,30 @@ function getState(anchor: HTMLElement, content: HTMLElement): OuiPopoverState {
|
|
|
109
125
|
content,
|
|
110
126
|
floatable: createEmbeddedFloatable(anchor, content, options),
|
|
111
127
|
focusTrap:
|
|
112
|
-
content
|
|
128
|
+
getAria(content, 'modal') === 'true'
|
|
113
129
|
? createFocusTrap(content, {
|
|
114
130
|
noescape: true,
|
|
115
131
|
})
|
|
116
132
|
: undefined,
|
|
117
133
|
listeners: [
|
|
118
134
|
getOnBeforeToggleListener(content),
|
|
119
|
-
on(content,
|
|
120
|
-
|
|
135
|
+
on(content, 'toggle', event => {
|
|
136
|
+
const expanded = event.newState === 'open';
|
|
137
|
+
|
|
138
|
+
if (expanded) {
|
|
121
139
|
ignoreFocus = false;
|
|
122
140
|
|
|
123
141
|
state.floatable?.update();
|
|
124
142
|
|
|
125
|
-
content.setAttribute(ATTRIBUTE_OPEN, '');
|
|
126
|
-
|
|
127
143
|
content.focus();
|
|
128
144
|
} else {
|
|
129
|
-
content.removeAttribute(ATTRIBUTE_OPEN);
|
|
130
|
-
|
|
131
145
|
if (!ignoreFocus) {
|
|
132
146
|
anchor?.focus();
|
|
133
147
|
}
|
|
134
148
|
}
|
|
149
|
+
|
|
150
|
+
setAria(anchor, 'expanded', expanded);
|
|
151
|
+
setAttribute(content, ATTRIBUTE_OPEN, expanded ? '' : undefined);
|
|
135
152
|
}),
|
|
136
153
|
],
|
|
137
154
|
popover: undefined as never,
|
|
@@ -142,6 +159,21 @@ function getState(anchor: HTMLElement, content: HTMLElement): OuiPopoverState {
|
|
|
142
159
|
return state;
|
|
143
160
|
}
|
|
144
161
|
|
|
162
|
+
function initialize(state: OuiPopoverState): void {
|
|
163
|
+
const id = getId(state.content);
|
|
164
|
+
|
|
165
|
+
setAria(state.anchor, {
|
|
166
|
+
controls: id,
|
|
167
|
+
expanded: 'false',
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const label = getAria(state.content, 'label') ?? getAria(state.content, 'labelledby');
|
|
171
|
+
|
|
172
|
+
if (label == null) {
|
|
173
|
+
setAria(state.content, 'labelledby', getId(state.anchor, id));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
145
177
|
function onPointerdown(): void {
|
|
146
178
|
ignoreFocus = true;
|
|
147
179
|
}
|
|
@@ -164,18 +196,10 @@ function removePopover(element: HTMLElement): void {
|
|
|
164
196
|
|
|
165
197
|
const ATTRIBUTE = 'oui-popover';
|
|
166
198
|
|
|
167
|
-
const ARIA_MODAL = 'aria-modal';
|
|
168
|
-
|
|
169
199
|
const ATTRIBUTE_OPEN = `${ATTRIBUTE}-open`;
|
|
170
200
|
|
|
171
|
-
const EVENT_TOGGLE = 'toggle';
|
|
172
|
-
|
|
173
|
-
const STATE_OPEN = 'open';
|
|
174
|
-
|
|
175
|
-
const TRUE = 'true';
|
|
176
|
-
|
|
177
201
|
const options: OuiFloatableOptions = {
|
|
178
|
-
attribute: `${ATTRIBUTE}position`,
|
|
202
|
+
attribute: `${ATTRIBUTE}-position`,
|
|
179
203
|
position: 'below-start',
|
|
180
204
|
reusable: false,
|
|
181
205
|
};
|
|
@@ -184,6 +208,8 @@ const states = new WeakMap<HTMLElement, OuiPopoverState>();
|
|
|
184
208
|
|
|
185
209
|
let ignoreFocus = false;
|
|
186
210
|
|
|
211
|
+
let index = 0;
|
|
212
|
+
|
|
187
213
|
// #endregion
|
|
188
214
|
|
|
189
215
|
// #region Initialization
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {isPlainObject} from '@oscarpalmer/atoms/is';
|
|
2
2
|
import type {EventPosition} from '@oscarpalmer/atoms/models';
|
|
3
3
|
import {getNumber} from '@oscarpalmer/atoms/number';
|
|
4
|
+
import {getAttribute, setAttribute} from '@oscarpalmer/toretto/attribute';
|
|
4
5
|
import {getPosition, on} from '@oscarpalmer/toretto/event';
|
|
5
6
|
import {findAncestor} from '@oscarpalmer/toretto/find';
|
|
6
7
|
import {isHTMLOrSVGElement} from '@oscarpalmer/toretto/is';
|
|
7
|
-
import {toggleStyles, type StyleToggler} from '@oscarpalmer/toretto/style';
|
|
8
|
+
import {setStyles, toggleStyles, type StyleToggler} from '@oscarpalmer/toretto/style';
|
|
8
9
|
import supportsTouch from '@oscarpalmer/toretto/touch';
|
|
9
10
|
import {attributable} from '../internal/attributable';
|
|
10
11
|
|
|
@@ -38,8 +39,10 @@ export class OuiResizable {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
reset(): void {
|
|
41
|
-
this.#state.element
|
|
42
|
-
|
|
42
|
+
setStyles(this.#state.element, {
|
|
43
|
+
height: '',
|
|
44
|
+
width: '',
|
|
45
|
+
});
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
|
|
@@ -134,8 +137,10 @@ function getAndSetDimensions(
|
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
if (element.checkVisibility()) {
|
|
137
|
-
element
|
|
138
|
-
|
|
140
|
+
setStyles(element, {
|
|
141
|
+
height: `${height}px`,
|
|
142
|
+
width: `${width}px`,
|
|
143
|
+
});
|
|
139
144
|
}
|
|
140
145
|
|
|
141
146
|
return [width, height];
|
|
@@ -186,7 +191,7 @@ function getState(
|
|
|
186
191
|
handle: HTMLElement,
|
|
187
192
|
input?: CreateOuiResizableOptions,
|
|
188
193
|
): OuiResizableState {
|
|
189
|
-
|
|
194
|
+
setAttribute(element, RESIZABLE_ATTRIBUTE, '');
|
|
190
195
|
|
|
191
196
|
const options = getValidOptions(element, input);
|
|
192
197
|
|
|
@@ -211,11 +216,11 @@ function getValidOptions(
|
|
|
211
216
|
return {
|
|
212
217
|
...getRestrictions(
|
|
213
218
|
input == null
|
|
214
|
-
? (
|
|
219
|
+
? (getAttribute(element, ATTRIBUTE_MAXIMUM) ??
|
|
215
220
|
getProperties(element, 'maxWidth', 'maxHeight'))
|
|
216
221
|
: [original.maximumWidth, original.maximumHeight],
|
|
217
222
|
input == null
|
|
218
|
-
? (
|
|
223
|
+
? (getAttribute(element, ATTRIBUTE_MINIMUM) ??
|
|
219
224
|
getProperties(element, 'minWidth', 'minHeight'))
|
|
220
225
|
: [original.minimumWidth, original.minimumHeight],
|
|
221
226
|
),
|
|
@@ -244,8 +249,10 @@ function onKeydown(event: KeyboardEvent): void {
|
|
|
244
249
|
return;
|
|
245
250
|
}
|
|
246
251
|
|
|
247
|
-
current.state.element
|
|
248
|
-
|
|
252
|
+
setStyles(current.state.element, {
|
|
253
|
+
height: `${current.state.height}px`,
|
|
254
|
+
width: `${current.state.width}px`,
|
|
255
|
+
});
|
|
249
256
|
|
|
250
257
|
resetResizable();
|
|
251
258
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type {EventPosition, PlainObject} from '@oscarpalmer/atoms/models';
|
|
2
|
+
import {getAttribute, setAttribute, setAttributes} from '@oscarpalmer/toretto/attribute';
|
|
2
3
|
import {createElement} from '@oscarpalmer/toretto/create';
|
|
3
4
|
import {getPosition} from '@oscarpalmer/toretto/event';
|
|
4
5
|
import {findAncestor, getElementFromPosition} from '@oscarpalmer/toretto/find';
|
|
5
6
|
import {isHTMLOrSVGElement} from '@oscarpalmer/toretto/is';
|
|
7
|
+
import {setStyle} from '@oscarpalmer/toretto/style';
|
|
6
8
|
import {attributable} from '../internal/attributable';
|
|
7
9
|
import {
|
|
8
10
|
addDraggable,
|
|
@@ -50,7 +52,7 @@ export class OuiSortable extends OuiDraggable<OuiSortableState> {
|
|
|
50
52
|
(getDraggableStates(element)?.sortable as OuiDraggableState & OuiSortableState)?.origin,
|
|
51
53
|
},
|
|
52
54
|
{
|
|
53
|
-
connections:
|
|
55
|
+
connections: getAttribute(element, ATTRIBUTE_CONNECTIONS),
|
|
54
56
|
},
|
|
55
57
|
);
|
|
56
58
|
}
|
|
@@ -67,7 +69,7 @@ type OuiSortablePlaceholderDrag = {
|
|
|
67
69
|
};
|
|
68
70
|
|
|
69
71
|
type OuiSortableState = {
|
|
70
|
-
connections: string | null;
|
|
72
|
+
connections: string | null | undefined;
|
|
71
73
|
origin?: HTMLElement;
|
|
72
74
|
};
|
|
73
75
|
|
|
@@ -166,10 +168,11 @@ function getOriginalPosition(
|
|
|
166
168
|
function getPositionPlaceholder(item: OuiDraggableItem<OuiSortableState>): HTMLElement {
|
|
167
169
|
placeholder.position ??= createElement('div');
|
|
168
170
|
|
|
169
|
-
placeholder.position
|
|
171
|
+
setAttribute(placeholder.position, ATTRIBUTE_PLACEHOLDER_POSITION, '');
|
|
170
172
|
|
|
171
173
|
if (item.state.origin != null) {
|
|
172
|
-
|
|
174
|
+
setStyle(
|
|
175
|
+
placeholder.position,
|
|
173
176
|
'--placeholder-height',
|
|
174
177
|
`${item.state.origin.getBoundingClientRect().height}px`,
|
|
175
178
|
);
|
|
@@ -188,9 +191,9 @@ function onBegin(
|
|
|
188
191
|
|
|
189
192
|
setPlaceholder(globals, item, element);
|
|
190
193
|
|
|
191
|
-
|
|
194
|
+
setAttribute(element, ATTRIBUTE_ORIGIN, '');
|
|
192
195
|
|
|
193
|
-
document.body
|
|
196
|
+
setAttribute(document.body, ATTRIBUTE_ACTIVE, '');
|
|
194
197
|
}
|
|
195
198
|
|
|
196
199
|
function onCancel(_: OuiDraggableGlobals, item: OuiDraggableItem<OuiSortableState>): void {
|
|
@@ -218,7 +221,7 @@ function onEnd(
|
|
|
218
221
|
let element = findAncestor(target, SELECTOR_ITEM) as HTMLElement;
|
|
219
222
|
|
|
220
223
|
if (element?.hasAttribute(ATTRIBUTE_PLACEHOLDER_POSITION)) {
|
|
221
|
-
const position =
|
|
224
|
+
const position = getAttribute(element, ATTRIBUTE_PLACEHOLDER_POSITION);
|
|
222
225
|
|
|
223
226
|
if (position === 'after') {
|
|
224
227
|
element = element.previousElementSibling as HTMLElement;
|
|
@@ -344,7 +347,7 @@ function onMove(
|
|
|
344
347
|
toElement.insertAdjacentElement(INSERT_AFTER, placeholder);
|
|
345
348
|
}
|
|
346
349
|
|
|
347
|
-
|
|
350
|
+
setAttribute(placeholder, ATTRIBUTE_PLACEHOLDER_POSITION, place);
|
|
348
351
|
} else {
|
|
349
352
|
placeholder.remove();
|
|
350
353
|
}
|
|
@@ -417,9 +420,8 @@ function setPlaceholder(
|
|
|
417
420
|
}
|
|
418
421
|
|
|
419
422
|
function updatePlaceholder(item: OuiDraggableItem<OuiSortableState>, element: HTMLElement): void {
|
|
420
|
-
element
|
|
421
|
-
|
|
422
|
-
element.setAttribute(ATTRIBUTE_PLACEHOLDER_DRAG, '');
|
|
423
|
+
setAttribute(element, ATTRIBUTE_PLACEHOLDER_DRAG, '');
|
|
424
|
+
setStyle(element, 'position', 'fixed');
|
|
423
425
|
|
|
424
426
|
const state = getDraggableStates(item.state.element)?.sortable;
|
|
425
427
|
|
|
@@ -427,17 +429,10 @@ function updatePlaceholder(item: OuiDraggableItem<OuiSortableState>, element: HT
|
|
|
427
429
|
return;
|
|
428
430
|
}
|
|
429
431
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
if (state.vertical) {
|
|
437
|
-
element.setAttribute(ATTRIBUTE_VERTICAL, '');
|
|
438
|
-
} else {
|
|
439
|
-
element.removeAttribute(ATTRIBUTE_VERTICAL);
|
|
440
|
-
}
|
|
432
|
+
setAttributes(element, {
|
|
433
|
+
[ATTRIBUTE_HORIZONTAL]: state.horizontal ? '' : undefined,
|
|
434
|
+
[ATTRIBUTE_VERTICAL]: state.vertical ? '' : undefined,
|
|
435
|
+
});
|
|
441
436
|
}
|
|
442
437
|
|
|
443
438
|
function validatePosition(
|
package/src/js/splitter.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {isNullableOrWhitespace} from '@oscarpalmer/atoms/is';
|
|
2
2
|
import {round} from '@oscarpalmer/atoms/math';
|
|
3
3
|
import {clamp} from '@oscarpalmer/atoms/number';
|
|
4
|
+
import {setAria} from '@oscarpalmer/toretto/aria';
|
|
5
|
+
import {getAttribute, setAttribute} from '@oscarpalmer/toretto/attribute';
|
|
4
6
|
import {getPosition, on} from '@oscarpalmer/toretto/event';
|
|
5
7
|
import {findAncestor} from '@oscarpalmer/toretto/find';
|
|
6
|
-
import {type StyleToggler, toggleStyles} from '@oscarpalmer/toretto/style';
|
|
8
|
+
import {setStyle, type StyleToggler, toggleStyles} from '@oscarpalmer/toretto/style';
|
|
7
9
|
import supportsTouch from '@oscarpalmer/toretto/touch';
|
|
8
10
|
|
|
9
11
|
declare global {
|
|
@@ -78,11 +80,7 @@ class OuiSplitter {
|
|
|
78
80
|
RESIZE_OBSERVER.unobserve(this.element);
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
this.element.setAttribute(ATTRIBUTE_HORIZONTAL, '');
|
|
83
|
-
} else {
|
|
84
|
-
this.element.removeAttribute(ATTRIBUTE_HORIZONTAL);
|
|
85
|
-
}
|
|
83
|
+
setAttribute(this.element, ATTRIBUTE_HORIZONTAL, this.types.horizontal ? '' : undefined);
|
|
86
84
|
|
|
87
85
|
setAriaOrientation(this);
|
|
88
86
|
}
|
|
@@ -120,7 +118,9 @@ export class OuiSplitterElement extends HTMLElement {
|
|
|
120
118
|
* Maximum size for the first panel
|
|
121
119
|
*/
|
|
122
120
|
set max(value: number) {
|
|
123
|
-
|
|
121
|
+
if (typeof value === 'number') {
|
|
122
|
+
setAttribute(this, ATTRIBUTE_MAX, value.toString());
|
|
123
|
+
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
@@ -134,7 +134,9 @@ export class OuiSplitterElement extends HTMLElement {
|
|
|
134
134
|
* Minimum size for the first panel
|
|
135
135
|
*/
|
|
136
136
|
set min(value: number) {
|
|
137
|
-
|
|
137
|
+
if (typeof value === 'number') {
|
|
138
|
+
setAttribute(this, ATTRIBUTE_MIN, value.toString());
|
|
139
|
+
}
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
/**
|
|
@@ -148,21 +150,23 @@ export class OuiSplitterElement extends HTMLElement {
|
|
|
148
150
|
* Current size for the first panel
|
|
149
151
|
*/
|
|
150
152
|
set size(value: number) {
|
|
151
|
-
|
|
153
|
+
if (typeof value === 'number') {
|
|
154
|
+
setAttribute(this, ATTRIBUTE_SIZE, value.toString());
|
|
155
|
+
}
|
|
152
156
|
}
|
|
153
157
|
|
|
154
158
|
/**
|
|
155
159
|
* Orientation of the splitter
|
|
156
160
|
*/
|
|
157
161
|
get type(): string {
|
|
158
|
-
return
|
|
162
|
+
return getAttribute(this, ATTRIBUTE_TYPE) ?? 'vertical';
|
|
159
163
|
}
|
|
160
164
|
|
|
161
165
|
/**
|
|
162
166
|
* Orientation of the splitter
|
|
163
167
|
*/
|
|
164
168
|
set type(value: string) {
|
|
165
|
-
|
|
169
|
+
setAttribute(this, ATTRIBUTE_TYPE, value);
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
// Constructor
|
|
@@ -170,7 +174,7 @@ export class OuiSplitterElement extends HTMLElement {
|
|
|
170
174
|
constructor() {
|
|
171
175
|
super();
|
|
172
176
|
|
|
173
|
-
const panels = [...this.children].filter(child => child instanceof HTMLElement
|
|
177
|
+
const panels = [...this.children].filter(child => child instanceof Element) as HTMLElement[];
|
|
174
178
|
|
|
175
179
|
if (panels.length !== 2) {
|
|
176
180
|
throw new Error(MESSAGE);
|
|
@@ -228,8 +232,8 @@ type OuiSplitterValuesNow = {
|
|
|
228
232
|
function createHandle(): HTMLSpanElement {
|
|
229
233
|
const handle = document.createElement('span');
|
|
230
234
|
|
|
231
|
-
handle
|
|
232
|
-
|
|
235
|
+
setAria(handle, 'hidden', 'true');
|
|
236
|
+
setAttribute(handle, ATTRIBUTE_HANDLE, '');
|
|
233
237
|
|
|
234
238
|
return handle;
|
|
235
239
|
}
|
|
@@ -240,9 +244,12 @@ function createSeparator(splitter: OuiSplitter): HTMLDivElement {
|
|
|
240
244
|
separator.role = 'separator';
|
|
241
245
|
separator.tabIndex = 0;
|
|
242
246
|
|
|
243
|
-
separator
|
|
244
|
-
|
|
245
|
-
|
|
247
|
+
setAria(separator, {
|
|
248
|
+
controls: splitter.element.id,
|
|
249
|
+
label: 'Resize panels',
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
setAttribute(separator, ATTRIBUTE_SEPARATOR, '');
|
|
246
253
|
|
|
247
254
|
return separator;
|
|
248
255
|
}
|
|
@@ -262,7 +269,7 @@ function getSize(splitter: OuiSplitter, value: number): number {
|
|
|
262
269
|
}
|
|
263
270
|
|
|
264
271
|
function getTypes(splitter: OuiSplitter, width?: number, height?: number): OuiSplitterTypes {
|
|
265
|
-
const type = splitter.element
|
|
272
|
+
const type = getAttribute(splitter.element, 'type');
|
|
266
273
|
|
|
267
274
|
if (type === 'horizontal') {
|
|
268
275
|
return {
|
|
@@ -285,7 +292,7 @@ function getTypes(splitter: OuiSplitter, width?: number, height?: number): OuiSp
|
|
|
285
292
|
}
|
|
286
293
|
|
|
287
294
|
function getValue(element: HTMLElement, name: string, defaultValue: number): number {
|
|
288
|
-
const value =
|
|
295
|
+
const value = getAttribute(element, name);
|
|
289
296
|
|
|
290
297
|
if (isNullableOrWhitespace(value)) {
|
|
291
298
|
return defaultValue;
|
|
@@ -408,11 +415,11 @@ function onObservation(entries: ResizeObserverEntry[]): void {
|
|
|
408
415
|
|
|
409
416
|
splitter.types = getTypes(splitter, entry.contentRect.width, entry.contentRect.height);
|
|
410
417
|
|
|
411
|
-
|
|
412
|
-
splitter.element
|
|
413
|
-
|
|
414
|
-
splitter.
|
|
415
|
-
|
|
418
|
+
setAttribute(
|
|
419
|
+
splitter.element,
|
|
420
|
+
ATTRIBUTE_HORIZONTAL,
|
|
421
|
+
splitter.types.horizontal ? '' : undefined,
|
|
422
|
+
);
|
|
416
423
|
|
|
417
424
|
setAriaOrientation(splitter);
|
|
418
425
|
}
|
|
@@ -436,8 +443,8 @@ function onPointerdown(event: Event): void {
|
|
|
436
443
|
event.preventDefault();
|
|
437
444
|
}
|
|
438
445
|
|
|
439
|
-
splitter.handle
|
|
440
|
-
splitter.separator
|
|
446
|
+
setAttribute(splitter.handle, ATTRIBUTE_ACTIVE, '');
|
|
447
|
+
setAttribute(splitter.separator, ATTRIBUTE_ACTIVE, '');
|
|
441
448
|
|
|
442
449
|
splitter.rectangle = splitter.element.getBoundingClientRect();
|
|
443
450
|
|
|
@@ -468,17 +475,15 @@ function onPointerup(): void {
|
|
|
468
475
|
}
|
|
469
476
|
|
|
470
477
|
function setAriaOrientation(splitter: OuiSplitter): void {
|
|
471
|
-
splitter.separator.
|
|
472
|
-
'aria-orientation',
|
|
473
|
-
splitter.types.horizontal ? 'horizontal' : 'vertical',
|
|
474
|
-
);
|
|
478
|
+
setAria(splitter.separator, 'orientation', splitter.types.horizontal ? 'horizontal' : 'vertical');
|
|
475
479
|
}
|
|
476
480
|
|
|
477
481
|
function setAriaValue(splitter: OuiSplitter): void {
|
|
478
|
-
splitter.separator
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
+
setAria(splitter.separator, {
|
|
483
|
+
valuemax: splitter.values.max,
|
|
484
|
+
valuemin: splitter.values.min,
|
|
485
|
+
valuenow: splitter.values.now.current,
|
|
486
|
+
});
|
|
482
487
|
}
|
|
483
488
|
|
|
484
489
|
function setSize(splitter: OuiSplitter, size: number, previous?: boolean): void {
|
|
@@ -488,7 +493,7 @@ function setSize(splitter: OuiSplitter, size: number, previous?: boolean): void
|
|
|
488
493
|
splitter.values.now.previous = size;
|
|
489
494
|
}
|
|
490
495
|
|
|
491
|
-
splitter.element
|
|
496
|
+
setStyle(splitter.element, '--oui-splitter-size', `${size}`);
|
|
492
497
|
|
|
493
498
|
setAriaValue(splitter);
|
|
494
499
|
}
|