@t007/utils 0.0.29 → 0.0.30

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/README.md CHANGED
@@ -151,10 +151,10 @@ All defaults are exposed as root-level, `t007`-prefixed variables:
151
151
  /** default scroll assist values */
152
152
  --t007-scroll-assist-color: rgb(0 0 0 / 1);
153
153
  --t007-scroll-assist-opacity: 0.07;
154
- --t007-scroll-assist-min-width: 2rem;
154
+ --t007-scroll-assist-width: 2rem;
155
155
  --t007-scroll-assist-height: 2rem;
156
- --t007-scroll-assist-inline-offset: -0.35rem;
157
- --t007-scroll-assist-block-offset: 0;
156
+ --t007-scroll-assist-inset-x: -0.35rem;
157
+ --t007-scroll-assist-inset-y: 0;
158
158
  }
159
159
 
160
160
  /** custom pre-requisites */
@@ -1,4 +1,4 @@
1
- // src/hooks/react/useHighlight.ts
1
+ // src/ts/hooks/react/useHighlight.ts
2
2
  import { useMemo } from "react";
3
3
  function useHighlight(text, query, ignoreCase = true, options) {
4
4
  const { trimQuery = true, wholeWord = false } = options ?? {};
@@ -1,4 +1,4 @@
1
- // src/core/dom.ts
1
+ // src/ts/core/dom.ts
2
2
  import { createEl, assignEl } from "sia-reactor/utils";
3
3
  import { getActiveEl } from "sia-reactor/utils";
4
4
  var 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] *)";
@@ -31,11 +31,14 @@ function loadResource(req, type = "style", { module, media, crossOrigin, integri
31
31
  });
32
32
  return w.t007._resourceCache[src];
33
33
  }
34
+ function getWindow(el = window) {
35
+ return (el instanceof Window ? el : el instanceof Document ? el?.defaultView : el?.ownerDocument?.defaultView) ?? void 0;
36
+ }
34
37
 
35
- // src/index.ts
38
+ // src/ts/index.ts
36
39
  import { NIL, NOOP } from "sia-reactor";
37
40
 
38
- // src/core/obj.ts
41
+ // src/ts/core/obj.ts
39
42
  import { isObj } from "sia-reactor/utils";
40
43
  function isDef(val) {
41
44
  return "undefined" !== typeof val;
@@ -68,10 +71,10 @@ function inBoolArrOpt(opt, str) {
68
71
  return opt?.includes?.(str) ?? opt;
69
72
  }
70
73
 
71
- // src/core/num.ts
74
+ // src/ts/core/num.ts
72
75
  import { clamp } from "sia-reactor/utils";
73
76
 
74
- // src/core/str.ts
77
+ // src/ts/core/str.ts
75
78
  function uid(prefix = "") {
76
79
  return prefix + Date.now().toString(36) + "_" + performance.now().toString(36).replace(".", "") + "_" + Math.random().toString(36).slice(2);
77
80
  }
@@ -97,7 +100,7 @@ function isSameURL(src1, src2) {
97
100
  }
98
101
  }
99
102
 
100
- // src/core/fn.ts
103
+ // src/ts/core/fn.ts
101
104
  import { setTimeout as setTimeout2, setInterval, requestAnimationFrame } from "sia-reactor/utils";
102
105
  function limited(FN_KEY, fn, opts = {}) {
103
106
  let count = 0, { key, maxTimes: max = 1 } = isStr(opts) ? { key: opts } : opts;
@@ -121,20 +124,20 @@ function bindCleanupToSignal(cleanup, signal) {
121
124
  return cleanup;
122
125
  }
123
126
 
124
- // src/core/keys.ts
127
+ // src/ts/core/keys.ts
125
128
  import { parseKeyCombo, stringifyKeyEvent, cleanKeyCombo, matchKeys, getTermsForKey, keyEventAllowed, formatKeyForDisplay, formatKeyShortcutsForDisplay, parseForARIAKS } from "sia-reactor/utils";
126
129
 
127
- // src/core/file.ts
130
+ // src/ts/core/file.ts
128
131
  function formatSize(bytes, decimals = 3, base = 1e3) {
129
132
  if (bytes < base) return `${bytes} byte${bytes == 1 ? "" : "s"}`;
130
133
  const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(base)), units.length - 1);
131
134
  return `${(bytes / Math.pow(base, exponent)).toFixed(decimals).replace(/\.0+$/, "")} ${units[exponent]}`;
132
135
  }
133
136
 
134
- // src/mixins/methd.ts
137
+ // src/ts/mixins/methd.ts
135
138
  import { onAllMethods, bindAllMethods, guardAllMethods, guardMethod } from "sia-reactor/utils";
136
139
 
