@splendidlabz/utils 1.11.2 → 1.11.4
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/cjs/dom/accessibility.cjs +2 -0
- package/dist/cjs/dom/actions/index.cjs +392 -7
- package/dist/cjs/dom/actions/masonry.cjs +97 -6
- package/dist/cjs/dom/actions/prefer-horizontal-scroll.cjs +58 -14
- package/dist/cjs/dom/actions/sticky.cjs +126 -6
- package/dist/cjs/dom/bounding-box.cjs +2 -0
- package/dist/cjs/dom/clipboard.cjs +2 -0
- package/dist/cjs/dom/cookie.cjs +3 -1
- package/dist/cjs/dom/css-vars.cjs +13 -3
- package/dist/cjs/dom/events.cjs +2 -0
- package/dist/cjs/dom/focusable.cjs +2 -0
- package/dist/cjs/dom/font-size.cjs +15 -3
- package/dist/cjs/dom/get-element.cjs +3 -1
- package/dist/cjs/dom/hash.cjs +2 -0
- package/dist/cjs/dom/index.cjs +1249 -47
- package/dist/cjs/dom/keyboard.cjs +2 -0
- package/dist/cjs/dom/local-store.cjs +3 -1
- package/dist/cjs/dom/media.cjs +2 -0
- package/dist/cjs/dom/observers/index.cjs +235 -9
- package/dist/cjs/dom/observers/intersection-observer.cjs +38 -6
- package/dist/cjs/dom/observers/mutation-observer.cjs +38 -6
- package/dist/cjs/dom/observers/observer.cjs +12 -2
- package/dist/cjs/dom/observers/resize-observer.cjs +38 -6
- package/dist/cjs/dom/observers/scroll-observer.cjs +62 -3
- package/dist/cjs/dom/pkce.cjs +13 -3
- package/dist/cjs/dom/query-params.cjs +3 -1
- package/dist/cjs/dom/random-string.cjs +2 -0
- package/dist/cjs/dom/sanitize.cjs +27 -3
- package/dist/cjs/dom/session-store.cjs +3 -1
- package/dist/cjs/dom/spam-prevention.cjs +2 -0
- package/dist/cjs/dom/trap-focus.cjs +131 -9
- package/dist/cjs/dom/ui/aria-current.cjs +2 -0
- package/dist/cjs/dom/ui/inconsistent-button-fix.cjs +2 -0
- package/dist/cjs/dom/ui/index.cjs +87 -9
- package/dist/cjs/dom/ui/scroll-container.cjs +2 -0
- package/dist/cjs/dom/ui/traverse-and-scramble.cjs +2 -0
- package/dist/cjs/lib/arrays/index.cjs +121 -13
- package/dist/cjs/lib/arrays/item-position.cjs +2 -0
- package/dist/cjs/lib/arrays/join.cjs +10 -2
- package/dist/cjs/lib/arrays/shuffle.cjs +2 -0
- package/dist/cjs/lib/arrays/sort.cjs +11 -3
- package/dist/cjs/lib/arrays/split-array.cjs +2 -0
- package/dist/cjs/lib/arrays/unique.cjs +2 -0
- package/dist/cjs/lib/auth/index.cjs +35 -3
- package/dist/cjs/lib/auth/route-manager.cjs +2 -0
- package/dist/cjs/lib/checks.cjs +2 -0
- package/dist/cjs/lib/date/days.cjs +3 -1
- package/dist/cjs/lib/date/index.cjs +190 -7
- package/dist/cjs/lib/date/months.cjs +3 -1
- package/dist/cjs/lib/date/time.cjs +14 -2
- package/dist/cjs/lib/form/form-data.cjs +2 -0
- package/dist/cjs/lib/form/index.cjs +104 -5
- package/dist/cjs/lib/form/sanitize.cjs +2 -0
- package/dist/cjs/lib/functions/callback.cjs +2 -0
- package/dist/cjs/lib/functions/debounce.cjs +2 -0
- package/dist/cjs/lib/functions/env.cjs +2 -0
- package/dist/cjs/lib/functions/functional.cjs +2 -0
- package/dist/cjs/lib/functions/index.cjs +124 -11
- package/dist/cjs/lib/functions/throttle.cjs +2 -0
- package/dist/cjs/lib/functions/timeout.cjs +2 -0
- package/dist/cjs/lib/hash.cjs +2 -0
- package/dist/cjs/lib/index.cjs +1160 -29
- package/dist/cjs/lib/numbers/index.cjs +17 -4
- package/dist/cjs/lib/numbers/math.cjs +2 -0
- package/dist/cjs/lib/objects/camelcase-keys.cjs +45 -4
- package/dist/cjs/lib/objects/empty.cjs +2 -0
- package/dist/cjs/lib/objects/equal.cjs +2 -0
- package/dist/cjs/lib/objects/extend.cjs +117 -6
- package/dist/cjs/lib/objects/flatten.cjs +11 -3
- package/dist/cjs/lib/objects/index.cjs +360 -27
- package/dist/cjs/lib/objects/json.cjs +2 -0
- package/dist/cjs/lib/objects/loop.cjs +2 -0
- package/dist/cjs/lib/objects/mix/mix.cjs +5 -3
- package/dist/cjs/lib/objects/nested-property.cjs +2 -0
- package/dist/cjs/lib/objects/normalize-object.cjs +78 -4
- package/dist/cjs/lib/objects/omit-empty.cjs +2 -0
- package/dist/cjs/lib/objects/size.cjs +2 -0
- package/dist/cjs/lib/objects/split.cjs +2 -0
- package/dist/cjs/lib/promises/index.cjs +51 -3
- package/dist/cjs/lib/promises/reject.cjs +19 -2
- package/dist/cjs/lib/sse.cjs +29 -4
- package/dist/cjs/lib/strings/convert-case/convert-case.cjs +2 -0
- package/dist/cjs/lib/strings/index.cjs +179 -11
- package/dist/cjs/lib/strings/markdown.cjs +3 -1
- package/dist/cjs/lib/strings/name.cjs +2 -0
- package/dist/cjs/lib/strings/pluralize.cjs +3 -1
- package/dist/cjs/lib/strings/query-string.cjs +2 -0
- package/dist/cjs/lib/style/index.cjs +31 -2
- package/dist/cjs/lib/symbols/index.cjs +22 -3
- package/dist/cjs/lib/symbols/symbols.cjs +2 -0
- package/dist/cjs/node/context.cjs +0 -0
- package/dist/cjs/node/dirname.cjs +4 -2
- package/dist/cjs/node/file-cache.cjs +45 -3
- package/dist/cjs/node/file.cjs +4 -2
- package/dist/cjs/node/hash.cjs +3 -1
- package/dist/cjs/node/index.cjs +278 -15
- package/dist/cjs/node/pkce.cjs +20 -8
- package/dist/cjs/node/random-string.cjs +3 -1
- package/dist/cjs/node/sanitize.cjs +27 -3
- package/dist/cjs/node/uuid.cjs +2 -0
- package/dist/esm/node/context.js +0 -0
- package/dist/esm/node/file-cache.js +1 -1
- package/dist/esm/node/pkce.js +3 -2
- package/dist/types/node/context.d.cts +2 -0
- package/dist/types/node/index.d.cts +1 -1
- package/dist/types/node/pkce.d.cts +7 -1
- package/package.json +5 -2
- package/CHANGELOG.md +0 -231
- package/eslint.config.js +0 -2
- package/src/dom/accessibility.js +0 -58
- package/src/dom/actions/index.js +0 -3
- package/src/dom/actions/masonry.js +0 -43
- package/src/dom/actions/prefer-horizontal-scroll.js +0 -121
- package/src/dom/actions/sticky.js +0 -85
- package/src/dom/bounding-box.js +0 -82
- package/src/dom/clipboard.js +0 -14
- package/src/dom/cookie.js +0 -32
- package/src/dom/css-vars.js +0 -19
- package/src/dom/events.js +0 -71
- package/src/dom/focusable.js +0 -165
- package/src/dom/font-size.js +0 -40
- package/src/dom/get-element.js +0 -176
- package/src/dom/hash.js +0 -9
- package/src/dom/index.js +0 -23
- package/src/dom/keyboard.js +0 -44
- package/src/dom/local-store.js +0 -66
- package/src/dom/media.js +0 -30
- package/src/dom/observers/index.js +0 -4
- package/src/dom/observers/intersection-observer.js +0 -43
- package/src/dom/observers/mutation-observer.js +0 -51
- package/src/dom/observers/observer.js +0 -18
- package/src/dom/observers/resize-observer.js +0 -66
- package/src/dom/observers/scroll-observer.js +0 -146
- package/src/dom/pkce.js +0 -34
- package/src/dom/query-params.js +0 -14
- package/src/dom/random-string.js +0 -18
- package/src/dom/random-string.test.js +0 -13
- package/src/dom/sanitize.js +0 -16
- package/src/dom/session-store.js +0 -29
- package/src/dom/spam-prevention.js +0 -40
- package/src/dom/trap-focus.js +0 -70
- package/src/dom/ui/aria-current.js +0 -20
- package/src/dom/ui/inconsistent-button-fix.js +0 -20
- package/src/dom/ui/index.js +0 -4
- package/src/dom/ui/scroll-container.js +0 -25
- package/src/dom/ui/traverse-and-scramble.js +0 -61
- package/src/lib/arrays/index.js +0 -6
- package/src/lib/arrays/item-position.js +0 -23
- package/src/lib/arrays/join.js +0 -20
- package/src/lib/arrays/shuffle.js +0 -21
- package/src/lib/arrays/sort.js +0 -88
- package/src/lib/arrays/sort.spec.js +0 -123
- package/src/lib/arrays/split-array.js +0 -15
- package/src/lib/arrays/unique.js +0 -3
- package/src/lib/auth/index.js +0 -1
- package/src/lib/auth/route-manager.js +0 -45
- package/src/lib/checks.js +0 -57
- package/src/lib/date/days.js +0 -9
- package/src/lib/date/index.js +0 -3
- package/src/lib/date/months.js +0 -74
- package/src/lib/date/time.js +0 -83
- package/src/lib/form/form-data.js +0 -73
- package/src/lib/form/index.js +0 -2
- package/src/lib/form/sanitize.js +0 -80
- package/src/lib/form/sanitize.spec.js +0 -126
- package/src/lib/functions/callback.js +0 -8
- package/src/lib/functions/debounce.js +0 -18
- package/src/lib/functions/env.js +0 -5
- package/src/lib/functions/functional.js +0 -113
- package/src/lib/functions/functional.test.js +0 -196
- package/src/lib/functions/index.js +0 -5
- package/src/lib/functions/throttle.js +0 -11
- package/src/lib/functions/timeout.js +0 -15
- package/src/lib/hash.js +0 -18
- package/src/lib/hash.spec.js +0 -163
- package/src/lib/index.js +0 -14
- package/src/lib/numbers/index.js +0 -12
- package/src/lib/numbers/math.js +0 -9
- package/src/lib/numbers/split-unit.test.js +0 -45
- package/src/lib/objects/camelcase-keys.js +0 -17
- package/src/lib/objects/camelcase-keys.test.js +0 -72
- package/src/lib/objects/empty.js +0 -10
- package/src/lib/objects/equal.js +0 -9
- package/src/lib/objects/extend.js +0 -16
- package/src/lib/objects/extend.test.js +0 -35
- package/src/lib/objects/flatten.js +0 -19
- package/src/lib/objects/index.js +0 -13
- package/src/lib/objects/json.js +0 -7
- package/src/lib/objects/loop.js +0 -11
- package/src/lib/objects/loop.test.js +0 -31
- package/src/lib/objects/mix/mix.js +0 -191
- package/src/lib/objects/mix/mix.md +0 -78
- package/src/lib/objects/mix/mix.test.js +0 -445
- package/src/lib/objects/nested-property.js +0 -41
- package/src/lib/objects/normalize-object.js +0 -10
- package/src/lib/objects/omit-empty.js +0 -23
- package/src/lib/objects/omit-empty.test.js +0 -85
- package/src/lib/objects/size.js +0 -41
- package/src/lib/objects/split.js +0 -19
- package/src/lib/promises/index.js +0 -1
- package/src/lib/promises/reject.js +0 -17
- package/src/lib/sse.js +0 -61
- package/src/lib/strings/convert-case/convert-case.js +0 -86
- package/src/lib/strings/convert-case/convert-case.md +0 -44
- package/src/lib/strings/convert-case/convert-case.test.js +0 -50
- package/src/lib/strings/index.js +0 -5
- package/src/lib/strings/markdown.js +0 -71
- package/src/lib/strings/name.js +0 -24
- package/src/lib/strings/name.test.js +0 -67
- package/src/lib/strings/pluralize.js +0 -2
- package/src/lib/strings/query-string.js +0 -18
- package/src/lib/style/index.js +0 -13
- package/src/lib/symbols/index.js +0 -1
- package/src/lib/symbols/symbols.js +0 -9
- package/src/node/dirname.js +0 -17
- package/src/node/file-cache.js +0 -184
- package/src/node/file.js +0 -13
- package/src/node/hash.js +0 -5
- package/src/node/index.js +0 -7
- package/src/node/pkce.js +0 -33
- package/src/node/random-string.js +0 -10
- package/src/node/random-string.test.js +0 -15
- package/src/node/sanitize.js +0 -13
- package/src/node/sanitize.spec.js +0 -142
- package/src/node/uuid.js +0 -5
- package/tsconfig.json +0 -23
- package/tsup.config.js +0 -38
- package/tsup.config.mjs +0 -45
|
@@ -15,18 +15,138 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/dom/actions/sticky.js
|
|
18
20
|
var sticky_exports = {};
|
|
19
21
|
__export(sticky_exports, {
|
|
20
22
|
sticky: () => sticky
|
|
21
23
|
});
|
|
22
24
|
module.exports = __toCommonJS(sticky_exports);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
// src/dom/bounding-box.js
|
|
27
|
+
function boundingBox(element, { containsPadding = true } = {}) {
|
|
28
|
+
const box = element.getBoundingClientRect();
|
|
29
|
+
const ret = {};
|
|
30
|
+
for (const prop in box) ret[prop] = box[prop];
|
|
31
|
+
if (!containsPadding) {
|
|
32
|
+
const style = getComputedStyle(element);
|
|
33
|
+
const paddingTop = parseFloat(style.paddingTop);
|
|
34
|
+
const paddingRight = parseFloat(style.paddingRight);
|
|
35
|
+
const paddingBottom = parseFloat(style.paddingBottom);
|
|
36
|
+
const paddingLeft = parseFloat(style.paddingLeft);
|
|
37
|
+
ret.x = ret.x + paddingLeft;
|
|
38
|
+
ret.y = ret.y + paddingTop;
|
|
39
|
+
ret.width = ret.width - paddingLeft - paddingRight;
|
|
40
|
+
ret.height = ret.height - paddingTop - paddingBottom;
|
|
41
|
+
ret.top = ret.top + paddingTop;
|
|
42
|
+
ret.bottom = ret.bottom - paddingBottom;
|
|
43
|
+
ret.right = ret.right - paddingRight;
|
|
44
|
+
ret.left = ret.left + paddingLeft;
|
|
45
|
+
}
|
|
46
|
+
ret.xCenter = (ret.left + ret.right) / 2;
|
|
47
|
+
ret.yCenter = (ret.top + ret.bottom) / 2;
|
|
48
|
+
return ret;
|
|
49
|
+
}
|
|
50
|
+
function boundingBoxRelativeToAncestor({ element, ancestorElement }) {
|
|
51
|
+
ancestorElement = ancestorElement || element.parentElement;
|
|
52
|
+
const box = boundingBox(element);
|
|
53
|
+
const ancestorBox = boundingBox(ancestorElement, {
|
|
54
|
+
containsPadding: false
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
top: box.top - ancestorBox.top,
|
|
58
|
+
right: box.right - ancestorBox.right,
|
|
59
|
+
bottom: box.bottom - ancestorBox.bottom,
|
|
60
|
+
left: box.left - ancestorBox.left,
|
|
61
|
+
width: box.width,
|
|
62
|
+
height: box.height,
|
|
63
|
+
xCenter: (box.left + box.right) / 2 - ancestorBox.left,
|
|
64
|
+
yCenter: (box.top + box.bottom) / 2 - ancestorBox.top
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/dom/events.js
|
|
69
|
+
function dispatchEvent(node, eventName, detail, options = {}) {
|
|
70
|
+
node.dispatchEvent(
|
|
71
|
+
new CustomEvent(eventName, {
|
|
72
|
+
...options,
|
|
73
|
+
detail
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/dom/get-element.js
|
|
79
|
+
function getNodeType(node) {
|
|
80
|
+
if (node instanceof Element) return "element";
|
|
81
|
+
if (node instanceof NodeList) return "nodelist";
|
|
82
|
+
if (Array.isArray(node)) return "array";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/dom/observers/observer.js
|
|
86
|
+
function useObserverMethodOnTarget(target, observer, method = "observe", options = void 0) {
|
|
87
|
+
const targetType = getNodeType(target);
|
|
88
|
+
if (targetType === "element") observer[method](target, options);
|
|
89
|
+
if (targetType === "nodelist") {
|
|
90
|
+
const elements = Array.from(target);
|
|
91
|
+
elements.forEach((element) => observer[method](element, options));
|
|
92
|
+
}
|
|
93
|
+
if (targetType === "array") {
|
|
94
|
+
target.forEach((element) => observer[method](element, options));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// src/dom/observers/resize-observer.js
|
|
99
|
+
function resizeObserver(target, options) {
|
|
100
|
+
const { callback, ...opts } = options;
|
|
101
|
+
const observer = new ResizeObserver(observerFn);
|
|
102
|
+
if (target === window || target === document)
|
|
103
|
+
target = document.documentElement;
|
|
104
|
+
useObserverMethodOnTarget(target, observer, "observe", opts);
|
|
105
|
+
function observerFn(entries) {
|
|
106
|
+
for (const entry of entries) {
|
|
107
|
+
if (callback) callback({ entry, entries, observer });
|
|
108
|
+
else
|
|
109
|
+
dispatchEvent(entry.target, "resize-obs", { entry, entries, observer });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
observe(target2) {
|
|
114
|
+
useObserverMethodOnTarget(target2, observer, "observe", options);
|
|
115
|
+
},
|
|
116
|
+
unobserve(target2) {
|
|
117
|
+
useObserverMethodOnTarget(target2, observer, "unobserve");
|
|
118
|
+
},
|
|
119
|
+
disconnect: (_) => observer.disconnect(),
|
|
120
|
+
destroy: (_) => observer.disconnect()
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/dom/ui/scroll-container.js
|
|
125
|
+
function findScrollContainer(element, direction = "both") {
|
|
126
|
+
if (!element) return;
|
|
127
|
+
let parent = element.parentElement;
|
|
128
|
+
while (parent) {
|
|
129
|
+
const { overflow, overflowX, overflowY } = getComputedStyle(parent);
|
|
130
|
+
if (direction === "both") {
|
|
131
|
+
if (overflow.includes("auto") || overflow.includes("scroll"))
|
|
132
|
+
return parent;
|
|
133
|
+
}
|
|
134
|
+
if (direction === "horizontal") {
|
|
135
|
+
if (overflowX === "auto" || overflowX === "scroll") return parent;
|
|
136
|
+
}
|
|
137
|
+
if (direction === "vertical") {
|
|
138
|
+
if (overflowY === "auto" || overflowY === "scroll") return parent;
|
|
139
|
+
}
|
|
140
|
+
parent = parent.parentElement;
|
|
141
|
+
}
|
|
142
|
+
return document.documentElement;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/dom/actions/sticky.js
|
|
26
146
|
function sticky(node, props = {}) {
|
|
27
|
-
const scrollContainer =
|
|
147
|
+
const scrollContainer = findScrollContainer(node);
|
|
28
148
|
let stickyTBLR = getComputedTBLR(node);
|
|
29
|
-
const obs =
|
|
149
|
+
const obs = resizeObserver(node, {
|
|
30
150
|
callback: ({ entry }) => {
|
|
31
151
|
stickyTBLR = getComputedTBLR(node);
|
|
32
152
|
isSticking();
|
|
@@ -38,7 +158,7 @@ function sticky(node, props = {}) {
|
|
|
38
158
|
}
|
|
39
159
|
function isSticking() {
|
|
40
160
|
const { top, bottom, left, right } = stickyTBLR;
|
|
41
|
-
const relativeRect =
|
|
161
|
+
const relativeRect = boundingBoxRelativeToAncestor({
|
|
42
162
|
element: node,
|
|
43
163
|
ancestorElement: scrollContainer
|
|
44
164
|
});
|
|
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/dom/bounding-box.js
|
|
18
20
|
var bounding_box_exports = {};
|
|
19
21
|
__export(bounding_box_exports, {
|
|
20
22
|
boundingBox: () => boundingBox,
|
|
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/dom/clipboard.js
|
|
18
20
|
var clipboard_exports = {};
|
|
19
21
|
__export(clipboard_exports, {
|
|
20
22
|
copyRichText: () => copyRichText
|
package/dist/cjs/dom/cookie.cjs
CHANGED
|
@@ -15,13 +15,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/dom/cookie.js
|
|
18
20
|
var cookie_exports = {};
|
|
19
21
|
__export(cookie_exports, {
|
|
20
22
|
cookies: () => cookies,
|
|
21
23
|
getCookie: () => getCookie
|
|
22
24
|
});
|
|
23
25
|
module.exports = __toCommonJS(cookie_exports);
|
|
24
|
-
|
|
26
|
+
var cookies = {
|
|
25
27
|
get(name) {
|
|
26
28
|
return getCookie(name);
|
|
27
29
|
},
|
|
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/dom/css-vars.js
|
|
18
20
|
var css_vars_exports = {};
|
|
19
21
|
__export(css_vars_exports, {
|
|
20
22
|
getCSSValue: () => getCSSValue,
|
|
@@ -23,7 +25,15 @@ __export(css_vars_exports, {
|
|
|
23
25
|
setCSSVar: () => setCSSVar
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(css_vars_exports);
|
|
26
|
-
|
|
28
|
+
|
|
29
|
+
// src/dom/get-element.js
|
|
30
|
+
function getElement(selector) {
|
|
31
|
+
if (!selector) return;
|
|
32
|
+
if (selector instanceof Element) return selector;
|
|
33
|
+
return document.querySelector(selector);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/dom/css-vars.js
|
|
27
37
|
function getCSSValue(element, prop) {
|
|
28
38
|
return getCSSVar(element, prop);
|
|
29
39
|
}
|
|
@@ -31,11 +41,11 @@ function setCSSValue(element, prop, value) {
|
|
|
31
41
|
setCSSVar(element, prop, value);
|
|
32
42
|
}
|
|
33
43
|
function getCSSVar(element, prop) {
|
|
34
|
-
element =
|
|
44
|
+
element = getElement(element);
|
|
35
45
|
return getComputedStyle(element).getPropertyValue(prop);
|
|
36
46
|
}
|
|
37
47
|
function setCSSVar(element, prop, value) {
|
|
38
|
-
element =
|
|
48
|
+
element = getElement(element);
|
|
39
49
|
element.style.setProperty(prop, value);
|
|
40
50
|
}
|
|
41
51
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/cjs/dom/events.cjs
CHANGED
|
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/dom/events.js
|
|
18
20
|
var events_exports = {};
|
|
19
21
|
__export(events_exports, {
|
|
20
22
|
addListeners: () => addListeners,
|
|
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/dom/focusable.js
|
|
18
20
|
var focusable_exports = {};
|
|
19
21
|
__export(focusable_exports, {
|
|
20
22
|
Focusable: () => Focusable,
|
|
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/dom/font-size.js
|
|
18
20
|
var font_size_exports = {};
|
|
19
21
|
__export(font_size_exports, {
|
|
20
22
|
em: () => em,
|
|
@@ -25,9 +27,19 @@ __export(font_size_exports, {
|
|
|
25
27
|
toPx: () => toPx
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(font_size_exports);
|
|
28
|
-
|
|
30
|
+
|
|
31
|
+
// src/lib/numbers/index.js
|
|
32
|
+
function splitUnit(string) {
|
|
33
|
+
if (typeof string === "number") return [string, null];
|
|
34
|
+
const regex = /(-?\d*\.?\d+)\s*([a-z]+)/i;
|
|
35
|
+
const match = string.match(regex);
|
|
36
|
+
if (match) return [parseFloat(match[1]), match[2]];
|
|
37
|
+
return [parseFloat(string), null];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/dom/font-size.js
|
|
29
41
|
function getUnit(value) {
|
|
30
|
-
const [, unit] =
|
|
42
|
+
const [, unit] = splitUnit(value);
|
|
31
43
|
return unit;
|
|
32
44
|
}
|
|
33
45
|
function rem(multiple = 1) {
|
|
@@ -48,7 +60,7 @@ function lh(element = document.body, multiple = 1) {
|
|
|
48
60
|
return Math.round(value * multiple);
|
|
49
61
|
}
|
|
50
62
|
function toPx(value, element = null) {
|
|
51
|
-
const [numeric, unit] =
|
|
63
|
+
const [numeric, unit] = splitUnit(value);
|
|
52
64
|
let finalValue = 0;
|
|
53
65
|
if (unit === "rem") finalValue = rem(numeric);
|
|
54
66
|
if (unit === "em") finalValue = em(element, numeric);
|
|
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/dom/get-element.js
|
|
18
20
|
var get_element_exports = {};
|
|
19
21
|
__export(get_element_exports, {
|
|
20
22
|
getAncestorWithSiblings: () => getAncestorWithSiblings,
|
|
@@ -27,7 +29,7 @@ __export(get_element_exports, {
|
|
|
27
29
|
isAncestor: () => isAncestor
|
|
28
30
|
});
|
|
29
31
|
module.exports = __toCommonJS(get_element_exports);
|
|
30
|
-
|
|
32
|
+
var astroNodes = ["ASTRO-SLOT", "ASTRO-ISLAND"];
|
|
31
33
|
function getNodeType(node) {
|
|
32
34
|
if (node instanceof Element) return "element";
|
|
33
35
|
if (node instanceof NodeList) return "nodelist";
|
package/dist/cjs/dom/hash.cjs
CHANGED
|
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/dom/hash.js
|
|
18
20
|
var hash_exports = {};
|
|
19
21
|
__export(hash_exports, {
|
|
20
22
|
sha256Hash: () => sha256Hash
|