@oscarpalmer/oui 0.30.0 → 0.32.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 +1 -5
- package/dist/css/combobox.css +224 -0
- package/dist/css/form.css +18 -14
- package/dist/js/combobox.d.mts +65 -1
- package/dist/js/combobox.mjs +587 -206
- package/dist/js/focus-trap/focus-trap.embedded.mjs +3 -4
- package/dist/js/internal/draggable.mjs +7 -15
- package/dist/js/menu.d.mts +1 -1
- package/dist/js/menu.mjs +5 -2
- package/dist/js/movable/movable.embedded.mjs +6 -10
- package/dist/js/resizable/resizable.embedded.mjs +9 -16
- package/dist/js/sortable/sortable.embedded.mjs +21 -26
- package/dist/js/toolbar.d.mts +1 -1
- package/package.json +4 -4
- package/src/css/badge.scss +1 -18
- package/src/css/combobox.scss +192 -2
- package/src/css/form.scss +18 -80
- package/src/css/mixins.scss +78 -0
- package/src/js/combobox.ts +1053 -336
- package/src/js/focus-trap/focus-trap.embedded.ts +3 -7
- package/src/js/internal/draggable.ts +4 -10
- package/src/js/menu.ts +5 -2
- package/src/js/movable/movable.embedded.ts +3 -6
- package/src/js/resizable/resizable.embedded.ts +6 -19
- package/src/js/sortable/sortable.embedded.ts +17 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {isPlainObject} from '@oscarpalmer/atoms/is';
|
|
2
2
|
import {clamp} from '@oscarpalmer/atoms/number';
|
|
3
3
|
import {setAttribute} from '@oscarpalmer/toretto/attribute';
|
|
4
|
-
import {on} from '@oscarpalmer/toretto/event';
|
|
4
|
+
import {dispatch, on} from '@oscarpalmer/toretto/event';
|
|
5
5
|
import {findAncestor} from '@oscarpalmer/toretto/find';
|
|
6
6
|
import {getFocusable} from '@oscarpalmer/toretto/focusable';
|
|
7
7
|
import {isHTMLOrSVGElement} from '@oscarpalmer/toretto/is';
|
|
@@ -289,14 +289,10 @@ function onTab(event: KeyboardEvent): void {
|
|
|
289
289
|
return;
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
const
|
|
293
|
-
cancelable: true,
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
element.dispatchEvent(dispatch);
|
|
292
|
+
const dispatched = dispatch(element, 'focus-trap');
|
|
297
293
|
|
|
298
294
|
setTimeout(() => {
|
|
299
|
-
if (
|
|
295
|
+
if (dispatched.defaultPrevented) {
|
|
300
296
|
return;
|
|
301
297
|
}
|
|
302
298
|
|
|
@@ -406,18 +406,15 @@ function onPointerdown(event: MouseEvent | TouchEvent): void {
|
|
|
406
406
|
globals.offset = item.state.options.position.getOffset(globals, item, element, position);
|
|
407
407
|
globals.original = item.state.options.position.getOriginal(globals, item, position);
|
|
408
408
|
|
|
409
|
-
const
|
|
409
|
+
const dispatched = dispatch(item.state.element, `${item.state.name}:begin`, {
|
|
410
410
|
detail: {
|
|
411
411
|
element,
|
|
412
412
|
position: {...globals.original},
|
|
413
413
|
},
|
|
414
|
-
cancelable: true,
|
|
415
414
|
});
|
|
416
415
|
|
|
417
|
-
item.state.element.dispatchEvent(dispatch);
|
|
418
|
-
|
|
419
416
|
setTimeout(() => {
|
|
420
|
-
if (
|
|
417
|
+
if (dispatched.defaultPrevented) {
|
|
421
418
|
item.state.options.drag.onCancel?.(globals, item);
|
|
422
419
|
|
|
423
420
|
reset();
|
|
@@ -462,15 +459,12 @@ function onPointermove(event: MouseEvent | TouchEvent): void {
|
|
|
462
459
|
original: position,
|
|
463
460
|
});
|
|
464
461
|
|
|
465
|
-
const
|
|
462
|
+
const dispatched = dispatch(current.state.element, `${current.state.name}:move`, {
|
|
466
463
|
detail,
|
|
467
|
-
cancelable: true,
|
|
468
464
|
});
|
|
469
465
|
|
|
470
|
-
current.state.element.dispatchEvent(dispatch);
|
|
471
|
-
|
|
472
466
|
setTimeout(() => {
|
|
473
|
-
if (
|
|
467
|
+
if (dispatched.defaultPrevented) {
|
|
474
468
|
cancelDrag(current);
|
|
475
469
|
}
|
|
476
470
|
});
|
package/src/js/menu.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {setAria, setRole} from '@oscarpalmer/toretto/aria';
|
|
2
|
-
import {setAttribute} from '@oscarpalmer/toretto/attribute';
|
|
2
|
+
import {setAttribute, setAttributes} from '@oscarpalmer/toretto/attribute';
|
|
3
3
|
import {on} from '@oscarpalmer/toretto/event';
|
|
4
4
|
import {findAncestor} from '@oscarpalmer/toretto/find';
|
|
5
5
|
import {createEmbeddedFloatable, getOnBeforeToggleListener} from './floatable/floatable.embedded';
|
|
@@ -197,7 +197,10 @@ function initializeMenu(menu: OuiMenu): void {
|
|
|
197
197
|
haspopup: 'menu',
|
|
198
198
|
});
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
setAttributes(menu.content, {
|
|
201
|
+
popover: '',
|
|
202
|
+
tabindex: '-1',
|
|
203
|
+
});
|
|
201
204
|
|
|
202
205
|
setRole(menu.content, 'menu');
|
|
203
206
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {EventPosition, PlainObject} from '@oscarpalmer/atoms/models';
|
|
2
2
|
import {setAttribute} from '@oscarpalmer/toretto/attribute';
|
|
3
|
-
import {getPosition, on} from '@oscarpalmer/toretto/event';
|
|
3
|
+
import {dispatch, getPosition, on} from '@oscarpalmer/toretto/event';
|
|
4
4
|
import {isHTMLOrSVGElement} from '@oscarpalmer/toretto/is';
|
|
5
5
|
import {getStyles, setStyle, setStyles} from '@oscarpalmer/toretto/style';
|
|
6
6
|
import {attributable} from '../internal/attributable';
|
|
@@ -199,18 +199,15 @@ function onEnd(
|
|
|
199
199
|
setOffset(state, container);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
const
|
|
202
|
+
const dispatched = dispatch(state.element, 'movable:end', {
|
|
203
203
|
detail: {
|
|
204
204
|
from: {...globals.original},
|
|
205
205
|
to: getPosition(event),
|
|
206
206
|
},
|
|
207
|
-
cancelable: true,
|
|
208
207
|
});
|
|
209
208
|
|
|
210
|
-
state.element.dispatchEvent(end);
|
|
211
|
-
|
|
212
209
|
setTimeout(() => {
|
|
213
|
-
if (
|
|
210
|
+
if (dispatched.defaultPrevented) {
|
|
214
211
|
onCancel(globals, item);
|
|
215
212
|
}
|
|
216
213
|
|
|
@@ -32,8 +32,6 @@ export class OuiResizable {
|
|
|
32
32
|
set(): void {
|
|
33
33
|
const [width, height] = getAndSetDimensions(this.#state.element, this.#state.options);
|
|
34
34
|
|
|
35
|
-
console.log('set', width, height);
|
|
36
|
-
|
|
37
35
|
this.#state.width = width;
|
|
38
36
|
this.#state.height = height;
|
|
39
37
|
}
|
|
@@ -291,14 +289,10 @@ function onPointerdown(event: MouseEvent | TouchEvent): void {
|
|
|
291
289
|
event.preventDefault();
|
|
292
290
|
}
|
|
293
291
|
|
|
294
|
-
const
|
|
295
|
-
cancelable: true,
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
element!.dispatchEvent(dispatch);
|
|
292
|
+
const dispatched = dispatch(element!, 'resizable:begin');
|
|
299
293
|
|
|
300
294
|
setTimeout(() => {
|
|
301
|
-
if (
|
|
295
|
+
if (dispatched.defaultPrevented) {
|
|
302
296
|
return;
|
|
303
297
|
}
|
|
304
298
|
|
|
@@ -326,18 +320,15 @@ function onPointermove(event: MouseEvent | TouchEvent): void {
|
|
|
326
320
|
|
|
327
321
|
getAndSetDimensions(current.state.element, current.state.options, {height, width});
|
|
328
322
|
|
|
329
|
-
const
|
|
330
|
-
cancelable: true,
|
|
323
|
+
const dispatched = dispatch(current.state.element, 'resizable:resize', {
|
|
331
324
|
detail: {
|
|
332
325
|
height,
|
|
333
326
|
width,
|
|
334
327
|
},
|
|
335
328
|
});
|
|
336
329
|
|
|
337
|
-
current.state.element.dispatchEvent(dispatch);
|
|
338
|
-
|
|
339
330
|
setTimeout(() => {
|
|
340
|
-
if (
|
|
331
|
+
if (dispatched.defaultPrevented) {
|
|
341
332
|
cancelResize(current);
|
|
342
333
|
}
|
|
343
334
|
});
|
|
@@ -348,14 +339,10 @@ function onPointerup(): void {
|
|
|
348
339
|
return;
|
|
349
340
|
}
|
|
350
341
|
|
|
351
|
-
const
|
|
352
|
-
cancelable: true,
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
current.state.element.dispatchEvent(dispatch);
|
|
342
|
+
const dispatched = dispatch(current.state.element, 'resizable:end');
|
|
356
343
|
|
|
357
344
|
setTimeout(() => {
|
|
358
|
-
if (current == null ||
|
|
345
|
+
if (current == null || dispatched.defaultPrevented) {
|
|
359
346
|
cancelResize(current);
|
|
360
347
|
|
|
361
348
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {EventPosition, PlainObject} from '@oscarpalmer/atoms/models';
|
|
2
2
|
import {getAttribute, setAttribute, setAttributes} from '@oscarpalmer/toretto/attribute';
|
|
3
3
|
import {createElement} from '@oscarpalmer/toretto/create';
|
|
4
|
-
import {getPosition} from '@oscarpalmer/toretto/event';
|
|
4
|
+
import {dispatch, getPosition} from '@oscarpalmer/toretto/event';
|
|
5
5
|
import {findAncestor, getElementFromPosition} from '@oscarpalmer/toretto/find';
|
|
6
6
|
import {isHTMLOrSVGElement} from '@oscarpalmer/toretto/is';
|
|
7
7
|
import {setStyle} from '@oscarpalmer/toretto/style';
|
|
@@ -80,7 +80,7 @@ type OuiSortableState = {
|
|
|
80
80
|
function afterEnd(
|
|
81
81
|
insert: 'append' | 'insert' | 'prepend' | undefined,
|
|
82
82
|
from: OuiDraggableItem<OuiSortableState>,
|
|
83
|
-
events: CustomEvent
|
|
83
|
+
events: [CustomEvent, CustomEvent | undefined],
|
|
84
84
|
elements: {origin?: HTMLElement; target: HTMLElement},
|
|
85
85
|
position: EventPosition | undefined,
|
|
86
86
|
valid: boolean,
|
|
@@ -91,7 +91,7 @@ function afterEnd(
|
|
|
91
91
|
|
|
92
92
|
resetPlaceholders();
|
|
93
93
|
|
|
94
|
-
if (!valid || events.some(event => event
|
|
94
|
+
if (!valid || events.some(event => event?.defaultPrevented)) {
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -277,17 +277,23 @@ function onEnd(
|
|
|
277
277
|
cancelable: true,
|
|
278
278
|
};
|
|
279
279
|
|
|
280
|
-
const
|
|
281
|
-
const toEvent = new CustomEvent('sortable:end', options);
|
|
280
|
+
const dispatchedFrom = dispatch(item.instance.element, 'sortable:end', options);
|
|
282
281
|
|
|
283
|
-
|
|
282
|
+
let dispatchedTo: CustomEvent | undefined;
|
|
284
283
|
|
|
285
|
-
if (item.instance !== toInstance) {
|
|
286
|
-
toInstance
|
|
284
|
+
if (item.instance !== toInstance && toInstance != null) {
|
|
285
|
+
dispatchedTo = dispatch(toInstance.element, 'sortable:end', options);
|
|
287
286
|
}
|
|
288
287
|
|
|
289
288
|
setTimeout(() => {
|
|
290
|
-
afterEnd(
|
|
289
|
+
afterEnd(
|
|
290
|
+
insert,
|
|
291
|
+
item,
|
|
292
|
+
[dispatchedFrom, dispatchedTo],
|
|
293
|
+
{origin, target: element},
|
|
294
|
+
position,
|
|
295
|
+
valid,
|
|
296
|
+
);
|
|
291
297
|
|
|
292
298
|
reset();
|
|
293
299
|
});
|
|
@@ -383,8 +389,7 @@ function setPlaceholder(
|
|
|
383
389
|
|
|
384
390
|
updatePlaceholder(item, element);
|
|
385
391
|
|
|
386
|
-
const
|
|
387
|
-
cancelable: true,
|
|
392
|
+
const dispatched = dispatch(item.instance.element, 'sortable:placeholder', {
|
|
388
393
|
detail: {
|
|
389
394
|
origin,
|
|
390
395
|
parent: item.state.element,
|
|
@@ -408,10 +413,8 @@ function setPlaceholder(
|
|
|
408
413
|
},
|
|
409
414
|
});
|
|
410
415
|
|
|
411
|
-
item.instance.element.dispatchEvent(event);
|
|
412
|
-
|
|
413
416
|
setTimeout(() => {
|
|
414
|
-
if (!
|
|
417
|
+
if (!dispatched.defaultPrevented && placeholder.drag.custom == null) {
|
|
415
418
|
placeholder.drag.default?.append(element.cloneNode(true));
|
|
416
419
|
}
|
|
417
420
|
|