137
- // src/index.ts
140
+ // src/ts/index.ts
138
141
  if ("undefined" !== typeof window) {
139
142
  (window.t007 ??= {}).VIRTUAL_RESOURCE = VIRTUAL_RESOURCE;
140
143
  window.T007_TOAST_JS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/toast@latest`;
@@ -152,6 +155,7 @@ export {
152
155
  isInteractive,
153
156
  VIRTUAL_RESOURCE,
154
157
  loadResource,
158
+ getWindow,
155
159
  getActiveEl,
156
160
  isObj,
157
161
  isDef,
@@ -4,9 +4,9 @@ import {
4
4
  createEl,
5
5
  getActiveEl,
6
6
  isInteractive
7
- } from "./chunk-N5KX6IW4.js";
7
+ } from "./chunk-Y5YJMRXD.js";
8
8
 
9
- // src/hooks/vanilla/outsideClick.ts
9
+ // src/ts/hooks/vanilla/outsideClick.ts
10
10
  import { NIL, NOOP } from "sia-reactor";
11
11
  function initOutsideClick(el, { enabled = false, onOutsideClick = NOOP, outOnClick = true, outOnEscape = true, outOnFocusOut = false, allowInputs = false, root = window, scoped = true, capture = true } = NIL) {
12
12
  const stacks = t007._outsiders_stacks ??= /* @__PURE__ */ new WeakMap(), existing = (t007._outsiders ??= /* @__PURE__ */ new WeakMap()).get(el);
@@ -29,7 +29,7 @@ function initOutsideClick(el, { enabled = false, onOutsideClick = NOOP, outOnCli
29
29
  }
30
30
  var removeOutsideClick = (el) => t007._outsiders?.get(el)?.();
31
31
 
32
- // src/hooks/vanilla/focusTrap.ts
32
+ // src/ts/hooks/vanilla/focusTrap.ts
33
33
  import { NIL as NIL2 } from "sia-reactor";
34
34
  function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus]", ringClassName = "focus-outline", root = window, scoped = true, capture = true } = NIL2) {
35
35
  const stacks = t007._ftrappers_stacks ??= /* @__PURE__ */ new WeakMap(), existing = (t007._ftrappers ??= /* @__PURE__ */ new WeakMap()).get(el);
@@ -40,9 +40,9 @@ function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus
40
40
  if (rt.hasAttribute("tabindex")) return rt.focus();
41
41
  const items = getFocusable();
42
42
  if (!items.length) return resetFocus(0, null);
43
- const ceiling = document.fullscreenElement || document.querySelector("dialog:modal") || document.body;
44
- let p = rt.parentElement || ceiling, all = getFocusable(p);
45
- while (p !== ceiling && (!all.length || rt.contains(all[0]) && rt.contains(all.at(-1)))) all = getFocusable(p = p.parentElement || ceiling);
43
+ const ceil = document.fullscreenElement || document.querySelector("dialog:modal") || document.body;
44
+ let p = rt.parentElement || ceil, all = getFocusable(p);
45
+ while (p !== ceil && (!all.length || (pre ? rt.contains(all[0]) : rt.contains(all.at(-1))))) all = getFocusable(p = p.parentElement || ceil);
46
46
  for (let target, len = all.length, i = all.indexOf(items[pre ? 0 : items.length - 1]) + (pre ? -1 : 1); pre ? i >= 0 : i < len; pre ? i-- : i++) if (!rt.contains(target = all[i])) return target.focus();
47
47
  (pre ? first : last).blur();
48
48
  }, handleFocusIn = () => {
@@ -64,7 +64,7 @@ function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus
64
64
  }
65
65
  var removeFocusTrap = (el) => t007._ftrappers?.get(el)?.();
66
66
 
67
- // src/hooks/vanilla/ripple.ts
67
+ // src/ts/hooks/vanilla/ripple.ts
68
68
  import { NIL as NIL3 } from "sia-reactor";
69
69
  function rippleHandler(e, { target, forceCenter = false, wrapperClassName = "t007-ripple-wrapper", className = "t007-ripple", holdClassName = "t007-ripple-hold", fadeClassName = "t007-ripple-fade" } = NIL3) {
70
70
  const el = target || e.currentTarget;
@@ -83,7 +83,7 @@ function rippleHandler(e, { target, forceCenter = false, wrapperClassName = "t00
83
83
  for (const evt of ["pointerup", "pointercancel"]) (el.ownerDocument?.defaultView || window).addEventListener(evt, release);
84
84
  }
85
85
 
86
- // src/hooks/react/useArrowNavigation/utils.ts
86
+ // src/ts/hooks/react/useArrowNavigation/utils.ts
87
87
  var getTargetIndex = ({ key, currIndex, length, gridX, gridY, vGridY, loop, ctrlKey = false, rtl }) => {
88
88
  const rowStart = currIndex - currIndex % gridX, rowEnd = Math.min(rowStart + gridX - 1, length - 1), colStart = currIndex % gridX, colEnd = Math.min(colStart + gridX * (gridY - 1), length - 1), canX = gridX > 1, canY = gridY > 1, horizontalMove = rtl ? { ArrowRight: canX ? -1 : 0, ArrowLeft: canX ? 1 : 0 } : { ArrowRight: canX ? 1 : 0, ArrowLeft: canX ? -1 : 0 }, move = { ...horizontalMove, ArrowDown: canY ? gridX : 0, ArrowUp: canY ? -gridX : 0, Home: ctrlKey ? 0 : rowStart, End: ctrlKey ? length - 1 : rowEnd, PageDown: (vGridY - 1) * gridX, PageUp: -(vGridY - 1) * gridX }[key] ?? 0;
89
89
  let targetIndex = key === "Home" || key === "End" ? move : currIndex + move;
@@ -127,7 +127,7 @@ var getGrid = (all, x = true, y = true, vY = true) => {
127
127
  return grid;
128
128
  };
129
129
 
130
- // src/hooks/react/useArrowNavigation/consts.ts
130
+ // src/ts/hooks/react/useArrowNavigation/consts.ts
131
131
  import { NOOP as NOOP2 } from "sia-reactor";
132
132
  var H_NAV_KEYS = ["ArrowRight", "ArrowLeft", "Home", "End"];
133
133
  var V_NAV_KEYS = ["ArrowUp", "ArrowDown", "PageDown", "PageUp"];
@@ -17,14 +17,14 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/components/react.ts
20
+ // src/ts/components/react.ts
21
21
  var react_exports = {};
22
22
  __export(react_exports, {
23
23
  HighlightText: () => HighlightText
24
24
  });
25
25
  module.exports = __toCommonJS(react_exports);
26
26
 
27
- // src/hooks/react/useHighlight.ts
27
+ // src/ts/hooks/react/useHighlight.ts
28
28
  var import_react = require("react");
29
29
  function useHighlight(text, query, ignoreCase = true, options) {
30
30
  const { trimQuery = true, wholeWord = false } = options ?? {};
@@ -37,7 +37,7 @@ function useHighlight(text, query, ignoreCase = true, options) {
37
37
  }, [text, query, ignoreCase, trimQuery, wholeWord]);
38
38
  }
39
39
 
40
- // src/components/react/HighlightText.tsx
40
+ // src/ts/components/react/HighlightText.tsx
41
41
  var import_jsx_runtime = require("react/jsx-runtime");
42
42
  var HighlightText = ({ children = "", query = "", className = "highlight", ignoreCase = true, trimQuery = true, wholeWord = false }) => {
43
43
  const chunks = useHighlight(children, query, ignoreCase, { trimQuery, wholeWord });
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  useHighlight
3
- } from "../chunk-OGFBI6PS.js";
3
+ } from "../chunk-RXMKMD3E.js";
4
4
 
5
- // src/components/react/HighlightText.tsx
5
+ // src/ts/components/react/HighlightText.tsx
6
6
  import { Fragment, jsx } from "react/jsx-runtime";
7
7
  var HighlightText = ({ children = "", query = "", className = "highlight", ignoreCase = true, trimQuery = true, wholeWord = false }) => {
8
8
  const chunks = useHighlight(children, query, ignoreCase, { trimQuery, wholeWord });
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/hooks/react.ts
20
+ // src/ts/hooks/react.ts
21
21
  var react_exports = {};
22
22
  __export(react_exports, {
23
23
  useArrowNavigation: () => useArrowNavigation,
@@ -29,19 +29,19 @@ __export(react_exports, {
29
29
  });
30
30
  module.exports = __toCommonJS(react_exports);
31
31
 
32
- // src/hooks/react/useScrollAssist.ts
32
+ // src/ts/hooks/react/useScrollAssist.ts
33
33
  var import_react = require("react");
34
34
 
35
- // src/core/num.ts
35
+ // src/ts/core/num.ts
36
36
  var import_utils = require("sia-reactor/utils");
37
37
 
38
- // src/core/dom.ts
38
+ // src/ts/core/dom.ts
39
39
  var import_utils2 = require("sia-reactor/utils");
40
40
  var import_utils3 = require("sia-reactor/utils");
41
41
  var 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] *)";
42
42
  var isInteractive = (target) => target instanceof HTMLElement && target.matches(INTERACTIVE_SELECTOR);
43
43
 
44
- // src/hooks/react/useScrollAssist.ts
44
+ // src/ts/hooks/react/useScrollAssist.ts
45
45
  var import_sia_reactor = require("sia-reactor");
46
46
  function useScrollAssist(ref, { enabled = true, pxPerSecond = 80, assistClassName = "t007-scroll-assist", vertical = true, horizontal = true } = import_sia_reactor.NIL) {
47
47
  const scrollId = (0, import_react.useRef)(null), last = (0, import_react.useRef)(performance.now()), assists = (0, import_react.useRef)({}), assistWidth = (0, import_react.useRef)(20), assistHeight = (0, import_react.useRef)(20);
@@ -120,10 +120,10 @@ function useScrollAssist(ref, { enabled = true, pxPerSecond = 80, assistClassNam
120
120
  return { update };
121
121
  }
122
122
 
123
- // src/hooks/react/useOutsideClick.ts
123
+ // src/ts/hooks/react/useOutsideClick.ts
124
124
  var import_react2 = require("react");
125
125
 
126
- // src/hooks/vanilla/outsideClick.ts
126
+ // src/ts/hooks/vanilla/outsideClick.ts
127
127
  var import_sia_reactor2 = require("sia-reactor");
128
128
  function initOutsideClick(el, { enabled = false, onOutsideClick = import_sia_reactor2.NOOP, outOnClick = true, outOnEscape = true, outOnFocusOut = false, allowInputs = false, root = window, scoped = true, capture = true } = import_sia_reactor2.NIL) {
129
129
  const stacks = t007._outsiders_stacks ??= /* @__PURE__ */ new WeakMap(), existing = (t007._outsiders ??= /* @__PURE__ */ new WeakMap()).get(el);
@@ -145,16 +145,16 @@ function initOutsideClick(el, { enabled = false, onOutsideClick = import_sia_rea
145
145
  return t007._outsiders.set(el, destroy), destroy;
146
146
  }
147
147
 
148
- // src/hooks/react/useOutsideClick.ts
148
+ // src/ts/hooks/react/useOutsideClick.ts
149
149
  var import_sia_reactor3 = require("sia-reactor");
150
150
  function useOutsideClick(ref, config = import_sia_reactor3.NIL) {
151
151
  (0, import_react2.useEffect)(() => ref.current ? initOutsideClick(ref.current, config) : void 0, [ref, config.enabled, config.onOutsideClick, config.outOnEscape, config.outOnClick, config.outOnFocusOut, config.allowInputs, config.root, config.scoped, config.capture]);
152
152
  }
153
153
 
154
- // src/hooks/react/useArrowNavigation/index.ts
154
+ // src/ts/hooks/react/useArrowNavigation/index.ts
155
155
  var import_react3 = require("react");
156
156
 
157
- // src/hooks/react/useArrowNavigation/utils.ts
157
+ // src/ts/hooks/react/useArrowNavigation/utils.ts
158
158
  var getTargetIndex = ({ key, currIndex, length, gridX, gridY, vGridY, loop, ctrlKey = false, rtl }) => {
159
159
  const rowStart = currIndex - currIndex % gridX, rowEnd = Math.min(rowStart + gridX - 1, length - 1), colStart = currIndex % gridX, colEnd = Math.min(colStart + gridX * (gridY - 1), length - 1), canX = gridX > 1, canY = gridY > 1, horizontalMove = rtl ? { ArrowRight: canX ? -1 : 0, ArrowLeft: canX ? 1 : 0 } : { ArrowRight: canX ? 1 : 0, ArrowLeft: canX ? -1 : 0 }, move = { ...horizontalMove, ArrowDown: canY ? gridX : 0, ArrowUp: canY ? -gridX : 0, Home: ctrlKey ? 0 : rowStart, End: ctrlKey ? length - 1 : rowEnd, PageDown: (vGridY - 1) * gridX, PageUp: -(vGridY - 1) * gridX }[key] ?? 0;
160
160
  let targetIndex = key === "Home" || key === "End" ? move : currIndex + move;
@@ -198,7 +198,7 @@ var getGrid = (all, x = true, y = true, vY = true) => {
198
198
  return grid;
199
199
  };
200
200
 
201
- // src/hooks/react/useArrowNavigation/consts.ts
201
+ // src/ts/hooks/react/useArrowNavigation/consts.ts
202
202
  var import_sia_reactor4 = require("sia-reactor");
203
203
  var H_NAV_KEYS = ["ArrowRight", "ArrowLeft", "Home", "End"];
204
204
  var V_NAV_KEYS = ["ArrowUp", "ArrowDown", "PageDown", "PageUp"];
@@ -224,7 +224,7 @@ var DEFAULT_CONFIG = {
224
224
  onFocusOut: import_sia_reactor4.NOOP
225
225
  };
226
226
 
227
- // src/hooks/react/useArrowNavigation/index.ts
227
+ // src/ts/hooks/react/useArrowNavigation/index.ts
228
228
  function useArrowNavigation(containerRef, config = {}) {
229
229
  const { enabled: isEnabled, selector, focusOnHover, loop, virtual, typeahead, rovingTab, resetMs, activeClass, inputSelector, defaultTabbableIndex, baseTabIndex, grid, rtl: isRtl, focusOptions, scrollIntoView, onSelect, onFocusOut } = { ...DEFAULT_CONFIG, ...config }, [gridX, setGridX] = (0, import_react3.useState)(grid.x || 1), [gridY, setGridY] = (0, import_react3.useState)(grid.y || 1), [vGridY, setVGridY] = (0, import_react3.useState)(grid.vY || 1), [activeIndex, setActiveIndex] = (0, import_react3.useState)(-1), buffer = (0, import_react3.useRef)(""), timeout = (0, import_react3.useRef)(null), itemsRef = (0, import_react3.useRef)([]), enabled = isEnabled ?? virtual, roving = rovingTab ?? !virtual, rtl = (0, import_react3.useMemo)(() => isRtl ?? ("undefined" === typeof document ? false : getComputedStyle(containerRef.current || document.body).direction === "rtl"), [containerRef, isRtl]), mutationObserverRef = (0, import_react3.useRef)(null), shouldSnub = (0, import_react3.useCallback)(() => !enabled || !containerRef.current, [enabled, containerRef]), isItemDisabled = (0, import_react3.useCallback)((el) => !el ? true : el.hasAttribute("disabled") || el.hasAttribute("aria-disabled"), []), getItems = (0, import_react3.useCallback)(() => itemsRef.current = Array.from(containerRef.current?.querySelectorAll(selector) || []), [containerRef, selector]);
230
230
  const getAbleIndex = (0, import_react3.useCallback)(
@@ -373,10 +373,10 @@ function useArrowNavigation(containerRef, config = {}) {
373
373
  return { gridX, gridY, vGridY, activeIndex, activeItem: (0, import_react3.useCallback)(() => itemsRef.current[activeIndex] ?? null, [activeIndex]), items: (0, import_react3.useCallback)(() => itemsRef.current, []), getAbleIndex, typeAhead, goToIndex, simulateKey };
374
374
  }
375
375
 
376
- // src/hooks/react/useFocusTrap.ts
376
+ // src/ts/hooks/react/useFocusTrap.ts
377
377
  var import_react4 = require("react");
378
378
 
379
- // src/hooks/vanilla/focusTrap.ts
379
+ // src/ts/hooks/vanilla/focusTrap.ts
380
380
  var import_sia_reactor5 = require("sia-reactor");
381
381
  function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus]", ringClassName = "focus-outline", root = window, scoped = true, capture = true } = import_sia_reactor5.NIL) {
382
382
  const stacks = t007._ftrappers_stacks ??= /* @__PURE__ */ new WeakMap(), existing = (t007._ftrappers ??= /* @__PURE__ */ new WeakMap()).get(el);
@@ -387,9 +387,9 @@ function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus
387
387
  if (rt.hasAttribute("tabindex")) return rt.focus();
388
388
  const items = getFocusable();
389
389
  if (!items.length) return resetFocus(0, null);
390
- const ceiling = document.fullscreenElement || document.querySelector("dialog:modal") || document.body;
391
- let p = rt.parentElement || ceiling, all = getFocusable(p);
392
- while (p !== ceiling && (!all.length || rt.contains(all[0]) && rt.contains(all.at(-1)))) all = getFocusable(p = p.parentElement || ceiling);
390
+ const ceil = document.fullscreenElement || document.querySelector("dialog:modal") || document.body;
391
+ let p = rt.parentElement || ceil, all = getFocusable(p);
392
+ while (p !== ceil && (!all.length || (pre ? rt.contains(all[0]) : rt.contains(all.at(-1))))) all = getFocusable(p = p.parentElement || ceil);
393
393
  for (let target, len = all.length, i = all.indexOf(items[pre ? 0 : items.length - 1]) + (pre ? -1 : 1); pre ? i >= 0 : i < len; pre ? i-- : i++) if (!rt.contains(target = all[i])) return target.focus();
394
394
  (pre ? first : last).blur();
395
395
  }, handleFocusIn = () => {
@@ -410,13 +410,13 @@ function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus
410
410
  return t007._ftrappers.set(el, destroy), destroy;
411
411
  }
412
412
 
413
- // src/hooks/react/useFocusTrap.ts
413
+ // src/ts/hooks/react/useFocusTrap.ts
414
414
  var import_sia_reactor6 = require("sia-reactor");
415
415
  function useFocusTrap(ref, config = import_sia_reactor6.NIL) {
416
416
  (0, import_react4.useEffect)(() => ref.current ? initFocusTrap(ref.current, config) : void 0, [ref, config.enabled, config.initialSelector, config.ringClassName, config.root, config.scoped, config.capture]);
417
417
  }
418
418
 
419
- // src/hooks/react/useHighlight.ts
419
+ // src/ts/hooks/react/useHighlight.ts
420
420
  var import_react5 = require("react");
421
421
  function useHighlight(text, query, ignoreCase = true, options) {
422
422
  const { trimQuery = true, wholeWord = false } = options ?? {};
@@ -429,10 +429,10 @@ function useHighlight(text, query, ignoreCase = true, options) {
429
429
  }, [text, query, ignoreCase, trimQuery, wholeWord]);
430
430
  }
431
431
 
432
- // src/hooks/react/useRipple.ts
432
+ // src/ts/hooks/react/useRipple.ts
433
433
  var import_react6 = require("react");
434
434
 
435
- // src/hooks/vanilla/ripple.ts
435
+ // src/ts/hooks/vanilla/ripple.ts
436
436
  var import_sia_reactor7 = require("sia-reactor");
437
437
  function rippleHandler(e, { target, forceCenter = false, wrapperClassName = "t007-ripple-wrapper", className = "t007-ripple", holdClassName = "t007-ripple-hold", fadeClassName = "t007-ripple-fade" } = import_sia_reactor7.NIL) {
438
438
  const el = target || e.currentTarget;
@@ -451,7 +451,7 @@ function rippleHandler(e, { target, forceCenter = false, wrapperClassName = "t00
451
451
  for (const evt of ["pointerup", "pointercancel"]) (el.ownerDocument?.defaultView || window).addEventListener(evt, release);
452
452
  }
453
453
 
454
- // src/hooks/react/useRipple.ts
454
+ // src/ts/hooks/react/useRipple.ts
455
455
  var import_sia_reactor8 = require("sia-reactor");
456
456
  function useRipple() {
457
457
  return (0, import_react6.useCallback)((e, config = import_sia_reactor8.NIL) => rippleHandler(e.nativeEvent, config), []);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useHighlight
3
- } from "../chunk-OGFBI6PS.js";
3
+ } from "../chunk-RXMKMD3E.js";
4
4
  import {
5
5
  DEFAULT_CONFIG,
6
6
  H_NAV_KEYS,
@@ -11,13 +11,13 @@ import {
11
11
  initFocusTrap,
12
12
  initOutsideClick,
13
13
  rippleHandler
14
- } from "../chunk-NLR4ANGT.js";
14
+ } from "../chunk-YDARUYLO.js";
15
15
  import {
16
16
  INTERACTIVE_SELECTOR,
17
17
  getActiveEl
18
- } from "../chunk-N5KX6IW4.js";
18
+ } from "../chunk-Y5YJMRXD.js";
19
19
 
20
- // src/hooks/react/useScrollAssist.ts
20
+ // src/ts/hooks/react/useScrollAssist.ts
21
21
  import { useEffect, useRef, useCallback } from "react";
22
22
  import { NIL } from "sia-reactor";
23
23
  function useScrollAssist(ref, { enabled = true, pxPerSecond = 80, assistClassName = "t007-scroll-assist", vertical = true, horizontal = true } = NIL) {
@@ -97,14 +97,14 @@ function useScrollAssist(ref, { enabled = true, pxPerSecond = 80, assistClassNam
97
97
  return { update };
98
98
  }
99
99
 
100
- // src/hooks/react/useOutsideClick.ts
100
+ // src/ts/hooks/react/useOutsideClick.ts
101
101
  import { useEffect as useEffect2 } from "react";
102
102
  import { NIL as NIL2 } from "sia-reactor";
103
103
  function useOutsideClick(ref, config = NIL2) {
104
104
  useEffect2(() => ref.current ? initOutsideClick(ref.current, config) : void 0, [ref, config.enabled, config.onOutsideClick, config.outOnEscape, config.outOnClick, config.outOnFocusOut, config.allowInputs, config.root, config.scoped, config.capture]);
105
105
  }
106
106
 
107
- // src/hooks/react/useArrowNavigation/index.ts
107
+ // src/ts/hooks/react/useArrowNavigation/index.ts
108
108
  import { useEffect as useEffect3, useState, useCallback as useCallback2, useRef as useRef2, useMemo } from "react";
109
109
  function useArrowNavigation(containerRef, config = {}) {
110
110
  const { enabled: isEnabled, selector, focusOnHover, loop, virtual, typeahead, rovingTab, resetMs, activeClass, inputSelector, defaultTabbableIndex, baseTabIndex, grid, rtl: isRtl, focusOptions, scrollIntoView, onSelect, onFocusOut } = { ...DEFAULT_CONFIG, ...config }, [gridX, setGridX] = useState(grid.x || 1), [gridY, setGridY] = useState(grid.y || 1), [vGridY, setVGridY] = useState(grid.vY || 1), [activeIndex, setActiveIndex] = useState(-1), buffer = useRef2(""), timeout = useRef2(null), itemsRef = useRef2([]), enabled = isEnabled ?? virtual, roving = rovingTab ?? !virtual, rtl = useMemo(() => isRtl ?? ("undefined" === typeof document ? false : getComputedStyle(containerRef.current || document.body).direction === "rtl"), [containerRef, isRtl]), mutationObserverRef = useRef2(null), shouldSnub = useCallback2(() => !enabled || !containerRef.current, [enabled, containerRef]), isItemDisabled = useCallback2((el) => !el ? true : el.hasAttribute("disabled") || el.hasAttribute("aria-disabled"), []), getItems = useCallback2(() => itemsRef.current = Array.from(containerRef.current?.querySelectorAll(selector) || []), [containerRef, selector]);
@@ -254,14 +254,14 @@ function useArrowNavigation(containerRef, config = {}) {
254
254
  return { gridX, gridY, vGridY, activeIndex, activeItem: useCallback2(() => itemsRef.current[activeIndex] ?? null, [activeIndex]), items: useCallback2(() => itemsRef.current, []), getAbleIndex, typeAhead, goToIndex, simulateKey };
255
255
  }
256
256
 
257
- // src/hooks/react/useFocusTrap.ts
257
+ // src/ts/hooks/react/useFocusTrap.ts
258
258
  import { useEffect as useEffect4 } from "react";
259
259
  import { NIL as NIL3 } from "sia-reactor";
260
260
  function useFocusTrap(ref, config = NIL3) {
261
261
  useEffect4(() => ref.current ? initFocusTrap(ref.current, config) : void 0, [ref, config.enabled, config.initialSelector, config.ringClassName, config.root, config.scoped, config.capture]);
262
262
  }
263
263
 
264
- // src/hooks/react/useRipple.ts
264
+ // src/ts/hooks/react/useRipple.ts
265
265
  import { useCallback as useCallback3 } from "react";
266
266
  import { NIL as NIL4 } from "sia-reactor";
267
267
  function useRipple() {
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/hooks/vanilla.ts
20
+ // src/ts/hooks/vanilla.ts
21
21
  var vanilla_exports = {};
22
22
  __export(vanilla_exports, {
23
23
  initArrowNavigation: () => initArrowNavigation,
@@ -33,19 +33,19 @@ __export(vanilla_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(vanilla_exports);
35
35
 
36
- // src/hooks/vanilla/scrollAssist.ts
36
+ // src/ts/hooks/vanilla/scrollAssist.ts
37
37
  var import_sia_reactor = require("sia-reactor");
38
38
 
39
- // src/core/dom.ts
39
+ // src/ts/core/dom.ts
40
40
  var import_utils = require("sia-reactor/utils");
41
41
  var import_utils2 = require("sia-reactor/utils");
42
42
  var 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] *)";
43
43
  var isInteractive = (target) => target instanceof HTMLElement && target.matches(INTERACTIVE_SELECTOR);
44
44
 
45
- // src/core/num.ts
45
+ // src/ts/core/num.ts
46
46
  var import_utils3 = require("sia-reactor/utils");
47
47
 
48
- // src/hooks/vanilla/scrollAssist.ts
48
+ // src/ts/hooks/vanilla/scrollAssist.ts
49
49
  function initScrollAssist(el, { pxPerSecond = 80, assistClassName = "t007-scroll-assist", vertical = true, horizontal = true } = import_sia_reactor.NIL) {
50
50
  const parent = el?.parentElement, existing = (t007._scrollers ??= /* @__PURE__ */ new WeakMap()).get(el);
51
51
  if (!parent || existing) return existing ? existing : void 0;
@@ -117,7 +117,7 @@ function initScrollAssist(el, { pxPerSecond = 80, assistClassName = "t007-scroll
117
117
  }
118
118
  var removeScrollAssist = (el) => t007._scrollers.get(el)?.destroy();
119
119
 
120
- // src/hooks/vanilla/scrollerator.ts
120
+ // src/ts/hooks/vanilla/scrollerator.ts
121
121
  var import_sia_reactor2 = require("sia-reactor");
122
122
  function initVScrollerator({ baseSpeed = 3, maxSpeed = 10, stepDelay = 2e3, baseRate = 16, lineHeight = 80, margin = 80, car = window } = import_sia_reactor2.NIL) {
123
123
  let linesPerSec = baseSpeed, accelId = null, lastTime = null;
@@ -134,7 +134,7 @@ function initVScrollerator({ baseSpeed = 3, maxSpeed = 10, stepDelay = 2e3, base
134
134
  return { drive, reset };
135
135
  }
136
136
 
137
- // src/hooks/vanilla/outsideClick.ts
137
+ // src/ts/hooks/vanilla/outsideClick.ts
138
138
  var import_sia_reactor3 = require("sia-reactor");
139
139
  function initOutsideClick(el, { enabled = false, onOutsideClick = import_sia_reactor3.NOOP, outOnClick = true, outOnEscape = true, outOnFocusOut = false, allowInputs = false, root = window, scoped = true, capture = true } = import_sia_reactor3.NIL) {
140
140
  const stacks = t007._outsiders_stacks ??= /* @__PURE__ */ new WeakMap(), existing = (t007._outsiders ??= /* @__PURE__ */ new WeakMap()).get(el);
@@ -157,7 +157,7 @@ function initOutsideClick(el, { enabled = false, onOutsideClick = import_sia_rea
157
157
  }
158
158
  var removeOutsideClick = (el) => t007._outsiders?.get(el)?.();
159
159
 
160
- // src/hooks/vanilla/focusTrap.ts
160
+ // src/ts/hooks/vanilla/focusTrap.ts
161
161
  var import_sia_reactor4 = require("sia-reactor");
162
162
  function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus]", ringClassName = "focus-outline", root = window, scoped = true, capture = true } = import_sia_reactor4.NIL) {
163
163
  const stacks = t007._ftrappers_stacks ??= /* @__PURE__ */ new WeakMap(), existing = (t007._ftrappers ??= /* @__PURE__ */ new WeakMap()).get(el);
@@ -168,9 +168,9 @@ function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus
168
168
  if (rt.hasAttribute("tabindex")) return rt.focus();
169
169
  const items = getFocusable();
170
170
  if (!items.length) return resetFocus(0, null);
171
- const ceiling = document.fullscreenElement || document.querySelector("dialog:modal") || document.body;
172
- let p = rt.parentElement || ceiling, all = getFocusable(p);
173
- while (p !== ceiling && (!all.length || rt.contains(all[0]) && rt.contains(all.at(-1)))) all = getFocusable(p = p.parentElement || ceiling);
171
+ const ceil = document.fullscreenElement || document.querySelector("dialog:modal") || document.body;
172
+ let p = rt.parentElement || ceil, all = getFocusable(p);
173
+ while (p !== ceil && (!all.length || (pre ? rt.contains(all[0]) : rt.contains(all.at(-1))))) all = getFocusable(p = p.parentElement || ceil);
174
174
  for (let target, len = all.length, i = all.indexOf(items[pre ? 0 : items.length - 1]) + (pre ? -1 : 1); pre ? i >= 0 : i < len; pre ? i-- : i++) if (!rt.contains(target = all[i])) return target.focus();
175
175
  (pre ? first : last).blur();
176
176
  }, handleFocusIn = () => {
@@ -192,7 +192,7 @@ function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus
192
192
  }
193
193
  var removeFocusTrap = (el) => t007._ftrappers?.get(el)?.();
194
194
 
195
- // src/hooks/react/useArrowNavigation/consts.ts
195
+ // src/ts/hooks/react/useArrowNavigation/consts.ts
196
196
  var import_sia_reactor5 = require("sia-reactor");
197
197
  var H_NAV_KEYS = ["ArrowRight", "ArrowLeft", "Home", "End"];
198
198
  var V_NAV_KEYS = ["ArrowUp", "ArrowDown", "PageDown", "PageUp"];
@@ -218,7 +218,7 @@ var DEFAULT_CONFIG = {
218
218
  onFocusOut: import_sia_reactor5.NOOP
219
219
  };
220
220
 
221
- // src/hooks/react/useArrowNavigation/utils.ts
221
+ // src/ts/hooks/react/useArrowNavigation/utils.ts
222
222
  var getTargetIndex = ({ key, currIndex, length, gridX, gridY, vGridY, loop, ctrlKey = false, rtl }) => {
223
223
  const rowStart = currIndex - currIndex % gridX, rowEnd = Math.min(rowStart + gridX - 1, length - 1), colStart = currIndex % gridX, colEnd = Math.min(colStart + gridX * (gridY - 1), length - 1), canX = gridX > 1, canY = gridY > 1, horizontalMove = rtl ? { ArrowRight: canX ? -1 : 0, ArrowLeft: canX ? 1 : 0 } : { ArrowRight: canX ? 1 : 0, ArrowLeft: canX ? -1 : 0 }, move = { ...horizontalMove, ArrowDown: canY ? gridX : 0, ArrowUp: canY ? -gridX : 0, Home: ctrlKey ? 0 : rowStart, End: ctrlKey ? length - 1 : rowEnd, PageDown: (vGridY - 1) * gridX, PageUp: -(vGridY - 1) * gridX }[key] ?? 0;
224
224
  let targetIndex = key === "Home" || key === "End" ? move : currIndex + move;
@@ -262,7 +262,7 @@ var getGrid = (all, x = true, y = true, vY = true) => {
262
262
  return grid;
263
263
  };
264
264
 
265
- // src/hooks/vanilla/arrowNavigation.ts
265
+ // src/ts/hooks/vanilla/arrowNavigation.ts
266
266
  function initArrowNavigation(container, config = {}) {
267
267
  const existing = (t007._arrownavs ??= /* @__PURE__ */ new WeakMap()).get(container);
268
268
  if (!config.enabled || existing) return existing ? existing : void 0;
@@ -375,7 +375,7 @@ function initArrowNavigation(container, config = {}) {
375
375
  }
376
376
  var removeArrowNavigation = (container) => t007._arrownavs?.get(container)?.destroy();
377
377
 
378
- // src/hooks/vanilla/ripple.ts
378
+ // src/ts/hooks/vanilla/ripple.ts
379
379
  var import_sia_reactor6 = require("sia-reactor");
380
380
  function rippleHandler(e, { target, forceCenter = false, wrapperClassName = "t007-ripple-wrapper", className = "t007-ripple", holdClassName = "t007-ripple-hold", fadeClassName = "t007-ripple-fade" } = import_sia_reactor6.NIL) {
381
381
  const el = target || e.currentTarget;
@@ -10,14 +10,14 @@ import {
10
10
  removeFocusTrap,
11
11
  removeOutsideClick,
12
12
  rippleHandler
13
- } from "../chunk-NLR4ANGT.js";
13
+ } from "../chunk-YDARUYLO.js";
14
14
  import {
15
15
  INTERACTIVE_SELECTOR,
16
16
  createEl,
17
17
  getActiveEl
18
- } from "../chunk-N5KX6IW4.js";
18
+ } from "../chunk-Y5YJMRXD.js";
19
19
 
20
- // src/hooks/vanilla/scrollAssist.ts
20
+ // src/ts/hooks/vanilla/scrollAssist.ts
21
21
  import { NIL } from "sia-reactor";
22
22
  function initScrollAssist(el, { pxPerSecond = 80, assistClassName = "t007-scroll-assist", vertical = true, horizontal = true } = NIL) {
23
23
  const parent = el?.parentElement, existing = (t007._scrollers ??= /* @__PURE__ */ new WeakMap()).get(el);
@@ -90,7 +90,7 @@ function initScrollAssist(el, { pxPerSecond = 80, assistClassName = "t007-scroll
90
90
  }
91
91
  var removeScrollAssist = (el) => t007._scrollers.get(el)?.destroy();
92
92
 
93
- // src/hooks/vanilla/scrollerator.ts
93
+ // src/ts/hooks/vanilla/scrollerator.ts
94
94
  import { NIL as NIL2 } from "sia-reactor";
95
95
  function initVScrollerator({ baseSpeed = 3, maxSpeed = 10, stepDelay = 2e3, baseRate = 16, lineHeight = 80, margin = 80, car = window } = NIL2) {
96
96
  let linesPerSec = baseSpeed, accelId = null, lastTime = null;
@@ -107,7 +107,7 @@ function initVScrollerator({ baseSpeed = 3, maxSpeed = 10, stepDelay = 2e3, base
107
107
  return { drive, reset };
108
108
  }
109
109
 
110
- // src/hooks/vanilla/arrowNavigation.ts
110
+ // src/ts/hooks/vanilla/arrowNavigation.ts
111
111
  function initArrowNavigation(container, config = {}) {
112
112
  const existing = (t007._arrownavs ??= /* @__PURE__ */ new WeakMap()).get(container);
113
113
  if (!config.enabled || existing) return existing ? existing : void 0;
package/dist/index.cjs CHANGED
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/index.ts
20
+ // src/ts/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  INTERACTIVE_SELECTOR: () => INTERACTIVE_SELECTOR,
@@ -37,6 +37,7 @@ __export(index_exports, {
37
37
  formatSize: () => formatSize,
38
38
  getActiveEl: () => import_utils2.getActiveEl,
39
39
  getTermsForKey: () => import_utils6.getTermsForKey,
40
+ getWindow: () => getWindow,
40
41
  guardAllMethods: () => import_utils7.guardAllMethods,
41
42
  guardMethod: () => import_utils7.guardMethod,
42
43
  inBoolArrOpt: () => inBoolArrOpt,
@@ -72,7 +73,7 @@ __export(index_exports, {
72
73
  });
73
74
  module.exports = __toCommonJS(index_exports);
74
75
 
75
- // src/core/dom.ts
76
+ // src/ts/core/dom.ts
76
77
  var import_utils = require("sia-reactor/utils");
77
78
  var import_utils2 = require("sia-reactor/utils");
78
79
  var 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] *)";
@@ -105,11 +106,14 @@ function loadResource(req, type = "style", { module: module2, media, crossOrigin
105
106
  });
106
107
  return w.t007._resourceCache[src];
107
108
  }
109
+ function getWindow(el = window) {
110
+ return (el instanceof Window ? el : el instanceof Document ? el?.defaultView : el?.ownerDocument?.defaultView) ?? void 0;
111
+ }
108
112
 
109
- // src/index.ts
113
+ // src/ts/index.ts
110
114
  var import_sia_reactor = require("sia-reactor");
111
115
 
112
- // src/core/obj.ts
116
+ // src/ts/core/obj.ts
113
117
  var import_utils3 = require("sia-reactor/utils");
114
118
  function isDef(val) {
115
119
  return "undefined" !== typeof val;
@@ -142,10 +146,10 @@ function inBoolArrOpt(opt, str) {
142
146
  return opt?.includes?.(str) ?? opt;
143
147
  }
144
148
 
145
- // src/core/num.ts
149
+ // src/ts/core/num.ts
146
150
  var import_utils4 = require("sia-reactor/utils");
147
151
 
148
- // src/core/str.ts
152
+ // src/ts/core/str.ts
149
153
  function uid(prefix = "") {
150
154
  return prefix + Date.now().toString(36) + "_" + performance.now().toString(36).replace(".", "") + "_" + Math.random().toString(36).slice(2);
151
155
  }
@@ -171,7 +175,7 @@ function isSameURL(src1, src2) {
171
175
  }
172
176
  }
173
177
 
174
- // src/core/fn.ts
178
+ // src/ts/core/fn.ts
175
179
  var import_utils5 = require("sia-reactor/utils");
176
180
  function limited(FN_KEY, fn, opts = {}) {
177
181
  let count = 0, { key, maxTimes: max = 1 } = isStr(opts) ? { key: opts } : opts;
@@ -195,20 +199,20 @@ function bindCleanupToSignal(cleanup, signal) {
195
199
  return cleanup;
196
200
  }
197
201
 
198
- // src/core/keys.ts
202
+ // src/ts/core/keys.ts
199
203
  var import_utils6 = require("sia-reactor/utils");
200
204
 
201
- // src/core/file.ts
205
+ // src/ts/core/file.ts
202
206
  function formatSize(bytes, decimals = 3, base = 1e3) {
203
207
  if (bytes < base) return `${bytes} byte${bytes == 1 ? "" : "s"}`;
204
208
  const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(base)), units.length - 1);
205
209
  return `${(bytes / Math.pow(base, exponent)).toFixed(decimals).replace(/\.0+$/, "")} ${units[exponent]}`;
206
210
  }
207
211
 
208
- // src/mixins/methd.ts
212
+ // src/ts/mixins/methd.ts
209
213
  var import_utils7 = require("sia-reactor/utils");
210
214
 
211
- // src/index.ts
215
+ // src/ts/index.ts
212
216
  if ("undefined" !== typeof window) {
213
217
  (window.t007 ??= {}).VIRTUAL_RESOURCE = VIRTUAL_RESOURCE;
214
218
  window.T007_TOAST_JS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/toast@latest`;
@@ -237,6 +241,7 @@ if ("undefined" !== typeof window) {
237
241
  formatSize,
238
242
  getActiveEl,
239
243
  getTermsForKey,
244
+ getWindow,
240
245
  guardAllMethods,
241
246
  guardMethod,
242
247
  inBoolArrOpt,
package/dist/index.d.cts CHANGED
@@ -70,13 +70,13 @@ declare function pxToRem(px: number, el?: HTMLElement): number;
70
70
  * @param time The CSS time string to parse.
71
71
  * @returns The equivalent time in milliseconds.
72
72
  */
73
- declare function parseCSSTime(time: string): number;
73
+ declare function parseCSSTime(time: any): number;
74
74
  /** Parse a CSS size value (i.e. "16px" or "1.5rem") into pixels.
75
75
  * @param size The CSS size string to parse.
76
76
  * @param el The element to use for rem reference if needed. Defaults to the root element.
77
77
  * @returns The equivalent value in pixels.
78
78
  */
79
- declare function parseCSSSize(size: string, el?: HTMLElement): number;
79
+ declare function parseCSSSize(size: any, el?: HTMLElement): number;
80
80
  /** Compare two URLs after normalizing origin, pathname, and separators.
81
81
  * @param src1 First URL or path.
82
82
  * @param src2 Second URL or path.
@@ -169,6 +169,12 @@ declare const VIRTUAL_RESOURCE: symbol;
169
169
  */
170
170
  declare function loadResource(req: string | symbol, type?: ResourceType, { module, media, crossOrigin, integrity, referrerPolicy, nonce, fetchPriority, attempts, retryKey }?: LoadResourceOptions, w?: Window & typeof globalThis): Promise<HTMLElement | void>;
171
171
 
172
+ /** Get the window object associated with a given element.
173
+ * @param el The element to get the window for, defaults to the main window.
174
+ * @returns The window object or undefined if none found.
175
+ */
176
+ declare function getWindow(el?: any): (Window & typeof globalThis) | undefined;
177
+
172
178
  /** Format a file size for display.
173
179
  * @param size Size in bytes.
174
180
  * @param decimals Decimal precision.
@@ -177,4 +183,4 @@ declare function loadResource(req: string | symbol, type?: ResourceType, { modul
177
183
  */
178
184
  declare function formatSize(bytes: number, decimals?: number, base?: number): string;
179
185
 
180
- export { INTERACTIVE_SELECTOR, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, VIRTUAL_RESOURCE, bindCleanupToSignal, breath, deepBreath, formatSize, inBoolArrOpt, isArr, isBool, isDef, isFunc, isInteractive, isIter, isNum, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, parseCSSSize, parseCSSTime, pxToRem, remToPx, uid };
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 };
package/dist/index.d.ts CHANGED
@@ -70,13 +70,13 @@ declare function pxToRem(px: number, el?: HTMLElement): number;
70
70
  * @param time The CSS time string to parse.
71
71
  * @returns The equivalent time in milliseconds.
72
72
  */
73
- declare function parseCSSTime(time: string): number;
73
+ declare function parseCSSTime(time: any): number;
74
74
  /** Parse a CSS size value (i.e. "16px" or "1.5rem") into pixels.
75
75
  * @param size The CSS size string to parse.
76
76
  * @param el The element to use for rem reference if needed. Defaults to the root element.
77
77
  * @returns The equivalent value in pixels.
78
78
  */
79
- declare function parseCSSSize(size: string, el?: HTMLElement): number;
79
+ declare function parseCSSSize(size: any, el?: HTMLElement): number;
80
80
  /** Compare two URLs after normalizing origin, pathname, and separators.
81
81
  * @param src1 First URL or path.
82
82
  * @param src2 Second URL or path.
@@ -169,6 +169,12 @@ declare const VIRTUAL_RESOURCE: symbol;
169
169
  */
170
170
  declare function loadResource(req: string | symbol, type?: ResourceType, { module, media, crossOrigin, integrity, referrerPolicy, nonce, fetchPriority, attempts, retryKey }?: LoadResourceOptions, w?: Window & typeof globalThis): Promise<HTMLElement | void>;
171
171
 
172
+ /** Get the window object associated with a given element.
173
+ * @param el The element to get the window for, defaults to the main window.
174
+ * @returns The window object or undefined if none found.
175
+ */
176
+ declare function getWindow(el?: any): (Window & typeof globalThis) | undefined;
177
+
172
178
  /** Format a file size for display.
173
179
  * @param size Size in bytes.
174
180
  * @param decimals Decimal precision.
@@ -177,4 +183,4 @@ declare function loadResource(req: string | symbol, type?: ResourceType, { modul
177
183
  */
178
184
  declare function formatSize(bytes: number, decimals?: number, base?: number): string;
179
185
 
180
- export { INTERACTIVE_SELECTOR, type LimitedHandle, type LimitedOptions, type LoadResourceOptions, type ResourceType, VIRTUAL_RESOURCE, bindCleanupToSignal, breath, deepBreath, formatSize, inBoolArrOpt, isArr, isBool, isDef, isFunc, isInteractive, isIter, isNum, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, parseCSSSize, parseCSSTime, pxToRem, remToPx, uid };
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 };
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  formatSize,
17
17
  getActiveEl,
