@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.
Files changed (53) hide show
  1. package/dist/css/a11y.css +2 -0
  2. package/dist/css/reset.css +4 -9
  3. package/dist/js/array.js +10 -9
  4. package/dist/js/array.mjs +10 -9
  5. package/dist/js/element/index.js +9 -14
  6. package/dist/js/element/index.mjs +9 -14
  7. package/dist/js/index.js +180 -302
  8. package/dist/js/index.mjs +1 -1
  9. package/dist/js/is.js +5 -1
  10. package/dist/js/is.mjs +5 -1
  11. package/dist/js/number.js +4 -4
  12. package/dist/js/number.mjs +4 -4
  13. package/dist/js/queue.js +1 -1
  14. package/dist/js/queue.mjs +1 -1
  15. package/dist/js/timer.js +60 -40
  16. package/dist/js/timer.mjs +60 -40
  17. package/dist/js/value.js +17 -28
  18. package/dist/js/value.mjs +18 -31
  19. package/package.json +20 -10
  20. package/src/css/a11y.scss +2 -0
  21. package/src/css/reset.scss +5 -10
  22. package/src/js/array.ts +158 -102
  23. package/src/js/element/index.ts +22 -21
  24. package/src/js/event.ts +2 -5
  25. package/src/js/index.ts +1 -1
  26. package/src/js/is.ts +14 -7
  27. package/src/js/models.ts +22 -0
  28. package/src/js/number.ts +8 -4
  29. package/src/js/queue.ts +1 -1
  30. package/src/js/timer.ts +100 -64
  31. package/src/js/value.ts +75 -88
  32. package/types/array.d.ts +31 -18
  33. package/types/event.d.ts +2 -6
  34. package/types/index.d.ts +1 -1
  35. package/types/is.d.ts +7 -4
  36. package/types/models.d.ts +10 -0
  37. package/types/timer.d.ts +17 -8
  38. package/types/value.d.ts +15 -16
  39. package/dist/js/html/attribute.mjs +0 -123
  40. package/dist/js/html/event.mjs +0 -9
  41. package/dist/js/html/index.mjs +0 -56
  42. package/dist/js/html/models.mjs +0 -5
  43. package/dist/js/html/node.mjs +0 -74
  44. package/dist/js/proxy.js +0 -329
  45. package/dist/js/proxy.mjs +0 -131
  46. package/dist/js/random.mjs +0 -30
  47. package/dist/js/signal.js +0 -179
  48. package/dist/js/signal.mjs +0 -136
  49. package/dist/js/template/event.mjs +0 -5
  50. package/dist/js/template/index.mjs +0 -59
  51. package/dist/js/template/node.mjs +0 -92
  52. package/src/js/proxy.ts +0 -209
  53. 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
  }
@@ -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: (item) => item?.[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 === undefined && callbacks?.key === undefined) {
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 !== undefined) {
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 === undefined && length >= 100) {
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 === undefined) {
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 === undefined) {
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 === undefined) {
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, deleteCount, values) {
129
- return _insertValues("splice", array, values, start, deleteCount);
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: (item) => item?.[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 === undefined && callbacks?.key === undefined) {
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 !== undefined) {
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 === undefined && length >= 100) {
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 === undefined) {
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 === undefined) {
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 === undefined) {
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, deleteCount, values) {
129
- return _insertValues("splice", array, values, start, deleteCount);
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);
@@ -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 && value != null) {
11
+ if (single) {
12
+ if (value == null) {
13
+ continue;
14
+ }
12
15
  return value;
13
16
  }
14
- if (!single) {
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) || selector instanceof NodeList ? selector : [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 single ? undefined : result.filter((value, index2, array) => array.indexOf(value) === index2);
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 typeof skipIgnore === "boolean" && skipIgnore || style.pointerEvents !== "none" && style.visibility !== "hidden";
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 && value != null) {
11
+ if (single) {
12
+ if (value == null) {
13
+ continue;
14
+ }
12
15
  return value;
13
16
  }
14
- if (!single) {
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) || selector instanceof NodeList ? selector : [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 single ? undefined : result.filter((value, index2, array) => array.indexOf(value) === index2);
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 typeof skipIgnore === "boolean" && skipIgnore || style.pointerEvents !== "none" && style.visibility !== "hidden";
64
+ return skipIgnore === true || style.pointerEvents !== "none" && style.visibility !== "hidden";
70
65
  });
71
66
  return elements[elements.length - 1];
72
67
  }