@oscarpalmer/oui 0.41.0 → 0.43.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/grid.css +38 -0
- package/dist/js/color-picker/color-picker.constants.d.mts +1 -1
- package/dist/js/color-picker/color-picker.constants.mjs +1 -2
- package/dist/js/color-picker/color-picker.dom.d.mts +2 -4
- package/dist/js/color-picker/color-picker.dom.mjs +1 -2
- package/dist/js/color-picker/color-picker.event.d.mts +2 -4
- package/dist/js/color-picker/color-picker.event.mjs +8 -9
- package/dist/js/color-picker/color-picker.form.d.mts +2 -4
- package/dist/js/color-picker/color-picker.form.mjs +2 -3
- package/dist/js/color-picker/color-picker.misc.d.mts +1 -1
- package/dist/js/color-picker/color-picker.misc.mjs +1 -2
- package/dist/js/color-picker/color-picker.model.d.mts +1 -1
- package/dist/js/color-picker/color-picker.model.mjs +1 -2
- package/dist/js/color-picker/color-picker.output.d.mts +2 -4
- package/dist/js/color-picker/color-picker.output.mjs +4 -5
- package/dist/js/color-picker/color-picker.state.d.mts +2 -4
- package/dist/js/color-picker/color-picker.state.mjs +4 -5
- package/dist/js/color-picker/index.d.mts +5 -7
- package/dist/js/color-picker/index.mjs +3 -4
- package/dist/js/{color-picker.constants-BZgXQr5o.d.mts → color-picker.constants-DdttC4ab.d.mts} +3 -8
- package/dist/js/{color-picker.misc-BIS3R6jk.d.mts → color-picker.misc-BH_tFyWR.d.mts} +1 -3
- package/dist/js/combobox/combobox.constants.d.mts +2 -2
- package/dist/js/combobox/combobox.constants.mjs +3 -3
- package/dist/js/combobox/combobox.dom.d.mts +3 -4
- package/dist/js/combobox/combobox.dom.mjs +3 -3
- package/dist/js/combobox/combobox.event.d.mts +3 -5
- package/dist/js/combobox/combobox.event.mjs +1 -2
- package/dist/js/combobox/combobox.misc.d.mts +1 -1
- package/dist/js/combobox/combobox.misc.mjs +1 -2
- package/dist/js/combobox/combobox.model.d.mts +1 -1
- package/dist/js/combobox/combobox.state.d.mts +3 -5
- package/dist/js/combobox/combobox.state.mjs +1 -2
- package/dist/js/combobox/index.d.mts +7 -9
- package/dist/js/combobox/index.mjs +3 -4
- package/dist/js/{combobox.constants-Hb3bqqQJ.d.mts → combobox.constants-CDnBNJC0.d.mts} +3 -4
- package/dist/js/{combobox.misc-DRDFk6X8.d.mts → combobox.misc-Csh9lm9_.d.mts} +1 -3
- package/dist/js/{combobox.model-gjEI2VqZ.d.mts → combobox.model-BRGQDuRl.d.mts} +2 -4
- package/dist/js/{combobox.state-AstCICiH.mjs → combobox.state-Bjt0dwe3.mjs} +29 -29
- package/dist/js/dialog/dialog.model.d.mts +1 -1
- package/dist/js/dialog/dialog.model.mjs +1 -2
- package/dist/js/dialog/index.d.mts +1 -3
- package/dist/js/dialog/index.mjs +2 -3
- package/dist/js/{dialog.model-HVzYWoDo.d.mts → dialog.model-cYq7rTKL.d.mts} +2 -4
- package/dist/js/floatable/floatable.embedded.d.mts +1 -1
- package/dist/js/floatable/floatable.embedded.mjs +1 -2
- package/dist/js/floatable/floatable.model.d.mts +1 -1
- package/dist/js/floatable/floatable.model.mjs +1 -2
- package/dist/js/floatable/floatable.standalone.d.mts +2 -2
- package/dist/js/floatable/floatable.standalone.mjs +1 -2
- package/dist/js/{floatable.embedded-ncshL3Sa.d.mts → floatable.embedded-Cr1KX6GZ.d.mts} +1 -3
- package/dist/js/{floatable.model-DXsQgoU7.d.mts → floatable.model-jS5Ui5Av.d.mts} +0 -2
- package/dist/js/focus-trap/focus-trap.embedded.d.mts +1 -1
- package/dist/js/focus-trap/focus-trap.embedded.mjs +4 -5
- package/dist/js/focus-trap/focus-trap.model.d.mts +2 -2
- package/dist/js/focus-trap/focus-trap.model.mjs +3 -3
- package/dist/js/focus-trap/focus-trap.standalone.d.mts +2 -2
- package/dist/js/focus-trap/focus-trap.standalone.mjs +1 -2
- package/dist/js/{focus-trap.embedded-DpcPkP7c.d.mts → focus-trap.embedded-BVXcd4OO.d.mts} +1 -3
- package/dist/js/{focus-trap.model-CpltX5B5.d.mts → focus-trap.model-wg0iAZ7x.d.mts} +2 -3
- package/dist/js/grid/grid.dom.d.mts +7 -0
- package/dist/js/grid/grid.dom.mjs +171 -0
- package/dist/js/grid/grid.event.d.mts +7 -0
- package/dist/js/grid/grid.event.mjs +1 -0
- package/dist/js/grid/grid.misc.d.mts +6 -0
- package/dist/js/grid/grid.misc.mjs +1 -0
- package/dist/js/grid/grid.model.d.mts +2 -0
- package/dist/js/grid/grid.model.mjs +39 -0
- package/dist/js/grid/index.d.mts +22 -0
- package/dist/js/grid/index.mjs +48 -0
- package/dist/js/grid.event-K_pG2vmS.mjs +192 -0
- package/dist/js/grid.model-SiNst5db.d.mts +90 -0
- package/dist/js/index.d.mts +22 -21
- package/dist/js/index.mjs +5 -3
- package/dist/js/internal/attributable.d.mts +1 -3
- package/dist/js/internal/attributable.mjs +3 -3
- package/dist/js/internal/draggable/draggable.model.d.mts +2 -2
- package/dist/js/internal/draggable/draggable.model.mjs +3 -3
- package/dist/js/internal/draggable/index.d.mts +2 -4
- package/dist/js/internal/draggable/index.mjs +18 -14
- package/dist/js/internal/l10n/index.d.mts +2 -4
- package/dist/js/internal/l10n/index.mjs +30 -22
- package/dist/js/internal/l10n/l10n.model.d.mts +1 -1
- package/dist/js/internal/l10n/l10n.model.mjs +1 -2
- package/dist/js/internal/misc.d.mts +2 -3
- package/dist/js/internal/misc.mjs +5 -3
- package/dist/js/internal/navigable/index.d.mts +2 -4
- package/dist/js/internal/navigable/index.mjs +1 -2
- package/dist/js/internal/navigable/navigable.model.d.mts +1 -1
- package/dist/js/internal/navigable/navigable.model.mjs +1 -2
- package/dist/js/internal/option-list/option-list.constants.d.mts +3 -5
- package/dist/js/internal/option-list/option-list.constants.mjs +3 -4
- package/dist/js/internal/option-list/option-list.data.d.mts +3 -4
- package/dist/js/internal/option-list/option-list.data.mjs +1 -2
- package/dist/js/internal/option-list/option-list.dom.d.mts +3 -5
- package/dist/js/internal/option-list/option-list.dom.mjs +1 -2
- package/dist/js/internal/option-list/option-list.event.d.mts +3 -5
- package/dist/js/internal/option-list/option-list.event.mjs +4 -5
- package/dist/js/internal/option-list/option-list.form.d.mts +3 -5
- package/dist/js/internal/option-list/option-list.form.mjs +2 -3
- package/dist/js/internal/option-list/option-list.misc.d.mts +3 -5
- package/dist/js/internal/option-list/option-list.misc.mjs +1 -2
- package/dist/js/internal/option-list/option-list.model.d.mts +2 -2
- package/dist/js/internal/option-list/option-list.model.mjs +7 -1
- package/dist/js/internal/option-list/option-list.state.d.mts +3 -5
- package/dist/js/internal/option-list/option-list.state.mjs +2 -3
- package/dist/js/l10n/index.d.mts +1 -1
- package/dist/js/l10n/index.mjs +1 -2
- package/dist/js/{l10n.model-D1E1u35L.d.mts → l10n.model-DxwLXnFl.d.mts} +0 -2
- package/dist/js/listbox/index.d.mts +6 -8
- package/dist/js/listbox/index.mjs +3 -4
- package/dist/js/listbox/listbox.constants.d.mts +1 -1
- package/dist/js/listbox/listbox.constants.mjs +1 -2
- package/dist/js/listbox/listbox.dom.d.mts +2 -4
- package/dist/js/listbox/listbox.dom.mjs +1 -2
- package/dist/js/listbox/listbox.event.d.mts +3 -5
- package/dist/js/listbox/listbox.event.mjs +1 -2
- package/dist/js/listbox/listbox.misc.d.mts +1 -1
- package/dist/js/listbox/listbox.misc.mjs +1 -2
- package/dist/js/listbox/listbox.model.d.mts +1 -1
- package/dist/js/listbox/listbox.state.d.mts +3 -5
- package/dist/js/listbox/listbox.state.mjs +1 -2
- package/dist/js/{listbox.constants-DOBMwKup.d.mts → listbox.constants-1yMPRl2C.d.mts} +1 -3
- package/dist/js/{listbox.misc-DwfB4Mu_.d.mts → listbox.misc-CkW28nUS.d.mts} +1 -3
- package/dist/js/{listbox.model-C0MYWXZe.d.mts → listbox.model-CUA_DaR9.d.mts} +1 -3
- package/dist/js/{listbox.state-BrN296BM.mjs → listbox.state-DO58GDqc.mjs} +8 -12
- package/dist/js/menu/index.mjs +5 -6
- package/dist/js/menu/menu.model.d.mts +3 -5
- package/dist/js/menu/menu.model.mjs +1 -2
- package/dist/js/movable/movable.embedded.d.mts +1 -1
- package/dist/js/movable/movable.embedded.mjs +3 -4
- package/dist/js/movable/movable.model.d.mts +2 -2
- package/dist/js/movable/movable.model.mjs +3 -3
- package/dist/js/movable/movable.standalone.d.mts +2 -2
- package/dist/js/movable/movable.standalone.mjs +1 -2
- package/dist/js/{movable.embedded-C1bDTLGs.d.mts → movable.embedded-HjPPob-Z.d.mts} +1 -3
- package/dist/js/{movable.model-D9nnPWKk.d.mts → movable.model-CQ3AbTrq.d.mts} +13 -7
- package/dist/js/{navigable.model-BqoR6iBv.d.mts → navigable.model-CrzJqKE7.d.mts} +0 -2
- package/dist/js/{option-list.data-CgMyUwPc.mjs → option-list.data-Be6wopy9.mjs} +7 -10
- package/dist/js/{option-list.model-CCPUlPeX.d.mts → option-list.model-DNZq-X0d.d.mts} +7 -4
- package/dist/js/popover/index.d.mts +1 -3
- package/dist/js/popover/index.mjs +3 -4
- package/dist/js/popover/popover.model.d.mts +1 -1
- package/dist/js/popover/popover.model.mjs +1 -2
- package/dist/js/{popover.model-DiLdz0Hc.d.mts → popover.model-CrrIdSmS.d.mts} +2 -4
- package/dist/js/resizable/resizable.embedded.d.mts +2 -2
- package/dist/js/resizable/resizable.embedded.mjs +122 -38
- package/dist/js/resizable/resizable.model.d.mts +2 -2
- package/dist/js/resizable/resizable.model.mjs +11 -3
- package/dist/js/resizable/resizable.standalone.d.mts +3 -3
- package/dist/js/resizable/resizable.standalone.mjs +2 -1
- package/dist/js/{resizable.embedded-BemH-7Re.d.mts → resizable.embedded-DQclAEP-.d.mts} +3 -4
- package/dist/js/resizable.model-BOufXDXx.d.mts +67 -0
- package/dist/js/sortable/sortable.embedded.d.mts +1 -1
- package/dist/js/sortable/sortable.embedded.mjs +5 -6
- package/dist/js/sortable/sortable.model.d.mts +2 -2
- package/dist/js/sortable/sortable.model.mjs +4 -3
- package/dist/js/sortable/sortable.standalone.d.mts +2 -2
- package/dist/js/sortable/sortable.standalone.mjs +1 -2
- package/dist/js/{sortable.embedded-CrEGff9k.d.mts → sortable.embedded-B5LPz-c_.d.mts} +1 -3
- package/dist/js/splitter/index.d.mts +2 -4
- package/dist/js/splitter/index.mjs +5 -5
- package/dist/js/splitter/splitter.model.d.mts +1 -1
- package/dist/js/splitter/splitter.model.mjs +1 -2
- package/dist/js/{splitter.model-C24W6eZ7.d.mts → splitter.model-DQDbIe4P.d.mts} +0 -2
- package/dist/js/tabs/index.d.mts +2 -4
- package/dist/js/tabs/index.mjs +10 -11
- package/dist/js/tabs/tabs.model.d.mts +1 -1
- package/dist/js/tabs/tabs.model.mjs +1 -2
- package/dist/js/{tabs.model-BHPy7fPo.d.mts → tabs.model-CvylbR2o.d.mts} +1 -3
- package/dist/js/toolbar/index.mjs +1 -2
- package/dist/js/toolbar/toolbar.model.d.mts +2 -4
- package/dist/js/toolbar/toolbar.model.mjs +1 -2
- package/dist/js/tooltip/index.d.mts +1 -3
- package/dist/js/tooltip/index.mjs +2 -3
- package/dist/js/tooltip/tooltip.model.d.mts +1 -1
- package/dist/js/tooltip/tooltip.model.mjs +1 -2
- package/dist/js/{tooltip.model-BpNStw5z.d.mts → tooltip.model-BI3UK-VU.d.mts} +1 -3
- package/package.json +11 -8
- package/dist/js/resizable.model-YEtcC9li.d.mts +0 -46
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { createResizable } from "../resizable/resizable.embedded.mjs";
|
|
2
|
+
import { RESIZABLE_ATTRIBUTE_HANDLE } from "../resizable/resizable.model.mjs";
|
|
3
|
+
import { GRID_ATTRIBUTE_COLUMNS, GRID_ATTRIBUTE_ITEM, GRID_ATTRIBUTE_PLACEHOLDER, GRID_ATTRIBUTE_SPAN, GRID_SELECTOR_ITEM_SCOPED, OuiGridResizeHandlerEvent } from "./grid.model.mjs";
|
|
4
|
+
import { getAttribute, setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
5
|
+
import { dispatch } from "@oscarpalmer/toretto/event";
|
|
6
|
+
import { getStyle } from "@oscarpalmer/toretto/style";
|
|
7
|
+
import { getNumber } from "@oscarpalmer/atoms/number";
|
|
8
|
+
import { floor, max, min } from "@oscarpalmer/atoms/math";
|
|
9
|
+
import { createElement } from "@oscarpalmer/toretto/create";
|
|
10
|
+
import { select } from "@oscarpalmer/atoms/array/select";
|
|
11
|
+
// src/js/grid/grid.dom.ts
|
|
12
|
+
function collides(first, second) {
|
|
13
|
+
return first.x < second.x + second.width && second.x < first.x + first.width && first.y < second.y + second.height && second.y < first.y + first.height;
|
|
14
|
+
}
|
|
15
|
+
function createResizeHandle(state, item) {
|
|
16
|
+
const handle = createElement("div", {
|
|
17
|
+
aria: { label: "Resize grid item" },
|
|
18
|
+
attribute: { [RESIZABLE_ATTRIBUTE_HANDLE]: "" },
|
|
19
|
+
property: { textContent: "R" }
|
|
20
|
+
});
|
|
21
|
+
dispatch(state.host, new OuiGridResizeHandlerEvent({
|
|
22
|
+
handle,
|
|
23
|
+
item
|
|
24
|
+
}));
|
|
25
|
+
return handle;
|
|
26
|
+
}
|
|
27
|
+
function findFreeSpot(size, others, containerWidth) {
|
|
28
|
+
const candidate = {
|
|
29
|
+
height: size.height,
|
|
30
|
+
width: size.width,
|
|
31
|
+
x: 0,
|
|
32
|
+
y: 0
|
|
33
|
+
};
|
|
34
|
+
while (true) {
|
|
35
|
+
const blocker = others.find((other) => collides(candidate, other));
|
|
36
|
+
if (blocker == null) return candidate;
|
|
37
|
+
candidate.x = blocker.x + blocker.width;
|
|
38
|
+
if (candidate.x + candidate.width > containerWidth) {
|
|
39
|
+
candidate.x = 0;
|
|
40
|
+
candidate.y = min(select.reverse(others, (other) => other.y + other.height, (bottom) => bottom > candidate.y));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function getColumns(host, gap, attribute) {
|
|
45
|
+
const [first, second] = (attribute ?? getAttribute(host, "columns") ?? "").split(",");
|
|
46
|
+
const preferred = Number.parseInt(first ?? "", 10);
|
|
47
|
+
const minimum = Number.parseFloat(second ?? "");
|
|
48
|
+
const hasMinimum = minimum > 0;
|
|
49
|
+
const hasPreferred = preferred > 0;
|
|
50
|
+
if (!hasMinimum && !hasPreferred) return;
|
|
51
|
+
const { clientWidth } = host;
|
|
52
|
+
const count = max([1, min([hasPreferred ? preferred : Number.POSITIVE_INFINITY, hasMinimum ? floor((clientWidth + gap) / (minimum + gap)) : Number.POSITIVE_INFINITY])]);
|
|
53
|
+
return {
|
|
54
|
+
count,
|
|
55
|
+
attribute: [preferred, Number.isNaN(minimum) ? void 0 : minimum],
|
|
56
|
+
width: (clientWidth - gap * (count - 1)) / count
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function getGridElements(state) {
|
|
60
|
+
const previous = new Set(state.elements.splice(0));
|
|
61
|
+
const next = [...state.host.querySelectorAll(GRID_SELECTOR_ITEM_SCOPED)];
|
|
62
|
+
const { length } = next;
|
|
63
|
+
for (let index = 0; index < length; index++) {
|
|
64
|
+
const element = next[index];
|
|
65
|
+
if (previous.has(element)) previous.delete(element);
|
|
66
|
+
setAttribute(element, GRID_ATTRIBUTE_ITEM, "");
|
|
67
|
+
}
|
|
68
|
+
if (state.active != null) previous.delete(state.active);
|
|
69
|
+
for (const element of previous) setAttribute(element, GRID_ATTRIBUTE_ITEM);
|
|
70
|
+
return next;
|
|
71
|
+
}
|
|
72
|
+
function getGap(host, input) {
|
|
73
|
+
let attribute;
|
|
74
|
+
let style;
|
|
75
|
+
let value;
|
|
76
|
+
input ??= getAttribute(host, "gap");
|
|
77
|
+
if (input != null) {
|
|
78
|
+
attribute = getNumber(input);
|
|
79
|
+
if (Number.isNaN(attribute) || attribute < 0) attribute = void 0;
|
|
80
|
+
else value = attribute;
|
|
81
|
+
}
|
|
82
|
+
if (value == null) {
|
|
83
|
+
style = getStyle(host, "gap", true);
|
|
84
|
+
if (style != null) value = getNumber(style.endsWith("px") ? style.slice(0, -2) : style);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
attribute,
|
|
88
|
+
style,
|
|
89
|
+
value: value == null ? 0 : max([value, 0])
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function getGridColumns(state) {
|
|
93
|
+
return state.columns?.attribute;
|
|
94
|
+
}
|
|
95
|
+
function getGridPlaceholder(original) {
|
|
96
|
+
placeholder ??= createElement("div", {
|
|
97
|
+
attribute: { [GRID_ATTRIBUTE_PLACEHOLDER]: "" },
|
|
98
|
+
style: {
|
|
99
|
+
position: "absolute",
|
|
100
|
+
inset: "0"
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
if (original == null) return placeholder;
|
|
104
|
+
setAttribute(placeholder, GRID_ATTRIBUTE_SPAN, getAttribute(original, GRID_ATTRIBUTE_SPAN));
|
|
105
|
+
placeholder.style.width = `${original.offsetWidth}px`;
|
|
106
|
+
placeholder.style.height = `${original.offsetHeight}px`;
|
|
107
|
+
placeholder.style.transform = original.style.transform;
|
|
108
|
+
return placeholder;
|
|
109
|
+
}
|
|
110
|
+
function getSpan(element, count) {
|
|
111
|
+
const span = getNumber(getAttribute(element, GRID_ATTRIBUTE_SPAN));
|
|
112
|
+
return min([span > 0 ? span : 1, count]);
|
|
113
|
+
}
|
|
114
|
+
function setGridColumns(state, value) {
|
|
115
|
+
let columns;
|
|
116
|
+
if (typeof value === "number") columns = [value, void 0];
|
|
117
|
+
else if (Array.isArray(value)) {
|
|
118
|
+
const [preferred, minimum] = value;
|
|
119
|
+
if (typeof preferred === "number" && (minimum == null || typeof minimum === "number")) columns = [preferred, minimum];
|
|
120
|
+
}
|
|
121
|
+
setAttribute(state.host, GRID_ATTRIBUTE_COLUMNS, columns == null ? null : `${columns[0]},${columns[1]}`);
|
|
122
|
+
}
|
|
123
|
+
function updateGridPositions(state) {
|
|
124
|
+
const { elements: items } = state;
|
|
125
|
+
const { length } = items;
|
|
126
|
+
const bottoms = [0];
|
|
127
|
+
const width = state.host.clientWidth;
|
|
128
|
+
const gap = getGap(state.host);
|
|
129
|
+
const columns = getColumns(state.host, gap.value);
|
|
130
|
+
state.columns = columns;
|
|
131
|
+
state.gap = gap;
|
|
132
|
+
const placed = [];
|
|
133
|
+
for (let index = 0; index < length; index += 1) {
|
|
134
|
+
const item = items[index];
|
|
135
|
+
const spot = findFreeSpot({
|
|
136
|
+
height: item.offsetHeight + gap.value,
|
|
137
|
+
width: columns == null ? min([item.offsetWidth + gap.value, width + gap.value]) : getSpan(item, columns.count)
|
|
138
|
+
}, placed, columns?.count ?? width + gap.value);
|
|
139
|
+
bottoms.push(spot.y + spot.height);
|
|
140
|
+
placed.push(spot);
|
|
141
|
+
if (columns == null) item.style.transform = `translate3d(${spot.x}px, ${spot.y}px, 0)`;
|
|
142
|
+
else {
|
|
143
|
+
const step = columns.width + gap.value;
|
|
144
|
+
item.style.transform = `translate3d(${spot.x * step}px, ${spot.y}px, 0)`;
|
|
145
|
+
item.style.width = `${spot.width * step - gap.value}px`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const height = max([0, max(bottoms) - gap.value]);
|
|
149
|
+
if (height !== state.height) {
|
|
150
|
+
state.height = height;
|
|
151
|
+
state.host.style.height = `${height}px`;
|
|
152
|
+
}
|
|
153
|
+
dispatch(state.host, "update");
|
|
154
|
+
}
|
|
155
|
+
function updateGridResizables(state) {
|
|
156
|
+
if (!state.host.hasAttribute("resizable")) return;
|
|
157
|
+
const { length } = state.elements;
|
|
158
|
+
for (let index = 0; index < length; index += 1) {
|
|
159
|
+
const element = state.elements[index];
|
|
160
|
+
if (element.hasAttribute("oui-grid-placeholder")) continue;
|
|
161
|
+
if (element.querySelector(":scope > [oui-resizable-handle]") == null) element.append(createResizeHandle(state, element));
|
|
162
|
+
createResizable(element, {
|
|
163
|
+
onBegin: state.callbacks.onResizeBegin,
|
|
164
|
+
onCancel: state.callbacks.onResizeUpdate,
|
|
165
|
+
onEnd: state.callbacks.onResizeUpdate,
|
|
166
|
+
onResize: state.callbacks.onResizeUpdate
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
let placeholder;
|
|
171
|
+
export { getGridColumns, getGridElements, getGridPlaceholder, setGridColumns, updateGridPositions, updateGridResizables };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { a as OuiResizableEventDetail } from "../resizable.model-BOufXDXx.mjs";
|
|
2
|
+
import { k as GridState } from "../grid.model-SiNst5db.mjs";
|
|
3
|
+
export declare function onBeginResizeGridItem(state: GridState, element: Element, size: OuiResizableEventDetail): void;
|
|
4
|
+
export declare function onGridAttributeChanged(state: GridState, name: string): void;
|
|
5
|
+
export declare function onGridItemResized(type: string, state: GridState, element: Element, size: OuiResizableEventDetail): void;
|
|
6
|
+
export declare function onGridMutation(state: GridState): void;
|
|
7
|
+
export declare function onGridResized(entries: ResizeObserverEntry[]): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as onBeginResizeGridItem, n as onGridAttributeChanged, r as onGridItemResized, i as onGridMutation, a as onGridResized } from "../grid.event-K_pG2vmS.mjs";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { O as GridSort, k as GridState } from "../grid.model-SiNst5db.mjs";
|
|
2
|
+
export declare function connectGrid(state: GridState): void;
|
|
3
|
+
export declare function createGridState(host: HTMLElement): GridState;
|
|
4
|
+
export declare function disconnectGrid(state: GridState): void;
|
|
5
|
+
export declare function endGridSort(sort: GridSort, target?: HTMLElement): undefined;
|
|
6
|
+
export declare function updateGrid(state: GridState): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { o as connectGrid, s as createGridState, c as disconnectGrid, l as endGridSort, u as updateGrid } from "../grid.event-K_pG2vmS.mjs";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as OuiGridEventSortDetail, C as GRID_SYMBOL, D as GridItem, E as GridGap, F as OuiGridSortEvent, I as gridStyling, M as OuiGridResizeEventDetail, N as OuiGridResizeHandlerEvent, O as GridSort, P as OuiGridResizeHandlerEventDetail, S as GRID_SELECTOR_ITEM_SCOPED, T as GridColumns, _ as GRID_EVENT_SORT_CANCEL, a as GRID_ATTRIBUTE_ITEM_HANDLE, b as GRID_SELECTOR_HANDLE, c as GRID_ATTRIBUTE_SORTABLE, d as GRID_EVENT_RESIZE_BEGIN, f as GRID_EVENT_RESIZE_CANCEL, g as GRID_EVENT_SORT_BEGIN, h as GRID_EVENT_RESIZE_HANDLE, i as GRID_ATTRIBUTE_ITEM_ACTIVE, j as OuiGridResizeEvent, k as GridState, l as GRID_ATTRIBUTE_SORTING, m as GRID_EVENT_RESIZE_END, n as GRID_ATTRIBUTE_GAP, o as GRID_ATTRIBUTE_PLACEHOLDER, p as GRID_EVENT_RESIZE_CHANGE, r as GRID_ATTRIBUTE_ITEM, s as GRID_ATTRIBUTE_RESIZABLE, t as GRID_ATTRIBUTE_COLUMNS, u as GRID_ATTRIBUTE_SPAN, v as GRID_EVENT_SORT_CHANGE, w as GRID_TAGNAME, x as GRID_SELECTOR_ITEM, y as GRID_EVENT_SORT_END } from "../grid.model-SiNst5db.mjs";
|
|
2
|
+
export { GRID_ATTRIBUTE_COLUMNS, GRID_ATTRIBUTE_GAP, GRID_ATTRIBUTE_ITEM, GRID_ATTRIBUTE_ITEM_ACTIVE, GRID_ATTRIBUTE_ITEM_HANDLE, GRID_ATTRIBUTE_PLACEHOLDER, GRID_ATTRIBUTE_RESIZABLE, GRID_ATTRIBUTE_SORTABLE, GRID_ATTRIBUTE_SORTING, GRID_ATTRIBUTE_SPAN, GRID_EVENT_RESIZE_BEGIN, GRID_EVENT_RESIZE_CANCEL, GRID_EVENT_RESIZE_CHANGE, GRID_EVENT_RESIZE_END, GRID_EVENT_RESIZE_HANDLE, GRID_EVENT_SORT_BEGIN, GRID_EVENT_SORT_CANCEL, GRID_EVENT_SORT_CHANGE, GRID_EVENT_SORT_END, GRID_SELECTOR_HANDLE, GRID_SELECTOR_ITEM, GRID_SELECTOR_ITEM_SCOPED, GRID_SYMBOL, GRID_TAGNAME, GridColumns, GridGap, GridItem, GridSort, GridState, OuiGridEventSortDetail, OuiGridResizeEvent, OuiGridResizeEventDetail, OuiGridResizeHandlerEvent, OuiGridResizeHandlerEventDetail, OuiGridSortEvent, gridStyling };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { toggleStyles } from "@oscarpalmer/toretto/style";
|
|
2
|
+
// src/js/grid/grid.model.ts
|
|
3
|
+
var OuiGridResizeEvent = class extends CustomEvent {};
|
|
4
|
+
var OuiGridResizeHandlerEvent = class extends CustomEvent {
|
|
5
|
+
constructor(detail) {
|
|
6
|
+
super(GRID_EVENT_RESIZE_HANDLE, { detail });
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
var OuiGridSortEvent = class extends CustomEvent {};
|
|
10
|
+
const GRID_TAGNAME = "oui-grid";
|
|
11
|
+
const GRID_ATTRIBUTE_COLUMNS = "columns";
|
|
12
|
+
const GRID_ATTRIBUTE_GAP = "gap";
|
|
13
|
+
const GRID_ATTRIBUTE_ITEM = `${GRID_TAGNAME}-item`;
|
|
14
|
+
const GRID_ATTRIBUTE_ITEM_ACTIVE = `${GRID_ATTRIBUTE_ITEM}-active`;
|
|
15
|
+
const GRID_ATTRIBUTE_ITEM_HANDLE = `${GRID_ATTRIBUTE_ITEM}-handle`;
|
|
16
|
+
const GRID_ATTRIBUTE_PLACEHOLDER = `${GRID_TAGNAME}-placeholder`;
|
|
17
|
+
const GRID_ATTRIBUTE_RESIZABLE = "resizable";
|
|
18
|
+
const GRID_ATTRIBUTE_SORTABLE = "sortable";
|
|
19
|
+
const GRID_ATTRIBUTE_SORTING = `${GRID_TAGNAME}-sorting`;
|
|
20
|
+
const GRID_ATTRIBUTE_SPAN = `${GRID_TAGNAME}-span`;
|
|
21
|
+
const GRID_EVENT_RESIZE_BEGIN = "resize:begin";
|
|
22
|
+
const GRID_EVENT_RESIZE_CANCEL = "resize:cancel";
|
|
23
|
+
const GRID_EVENT_RESIZE_CHANGE = "resize:change";
|
|
24
|
+
const GRID_EVENT_RESIZE_END = "resize:end";
|
|
25
|
+
const GRID_EVENT_RESIZE_HANDLE = "resize:handle";
|
|
26
|
+
const GRID_EVENT_SORT_BEGIN = "sort:begin";
|
|
27
|
+
const GRID_EVENT_SORT_CANCEL = "sort:cancel";
|
|
28
|
+
const GRID_EVENT_SORT_CHANGE = "sort:change";
|
|
29
|
+
const GRID_EVENT_SORT_END = "sort:end";
|
|
30
|
+
const GRID_SELECTOR_HANDLE = `[${GRID_ATTRIBUTE_ITEM_HANDLE}]`;
|
|
31
|
+
const GRID_SELECTOR_ITEM = `${GRID_TAGNAME} > *`;
|
|
32
|
+
const GRID_SELECTOR_ITEM_SCOPED = `:scope > *`;
|
|
33
|
+
const GRID_SYMBOL = Symbol(GRID_TAGNAME);
|
|
34
|
+
const gridStyling = toggleStyles(document.body, {
|
|
35
|
+
touchAction: "none",
|
|
36
|
+
userSelect: "none",
|
|
37
|
+
webkitUserSelect: "none"
|
|
38
|
+
});
|
|
39
|
+
export { GRID_ATTRIBUTE_COLUMNS, GRID_ATTRIBUTE_GAP, GRID_ATTRIBUTE_ITEM, GRID_ATTRIBUTE_ITEM_ACTIVE, GRID_ATTRIBUTE_ITEM_HANDLE, GRID_ATTRIBUTE_PLACEHOLDER, GRID_ATTRIBUTE_RESIZABLE, GRID_ATTRIBUTE_SORTABLE, GRID_ATTRIBUTE_SORTING, GRID_ATTRIBUTE_SPAN, GRID_EVENT_RESIZE_BEGIN, GRID_EVENT_RESIZE_CANCEL, GRID_EVENT_RESIZE_CHANGE, GRID_EVENT_RESIZE_END, GRID_EVENT_RESIZE_HANDLE, GRID_EVENT_SORT_BEGIN, GRID_EVENT_SORT_CANCEL, GRID_EVENT_SORT_CHANGE, GRID_EVENT_SORT_END, GRID_SELECTOR_HANDLE, GRID_SELECTOR_ITEM, GRID_SELECTOR_ITEM_SCOPED, GRID_SYMBOL, GRID_TAGNAME, OuiGridResizeEvent, OuiGridResizeHandlerEvent, OuiGridSortEvent, gridStyling };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { C as GRID_SYMBOL, E as GridGap, k as GridState, w as GRID_TAGNAME } from "../grid.model-SiNst5db.mjs";
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLElementTagNameMap {
|
|
4
|
+
[GRID_TAGNAME]: OuiGridElement;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export interface OuiGridElement {
|
|
8
|
+
[GRID_SYMBOL]: GridState;
|
|
9
|
+
}
|
|
10
|
+
export declare class OuiGridElement extends HTMLElement {
|
|
11
|
+
static readonly observedAttributes: string[];
|
|
12
|
+
get columns(): [number, number | undefined] | undefined;
|
|
13
|
+
set columns(value: number | [number, number | undefined] | undefined);
|
|
14
|
+
get gap(): GridGap;
|
|
15
|
+
set gap(value: number);
|
|
16
|
+
constructor();
|
|
17
|
+
attributeChangedCallback(name: string): void;
|
|
18
|
+
connectedCallback(): void;
|
|
19
|
+
disconnectedCallback(): void;
|
|
20
|
+
update(): void;
|
|
21
|
+
updateResizers(updater: (item: HTMLElement, handle: HTMLElement) => void): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { RESIZABLE_SELECTOR_HANDLE_SCOPED } from "../resizable/resizable.model.mjs";
|
|
2
|
+
import { getGridColumns, setGridColumns } from "./grid.dom.mjs";
|
|
3
|
+
import { c as disconnectGrid, n as onGridAttributeChanged, o as connectGrid, s as createGridState, u as updateGrid } from "../grid.event-K_pG2vmS.mjs";
|
|
4
|
+
import { GRID_ATTRIBUTE_COLUMNS, GRID_SYMBOL, GRID_TAGNAME } from "./grid.model.mjs";
|
|
5
|
+
import { setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
6
|
+
// src/js/grid/index.ts
|
|
7
|
+
var OuiGridElement = class extends HTMLElement {
|
|
8
|
+
static observedAttributes = [GRID_ATTRIBUTE_COLUMNS, "gap"];
|
|
9
|
+
get columns() {
|
|
10
|
+
return getGridColumns(this[GRID_SYMBOL]);
|
|
11
|
+
}
|
|
12
|
+
set columns(value) {
|
|
13
|
+
setGridColumns(this[GRID_SYMBOL], value);
|
|
14
|
+
}
|
|
15
|
+
get gap() {
|
|
16
|
+
return { ...this[GRID_SYMBOL].gap };
|
|
17
|
+
}
|
|
18
|
+
set gap(value) {
|
|
19
|
+
setAttribute(this, "gap", typeof value === "number" ? value : void 0);
|
|
20
|
+
}
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
this[GRID_SYMBOL] = createGridState(this);
|
|
24
|
+
}
|
|
25
|
+
attributeChangedCallback(name) {
|
|
26
|
+
onGridAttributeChanged(this[GRID_SYMBOL], name);
|
|
27
|
+
}
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
connectGrid(this[GRID_SYMBOL]);
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
disconnectGrid(this[GRID_SYMBOL]);
|
|
33
|
+
}
|
|
34
|
+
update() {
|
|
35
|
+
updateGrid(this[GRID_SYMBOL]);
|
|
36
|
+
}
|
|
37
|
+
updateResizers(updater) {
|
|
38
|
+
if (!this.hasAttribute("resizable")) return;
|
|
39
|
+
const { length } = this[GRID_SYMBOL].elements;
|
|
40
|
+
for (let index = 0; index < length; index += 1) {
|
|
41
|
+
const element = this[GRID_SYMBOL].elements[index];
|
|
42
|
+
const handle = element.querySelector(RESIZABLE_SELECTOR_HANDLE_SCOPED);
|
|
43
|
+
if (handle != null) updater(element, handle);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
customElements.define(GRID_TAGNAME, OuiGridElement);
|
|
48
|
+
export { OuiGridElement };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { ignoreEvent } from "./internal/misc.mjs";
|
|
2
|
+
import { getResizable } from "./resizable/resizable.embedded.mjs";
|
|
3
|
+
import { getGridElements, getGridPlaceholder, updateGridPositions, updateGridResizables } from "./grid/grid.dom.mjs";
|
|
4
|
+
import { GRID_ATTRIBUTE_ITEM_ACTIVE, GRID_ATTRIBUTE_SORTABLE, GRID_ATTRIBUTE_SORTING, GRID_ATTRIBUTE_SPAN, GRID_EVENT_RESIZE_BEGIN, GRID_EVENT_RESIZE_CANCEL, GRID_EVENT_RESIZE_CHANGE, GRID_EVENT_RESIZE_END, GRID_EVENT_SORT_BEGIN, GRID_EVENT_SORT_CANCEL, GRID_EVENT_SORT_CHANGE, GRID_EVENT_SORT_END, GRID_SELECTOR_HANDLE, GRID_SELECTOR_ITEM, GRID_SYMBOL, GRID_TAGNAME, OuiGridResizeEvent, OuiGridSortEvent, gridStyling } from "./grid/grid.model.mjs";
|
|
5
|
+
import { setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
6
|
+
import { dispatch, getEventPosition, on } from "@oscarpalmer/toretto/event";
|
|
7
|
+
import { findAncestor } from "@oscarpalmer/toretto/find";
|
|
8
|
+
import { supportsTouch } from "@oscarpalmer/toretto/touch";
|
|
9
|
+
import { max, min, round } from "@oscarpalmer/atoms/math";
|
|
10
|
+
import { getString } from "@oscarpalmer/atoms/string";
|
|
11
|
+
// src/js/grid/grid.misc.ts
|
|
12
|
+
function connectGrid(state) {
|
|
13
|
+
state.elements = getGridElements(state);
|
|
14
|
+
state.mutationObserver.observe(state.host, mutationOptions);
|
|
15
|
+
resizeObserver.observe(state.host);
|
|
16
|
+
updateGridResizables(state);
|
|
17
|
+
}
|
|
18
|
+
function createGridState(host) {
|
|
19
|
+
const state = {
|
|
20
|
+
host,
|
|
21
|
+
callbacks: {
|
|
22
|
+
onResizeBegin: (element, size) => onBeginResizeGridItem(state, element, size),
|
|
23
|
+
onResizeCancel: (element, size) => onGridItemResized(GRID_EVENT_RESIZE_CANCEL, state, element, size),
|
|
24
|
+
onResizeEnd: (element, size) => onGridItemResized(GRID_EVENT_RESIZE_END, state, element, size),
|
|
25
|
+
onResizeUpdate: (element, size) => onGridItemResized(GRID_EVENT_RESIZE_CHANGE, state, element, size)
|
|
26
|
+
},
|
|
27
|
+
elements: [],
|
|
28
|
+
gap: { value: 0 },
|
|
29
|
+
mutationObserver: new MutationObserver(() => onGridMutation(state)),
|
|
30
|
+
sortable: host.hasAttribute(GRID_ATTRIBUTE_SORTABLE)
|
|
31
|
+
};
|
|
32
|
+
return state;
|
|
33
|
+
}
|
|
34
|
+
function disconnectGrid(state) {
|
|
35
|
+
state.mutationObserver.disconnect();
|
|
36
|
+
resizeObserver.unobserve(state.host);
|
|
37
|
+
}
|
|
38
|
+
function endGridSort(sort, target) {
|
|
39
|
+
sort.item.style.pointerEvents = sort.style.pointerEvents;
|
|
40
|
+
sort.item.style.position = "";
|
|
41
|
+
sort.item.style.transform = sort.style.transform;
|
|
42
|
+
sort.item.style.zIndex = sort.style.zIndex;
|
|
43
|
+
sort.state.active = void 0;
|
|
44
|
+
const placeholder = getGridPlaceholder();
|
|
45
|
+
if (target == null) {
|
|
46
|
+
placeholder?.replaceWith(sort.item);
|
|
47
|
+
dispatch(sort.state.host, new OuiGridSortEvent(GRID_EVENT_SORT_CANCEL, { detail: { item: sort.item } }));
|
|
48
|
+
} else {
|
|
49
|
+
const event = new OuiGridSortEvent(GRID_EVENT_SORT_END, { detail: {
|
|
50
|
+
destination: target,
|
|
51
|
+
item: sort.item
|
|
52
|
+
} });
|
|
53
|
+
if (dispatch(sort.state.host, event).defaultPrevented) placeholder?.replaceWith(sort.item);
|
|
54
|
+
else {
|
|
55
|
+
const next = sort.state.elements.indexOf(target);
|
|
56
|
+
if (sort.index < next) target?.after(sort.item);
|
|
57
|
+
else target?.before(sort.item);
|
|
58
|
+
placeholder?.remove();
|
|
59
|
+
updateGridPositions(sort.state);
|
|
60
|
+
updateGridResizables(sort.state);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
setAttribute(sort.state.host, GRID_ATTRIBUTE_SORTING);
|
|
64
|
+
setAttribute(sort.item, GRID_ATTRIBUTE_ITEM_ACTIVE);
|
|
65
|
+
gridStyling.remove();
|
|
66
|
+
}
|
|
67
|
+
function updateGrid(state) {
|
|
68
|
+
if (state.host.isConnected) updateGridPositions(state);
|
|
69
|
+
}
|
|
70
|
+
const mutationOptions = { childList: true };
|
|
71
|
+
const resizeObserver = new ResizeObserver(onGridResized);
|
|
72
|
+
// src/js/grid/grid.event.ts
|
|
73
|
+
function onBeginResizeGridItem(state, element, size) {
|
|
74
|
+
const event = new OuiGridResizeEvent(GRID_EVENT_RESIZE_BEGIN, { detail: {
|
|
75
|
+
...size,
|
|
76
|
+
item: element
|
|
77
|
+
} });
|
|
78
|
+
if (dispatch(state.host, event).defaultPrevented) return;
|
|
79
|
+
const { columns } = state;
|
|
80
|
+
if (columns == null) return;
|
|
81
|
+
const resizable = getResizable(element);
|
|
82
|
+
if (resizable == null) return;
|
|
83
|
+
state.active = element;
|
|
84
|
+
const step = columns.width + state.gap.value;
|
|
85
|
+
resizable.configure({
|
|
86
|
+
maximumWidth: columns.count * step - state.gap.value,
|
|
87
|
+
minimumWidth: columns.width,
|
|
88
|
+
stepWidth: step
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function onGridAttributeChanged(state, name) {
|
|
92
|
+
if (!state.host.isConnected) return;
|
|
93
|
+
if (name === "columns" || name === "gap") updateGridPositions(state);
|
|
94
|
+
}
|
|
95
|
+
function onGridItemResized(type, state, element, size) {
|
|
96
|
+
const event = new OuiGridResizeEvent(type, { detail: {
|
|
97
|
+
...size,
|
|
98
|
+
item: element
|
|
99
|
+
} });
|
|
100
|
+
if (dispatch(state.host, event).defaultPrevented) return;
|
|
101
|
+
const { columns } = state;
|
|
102
|
+
if (columns != null) {
|
|
103
|
+
const span = max([1, min([round((size.width + state.gap.value) / (columns.width + state.gap.value)), columns.count])]);
|
|
104
|
+
setAttribute(element, GRID_ATTRIBUTE_SPAN, getString(span));
|
|
105
|
+
}
|
|
106
|
+
updateGridPositions(state);
|
|
107
|
+
if (type === "resize:cancel" || type === "resize:end") state.active = void 0;
|
|
108
|
+
}
|
|
109
|
+
function onGridMutation(state) {
|
|
110
|
+
state.elements = getGridElements(state);
|
|
111
|
+
updateGridPositions(state);
|
|
112
|
+
updateGridResizables(state);
|
|
113
|
+
}
|
|
114
|
+
function onGridResized(entries) {
|
|
115
|
+
const { length } = entries;
|
|
116
|
+
for (let index = 0; index < length; index += 1) {
|
|
117
|
+
const entry = entries[index];
|
|
118
|
+
if (GRID_SYMBOL in entry.target) updateGridPositions(entry.target[GRID_SYMBOL]);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function onKeydown(event) {
|
|
122
|
+
if (event.key === "Escape" && sort != null) sort = endGridSort(sort);
|
|
123
|
+
}
|
|
124
|
+
function onPointerdown(event) {
|
|
125
|
+
if (ignoreEvent(event, supportsTouch.value)) return;
|
|
126
|
+
const item = findAncestor(event, GRID_SELECTOR_ITEM);
|
|
127
|
+
if (item == null) return;
|
|
128
|
+
const handle = item.querySelector(GRID_SELECTOR_HANDLE);
|
|
129
|
+
if (handle != null && !(event.target === handle || handle.contains(event.target))) return;
|
|
130
|
+
const grid = findAncestor(item, GRID_TAGNAME);
|
|
131
|
+
if (grid == null) return;
|
|
132
|
+
const state = grid[GRID_SYMBOL];
|
|
133
|
+
if (!state.sortable) return;
|
|
134
|
+
if (supportsTouch.value) event.preventDefault();
|
|
135
|
+
const dispatched = new OuiGridSortEvent(GRID_EVENT_SORT_BEGIN, { detail: { item } });
|
|
136
|
+
if (dispatch(state.host, dispatched).defaultPrevented) return;
|
|
137
|
+
state.active = item;
|
|
138
|
+
const placeholder = getGridPlaceholder(item);
|
|
139
|
+
const position = getEventPosition(event);
|
|
140
|
+
const rectangle = item.getBoundingClientRect();
|
|
141
|
+
item.replaceWith(placeholder);
|
|
142
|
+
document.body.append(item);
|
|
143
|
+
sort = {
|
|
144
|
+
item,
|
|
145
|
+
state,
|
|
146
|
+
index: state.elements.indexOf(item),
|
|
147
|
+
offset: {
|
|
148
|
+
x: position.x - rectangle.left,
|
|
149
|
+
y: position.y - rectangle.top
|
|
150
|
+
},
|
|
151
|
+
style: {
|
|
152
|
+
pointerEvents: item.style.pointerEvents,
|
|
153
|
+
transform: item.style.transform,
|
|
154
|
+
zIndex: item.style.zIndex
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
setAttribute(sort.state.host, GRID_ATTRIBUTE_SORTING, "");
|
|
158
|
+
setAttribute(sort.item, GRID_ATTRIBUTE_ITEM_ACTIVE, "");
|
|
159
|
+
gridStyling.set();
|
|
160
|
+
onPointermove(event);
|
|
161
|
+
}
|
|
162
|
+
function onPointermove(event) {
|
|
163
|
+
if (sort == null) return;
|
|
164
|
+
const { x, y } = getEventPosition(event);
|
|
165
|
+
sort.item.style.pointerEvents = "none";
|
|
166
|
+
sort.item.style.position = "fixed";
|
|
167
|
+
sort.item.style.transform = `translate3d(${x - sort.offset.x}px, ${y - sort.offset.y}px, 0)`;
|
|
168
|
+
sort.item.style.zIndex = "1000";
|
|
169
|
+
const dispatched = new OuiGridSortEvent(GRID_EVENT_SORT_CHANGE, { detail: { item: sort.item } });
|
|
170
|
+
if (dispatch(sort.state.host, dispatched).defaultPrevented) sort = endGridSort(sort);
|
|
171
|
+
}
|
|
172
|
+
function onPointerup(event) {
|
|
173
|
+
if (sort == null) return;
|
|
174
|
+
const target = findAncestor(event, GRID_SELECTOR_ITEM);
|
|
175
|
+
if (target == null) {
|
|
176
|
+
sort = endGridSort(sort);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (findAncestor(target, "oui-grid")?.[GRID_SYMBOL] !== sort.state) {
|
|
180
|
+
sort = endGridSort(sort);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
sort = endGridSort(sort, target);
|
|
184
|
+
}
|
|
185
|
+
let sort;
|
|
186
|
+
on(document, "keydown", onKeydown);
|
|
187
|
+
on(document, "mousedown", onPointerdown);
|
|
188
|
+
on(document, "pointermove", onPointermove);
|
|
189
|
+
on(document, "pointerup", onPointerup);
|
|
190
|
+
on(document, "touchcancel", onPointerup);
|
|
191
|
+
on(document, "touchstart", onPointerdown, { passive: false });
|
|
192
|
+
export { onGridResized as a, disconnectGrid as c, onGridMutation as i, endGridSort as l, onGridAttributeChanged as n, connectGrid as o, onGridItemResized as r, createGridState as s, onBeginResizeGridItem as t, updateGrid as u };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { a as OuiResizableEventDetail } from "./resizable.model-BOufXDXx.mjs";
|
|
2
|
+
import { StyleToggler } from "@oscarpalmer/toretto/style";
|
|
3
|
+
import { EventPosition } from "@oscarpalmer/toretto/models";
|
|
4
|
+
type GridColumns = {
|
|
5
|
+
attribute: [number, number | undefined];
|
|
6
|
+
count: number;
|
|
7
|
+
width: number;
|
|
8
|
+
};
|
|
9
|
+
type GridGap = {
|
|
10
|
+
attribute?: number;
|
|
11
|
+
style?: string;
|
|
12
|
+
value: number;
|
|
13
|
+
};
|
|
14
|
+
type GridItem = {
|
|
15
|
+
height: number;
|
|
16
|
+
width: number;
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
};
|
|
20
|
+
type GridSort = {
|
|
21
|
+
index: number;
|
|
22
|
+
item: HTMLElement;
|
|
23
|
+
offset: EventPosition;
|
|
24
|
+
state: GridState;
|
|
25
|
+
style: GridSortStyle;
|
|
26
|
+
};
|
|
27
|
+
type GridSortStyle = {
|
|
28
|
+
pointerEvents: string;
|
|
29
|
+
transform: string;
|
|
30
|
+
zIndex: string;
|
|
31
|
+
};
|
|
32
|
+
type GridState = {
|
|
33
|
+
active?: HTMLElement;
|
|
34
|
+
callbacks: GridStateCallbacks;
|
|
35
|
+
columns?: GridColumns;
|
|
36
|
+
elements: HTMLElement[];
|
|
37
|
+
gap: GridGap;
|
|
38
|
+
height?: number;
|
|
39
|
+
host: HTMLElement;
|
|
40
|
+
mutationObserver: MutationObserver;
|
|
41
|
+
sortable: boolean;
|
|
42
|
+
};
|
|
43
|
+
type GridStateCallbacks = {
|
|
44
|
+
onResizeBegin: (element: Element, size: OuiResizableEventDetail) => void;
|
|
45
|
+
onResizeCancel: (element: Element, size: OuiResizableEventDetail) => void;
|
|
46
|
+
onResizeEnd: (element: Element, size: OuiResizableEventDetail) => void;
|
|
47
|
+
onResizeUpdate: (element: Element, size: OuiResizableEventDetail) => void;
|
|
48
|
+
};
|
|
49
|
+
declare class OuiGridResizeEvent extends CustomEvent<OuiGridResizeEventDetail> {}
|
|
50
|
+
type OuiGridResizeEventDetail = {
|
|
51
|
+
item: HTMLElement;
|
|
52
|
+
} & OuiResizableEventDetail;
|
|
53
|
+
declare class OuiGridResizeHandlerEvent extends CustomEvent<OuiGridResizeHandlerEventDetail> {
|
|
54
|
+
constructor(detail: OuiGridResizeHandlerEventDetail);
|
|
55
|
+
}
|
|
56
|
+
type OuiGridResizeHandlerEventDetail = {
|
|
57
|
+
handle: HTMLElement;
|
|
58
|
+
item: HTMLElement;
|
|
59
|
+
};
|
|
60
|
+
declare class OuiGridSortEvent extends CustomEvent<OuiGridEventSortDetail> {}
|
|
61
|
+
type OuiGridEventSortDetail = {
|
|
62
|
+
destination?: HTMLElement;
|
|
63
|
+
item: HTMLElement;
|
|
64
|
+
};
|
|
65
|
+
declare const GRID_TAGNAME = "oui-grid";
|
|
66
|
+
declare const GRID_ATTRIBUTE_COLUMNS = "columns";
|
|
67
|
+
declare const GRID_ATTRIBUTE_GAP = "gap";
|
|
68
|
+
declare const GRID_ATTRIBUTE_ITEM: string;
|
|
69
|
+
declare const GRID_ATTRIBUTE_ITEM_ACTIVE: string;
|
|
70
|
+
declare const GRID_ATTRIBUTE_ITEM_HANDLE: string;
|
|
71
|
+
declare const GRID_ATTRIBUTE_PLACEHOLDER: string;
|
|
72
|
+
declare const GRID_ATTRIBUTE_RESIZABLE = "resizable";
|
|
73
|
+
declare const GRID_ATTRIBUTE_SORTABLE = "sortable";
|
|
74
|
+
declare const GRID_ATTRIBUTE_SORTING: string;
|
|
75
|
+
declare const GRID_ATTRIBUTE_SPAN: string;
|
|
76
|
+
declare const GRID_EVENT_RESIZE_BEGIN = "resize:begin";
|
|
77
|
+
declare const GRID_EVENT_RESIZE_CANCEL = "resize:cancel";
|
|
78
|
+
declare const GRID_EVENT_RESIZE_CHANGE = "resize:change";
|
|
79
|
+
declare const GRID_EVENT_RESIZE_END = "resize:end";
|
|
80
|
+
declare const GRID_EVENT_RESIZE_HANDLE = "resize:handle";
|
|
81
|
+
declare const GRID_EVENT_SORT_BEGIN = "sort:begin";
|
|
82
|
+
declare const GRID_EVENT_SORT_CANCEL = "sort:cancel";
|
|
83
|
+
declare const GRID_EVENT_SORT_CHANGE = "sort:change";
|
|
84
|
+
declare const GRID_EVENT_SORT_END = "sort:end";
|
|
85
|
+
declare const GRID_SELECTOR_HANDLE: string;
|
|
86
|
+
declare const GRID_SELECTOR_ITEM: string;
|
|
87
|
+
declare const GRID_SELECTOR_ITEM_SCOPED: string;
|
|
88
|
+
declare const GRID_SYMBOL: unique symbol;
|
|
89
|
+
declare const gridStyling: StyleToggler;
|
|
90
|
+
export { OuiGridEventSortDetail as A, GRID_SYMBOL as C, GridItem as D, GridGap as E, OuiGridSortEvent as F, gridStyling as I, OuiGridResizeEventDetail as M, OuiGridResizeHandlerEvent as N, GridSort as O, OuiGridResizeHandlerEventDetail as P, GRID_SELECTOR_ITEM_SCOPED as S, GridColumns as T, GRID_EVENT_SORT_CANCEL as _, GRID_ATTRIBUTE_ITEM_HANDLE as a, GRID_SELECTOR_HANDLE as b, GRID_ATTRIBUTE_SORTABLE as c, GRID_EVENT_RESIZE_BEGIN as d, GRID_EVENT_RESIZE_CANCEL as f, GRID_EVENT_SORT_BEGIN as g, GRID_EVENT_RESIZE_HANDLE as h, GRID_ATTRIBUTE_ITEM_ACTIVE as i, OuiGridResizeEvent as j, GridState as k, GRID_ATTRIBUTE_SORTING as l, GRID_EVENT_RESIZE_END as m, GRID_ATTRIBUTE_GAP as n, GRID_ATTRIBUTE_PLACEHOLDER as o, GRID_EVENT_RESIZE_CHANGE as p, GRID_ATTRIBUTE_ITEM as r, GRID_ATTRIBUTE_RESIZABLE as s, GRID_ATTRIBUTE_COLUMNS as t, GRID_ATTRIBUTE_SPAN as u, GRID_EVENT_SORT_CHANGE as v, GRID_TAGNAME as w, GRID_SELECTOR_ITEM as x, GRID_EVENT_SORT_END as y };
|
package/dist/js/index.d.mts
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import { c as OuiFloatable, t as CreateOuiFloatableOptions, u as OuiFloatablePosition } from "./floatable.model-
|
|
2
|
-
import { N as OuiColorPickerEvent } from "./color-picker.constants-
|
|
3
|
-
import { a as setColorPickerLocalizations } from "./color-picker.misc-
|
|
4
|
-
import { OuiColorPickerElement } from "./color-picker/index.mjs";
|
|
5
|
-
import { i as setComboboxLocalizations } from "./combobox.misc-DRDFk6X8.mjs";
|
|
6
|
-
import { OuiComboboxElement } from "./combobox/index.mjs";
|
|
7
|
-
import { $ as OuiSortable, p as CreateOuiDraggableOptions, u as OuiMovable } from "./movable.model-D9nnPWKk.mjs";
|
|
8
|
-
import { n as OuiResizable, t as CreateOuiResizableOptions } from "./resizable.model-YEtcC9li.mjs";
|
|
9
|
-
import { c as OuiDialog } from "./dialog.model-HVzYWoDo.mjs";
|
|
10
|
-
import { getDialog } from "./dialog/index.mjs";
|
|
11
|
-
import { n as createFloatable } from "./floatable.embedded-ncshL3Sa.mjs";
|
|
1
|
+
import { c as OuiFloatable, t as CreateOuiFloatableOptions, u as OuiFloatablePosition } from "./floatable.model-jS5Ui5Av.mjs";
|
|
2
|
+
import { N as OuiColorPickerEvent } from "./color-picker.constants-DdttC4ab.mjs";
|
|
3
|
+
import { a as setColorPickerLocalizations } from "./color-picker.misc-BH_tFyWR.mjs";
|
|
12
4
|
import "./floatable/floatable.standalone.mjs";
|
|
13
|
-
import {
|
|
14
|
-
import { t as createFocusTrap } from "./focus-trap.embedded-DpcPkP7c.mjs";
|
|
15
|
-
import { t as createMovable } from "./movable.embedded-C1bDTLGs.mjs";
|
|
5
|
+
import { i as setComboboxLocalizations } from "./combobox.misc-Csh9lm9_.mjs";
|
|
16
6
|
import "./movable/movable.standalone.mjs";
|
|
17
|
-
import {
|
|
7
|
+
import { d as OuiMovable, m as CreateOuiDraggableOptions, nt as OuiSortable } from "./movable.model-CQ3AbTrq.mjs";
|
|
8
|
+
import { i as OuiResizableEvent, n as OuiResizable, t as CreateOuiResizableOptions } from "./resizable.model-BOufXDXx.mjs";
|
|
9
|
+
import { c as OuiDialog } from "./dialog.model-cYq7rTKL.mjs";
|
|
18
10
|
import "./resizable/resizable.standalone.mjs";
|
|
19
|
-
import {
|
|
11
|
+
import { n as createFloatable } from "./floatable.embedded-Cr1KX6GZ.mjs";
|
|
20
12
|
import "./sortable/sortable.standalone.mjs";
|
|
21
|
-
import {
|
|
13
|
+
import { l as OuiFocusTrap, u as OuiFocusTrapOptions } from "./focus-trap.model-wg0iAZ7x.mjs";
|
|
14
|
+
import { t as createFocusTrap } from "./focus-trap.embedded-BVXcd4OO.mjs";
|
|
15
|
+
import { OuiColorPickerElement } from "./color-picker/index.mjs";
|
|
16
|
+
import { t as createMovable } from "./movable.embedded-HjPPob-Z.mjs";
|
|
17
|
+
import { OuiComboboxElement } from "./combobox/index.mjs";
|
|
18
|
+
import { t as createResizable } from "./resizable.embedded-DQclAEP-.mjs";
|
|
19
|
+
import { getDialog } from "./dialog/index.mjs";
|
|
20
|
+
import { t as createSortable } from "./sortable.embedded-B5LPz-c_.mjs";
|
|
21
|
+
import { OuiGridElement } from "./grid/index.mjs";
|
|
22
|
+
import { n as setListboxLocalizations } from "./listbox.misc-CkW28nUS.mjs";
|
|
22
23
|
import { OuiListboxElement } from "./listbox/index.mjs";
|
|
23
|
-
import { t as OuiPopover } from "./popover.model-
|
|
24
|
+
import { t as OuiPopover } from "./popover.model-CrrIdSmS.mjs";
|
|
24
25
|
import { getPopover } from "./popover/index.mjs";
|
|
25
26
|
import { OuiSplitterElement } from "./splitter/index.mjs";
|
|
26
|
-
import { r as OuiTabsEvent } from "./tabs.model-
|
|
27
|
+
import { r as OuiTabsEvent } from "./tabs.model-CvylbR2o.mjs";
|
|
27
28
|
import { OuiTabsElement } from "./tabs/index.mjs";
|
|
28
|
-
import { t as OuiTooltip } from "./tooltip.model-
|
|
29
|
+
import { t as OuiTooltip } from "./tooltip.model-BI3UK-VU.mjs";
|
|
29
30
|
import { getTooltip, setTooltipDelay } from "./tooltip/index.mjs";
|
|
30
|
-
export { type CreateOuiFloatableOptions, type CreateOuiDraggableOptions as CreateOuiMovableOptions, type CreateOuiDraggableOptions as CreateOuiSortableOptions, type CreateOuiResizableOptions, OuiColorPickerElement, OuiColorPickerEvent, OuiComboboxElement, type OuiDialog, type OuiFloatable, type OuiFloatablePosition, type OuiFocusTrap, type OuiFocusTrapOptions, OuiListboxElement, type OuiMovable, type OuiPopover, type OuiResizable, type OuiSortable, OuiSplitterElement, OuiTabsElement, OuiTabsEvent, type OuiTooltip, createFloatable, createFocusTrap, createMovable, createResizable as createOuiResizable, createSortable, getDialog, getPopover, getTooltip, setColorPickerLocalizations, setComboboxLocalizations, setListboxLocalizations, setTooltipDelay };
|
|
31
|
+
export { type CreateOuiFloatableOptions, type CreateOuiDraggableOptions as CreateOuiMovableOptions, type CreateOuiDraggableOptions as CreateOuiSortableOptions, type CreateOuiResizableOptions, OuiColorPickerElement, OuiColorPickerEvent, OuiComboboxElement, type OuiDialog, type OuiFloatable, type OuiFloatablePosition, type OuiFocusTrap, type OuiFocusTrapOptions, OuiGridElement, OuiListboxElement, type OuiMovable, type OuiPopover, type OuiResizable, OuiResizableEvent, type OuiSortable, OuiSplitterElement, OuiTabsElement, OuiTabsEvent, type OuiTooltip, createFloatable, createFocusTrap, createMovable, createResizable as createOuiResizable, createSortable, getDialog, getPopover, getTooltip, setColorPickerLocalizations, setComboboxLocalizations, setListboxLocalizations, setTooltipDelay };
|