@oscarpalmer/oui 0.28.0 → 0.29.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.
Files changed (46) hide show
  1. package/dist/js/dialog.d.mts +1 -1
  2. package/dist/js/dialog.mjs +19 -20
  3. package/dist/js/{draggable-zszaW1qS.d.mts → draggable-fIYXd8eO.d.mts} +3 -3
  4. package/dist/js/floatable/floatable.embedded.d.mts +2 -2
  5. package/dist/js/floatable/floatable.embedded.mjs +17 -16
  6. package/dist/js/floatable/floatable.standalone.d.mts +1 -1
  7. package/dist/js/{floatable.embedded-YxGwzgbE.d.mts → floatable.embedded-DUR8bQBK.d.mts} +1 -2
  8. package/dist/js/focus-trap/focus-trap.embedded.mjs +6 -5
  9. package/dist/js/index.d.mts +2 -2
  10. package/dist/js/index.mjs +1 -0
  11. package/dist/js/internal/attributable.mjs +3 -4
  12. package/dist/js/internal/draggable.d.mts +1 -1
  13. package/dist/js/internal/draggable.mjs +11 -8
  14. package/dist/js/internal/navigable.d.mts +32 -0
  15. package/dist/js/internal/navigable.mjs +107 -0
  16. package/dist/js/menu.d.mts +1 -0
  17. package/dist/js/menu.mjs +168 -0
  18. package/dist/js/movable/movable.embedded.d.mts +1 -1
  19. package/dist/js/movable/movable.embedded.mjs +8 -13
  20. package/dist/js/movable/movable.standalone.d.mts +1 -1
  21. package/dist/js/popover.d.mts +1 -1
  22. package/dist/js/popover.mjs +27 -12
  23. package/dist/js/resizable/resizable.embedded.mjs +16 -11
  24. package/dist/js/sortable/sortable.embedded.d.mts +1 -1
  25. package/dist/js/sortable/sortable.embedded.mjs +15 -13
  26. package/dist/js/sortable/sortable.standalone.d.mts +1 -1
  27. package/dist/js/splitter.mjs +29 -25
  28. package/dist/js/toolbar.mjs +12 -88
  29. package/dist/js/tooltip.d.mts +1 -1
  30. package/dist/js/tooltip.mjs +12 -17
  31. package/package.json +7 -3
  32. package/src/js/dialog.ts +22 -26
  33. package/src/js/floatable/floatable.embedded.ts +19 -18
  34. package/src/js/focus-trap/focus-trap.embedded.ts +6 -5
  35. package/src/js/index.ts +1 -0
  36. package/src/js/internal/attributable.ts +3 -5
  37. package/src/js/internal/draggable.ts +12 -9
  38. package/src/js/internal/navigable.ts +247 -0
  39. package/src/js/menu.ts +345 -0
  40. package/src/js/movable/movable.embedded.ts +10 -13
  41. package/src/js/popover.ts +41 -15
  42. package/src/js/resizable/resizable.embedded.ts +17 -10
  43. package/src/js/sortable/sortable.embedded.ts +17 -22
  44. package/src/js/splitter.ts +40 -35
  45. package/src/js/toolbar.ts +27 -178
  46. package/src/js/tooltip.ts +18 -30
