@oscarpalmer/atoms 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/a11y.css +2 -0
- package/dist/css/reset.css +4 -9
- package/dist/js/array.js +10 -9
- package/dist/js/array.mjs +10 -9
- package/dist/js/element/index.js +9 -14
- package/dist/js/element/index.mjs +9 -14
- package/dist/js/index.js +180 -302
- package/dist/js/index.mjs +1 -1
- package/dist/js/is.js +5 -1
- package/dist/js/is.mjs +5 -1
- package/dist/js/number.js +4 -4
- package/dist/js/number.mjs +4 -4
- package/dist/js/queue.js +1 -1
- package/dist/js/queue.mjs +1 -1
- package/dist/js/timer.js +60 -40
- package/dist/js/timer.mjs +60 -40
- package/dist/js/value.js +17 -28
- package/dist/js/value.mjs +18 -31
- package/package.json +20 -10
- package/src/css/a11y.scss +2 -0
- package/src/css/reset.scss +5 -10
- package/src/js/array.ts +158 -102
- package/src/js/element/index.ts +22 -21
- package/src/js/event.ts +2 -5
- package/src/js/index.ts +1 -1
- package/src/js/is.ts +14 -7
- package/src/js/models.ts +22 -0
- package/src/js/number.ts +8 -4
- package/src/js/queue.ts +1 -1
- package/src/js/timer.ts +100 -64
- package/src/js/value.ts +75 -88
- package/types/array.d.ts +31 -18
- package/types/event.d.ts +2 -6
- package/types/index.d.ts +1 -1
- package/types/is.d.ts +7 -4
- package/types/models.d.ts +10 -0
- package/types/timer.d.ts +17 -8
- package/types/value.d.ts +15 -16
- package/dist/js/html/attribute.mjs +0 -123
- package/dist/js/html/event.mjs +0 -9
- package/dist/js/html/index.mjs +0 -56
- package/dist/js/html/models.mjs +0 -5
- package/dist/js/html/node.mjs +0 -74
- package/dist/js/proxy.js +0 -329
- package/dist/js/proxy.mjs +0 -131
- package/dist/js/random.mjs +0 -30
- package/dist/js/signal.js +0 -179
- package/dist/js/signal.mjs +0 -136
- package/dist/js/template/event.mjs +0 -5
- package/dist/js/template/index.mjs +0 -59
- package/dist/js/template/node.mjs +0 -92
- package/src/js/proxy.ts +0 -209
- package/types/proxy.d.ts +0 -18
package/dist/css/a11y.css
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
.visually-hidden:not(:active):not(:focus):not(:focus-within) {
|
|
5
5
|
width: 1px !important;
|
|
6
6
|
height: 1px !important;
|
|
7
|
+
padding: 0 !important;
|
|
7
8
|
clip: rect(1px, 1px 1px, 1px) !important;
|
|
8
9
|
clip-path: inset(50%) !important;
|
|
9
10
|
overflow: hidden !important;
|
|
11
|
+
border: 0 !important;
|
|
10
12
|
white-space: nowrap !important;
|
|
11
13
|
}
|
package/dist/css/reset.css
CHANGED
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
|
|
40
40
|
::before,
|
|
41
41
|
::after {
|
|
42
|
-
box-sizing: inherit;
|
|
43
42
|
text-decoration: inherit;
|
|
44
43
|
vertical-align: inherit;
|
|
45
44
|
}
|
|
@@ -83,6 +82,10 @@
|
|
|
83
82
|
font-weight: bolder;
|
|
84
83
|
}
|
|
85
84
|
|
|
85
|
+
:where(button, h1, h2, h3, h4, h5, h6, input, label, legend) {
|
|
86
|
+
line-height: 1.125;
|
|
87
|
+
}
|
|
88
|
+
|
|
86
89
|
:where(button, [type=button i], [type=reset i], [type=submit i]) {
|
|
87
90
|
-webkit-appearance: button;
|
|
88
91
|
cursor: pointer;
|
|
@@ -109,10 +112,6 @@
|
|
|
109
112
|
margin: 0;
|
|
110
113
|
}
|
|
111
114
|
|
|
112
|
-
:where(h1, h2, h3, h4, h5, h6, label, legend) {
|
|
113
|
-
line-height: 1.125;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
115
|
:where(h1, h2, h3, h4, h5, h6) {
|
|
117
116
|
text-wrap: balance;
|
|
118
117
|
}
|
|
@@ -180,10 +179,6 @@
|
|
|
180
179
|
letter-spacing: inherit;
|
|
181
180
|
}
|
|
182
181
|
|
|
183
|
-
:where(button, input) {
|
|
184
|
-
line-height: 1.25;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
182
|
:where(fieldset) {
|
|
188
183
|
border: 1px solid darkgrey;
|
|
189
184
|
}
|
package/dist/js/array.js
CHANGED
|
@@ -11,15 +11,15 @@ var _getCallbacks = function(bool, key) {
|
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
return {
|
|
14
|
-
key: (
|
|
14
|
+
key: (value) => value?.[key]
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
var _findValue = function(type, array, value, key) {
|
|
18
18
|
const callbacks = _getCallbacks(value, key);
|
|
19
|
-
if (callbacks?.bool
|
|
19
|
+
if (callbacks?.bool == null && callbacks?.key == null) {
|
|
20
20
|
return type === "index" ? array.indexOf(value) : array.find((item) => item === value);
|
|
21
21
|
}
|
|
22
|
-
if (callbacks.bool
|
|
22
|
+
if (callbacks.bool != null) {
|
|
23
23
|
const index2 = array.findIndex(callbacks.bool);
|
|
24
24
|
return type === "index" ? index2 : index2 > -1 ? array[index2] : undefined;
|
|
25
25
|
}
|
|
@@ -36,13 +36,13 @@ var _findValue = function(type, array, value, key) {
|
|
|
36
36
|
var _findValues = function(type, array, value, key) {
|
|
37
37
|
const callbacks = _getCallbacks(value, key);
|
|
38
38
|
const { length } = array;
|
|
39
|
-
if (type === "unique" && callbacks?.key
|
|
39
|
+
if (type === "unique" && callbacks?.key == null && length >= 100) {
|
|
40
40
|
return Array.from(new Set(array));
|
|
41
41
|
}
|
|
42
42
|
if (typeof callbacks?.bool === "function") {
|
|
43
43
|
return array.filter(callbacks.bool);
|
|
44
44
|
}
|
|
45
|
-
if (type === "all" && key
|
|
45
|
+
if (type === "all" && key == null) {
|
|
46
46
|
return array.filter((item) => item === value);
|
|
47
47
|
}
|
|
48
48
|
const hasCallback = typeof callbacks?.key === "function";
|
|
@@ -68,7 +68,7 @@ var _insertValues = function(type, array, values, start, deleteCount) {
|
|
|
68
68
|
let returned;
|
|
69
69
|
for (;index < length; index += 1) {
|
|
70
70
|
const result = array.splice(start, index === 0 ? deleteCount : 0, ...chunked[index]);
|
|
71
|
-
if (returned
|
|
71
|
+
if (returned == null) {
|
|
72
72
|
returned = result;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -99,7 +99,7 @@ function find(array, value, key) {
|
|
|
99
99
|
}
|
|
100
100
|
function groupBy(array, key) {
|
|
101
101
|
const callbacks = _getCallbacks(undefined, key);
|
|
102
|
-
if (callbacks?.key
|
|
102
|
+
if (callbacks?.key == null) {
|
|
103
103
|
return {};
|
|
104
104
|
}
|
|
105
105
|
const grouped = {};
|
|
@@ -125,8 +125,9 @@ function insert(array, index, values) {
|
|
|
125
125
|
function push(array, values) {
|
|
126
126
|
return _insertValues("push", array, values, array.length, 0);
|
|
127
127
|
}
|
|
128
|
-
function splice(array, start,
|
|
129
|
-
|
|
128
|
+
function splice(array, start, amountOrValues, values) {
|
|
129
|
+
const amoutOrValuesIsArray = Array.isArray(amountOrValues);
|
|
130
|
+
return _insertValues("splice", array, amoutOrValuesIsArray ? amountOrValues : values ?? [], start, amoutOrValuesIsArray ? array.length : typeof amountOrValues === "number" && amountOrValues > 0 ? amountOrValues : 0);
|
|
130
131
|
}
|
|
131
132
|
function unique(array, key) {
|
|
132
133
|
return _findValues("unique", array, undefined, key);
|
package/dist/js/array.mjs
CHANGED
|
@@ -11,15 +11,15 @@ var _getCallbacks = function(bool, key) {
|
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
return {
|
|
14
|
-
key: (
|
|
14
|
+
key: (value) => value?.[key]
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
var _findValue = function(type, array, value, key) {
|
|
18
18
|
const callbacks = _getCallbacks(value, key);
|
|
19
|
-
if (callbacks?.bool
|
|
19
|
+
if (callbacks?.bool == null && callbacks?.key == null) {
|
|
20
20
|
return type === "index" ? array.indexOf(value) : array.find((item) => item === value);
|
|
21
21
|
}
|
|
22
|
-
if (callbacks.bool
|
|
22
|
+
if (callbacks.bool != null) {
|
|
23
23
|
const index2 = array.findIndex(callbacks.bool);
|
|
24
24
|
return type === "index" ? index2 : index2 > -1 ? array[index2] : undefined;
|
|
25
25
|
}
|
|
@@ -36,13 +36,13 @@ var _findValue = function(type, array, value, key) {
|
|
|
36
36
|
var _findValues = function(type, array, value, key) {
|
|
37
37
|
const callbacks = _getCallbacks(value, key);
|
|
38
38
|
const { length } = array;
|
|
39
|
-
if (type === "unique" && callbacks?.key
|
|
39
|
+
if (type === "unique" && callbacks?.key == null && length >= 100) {
|
|
40
40
|
return Array.from(new Set(array));
|
|
41
41
|
}
|
|
42
42
|
if (typeof callbacks?.bool === "function") {
|
|
43
43
|
return array.filter(callbacks.bool);
|
|
44
44
|
}
|
|
45
|
-
if (type === "all" && key
|
|
45
|
+
if (type === "all" && key == null) {
|
|
46
46
|
return array.filter((item) => item === value);
|
|
47
47
|
}
|
|
48
48
|
const hasCallback = typeof callbacks?.key === "function";
|
|
@@ -68,7 +68,7 @@ var _insertValues = function(type, array, values, start, deleteCount) {
|
|
|
68
68
|
let returned;
|
|
69
69
|
for (;index < length; index += 1) {
|
|
70
70
|
const result = array.splice(start, index === 0 ? deleteCount : 0, ...chunked[index]);
|
|
71
|
-
if (returned
|
|
71
|
+
if (returned == null) {
|
|
72
72
|
returned = result;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -99,7 +99,7 @@ function find(array, value, key) {
|
|
|
99
99
|
}
|
|
100
100
|
function groupBy(array, key) {
|
|
101
101
|
const callbacks = _getCallbacks(undefined, key);
|
|
102
|
-
if (callbacks?.key
|
|
102
|
+
if (callbacks?.key == null) {
|
|
103
103
|
return {};
|
|
104
104
|
}
|
|
105
105
|
const grouped = {};
|
|
@@ -125,8 +125,9 @@ function insert(array, index, values) {
|
|
|
125
125
|
function push(array, values) {
|
|
126
126
|
return _insertValues("push", array, values, array.length, 0);
|
|
127
127
|
}
|
|
128
|
-
function splice(array, start,
|
|
129
|
-
|
|
128
|
+
function splice(array, start, amountOrValues, values) {
|
|
129
|
+
const amoutOrValuesIsArray = Array.isArray(amountOrValues);
|
|
130
|
+
return _insertValues("splice", array, amoutOrValuesIsArray ? amountOrValues : values ?? [], start, amoutOrValuesIsArray ? array.length : typeof amountOrValues === "number" && amountOrValues > 0 ? amountOrValues : 0);
|
|
130
131
|
}
|
|
131
132
|
function unique(array, key) {
|
|
132
133
|
return _findValues("unique", array, undefined, key);
|
package/dist/js/element/index.js
CHANGED
|
@@ -8,32 +8,27 @@ var _findElements = function(selector, context, single) {
|
|
|
8
8
|
let index2 = 0;
|
|
9
9
|
for (;index2 < length2; index2 += 1) {
|
|
10
10
|
const value = callback.call(contexts[index2], selector);
|
|
11
|
-
if (single
|
|
11
|
+
if (single) {
|
|
12
|
+
if (value == null) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
12
15
|
return value;
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
result.push(...Array.from(value));
|
|
16
|
-
}
|
|
17
|
+
result.push(...Array.from(value));
|
|
17
18
|
}
|
|
18
19
|
return single ? undefined : result.filter((value, index3, array) => array.indexOf(value) === index3);
|
|
19
20
|
}
|
|
20
|
-
const nodes = Array.isArray(selector)
|
|
21
|
+
const nodes = Array.isArray(selector) ? selector : selector instanceof NodeList ? Array.from(selector) : [selector];
|
|
21
22
|
const { length } = nodes;
|
|
22
23
|
let index = 0;
|
|
23
24
|
for (;index < length; index += 1) {
|
|
24
25
|
const node = nodes[index];
|
|
25
26
|
const element = node instanceof Document ? node.body : node instanceof Element ? node : undefined;
|
|
26
|
-
if (element == null) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if (context == null || contexts.some((context2) => context2.contains(node))) {
|
|
30
|
-
if (single) {
|
|
31
|
-
return element;
|
|
32
|
-
}
|
|
27
|
+
if (element != null && (context == null || contexts.length === 0 || contexts.some((context2) => context2 === element || context2.contains(element))) && !result.includes(element)) {
|
|
33
28
|
result.push(element);
|
|
34
29
|
}
|
|
35
30
|
}
|
|
36
|
-
return
|
|
31
|
+
return result;
|
|
37
32
|
};
|
|
38
33
|
function findElement(selector, context) {
|
|
39
34
|
return _findElements(selector, context, true);
|
|
@@ -66,7 +61,7 @@ function getElementUnderPointer(skipIgnore) {
|
|
|
66
61
|
return false;
|
|
67
62
|
}
|
|
68
63
|
const style = getComputedStyle(element);
|
|
69
|
-
return
|
|
64
|
+
return skipIgnore === true || style.pointerEvents !== "none" && style.visibility !== "hidden";
|
|
70
65
|
});
|
|
71
66
|
return elements[elements.length - 1];
|
|
72
67
|
}
|
|
@@ -8,32 +8,27 @@ var _findElements = function(selector, context, single) {
|
|
|
8
8
|
let index2 = 0;
|
|
9
9
|
for (;index2 < length2; index2 += 1) {
|
|
10
10
|
const value = callback.call(contexts[index2], selector);
|
|
11
|
-
if (single
|
|
11
|
+
if (single) {
|
|
12
|
+
if (value == null) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
12
15
|
return value;
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
result.push(...Array.from(value));
|
|
16
|
-
}
|
|
17
|
+
result.push(...Array.from(value));
|
|
17
18
|
}
|
|
18
19
|
return single ? undefined : result.filter((value, index3, array) => array.indexOf(value) === index3);
|
|
19
20
|
}
|
|
20
|
-
const nodes = Array.isArray(selector)
|
|
21
|
+
const nodes = Array.isArray(selector) ? selector : selector instanceof NodeList ? Array.from(selector) : [selector];
|
|
21
22
|
const { length } = nodes;
|
|
22
23
|
let index = 0;
|
|
23
24
|
for (;index < length; index += 1) {
|
|
24
25
|
const node = nodes[index];
|
|
25
26
|
const element = node instanceof Document ? node.body : node instanceof Element ? node : undefined;
|
|
26
|
-
if (element == null) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if (context == null || contexts.some((context2) => context2.contains(node))) {
|
|
30
|
-
if (single) {
|
|
31
|
-
return element;
|
|
32
|
-
}
|
|
27
|
+
if (element != null && (context == null || contexts.length === 0 || contexts.some((context2) => context2 === element || context2.contains(element))) && !result.includes(element)) {
|
|
33
28
|
result.push(element);
|
|
34
29
|
}
|
|
35
30
|
}
|
|
36
|
-
return
|
|
31
|
+
return result;
|
|
37
32
|
};
|
|
38
33
|
function findElement(selector, context) {
|
|
39
34
|
return _findElements(selector, context, true);
|
|
@@ -66,7 +61,7 @@ function getElementUnderPointer(skipIgnore) {
|
|
|
66
61
|
return false;
|
|
67
62
|
}
|
|
68
63
|
const style = getComputedStyle(element);
|
|
69
|
-
return
|
|
64
|
+
return skipIgnore === true || style.pointerEvents !== "none" && style.visibility !== "hidden";
|
|
70
65
|
});
|
|
71
66
|
return elements[elements.length - 1];
|
|
72
67
|
}
|