18
18
  getTermsForKey,
19
+ getWindow,
19
20
  guardAllMethods,
20
21
  guardMethod,
21
22
  inBoolArrOpt,
@@ -48,7 +49,7 @@ import {
48
49
  setTimeout,
49
50
  stringifyKeyEvent,
50
51
  uid
51
- } from "./chunk-N5KX6IW4.js";
52
+ } from "./chunk-Y5YJMRXD.js";
52
53
  export {
53
54
  INTERACTIVE_SELECTOR,
54
55
  NIL,
@@ -67,6 +68,7 @@ export {
67
68
  formatSize,
68
69
  getActiveEl,
69
70
  getTermsForKey,
71
+ getWindow,
70
72
  guardAllMethods,
71
73
  guardMethod,
72
74
  inBoolArrOpt,
@@ -1,44 +1,44 @@
1
1
  :root {
2
- --t007-scroll-assist-color: rgb(0 0 0 / 1);
2
+ --t007-scroll-assist-color: black;
3
3
  --t007-scroll-assist-opacity: 0.5;
4
- --t007-scroll-assist-min-width: 2rem;
5
- --t007-scroll-assist-height: 2rem;
6
- --t007-scroll-assist-inline-offset: -0.35rem;
7
- --t007-scroll-assist-block-offset: 0;
4
+ --t007-scroll-assist-width: 2rem;
5
+ --t007-scroll-assist-height: var(--t007-scroll-assist-width);
6
+ --t007-scroll-assist-inset-x: calc(var(--t007-scroll-assist-width) * -0.25);
7
+ --t007-scroll-assist-inset-y: 0;
8
8
  }
9
9
 
10
10
  .t007-scroll-assist {
11
- --t007-scroll-assist-gradient-dir: to right;
11
+ --t007-gradient-dir: to right;
12
12
  position: absolute;
13
- min-width: var(--t007-scroll-assist-min-width);
13
+ min-width: var(--t007-scroll-assist-width);
14
14
  height: 100%;
15
15
  opacity: var(--t007-scroll-assist-opacity);
16
- background: linear-gradient(var(--t007-scroll-assist-gradient-dir), transparent 0, var(--t007-scroll-assist-color) 30%, transparent);
16
+ background: linear-gradient(var(--t007-gradient-dir), transparent 0, var(--t007-scroll-assist-color) 30%, transparent);
17
17
  z-index: 2;
18
18
  }
19
19
 
20
20
  .t007-scroll-assist[data-scroll-direction="left"] {
21
- --t007-scroll-assist-gradient-dir: to right;
21
+ --t007-gradient-dir: to right;
22
22
  top: 0;
23
- left: var(--t007-scroll-assist-inline-offset);
23
+ left: var(--t007-scroll-assist-inset-x);
24
24
  }
25
25
 
26
26
  .t007-scroll-assist[data-scroll-direction="right"] {
27
- --t007-scroll-assist-gradient-dir: to left;
27
+ --t007-gradient-dir: to left;
28
28
  top: 0;
29
- right: var(--t007-scroll-assist-inline-offset);
29
+ right: var(--t007-scroll-assist-inset-x);
30
30
  }
31
31
 
32
32
  .t007-scroll-assist[data-scroll-direction="up"] {
33
- --t007-scroll-assist-gradient-dir: to bottom;
34
- top: var(--t007-scroll-assist-block-offset);
33
+ --t007-gradient-dir: to bottom;
34
+ top: var(--t007-scroll-assist-inset-y);
35
35
  height: var(--t007-scroll-assist-height);
36
36
  width: 100%;
37
37
  }
38
38
 
39
39
  .t007-scroll-assist[data-scroll-direction="down"] {
40
- --t007-scroll-assist-gradient-dir: to top;
41
- bottom: var(--t007-scroll-assist-block-offset);
40
+ --t007-gradient-dir: to top;
41
+ bottom: var(--t007-scroll-assist-inset-y);
42
42
  height: var(--t007-scroll-assist-height);
43
43
  width: 100%;
44
44
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@t007/utils",
3
- "version": "0.0.29",
4
- "description": "High-performance, zero-dependency utility functions for the t007 ecosystem.",
3
+ "version": "0.0.30",
4
+ "description": "High-performance utilities for the t007 ecosystem.",
5
5
  "author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -50,7 +50,7 @@
50
50
  "access": "public"
51
51
  },
52
52
  "scripts": {
53
- "build": "tsup --config tsup.config.ts && shx cp src/styles/ripple.css dist/styles/ripple.css && shx cp src/styles/scroll-assist.css dist/styles/scroll-assist.css",
53
+ "build": "tsup --config tsup.config.ts",
54
54
  "prepublishOnly": "shx cp ../../LICENSE ."
55
55
  },
56
56
  "files": [
@@ -70,12 +70,12 @@
70
70
  "devDependencies": {
71
71
  "@types/react": "^18.0.0",
72
72
  "@types/react-dom": "^18.0.0",
73
+ "esbuild-sass-plugin": "^3.7.0",
73
74
  "react": "^18.3.1",
74
75
  "react-dom": "^18.3.1"
75
76
  },
76
77
  "dependencies": {
77
- "@t007/input": "^0.0.27",
78
- "sia-reactor": "^0.0.32"
78
+ "sia-reactor": "^0.0.33"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "react": "^18.0.0"