@@ -0,0 +1,168 @@
1
+ import { createEmbeddedFloatable, getOnBeforeToggleListener } from "./floatable/floatable.embedded.mjs";
2
+ import { attributable } from "./internal/attributable.mjs";
3
+ import { NAVIGABLE_KEYS_HORIZONTAL, NAVIGABLE_KEYS_VERTICAL, getNavigable, updateNavigableFocus } from "./internal/navigable.mjs";
4
+ import { setAria, setRole } from "@oscarpalmer/toretto/aria";
5
+ import { on } from "@oscarpalmer/toretto/event";
6
+ import { setAttribute } from "@oscarpalmer/toretto/attribute";
7
+ import { findAncestor } from "@oscarpalmer/toretto/find";
8
+ //#region src/js/menu.ts
9
+ var OuiMenu = class {
10
+ content;
11
+ element;
12
+ floatable;
13
+ navigable;
14
+ toggle;
15
+ get open() {
16
+ return this.floatable.open;
17
+ }
18
+ constructor(element, navigable) {
19
+ this.element = element;
20
+ this.navigable = navigable;
21
+ this.content = navigable.element;
22
+ this.toggle = element.querySelector(SELECTOR_MENU_TOGGLE);
23
+ this.floatable = createEmbeddedFloatable(this.toggle, this.content, {
24
+ attribute: ATTRIBUTE_MENU_POSITION,
25
+ position: findAncestor(element.parentElement, SELECTOR_MENU_CONTENT) == null ? "below-start" : "end-top",
26
+ reusable: false
27
+ });
28
+ this.navigable.listeners.push(getOnBeforeToggleListener(this.content), on(this.content, "click", (event) => {
29
+ event.stopPropagation();
30
+ if (findAncestor(event, SELECTOR_MENU_TOGGLE) != null) return;
31
+ const elements = document.querySelectorAll(SELECTOR_MENU_CONTENT);
32
+ for (const element of elements) menus.get(element)?.floatable.hide();
33
+ const menu = menus.get(elements[0]);
34
+ if (menu != null && event.pointerId === -1) updateNavigableFocus(menu.navigable, true);
35
+ }), on(this.content, "toggle", (event) => {
36
+ const expanded = event.newState === "open";
37
+ if (expanded) {
38
+ this.floatable?.update();
39
+ updateNavigableFocus(this.navigable, true);
40
+ }
41
+ setAria(this.toggle, "expanded", expanded);
42
+ }));
43
+ this.floatable.update();
44
+ initializeMenu(this);
45
+ updateNavigableFocus(this.navigable, false);
46
+ }
47
+ destroy() {
48
+ this.floatable.destroy();
49
+ this.navigable.destroy();
50
+ this.floatable = void 0;
51
+ this.navigable = void 0;
52
+ }
53
+ };
54
+ var OuiMenubar = class {
55
+ element;
56
+ navigable;
57
+ constructor(element, navigable) {
58
+ this.element = element;
59
+ this.navigable = navigable;
60
+ updateNavigableFocus(this.navigable, false);
61
+ }
62
+ destroy() {
63
+ this.navigable.destroy();
64
+ this.navigable = void 0;
65
+ }
66
+ };
67
+ function addInstance(instances, ctor, element, content, options) {
68
+ if (!instances.has(content)) instances.set(content, new ctor(element, getNavigable(content, {
69
+ ...options,
70
+ onDeactivate,
71
+ onPreventNavigation,
72
+ onShouldActivate,
73
+ onShouldDeactivate
74
+ })));
75
+ }
76
+ function addMenu(element) {
77
+ const content = element.querySelector(SELECTOR_MENU_CONTENT);
78
+ const toggle = element.querySelector(SELECTOR_MENU_TOGGLE);
79
+ if (content != null && toggle != null) addInstance(menus, OuiMenu, element, content, {
80
+ selector: SELECTOR_MENU_ITEM,
81
+ vertical: true
82
+ });
83
+ }
84
+ function addMenubar(element) {
85
+ addInstance(menubars, OuiMenubar, element, element, {
86
+ role: "menubar",
87
+ selector: SELECTOR_MENUBAR_ITEM,
88
+ vertical: false
89
+ });
90
+ }
91
+ function getId(element, value) {
92
+ let { id } = element;
93
+ if (id == null || id.trim().length === 0) {
94
+ id = value == null ? `oui_menu_${++index}` : `${value}_toggle`;
95
+ element.id = id;
96
+ }
97
+ return id;
98
+ }
99
+ function initializeMenu(menu) {
100
+ const id = getId(menu.content);
101
+ setAttribute(menu.toggle, "popovertarget", id);
102
+ setAria(menu.toggle, {
103
+ controls: id,
104
+ expanded: "false",
105
+ haspopup: "menu"
106
+ });
107
+ setAttribute(menu.content, "tabindex", "-1");
108
+ setRole(menu.content, "menu");
109
+ }
110
+ function onDeactivate(_, navigable) {
111
+ const menu = menus.get(navigable.element);
112
+ if (menu == null) return;
113
+ menu.floatable.hide();
114
+ const element = findAncestor(menu.element.parentElement, SELECTORS);
115
+ if (element == null) return;
116
+ const instance = menubars.get(element) ?? menus.get(element);
117
+ if (instance != null) updateNavigableFocus(instance.navigable, true);
118
+ }
119
+ function onPreventNavigation(_, navigable) {
120
+ return findAncestor((menubars.get(navigable.element) ?? menus.get(navigable.element))?.element.parentElement, SELECTORS) != null;
121
+ }
122
+ function onShouldActivate(event, navigable) {
123
+ let activate = false;
124
+ if (menubars.has(navigable.element)) activate = navigable.orientation === "horizontal" ? NAVIGABLE_KEYS_VERTICAL.has(event.key) : NAVIGABLE_KEYS_HORIZONTAL.has(event.key);
125
+ else if (menus.has(navigable.element)) activate = navigable.orientation === "horizontal" ? NAVIGABLE_KEYS_VERTICAL.has(event.key) : event.key === "ArrowRight";
126
+ if (activate) {
127
+ const target = event.target instanceof HTMLElement && event.target.matches(SELECTOR_MENU_TOGGLE) ? event.target : void 0;
128
+ if (target == null) activate = false;
129
+ else target.click();
130
+ }
131
+ return activate;
132
+ }
133
+ function onShouldDeactivate(event, navigable) {
134
+ if (menubars.has(navigable.element)) return;
135
+ const menu = menus.get(navigable.element);
136
+ if (menu == null) return;
137
+ const horizontal = navigable.orientation === "horizontal";
138
+ const altKey = horizontal ? "ArrowDown" : "ArrowRight";
139
+ const baseKey = horizontal ? "ArrowUp" : "ArrowLeft";
140
+ if (event.key === baseKey) return findAncestor(menu.element.parentElement, SELECTOR_MENU_CONTENT) != null;
141
+ if (event.key === altKey && event.target instanceof HTMLElement && !event.target.hasAttribute("popovertarget")) return false;
142
+ }
143
+ function removeInstance(instances, element) {
144
+ instances.get(element)?.destroy();
145
+ instances.delete(element);
146
+ }
147
+ function removeMenu(element) {
148
+ removeInstance(menus, element);
149
+ }
150
+ function removeMenubar(element) {
151
+ removeInstance(menubars, element);
152
+ }
153
+ const ATTRIBUTE_MENU = "oui-menu";
154
+ const ATTRIBUTE_MENU_POSITION = "oui-menu-position";
155
+ const ATTRIBUTE_MENUBAR = "oui-menubar";
156
+ const SELECTOR_MENUBAR = `[${ATTRIBUTE_MENUBAR}]`;
157
+ const SELECTOR_MENUBAR_ITEM = `:scope > [${ATTRIBUTE_MENUBAR}-item], :scope > * > [${ATTRIBUTE_MENUBAR}-item]`;
158
+ const SELECTOR_MENU_CONTENT = `[${ATTRIBUTE_MENU}-content]`;
159
+ const SELECTOR_MENU_ITEM = `:scope > [${ATTRIBUTE_MENU}-item], :scope > * > [${ATTRIBUTE_MENU}-item]`;
160
+ const SELECTOR_MENU_TOGGLE = `[${ATTRIBUTE_MENU}-toggle]`;
161
+ const SELECTORS = `${SELECTOR_MENUBAR}, ${SELECTOR_MENU_CONTENT}`;
162
+ const menubars = /* @__PURE__ */ new WeakMap();
163
+ const menus = /* @__PURE__ */ new WeakMap();
164
+ let index = 0;
165
+ attributable(ATTRIBUTE_MENU, addMenu, removeMenu);
166
+ attributable(ATTRIBUTE_MENUBAR, addMenubar, removeMenubar);
167
+ //#endregion
168
+ export {};
@@ -1,2 +1,2 @@
1
- import { g as createMovable, h as OuiMovable, m as ATTRIBUTE_MOVABLE_HANDLE, p as ATTRIBUTE_MOVABLE } from "../draggable-zszaW1qS.mjs";
1
+ import { g as createMovable, h as OuiMovable, m as ATTRIBUTE_MOVABLE_HANDLE, p as ATTRIBUTE_MOVABLE } from "../draggable-fIYXd8eO.mjs";
2
2
  export { ATTRIBUTE_MOVABLE, ATTRIBUTE_MOVABLE_HANDLE, OuiMovable, createMovable };
