@t007/utils 0.0.31 → 0.0.33
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/{chunk-Y5YJMRXD.js → chunk-4O76EZJ4.js} +9 -5
- package/dist/{chunk-LBDWVTYF.js → chunk-QJ72EQCJ.js} +1 -1
- package/dist/hooks/react.js +2 -2
- package/dist/hooks/vanilla.js +2 -2
- package/dist/index.cjs +10 -5
- package/dist/index.d.cts +22 -17
- package/dist/index.d.ts +22 -17
- package/dist/index.js +3 -1
- package/package.json +2 -2
|
@@ -90,15 +90,18 @@ function parseCSSTime(time) {
|
|
|
90
90
|
function parseCSSSize(size, el) {
|
|
91
91
|
return size?.endsWith?.("px") ? parseFloat(size) : remToPx(parseFloat(size), el);
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
|
|
93
|
+
function cleanURL(url) {
|
|
95
94
|
try {
|
|
96
|
-
const
|
|
97
|
-
return decodeURIComponent(
|
|
95
|
+
const u = new URL(url, window.location.href);
|
|
96
|
+
return decodeURIComponent(u.origin + u.pathname);
|
|
98
97
|
} catch {
|
|
99
|
-
return
|
|
98
|
+
return url.replace(/\\/g, "/").split("?")[0].trim();
|
|
100
99
|
}
|
|
101
100
|
}
|
|
101
|
+
function isSameURL(url1, url2) {
|
|
102
|
+
if (!isStr(url1) || !isStr(url2) || !url1 || !url2) return false;
|
|
103
|
+
return cleanURL(url1) === cleanURL(url2);
|
|
104
|
+
}
|
|
102
105
|
|
|
103
106
|
// src/ts/core/fn.ts
|
|
104
107
|
import { setTimeout as setTimeout2, setInterval, requestAnimationFrame } from "sia-reactor/utils";
|
|
@@ -174,6 +177,7 @@ export {
|
|
|
174
177
|
pxToRem,
|
|
175
178
|
parseCSSTime,
|
|
176
179
|
parseCSSSize,
|
|
180
|
+
cleanURL,
|
|
177
181
|
isSameURL,
|
|
178
182
|
limited,
|
|
179
183
|
mockAsync,
|
package/dist/hooks/react.js
CHANGED
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
initFocusTrap,
|
|
12
12
|
initOutsideClick,
|
|
13
13
|
rippleHandler
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-QJ72EQCJ.js";
|
|
15
15
|
import {
|
|
16
16
|
INTERACTIVE_SELECTOR,
|
|
17
17
|
getActiveEl
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-4O76EZJ4.js";
|
|
19
19
|
|
|
20
20
|
// src/ts/hooks/react/useScrollAssist.ts
|
|
21
21
|
import { useEffect, useRef, useCallback } from "react";
|
package/dist/hooks/vanilla.js
CHANGED
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
removeFocusTrap,
|
|
11
11
|
removeOutsideClick,
|
|
12
12
|
rippleHandler
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-QJ72EQCJ.js";
|
|
14
14
|
import {
|
|
15
15
|
INTERACTIVE_SELECTOR,
|
|
16
16
|
createEl,
|
|
17
17
|
getActiveEl
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-4O76EZJ4.js";
|
|
19
19
|
|
|
20
20
|
// src/ts/hooks/vanilla/scrollAssist.ts
|
|
21
21
|
import { NIL } from "sia-reactor";
|
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ __export(index_exports, {
|
|
|
30
30
|
breath: () => breath,
|
|
31
31
|
clamp: () => import_utils4.clamp,
|
|
32
32
|
cleanKeyCombo: () => import_utils6.cleanKeyCombo,
|
|
33
|
+
cleanURL: () => cleanURL,
|
|
33
34
|
createEl: () => import_utils.createEl,
|
|
34
35
|
deepBreath: () => deepBreath,
|
|
35
36
|
formatKeyForDisplay: () => import_utils6.formatKeyForDisplay,
|
|
@@ -165,15 +166,18 @@ function parseCSSTime(time) {
|
|
|
165
166
|
function parseCSSSize(size, el) {
|
|
166
167
|
return size?.endsWith?.("px") ? parseFloat(size) : remToPx(parseFloat(size), el);
|
|
167
168
|
}
|
|
168
|
-
function
|
|
169
|
-
if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
|
|
169
|
+
function cleanURL(url) {
|
|
170
170
|
try {
|
|
171
|
-
const
|
|
172
|
-
return decodeURIComponent(
|
|
171
|
+
const u = new URL(url, window.location.href);
|
|
172
|
+
return decodeURIComponent(u.origin + u.pathname);
|
|
173
173
|
} catch {
|
|
174
|
-
return
|
|
174
|
+
return url.replace(/\\/g, "/").split("?")[0].trim();
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
+
function isSameURL(url1, url2) {
|
|
178
|
+
if (!isStr(url1) || !isStr(url2) || !url1 || !url2) return false;
|
|
179
|
+
return cleanURL(url1) === cleanURL(url2);
|
|
180
|
+
}
|
|
177
181
|
|
|
178
182
|
// src/ts/core/fn.ts
|
|
179
183
|
var import_utils5 = require("sia-reactor/utils");
|
|
@@ -234,6 +238,7 @@ if ("undefined" !== typeof window) {
|
|
|
234
238
|
breath,
|
|
235
239
|
clamp,
|
|
236
240
|
cleanKeyCombo,
|
|
241
|
+
cleanURL,
|
|
237
242
|
createEl,
|
|
238
243
|
deepBreath,
|
|
239
244
|
formatKeyForDisplay,
|
package/dist/index.d.cts
CHANGED
|
@@ -20,18 +20,18 @@ declare global {
|
|
|
20
20
|
interface Window {
|
|
21
21
|
/** Shared T007 namespace. */
|
|
22
22
|
t007: T007Namespace;
|
|
23
|
-
/** CDN entrypoint for
|
|
24
|
-
T007_TOAST_JS_SRC?: string;
|
|
25
|
-
/** CDN entrypoint for
|
|
26
|
-
T007_INPUT_JS_SRC?: string;
|
|
27
|
-
/** CDN entrypoint for
|
|
28
|
-
T007_DIALOG_JS_SRC?: string;
|
|
29
|
-
/** CDN stylesheet for
|
|
30
|
-
T007_TOAST_CSS_SRC?: string;
|
|
31
|
-
/** CDN stylesheet for
|
|
32
|
-
T007_INPUT_CSS_SRC?: string;
|
|
33
|
-
/** CDN stylesheet for
|
|
34
|
-
T007_DIALOG_CSS_SRC?: string;
|
|
23
|
+
/** CDN js entrypoint for `@t007/toast`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
|
|
24
|
+
T007_TOAST_JS_SRC?: string | symbol;
|
|
25
|
+
/** CDN js entrypoint for `@t007/input`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
|
|
26
|
+
T007_INPUT_JS_SRC?: string | symbol;
|
|
27
|
+
/** CDN js entrypoint for `@t007/dialog`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
|
|
28
|
+
T007_DIALOG_JS_SRC?: string | symbol;
|
|
29
|
+
/** CDN stylesheet for `@t007/toast`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
|
|
30
|
+
T007_TOAST_CSS_SRC?: string | symbol;
|
|
31
|
+
/** CDN stylesheet for `@t007/input`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
|
|
32
|
+
T007_INPUT_CSS_SRC?: string | symbol;
|
|
33
|
+
/** CDN stylesheet for `@t007/dialog`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
|
|
34
|
+
T007_DIALOG_CSS_SRC?: string | symbol;
|
|
35
35
|
}
|
|
36
36
|
/** Shared T007 namespace on the global object. */
|
|
37
37
|
var t007: T007Namespace;
|
|
@@ -77,12 +77,17 @@ declare function parseCSSTime(time: any): number;
|
|
|
77
77
|
* @returns The equivalent value in pixels.
|
|
78
78
|
*/
|
|
79
79
|
declare function parseCSSSize(size: any, el?: HTMLElement): number;
|
|
80
|
+
/** Normalize a URL by decoding it and removing query parameters and hash fragments.
|
|
81
|
+
* @param url The URL string to clean.
|
|
82
|
+
* @returns A normalized URL string for comparison.
|
|
83
|
+
*/
|
|
84
|
+
declare function cleanURL(url: string): string;
|
|
80
85
|
/** Compare two URLs after normalizing origin, pathname, and separators.
|
|
81
|
-
* @param
|
|
82
|
-
* @param
|
|
86
|
+
* @param url1 First URL or path.
|
|
87
|
+
* @param url2 Second URL or path.
|
|
83
88
|
* @returns True when both references point to the same resource.
|
|
84
89
|
*/
|
|
85
|
-
declare function isSameURL(
|
|
90
|
+
declare function isSameURL(url1: unknown, url2: unknown): boolean;
|
|
86
91
|
|
|
87
92
|
interface LimitedOptions {
|
|
88
93
|
/** Storage key used to persist call counts. */
|
|
@@ -134,7 +139,7 @@ declare function bindCleanupToSignal<Cb extends () => any>(cleanup: Cb, signal?:
|
|
|
134
139
|
/** Exhaustive Selector used for interactive, tabbable UI controls. */
|
|
135
140
|
declare const INTERACTIVE_SELECTOR = ":is(button,[href],input:not([type='hidden']),select,textarea,details>summary,[contenteditable='true'],iframe,audio[controls],video[controls],[tabindex]):not([disabled],[tabindex='-1'],[data-focus-guard],[inert],[inert] *)";
|
|
136
141
|
/** Check whether an event target points to an interactive element. */
|
|
137
|
-
declare const isInteractive: (target: EventTarget | null) =>
|
|
142
|
+
declare const isInteractive: (target: EventTarget | null) => boolean;
|
|
138
143
|
/** Resource type accepted by loadResource. */
|
|
139
144
|
type ResourceType = "style" | "script" | string;
|
|
140
145
|
/** Options used when loading a script or stylesheet resource. */
|
|
@@ -183,4 +188,4 @@ declare function getWindow(el?: any): (Window & typeof globalThis) | undefined;
|
|
|
183
188
|
*/
|
|
184
189
|
declare function formatSize(bytes: number, decimals?: number, base?: number): string;
|
|
185
190
|
|
|
186
|
-
export { INTERACTIVE_SELECTOR, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, VIRTUAL_RESOURCE, bindCleanupToSignal, breath, deepBreath, formatSize, getWindow, inBoolArrOpt, isArr, isBool, isDef, isFunc, isInteractive, isIter, isNum, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, parseCSSSize, parseCSSTime, pxToRem, remToPx, uid };
|
|
191
|
+
export { INTERACTIVE_SELECTOR, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, VIRTUAL_RESOURCE, bindCleanupToSignal, breath, cleanURL, deepBreath, formatSize, getWindow, inBoolArrOpt, isArr, isBool, isDef, isFunc, isInteractive, isIter, isNum, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, parseCSSSize, parseCSSTime, pxToRem, remToPx, uid };
|
package/dist/index.d.ts
CHANGED
|
@@ -20,18 +20,18 @@ declare global {
|
|
|
20
20
|
interface Window {
|
|
21
21
|
/** Shared T007 namespace. */
|
|
22
22
|
t007: T007Namespace;
|
|
23
|
-
/** CDN entrypoint for
|
|
24
|
-
T007_TOAST_JS_SRC?: string;
|
|
25
|
-
/** CDN entrypoint for
|
|
26
|
-
T007_INPUT_JS_SRC?: string;
|
|
27
|
-
/** CDN entrypoint for
|
|
28
|
-
T007_DIALOG_JS_SRC?: string;
|
|
29
|
-
/** CDN stylesheet for
|
|
30
|
-
T007_TOAST_CSS_SRC?: string;
|
|
31
|
-
/** CDN stylesheet for
|
|
32
|
-
T007_INPUT_CSS_SRC?: string;
|
|
33
|
-
/** CDN stylesheet for
|
|
34
|
-
T007_DIALOG_CSS_SRC?: string;
|
|
23
|
+
/** CDN js entrypoint for `@t007/toast`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
|
|
24
|
+
T007_TOAST_JS_SRC?: string | symbol;
|
|
25
|
+
/** CDN js entrypoint for `@t007/input`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
|
|
26
|
+
T007_INPUT_JS_SRC?: string | symbol;
|
|
27
|
+
/** CDN js entrypoint for `@t007/dialog`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
|
|
28
|
+
T007_DIALOG_JS_SRC?: string | symbol;
|
|
29
|
+
/** CDN stylesheet for `@t007/toast`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
|
|
30
|
+
T007_TOAST_CSS_SRC?: string | symbol;
|
|
31
|
+
/** CDN stylesheet for `@t007/input`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
|
|
32
|
+
T007_INPUT_CSS_SRC?: string | symbol;
|
|
33
|
+
/** CDN stylesheet for `@t007/dialog`, assign a symbol if bundling, e.g. `VIRTUAL_RESOURCE` from `@t007/utils`. */
|
|
34
|
+
T007_DIALOG_CSS_SRC?: string | symbol;
|
|
35
35
|
}
|
|
36
36
|
/** Shared T007 namespace on the global object. */
|
|
37
37
|
var t007: T007Namespace;
|
|
@@ -77,12 +77,17 @@ declare function parseCSSTime(time: any): number;
|
|
|
77
77
|
* @returns The equivalent value in pixels.
|
|
78
78
|
*/
|
|
79
79
|
declare function parseCSSSize(size: any, el?: HTMLElement): number;
|
|
80
|
+
/** Normalize a URL by decoding it and removing query parameters and hash fragments.
|
|
81
|
+
* @param url The URL string to clean.
|
|
82
|
+
* @returns A normalized URL string for comparison.
|
|
83
|
+
*/
|
|
84
|
+
declare function cleanURL(url: string): string;
|
|
80
85
|
/** Compare two URLs after normalizing origin, pathname, and separators.
|
|
81
|
-
* @param
|
|
82
|
-
* @param
|
|
86
|
+
* @param url1 First URL or path.
|
|
87
|
+
* @param url2 Second URL or path.
|
|
83
88
|
* @returns True when both references point to the same resource.
|
|
84
89
|
*/
|
|
85
|
-
declare function isSameURL(
|
|
90
|
+
declare function isSameURL(url1: unknown, url2: unknown): boolean;
|
|
86
91
|
|
|
87
92
|
interface LimitedOptions {
|
|
88
93
|
/** Storage key used to persist call counts. */
|
|
@@ -134,7 +139,7 @@ declare function bindCleanupToSignal<Cb extends () => any>(cleanup: Cb, signal?:
|
|
|
134
139
|
/** Exhaustive Selector used for interactive, tabbable UI controls. */
|
|
135
140
|
declare const INTERACTIVE_SELECTOR = ":is(button,[href],input:not([type='hidden']),select,textarea,details>summary,[contenteditable='true'],iframe,audio[controls],video[controls],[tabindex]):not([disabled],[tabindex='-1'],[data-focus-guard],[inert],[inert] *)";
|
|
136
141
|
/** Check whether an event target points to an interactive element. */
|
|
137
|
-
declare const isInteractive: (target: EventTarget | null) =>
|
|
142
|
+
declare const isInteractive: (target: EventTarget | null) => boolean;
|
|
138
143
|
/** Resource type accepted by loadResource. */
|
|
139
144
|
type ResourceType = "style" | "script" | string;
|
|
140
145
|
/** Options used when loading a script or stylesheet resource. */
|
|
@@ -183,4 +188,4 @@ declare function getWindow(el?: any): (Window & typeof globalThis) | undefined;
|
|
|
183
188
|
*/
|
|
184
189
|
declare function formatSize(bytes: number, decimals?: number, base?: number): string;
|
|
185
190
|
|
|
186
|
-
export { INTERACTIVE_SELECTOR, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, VIRTUAL_RESOURCE, bindCleanupToSignal, breath, deepBreath, formatSize, getWindow, inBoolArrOpt, isArr, isBool, isDef, isFunc, isInteractive, isIter, isNum, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, parseCSSSize, parseCSSTime, pxToRem, remToPx, uid };
|
|
191
|
+
export { INTERACTIVE_SELECTOR, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, VIRTUAL_RESOURCE, bindCleanupToSignal, breath, cleanURL, deepBreath, formatSize, getWindow, inBoolArrOpt, isArr, isBool, isDef, isFunc, isInteractive, isIter, isNum, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, parseCSSSize, parseCSSTime, pxToRem, remToPx, uid };
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
breath,
|
|
10
10
|
clamp,
|
|
11
11
|
cleanKeyCombo,
|
|
12
|
+
cleanURL,
|
|
12
13
|
createEl,
|
|
13
14
|
deepBreath,
|
|
14
15
|
formatKeyForDisplay,
|
|
@@ -49,7 +50,7 @@ import {
|
|
|
49
50
|
setTimeout,
|
|
50
51
|
stringifyKeyEvent,
|
|
51
52
|
uid
|
|
52
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-4O76EZJ4.js";
|
|
53
54
|
export {
|
|
54
55
|
INTERACTIVE_SELECTOR,
|
|
55
56
|
NIL,
|
|
@@ -61,6 +62,7 @@ export {
|
|
|
61
62
|
breath,
|
|
62
63
|
clamp,
|
|
63
64
|
cleanKeyCombo,
|
|
65
|
+
cleanURL,
|
|
64
66
|
createEl,
|
|
65
67
|
deepBreath,
|
|
66
68
|
formatKeyForDisplay,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t007/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"description": "High-performance utilities for the t007 ecosystem.",
|
|
5
5
|
"author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"react-dom": "^18.3.1"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"sia-reactor": "^0.0.
|
|
78
|
+
"sia-reactor": "^0.0.34"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"react": "^18.0.0"
|