@oscarpalmer/tabela 0.13.0 → 0.14.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/components/{body.component.mjs → body.component.js} +3 -6
- package/dist/components/{column.component.mjs → column.component.js} +5 -8
- package/dist/components/{footer.component.mjs → footer.component.js} +4 -7
- package/dist/components/group.component.js +28 -0
- package/dist/components/{header.component.mjs → header.component.js} +3 -6
- package/dist/components/{row.component.mjs → row.component.js} +7 -11
- package/dist/helpers/{dom.helpers.mjs → dom.helpers.js} +9 -13
- package/dist/helpers/{misc.helpers.mjs → misc.helpers.js} +1 -3
- package/dist/helpers/style.helper.js +6 -0
- package/dist/{index.mjs → index.js} +1 -3
- package/dist/managers/{column.manager.mjs → column.manager.js} +1 -6
- package/dist/managers/data.manager.js +181 -0
- package/dist/managers/{event.manager.mjs → event.manager.js} +8 -9
- package/dist/managers/{filter.manager.mjs → filter.manager.js} +14 -23
- package/dist/managers/group.manager.js +46 -0
- package/dist/managers/{navigation.manager.mjs → navigation.manager.js} +24 -27
- package/dist/managers/{render.manager.mjs → render.manager.js} +26 -35
- package/dist/managers/{row.manager.mjs → row.manager.js} +11 -18
- package/dist/managers/{selection.manager.mjs → selection.manager.js} +28 -32
- package/dist/managers/{sort.manager.mjs → sort.manager.js} +9 -12
- package/dist/models/body.model.js +0 -0
- package/dist/models/column.model.js +0 -0
- package/dist/models/data.model.js +0 -0
- package/dist/models/filter.model.js +0 -0
- package/dist/models/footer.model.js +0 -0
- package/dist/models/group.model.js +0 -0
- package/dist/models/header.model.js +0 -0
- package/dist/models/render.model.js +0 -0
- package/dist/models/selection.model.js +0 -0
- package/dist/models/sort.model.js +0 -0
- package/dist/models/tabela.model.js +0 -0
- package/dist/models/tabela.options.js +0 -0
- package/dist/{tabela.full.mjs → tabela.full.js} +860 -1049
- package/dist/tabela.js +105 -0
- package/package.json +1 -1
- package/src/components/body.component.ts +10 -7
- package/src/components/column.component.ts +19 -15
- package/src/components/footer.component.ts +7 -10
- package/src/components/group.component.ts +34 -12
- package/src/components/header.component.ts +6 -5
- package/src/components/row.component.ts +27 -19
- package/src/helpers/dom.helpers.ts +18 -22
- package/src/helpers/misc.helpers.ts +5 -0
- package/src/managers/data.manager.ts +80 -77
- package/src/managers/event.manager.ts +21 -10
- package/src/managers/filter.manager.ts +34 -21
- package/src/managers/group.manager.ts +18 -9
- package/src/managers/navigation.manager.ts +46 -49
- package/src/managers/render.manager.ts +34 -21
- package/src/managers/row.manager.ts +1 -1
- package/src/managers/selection.manager.ts +37 -35
- package/src/managers/sort.manager.ts +47 -34
- package/src/managers/style.manager.ts +40 -25
- package/src/models/column.model.ts +2 -6
- package/src/models/data.model.ts +7 -8
- package/src/models/dom.model.ts +33 -0
- package/src/models/event.model.ts +7 -0
- package/src/models/filter.model.ts +20 -0
- package/src/models/group.model.ts +4 -0
- package/src/models/sort.model.ts +4 -0
- package/src/models/style.model.ts +32 -20
- package/src/models/tabela.model.ts +1 -0
- package/src/tabela.ts +20 -22
- package/dist/body.component-_VDOpJhV.d.mts +0 -10
- package/dist/body.model-2iwsovAV.d.mts +0 -7
- package/dist/column.component-Bx46r3JI.d.mts +0 -16
- package/dist/column.model-D-aw4EU4.d.mts +0 -16
- package/dist/components/body.component.d.mts +0 -2
- package/dist/components/column.component.d.mts +0 -2
- package/dist/components/footer.component.d.mts +0 -2
- package/dist/components/group.component.d.mts +0 -2
- package/dist/components/group.component.mjs +0 -51
- package/dist/components/header.component.d.mts +0 -2
- package/dist/components/row.component.d.mts +0 -2
- package/dist/filter.model-7ukJrtil.d.mts +0 -16
- package/dist/footer.component-Curiab8j.d.mts +0 -12
- package/dist/footer.model-DhqoS6ds.d.mts +0 -8
- package/dist/group.component-Cq1YYbfJ.d.mts +0 -285
- package/dist/group.model-BsKFwHbt.d.mts +0 -10
- package/dist/header.component-BjjlpZIg.d.mts +0 -12
- package/dist/header.model-DN_KzUCV.d.mts +0 -7
- package/dist/helpers/dom.helpers.d.mts +0 -12
- package/dist/helpers/misc.helpers.d.mts +0 -6
- package/dist/helpers/style.helper.d.mts +0 -6
- package/dist/helpers/style.helper.mjs +0 -8
- package/dist/index.d.mts +0 -7
- package/dist/managers/column.manager.d.mts +0 -2
- package/dist/managers/data.manager.d.mts +0 -2
- package/dist/managers/data.manager.mjs +0 -222
- package/dist/managers/event.manager.d.mts +0 -2
- package/dist/managers/filter.manager.d.mts +0 -2
- package/dist/managers/group.manager.d.mts +0 -2
- package/dist/managers/group.manager.mjs +0 -73
- package/dist/managers/navigation.manager.d.mts +0 -2
- package/dist/managers/render.manager.d.mts +0 -2
- package/dist/managers/row.manager.d.mts +0 -2
- package/dist/managers/selection.manager.d.mts +0 -2
- package/dist/managers/sort.manager.d.mts +0 -2
- package/dist/managers/style.manager.d.mts +0 -2
- package/dist/managers/style.manager.mjs +0 -149
- package/dist/models/body.model.d.mts +0 -2
- package/dist/models/body.model.mjs +0 -1
- package/dist/models/column.model.d.mts +0 -2
- package/dist/models/column.model.mjs +0 -1
- package/dist/models/data.model.d.mts +0 -2
- package/dist/models/data.model.mjs +0 -1
- package/dist/models/filter.model.d.mts +0 -2
- package/dist/models/filter.model.mjs +0 -1
- package/dist/models/footer.model.d.mts +0 -2
- package/dist/models/footer.model.mjs +0 -1
- package/dist/models/group.model.d.mts +0 -2
- package/dist/models/group.model.mjs +0 -1
- package/dist/models/header.model.d.mts +0 -2
- package/dist/models/header.model.mjs +0 -1
- package/dist/models/render.model.d.mts +0 -2
- package/dist/models/render.model.mjs +0 -1
- package/dist/models/selection.model.d.mts +0 -2
- package/dist/models/selection.model.mjs +0 -1
- package/dist/models/sort.model.d.mts +0 -2
- package/dist/models/sort.model.mjs +0 -1
- package/dist/models/style.model.d.mts +0 -23
- package/dist/models/style.model.mjs +0 -23
- package/dist/models/tabela.model.d.mts +0 -2
- package/dist/models/tabela.model.mjs +0 -1
- package/dist/models/tabela.options.d.mts +0 -2
- package/dist/models/tabela.options.mjs +0 -1
- package/dist/selection.model-rwQe9fco.d.mts +0 -12
- package/dist/sort.model-CauImaLu.d.mts +0 -15
- package/dist/tabela.d.mts +0 -21
- package/dist/tabela.mjs +0 -126
- package/dist/tabela.options-RkZvfptB.d.mts +0 -14
|
@@ -1,89 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Is the value an event target?
|
|
4
|
-
* @param value Value to check
|
|
5
|
-
* @returns `true` if it's an event target, otherwise `false`
|
|
6
|
-
*/
|
|
7
|
-
function isEventTarget(value) {
|
|
8
|
-
return typeof value === "object" && value != null && typeof value.addEventListener === "function" && typeof value.removeEventListener === "function" && typeof value.dispatchEvent === "function";
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Is the value an HTML or SVG element?
|
|
12
|
-
* @param value Value to check
|
|
13
|
-
* @returns `true` if it's an HTML or SVG element, otherwise `false`
|
|
14
|
-
*/
|
|
15
|
-
function isHTMLOrSVGElement(value) {
|
|
16
|
-
return value instanceof HTMLElement || value instanceof SVGElement;
|
|
17
|
-
}
|
|
18
|
-
new Set([
|
|
19
|
-
Node.ELEMENT_NODE,
|
|
20
|
-
Node.TEXT_NODE,
|
|
21
|
-
Node.PROCESSING_INSTRUCTION_NODE,
|
|
22
|
-
Node.COMMENT_NODE,
|
|
23
|
-
Node.DOCUMENT_TYPE_NODE
|
|
24
|
-
]);
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/is.mjs
|
|
27
|
-
/**
|
|
28
|
-
* Is the value a constructor function?
|
|
29
|
-
* @param value Value to check
|
|
30
|
-
* @returns `true` if the value is a constructor function, otherwise `false`
|
|
31
|
-
*/
|
|
32
|
-
function isConstructor(value) {
|
|
33
|
-
return typeof value === "function" && value.prototype?.constructor === value;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Is the value a key?
|
|
37
|
-
* @param value Value to check
|
|
38
|
-
* @returns `true` if the value is a `Key` _(`number` or `string`)_, otherwise `false`
|
|
39
|
-
*/
|
|
40
|
-
function isKey(value) {
|
|
41
|
-
return typeof value === "number" || typeof value === "string";
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Is the value a number?
|
|
45
|
-
* @param value Value to check
|
|
46
|
-
* @returns `true` if the value is a `number`, otherwise `false`
|
|
47
|
-
*/
|
|
48
|
-
function isNumber(value) {
|
|
49
|
-
return typeof value === "number" && !Number.isNaN(value);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Is the value a plain object?
|
|
53
|
-
* @param value Value to check
|
|
54
|
-
* @returns `true` if the value is a plain object, otherwise `false`
|
|
55
|
-
*/
|
|
56
|
-
function isPlainObject(value) {
|
|
57
|
-
if (value === null || typeof value !== "object") return false;
|
|
58
|
-
if (Symbol.toStringTag in value || Symbol.iterator in value) return false;
|
|
59
|
-
const prototype = Object.getPrototypeOf(value);
|
|
60
|
-
return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Is the value a typed array?
|
|
64
|
-
* @param value Value to check
|
|
65
|
-
* @returns `true` if the value is a typed array, otherwise `false`
|
|
66
|
-
*/
|
|
67
|
-
function isTypedArray(value) {
|
|
68
|
-
TYPED_ARRAYS ??= new Set([
|
|
69
|
-
Int8Array,
|
|
70
|
-
Uint8Array,
|
|
71
|
-
Uint8ClampedArray,
|
|
72
|
-
Int16Array,
|
|
73
|
-
Uint16Array,
|
|
74
|
-
Int32Array,
|
|
75
|
-
Uint32Array,
|
|
76
|
-
Float32Array,
|
|
77
|
-
Float64Array,
|
|
78
|
-
BigInt64Array,
|
|
79
|
-
BigUint64Array
|
|
80
|
-
]);
|
|
81
|
-
return TYPED_ARRAYS.has(value?.constructor);
|
|
82
|
-
}
|
|
83
|
-
let TYPED_ARRAYS;
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/array/compact.mjs
|
|
86
|
-
function compact(array, strict) {
|
|
1
|
+
function compact$1(array, strict) {
|
|
87
2
|
if (!Array.isArray(array)) return [];
|
|
88
3
|
if (strict === true) return array.filter(Boolean);
|
|
89
4
|
const { length } = array;
|
|
@@ -94,143 +9,56 @@ function compact(array, strict) {
|
|
|
94
9
|
}
|
|
95
10
|
return compacted;
|
|
96
11
|
}
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/string.mjs
|
|
99
12
|
/**
|
|
100
13
|
* Get the string value from any value
|
|
101
14
|
* @param value Original value
|
|
102
15
|
* @returns String representation of the value
|
|
103
16
|
*/
|
|
104
|
-
function getString(value) {
|
|
17
|
+
function getString$1(value) {
|
|
105
18
|
if (typeof value === "string") return value;
|
|
106
19
|
if (value == null) return "";
|
|
107
|
-
if (typeof value === "function") return getString(value());
|
|
20
|
+
if (typeof value === "function") return getString$1(value());
|
|
108
21
|
if (typeof value !== "object") return String(value);
|
|
109
22
|
const asString = String(value.valueOf?.() ?? value);
|
|
110
23
|
return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
|
|
111
24
|
}
|
|
112
|
-
function ignoreKey(key) {
|
|
113
|
-
return EXPRESSION_IGNORED.test(key);
|
|
114
|
-
}
|
|
115
25
|
/**
|
|
116
26
|
* Join an array of values into a string
|
|
117
27
|
* @param value Array of values
|
|
118
28
|
* @param delimiter Delimiter to use between values
|
|
119
29
|
* @returns Joined string
|
|
120
30
|
*/
|
|
121
|
-
function join(value, delimiter) {
|
|
122
|
-
return compact(value).map(getString).join(typeof delimiter === "string" ? delimiter : "");
|
|
31
|
+
function join$1(value, delimiter) {
|
|
32
|
+
return compact$1(value).map(getString$1).join(typeof delimiter === "string" ? delimiter : "");
|
|
123
33
|
}
|
|
124
34
|
/**
|
|
125
35
|
* Split a string into words _(and other readable parts)_
|
|
126
36
|
* @param value Original string
|
|
127
37
|
* @returns Array of words found in the string
|
|
128
38
|
*/
|
|
129
|
-
function words(value) {
|
|
130
|
-
return typeof value === "string" ? value.match(EXPRESSION_WORDS) ?? [] : [];
|
|
39
|
+
function words$1(value) {
|
|
40
|
+
return typeof value === "string" ? value.match(EXPRESSION_WORDS$1) ?? [] : [];
|
|
131
41
|
}
|
|
132
|
-
|
|
133
|
-
const EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region node_modules/@oscarpalmer/atoms/dist/is.mjs
|
|
42
|
+
var EXPRESSION_WORDS$1 = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
136
43
|
/**
|
|
137
|
-
* Is the value
|
|
44
|
+
* Is the value a number?
|
|
138
45
|
* @param value Value to check
|
|
139
|
-
* @returns `true` if the value is
|
|
46
|
+
* @returns `true` if the value is a `number`, otherwise `false`
|
|
140
47
|
*/
|
|
141
|
-
function
|
|
142
|
-
return value
|
|
143
|
-
}
|
|
144
|
-
const EXPRESSION_WHITESPACE = /^\s*$/;
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region node_modules/@oscarpalmer/toretto/dist/internal/element-value.mjs
|
|
147
|
-
function setElementValue(element, first, second, third, callback) {
|
|
148
|
-
if (!isHTMLOrSVGElement(element)) return;
|
|
149
|
-
if (typeof first === "string") setElementValues(element, first, second, third, callback);
|
|
150
|
-
else if (isAttribute(first)) setElementValues(element, first.name, first.value, third, callback);
|
|
151
|
-
}
|
|
152
|
-
function setElementValues(element, first, second, third, callback) {
|
|
153
|
-
if (!isHTMLOrSVGElement(element)) return;
|
|
154
|
-
if (typeof first === "string") {
|
|
155
|
-
callback(element, first, second, third);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const isArray = Array.isArray(first);
|
|
159
|
-
if (!isArray && !(typeof first === "object" && first !== null)) return;
|
|
160
|
-
const entries = isArray ? first : Object.entries(first).map(([name, value]) => ({
|
|
161
|
-
name,
|
|
162
|
-
value
|
|
163
|
-
}));
|
|
164
|
-
const { length } = entries;
|
|
165
|
-
for (let index = 0; index < length; index += 1) {
|
|
166
|
-
const entry = entries[index];
|
|
167
|
-
if (typeof entry === "object" && typeof entry?.name === "string") callback(element, entry.name, entry.value, third);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function updateElementValue(element, key, value, set, remove, isBoolean, json) {
|
|
171
|
-
if (isBoolean ? value == null : isNullableOrWhitespace(value)) remove.call(element, key);
|
|
172
|
-
else set.call(element, key, json ? JSON.stringify(value) : String(value));
|
|
173
|
-
}
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region node_modules/@oscarpalmer/toretto/dist/internal/attribute.mjs
|
|
176
|
-
function isAttribute(value) {
|
|
177
|
-
return value instanceof Attr || isPlainObject(value) && typeof value.name === "string" && "value" in value;
|
|
178
|
-
}
|
|
179
|
-
function updateAttribute(element, name, value, dispatch) {
|
|
180
|
-
const normalizedName = name.toLowerCase();
|
|
181
|
-
const isBoolean = booleanAttributesSet.has(normalizedName);
|
|
182
|
-
const next = isBoolean ? value === true || typeof value === "string" && (value === "" || value.toLowerCase() === normalizedName) : value == null ? "" : value;
|
|
183
|
-
if (name in element) updateProperty(element, normalizedName, next, dispatch);
|
|
184
|
-
updateElementValue(element, name, isBoolean ? next ? "" : null : value, element.setAttribute, element.removeAttribute, isBoolean, false);
|
|
185
|
-
}
|
|
186
|
-
function updateProperty(element, name, value, dispatch) {
|
|
187
|
-
if (Object.is(element[name], value)) return;
|
|
188
|
-
element[name] = value;
|
|
189
|
-
const event = dispatch !== false && elementEvents[element.tagName]?.[name];
|
|
190
|
-
if (typeof event === "string") element.dispatchEvent(new Event(event, { bubbles: true }));
|
|
48
|
+
function isNumber$1(value) {
|
|
49
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
191
50
|
}
|
|
192
51
|
/**
|
|
193
|
-
*
|
|
52
|
+
* Is the value a plain object?
|
|
53
|
+
* @param value Value to check
|
|
54
|
+
* @returns `true` if the value is a plain object, otherwise `false`
|
|
194
55
|
*/
|
|
195
|
-
|
|
196
|
-
"
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
"default",
|
|
202
|
-
"defer",
|
|
203
|
-
"disabled",
|
|
204
|
-
"formnovalidate",
|
|
205
|
-
"hidden",
|
|
206
|
-
"inert",
|
|
207
|
-
"ismap",
|
|
208
|
-
"itemscope",
|
|
209
|
-
"loop",
|
|
210
|
-
"multiple",
|
|
211
|
-
"muted",
|
|
212
|
-
"nomodule",
|
|
213
|
-
"novalidate",
|
|
214
|
-
"open",
|
|
215
|
-
"playsinline",
|
|
216
|
-
"readonly",
|
|
217
|
-
"required",
|
|
218
|
-
"reversed",
|
|
219
|
-
"selected"
|
|
220
|
-
]);
|
|
221
|
-
const booleanAttributesSet = new Set(booleanAttributes);
|
|
222
|
-
const elementEvents = {
|
|
223
|
-
DETAILS: { open: "toggle" },
|
|
224
|
-
INPUT: {
|
|
225
|
-
checked: "change",
|
|
226
|
-
value: "input"
|
|
227
|
-
},
|
|
228
|
-
SELECT: { value: "change" },
|
|
229
|
-
TEXTAREA: { value: "input" }
|
|
230
|
-
};
|
|
231
|
-
document.createElement("form");
|
|
232
|
-
//#endregion
|
|
233
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/number.mjs
|
|
56
|
+
function isPlainObject$1(value) {
|
|
57
|
+
if (value === null || typeof value !== "object") return false;
|
|
58
|
+
if (Symbol.toStringTag in value || Symbol.iterator in value) return false;
|
|
59
|
+
const prototype = Object.getPrototypeOf(value);
|
|
60
|
+
return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
|
|
61
|
+
}
|
|
234
62
|
/**
|
|
235
63
|
* Clamp a number between a minimum and maximum value
|
|
236
64
|
* @param value Value to clamp
|
|
@@ -239,59 +67,29 @@ document.createElement("form");
|
|
|
239
67
|
* @param loop If `true`, the value will loop around when smaller than the minimum or larger than the maximum _(defaults to `false`)_
|
|
240
68
|
* @returns Clamped value
|
|
241
69
|
*/
|
|
242
|
-
function clamp(value, minimum, maximum, loop) {
|
|
70
|
+
function clamp$1(value, minimum, maximum, loop) {
|
|
243
71
|
if (![
|
|
244
72
|
value,
|
|
245
73
|
minimum,
|
|
246
74
|
maximum
|
|
247
|
-
].every(isNumber)) return NaN;
|
|
75
|
+
].every(isNumber$1)) return NaN;
|
|
248
76
|
if (value < minimum) return loop === true ? maximum : minimum;
|
|
249
77
|
return value > maximum ? loop === true ? minimum : maximum : value;
|
|
250
78
|
}
|
|
251
|
-
|
|
252
|
-
* Get the number value from an unknown value _(based on Lodash)_
|
|
253
|
-
* @param value Original value
|
|
254
|
-
* @returns Original value as a number, or `NaN` if the value is unable to be parsed
|
|
255
|
-
*/
|
|
256
|
-
function getNumber(value) {
|
|
257
|
-
if (typeof value === "number") return value;
|
|
258
|
-
if (typeof value === "bigint" || typeof value === "boolean") return Number(value);
|
|
259
|
-
if (value == null || typeof value === "symbol") return NaN;
|
|
260
|
-
if (typeof value === "function") return getNumber(value());
|
|
261
|
-
let parsed = value.valueOf();
|
|
262
|
-
if (typeof parsed === "object") parsed = parsed.toString();
|
|
263
|
-
if (typeof parsed !== "string") return getNumber(parsed);
|
|
264
|
-
const trimmed = parsed.trim();
|
|
265
|
-
if (trimmed.length === 0) return NaN;
|
|
266
|
-
if (EXPRESSION_ZEROISH.test(parsed)) return 0;
|
|
267
|
-
const isBinary = EXPRESSION_BINARY.test(trimmed);
|
|
268
|
-
if (isBinary || EXPRESSION_OCTAL.test(trimmed)) return Number.parseInt(trimmed.slice(2), isBinary ? 2 : OCTAL_VALUE);
|
|
269
|
-
return Number(EXPRESSION_HEX.test(trimmed) ? trimmed : trimmed.replace(EXPRESSION_UNDERSCORE, ""));
|
|
270
|
-
}
|
|
271
|
-
const EXPRESSION_BINARY = /^0b[01]+$/i;
|
|
272
|
-
const EXPRESSION_HEX = /^0x[0-9a-f]+$/i;
|
|
273
|
-
const EXPRESSION_OCTAL = /^0o[0-7]+$/i;
|
|
274
|
-
const EXPRESSION_UNDERSCORE = /_/g;
|
|
275
|
-
const EXPRESSION_ZEROISH = /^\s*0+\s*$/;
|
|
276
|
-
const OCTAL_VALUE = 8;
|
|
277
|
-
//#endregion
|
|
278
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/sized.mjs
|
|
279
|
-
function getSizedMaximum(first, second) {
|
|
79
|
+
function getSizedMaximum$1(first, second) {
|
|
280
80
|
let actual;
|
|
281
81
|
if (typeof first === "number") actual = first;
|
|
282
|
-
else actual = typeof second === "number" ? second : MAXIMUM_DEFAULT;
|
|
283
|
-
return clamp(actual, 1, MAXIMUM_ABSOLUTE);
|
|
82
|
+
else actual = typeof second === "number" ? second : MAXIMUM_DEFAULT$1;
|
|
83
|
+
return clamp$1(actual, 1, MAXIMUM_ABSOLUTE$1);
|
|
284
84
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
//#endregion
|
|
288
|
-
//#region node_modules/@oscarpalmer/atoms/dist/sized/map.mjs
|
|
85
|
+
var MAXIMUM_ABSOLUTE$1 = 16777216;
|
|
86
|
+
var MAXIMUM_DEFAULT$1 = 1048576;
|
|
289
87
|
/**
|
|
290
88
|
* A Map with a maximum size
|
|
291
89
|
*
|
|
292
90
|
* Behavior is similar to a _LRU_-cache, where the least recently used entries are removed
|
|
293
91
|
*/
|
|
294
|
-
var SizedMap = class extends Map {
|
|
92
|
+
var SizedMap$1 = class extends Map {
|
|
295
93
|
/**
|
|
296
94
|
* The maximum size of the Map
|
|
297
95
|
*/
|
|
@@ -306,7 +104,7 @@ var SizedMap = class extends Map {
|
|
|
306
104
|
return this.#maximumSize;
|
|
307
105
|
}
|
|
308
106
|
constructor(first, second) {
|
|
309
|
-
const maximum = getSizedMaximum(first, second);
|
|
107
|
+
const maximum = getSizedMaximum$1(first, second);
|
|
310
108
|
super();
|
|
311
109
|
this.#maximumSize = maximum;
|
|
312
110
|
if (Array.isArray(first)) {
|
|
@@ -332,9 +130,7 @@ var SizedMap = class extends Map {
|
|
|
332
130
|
return super.set(key, value);
|
|
333
131
|
}
|
|
334
132
|
};
|
|
335
|
-
|
|
336
|
-
//#region node_modules/@oscarpalmer/atoms/dist/function/memoize.mjs
|
|
337
|
-
var Memoized = class {
|
|
133
|
+
var Memoized$1 = class {
|
|
338
134
|
#state;
|
|
339
135
|
/**
|
|
340
136
|
* Maximum cache size
|
|
@@ -349,9 +145,9 @@ var Memoized = class {
|
|
|
349
145
|
return this.#state.cache?.size ?? NaN;
|
|
350
146
|
}
|
|
351
147
|
constructor(callback, options) {
|
|
352
|
-
const cache = new SizedMap(options.cacheSize);
|
|
148
|
+
const cache = new SizedMap$1(options.cacheSize);
|
|
353
149
|
const getter = (...parameters) => {
|
|
354
|
-
const key = options.cacheKey?.(...parameters) ?? (parameters.length === 1 ? parameters[0] : join(parameters.map(getString),
|
|
150
|
+
const key = options.cacheKey?.(...parameters) ?? (parameters.length === 1 ? parameters[0] : join$1(parameters.map(getString$1), "_"));
|
|
355
151
|
if (cache.has(key)) return cache.get(key);
|
|
356
152
|
const value = callback(...parameters);
|
|
357
153
|
cache.set(key, value);
|
|
@@ -410,11 +206,11 @@ var Memoized = class {
|
|
|
410
206
|
return this.#state.getter(...parameters);
|
|
411
207
|
}
|
|
412
208
|
};
|
|
413
|
-
function getMemoizationOptions(input) {
|
|
414
|
-
const { cacheKey, cacheSize } = isPlainObject(input) ? input : {};
|
|
209
|
+
function getMemoizationOptions$1(input) {
|
|
210
|
+
const { cacheKey, cacheSize } = isPlainObject$1(input) ? input : {};
|
|
415
211
|
return {
|
|
416
212
|
cacheKey: typeof cacheKey === "function" ? cacheKey : void 0,
|
|
417
|
-
cacheSize: typeof cacheSize === "number" && cacheSize > 0 ? cacheSize : DEFAULT_CACHE_SIZE
|
|
213
|
+
cacheSize: typeof cacheSize === "number" && cacheSize > 0 ? cacheSize : DEFAULT_CACHE_SIZE$1
|
|
418
214
|
};
|
|
419
215
|
}
|
|
420
216
|
/**
|
|
@@ -423,20 +219,17 @@ function getMemoizationOptions(input) {
|
|
|
423
219
|
* @param options Memoization options
|
|
424
220
|
* @returns Memoized instance
|
|
425
221
|
*/
|
|
426
|
-
function memoize(callback, options) {
|
|
427
|
-
return new Memoized(callback, getMemoizationOptions(options));
|
|
222
|
+
function memoize$1(callback, options) {
|
|
223
|
+
return new Memoized$1(callback, getMemoizationOptions$1(options));
|
|
428
224
|
}
|
|
429
|
-
|
|
430
|
-
const SEPARATOR = "_";
|
|
431
|
-
//#endregion
|
|
432
|
-
//#region node_modules/@oscarpalmer/atoms/dist/string/case.mjs
|
|
225
|
+
var DEFAULT_CACHE_SIZE$1 = 1024;
|
|
433
226
|
/**
|
|
434
227
|
* Convert a string to camel case _(thisIsCamelCase)_
|
|
435
228
|
* @param value String to convert
|
|
436
229
|
* @returns Camel-cased string
|
|
437
230
|
*/
|
|
438
231
|
function camelCase(value) {
|
|
439
|
-
return toCase(
|
|
232
|
+
return toCase("camel", value, true, false);
|
|
440
233
|
}
|
|
441
234
|
/**
|
|
442
235
|
* Capitalize the first letter of a string _(and lowercase the rest)_
|
|
@@ -445,11 +238,11 @@ function camelCase(value) {
|
|
|
445
238
|
*/
|
|
446
239
|
function capitalize(value) {
|
|
447
240
|
if (typeof value !== "string" || value.length === 0) return "";
|
|
448
|
-
memoizedCapitalize ??= memoize((v) => v.length === 1 ? v.toLocaleUpperCase() : `${v.charAt(0).toLocaleUpperCase()}${v.slice(1).toLocaleLowerCase()}`);
|
|
241
|
+
memoizedCapitalize ??= memoize$1((v) => v.length === 1 ? v.toLocaleUpperCase() : `${v.charAt(0).toLocaleUpperCase()}${v.slice(1).toLocaleLowerCase()}`);
|
|
449
242
|
return memoizedCapitalize.run(value);
|
|
450
243
|
}
|
|
451
244
|
function toCase(type, value, capitalizeAny, capitalizeFirst) {
|
|
452
|
-
caseMemoizers[type] ??= memoize(toCaseCallback.bind({
|
|
245
|
+
caseMemoizers[type] ??= memoize$1(toCaseCallback.bind({
|
|
453
246
|
type,
|
|
454
247
|
capitalizeAny,
|
|
455
248
|
capitalizeFirst
|
|
@@ -460,11 +253,11 @@ function toCaseCallback(value) {
|
|
|
460
253
|
if (typeof value !== "string") return "";
|
|
461
254
|
if (value.length < 1) return value;
|
|
462
255
|
const { capitalizeAny, capitalizeFirst, type } = this;
|
|
463
|
-
const parts = words(value);
|
|
256
|
+
const parts = words$1(value);
|
|
464
257
|
const partsLength = parts.length;
|
|
465
258
|
const cased = [];
|
|
466
259
|
for (let partIndex = 0; partIndex < partsLength; partIndex += 1) {
|
|
467
|
-
const items = parts[partIndex].replace(EXPRESSION_ACRONYM, (full, one, two, three) => three ===
|
|
260
|
+
const items = parts[partIndex].replace(EXPRESSION_ACRONYM, (full, one, two, three) => three === "s" ? full : `${one}-${two}${three}`).replace(EXPRESSION_CAMEL_CASE, REPLACEMENT_CAMEL_CASE).split("-");
|
|
468
261
|
const itemsLength = items.length;
|
|
469
262
|
const partResult = [];
|
|
470
263
|
let itemCount = 0;
|
|
@@ -475,31 +268,21 @@ function toCaseCallback(value) {
|
|
|
475
268
|
else partResult.push(capitalize(item));
|
|
476
269
|
itemCount += 1;
|
|
477
270
|
}
|
|
478
|
-
cased.push(join(partResult, delimiters[type]));
|
|
479
|
-
}
|
|
480
|
-
return join(cased, delimiters[type]);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
const DELIMITER_UNDERSCORE = "_";
|
|
489
|
-
const EXPRESSION_CAMEL_CASE = /(\p{Ll})(\p{Lu})/gu;
|
|
490
|
-
const EXPRESSION_ACRONYM = /(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu;
|
|
491
|
-
const REPLACEMENT_CAMEL_CASE = "$1-$2";
|
|
492
|
-
const S = "s";
|
|
493
|
-
const caseMemoizers = {};
|
|
494
|
-
const delimiters = {
|
|
495
|
-
[CASE_CAMEL]: DELIMTER_EMPTY,
|
|
496
|
-
[CASE_KEBAB]: DELIMITER_HYPHEN,
|
|
497
|
-
[CASE_PASCAL]: DELIMTER_EMPTY,
|
|
498
|
-
[CASE_SNAKE]: DELIMITER_UNDERSCORE
|
|
271
|
+
cased.push(join$1(partResult, delimiters[type]));
|
|
272
|
+
}
|
|
273
|
+
return join$1(cased, delimiters[type]);
|
|
274
|
+
}
|
|
275
|
+
var caseMemoizers = {};
|
|
276
|
+
var delimiters = {
|
|
277
|
+
camel: "",
|
|
278
|
+
kebab: "-",
|
|
279
|
+
pascal: "",
|
|
280
|
+
snake: "_"
|
|
499
281
|
};
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
282
|
+
var EXPRESSION_CAMEL_CASE = /(\p{Ll})(\p{Lu})/gu;
|
|
283
|
+
var EXPRESSION_ACRONYM = /(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu;
|
|
284
|
+
var REPLACEMENT_CAMEL_CASE = "$1-$2";
|
|
285
|
+
var memoizedCapitalize;
|
|
503
286
|
function getBoolean(value, defaultValue) {
|
|
504
287
|
return typeof value === "boolean" ? value : defaultValue ?? false;
|
|
505
288
|
}
|
|
@@ -507,16 +290,127 @@ function getStyleValue(element, property, computed) {
|
|
|
507
290
|
const name = camelCase(property);
|
|
508
291
|
return computed ? getComputedStyle(element)[name] : element.style[name];
|
|
509
292
|
}
|
|
510
|
-
|
|
511
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Is the value an event target?
|
|
295
|
+
* @param value Value to check
|
|
296
|
+
* @returns `true` if it's an event target, otherwise `false`
|
|
297
|
+
*/
|
|
298
|
+
function isEventTarget(value) {
|
|
299
|
+
return typeof value === "object" && value != null && typeof value.addEventListener === "function" && typeof value.removeEventListener === "function" && typeof value.dispatchEvent === "function";
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Is the value an HTML or SVG element?
|
|
303
|
+
* @param value Value to check
|
|
304
|
+
* @returns `true` if it's an HTML or SVG element, otherwise `false`
|
|
305
|
+
*/
|
|
306
|
+
function isHTMLOrSVGElement(value) {
|
|
307
|
+
return value instanceof HTMLElement || value instanceof SVGElement;
|
|
308
|
+
}
|
|
309
|
+
new Set([
|
|
310
|
+
Node.ELEMENT_NODE,
|
|
311
|
+
Node.TEXT_NODE,
|
|
312
|
+
Node.PROCESSING_INSTRUCTION_NODE,
|
|
313
|
+
Node.COMMENT_NODE,
|
|
314
|
+
Node.DOCUMENT_TYPE_NODE
|
|
315
|
+
]);
|
|
316
|
+
/**
|
|
317
|
+
* Is the value `undefined`, `null`, or a whitespace-only string?
|
|
318
|
+
* @param value Value to check
|
|
319
|
+
* @returns `true` if the value is nullable or a whitespace-only string, otherwise `false`
|
|
320
|
+
*/
|
|
321
|
+
function isNullableOrWhitespace$1(value) {
|
|
322
|
+
return value == null || EXPRESSION_WHITESPACE$1.test(getString$1(value));
|
|
323
|
+
}
|
|
324
|
+
var EXPRESSION_WHITESPACE$1 = /^\s*$/;
|
|
325
|
+
function setElementValue(element, first, second, third, callback) {
|
|
326
|
+
if (!isHTMLOrSVGElement(element)) return;
|
|
327
|
+
if (typeof first === "string") setElementValues(element, first, second, third, callback);
|
|
328
|
+
else if (isAttribute(first)) setElementValues(element, first.name, first.value, third, callback);
|
|
329
|
+
}
|
|
330
|
+
function setElementValues(element, first, second, third, callback) {
|
|
331
|
+
if (!isHTMLOrSVGElement(element)) return;
|
|
332
|
+
if (typeof first === "string") {
|
|
333
|
+
callback(element, first, second, third);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const isArray = Array.isArray(first);
|
|
337
|
+
if (!isArray && !(typeof first === "object" && first !== null)) return;
|
|
338
|
+
const entries = isArray ? first : Object.entries(first).map(([name, value]) => ({
|
|
339
|
+
name,
|
|
340
|
+
value
|
|
341
|
+
}));
|
|
342
|
+
const { length } = entries;
|
|
343
|
+
for (let index = 0; index < length; index += 1) {
|
|
344
|
+
const entry = entries[index];
|
|
345
|
+
if (typeof entry === "object" && typeof entry?.name === "string") callback(element, entry.name, entry.value, third);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function updateElementValue(element, key, value, set, remove, isBoolean, json) {
|
|
349
|
+
if (isBoolean ? value == null : isNullableOrWhitespace$1(value)) remove.call(element, key);
|
|
350
|
+
else set.call(element, key, json ? JSON.stringify(value) : String(value));
|
|
351
|
+
}
|
|
352
|
+
function isAttribute(value) {
|
|
353
|
+
return value instanceof Attr || isPlainObject$1(value) && typeof value.name === "string" && "value" in value;
|
|
354
|
+
}
|
|
355
|
+
function updateAttribute(element, name, value, dispatch) {
|
|
356
|
+
const normalizedName = name.toLowerCase();
|
|
357
|
+
const isBoolean = booleanAttributesSet.has(normalizedName);
|
|
358
|
+
const next = isBoolean ? value === true || typeof value === "string" && (value === "" || value.toLowerCase() === normalizedName) : value == null ? "" : value;
|
|
359
|
+
if (name in element) updateProperty(element, normalizedName, next, dispatch);
|
|
360
|
+
updateElementValue(element, name, isBoolean ? next ? "" : null : value, element.setAttribute, element.removeAttribute, isBoolean, false);
|
|
361
|
+
}
|
|
362
|
+
function updateProperty(element, name, value, dispatch) {
|
|
363
|
+
if (Object.is(element[name], value)) return;
|
|
364
|
+
element[name] = value;
|
|
365
|
+
const event = dispatch !== false && elementEvents[element.tagName]?.[name];
|
|
366
|
+
if (typeof event === "string") element.dispatchEvent(new Event(event, { bubbles: true }));
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* List of boolean attributes
|
|
370
|
+
*/
|
|
371
|
+
const booleanAttributes = Object.freeze([
|
|
372
|
+
"async",
|
|
373
|
+
"autofocus",
|
|
374
|
+
"autoplay",
|
|
375
|
+
"checked",
|
|
376
|
+
"controls",
|
|
377
|
+
"default",
|
|
378
|
+
"defer",
|
|
379
|
+
"disabled",
|
|
380
|
+
"formnovalidate",
|
|
381
|
+
"hidden",
|
|
382
|
+
"inert",
|
|
383
|
+
"ismap",
|
|
384
|
+
"itemscope",
|
|
385
|
+
"loop",
|
|
386
|
+
"multiple",
|
|
387
|
+
"muted",
|
|
388
|
+
"nomodule",
|
|
389
|
+
"novalidate",
|
|
390
|
+
"open",
|
|
391
|
+
"playsinline",
|
|
392
|
+
"readonly",
|
|
393
|
+
"required",
|
|
394
|
+
"reversed",
|
|
395
|
+
"selected"
|
|
396
|
+
]);
|
|
397
|
+
var booleanAttributesSet = new Set(booleanAttributes);
|
|
398
|
+
var elementEvents = {
|
|
399
|
+
DETAILS: { open: "toggle" },
|
|
400
|
+
INPUT: {
|
|
401
|
+
checked: "change",
|
|
402
|
+
value: "input"
|
|
403
|
+
},
|
|
404
|
+
SELECT: { value: "change" },
|
|
405
|
+
TEXTAREA: { value: "input" }
|
|
406
|
+
};
|
|
407
|
+
document.createElement("form");
|
|
512
408
|
function setAttribute(element, first, second, third) {
|
|
513
409
|
setElementValue(element, first, second, third, updateAttribute);
|
|
514
410
|
}
|
|
515
411
|
function setAttributes(element, attributes, dispatch) {
|
|
516
412
|
setElementValues(element, attributes, null, dispatch, updateAttribute);
|
|
517
413
|
}
|
|
518
|
-
//#endregion
|
|
519
|
-
//#region node_modules/@oscarpalmer/toretto/dist/style.mjs
|
|
520
414
|
/**
|
|
521
415
|
* Get styles from an element
|
|
522
416
|
* @param element Element to get the styles from
|
|
@@ -581,36 +475,12 @@ function updateStyleProperty(element, key, value) {
|
|
|
581
475
|
this.style[property] = "";
|
|
582
476
|
}, false, false);
|
|
583
477
|
}
|
|
584
|
-
//#endregion
|
|
585
|
-
//#region src/models/style.model.ts
|
|
586
|
-
const CSS_TABELA = "tabela";
|
|
587
|
-
const CSS_TABELA_CELL = "tabela__cell";
|
|
588
|
-
const CSS_TABELA_CELL_BODY = "tabela__cell--body";
|
|
589
|
-
const CSS_TABELA_CELL_FOOTER = "tabela__cell--footer";
|
|
590
|
-
const CSS_TABELA_FAKER = "tabela__faker";
|
|
591
|
-
const CSS_TABELA_HEADING = "tabela__heading";
|
|
592
|
-
const CSS_TABELA_HEADING_CONTENT = "tabela__heading__content";
|
|
593
|
-
const CSS_TABELA_HEADING_SORTER = "tabela__heading__sorter";
|
|
594
|
-
const CSS_TABELA_ROW = "tabela__row";
|
|
595
|
-
const CSS_TABELA_ROW_BODY = "tabela__row--body";
|
|
596
|
-
const CSS_TABELA_ROW_FOOTER = "tabela__row--footer";
|
|
597
|
-
const CSS_TABELA_ROW_GROUP = "tabela__row--group tabela__group";
|
|
598
|
-
const CSS_TABELA_ROW_HEADER = "tabela__row--header";
|
|
599
|
-
const CSS_TABELA_ROW_SELECTED = "tabela__row--selected";
|
|
600
|
-
const CSS_TABELA_ROWGROUP = "tabela__rowgroup";
|
|
601
|
-
const CSS_TABELA_ROWGROUP_BODY = "tabela__rowgroup--body";
|
|
602
|
-
const CSS_TABELA_ROWGROUP_FOOTER = "tabela__rowgroup--footer";
|
|
603
|
-
const CSS_TABELA_ROWGROUP_HEADER = "tabela__rowgroup--header";
|
|
604
|
-
const CSS_TABELA_SELECTION = "tabela__selection";
|
|
605
|
-
const CSS_TABELA_TABLE = "tabela__table";
|
|
606
|
-
//#endregion
|
|
607
|
-
//#region src/helpers/dom.helpers.ts
|
|
608
478
|
function createCell(width, body) {
|
|
609
479
|
const cell = createElement("div", {
|
|
610
|
-
className:
|
|
480
|
+
className: "tabela__cell",
|
|
611
481
|
role: "cell"
|
|
612
482
|
}, {}, { width: `${width}px` });
|
|
613
|
-
if (body ?? true) cell.classList.add(
|
|
483
|
+
if (body ?? true) cell.classList.add("tabela__cell--body");
|
|
614
484
|
return cell;
|
|
615
485
|
}
|
|
616
486
|
function createElement(tagName, properties, attributes, style) {
|
|
@@ -624,9 +494,9 @@ function createElement(tagName, properties, attributes, style) {
|
|
|
624
494
|
}
|
|
625
495
|
function createRowGroup(withRow) {
|
|
626
496
|
const group = createElement("div", {
|
|
627
|
-
className:
|
|
497
|
+
className: "tabela__rowgroup",
|
|
628
498
|
role: "rowgroup"
|
|
629
|
-
});
|
|
499
|
+
}, {}, {});
|
|
630
500
|
if (!(withRow ?? true)) return group;
|
|
631
501
|
const row = createRow();
|
|
632
502
|
group.append(row);
|
|
@@ -637,14 +507,12 @@ function createRowGroup(withRow) {
|
|
|
637
507
|
}
|
|
638
508
|
function createRow() {
|
|
639
509
|
return createElement("div", {
|
|
640
|
-
className:
|
|
510
|
+
className: "tabela__row",
|
|
641
511
|
role: "row"
|
|
642
512
|
}, {}, { height: "32px" });
|
|
643
513
|
}
|
|
644
|
-
//#endregion
|
|
645
|
-
//#region src/components/body.component.ts
|
|
646
514
|
function createFaker() {
|
|
647
|
-
return createElement("div", { className:
|
|
515
|
+
return createElement("div", { className: "tabela__faker" }, {}, {});
|
|
648
516
|
}
|
|
649
517
|
var BodyComponent = class {
|
|
650
518
|
elements = {
|
|
@@ -654,7 +522,7 @@ var BodyComponent = class {
|
|
|
654
522
|
constructor() {
|
|
655
523
|
const group = createRowGroup(false);
|
|
656
524
|
this.elements.group = group;
|
|
657
|
-
group.className +=
|
|
525
|
+
group.className += " tabela__rowgroup--body";
|
|
658
526
|
group.tabIndex = 0;
|
|
659
527
|
group.setAttribute("data-event", "body");
|
|
660
528
|
group.append(this.elements.faker);
|
|
@@ -664,8 +532,6 @@ var BodyComponent = class {
|
|
|
664
532
|
this.elements.group = void 0;
|
|
665
533
|
}
|
|
666
534
|
};
|
|
667
|
-
//#endregion
|
|
668
|
-
//#region src/components/footer.component.ts
|
|
669
535
|
var FooterComponent = class {
|
|
670
536
|
elements;
|
|
671
537
|
constructor() {
|
|
@@ -675,8 +541,8 @@ var FooterComponent = class {
|
|
|
675
541
|
row,
|
|
676
542
|
cells: []
|
|
677
543
|
};
|
|
678
|
-
group.className +=
|
|
679
|
-
row.className +=
|
|
544
|
+
group.className += " tabela__rowgroup--footer";
|
|
545
|
+
row.className += " tabela__row--footer";
|
|
680
546
|
}
|
|
681
547
|
destroy() {
|
|
682
548
|
this.elements.cells.length = 0;
|
|
@@ -690,15 +556,13 @@ var FooterComponent = class {
|
|
|
690
556
|
elements.row.innerHTML = "";
|
|
691
557
|
for (let index = 0; index < length; index += 1) {
|
|
692
558
|
const cell = createCell(columns[index].options.width ?? 4, false);
|
|
693
|
-
cell.className +=
|
|
559
|
+
cell.className += " tabela__cell--footer";
|
|
694
560
|
cell.innerHTML = " ";
|
|
695
561
|
elements.cells.push(cell);
|
|
696
562
|
elements.row.append(cell);
|
|
697
563
|
}
|
|
698
564
|
}
|
|
699
565
|
};
|
|
700
|
-
//#endregion
|
|
701
|
-
//#region src/components/header.component.ts
|
|
702
566
|
var HeaderComponent = class {
|
|
703
567
|
elements;
|
|
704
568
|
constructor() {
|
|
@@ -707,8 +571,8 @@ var HeaderComponent = class {
|
|
|
707
571
|
group,
|
|
708
572
|
row
|
|
709
573
|
};
|
|
710
|
-
group.className +=
|
|
711
|
-
row.className +=
|
|
574
|
+
group.className += " tabela__rowgroup--header";
|
|
575
|
+
row.className += " tabela__row--header";
|
|
712
576
|
}
|
|
713
577
|
destroy() {
|
|
714
578
|
this.elements.group = void 0;
|
|
@@ -719,8 +583,6 @@ var HeaderComponent = class {
|
|
|
719
583
|
this.elements.row.append(...columns.map((column) => column.elements.wrapper));
|
|
720
584
|
}
|
|
721
585
|
};
|
|
722
|
-
//#endregion
|
|
723
|
-
//#region src/components/column.component.ts
|
|
724
586
|
var ColumnComponent = class {
|
|
725
587
|
elements;
|
|
726
588
|
options;
|
|
@@ -742,17 +604,17 @@ var ColumnComponent = class {
|
|
|
742
604
|
};
|
|
743
605
|
function createHeading(field, title, width) {
|
|
744
606
|
const wrapper = createElement("div", {
|
|
745
|
-
className:
|
|
607
|
+
className: "tabela__heading",
|
|
746
608
|
role: "columnheader"
|
|
747
609
|
}, {
|
|
748
610
|
"data-event": "heading",
|
|
749
611
|
"data-field": field
|
|
750
612
|
}, { width: `${width}px` });
|
|
751
613
|
const content = createElement("div", {
|
|
752
|
-
className:
|
|
614
|
+
className: "tabela__heading__content",
|
|
753
615
|
textContent: title
|
|
754
|
-
});
|
|
755
|
-
const sorter = createElement("div", { className:
|
|
616
|
+
}, {}, {});
|
|
617
|
+
const sorter = createElement("div", { className: "tabela__heading__sorter" }, {}, {});
|
|
756
618
|
wrapper.append(content, sorter);
|
|
757
619
|
return {
|
|
758
620
|
content,
|
|
@@ -760,8 +622,6 @@ function createHeading(field, title, width) {
|
|
|
760
622
|
wrapper
|
|
761
623
|
};
|
|
762
624
|
}
|
|
763
|
-
//#endregion
|
|
764
|
-
//#region src/managers/column.manager.ts
|
|
765
625
|
var ColumnManager = class {
|
|
766
626
|
items = [];
|
|
767
627
|
constructor(state) {
|
|
@@ -774,9 +634,6 @@ var ColumnManager = class {
|
|
|
774
634
|
this.items = void 0;
|
|
775
635
|
this.state = void 0;
|
|
776
636
|
}
|
|
777
|
-
get(field) {
|
|
778
|
-
return this.items.find((item) => item.options.field === field);
|
|
779
|
-
}
|
|
780
637
|
remove(value) {
|
|
781
638
|
const { items, state } = this;
|
|
782
639
|
const { components, managers } = state;
|
|
@@ -802,31 +659,6 @@ var ColumnManager = class {
|
|
|
802
659
|
footer.update(items);
|
|
803
660
|
}
|
|
804
661
|
};
|
|
805
|
-
//#endregion
|
|
806
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/array/chunk.mjs
|
|
807
|
-
/**
|
|
808
|
-
* Chunk an array into smaller arrays
|
|
809
|
-
* @param array Array to chunk
|
|
810
|
-
* @param size Size of each chunk _(minimum is `1`, maximum is `5000`; defaults to `5000`)_
|
|
811
|
-
* @returns Array of arrays
|
|
812
|
-
*/
|
|
813
|
-
function chunk(array, size) {
|
|
814
|
-
if (!Array.isArray(array)) return [];
|
|
815
|
-
if (array.length === 0) return [];
|
|
816
|
-
const { length } = array;
|
|
817
|
-
const actualSize = typeof size === "number" && size > 0 && size <= MAX_SIZE ? size : MAX_SIZE;
|
|
818
|
-
if (length <= actualSize) return [array];
|
|
819
|
-
const chunks = [];
|
|
820
|
-
let index = 0;
|
|
821
|
-
while (index < length) {
|
|
822
|
-
chunks.push(array.slice(index, index + actualSize));
|
|
823
|
-
index += actualSize;
|
|
824
|
-
}
|
|
825
|
-
return chunks;
|
|
826
|
-
}
|
|
827
|
-
const MAX_SIZE = 5e3;
|
|
828
|
-
//#endregion
|
|
829
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/array/callbacks.mjs
|
|
830
662
|
function getArrayCallback(value) {
|
|
831
663
|
switch (typeof value) {
|
|
832
664
|
case "function": return value;
|
|
@@ -842,8 +674,26 @@ function getArrayCallbacks(bool, key, value) {
|
|
|
842
674
|
value: getArrayCallback(value)
|
|
843
675
|
};
|
|
844
676
|
}
|
|
845
|
-
|
|
846
|
-
|
|
677
|
+
function findValue(type, array, parameters) {
|
|
678
|
+
const findIndex = type === FIND_VALUE_INDEX;
|
|
679
|
+
if (!Array.isArray(array) || array.length === 0) return findIndex ? -1 : void 0;
|
|
680
|
+
const { bool, key, value } = getParameters(parameters);
|
|
681
|
+
const callbacks = getArrayCallbacks(bool, key);
|
|
682
|
+
if (callbacks?.bool == null && callbacks?.keyed == null) return findIndex ? array.indexOf(value) : array.find((item) => Object.is(item, value));
|
|
683
|
+
if (callbacks.bool != null) {
|
|
684
|
+
const index = array.findIndex(callbacks.bool);
|
|
685
|
+
return findIndex ? index : array[index];
|
|
686
|
+
}
|
|
687
|
+
return findValueInArray(array, callbacks.keyed, value, findIndex);
|
|
688
|
+
}
|
|
689
|
+
function findValueInArray(array, callback, value, findIndex) {
|
|
690
|
+
const { length } = array;
|
|
691
|
+
for (let index = 0; index < length; index += 1) {
|
|
692
|
+
const item = array[index];
|
|
693
|
+
if (Object.is(callback?.(item, index, array), value)) return findIndex ? index : item;
|
|
694
|
+
}
|
|
695
|
+
return findIndex ? -1 : void 0;
|
|
696
|
+
}
|
|
847
697
|
function findValues(type, array, parameters, mapper) {
|
|
848
698
|
const result = {
|
|
849
699
|
matched: [],
|
|
@@ -886,14 +736,149 @@ function getParameters(original) {
|
|
|
886
736
|
value: length === 1 && typeof original[0] !== "function" ? original[0] : original[1]
|
|
887
737
|
};
|
|
888
738
|
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
739
|
+
var FIND_VALUE_INDEX = "index";
|
|
740
|
+
var UNIQUE_THRESHOLD = 100;
|
|
741
|
+
function filter(array, ...parameters) {
|
|
742
|
+
return findValues("all", array, parameters).matched;
|
|
743
|
+
}
|
|
744
|
+
filter.remove = removeFiltered;
|
|
745
|
+
function removeFiltered(array, ...parameters) {
|
|
746
|
+
return findValues("all", array, parameters).notMatched;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Is the value a constructor function?
|
|
750
|
+
* @param value Value to check
|
|
751
|
+
* @returns `true` if the value is a constructor function, otherwise `false`
|
|
752
|
+
*/
|
|
753
|
+
function isConstructor(value) {
|
|
754
|
+
return typeof value === "function" && value.prototype?.constructor === value;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Is the value a key?
|
|
758
|
+
* @param value Value to check
|
|
759
|
+
* @returns `true` if the value is a `Key` _(`number` or `string`)_, otherwise `false`
|
|
760
|
+
*/
|
|
761
|
+
function isKey(value) {
|
|
762
|
+
return typeof value === "number" || typeof value === "string";
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Is the value a number?
|
|
766
|
+
* @param value Value to check
|
|
767
|
+
* @returns `true` if the value is a `number`, otherwise `false`
|
|
768
|
+
*/
|
|
769
|
+
function isNumber(value) {
|
|
770
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Is the value a plain object?
|
|
774
|
+
* @param value Value to check
|
|
775
|
+
* @returns `true` if the value is a plain object, otherwise `false`
|
|
776
|
+
*/
|
|
777
|
+
function isPlainObject(value) {
|
|
778
|
+
if (value === null || typeof value !== "object") return false;
|
|
779
|
+
if (Symbol.toStringTag in value || Symbol.iterator in value) return false;
|
|
780
|
+
const prototype = Object.getPrototypeOf(value);
|
|
781
|
+
return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Is the value a typed array?
|
|
785
|
+
* @param value Value to check
|
|
786
|
+
* @returns `true` if the value is a typed array, otherwise `false`
|
|
787
|
+
*/
|
|
788
|
+
function isTypedArray(value) {
|
|
789
|
+
TYPED_ARRAYS ??= new Set([
|
|
790
|
+
Int8Array,
|
|
791
|
+
Uint8Array,
|
|
792
|
+
Uint8ClampedArray,
|
|
793
|
+
Int16Array,
|
|
794
|
+
Uint16Array,
|
|
795
|
+
Int32Array,
|
|
796
|
+
Uint32Array,
|
|
797
|
+
Float32Array,
|
|
798
|
+
Float64Array,
|
|
799
|
+
BigInt64Array,
|
|
800
|
+
BigUint64Array
|
|
801
|
+
]);
|
|
802
|
+
return TYPED_ARRAYS.has(value?.constructor);
|
|
803
|
+
}
|
|
804
|
+
var TYPED_ARRAYS;
|
|
805
|
+
/**
|
|
806
|
+
* Chunk an array into smaller arrays
|
|
807
|
+
* @param array Array to chunk
|
|
808
|
+
* @param size Size of each chunk _(minimum is `1`, maximum is `5000`; defaults to `5000`)_
|
|
809
|
+
* @returns Array of arrays
|
|
810
|
+
*/
|
|
811
|
+
function chunk(array, size) {
|
|
812
|
+
if (!Array.isArray(array)) return [];
|
|
813
|
+
if (array.length === 0) return [];
|
|
814
|
+
const { length } = array;
|
|
815
|
+
const actualSize = typeof size === "number" && size > 0 && size <= MAX_SIZE ? size : MAX_SIZE;
|
|
816
|
+
if (length <= actualSize) return [array];
|
|
817
|
+
const chunks = [];
|
|
818
|
+
let index = 0;
|
|
819
|
+
while (index < length) {
|
|
820
|
+
chunks.push(array.slice(index, index + actualSize));
|
|
821
|
+
index += actualSize;
|
|
822
|
+
}
|
|
823
|
+
return chunks;
|
|
824
|
+
}
|
|
825
|
+
var MAX_SIZE = 5e3;
|
|
826
|
+
function compact(array, strict) {
|
|
827
|
+
if (!Array.isArray(array)) return [];
|
|
828
|
+
if (strict === true) return array.filter(Boolean);
|
|
829
|
+
const { length } = array;
|
|
830
|
+
const compacted = [];
|
|
831
|
+
for (let index = 0; index < length; index += 1) {
|
|
832
|
+
const item = array[index];
|
|
833
|
+
if (item != null) compacted.push(item);
|
|
834
|
+
}
|
|
835
|
+
return compacted;
|
|
836
|
+
}
|
|
837
|
+
function indexOf(array, ...parameters) {
|
|
838
|
+
return findValue(FIND_VALUE_INDEX, array, parameters);
|
|
839
|
+
}
|
|
840
|
+
function getName(start, haystack, needle) {
|
|
841
|
+
if (start === 0) return haystack === needle ? POSITION_SAME : POSITION_START;
|
|
842
|
+
return start + needle === haystack ? POSITION_END : POSITION_INSIDE;
|
|
843
|
+
}
|
|
844
|
+
function getPosition$1(haystack, needle, key) {
|
|
845
|
+
if (!Array.isArray(haystack) || !Array.isArray(needle)) return invalid;
|
|
846
|
+
const haystackLength = haystack.length;
|
|
847
|
+
const needleLength = needle.length;
|
|
848
|
+
if (haystackLength === 0 || needleLength === 0) return outside;
|
|
849
|
+
if (needleLength > haystackLength) return outside;
|
|
850
|
+
const callback = getArrayCallback(key);
|
|
851
|
+
const limit = haystackLength - needleLength + 1;
|
|
852
|
+
let needleValues = callback == null ? needle : needle.slice();
|
|
853
|
+
if (callback != null) for (let needleIndex = 0; needleIndex < needleLength; needleIndex += 1) needleValues[needleIndex] = callback(needle[needleIndex], needleIndex, needle);
|
|
854
|
+
for (let haystackIndex = 0; haystackIndex < limit; haystackIndex += 1) {
|
|
855
|
+
let haystackItem = haystack[haystackIndex];
|
|
856
|
+
let haystackValue = callback?.(haystackItem, haystackIndex, haystack) ?? haystackItem;
|
|
857
|
+
if (!Object.is(haystackValue, needleValues[0])) continue;
|
|
858
|
+
if (needleLength === 1) return [haystackIndex, getName(haystackIndex, haystackLength, needleLength)];
|
|
859
|
+
for (let needleIndex = 1; needleIndex < needleLength; needleIndex += 1) {
|
|
860
|
+
haystackItem = haystack[haystackIndex + needleIndex];
|
|
861
|
+
haystackValue = callback?.(haystackItem, haystackIndex + needleIndex, haystack) ?? haystackItem;
|
|
862
|
+
if (!Object.is(haystackValue, needleValues[needleIndex])) break;
|
|
863
|
+
if (needleIndex === needleLength - 1) return [haystackIndex, getName(haystackIndex, haystackLength, needleLength)];
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return outside;
|
|
867
|
+
}
|
|
868
|
+
function indexOfArray(haystack, needle, key) {
|
|
869
|
+
return getPosition$1(haystack, needle, key)[0];
|
|
870
|
+
}
|
|
871
|
+
var POSITION_END = "end";
|
|
872
|
+
var POSITION_INSIDE = "inside";
|
|
873
|
+
var POSITION_INVALID = "invalid";
|
|
874
|
+
var POSITION_OUTSIDE = "outside";
|
|
875
|
+
var POSITION_SAME = "same";
|
|
876
|
+
var POSITION_START = "start";
|
|
877
|
+
var invalid = [-1, POSITION_INVALID];
|
|
878
|
+
var outside = [-1, POSITION_OUTSIDE];
|
|
892
879
|
function select(array, ...parameters) {
|
|
893
880
|
return findValues("all", array, parameters, parameters.pop()).matched;
|
|
894
881
|
}
|
|
895
|
-
//#endregion
|
|
896
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/math/aggregate.mjs
|
|
897
882
|
function aggregate(type, array, key) {
|
|
898
883
|
const length = Array.isArray(array) ? array.length : 0;
|
|
899
884
|
if (length === 0) return {
|
|
@@ -932,14 +917,43 @@ function getAggregated(type, array, key) {
|
|
|
932
917
|
const aggregated = aggregate(type, array, key);
|
|
933
918
|
return aggregated.count > 0 ? aggregated.value : NaN;
|
|
934
919
|
}
|
|
935
|
-
|
|
920
|
+
var aggregators = {
|
|
936
921
|
average: calculateSum,
|
|
937
922
|
max: (current, value, notNumber) => notNumber || value > current ? value : current,
|
|
938
923
|
min: (current, value, notNumber) => notNumber || value < current ? value : current,
|
|
939
924
|
sum: calculateSum
|
|
940
925
|
};
|
|
941
|
-
|
|
942
|
-
|
|
926
|
+
/**
|
|
927
|
+
* Get the string value from any value
|
|
928
|
+
* @param value Original value
|
|
929
|
+
* @returns String representation of the value
|
|
930
|
+
*/
|
|
931
|
+
function getString(value) {
|
|
932
|
+
if (typeof value === "string") return value;
|
|
933
|
+
if (value == null) return "";
|
|
934
|
+
if (typeof value === "function") return getString(value());
|
|
935
|
+
if (typeof value !== "object") return String(value);
|
|
936
|
+
const asString = String(value.valueOf?.() ?? value);
|
|
937
|
+
return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Join an array of values into a string
|
|
941
|
+
* @param value Array of values
|
|
942
|
+
* @param delimiter Delimiter to use between values
|
|
943
|
+
* @returns Joined string
|
|
944
|
+
*/
|
|
945
|
+
function join(value, delimiter) {
|
|
946
|
+
return compact(value).map(getString).join(typeof delimiter === "string" ? delimiter : "");
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Split a string into words _(and other readable parts)_
|
|
950
|
+
* @param value Original string
|
|
951
|
+
* @returns Array of words found in the string
|
|
952
|
+
*/
|
|
953
|
+
function words(value) {
|
|
954
|
+
return typeof value === "string" ? value.match(EXPRESSION_WORDS) ?? [] : [];
|
|
955
|
+
}
|
|
956
|
+
var EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
943
957
|
function getCompareHandlers(owner, options) {
|
|
944
958
|
const { get, register, unregister } = getHandlers(owner, options);
|
|
945
959
|
return {
|
|
@@ -973,9 +987,7 @@ function getHandlers(owner, options) {
|
|
|
973
987
|
function isConstructable(value) {
|
|
974
988
|
return typeof value === "object" && value !== null;
|
|
975
989
|
}
|
|
976
|
-
|
|
977
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/value/compare.mjs
|
|
978
|
-
const COMPARE_NAME = "compare";
|
|
990
|
+
var COMPARE_NAME = "compare";
|
|
979
991
|
/**
|
|
980
992
|
* Compare two values _(for sorting purposes)_
|
|
981
993
|
* @param first First value
|
|
@@ -1046,14 +1058,12 @@ function getComparisonParts(value) {
|
|
|
1046
1058
|
if (Array.isArray(value)) return value;
|
|
1047
1059
|
return typeof value === "object" ? [value] : words(getString(value));
|
|
1048
1060
|
}
|
|
1049
|
-
|
|
1061
|
+
var comparators$1 = {
|
|
1050
1062
|
bigint: compareNumbers,
|
|
1051
1063
|
boolean: compareNumbers,
|
|
1052
1064
|
number: compareNumbers,
|
|
1053
1065
|
symbol: compareSymbols
|
|
1054
1066
|
};
|
|
1055
|
-
//#endregion
|
|
1056
|
-
//#region node_modules/@oscarpalmer/atoms/dist/array/sort.mjs
|
|
1057
1067
|
function getCallback(value, key, forObject) {
|
|
1058
1068
|
if (key != null) return;
|
|
1059
1069
|
if (forObject && typeof value.value === "function") return value.value;
|
|
@@ -1111,8 +1121,56 @@ function sort(array, first, second) {
|
|
|
1111
1121
|
return 0;
|
|
1112
1122
|
});
|
|
1113
1123
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1124
|
+
function swap(array, first, second, third) {
|
|
1125
|
+
if (!Array.isArray(array)) return [];
|
|
1126
|
+
if (array.length === 0) return array;
|
|
1127
|
+
if (Array.isArray(first) && Array.isArray(second)) return swapArrays(array, first, second, third);
|
|
1128
|
+
return swapValues(array, first, second, third);
|
|
1129
|
+
}
|
|
1130
|
+
swap.indices = swapIndices;
|
|
1131
|
+
function swapArrays(array, from, to, key) {
|
|
1132
|
+
if (from.length === 0 || to.length === 0) return array;
|
|
1133
|
+
if (from.length === 1 && to.length === 1) return swapValues(array, from[0], to[0], key);
|
|
1134
|
+
const fromIndex = indexOfArray(array, from, key);
|
|
1135
|
+
const toIndex = indexOfArray(array, to, key);
|
|
1136
|
+
if (fromIndex === -1 || toIndex === -1) return array;
|
|
1137
|
+
const first = fromIndex < toIndex ? from : to;
|
|
1138
|
+
const second = fromIndex < toIndex ? to : from;
|
|
1139
|
+
const firstIndex = first === from ? fromIndex : toIndex;
|
|
1140
|
+
const secondIndex = first === from ? toIndex : fromIndex;
|
|
1141
|
+
const firstEnd = firstIndex + first.length - 1;
|
|
1142
|
+
if (firstIndex <= secondIndex + second.length - 1 && firstEnd >= secondIndex) return array;
|
|
1143
|
+
array.splice(firstIndex, first.length, ...second);
|
|
1144
|
+
array.splice(secondIndex, second.length, ...first);
|
|
1145
|
+
return array;
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Swap two indiced items in an array
|
|
1149
|
+
*
|
|
1150
|
+
* If either index is out of bounds, the array will be returned unchanged
|
|
1151
|
+
* @param array Array of items to swap
|
|
1152
|
+
* @param first First index _(can be negative to count from the end)_
|
|
1153
|
+
* @param second Second index _(can be negative to count from the end)_
|
|
1154
|
+
* @returns Original array with items swapped _(or unchanged if unable to swap)_
|
|
1155
|
+
*/
|
|
1156
|
+
function swapIndices(array, first, second) {
|
|
1157
|
+
if (!Array.isArray(array) || array.length === 0) return [];
|
|
1158
|
+
if (typeof first !== "number" || typeof second !== "number") return array;
|
|
1159
|
+
const firstIndex = first < 0 ? array.length + first : first;
|
|
1160
|
+
const secondIndex = second < 0 ? array.length + second : second;
|
|
1161
|
+
if (firstIndex === secondIndex || firstIndex >= array.length || secondIndex >= array.length) return array;
|
|
1162
|
+
const temp = array[firstIndex];
|
|
1163
|
+
array[firstIndex] = array[secondIndex];
|
|
1164
|
+
array[secondIndex] = temp;
|
|
1165
|
+
return array;
|
|
1166
|
+
}
|
|
1167
|
+
function swapValues(array, from, to, key) {
|
|
1168
|
+
const callback = getArrayCallback(key);
|
|
1169
|
+
const first = callback == null ? array.indexOf(from) : indexOf(array, callback, callback(from, void 0, []));
|
|
1170
|
+
const second = callback == null ? array.indexOf(to) : indexOf(array, callback, callback(to, void 0, []));
|
|
1171
|
+
if (first === second || first === -1 || second === -1) return array;
|
|
1172
|
+
return swapIndices(array, first, second);
|
|
1173
|
+
}
|
|
1116
1174
|
function getMapValues(array, first, second, arrays) {
|
|
1117
1175
|
if (!Array.isArray(array)) return /* @__PURE__ */ new Map();
|
|
1118
1176
|
const { length } = array;
|
|
@@ -1137,8 +1195,6 @@ toMap.arrays = toMapArrays;
|
|
|
1137
1195
|
function toMapArrays(array, first, second) {
|
|
1138
1196
|
return getMapValues(array, first, second, true);
|
|
1139
1197
|
}
|
|
1140
|
-
//#endregion
|
|
1141
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/array/group.mjs
|
|
1142
1198
|
function groupValues(array, key, value, arrays) {
|
|
1143
1199
|
if (!Array.isArray(array) || array.length === 0) return {};
|
|
1144
1200
|
const { length } = array;
|
|
@@ -1156,8 +1212,6 @@ function groupValues(array, key, value, arrays) {
|
|
|
1156
1212
|
}
|
|
1157
1213
|
return record;
|
|
1158
1214
|
}
|
|
1159
|
-
//#endregion
|
|
1160
|
-
//#region node_modules/@oscarpalmer/atoms/dist/array/to-record.mjs
|
|
1161
1215
|
function toRecord(array, first, second) {
|
|
1162
1216
|
return groupValues(array, first, second, false);
|
|
1163
1217
|
}
|
|
@@ -1165,199 +1219,31 @@ toRecord.arrays = toRecordArrays;
|
|
|
1165
1219
|
function toRecordArrays(array, first, second) {
|
|
1166
1220
|
return groupValues(array, first, second, true);
|
|
1167
1221
|
}
|
|
1168
|
-
//#endregion
|
|
1169
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/function/timer.mjs
|
|
1170
|
-
function getInterval(value) {
|
|
1171
|
-
return typeof value === "number" && value > 0 ? value : 0;
|
|
1172
|
-
}
|
|
1173
|
-
function getTimer(type, callback, time) {
|
|
1174
|
-
const interval = getInterval(time);
|
|
1175
|
-
function run(now) {
|
|
1176
|
-
start ??= now;
|
|
1177
|
-
if (interval === 0 || now - start >= interval - OFFSET) {
|
|
1178
|
-
if (throttle) start = now;
|
|
1179
|
-
callback(...args);
|
|
1180
|
-
} else frame = requestAnimationFrame(run);
|
|
1181
|
-
}
|
|
1182
|
-
const throttle = type === TIMER_THROTTLE;
|
|
1183
|
-
let args;
|
|
1184
|
-
let frame;
|
|
1185
|
-
let start;
|
|
1186
|
-
const timer = (...parameters) => {
|
|
1187
|
-
timer.cancel();
|
|
1188
|
-
args = parameters;
|
|
1189
|
-
frame = requestAnimationFrame(run);
|
|
1190
|
-
};
|
|
1191
|
-
timer.cancel = () => {
|
|
1192
|
-
cancelAnimationFrame(frame);
|
|
1193
|
-
};
|
|
1194
|
-
return timer;
|
|
1195
|
-
}
|
|
1196
|
-
const OFFSET = 5;
|
|
1197
|
-
const TIMER_THROTTLE = "throttle";
|
|
1198
|
-
const TIMER_WAIT = "wait";
|
|
1199
|
-
//#endregion
|
|
1200
|
-
//#region node_modules/@oscarpalmer/atoms/dist/promise/models.mjs
|
|
1201
|
-
const PROMISE_ABORT_EVENT = "abort";
|
|
1202
|
-
const PROMISE_ABORT_OPTIONS = { once: true };
|
|
1203
|
-
//#endregion
|
|
1204
|
-
//#region node_modules/@oscarpalmer/atoms/dist/promise/helpers.mjs
|
|
1205
|
-
function getNumberOrDefault(value) {
|
|
1206
|
-
return typeof value === "number" && value > 0 ? value : 0;
|
|
1207
|
-
}
|
|
1208
|
-
function getPromiseOptions(input) {
|
|
1209
|
-
if (typeof input === "number") return { time: getNumberOrDefault(input) };
|
|
1210
|
-
if (input instanceof AbortSignal) return {
|
|
1211
|
-
signal: input,
|
|
1212
|
-
time: 0
|
|
1213
|
-
};
|
|
1214
|
-
const options = typeof input === "object" && input !== null ? input : {};
|
|
1215
|
-
return {
|
|
1216
|
-
signal: options.signal instanceof AbortSignal ? options.signal : void 0,
|
|
1217
|
-
time: getNumberOrDefault(options.time)
|
|
1218
|
-
};
|
|
1219
|
-
}
|
|
1220
|
-
//#endregion
|
|
1221
|
-
//#region node_modules/@oscarpalmer/atoms/dist/promise/misc.mjs
|
|
1222
|
-
function settlePromise(aborter, settler, value, signal) {
|
|
1223
|
-
signal?.removeEventListener(PROMISE_ABORT_EVENT, aborter);
|
|
1224
|
-
settler(value);
|
|
1225
|
-
}
|
|
1226
|
-
//#endregion
|
|
1227
|
-
//#region node_modules/@oscarpalmer/atoms/dist/promise/delay.mjs
|
|
1228
|
-
function delay(options) {
|
|
1229
|
-
const { signal, time } = getPromiseOptions(options);
|
|
1230
|
-
if (signal?.aborted ?? false) return Promise.reject(signal.reason);
|
|
1231
|
-
function abort() {
|
|
1232
|
-
timer.cancel();
|
|
1233
|
-
rejector(signal.reason);
|
|
1234
|
-
}
|
|
1235
|
-
const timer = getTimer(TIMER_WAIT, () => {
|
|
1236
|
-
settlePromise(abort, resolver, void 0, signal);
|
|
1237
|
-
}, time);
|
|
1238
|
-
signal?.addEventListener(PROMISE_ABORT_EVENT, abort, PROMISE_ABORT_OPTIONS);
|
|
1239
|
-
let rejector;
|
|
1240
|
-
let resolver;
|
|
1241
|
-
return new Promise((resolve, reject) => {
|
|
1242
|
-
rejector = reject;
|
|
1243
|
-
resolver = resolve;
|
|
1244
|
-
if (time === 0) settlePromise(abort, resolve, void 0, signal);
|
|
1245
|
-
else timer();
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
//#endregion
|
|
1249
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/value/misc.mjs
|
|
1250
|
-
function findKey(needle, haystack) {
|
|
1251
|
-
const keys = Object.keys(haystack);
|
|
1252
|
-
const index = keys.map((key) => key.toLowerCase()).indexOf(needle.toLowerCase());
|
|
1253
|
-
return index > -1 ? keys[index] : needle;
|
|
1254
|
-
}
|
|
1255
|
-
function getNestedValue(data, path, ignoreCase) {
|
|
1256
|
-
if (typeof data !== "object" || data === null || typeof path !== "string" || path.trim().length === 0) return {
|
|
1257
|
-
exists: false,
|
|
1258
|
-
value: void 0
|
|
1259
|
-
};
|
|
1260
|
-
const shouldIgnoreCase = ignoreCase === true;
|
|
1261
|
-
const paths = getPaths(path, shouldIgnoreCase);
|
|
1262
|
-
if (typeof paths === "string") return handleValue(data, paths, null, true, shouldIgnoreCase);
|
|
1263
|
-
const { length } = paths;
|
|
1264
|
-
let current = data;
|
|
1265
|
-
for (let index = 0; index < length; index += 1) {
|
|
1266
|
-
const part = paths[index];
|
|
1267
|
-
const handled = handleValue(current, part, null, true, shouldIgnoreCase);
|
|
1268
|
-
if (!handled.exists) return handled;
|
|
1269
|
-
current = handled.value;
|
|
1270
|
-
}
|
|
1271
|
-
return {
|
|
1272
|
-
exists: true,
|
|
1273
|
-
value: current
|
|
1274
|
-
};
|
|
1275
|
-
}
|
|
1276
|
-
function getPaths(path, lowercase) {
|
|
1277
|
-
const normalized = lowercase ? path.toLowerCase() : path;
|
|
1278
|
-
if (!EXPRESSION_NESTED.test(normalized)) return normalized;
|
|
1279
|
-
return normalized.replace(EXPRESSION_BRACKET, ".$1").replace(EXPRESSION_DOTS, "").split(".");
|
|
1280
|
-
}
|
|
1281
|
-
function handleValue(data, path, value, get, ignoreCase) {
|
|
1282
|
-
if (typeof data === "object" && data !== null && !ignoreKey(path)) {
|
|
1283
|
-
const key = ignoreCase ? findKey(path, data) : path;
|
|
1284
|
-
if (get) return {
|
|
1285
|
-
exists: key in data,
|
|
1286
|
-
value: data[key]
|
|
1287
|
-
};
|
|
1288
|
-
data[key] = typeof value === "function" ? value(data[key]) : value;
|
|
1289
|
-
}
|
|
1290
|
-
if (get) return {
|
|
1291
|
-
exists: false,
|
|
1292
|
-
value: void 0
|
|
1293
|
-
};
|
|
1294
|
-
}
|
|
1295
|
-
const EXPRESSION_BRACKET = /\[(\w+)\]/g;
|
|
1296
|
-
const EXPRESSION_DOTS = /^\.|\.$/g;
|
|
1297
|
-
const EXPRESSION_NESTED = /\.|\[\w+\]/;
|
|
1298
|
-
//#endregion
|
|
1299
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/value/get.mjs
|
|
1300
|
-
function getValue(data, path, ignoreCase) {
|
|
1301
|
-
return getNestedValue(data, path, ignoreCase === true).value;
|
|
1302
|
-
}
|
|
1303
|
-
//#endregion
|
|
1304
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/value/has.mjs
|
|
1305
|
-
function hasValue(data, path, ignoreCase) {
|
|
1306
|
-
return getNestedValue(data, path, ignoreCase === true).exists;
|
|
1307
|
-
}
|
|
1308
|
-
hasValue.get = getWithHasValue;
|
|
1309
|
-
function getWithHasValue(data, path, ignoreCase) {
|
|
1310
|
-
return getNestedValue(data, path, ignoreCase === true);
|
|
1311
|
-
}
|
|
1312
|
-
//#endregion
|
|
1313
|
-
//#region src/components/group.component.ts
|
|
1314
1222
|
var GroupComponent = class {
|
|
1315
1223
|
element;
|
|
1316
1224
|
expanded = true;
|
|
1317
1225
|
filtered = 0;
|
|
1318
|
-
key;
|
|
1319
1226
|
selected = 0;
|
|
1320
1227
|
total = 0;
|
|
1321
|
-
value
|
|
1322
|
-
|
|
1228
|
+
constructor(key, label, value) {
|
|
1229
|
+
this.key = key;
|
|
1323
1230
|
this.label = label;
|
|
1324
|
-
|
|
1325
|
-
this.key = `group:${stringified}`;
|
|
1326
|
-
this.value = {
|
|
1327
|
-
stringified,
|
|
1328
|
-
original: value
|
|
1329
|
-
};
|
|
1231
|
+
this.value = value;
|
|
1330
1232
|
}
|
|
1331
1233
|
};
|
|
1332
|
-
function removeGroup(group) {
|
|
1333
|
-
if (group.element == null) return;
|
|
1334
|
-
group.element.innerHTML = "";
|
|
1335
|
-
group.element.remove();
|
|
1336
|
-
}
|
|
1337
1234
|
function renderGroup(state, component) {
|
|
1338
1235
|
component.element ??= createElement("div", {
|
|
1339
|
-
className:
|
|
1236
|
+
className: "tabela__row tabela__row--group",
|
|
1340
1237
|
innerHTML: `<div class="tabela__cell tabela__cell--group" role="cell">
|
|
1341
|
-
<button class="tabela__button tabela__button--group" data-event="group" data-key="
|
|
1238
|
+
<button class="tabela__button tabela__button--group" data-event="group" data-key="${component.key}" type="button">
|
|
1342
1239
|
<span aria-hidden="true"></span>
|
|
1343
1240
|
<span>Open/close</span>
|
|
1344
1241
|
</button>
|
|
1345
1242
|
<p>${component.label}</p>
|
|
1346
|
-
<span class="tabela__group__total">${component.total}</span>
|
|
1347
|
-
<span class="tabela__group__selected">${component.selected === 0 ? "" : component.selected}</span>
|
|
1348
1243
|
</div>`,
|
|
1349
1244
|
role: "row"
|
|
1350
1245
|
}, {}, { height: `${state.options.rowHeight}px` });
|
|
1351
1246
|
}
|
|
1352
|
-
function updateGroup(state, component) {
|
|
1353
|
-
if (component.element == null) return;
|
|
1354
|
-
const selected = component.element.querySelector(".tabela__group__selected");
|
|
1355
|
-
const total = component.element.querySelector(".tabela__group__total");
|
|
1356
|
-
if (selected != null) selected.textContent = component.selected === 0 ? "" : String(component.selected);
|
|
1357
|
-
if (total != null) total.textContent = String(component.total);
|
|
1358
|
-
}
|
|
1359
|
-
//#endregion
|
|
1360
|
-
//#region src/managers/sort.manager.ts
|
|
1361
1247
|
var SortManager = class {
|
|
1362
1248
|
handlers = Object.freeze({
|
|
1363
1249
|
add: (field, direction) => this.add(field, direction),
|
|
@@ -1433,7 +1319,7 @@ var SortManager = class {
|
|
|
1433
1319
|
});
|
|
1434
1320
|
setAttribute(column.elements.sorter, "data-sort-position", sorterIndex > -1 && items.length > 1 ? sorterIndex + 1 : void 0);
|
|
1435
1321
|
}
|
|
1436
|
-
state.managers.data.
|
|
1322
|
+
state.managers.data.values.keys.active = items.length === 0 ? void 0 : getSortedKeys(state, items);
|
|
1437
1323
|
state.managers.render.update(true, true);
|
|
1438
1324
|
}
|
|
1439
1325
|
toggle(event, field, direction) {
|
|
@@ -1450,16 +1336,16 @@ var SortManager = class {
|
|
|
1450
1336
|
}
|
|
1451
1337
|
}
|
|
1452
1338
|
};
|
|
1453
|
-
function
|
|
1454
|
-
const data = state.managers.data.
|
|
1455
|
-
if (!state.managers.group.enabled) return sort(data, sorters).map((item) =>
|
|
1456
|
-
return sortWithGroups(state, data, sorters).map((item) => item instanceof GroupComponent ? item :
|
|
1339
|
+
function getSortedKeys(state, sorters) {
|
|
1340
|
+
const data = state.managers.data.values.keys.active?.map((key) => key instanceof GroupComponent ? key : state.managers.data.values.objects.mapped.get(key)) ?? state.managers.data.values.objects.array.slice();
|
|
1341
|
+
if (!state.managers.group.enabled) return sort(data, sorters).map((item) => item[state.key]);
|
|
1342
|
+
return sortWithGroups(state, data, sorters).map((item) => item instanceof GroupComponent ? item : item[state.key]);
|
|
1457
1343
|
}
|
|
1458
1344
|
function sortWithGroups(state, data, sorters) {
|
|
1459
1345
|
const { length } = sorters;
|
|
1460
1346
|
return data.sort((first, second) => {
|
|
1461
|
-
const firstValue = first instanceof GroupComponent ? first.value
|
|
1462
|
-
const secondValue = second instanceof GroupComponent ? second.value
|
|
1347
|
+
const firstValue = first instanceof GroupComponent ? first.value : first[state.managers.group.field];
|
|
1348
|
+
const secondValue = second instanceof GroupComponent ? second.value : second[state.managers.group.field];
|
|
1463
1349
|
const firstOrder = state.managers.group.order[firstValue];
|
|
1464
1350
|
const secondOrder = state.managers.group.order[secondValue];
|
|
1465
1351
|
const groupComparison = compare(firstOrder, secondOrder);
|
|
@@ -1469,14 +1355,21 @@ function sortWithGroups(state, data, sorters) {
|
|
|
1469
1355
|
if (firstIsGroup || secondIsGroup) return firstIsGroup && secondIsGroup ? 0 : firstIsGroup ? -1 : 1;
|
|
1470
1356
|
for (let index = 0; index < length; index += 1) {
|
|
1471
1357
|
const sorter = sorters[index];
|
|
1472
|
-
const comparison = compare(
|
|
1358
|
+
const comparison = compare(first[sorter.key], second[sorter.key]);
|
|
1473
1359
|
if (comparison !== 0) return comparison * (sorter.direction === "ascending" ? 1 : -1);
|
|
1474
1360
|
}
|
|
1475
1361
|
return 0;
|
|
1476
1362
|
});
|
|
1477
1363
|
}
|
|
1478
|
-
|
|
1479
|
-
|
|
1364
|
+
/**
|
|
1365
|
+
* Is the value `undefined`, `null`, or a whitespace-only string?
|
|
1366
|
+
* @param value Value to check
|
|
1367
|
+
* @returns `true` if the value is nullable or a whitespace-only string, otherwise `false`
|
|
1368
|
+
*/
|
|
1369
|
+
function isNullableOrWhitespace(value) {
|
|
1370
|
+
return value == null || EXPRESSION_WHITESPACE.test(getString(value));
|
|
1371
|
+
}
|
|
1372
|
+
var EXPRESSION_WHITESPACE = /^\s*$/;
|
|
1480
1373
|
var DataManager = class {
|
|
1481
1374
|
handlers = Object.freeze({
|
|
1482
1375
|
add: (data) => void this.add(data, true),
|
|
@@ -1486,185 +1379,148 @@ var DataManager = class {
|
|
|
1486
1379
|
synchronize: (data, remove) => void this.synchronize(data, remove),
|
|
1487
1380
|
update: (data) => void this.update(data)
|
|
1488
1381
|
});
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1382
|
+
values = {
|
|
1383
|
+
keys: { original: [] },
|
|
1384
|
+
objects: {
|
|
1385
|
+
mapped: /* @__PURE__ */ new Map(),
|
|
1386
|
+
array: []
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1389
|
+
get keys() {
|
|
1390
|
+
return this.values.keys.active ?? this.values.keys.original;
|
|
1492
1391
|
}
|
|
1493
1392
|
get size() {
|
|
1494
|
-
return this.
|
|
1393
|
+
return this.keys.length;
|
|
1495
1394
|
}
|
|
1496
1395
|
constructor(state) {
|
|
1497
|
-
this.state =
|
|
1498
|
-
...state,
|
|
1499
|
-
items: { original: [] },
|
|
1500
|
-
values: {
|
|
1501
|
-
array: [],
|
|
1502
|
-
mapped: /* @__PURE__ */ new Map()
|
|
1503
|
-
}
|
|
1504
|
-
};
|
|
1396
|
+
this.state = state;
|
|
1505
1397
|
}
|
|
1506
1398
|
async add(data, render) {
|
|
1507
|
-
const { state } = this;
|
|
1508
|
-
const
|
|
1399
|
+
const { state, values } = this;
|
|
1400
|
+
const { length } = data;
|
|
1509
1401
|
const updates = [];
|
|
1510
|
-
let groupColumn;
|
|
1511
|
-
let { length } = data;
|
|
1512
1402
|
for (let index = 0; index < length; index += 1) {
|
|
1513
1403
|
const item = data[index];
|
|
1514
|
-
const key =
|
|
1515
|
-
if (
|
|
1404
|
+
const key = item[state.key];
|
|
1405
|
+
if (values.objects.mapped.has(key)) {
|
|
1516
1406
|
updates.push(item);
|
|
1517
1407
|
continue;
|
|
1518
1408
|
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1409
|
+
values.objects.array.push(item);
|
|
1410
|
+
values.objects.mapped.set(key, item);
|
|
1521
1411
|
if (!state.managers.group.enabled) continue;
|
|
1522
|
-
const
|
|
1523
|
-
let group = state.managers.group.get(
|
|
1412
|
+
const groupKey = item[state.managers.group.field];
|
|
1413
|
+
let group = state.managers.group.get(groupKey);
|
|
1524
1414
|
if (group == null) {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
state.values.array.push(group);
|
|
1415
|
+
group = new GroupComponent(String(groupKey), String(groupKey), groupKey);
|
|
1416
|
+
values.objects.array.push(group);
|
|
1528
1417
|
state.managers.group.add(group);
|
|
1529
1418
|
}
|
|
1530
1419
|
if (!group.expanded) state.managers.group.collapsed.add(key);
|
|
1531
1420
|
group.total += 1;
|
|
1532
|
-
groups.push(group);
|
|
1533
1421
|
}
|
|
1534
|
-
length = groups.length;
|
|
1535
|
-
for (let index = 0; index < length; index += 1) updateGroup(state, groups[index]);
|
|
1536
1422
|
if (updates.length > 0) this.update(updates);
|
|
1537
1423
|
else if (render) this.render();
|
|
1538
1424
|
}
|
|
1539
1425
|
clear() {
|
|
1540
|
-
if (this.
|
|
1426
|
+
if (this.values.objects.array.length > 0) this.set([]);
|
|
1541
1427
|
}
|
|
1542
1428
|
destroy() {
|
|
1543
|
-
const {
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1429
|
+
const { values } = this;
|
|
1430
|
+
values.objects.mapped.clear();
|
|
1431
|
+
values.keys.active = void 0;
|
|
1432
|
+
values.keys.original.length = 0;
|
|
1433
|
+
values.objects.array.length = 0;
|
|
1548
1434
|
this.handlers = void 0;
|
|
1549
1435
|
this.state = void 0;
|
|
1436
|
+
this.values = void 0;
|
|
1550
1437
|
}
|
|
1551
1438
|
get(active) {
|
|
1552
|
-
const {
|
|
1553
|
-
return active ?? false ? select(
|
|
1439
|
+
const { values } = this;
|
|
1440
|
+
return active ?? false ? select(values.keys.active ?? [], (key) => !(key instanceof GroupComponent), (key) => values.objects.mapped.get(key)) : values.objects.array.filter((item) => !(item instanceof GroupComponent));
|
|
1554
1441
|
}
|
|
1555
|
-
getIndex(
|
|
1556
|
-
|
|
1557
|
-
return this.items.findIndex((value) => value instanceof GroupComponent ? value.key === item : value === item);
|
|
1442
|
+
getIndex(key) {
|
|
1443
|
+
return this.keys.indexOf(key);
|
|
1558
1444
|
}
|
|
1559
1445
|
async remove(items, render) {
|
|
1560
|
-
const { state } = this;
|
|
1561
|
-
const keys = items.map((value) => isPlainObject(value) ?
|
|
1446
|
+
const { state, values } = this;
|
|
1447
|
+
const keys = items.map((value) => isPlainObject(value) ? value[state.key] : value).filter((key) => values.objects.mapped.has(key));
|
|
1562
1448
|
const { length } = keys;
|
|
1563
|
-
if (length
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
state.
|
|
1572
|
-
state.managers.
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
for (let itemIndex = 0; itemIndex < chunkLength; itemIndex += 1) {
|
|
1583
|
-
const item = chunk[itemIndex];
|
|
1584
|
-
const dataIndex = state.items.original.indexOf(item);
|
|
1585
|
-
let dataValue;
|
|
1586
|
-
[dataValue] = state.values.array.splice(dataIndex, 1);
|
|
1587
|
-
state.items.original.splice(dataIndex, 1);
|
|
1588
|
-
state.managers.row.remove(item);
|
|
1589
|
-
state.values.mapped.delete(item);
|
|
1590
|
-
if (!state.managers.group.enabled || item instanceof GroupComponent) continue;
|
|
1591
|
-
state.managers.group.collapsed.delete(item);
|
|
1592
|
-
const groupKey = getValue(dataValue, state.managers.group.field);
|
|
1593
|
-
const group = state.managers.group.get(groupKey);
|
|
1594
|
-
if (group == null) continue;
|
|
1595
|
-
group.total -= 1;
|
|
1596
|
-
if (group.total > 0) {
|
|
1597
|
-
groups.push(group);
|
|
1598
|
-
continue;
|
|
1599
|
-
}
|
|
1600
|
-
let groupIndex = groups.indexOf(group);
|
|
1601
|
-
if (groupIndex > -1) groups.splice(groupIndex, 1);
|
|
1602
|
-
groupIndex = state.values.array.indexOf(group);
|
|
1603
|
-
if (groupIndex > -1) {
|
|
1604
|
-
state.items.original.splice(groupIndex, 1);
|
|
1605
|
-
state.values.array.splice(groupIndex, 1);
|
|
1606
|
-
}
|
|
1607
|
-
state.managers.group.remove(group);
|
|
1608
|
-
if (items.length >= 1e4) await delay(25);
|
|
1609
|
-
}
|
|
1449
|
+
if (length === 0) return;
|
|
1450
|
+
for (let keyIndex = 0; keyIndex < length; keyIndex += 1) {
|
|
1451
|
+
const key = keys[keyIndex];
|
|
1452
|
+
values.objects.mapped.delete(key);
|
|
1453
|
+
const arrayIndex = values.objects.array.findIndex((item) => !(item instanceof GroupComponent) && item[state.key] === key);
|
|
1454
|
+
let item;
|
|
1455
|
+
if (arrayIndex > -1) [item] = values.objects.array.splice(arrayIndex, 1);
|
|
1456
|
+
values.keys.original.splice(values.keys.original.indexOf(key), 1);
|
|
1457
|
+
state.managers.row.remove(key);
|
|
1458
|
+
if (!state.managers.group.enabled || item == null) continue;
|
|
1459
|
+
state.managers.group.collapsed.delete(key);
|
|
1460
|
+
const groupKey = item[state.managers.group.field];
|
|
1461
|
+
const group = state.managers.group.get(groupKey);
|
|
1462
|
+
if (group == null) continue;
|
|
1463
|
+
group.total -= 1;
|
|
1464
|
+
if (group.total > 0) continue;
|
|
1465
|
+
const groupIndex = values.objects.array.findIndex((item) => item instanceof GroupComponent && item.value === groupKey);
|
|
1466
|
+
if (groupIndex > -1) values.objects.array.splice(groupIndex, 1);
|
|
1467
|
+
state.managers.group.remove(group);
|
|
1610
1468
|
}
|
|
1611
|
-
|
|
1612
|
-
for (let index = 0; index < length; index += 1) updateGroup(state, groups[index]);
|
|
1613
|
-
if (render) return this.render();
|
|
1469
|
+
if (render) this.render();
|
|
1614
1470
|
}
|
|
1615
1471
|
render() {
|
|
1616
|
-
const { state } = this;
|
|
1617
|
-
if (state.managers.group.enabled) sortWithGroups(state,
|
|
1472
|
+
const { state, values } = this;
|
|
1473
|
+
if (state.managers.group.enabled) sortWithGroups(state, values.objects.array, [{
|
|
1618
1474
|
direction: "ascending",
|
|
1619
1475
|
key: state.key
|
|
1620
1476
|
}]);
|
|
1621
|
-
else sort(
|
|
1477
|
+
else sort(values.objects.array, [{
|
|
1622
1478
|
direction: "ascending",
|
|
1623
1479
|
key: state.key
|
|
1624
1480
|
}]);
|
|
1625
|
-
|
|
1626
|
-
|
|
1481
|
+
values.keys.original = values.objects.array.map((item) => item instanceof GroupComponent ? item : item[state.key]);
|
|
1482
|
+
values.objects.mapped = toMap(values.objects.array.filter((item) => !(item instanceof GroupComponent)), (item) => item[state.key]);
|
|
1627
1483
|
if (Object.keys(state.managers.filter.items).length > 0) state.managers.filter.filter();
|
|
1628
1484
|
else if (state.managers.sort.items.length > 0) state.managers.sort.sort();
|
|
1629
1485
|
else state.managers.render.update(true, true);
|
|
1630
1486
|
}
|
|
1631
1487
|
set(data) {
|
|
1632
|
-
const { state } = this;
|
|
1488
|
+
const { state, values } = this;
|
|
1633
1489
|
const array = data.slice();
|
|
1634
1490
|
if (state.managers.group.enabled) {
|
|
1635
|
-
const column = state.managers.column.get(state.managers.group.field);
|
|
1636
1491
|
const grouped = toRecord.arrays(data, state.managers.group.field);
|
|
1637
1492
|
const entries = Object.entries(grouped);
|
|
1638
1493
|
const { length } = entries;
|
|
1639
1494
|
const groups = [];
|
|
1640
1495
|
for (let index = 0; index < length; index += 1) {
|
|
1641
1496
|
const [value, items] = entries[index];
|
|
1642
|
-
const
|
|
1497
|
+
const key = String(value);
|
|
1498
|
+
const group = new GroupComponent(key, key, value);
|
|
1643
1499
|
group.total = items.length;
|
|
1644
1500
|
groups.push(group);
|
|
1645
1501
|
array.push(group);
|
|
1646
1502
|
}
|
|
1647
1503
|
state.managers.group.set(groups);
|
|
1648
1504
|
}
|
|
1649
|
-
|
|
1505
|
+
values.objects.array = array;
|
|
1650
1506
|
this.render();
|
|
1651
1507
|
}
|
|
1652
1508
|
async synchronize(data, remove) {
|
|
1653
|
-
const { state } = this;
|
|
1509
|
+
const { state, values } = this;
|
|
1654
1510
|
const add = [];
|
|
1655
1511
|
const updated = [];
|
|
1656
1512
|
const keys = /* @__PURE__ */ new Set([]);
|
|
1657
1513
|
const { length } = data;
|
|
1658
1514
|
for (let index = 0; index < length; index += 1) {
|
|
1659
1515
|
const object = data[index];
|
|
1660
|
-
const key =
|
|
1661
|
-
if (
|
|
1516
|
+
const key = object[state.key];
|
|
1517
|
+
if (values.objects.mapped.has(key)) updated.push(object);
|
|
1662
1518
|
else add.push(object);
|
|
1663
1519
|
keys.add(key);
|
|
1664
1520
|
}
|
|
1665
1521
|
if (keys.size === 0) return;
|
|
1666
1522
|
if (remove ?? false) {
|
|
1667
|
-
const toRemove =
|
|
1523
|
+
const toRemove = values.keys.original.filter((key) => !(key instanceof GroupComponent) && !keys.has(key));
|
|
1668
1524
|
if (toRemove.length > 0) await this.remove(toRemove, false);
|
|
1669
1525
|
}
|
|
1670
1526
|
await this.update(updated);
|
|
@@ -1672,14 +1528,14 @@ var DataManager = class {
|
|
|
1672
1528
|
if (add.length > 0 || (remove ?? false)) this.render();
|
|
1673
1529
|
}
|
|
1674
1530
|
async update(data) {
|
|
1675
|
-
const { state } = this;
|
|
1531
|
+
const { state, values } = this;
|
|
1676
1532
|
const { length } = data;
|
|
1677
1533
|
for (let index = 0; index < length; index += 1) {
|
|
1678
1534
|
const object = data[index];
|
|
1679
|
-
const key =
|
|
1680
|
-
const value =
|
|
1535
|
+
const key = object[state.key];
|
|
1536
|
+
const value = values.objects.mapped.get(key);
|
|
1681
1537
|
if (value != null) {
|
|
1682
|
-
|
|
1538
|
+
values.objects.mapped.set(key, {
|
|
1683
1539
|
...value,
|
|
1684
1540
|
...object
|
|
1685
1541
|
});
|
|
@@ -1688,8 +1544,6 @@ var DataManager = class {
|
|
|
1688
1544
|
}
|
|
1689
1545
|
}
|
|
1690
1546
|
};
|
|
1691
|
-
//#endregion
|
|
1692
|
-
//#region node_modules/@oscarpalmer/toretto/dist/event/delegation.mjs
|
|
1693
1547
|
function addDelegatedHandler(doc, type, name, passive) {
|
|
1694
1548
|
if (DELEGATED.has(name)) return;
|
|
1695
1549
|
DELEGATED.add(name);
|
|
@@ -1741,11 +1595,11 @@ function removeDelegatedListener(target, name, listener) {
|
|
|
1741
1595
|
if (handlers.size === 0) target[name] = void 0;
|
|
1742
1596
|
return true;
|
|
1743
1597
|
}
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1598
|
+
var DELEGATED = /* @__PURE__ */ new Set();
|
|
1599
|
+
var EVENT_PREFIX = "@";
|
|
1600
|
+
var EVENT_SUFFIX_ACTIVE = ":active";
|
|
1601
|
+
var EVENT_SUFFIX_PASSIVE = ":passive";
|
|
1602
|
+
var EVENT_TYPES = new Set([
|
|
1749
1603
|
"beforeinput",
|
|
1750
1604
|
"click",
|
|
1751
1605
|
"dblclick",
|
|
@@ -1769,16 +1623,12 @@ const EVENT_TYPES = new Set([
|
|
|
1769
1623
|
"touchmove",
|
|
1770
1624
|
"touchstart"
|
|
1771
1625
|
]);
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
//#endregion
|
|
1775
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/function/misc.mjs
|
|
1626
|
+
var HANDLER_ACTIVE = delegatedEventHandler.bind(false);
|
|
1627
|
+
var HANDLER_PASSIVE = delegatedEventHandler.bind(true);
|
|
1776
1628
|
/**
|
|
1777
1629
|
* A function that does nothing, which can be useful, I guess…
|
|
1778
1630
|
*/
|
|
1779
1631
|
function noop() {}
|
|
1780
|
-
//#endregion
|
|
1781
|
-
//#region node_modules/@oscarpalmer/toretto/dist/event/index.mjs
|
|
1782
1632
|
function createEventOptions(options) {
|
|
1783
1633
|
return {
|
|
1784
1634
|
capture: getBoolean(options?.capture),
|
|
@@ -1818,8 +1668,6 @@ function on(target, type, listener, options) {
|
|
|
1818
1668
|
target.removeEventListener(type, listener, extended);
|
|
1819
1669
|
};
|
|
1820
1670
|
}
|
|
1821
|
-
//#endregion
|
|
1822
|
-
//#region node_modules/@oscarpalmer/toretto/dist/find/relative.mjs
|
|
1823
1671
|
function findAncestor(origin, selector) {
|
|
1824
1672
|
const element = getElement(origin);
|
|
1825
1673
|
if (element == null || selector == null) return null;
|
|
@@ -1840,8 +1688,6 @@ function getElement(origin) {
|
|
|
1840
1688
|
if (origin instanceof Element) return origin;
|
|
1841
1689
|
return origin instanceof Event && origin.target instanceof Element ? origin.target : void 0;
|
|
1842
1690
|
}
|
|
1843
|
-
//#endregion
|
|
1844
|
-
//#region src/managers/event.manager.ts
|
|
1845
1691
|
var EventManager = class {
|
|
1846
1692
|
constructor(state) {
|
|
1847
1693
|
this.state = state;
|
|
@@ -1859,7 +1705,7 @@ var EventManager = class {
|
|
|
1859
1705
|
};
|
|
1860
1706
|
function onClick(event) {
|
|
1861
1707
|
const target = findAncestor(event, "[data-event]");
|
|
1862
|
-
const table = findAncestor(event, ".
|
|
1708
|
+
const table = findAncestor(event, ".tabela");
|
|
1863
1709
|
if (!(target instanceof HTMLElement) || !(table instanceof HTMLElement)) return;
|
|
1864
1710
|
const manager = mapped$1.get(table);
|
|
1865
1711
|
if (manager == null) return;
|
|
@@ -1878,21 +1724,211 @@ function onClick(event) {
|
|
|
1878
1724
|
}
|
|
1879
1725
|
function onKeydown(event) {
|
|
1880
1726
|
const target = findAncestor(event, "[data-event]");
|
|
1881
|
-
const table = findAncestor(event, ".
|
|
1727
|
+
const table = findAncestor(event, ".tabela");
|
|
1882
1728
|
if (!(target instanceof HTMLElement) || !(table instanceof HTMLElement)) return;
|
|
1883
1729
|
const manager = mapped$1.get(table);
|
|
1884
1730
|
if (manager == null) return;
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1731
|
+
switch (target?.getAttribute("data-event")) {
|
|
1732
|
+
case "body":
|
|
1733
|
+
manager.state.managers.navigation.handle(event);
|
|
1734
|
+
break;
|
|
1735
|
+
default: break;
|
|
1888
1736
|
}
|
|
1889
|
-
manager.state.managers.navigation.handle(event);
|
|
1890
1737
|
}
|
|
1891
1738
|
const mapped$1 = /* @__PURE__ */ new WeakMap();
|
|
1892
1739
|
on(document, "click", onClick);
|
|
1893
1740
|
on(document, "keydown", onKeydown, { passive: false });
|
|
1894
|
-
|
|
1895
|
-
|
|
1741
|
+
/**
|
|
1742
|
+
* Clamp a number between a minimum and maximum value
|
|
1743
|
+
* @param value Value to clamp
|
|
1744
|
+
* @param minimum Minimum value
|
|
1745
|
+
* @param maximum Maximum value
|
|
1746
|
+
* @param loop If `true`, the value will loop around when smaller than the minimum or larger than the maximum _(defaults to `false`)_
|
|
1747
|
+
* @returns Clamped value
|
|
1748
|
+
*/
|
|
1749
|
+
function clamp(value, minimum, maximum, loop) {
|
|
1750
|
+
if (![
|
|
1751
|
+
value,
|
|
1752
|
+
minimum,
|
|
1753
|
+
maximum
|
|
1754
|
+
].every(isNumber)) return NaN;
|
|
1755
|
+
if (value < minimum) return loop === true ? maximum : minimum;
|
|
1756
|
+
return value > maximum ? loop === true ? minimum : maximum : value;
|
|
1757
|
+
}
|
|
1758
|
+
/**
|
|
1759
|
+
* Get the number value from an unknown value _(based on Lodash)_
|
|
1760
|
+
* @param value Original value
|
|
1761
|
+
* @returns Original value as a number, or `NaN` if the value is unable to be parsed
|
|
1762
|
+
*/
|
|
1763
|
+
function getNumber(value) {
|
|
1764
|
+
if (typeof value === "number") return value;
|
|
1765
|
+
if (typeof value === "bigint" || typeof value === "boolean") return Number(value);
|
|
1766
|
+
if (value == null || typeof value === "symbol") return NaN;
|
|
1767
|
+
if (typeof value === "function") return getNumber(value());
|
|
1768
|
+
let parsed = value.valueOf();
|
|
1769
|
+
if (typeof parsed === "object") parsed = parsed.toString();
|
|
1770
|
+
if (typeof parsed !== "string") return getNumber(parsed);
|
|
1771
|
+
const trimmed = parsed.trim();
|
|
1772
|
+
if (trimmed.length === 0) return NaN;
|
|
1773
|
+
if (EXPRESSION_ZEROISH.test(parsed)) return 0;
|
|
1774
|
+
const isBinary = EXPRESSION_BINARY.test(trimmed);
|
|
1775
|
+
if (isBinary || EXPRESSION_OCTAL.test(trimmed)) return Number.parseInt(trimmed.slice(2), isBinary ? 2 : OCTAL_VALUE);
|
|
1776
|
+
return Number(EXPRESSION_HEX.test(trimmed) ? trimmed : trimmed.replace(EXPRESSION_UNDERSCORE, ""));
|
|
1777
|
+
}
|
|
1778
|
+
var EXPRESSION_BINARY = /^0b[01]+$/i;
|
|
1779
|
+
var EXPRESSION_HEX = /^0x[0-9a-f]+$/i;
|
|
1780
|
+
var EXPRESSION_OCTAL = /^0o[0-7]+$/i;
|
|
1781
|
+
var EXPRESSION_UNDERSCORE = /_/g;
|
|
1782
|
+
var EXPRESSION_ZEROISH = /^\s*0+\s*$/;
|
|
1783
|
+
var OCTAL_VALUE = 8;
|
|
1784
|
+
function getSizedMaximum(first, second) {
|
|
1785
|
+
let actual;
|
|
1786
|
+
if (typeof first === "number") actual = first;
|
|
1787
|
+
else actual = typeof second === "number" ? second : MAXIMUM_DEFAULT;
|
|
1788
|
+
return clamp(actual, 1, MAXIMUM_ABSOLUTE);
|
|
1789
|
+
}
|
|
1790
|
+
var MAXIMUM_ABSOLUTE = 16777216;
|
|
1791
|
+
var MAXIMUM_DEFAULT = 1048576;
|
|
1792
|
+
/**
|
|
1793
|
+
* A Map with a maximum size
|
|
1794
|
+
*
|
|
1795
|
+
* Behavior is similar to a _LRU_-cache, where the least recently used entries are removed
|
|
1796
|
+
*/
|
|
1797
|
+
var SizedMap = class extends Map {
|
|
1798
|
+
/**
|
|
1799
|
+
* The maximum size of the Map
|
|
1800
|
+
*/
|
|
1801
|
+
#maximumSize;
|
|
1802
|
+
/**
|
|
1803
|
+
* Is the Map full?
|
|
1804
|
+
*/
|
|
1805
|
+
get full() {
|
|
1806
|
+
return this.size >= this.#maximumSize;
|
|
1807
|
+
}
|
|
1808
|
+
get maximum() {
|
|
1809
|
+
return this.#maximumSize;
|
|
1810
|
+
}
|
|
1811
|
+
constructor(first, second) {
|
|
1812
|
+
const maximum = getSizedMaximum(first, second);
|
|
1813
|
+
super();
|
|
1814
|
+
this.#maximumSize = maximum;
|
|
1815
|
+
if (Array.isArray(first)) {
|
|
1816
|
+
const { length } = first;
|
|
1817
|
+
if (length <= maximum) for (let index = 0; index < length; index += 1) this.set(...first[index]);
|
|
1818
|
+
else for (let index = 0; index < maximum; index += 1) this.set(...first[length - maximum + index]);
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
/**
|
|
1822
|
+
* @inheritdoc
|
|
1823
|
+
*/
|
|
1824
|
+
get(key) {
|
|
1825
|
+
const value = super.get(key);
|
|
1826
|
+
if (value !== void 0 || this.has(key)) this.set(key, value);
|
|
1827
|
+
return value;
|
|
1828
|
+
}
|
|
1829
|
+
/**
|
|
1830
|
+
* @inheritdoc
|
|
1831
|
+
*/
|
|
1832
|
+
set(key, value) {
|
|
1833
|
+
if (this.has(key)) this.delete(key);
|
|
1834
|
+
else if (this.size >= this.#maximumSize) this.delete(this.keys().next().value);
|
|
1835
|
+
return super.set(key, value);
|
|
1836
|
+
}
|
|
1837
|
+
};
|
|
1838
|
+
var Memoized = class {
|
|
1839
|
+
#state;
|
|
1840
|
+
/**
|
|
1841
|
+
* Maximum cache size
|
|
1842
|
+
*/
|
|
1843
|
+
get maximum() {
|
|
1844
|
+
return this.#state.cache?.maximum ?? NaN;
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Current cache size
|
|
1848
|
+
*/
|
|
1849
|
+
get size() {
|
|
1850
|
+
return this.#state.cache?.size ?? NaN;
|
|
1851
|
+
}
|
|
1852
|
+
constructor(callback, options) {
|
|
1853
|
+
const cache = new SizedMap(options.cacheSize);
|
|
1854
|
+
const getter = (...parameters) => {
|
|
1855
|
+
const key = options.cacheKey?.(...parameters) ?? (parameters.length === 1 ? parameters[0] : join(parameters.map(getString), SEPARATOR));
|
|
1856
|
+
if (cache.has(key)) return cache.get(key);
|
|
1857
|
+
const value = callback(...parameters);
|
|
1858
|
+
cache.set(key, value);
|
|
1859
|
+
return value;
|
|
1860
|
+
};
|
|
1861
|
+
this.#state = {
|
|
1862
|
+
cache,
|
|
1863
|
+
getter
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Clear the cache
|
|
1868
|
+
*/
|
|
1869
|
+
clear() {
|
|
1870
|
+
this.#state.cache?.clear();
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* Delete a result from the cache
|
|
1874
|
+
* @param key Key to delete
|
|
1875
|
+
* @returns `true` if the key existed and was removed, otherwise `false`
|
|
1876
|
+
*/
|
|
1877
|
+
delete(key) {
|
|
1878
|
+
return this.#state.cache?.delete(key) ?? false;
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* Destroy the instance _(clearing its cache and removing its callback)_
|
|
1882
|
+
*/
|
|
1883
|
+
destroy() {
|
|
1884
|
+
this.#state.cache?.clear();
|
|
1885
|
+
this.#state.cache = void 0;
|
|
1886
|
+
this.#state.getter = void 0;
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* Get a result from the cache
|
|
1890
|
+
* @param key Key to get
|
|
1891
|
+
* @returns Cached result or `undefined` if it does not exist
|
|
1892
|
+
*/
|
|
1893
|
+
get(key) {
|
|
1894
|
+
return this.#state.cache?.get(key);
|
|
1895
|
+
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Does the result exist?
|
|
1898
|
+
* @param key Key to check
|
|
1899
|
+
* @returns `true` if the result exists, otherwise `false`
|
|
1900
|
+
*/
|
|
1901
|
+
has(key) {
|
|
1902
|
+
return this.#state.cache?.has(key) ?? false;
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Run the callback with the provided parameters
|
|
1906
|
+
* @param parameters Parameters to pass to the callback
|
|
1907
|
+
* @returns Cached or computed _(then cached)_ result
|
|
1908
|
+
*/
|
|
1909
|
+
run(...parameters) {
|
|
1910
|
+
if (this.#state.cache == null || this.#state.getter == null) throw new Error("The Memoized instance has been destroyed");
|
|
1911
|
+
return this.#state.getter(...parameters);
|
|
1912
|
+
}
|
|
1913
|
+
};
|
|
1914
|
+
function getMemoizationOptions(input) {
|
|
1915
|
+
const { cacheKey, cacheSize } = isPlainObject(input) ? input : {};
|
|
1916
|
+
return {
|
|
1917
|
+
cacheKey: typeof cacheKey === "function" ? cacheKey : void 0,
|
|
1918
|
+
cacheSize: typeof cacheSize === "number" && cacheSize > 0 ? cacheSize : DEFAULT_CACHE_SIZE
|
|
1919
|
+
};
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* Memoize a function, caching and retrieving results based on the first parameter
|
|
1923
|
+
* @param callback Callback to memoize
|
|
1924
|
+
* @param options Memoization options
|
|
1925
|
+
* @returns Memoized instance
|
|
1926
|
+
*/
|
|
1927
|
+
function memoize(callback, options) {
|
|
1928
|
+
return new Memoized(callback, getMemoizationOptions(options));
|
|
1929
|
+
}
|
|
1930
|
+
var DEFAULT_CACHE_SIZE = 1024;
|
|
1931
|
+
var SEPARATOR = "_";
|
|
1896
1932
|
/**
|
|
1897
1933
|
* Check if a string ends with a specified substring
|
|
1898
1934
|
* @param haystack String to look in
|
|
@@ -1931,12 +1967,10 @@ function matchCallback(haystack, needle, ignoreCase) {
|
|
|
1931
1967
|
function startsWith(haystack, needle, ignoreCase) {
|
|
1932
1968
|
return match(MATCH_STARTS_WITH, haystack, needle, ignoreCase === true);
|
|
1933
1969
|
}
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
//#endregion
|
|
1939
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/value/equal.mjs
|
|
1970
|
+
var MATCH_ENDS_WITH = "endsWith";
|
|
1971
|
+
var MATCH_INCLUDES = "includes";
|
|
1972
|
+
var MATCH_STARTS_WITH = "startsWith";
|
|
1973
|
+
var matchMemoizers = {};
|
|
1940
1974
|
function equal(first, second, options) {
|
|
1941
1975
|
return equalValue(first, second, getEqualOptions(options));
|
|
1942
1976
|
}
|
|
@@ -2102,12 +2136,10 @@ function getEqualOptions(input) {
|
|
|
2102
2136
|
options.relaxedNullish = input.relaxedNullish === true;
|
|
2103
2137
|
return options;
|
|
2104
2138
|
}
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
//#endregion
|
|
2110
|
-
//#region src/managers/filter.manager.ts
|
|
2139
|
+
var ARRAY_PEEK_PERCENTAGE = 10;
|
|
2140
|
+
var ARRAY_THRESHOLD = 100;
|
|
2141
|
+
var ERROR_PROPERTIES = ["name", "message"];
|
|
2142
|
+
var EXPRESSION_PROPERTIES = ["source", "flags"];
|
|
2111
2143
|
var FilterManager = class {
|
|
2112
2144
|
handlers = Object.freeze({
|
|
2113
2145
|
add: (item) => this.add(item),
|
|
@@ -2121,7 +2153,7 @@ var FilterManager = class {
|
|
|
2121
2153
|
}
|
|
2122
2154
|
add(item) {
|
|
2123
2155
|
if (this.items[item.field] == null) this.items[item.field] = [];
|
|
2124
|
-
else if (this.items[item.field].findIndex((existing) => equal(existing, item))
|
|
2156
|
+
else if (this.items[item.field].findIndex((existing) => equal(existing, item)) !== -1) return;
|
|
2125
2157
|
this.items[item.field].push(item);
|
|
2126
2158
|
this.filter();
|
|
2127
2159
|
}
|
|
@@ -2140,14 +2172,14 @@ var FilterManager = class {
|
|
|
2140
2172
|
const { state } = this;
|
|
2141
2173
|
const filtered = [];
|
|
2142
2174
|
const filters = Object.entries(this.items);
|
|
2143
|
-
const
|
|
2144
|
-
rowLoop: for (let
|
|
2145
|
-
const
|
|
2146
|
-
if (
|
|
2147
|
-
filtered.push(
|
|
2175
|
+
const keysLength = state.managers.data.values.keys.original.length;
|
|
2176
|
+
rowLoop: for (let keyIndex = 0; keyIndex < keysLength; keyIndex += 1) {
|
|
2177
|
+
const key = state.managers.data.values.keys.original[keyIndex];
|
|
2178
|
+
if (key instanceof GroupComponent) {
|
|
2179
|
+
filtered.push(key);
|
|
2148
2180
|
continue;
|
|
2149
2181
|
}
|
|
2150
|
-
const row = state.managers.data.
|
|
2182
|
+
const row = state.managers.data.values.objects.mapped.get(key);
|
|
2151
2183
|
if (row == null) continue;
|
|
2152
2184
|
filterLoop: for (let filterIndex = 0; filterIndex < filters.length; filterIndex += 1) {
|
|
2153
2185
|
const [field, items] = filters[filterIndex];
|
|
@@ -2158,23 +2190,16 @@ var FilterManager = class {
|
|
|
2158
2190
|
}
|
|
2159
2191
|
continue rowLoop;
|
|
2160
2192
|
}
|
|
2161
|
-
filtered.push(
|
|
2193
|
+
filtered.push(key);
|
|
2162
2194
|
}
|
|
2163
|
-
state.managers.data.
|
|
2195
|
+
state.managers.data.values.keys.active = filtered;
|
|
2164
2196
|
if (state.managers.sort.items.length > 0) state.managers.sort.sort();
|
|
2165
2197
|
else state.managers.render.update(true, true);
|
|
2166
2198
|
}
|
|
2167
2199
|
remove(value) {
|
|
2168
2200
|
if (typeof value === "string") {
|
|
2169
2201
|
if (this.items[value] == null) return;
|
|
2170
|
-
|
|
2171
|
-
const filters = Object.keys(this.items);
|
|
2172
|
-
const { length } = filters;
|
|
2173
|
-
for (let index = 0; index < length; index += 1) {
|
|
2174
|
-
const field = filters[index];
|
|
2175
|
-
if (field !== value) keyed[field] = this.items[field];
|
|
2176
|
-
}
|
|
2177
|
-
this.items = keyed;
|
|
2202
|
+
this.items = {};
|
|
2178
2203
|
} else {
|
|
2179
2204
|
const { field } = value;
|
|
2180
2205
|
if (this.items[field] == null) return;
|
|
@@ -2207,18 +2232,10 @@ const comparators = {
|
|
|
2207
2232
|
"starts-with": (row, filter) => startsWith(getString(row), getString(filter), true)
|
|
2208
2233
|
};
|
|
2209
2234
|
const equalizer = equal.initialize({ ignoreCase: true });
|
|
2210
|
-
//#endregion
|
|
2211
|
-
//#region src/managers/group.manager.ts
|
|
2212
2235
|
var GroupManager = class {
|
|
2213
2236
|
collapsed = /* @__PURE__ */ new Set();
|
|
2214
2237
|
enabled = false;
|
|
2215
2238
|
field;
|
|
2216
|
-
handlers = Object.freeze({ set: (group) => {
|
|
2217
|
-
if (group === this.field) return;
|
|
2218
|
-
this.enabled = !isNullableOrWhitespace(group);
|
|
2219
|
-
this.field = group ?? "";
|
|
2220
|
-
this.state.managers.data.set(this.state.managers.data.get());
|
|
2221
|
-
} });
|
|
2222
2239
|
items = [];
|
|
2223
2240
|
order = {};
|
|
2224
2241
|
constructor(state) {
|
|
@@ -2230,60 +2247,39 @@ var GroupManager = class {
|
|
|
2230
2247
|
add(group) {
|
|
2231
2248
|
this.set([...this.items, group]);
|
|
2232
2249
|
}
|
|
2233
|
-
clear() {
|
|
2234
|
-
const groups = this.items.splice(0);
|
|
2235
|
-
const { length } = groups;
|
|
2236
|
-
for (let index = 0; index < length; index += 1) this.remove(groups[index]);
|
|
2237
|
-
}
|
|
2238
|
-
destroy() {
|
|
2239
|
-
const groups = this.items.splice(0);
|
|
2240
|
-
const { length } = groups;
|
|
2241
|
-
for (let index = 0; index < length; index += 1) removeGroup(groups[index]);
|
|
2242
|
-
this.collapsed.clear();
|
|
2243
|
-
this.handlers = void 0;
|
|
2244
|
-
this.state = void 0;
|
|
2245
|
-
}
|
|
2246
2250
|
get(value) {
|
|
2247
|
-
|
|
2248
|
-
return this.items.find((item) => item.value.stringified === asString);
|
|
2251
|
+
return this.items.find((item) => item.value === value);
|
|
2249
2252
|
}
|
|
2250
2253
|
handle(button) {
|
|
2251
|
-
const
|
|
2252
|
-
const group = this.get(
|
|
2254
|
+
const key = button.dataset.key;
|
|
2255
|
+
const group = this.get(key);
|
|
2253
2256
|
if (group == null) return;
|
|
2254
2257
|
const { collapsed, items, state } = this;
|
|
2255
2258
|
group.expanded = !group.expanded;
|
|
2256
2259
|
const index = items.indexOf(group);
|
|
2257
|
-
let first = state.managers.data.
|
|
2258
|
-
const last = items[index + 1] == null ? state.managers.data.
|
|
2260
|
+
let first = state.managers.data.values.keys.original.indexOf(items[index]) + 1;
|
|
2261
|
+
const last = items[index + 1] == null ? state.managers.data.keys.length - 1 : state.managers.data.values.keys.original.indexOf(items[index + 1]) - 1;
|
|
2259
2262
|
for (; first <= last; first += 1) {
|
|
2260
|
-
const key = state.managers.data.
|
|
2263
|
+
const key = state.managers.data.values.keys.original[first];
|
|
2261
2264
|
if (group.expanded) collapsed.delete(key);
|
|
2262
2265
|
else collapsed.add(key);
|
|
2263
2266
|
}
|
|
2264
|
-
|
|
2265
|
-
else if (state.managers.sort.items.length > 0) state.managers.sort.sort();
|
|
2266
|
-
else state.managers.render.update(true, true);
|
|
2267
|
+
state.managers.render.update(true, true);
|
|
2267
2268
|
}
|
|
2268
2269
|
remove(group) {
|
|
2269
|
-
removeGroup(group);
|
|
2270
2270
|
this.set(this.items.filter((item) => item !== group));
|
|
2271
2271
|
}
|
|
2272
2272
|
set(items) {
|
|
2273
2273
|
this.items = sort(items, (item) => item.label);
|
|
2274
|
-
this.order = toRecord(items,
|
|
2274
|
+
this.order = toRecord(items, "value", (_, index) => index);
|
|
2275
2275
|
}
|
|
2276
2276
|
};
|
|
2277
|
-
//#endregion
|
|
2278
|
-
//#region src/helpers/misc.helpers.ts
|
|
2279
2277
|
function getKey(value) {
|
|
2280
2278
|
if (typeof value === "number") return value;
|
|
2281
2279
|
if (typeof value !== "string") return;
|
|
2282
2280
|
return integerExpression.test(value) ? Number.parseInt(value, 10) : value;
|
|
2283
2281
|
}
|
|
2284
2282
|
const integerExpression = /^\d+$/;
|
|
2285
|
-
//#endregion
|
|
2286
|
-
//#region src/managers/navigation.manager.ts
|
|
2287
2283
|
var NavigationManager = class {
|
|
2288
2284
|
active;
|
|
2289
2285
|
constructor(state) {
|
|
@@ -2297,28 +2293,28 @@ var NavigationManager = class {
|
|
|
2297
2293
|
event.preventDefault();
|
|
2298
2294
|
const { components, id, managers } = this.state;
|
|
2299
2295
|
const activeDescendant = components.body.elements.group.getAttribute("aria-activedescendant");
|
|
2300
|
-
const {
|
|
2301
|
-
const { length } =
|
|
2296
|
+
const { keys } = managers.data;
|
|
2297
|
+
const { length } = keys;
|
|
2302
2298
|
let next;
|
|
2303
2299
|
if (isNullableOrWhitespace(activeDescendant)) next = getDefaultIndex(event.key, length);
|
|
2304
|
-
else next = getIndex(
|
|
2305
|
-
if (next != null) this.setActive(
|
|
2300
|
+
else next = getIndex(event, activeDescendant, id, keys);
|
|
2301
|
+
if (next != null) this.setActive(keys.at(next));
|
|
2306
2302
|
}
|
|
2307
|
-
setActive(
|
|
2308
|
-
const { components,
|
|
2309
|
-
this.active =
|
|
2303
|
+
setActive(key, scroll) {
|
|
2304
|
+
const { components, managers, options } = this.state;
|
|
2305
|
+
this.active = key;
|
|
2310
2306
|
const active = components.body.elements.group.querySelectorAll("[data-active=\"true\"]");
|
|
2311
2307
|
for (const item of active) item.setAttribute("data-active", "false");
|
|
2312
|
-
const
|
|
2313
|
-
if (
|
|
2314
|
-
|
|
2315
|
-
if (scroll ?? true) if (
|
|
2316
|
-
top: managers.data.getIndex(
|
|
2308
|
+
const row = managers.row.get(key);
|
|
2309
|
+
if (row != null) {
|
|
2310
|
+
row.element?.setAttribute("data-active", "true");
|
|
2311
|
+
if (scroll ?? true) if (row.element == null) components.body.elements.group.scrollTo({
|
|
2312
|
+
top: managers.data.getIndex(key) * options.rowHeight,
|
|
2317
2313
|
behavior: "smooth"
|
|
2318
2314
|
});
|
|
2319
|
-
else
|
|
2315
|
+
else row.element.scrollIntoView({ block: "nearest" });
|
|
2320
2316
|
}
|
|
2321
|
-
components.body.elements.group.setAttribute("aria-activedescendant",
|
|
2317
|
+
components.body.elements.group.setAttribute("aria-activedescendant", row == null ? "" : `tabela_${this.state.id}_row_${key}`);
|
|
2322
2318
|
}
|
|
2323
2319
|
};
|
|
2324
2320
|
function getDefaultIndex(key, max) {
|
|
@@ -2329,11 +2325,11 @@ function getDefaultIndex(key, max) {
|
|
|
2329
2325
|
default: return 0;
|
|
2330
2326
|
}
|
|
2331
2327
|
}
|
|
2332
|
-
function getIndex(
|
|
2333
|
-
const key = getKey(active.replace(`tabela_${id}
|
|
2328
|
+
function getIndex(event, active, id, keys) {
|
|
2329
|
+
const key = getKey(active.replace(`tabela_${id}_row_`, ""));
|
|
2334
2330
|
if (key == null) return;
|
|
2335
|
-
if (absoluteKeys.has(event.key)) return event.key === "Home" ? 0 :
|
|
2336
|
-
return clamp(
|
|
2331
|
+
if (absoluteKeys.has(event.key)) return event.key === "Home" ? 0 : keys.length - 1;
|
|
2332
|
+
return clamp(keys.indexOf(key) + getOffset(event.key), 0, keys.length - 1, true);
|
|
2337
2333
|
}
|
|
2338
2334
|
function getOffset(key) {
|
|
2339
2335
|
switch (key) {
|
|
@@ -2353,8 +2349,6 @@ const allKeys = new Set([
|
|
|
2353
2349
|
...arrowKeys,
|
|
2354
2350
|
...pageKeys
|
|
2355
2351
|
]);
|
|
2356
|
-
//#endregion
|
|
2357
|
-
//#region src/components/row.component.ts
|
|
2358
2352
|
function removeRow(pool, row) {
|
|
2359
2353
|
if (row.element != null) {
|
|
2360
2354
|
row.element.innerHTML = "";
|
|
@@ -2375,20 +2369,20 @@ function renderRow(state, row) {
|
|
|
2375
2369
|
"data-active": String(state.managers.navigation.active === row.key),
|
|
2376
2370
|
"data-event": "row",
|
|
2377
2371
|
"data-key": key,
|
|
2378
|
-
id: `tabela_${state.id}
|
|
2372
|
+
id: `tabela_${state.id}_row_${key}`
|
|
2379
2373
|
});
|
|
2380
|
-
element.classList.add(
|
|
2381
|
-
if (selected) element.classList.add(
|
|
2382
|
-
else element.classList.remove(
|
|
2374
|
+
element.classList.add("tabela__row--body");
|
|
2375
|
+
if (selected) element.classList.add("tabela__row--selected");
|
|
2376
|
+
else element.classList.remove("tabela__row--selected");
|
|
2383
2377
|
const columns = state.managers.column.items;
|
|
2384
2378
|
const { length } = columns;
|
|
2385
|
-
const data = state.managers.data.
|
|
2379
|
+
const data = state.managers.data.values.objects.mapped.get(row.key);
|
|
2386
2380
|
if (data == null) return;
|
|
2387
2381
|
for (let index = 0; index < length; index += 1) {
|
|
2388
2382
|
const { options } = columns[index];
|
|
2389
2383
|
state.managers.render.pool.cells[options.field] ??= [];
|
|
2390
2384
|
const cell = state.managers.render.pool.cells[columns[index].options.field].shift() ?? createCell(options.width);
|
|
2391
|
-
cell.textContent = String(
|
|
2385
|
+
cell.textContent = String(data[options.field]);
|
|
2392
2386
|
row.cells[options.field] = cell;
|
|
2393
2387
|
element.append(cell);
|
|
2394
2388
|
}
|
|
@@ -2400,21 +2394,17 @@ var RowComponent = class {
|
|
|
2400
2394
|
this.key = key;
|
|
2401
2395
|
}
|
|
2402
2396
|
};
|
|
2403
|
-
//#endregion
|
|
2404
|
-
//#region src/managers/render.manager.ts
|
|
2405
2397
|
function getRange(state, down) {
|
|
2406
|
-
const {
|
|
2407
|
-
const { clientHeight, scrollTop } =
|
|
2408
|
-
const {
|
|
2409
|
-
const
|
|
2410
|
-
const
|
|
2411
|
-
const
|
|
2412
|
-
const
|
|
2413
|
-
const
|
|
2414
|
-
const after = Math.ceil(visible) * (down ? 2 : 1);
|
|
2415
|
-
const start = Math.max(0, firstIndex - before);
|
|
2398
|
+
const { components, managers, options } = state;
|
|
2399
|
+
const { clientHeight, scrollTop } = components.body.elements.group;
|
|
2400
|
+
const { keys } = managers.data;
|
|
2401
|
+
const first = Math.floor(scrollTop / options.rowHeight);
|
|
2402
|
+
const last = Math.min(keys.length - managers.group.collapsed.size - 1, Math.ceil((scrollTop + clientHeight) / options.rowHeight) - 1);
|
|
2403
|
+
const before = Math.ceil(clientHeight / options.rowHeight) * (down ? 1 : 2);
|
|
2404
|
+
const after = Math.ceil(clientHeight / options.rowHeight) * (down ? 2 : 1);
|
|
2405
|
+
const start = Math.max(0, first - before);
|
|
2416
2406
|
return {
|
|
2417
|
-
end: Math.min(
|
|
2407
|
+
end: Math.min(keys.length - managers.group.collapsed.size - 1, last + after),
|
|
2418
2408
|
start
|
|
2419
2409
|
};
|
|
2420
2410
|
}
|
|
@@ -2422,7 +2412,7 @@ function onScroll() {
|
|
|
2422
2412
|
const { state } = this;
|
|
2423
2413
|
if (!state.active) {
|
|
2424
2414
|
requestAnimationFrame(() => {
|
|
2425
|
-
const top = state.
|
|
2415
|
+
const top = state.components.body.elements.group.scrollTop;
|
|
2426
2416
|
this.update(top > state.top);
|
|
2427
2417
|
state.active = false;
|
|
2428
2418
|
state.top = top;
|
|
@@ -2440,7 +2430,7 @@ var RenderManager = class {
|
|
|
2440
2430
|
state;
|
|
2441
2431
|
visible = /* @__PURE__ */ new Map();
|
|
2442
2432
|
constructor(state) {
|
|
2443
|
-
this.listener = on(state.
|
|
2433
|
+
this.listener = on(state.components.body.elements.group, "scroll", onScroll.bind(this));
|
|
2444
2434
|
this.state = {
|
|
2445
2435
|
...state,
|
|
2446
2436
|
active: false,
|
|
@@ -2451,11 +2441,6 @@ var RenderManager = class {
|
|
|
2451
2441
|
const { listener, pool, visible } = this;
|
|
2452
2442
|
listener();
|
|
2453
2443
|
visible.clear();
|
|
2454
|
-
const cells = Object.values(pool.cells).flat();
|
|
2455
|
-
let { length } = cells;
|
|
2456
|
-
for (let index = 0; index < length; index += 1) cells[index].remove();
|
|
2457
|
-
length = pool.rows.length;
|
|
2458
|
-
for (let index = 0; index < length; index += 1) pool.rows[index].remove();
|
|
2459
2444
|
pool.cells = {};
|
|
2460
2445
|
pool.rows = [];
|
|
2461
2446
|
this.fragment = void 0;
|
|
@@ -2470,7 +2455,7 @@ var RenderManager = class {
|
|
|
2470
2455
|
for (let index = 0; index < length; index += 1) delete pool.cells[fields[index]];
|
|
2471
2456
|
for (const [, key] of visible) {
|
|
2472
2457
|
if (key instanceof GroupComponent) continue;
|
|
2473
|
-
const row = state.managers.row.get(key
|
|
2458
|
+
const row = state.managers.row.get(key);
|
|
2474
2459
|
if (row == null || row.element == null) continue;
|
|
2475
2460
|
for (let index = 0; index < length; index += 1) {
|
|
2476
2461
|
row.cells[fields[index]].innerHTML = "";
|
|
@@ -2500,38 +2485,38 @@ var RenderManager = class {
|
|
|
2500
2485
|
}
|
|
2501
2486
|
continue;
|
|
2502
2487
|
}
|
|
2503
|
-
const row = managers.row.get(key
|
|
2488
|
+
const row = managers.row.get(key);
|
|
2504
2489
|
if (remove || row == null || !indices.has(index) || managers.group.collapsed.has(key)) {
|
|
2505
2490
|
visible.delete(index);
|
|
2506
2491
|
if (row != null) removeRow(pool, row);
|
|
2507
2492
|
}
|
|
2508
2493
|
}
|
|
2509
2494
|
const fragment = this.getFragment();
|
|
2510
|
-
const {
|
|
2495
|
+
const { keys } = managers.data;
|
|
2511
2496
|
let count = 0;
|
|
2512
2497
|
let offset = 0;
|
|
2513
2498
|
for (let index = range.start; index <= range.end + offset; index += 1) {
|
|
2514
2499
|
if (visible.has(index)) continue;
|
|
2515
|
-
const
|
|
2516
|
-
if (
|
|
2500
|
+
const key = keys[index];
|
|
2501
|
+
if (key instanceof GroupComponent) {
|
|
2517
2502
|
count += 1;
|
|
2518
|
-
renderGroup(state,
|
|
2519
|
-
visible.set(index,
|
|
2520
|
-
if (
|
|
2521
|
-
|
|
2522
|
-
fragment.append(
|
|
2503
|
+
renderGroup(state, key);
|
|
2504
|
+
visible.set(index, key);
|
|
2505
|
+
if (key.element != null) {
|
|
2506
|
+
key.element.style.transform = `translateY(${(index - offset) * options.rowHeight}px)`;
|
|
2507
|
+
fragment.append(key.element);
|
|
2523
2508
|
}
|
|
2524
2509
|
continue;
|
|
2525
2510
|
}
|
|
2526
|
-
const row = managers.row.get(
|
|
2511
|
+
const row = managers.row.get(key);
|
|
2527
2512
|
if (row == null) continue;
|
|
2528
|
-
if (managers.group.collapsed.has(
|
|
2513
|
+
if (managers.group.collapsed.has(key)) {
|
|
2529
2514
|
offset += 1;
|
|
2530
2515
|
continue;
|
|
2531
2516
|
}
|
|
2532
2517
|
count += 1;
|
|
2533
2518
|
renderRow(state, row);
|
|
2534
|
-
visible.set(index,
|
|
2519
|
+
visible.set(index, key);
|
|
2535
2520
|
if (row.element != null) {
|
|
2536
2521
|
row.element.style.transform = `translateY(${(index - offset) * options.rowHeight}px)`;
|
|
2537
2522
|
fragment.append(row.element);
|
|
@@ -2540,28 +2525,22 @@ var RenderManager = class {
|
|
|
2540
2525
|
if (count > 0) components.body.elements.group[down ? "append" : "prepend"](fragment);
|
|
2541
2526
|
}
|
|
2542
2527
|
};
|
|
2543
|
-
//#endregion
|
|
2544
|
-
//#region src/managers/row.manager.ts
|
|
2545
2528
|
var RowManager = class {
|
|
2546
2529
|
components = /* @__PURE__ */ new Map();
|
|
2547
2530
|
constructor(state) {
|
|
2548
2531
|
this.state = state;
|
|
2549
2532
|
}
|
|
2550
|
-
clear() {
|
|
2551
|
-
const { components } = this;
|
|
2552
|
-
const rows = [...components.values()];
|
|
2553
|
-
const { length } = rows;
|
|
2554
|
-
for (let index = 0; index < length; index += 1) this.removeRow(rows[index]);
|
|
2555
|
-
components.clear();
|
|
2556
|
-
}
|
|
2557
2533
|
destroy() {
|
|
2558
|
-
this.
|
|
2534
|
+
const components = [...this.components.values()];
|
|
2535
|
+
const { length } = components;
|
|
2536
|
+
for (let index = 0; index < length; index += 1) removeRow(this.state.managers.render.pool, components[index]);
|
|
2537
|
+
this.components.clear();
|
|
2559
2538
|
this.components = void 0;
|
|
2560
2539
|
this.state = void 0;
|
|
2561
2540
|
}
|
|
2562
|
-
get(key
|
|
2541
|
+
get(key) {
|
|
2563
2542
|
let row = this.components.get(key);
|
|
2564
|
-
if (row == null
|
|
2543
|
+
if (row == null) {
|
|
2565
2544
|
row = new RowComponent(key);
|
|
2566
2545
|
this.components.set(key, row);
|
|
2567
2546
|
}
|
|
@@ -2572,25 +2551,20 @@ var RowManager = class {
|
|
|
2572
2551
|
}
|
|
2573
2552
|
remove(key) {
|
|
2574
2553
|
const row = this.components.get(key);
|
|
2575
|
-
if (row != null)
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
this.components.delete(row.key);
|
|
2554
|
+
if (row != null) {
|
|
2555
|
+
removeRow(this.state.managers.render.pool, row);
|
|
2556
|
+
this.components.delete(key);
|
|
2557
|
+
}
|
|
2580
2558
|
}
|
|
2581
2559
|
update(key) {
|
|
2582
2560
|
const row = this.components.get(key);
|
|
2583
2561
|
if (row != null) renderRow(this.state, row);
|
|
2584
2562
|
}
|
|
2585
2563
|
};
|
|
2586
|
-
|
|
2587
|
-
//#region src/helpers/style.helper.ts
|
|
2588
|
-
const preventSelection = toggleStyles(document.body, {
|
|
2564
|
+
const dragStyling = toggleStyles(document.body, {
|
|
2589
2565
|
userSelect: "none",
|
|
2590
2566
|
webkitUserSelect: "none"
|
|
2591
2567
|
});
|
|
2592
|
-
//#endregion
|
|
2593
|
-
//#region src/managers/selection.manager.ts
|
|
2594
2568
|
var SelectionManager = class {
|
|
2595
2569
|
handlers = Object.freeze({
|
|
2596
2570
|
add: (keys) => this.add(keys),
|
|
@@ -2654,15 +2628,15 @@ var SelectionManager = class {
|
|
|
2654
2628
|
const fromKey = keyed ? from : getKey(from.getAttribute("data-key"));
|
|
2655
2629
|
const toKey = keyed ? to : getKey(to.getAttribute("data-key"));
|
|
2656
2630
|
if (fromKey === toKey) return;
|
|
2657
|
-
const {
|
|
2631
|
+
const { keys } = state.managers.data;
|
|
2658
2632
|
const fromIndex = state.managers.data.getIndex(fromKey);
|
|
2659
2633
|
const toIndex = state.managers.data.getIndex(toKey);
|
|
2660
2634
|
if (fromIndex === -1 || toIndex === -1) return;
|
|
2661
2635
|
const [start, end] = fromIndex < toIndex ? [fromIndex, toIndex] : [toIndex, fromIndex];
|
|
2662
2636
|
const selected = [];
|
|
2663
2637
|
for (let index = start; index <= end; index += 1) {
|
|
2664
|
-
const
|
|
2665
|
-
if (!(
|
|
2638
|
+
const key = keys[index];
|
|
2639
|
+
if (!(key instanceof GroupComponent)) selected.push(key);
|
|
2666
2640
|
}
|
|
2667
2641
|
if (keyed) this.add(selected);
|
|
2668
2642
|
else this.set(selected);
|
|
@@ -2688,12 +2662,11 @@ var SelectionManager = class {
|
|
|
2688
2662
|
}
|
|
2689
2663
|
toggle() {
|
|
2690
2664
|
const { items, state } = this;
|
|
2691
|
-
const
|
|
2692
|
-
if (items.size ===
|
|
2693
|
-
else this.set(
|
|
2665
|
+
const { keys } = state.managers.data;
|
|
2666
|
+
if (items.size === keys.length - state.managers.group.items.length) this.clear();
|
|
2667
|
+
else this.set(keys.filter((key) => !(key instanceof GroupComponent)));
|
|
2694
2668
|
}
|
|
2695
2669
|
update(removed) {
|
|
2696
|
-
const { state } = this;
|
|
2697
2670
|
const items = [...removed.map((key) => ({
|
|
2698
2671
|
key,
|
|
2699
2672
|
removed: true
|
|
@@ -2701,28 +2674,28 @@ var SelectionManager = class {
|
|
|
2701
2674
|
key,
|
|
2702
2675
|
removed: false
|
|
2703
2676
|
}))];
|
|
2704
|
-
|
|
2677
|
+
const { length } = items;
|
|
2705
2678
|
for (let index = 0; index < length; index += 1) {
|
|
2706
2679
|
const { key, removed } = items[index];
|
|
2707
|
-
const
|
|
2708
|
-
if (element == null) continue;
|
|
2709
|
-
setAttribute(element, "aria-selected", String(!removed));
|
|
2710
|
-
if (removed) element.classList.remove(
|
|
2711
|
-
else element.classList.add(
|
|
2680
|
+
const row = this.state.managers.row.get(key);
|
|
2681
|
+
if (row == null || row.element == null) continue;
|
|
2682
|
+
setAttribute(row.element, "aria-selected", String(!removed));
|
|
2683
|
+
if (removed) row.element.classList.remove("tabela__row--selected");
|
|
2684
|
+
else row.element.classList.add("tabela__row--selected");
|
|
2712
2685
|
}
|
|
2713
2686
|
}
|
|
2714
2687
|
};
|
|
2715
2688
|
function getPlaceholder() {
|
|
2716
|
-
placeholder ??= createElement("div", { className:
|
|
2689
|
+
placeholder ??= createElement("div", { className: "tabela__selection--placeholder" }, {}, {});
|
|
2717
2690
|
return placeholder;
|
|
2718
2691
|
}
|
|
2719
2692
|
function onMouseDown(event) {
|
|
2720
2693
|
if (shifted) {
|
|
2721
|
-
const row = findAncestor(event.target,
|
|
2694
|
+
const row = findAncestor(event.target, ".tabela__row--body");
|
|
2722
2695
|
if (!(row instanceof HTMLElement)) return;
|
|
2723
2696
|
startElement = row;
|
|
2724
2697
|
startPosition = getPosition(event);
|
|
2725
|
-
|
|
2698
|
+
dragStyling.set();
|
|
2726
2699
|
}
|
|
2727
2700
|
}
|
|
2728
2701
|
function onMouseMove(event) {
|
|
@@ -2743,14 +2716,14 @@ function onMouseUp(event) {
|
|
|
2743
2716
|
if (startElement == null) return;
|
|
2744
2717
|
if (!event.shiftKey) {
|
|
2745
2718
|
shifted = false;
|
|
2746
|
-
|
|
2719
|
+
dragStyling.remove();
|
|
2747
2720
|
}
|
|
2748
2721
|
getPlaceholder().remove();
|
|
2749
2722
|
const row = findAncestor(event.target, ".tabela__row--body");
|
|
2750
2723
|
if (row instanceof HTMLElement) {
|
|
2751
2724
|
endElement = row;
|
|
2752
|
-
const endTable = findAncestor(endElement, ".
|
|
2753
|
-
const startTable = findAncestor(startElement, ".
|
|
2725
|
+
const endTable = findAncestor(endElement, ".tabela");
|
|
2726
|
+
const startTable = findAncestor(startElement, ".tabela");
|
|
2754
2727
|
if (startTable != null && startTable === endTable) mapped.get(startTable)?.range(startElement, endElement);
|
|
2755
2728
|
}
|
|
2756
2729
|
endElement = void 0;
|
|
@@ -2777,158 +2750,12 @@ on(document, "keyup", onShiftUp);
|
|
|
2777
2750
|
on(document, "mousedown", onMouseDown);
|
|
2778
2751
|
on(document, "mousemove", onMouseMove);
|
|
2779
2752
|
on(document, "mouseup", onMouseUp);
|
|
2780
|
-
//#endregion
|
|
2781
|
-
//#region src/managers/style.manager.ts
|
|
2782
|
-
var StyleManager = class {
|
|
2783
|
-
constructor(state) {
|
|
2784
|
-
this.state = state;
|
|
2785
|
-
if (appended) return;
|
|
2786
|
-
appended = true;
|
|
2787
|
-
const style = document.createElement("style");
|
|
2788
|
-
style.textContent = styling;
|
|
2789
|
-
document.head.appendChild(style);
|
|
2790
|
-
}
|
|
2791
|
-
};
|
|
2792
|
-
const styling = `/** Table */
|
|
2793
|
-
|
|
2794
|
-
:where(.tabela) {
|
|
2795
|
-
flex: 1;
|
|
2796
|
-
position: relative;
|
|
2797
|
-
background-color: var(--oui-absolute);
|
|
2798
|
-
border: 1px solid grey;
|
|
2799
|
-
}
|
|
2800
|
-
|
|
2801
|
-
:where(.tabela__table) {
|
|
2802
|
-
min-height: 24em;
|
|
2803
|
-
display: flex;
|
|
2804
|
-
flex-flow: column nowrap;
|
|
2805
|
-
flex: 1;
|
|
2806
|
-
overflow: auto;
|
|
2807
|
-
position: absolute;
|
|
2808
|
-
inset: 0;
|
|
2809
|
-
}
|
|
2810
|
-
|
|
2811
|
-
/** Row group */
|
|
2812
|
-
|
|
2813
|
-
:where(.tabela__rowgroup--header),
|
|
2814
|
-
:where(.tabela__rowgroup--footer) {
|
|
2815
|
-
background-color: white;
|
|
2816
|
-
position: sticky;
|
|
2817
|
-
left: 0;
|
|
2818
|
-
z-index: 10;
|
|
2819
|
-
}
|
|
2820
|
-
|
|
2821
|
-
:where(.tabela__rowgroup--header) {
|
|
2822
|
-
top: 0;
|
|
2823
|
-
}
|
|
2824
|
-
|
|
2825
|
-
:where(.tabela__rowgroup--footer) {
|
|
2826
|
-
bottom: 0;
|
|
2827
|
-
}
|
|
2828
|
-
|
|
2829
|
-
:where(.tabela__rowgroup--body) {
|
|
2830
|
-
display: flex;
|
|
2831
|
-
flex-flow: column nowrap;
|
|
2832
|
-
flex: 1;
|
|
2833
|
-
}
|
|
2834
|
-
|
|
2835
|
-
:where(.tabela__rowgroup--body:focus) {
|
|
2836
|
-
outline: none;
|
|
2837
|
-
}
|
|
2838
|
-
|
|
2839
|
-
:where(.tabela:has(.tabela__rowgroup--body:focus-visible)) {
|
|
2840
|
-
outline: 2px solid var(--oui-blue-6);
|
|
2841
|
-
outline-offset: 2px;
|
|
2842
|
-
}
|
|
2843
|
-
|
|
2844
|
-
/** Row */
|
|
2845
|
-
|
|
2846
|
-
:where(.tabela__row) {
|
|
2847
|
-
width: 100%;
|
|
2848
|
-
display: flex;
|
|
2849
|
-
flex-flow: row nowrap;
|
|
2850
|
-
}
|
|
2851
|
-
|
|
2852
|
-
:where(.tabela__row:last-child .tabela__cell) {
|
|
2853
|
-
border-bottom-width: 0;
|
|
2854
|
-
}
|
|
2855
|
-
|
|
2856
|
-
:where(.tabela__row--body),
|
|
2857
|
-
:where(.tabela__row--group) {
|
|
2858
|
-
flex: 1;
|
|
2859
|
-
position: absolute;
|
|
2860
|
-
}
|
|
2861
|
-
|
|
2862
|
-
:where(.tabela__row--selected) {
|
|
2863
|
-
background-color: var(--oui-blue-1);
|
|
2864
|
-
color: var(--oui-blue-9);
|
|
2865
|
-
}
|
|
2866
|
-
|
|
2867
|
-
:where(.tabela:has(.tabela__rowgroup--body:focus-visible) .tabela__row[data-active="true"]) {
|
|
2868
|
-
outline: 2px solid var(--oui-blue-6);
|
|
2869
|
-
outline-offset: 2px;
|
|
2870
|
-
}
|
|
2871
|
-
|
|
2872
|
-
/** Cells */
|
|
2873
|
-
|
|
2874
|
-
:where(.tabela__cell),
|
|
2875
|
-
:where(.tabela__heading) {
|
|
2876
|
-
padding: 0.5em;
|
|
2877
|
-
border-color: gray;
|
|
2878
|
-
border-style: solid;
|
|
2879
|
-
border-width: 0 1px 1px 0;
|
|
2880
|
-
line-height: 1;
|
|
2881
|
-
}
|
|
2882
|
-
|
|
2883
|
-
:where(.tabela__row .tabela__cell:last-child),
|
|
2884
|
-
:where(.tabela__row .tabela__heading:last-child) {
|
|
2885
|
-
flex: 1;
|
|
2886
|
-
border-right-width: 0;
|
|
2887
|
-
}
|
|
2888
|
-
|
|
2889
|
-
:where(.tabela__cell) {
|
|
2890
|
-
overflow: hidden;
|
|
2891
|
-
text-overflow: ellipsis;
|
|
2892
|
-
white-space: nowrap;
|
|
2893
|
-
}
|
|
2894
|
-
|
|
2895
|
-
:where(.tabela__cell--footer) {
|
|
2896
|
-
border-top-width: 1px;
|
|
2897
|
-
border-bottom-width: 0;
|
|
2898
|
-
}
|
|
2899
|
-
|
|
2900
|
-
:where(.tabela__cell--group) {
|
|
2901
|
-
padding: 0;
|
|
2902
|
-
display: flex;
|
|
2903
|
-
flex-flow: row nowrap;
|
|
2904
|
-
align-items: center;
|
|
2905
|
-
gap: 0.5em;
|
|
2906
|
-
}
|
|
2907
|
-
|
|
2908
|
-
:where(.tabela__cell--group .tabela__button) {
|
|
2909
|
-
margin: 0 0 0 .25rem;
|
|
2910
|
-
}
|
|
2911
|
-
|
|
2912
|
-
/** Misc. */
|
|
2913
|
-
|
|
2914
|
-
:where(.tabela__button) {
|
|
2915
|
-
font-size: .75rem;
|
|
2916
|
-
font-weight: bold;
|
|
2917
|
-
}
|
|
2918
|
-
|
|
2919
|
-
:where(.tabela__selection) {
|
|
2920
|
-
background-color: color-mix(in oklch, var(--oui-blue-6), transparent);
|
|
2921
|
-
border: 1px solid var(--oui-blue-6);
|
|
2922
|
-
border-radius: .25rem;
|
|
2923
|
-
position: fixed;
|
|
2924
|
-
z-index: 1000;
|
|
2925
|
-
}
|
|
2926
|
-
`.replace(/^\s+|\s+|\s+$/g, " ");
|
|
2927
|
-
let appended = false;
|
|
2928
|
-
//#endregion
|
|
2929
|
-
//#region src/tabela.ts
|
|
2930
2753
|
var Tabela = class {
|
|
2931
|
-
#components
|
|
2754
|
+
#components = {
|
|
2755
|
+
header: void 0,
|
|
2756
|
+
body: void 0,
|
|
2757
|
+
footer: void 0
|
|
2758
|
+
};
|
|
2932
2759
|
#element;
|
|
2933
2760
|
#id = getId();
|
|
2934
2761
|
#table;
|
|
@@ -2943,13 +2770,10 @@ var Tabela = class {
|
|
|
2943
2770
|
render: void 0,
|
|
2944
2771
|
row: void 0,
|
|
2945
2772
|
selection: void 0,
|
|
2946
|
-
sort: void 0
|
|
2947
|
-
style: void 0
|
|
2773
|
+
sort: void 0
|
|
2948
2774
|
};
|
|
2949
|
-
#state;
|
|
2950
2775
|
data;
|
|
2951
2776
|
filter;
|
|
2952
|
-
group;
|
|
2953
2777
|
selection;
|
|
2954
2778
|
sort;
|
|
2955
2779
|
get key() {
|
|
@@ -2958,18 +2782,17 @@ var Tabela = class {
|
|
|
2958
2782
|
constructor(element, options) {
|
|
2959
2783
|
this.#element = element;
|
|
2960
2784
|
element.innerHTML = "";
|
|
2961
|
-
element.classList.add(
|
|
2785
|
+
element.classList.add("tabela");
|
|
2962
2786
|
this.#table = createElement("div", {
|
|
2963
|
-
className:
|
|
2787
|
+
className: "tabela__table",
|
|
2964
2788
|
role: "table"
|
|
2965
|
-
}
|
|
2789
|
+
});
|
|
2790
|
+
element.setAttribute("aria-label", options.label);
|
|
2966
2791
|
this.#key = options.key;
|
|
2967
|
-
this.#components =
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
};
|
|
2972
|
-
this.#state = {
|
|
2792
|
+
this.#components.header = new HeaderComponent();
|
|
2793
|
+
this.#components.body = new BodyComponent();
|
|
2794
|
+
this.#components.footer = new FooterComponent();
|
|
2795
|
+
const state = {
|
|
2973
2796
|
options,
|
|
2974
2797
|
components: this.#components,
|
|
2975
2798
|
element: this.#table,
|
|
@@ -2977,23 +2800,20 @@ var Tabela = class {
|
|
|
2977
2800
|
key: this.#key,
|
|
2978
2801
|
managers: this.#managers
|
|
2979
2802
|
};
|
|
2980
|
-
this.#managers.column = new ColumnManager(
|
|
2981
|
-
this.#managers.data = new DataManager(
|
|
2982
|
-
this.#managers.event = new EventManager(
|
|
2983
|
-
this.#managers.filter = new FilterManager(
|
|
2984
|
-
this.#managers.group = new GroupManager(
|
|
2985
|
-
this.#managers.navigation = new NavigationManager(
|
|
2986
|
-
this.#managers.render = new RenderManager(
|
|
2987
|
-
this.#managers.row = new RowManager(
|
|
2988
|
-
this.#managers.selection = new SelectionManager(
|
|
2989
|
-
this.#managers.sort = new SortManager(
|
|
2990
|
-
this.#managers.style = new StyleManager(this.#state);
|
|
2803
|
+
this.#managers.column = new ColumnManager(state);
|
|
2804
|
+
this.#managers.data = new DataManager(state);
|
|
2805
|
+
this.#managers.event = new EventManager(state);
|
|
2806
|
+
this.#managers.filter = new FilterManager(state);
|
|
2807
|
+
this.#managers.group = new GroupManager(state);
|
|
2808
|
+
this.#managers.navigation = new NavigationManager(state);
|
|
2809
|
+
this.#managers.render = new RenderManager(state);
|
|
2810
|
+
this.#managers.row = new RowManager(state);
|
|
2811
|
+
this.#managers.selection = new SelectionManager(state);
|
|
2812
|
+
this.#managers.sort = new SortManager(state);
|
|
2991
2813
|
this.#table.append(this.#components.header.elements.group, this.#components.body.elements.group, this.#components.footer.elements.group);
|
|
2992
|
-
element.append(this.#table);
|
|
2993
2814
|
this.#managers.data.set(options.data);
|
|
2994
2815
|
this.data = this.#managers.data.handlers;
|
|
2995
2816
|
this.filter = this.#managers.filter.handlers;
|
|
2996
|
-
this.group = this.#managers.group.handlers;
|
|
2997
2817
|
this.selection = this.#managers.selection.handlers;
|
|
2998
2818
|
this.sort = this.#managers.sort.handlers;
|
|
2999
2819
|
}
|
|
@@ -3009,22 +2829,16 @@ var Tabela = class {
|
|
|
3009
2829
|
managers.data.destroy();
|
|
3010
2830
|
managers.event.destroy();
|
|
3011
2831
|
managers.filter.destroy();
|
|
3012
|
-
managers.group.destroy();
|
|
3013
2832
|
managers.navigation.destroy();
|
|
3014
2833
|
managers.render.destroy();
|
|
3015
2834
|
managers.row.destroy();
|
|
3016
2835
|
managers.selection.destroy();
|
|
3017
2836
|
managers.sort.destroy();
|
|
3018
2837
|
element.innerHTML = "";
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
element.classList.remove(CSS_TABELA);
|
|
2838
|
+
element.role = "";
|
|
2839
|
+
element.classList.remove("tabela");
|
|
3022
2840
|
table.removeAttribute("aria-label");
|
|
3023
2841
|
table.removeAttribute("role");
|
|
3024
|
-
this.#state.components = void 0;
|
|
3025
|
-
this.#state.managers = void 0;
|
|
3026
|
-
this.#state.element = void 0;
|
|
3027
|
-
this.#state.options = void 0;
|
|
3028
2842
|
this.#element = void 0;
|
|
3029
2843
|
this.#table = void 0;
|
|
3030
2844
|
}
|
|
@@ -3034,10 +2848,7 @@ function getId() {
|
|
|
3034
2848
|
return id;
|
|
3035
2849
|
}
|
|
3036
2850
|
let id = 0;
|
|
3037
|
-
//#endregion
|
|
3038
|
-
//#region src/index.ts
|
|
3039
2851
|
function tabela(element, options) {
|
|
3040
2852
|
return new Tabela(element, options);
|
|
3041
2853
|
}
|
|
3042
|
-
//#endregion
|
|
3043
2854
|
export { tabela };
|