@@ -1,16 +1,15 @@
1
1
  import { attributable } from "../internal/attributable.mjs";
2
2
  import { OuiDraggable, addDraggable, getDraggableStates, removeDraggable } from "../internal/draggable.mjs";
3
3
  import { getPosition, on } from "@oscarpalmer/toretto/event";
4
+ import { setAttribute } from "@oscarpalmer/toretto/attribute";
4
5
  import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
6
+ import { getStyles, setStyle, setStyles } from "@oscarpalmer/toretto/style";
5
7
  //#region src/js/movable/movable.embedded.ts
6
8
  var OuiMovable = class extends OuiDraggable {
7
9
  #element;
8
10
  #style;
9
11
  constructor(element, options) {
10
- const style = {
11
- inset: element.style.inset,
12
- position: element.style.position
13
- };
12
+ const style = getStyles(element, ["inset", "position"]);
14
13
  super("movable", "move", ATTRIBUTE_MOVABLE, element, {
15
14
  container: {
16
15
  attribute: ATTRIBUTE_CONTAINER,
@@ -52,8 +51,7 @@ var OuiMovable = class extends OuiDraggable {
52
51
  */
53
52
  destroy() {
54
53
  MOVED.delete(this);
55
- this.#element.style.inset = this.#style.inset;
56
- this.#element.style.position = this.#style.position;
54
+ setStyles(this.#element, this.#style);
57
55
  this.#element = void 0;
58
56
  this.#style = void 0;
59
57
  super.destroy();
@@ -98,11 +96,8 @@ function onCancel(globals, item) {
98
96
  x: 0,
99
97
  y: 0
100
98
  };
101
- if (moved) element.style.inset = `${y}px auto auto ${x}px`;
102
- else {
103
- element.style.position = style.position;
104
- element.style.inset = style.inset;
105
- }
99
+ if (moved) setStyle(element, "inset", `${y}px auto auto ${x}px`);
100
+ else setStyles(element, style);
106
101
  element.removeAttribute(ATTRIBUTE_MOVING);
107
102
  }
108
103
  function onEnd(event, globals, item, reset) {
@@ -129,7 +124,7 @@ function onEnd(event, globals, item, reset) {
129
124
  });
130
125
  }
131
126
  function onMove(_, globals, __, position) {
132
- globals.element?.node.setAttribute(ATTRIBUTE_MOVING, "");
127
+ setAttribute(globals.element?.node, ATTRIBUTE_MOVING, "");
133
128
  return {
134
129
  from: { ...globals.original },
135
130
  to: { ...position.calculated }
@@ -153,7 +148,7 @@ function reposition(movable) {
153
148
  const container = state.container.getBoundingClientRect();
154
149
  const x = container.left + (state.offset?.x ?? 0);
155
150
  const y = container.top + (state.offset?.y ?? 0);
156
- state.element.style.inset = `${y}px auto auto ${x}px`;
151
+ setStyle(state.element, "inset", `${y}px auto auto ${x}px`);
157
152
  }
158
153
  function setOffset(state, container) {
159
154
  state.offset = {};
@@ -1,2 +1,2 @@
1
- import { g as createMovable, h as OuiMovable, t as CreateOuiDraggableOptions } from "../draggable-zszaW1qS.mjs";
1
+ import { g as createMovable, h as OuiMovable, t as CreateOuiDraggableOptions } from "../draggable-fIYXd8eO.mjs";
2
2
  export { type CreateOuiDraggableOptions as CreateOuiMovableOptions, type OuiMovable, createMovable };
@@ -1,4 +1,4 @@
1
- import { i as OuiFloatable } from "./floatable.embedded-YxGwzgbE.mjs";
1
+ import { r as OuiFloatable } from "./floatable.embedded-DUR8bQBK.mjs";
2
2
  import { i as OuiFocusTrap } from "./focus-trap.embedded-DR8NpZfr.mjs";
3
3
  import { RemovableEventListener } from "@oscarpalmer/toretto/models";
4
4
 
@@ -1,7 +1,9 @@
1
1
  import { createEmbeddedFloatable, getOnBeforeToggleListener } from "./floatable/floatable.embedded.mjs";
2
2
  import { attributable } from "./internal/attributable.mjs";
3
3
  import { createFocusTrap } from "./focus-trap/focus-trap.embedded.mjs";
4
+ import { getAria, setAria } from "@oscarpalmer/toretto/aria";
4
5
  import { on } from "@oscarpalmer/toretto/event";
6
+ import { setAttribute } from "@oscarpalmer/toretto/attribute";
5
7
  import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
6
8
  //#region src/js/popover.ts
7
9
  var OuiPopover = class {
@@ -18,6 +20,7 @@ var OuiPopover = class {
18
20
  }
19
21
  constructor(state) {
20
22
  this.#state = state;
23
+ initialize(state);
21
24
  this.#state.floatable.update();
22
25
  }
23
26
  /**
@@ -49,6 +52,14 @@ function destroyPopover(state) {
49
52
  state.listeners = void 0;
50
53
  state.popover = void 0;
51
54
  }
55
+ function getId(element, value) {
56
+ let { id } = element;
57
+ if (id == null || id.trim().length === 0) {
58
+ id = value == null ? `oui_popover_${++index}` : `${value}_toggle`;
59
+ element.id = id;
60
+ }
61
+ return id;
62
+ }
52
63
  /**
53
64
  * Get the _OuiPopover_ for an element
54
65
  *
@@ -63,23 +74,30 @@ function getState(anchor, content) {
63
74
  anchor,
64
75
  content,
65
76
  floatable: createEmbeddedFloatable(anchor, content, options),
66
- focusTrap: content.getAttribute(ARIA_MODAL) === TRUE ? createFocusTrap(content, { noescape: true }) : void 0,
67
- listeners: [getOnBeforeToggleListener(content), on(content, EVENT_TOGGLE, (event) => {
68
- if (event.newState === STATE_OPEN) {
77
+ focusTrap: getAria(content, "modal") === "true" ? createFocusTrap(content, { noescape: true }) : void 0,
78
+ listeners: [getOnBeforeToggleListener(content), on(content, "toggle", (event) => {
79
+ const expanded = event.newState === "open";
80
+ if (expanded) {
69
81
  ignoreFocus = false;
70
82
  state.floatable?.update();
71
- content.setAttribute(ATTRIBUTE_OPEN, "");
72
83
  content.focus();
73
- } else {
74
- content.removeAttribute(ATTRIBUTE_OPEN);
75
- if (!ignoreFocus) anchor?.focus();
76
- }
84
+ } else if (!ignoreFocus) anchor?.focus();
85
+ setAria(anchor, "expanded", expanded);
86
+ setAttribute(content, ATTRIBUTE_OPEN, expanded ? "" : void 0);
77
87
  })],
78
88
  popover: void 0
79
89
  };
80
90
  state.popover = new OuiPopover(state);
81
91
  return state;
82
92
  }
93
+ function initialize(state) {
94
+ const id = getId(state.content);
95
+ setAria(state.anchor, {
96
+ controls: id,
97
+ expanded: "false"
98
+ });
99
+ if ((getAria(state.content, "label") ?? getAria(state.content, "labelledby")) == null) setAria(state.content, "labelledby", getId(state.anchor, id));
100
+ }
83
101
  function onPointerdown() {
84
102
  ignoreFocus = true;
85
103
  }
@@ -90,11 +108,7 @@ function removePopover(element) {
90
108
  states.delete(element);
91
109
  }
92
110
  const ATTRIBUTE = "oui-popover";
93
- const ARIA_MODAL = "aria-modal";
94
111
  const ATTRIBUTE_OPEN = `${ATTRIBUTE}-open`;
95
- const EVENT_TOGGLE = "toggle";
96
- const STATE_OPEN = "open";
97
- const TRUE = "true";
98
112
  const options = {
99
113
  attribute: `${ATTRIBUTE}position`,
100
114
  position: "below-start",
@@ -102,6 +116,7 @@ const options = {
102
116
  };
103
117
  const states = /* @__PURE__ */ new WeakMap();
104
118
  let ignoreFocus = false;
119
+ let index = 0;
105
120
  on(document, "pointerdown", onPointerdown, { capture: true });
106
121
  attributable(ATTRIBUTE, addPopover, removePopover);
107
122
  //#endregion
@@ -1,10 +1,11 @@
1
1
  import { attributable } from "../internal/attributable.mjs";
2
2
  import { getPosition, on } from "@oscarpalmer/toretto/event";
3
3
  import { isPlainObject } from "@oscarpalmer/atoms/is";
4
+ import { getAttribute, setAttribute } from "@oscarpalmer/toretto/attribute";
4
5
  import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
6
+ import { setStyles, toggleStyles } from "@oscarpalmer/toretto/style";
5
7
  import { getNumber } from "@oscarpalmer/atoms/number";
6
8
  import { findAncestor } from "@oscarpalmer/toretto/find";
7
- import { toggleStyles } from "@oscarpalmer/toretto/style";
8
9
  import supportsTouch from "@oscarpalmer/toretto/touch";
9
10
  //#region src/js/resizable/resizable.embedded.ts
10
11
  var OuiResizable = class {
@@ -22,8 +23,10 @@ var OuiResizable = class {
22
23
  this.#state.height = height;
23
24
  }
24
25
  reset() {
25
- this.#state.element.style.height = "";
26
- this.#state.element.style.width = "";
26
+ setStyles(this.#state.element, {
27
+ height: "",
28
+ width: ""
29
+ });
27
30
  }
28
31
  };
29
32
  function addResizable(element, options) {
@@ -61,10 +64,10 @@ function getAndSetDimensions(element, options, input) {
61
64
  else if (options.minimumWidth > -1 && width < options.minimumWidth) width = options.minimumWidth;
62
65
  if (options.maximumHeight > -1 && height > options.maximumHeight) height = options.maximumHeight;
63
66
  else if (options.minimumHeight > -1 && height < options.minimumHeight) height = options.minimumHeight;
64
- if (element.checkVisibility()) {
65
- element.style.height = `${height}px`;
66
- element.style.width = `${width}px`;
67
- }
67
+ if (element.checkVisibility()) setStyles(element, {
68
+ height: `${height}px`,
69
+ width: `${width}px`
70
+ });
68
71
  return [width, height];
69
72
  }
70
73
  function getProperties(element, widthProperty, heightProperty) {
@@ -84,7 +87,7 @@ function getRestrictions(maximum, minimum) {
84
87
  };
85
88
  }
86
89
  function getState(element, handle, input) {
87
- element.setAttribute(RESIZABLE_ATTRIBUTE, "");
90
+ setAttribute(element, RESIZABLE_ATTRIBUTE, "");
88
91
  const options = getValidOptions(element, input);
89
92
  const [width, height] = getAndSetDimensions(element, options);
90
93
  return {
@@ -98,7 +101,7 @@ function getState(element, handle, input) {
98
101
  }
99
102
  function getValidOptions(element, input) {
100
103
  const original = isPlainObject(input) ? input : {};
101
- return { ...getRestrictions(input == null ? element.getAttribute(ATTRIBUTE_MAXIMUM) ?? getProperties(element, "maxWidth", "maxHeight") : [original.maximumWidth, original.maximumHeight], input == null ? element.getAttribute(ATTRIBUTE_MINIMUM) ?? getProperties(element, "minWidth", "minHeight") : [original.minimumWidth, original.minimumHeight]) };
104
+ return { ...getRestrictions(input == null ? getAttribute(element, ATTRIBUTE_MAXIMUM) ?? getProperties(element, "maxWidth", "maxHeight") : [original.maximumWidth, original.maximumHeight], input == null ? getAttribute(element, ATTRIBUTE_MINIMUM) ?? getProperties(element, "minWidth", "minHeight") : [original.minimumWidth, original.minimumHeight]) };
102
105
  }
103
106
  function getXAndY(first, second) {
104
107
  const [x, y] = typeof first === "string" && second == null ? first.split(",") : [first, second];
@@ -110,8 +113,10 @@ function getXAndY(first, second) {
110
113
  }
111
114
  function onKeydown(event) {
112
115
  if (current == null || event.key !== "Escape") return;
113
- current.state.element.style.height = `${current.state.height}px`;
114
- current.state.element.style.width = `${current.state.width}px`;
116
+ setStyles(current.state.element, {
117
+ height: `${current.state.height}px`,
118
+ width: `${current.state.width}px`
119
+ });
115
120
  resetResizable();
116
121
  }
117
122
  function onPointerdown(event) {
@@ -1,2 +1,2 @@
1
- import { d as OuiSortable, f as createSortable } from "../draggable-zszaW1qS.mjs";
1
+ import { d as OuiSortable, f as createSortable } from "../draggable-fIYXd8eO.mjs";
2
2
  export { OuiSortable, createSortable };
@@ -1,7 +1,9 @@
1
1
  import { attributable } from "../internal/attributable.mjs";
2
2
  import { OuiDraggable, addDraggable, getDraggableStates, removeDraggable } from "../internal/draggable.mjs";
3
3
  import { getPosition } from "@oscarpalmer/toretto/event";
4
+ import { getAttribute, setAttribute, setAttributes } from "@oscarpalmer/toretto/attribute";
4
5
  import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
6
+ import { setStyle } from "@oscarpalmer/toretto/style";
5
7
  import { findAncestor, getElementFromPosition } from "@oscarpalmer/toretto/find";
6
8
  import { createElement } from "@oscarpalmer/toretto/create";
7
9
  //#region src/js/sortable/sortable.embedded.ts
@@ -26,7 +28,7 @@ var OuiSortable = class extends OuiDraggable {
26
28
  },
27
29
  getDragged: getDragPlaceholder,
28
30
  getOrigin: () => (getDraggableStates(element)?.sortable)?.origin
29
- }, { connections: element.getAttribute(ATTRIBUTE_CONNECTIONS) });
31
+ }, { connections: getAttribute(element, ATTRIBUTE_CONNECTIONS) });
30
32
  }
31
33
  };
32
34
  function afterEnd(insert, from, events, elements, position, valid) {
@@ -72,15 +74,15 @@ function getOriginalPosition(_, __, position) {
72
74
  }
73
75
  function getPositionPlaceholder(item) {
74
76
  placeholder.position ??= createElement("div");
75
- placeholder.position.setAttribute(ATTRIBUTE_PLACEHOLDER_POSITION, "");
76
- if (item.state.origin != null) placeholder.position.style.setProperty("--placeholder-height", `${item.state.origin.getBoundingClientRect().height}px`);
77
+ setAttribute(placeholder.position, ATTRIBUTE_PLACEHOLDER_POSITION, "");
78
+ if (item.state.origin != null) setStyle(placeholder.position, "--placeholder-height", `${item.state.origin.getBoundingClientRect().height}px`);
77
79
  return placeholder.position;
78
80
  }
79
81
  function onBegin(_, globals, item, element) {
80
82
  item.state.origin = element;
81
83
  setPlaceholder(globals, item, element);
82
- element.setAttribute(ATTRIBUTE_ORIGIN, "");
83
- document.body.setAttribute(ATTRIBUTE_ACTIVE, "");
84
+ setAttribute(element, ATTRIBUTE_ORIGIN, "");
85
+ setAttribute(document.body, ATTRIBUTE_ACTIVE, "");
84
86
  }
85
87
  function onCancel(_, item) {
86
88
  item.state.origin?.removeAttribute(ATTRIBUTE_ORIGIN);
@@ -96,7 +98,7 @@ function onEnd(event, globals, item, reset) {
96
98
  };
97
99
  const target = getElementFromPosition(position)[0];
98
100
  let element = findAncestor(target, SELECTOR_ITEM);
99
- if (element?.hasAttribute(ATTRIBUTE_PLACEHOLDER_POSITION)) if (element.getAttribute(ATTRIBUTE_PLACEHOLDER_POSITION) === "after") element = element.previousElementSibling;
101
+ if (element?.hasAttribute(ATTRIBUTE_PLACEHOLDER_POSITION)) if (getAttribute(element, ATTRIBUTE_PLACEHOLDER_POSITION) === "after") element = element.previousElementSibling;
100
102
  else element = element.nextElementSibling;
101
103
  let insert = "insert";
102
104
  let toInstance;
@@ -168,7 +170,7 @@ function onMove(event, globals, item, position) {
168
170
  place = "after";
169
171
  toElement.insertAdjacentElement(INSERT_AFTER, placeholder);
170
172
  }
171
- placeholder.setAttribute(ATTRIBUTE_PLACEHOLDER_POSITION, place);
173
+ setAttribute(placeholder, ATTRIBUTE_PLACEHOLDER_POSITION, place);
172
174
  } else placeholder.remove();
173
175
  return {
174
176
  from: {
@@ -216,14 +218,14 @@ function setPlaceholder(state, item, origin) {
216
218
  });
217
219
  }
218
220
  function updatePlaceholder(item, element) {
219
- element.style.position = "fixed";
220
- element.setAttribute(ATTRIBUTE_PLACEHOLDER_DRAG, "");
221
+ setAttribute(element, ATTRIBUTE_PLACEHOLDER_DRAG, "");
222
+ setStyle(element, "position", "fixed");
221
223
  const state = getDraggableStates(item.state.element)?.sortable;
222
224
  if (state == null) return;
223
- if (state.horizontal) element.setAttribute(ATTRIBUTE_HORIZONTAL, "");
224
- else element.removeAttribute(ATTRIBUTE_HORIZONTAL);
225
- if (state.vertical) element.setAttribute(ATTRIBUTE_VERTICAL, "");
226
- else element.removeAttribute(ATTRIBUTE_VERTICAL);
225
+ setAttributes(element, {
226
+ [ATTRIBUTE_HORIZONTAL]: state.horizontal ? "" : void 0,
227
+ [ATTRIBUTE_VERTICAL]: state.vertical ? "" : void 0
228
+ });
227
229
  }
228
230
  function validatePosition(_, from, to, position) {
229
231
  let valid = true;
@@ -1,2 +1,2 @@
1
- import { d as OuiSortable, f as createSortable, t as CreateOuiDraggableOptions } from "../draggable-zszaW1qS.mjs";
1
+ import { d as OuiSortable, f as createSortable, t as CreateOuiDraggableOptions } from "../draggable-fIYXd8eO.mjs";
2
2
  export { type CreateOuiDraggableOptions as CreateOuiSortableOptions, type OuiSortable, createSortable };
@@ -1,8 +1,10 @@
1
+ import { setAria } from "@oscarpalmer/toretto/aria";
1
2
  import { getPosition, on } from "@oscarpalmer/toretto/event";
2
3
  import { isNullableOrWhitespace } from "@oscarpalmer/atoms/is";
4
+ import { getAttribute, setAttribute } from "@oscarpalmer/toretto/attribute";
5
+ import { setStyle, toggleStyles } from "@oscarpalmer/toretto/style";
3
6
  import { clamp } from "@oscarpalmer/atoms/number";
4
7
  import { findAncestor } from "@oscarpalmer/toretto/find";
5
- import { toggleStyles } from "@oscarpalmer/toretto/style";
6
8
  import supportsTouch from "@oscarpalmer/toretto/touch";
7
9
  import { round } from "@oscarpalmer/atoms/math";
8
10
  //#region src/js/splitter.ts
@@ -42,8 +44,7 @@ var OuiSplitter = class {
42
44
  this.types = getTypes(this);
43
45
  if (this.types.auto) RESIZE_OBSERVER.observe(this.element);
44
46
  else RESIZE_OBSERVER.unobserve(this.element);
45
- if (this.types.horizontal) this.element.setAttribute(ATTRIBUTE_HORIZONTAL, "");
46
- else this.element.removeAttribute(ATTRIBUTE_HORIZONTAL);
47
+ setAttribute(this.element, ATTRIBUTE_HORIZONTAL, this.types.horizontal ? "" : void 0);
47
48
  setAriaOrientation(this);
48
49
  }
49
50
  updateValues() {
@@ -72,7 +73,7 @@ var OuiSplitterElement = class extends HTMLElement {
72
73
  * Maximum size for the first panel
73
74
  */
74
75
  set max(value) {
75
- this.setAttribute(ATTRIBUTE_MAX, String(value));
76
+ if (typeof value === "number") setAttribute(this, ATTRIBUTE_MAX, value.toString());
76
77
  }
77
78
  /**
78
79
  * Minimum size for the first panel
@@ -84,7 +85,7 @@ var OuiSplitterElement = class extends HTMLElement {
84
85
  * Minimum size for the first panel
85
86
  */
86
87
  set min(value) {
87
- this.setAttribute(ATTRIBUTE_MIN, String(value));
88
+ if (typeof value === "number") setAttribute(this, ATTRIBUTE_MIN, value.toString());
88
89
  }
89
90
  /**
90
91
  * Current size for the first panel
@@ -96,23 +97,23 @@ var OuiSplitterElement = class extends HTMLElement {
96
97
  * Current size for the first panel
97
98
  */
98
99
  set size(value) {
99
- this.setAttribute(ATTRIBUTE_SIZE, String(value));
100
+ if (typeof value === "number") setAttribute(this, ATTRIBUTE_SIZE, value.toString());
100
101
  }
101
102
  /**
102
103
  * Orientation of the splitter
103
104
  */
104
105
  get type() {
105
- return this.getAttribute(ATTRIBUTE_TYPE) ?? "vertical";
106
+ return getAttribute(this, ATTRIBUTE_TYPE) ?? "vertical";
106
107
  }
107
108
  /**
108
109
  * Orientation of the splitter
109
110
  */
110
111
  set type(value) {
111
- this.setAttribute(ATTRIBUTE_TYPE, value);
112
+ setAttribute(this, ATTRIBUTE_TYPE, value);
112
113
  }
113
114
  constructor() {
114
115
  super();
115
- const panels = [...this.children].filter((child) => child instanceof HTMLElement);
116
+ const panels = [...this.children].filter((child) => child instanceof Element);
116
117
  if (panels.length !== 2) throw new Error(MESSAGE);
117
118
  this.#splitter = new OuiSplitter(this, panels);
118
119
  }
@@ -138,17 +139,19 @@ var OuiSplitterElement = class extends HTMLElement {
138
139
  };
139
140
  function createHandle() {
140
141
  const handle = document.createElement("span");
141
- handle.setAttribute("aria-hidden", "true");
142
- handle.setAttribute(ATTRIBUTE_HANDLE, "");
142
+ setAria(handle, "hidden", "true");
143
+ setAttribute(handle, ATTRIBUTE_HANDLE, "");
143
144
  return handle;
144
145
  }
145
146
  function createSeparator(splitter) {
146
147
  const separator = document.createElement("div");
147
148
  separator.role = "separator";
148
149
  separator.tabIndex = 0;
149
- separator.setAttribute("aria-controls", splitter.element.id);
150
- separator.setAttribute("aria-label", "Resize panels");
151
- separator.setAttribute(ATTRIBUTE_SEPARATOR, "");
150
+ setAria(separator, {
151
+ controls: splitter.element.id,
152
+ label: "Resize panels"
153
+ });
154
+ setAttribute(separator, ATTRIBUTE_SEPARATOR, "");
152
155
  return separator;
153
156
  }
154
157
  function getContained(min, value, max) {
@@ -160,7 +163,7 @@ function getSize(splitter, value) {
160
163
  return getContained(splitter.values.min, fraction, splitter.values.max);
161
164
  }
162
165
  function getTypes(splitter, width, height) {
163
- const type = splitter.element.getAttribute("type")?.trim() ?? "";
166
+ const type = getAttribute(splitter.element, "type");
164
167
  if (type === "horizontal") return {
165
168
  auto: false,
166
169
  horizontal: true
@@ -175,7 +178,7 @@ function getTypes(splitter, width, height) {
175
178
  };
176
179
  }
177
180
  function getValue(element, name, defaultValue) {
178
- const value = element.getAttribute(name);
181
+ const value = getAttribute(element, name);
179
182
  if (isNullableOrWhitespace(value)) return defaultValue;
180
183
  const parsed = Number.parseFloat(value);
181
184
  if (Number.isNaN(parsed)) return defaultValue;
@@ -235,8 +238,7 @@ function onObservation(entries) {
235
238
  const splitter = MAPPED_ELEMENTS.get(entry.target);
236
239
  if (splitter == null) return;
237
240
  splitter.types = getTypes(splitter, entry.contentRect.width, entry.contentRect.height);
238
- if (splitter.types.horizontal) splitter.element.setAttribute(ATTRIBUTE_HORIZONTAL, "");
239
- else splitter.element.removeAttribute(ATTRIBUTE_HORIZONTAL);
241
+ setAttribute(splitter.element, ATTRIBUTE_HORIZONTAL, splitter.types.horizontal ? "" : void 0);
240
242
  setAriaOrientation(splitter);
241
243
  }
242
244
  frame = void 0;
@@ -247,8 +249,8 @@ function onPointerdown(event) {
247
249
  splitter = MAPPED_ELEMENTS.get(findAncestor(event, SELECTOR_HANDLE));
248
250
  if (splitter == null) return;
249
251
  if (supportsTouch.value) event.preventDefault();
250
- splitter.handle.setAttribute(ATTRIBUTE_ACTIVE, "");
251
- splitter.separator.setAttribute(ATTRIBUTE_ACTIVE, "");
252
+ setAttribute(splitter.handle, ATTRIBUTE_ACTIVE, "");
253
+ setAttribute(splitter.separator, ATTRIBUTE_ACTIVE, "");
252
254
  splitter.rectangle = splitter.element.getBoundingClientRect();
253
255
  STYLING_TOGGLER.set();
254
256
  }
@@ -264,17 +266,19 @@ function onPointerup() {
264
266
  if (splitter != null) onEnd(false);
265
267
  }
266
268
  function setAriaOrientation(splitter) {
267
- splitter.separator.setAttribute("aria-orientation", splitter.types.horizontal ? "horizontal" : "vertical");
269
+ setAria(splitter.separator, "orientation", splitter.types.horizontal ? "horizontal" : "vertical");
268
270
  }
269
271
  function setAriaValue(splitter) {
270
- splitter.separator.setAttribute("aria-valuemax", String(splitter.values.max));
271
- splitter.separator.setAttribute("aria-valuemin", String(splitter.values.min));
272
- splitter.separator.setAttribute("aria-valuenow", String(splitter.values.now.current));
272
+ setAria(splitter.separator, {
273
+ valuemax: splitter.values.max,
274
+ valuemin: splitter.values.min,
275
+ valuenow: splitter.values.now.current
276
+ });
273
277
  }
274
278
  function setSize(splitter, size, previous) {
275
279
  splitter.values.now.current = size;
276
280
  if (previous) splitter.values.now.previous = size;
277
- splitter.element.style.setProperty("--oui-splitter-size", `${size}`);
281
+ setStyle(splitter.element, "--oui-splitter-size", `${size}`);
278
282
  setAriaValue(splitter);
279
283
  }
280
284
  const SELECTOR = "oui-splitter";