elements-kit 0.0.14 → 0.0.16

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 (112) hide show
  1. package/README.md +138 -31
  2. package/dist/attributes-Dtn68R1u.d.mts +94 -0
  3. package/dist/attributes.d.mts +1 -93
  4. package/dist/custom-elements.d.mts +74 -0
  5. package/dist/custom-elements.mjs +100 -0
  6. package/dist/define-CjbTZ3VG.d.mts +23 -0
  7. package/dist/{element-C_4VbkvQ.mjs → element-CGVy_8TW.mjs} +12 -18
  8. package/dist/for.d.mts +45 -0
  9. package/dist/for.mjs +136 -0
  10. package/dist/{index-DUshSQ_6.d.mts → index-DydGTqZU.d.mts} +60 -10
  11. package/dist/index.d.mts +1 -36
  12. package/dist/index.mjs +1 -144
  13. package/dist/infer-BfzRJoCn.d.mts +203 -0
  14. package/dist/integrations/react.d.mts +1 -1
  15. package/dist/integrations/react.mjs +1 -1
  16. package/dist/jsx-runtime/index.d.mts +18 -25
  17. package/dist/jsx-runtime/index.mjs +2 -2
  18. package/dist/signals/index.d.mts +2 -2
  19. package/dist/signals/index.mjs +2 -2
  20. package/dist/{signals-BHmWX6ox.mjs → signals-J8dK_rA4.mjs} +57 -17
  21. package/dist/slot-C7GQZe-r.d.mts +104 -0
  22. package/dist/{slot-Cydy7-0L.mjs → slot-Kb61AcgW.mjs} +21 -2
  23. package/dist/slot.d.mts +2 -84
  24. package/dist/slot.mjs +2 -2
  25. package/dist/{test.BmQO5GaM-ANkhHvbr.mjs → test.BmQO5GaM-DfGStnii.mjs} +1 -1
  26. package/dist/utilities/_observe.d.mts +11 -0
  27. package/dist/utilities/_observe.mjs +15 -0
  28. package/dist/utilities/active-element.d.mts +1 -1
  29. package/dist/utilities/active-element.mjs +6 -2
  30. package/dist/utilities/active-element.test.mjs +1 -1
  31. package/dist/utilities/async.d.mts +1 -1
  32. package/dist/utilities/async.mjs +1 -1
  33. package/dist/utilities/async.test.mjs +2 -2
  34. package/dist/utilities/debounced.d.mts +1 -1
  35. package/dist/utilities/debounced.mjs +1 -1
  36. package/dist/utilities/debounced.test.mjs +2 -2
  37. package/dist/utilities/element-rect.d.mts +1 -1
  38. package/dist/utilities/element-rect.mjs +1 -1
  39. package/dist/utilities/element-rect.test.mjs +2 -2
  40. package/dist/utilities/element-scroll.d.mts +1 -1
  41. package/dist/utilities/element-scroll.mjs +7 -34
  42. package/dist/utilities/element-scroll.test.mjs +2 -2
  43. package/dist/utilities/environment.d.mts +5 -0
  44. package/dist/utilities/environment.mjs +5 -0
  45. package/dist/utilities/event-driven.d.mts +1 -1
  46. package/dist/utilities/event-driven.mjs +2 -2
  47. package/dist/utilities/event-listener.d.mts +1 -1
  48. package/dist/utilities/event-listener.mjs +1 -1
  49. package/dist/utilities/event-listener.test.mjs +2 -2
  50. package/dist/utilities/focus-within.d.mts +1 -1
  51. package/dist/utilities/focus-within.mjs +1 -1
  52. package/dist/utilities/focus-within.test.mjs +2 -2
  53. package/dist/utilities/hover.d.mts +1 -1
  54. package/dist/utilities/hover.mjs +1 -1
  55. package/dist/utilities/hover.test.mjs +2 -2
  56. package/dist/utilities/intersection-observer.mjs +4 -6
  57. package/dist/utilities/intersection-observer.test.mjs +2 -2
  58. package/dist/utilities/interval.d.mts +1 -1
  59. package/dist/utilities/interval.mjs +1 -1
  60. package/dist/utilities/interval.test.mjs +18 -2
  61. package/dist/utilities/location.d.mts +2 -14
  62. package/dist/utilities/location.mjs +12 -3
  63. package/dist/utilities/location.test.mjs +5 -5
  64. package/dist/utilities/long-press.mjs +1 -1
  65. package/dist/utilities/long-press.test.mjs +2 -2
  66. package/dist/utilities/media-devices.d.mts +1 -1
  67. package/dist/utilities/media-devices.mjs +1 -1
  68. package/dist/utilities/media-devices.test.mjs +2 -2
  69. package/dist/utilities/media-player.d.mts +1 -1
  70. package/dist/utilities/media-player.test.mjs +2 -2
  71. package/dist/utilities/media-query.d.mts +2 -3
  72. package/dist/utilities/media-query.mjs +3 -3
  73. package/dist/utilities/mutation-observer.mjs +4 -7
  74. package/dist/utilities/mutation-observer.test.mjs +2 -2
  75. package/dist/utilities/network.d.mts +2 -2
  76. package/dist/utilities/network.mjs +5 -3
  77. package/dist/utilities/network.test.mjs +1 -1
  78. package/dist/utilities/on-click-outside.test.mjs +2 -2
  79. package/dist/utilities/orientation.d.mts +1 -1
  80. package/dist/utilities/orientation.mjs +9 -1
  81. package/dist/utilities/previous.d.mts +1 -1
  82. package/dist/utilities/previous.mjs +1 -1
  83. package/dist/utilities/previous.test.mjs +2 -2
  84. package/dist/utilities/promise.d.mts +1 -1
  85. package/dist/utilities/promise.mjs +1 -1
  86. package/dist/utilities/promise.test.mjs +2 -2
  87. package/dist/utilities/resize-observer.mjs +4 -6
  88. package/dist/utilities/retry.mjs +1 -1
  89. package/dist/utilities/retry.test.mjs +2 -2
  90. package/dist/utilities/routing.d.mts +1 -1
  91. package/dist/utilities/routing.mjs +1 -1
  92. package/dist/utilities/routing.test.mjs +1 -1
  93. package/dist/utilities/search-params.d.mts +1 -1
  94. package/dist/utilities/search-params.test.mjs +2 -2
  95. package/dist/utilities/ssr.test.d.mts +1 -0
  96. package/dist/utilities/ssr.test.mjs +64 -0
  97. package/dist/utilities/storage.d.mts +1 -1
  98. package/dist/utilities/storage.test.mjs +2 -2
  99. package/dist/utilities/throttled.d.mts +1 -1
  100. package/dist/utilities/throttled.mjs +1 -1
  101. package/dist/utilities/throttled.test.mjs +2 -2
  102. package/dist/utilities/timeout.d.mts +1 -1
  103. package/dist/utilities/timeout.mjs +1 -1
  104. package/dist/utilities/timeout.test.mjs +57 -2
  105. package/dist/utilities/window-focus.d.mts +2 -2
  106. package/dist/utilities/window-focus.mjs +5 -3
  107. package/dist/utilities/window-size.d.mts +1 -1
  108. package/dist/utilities/window-size.mjs +10 -5
  109. package/dist/utilities/window-size.test.mjs +1 -1
  110. package/package.json +11 -1
  111. package/dist/lib-JA05lzCN.d.mts +0 -4
  112. /package/dist/{polyfill-DR5XVnh_.d.mts → polyfill-BVNd6ogU.d.mts} +0 -0
@@ -1,4 +1,4 @@
1
- import { r as Signal, t as Computed } from "../index-DUshSQ_6.mjs";
1
+ import { r as Signal, t as Computed } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/media-player.d.ts
4
4
  type MediaPlayerResult<T extends HTMLMediaElement> = {
@@ -1,5 +1,5 @@
1
- import { d as effectScope } from "../signals-BHmWX6ox.mjs";
2
- import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { f as effectScope } from "../signals-J8dK_rA4.mjs";
2
+ import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
3
3
  import { createMediaPlayer } from "./media-player.mjs";
4
4
  //#region src/utilities/media-player.test.ts
5
5
  afterEach(() => {
@@ -1,7 +1,6 @@
1
- import { t as Computed } from "../index-DUshSQ_6.mjs";
1
+ import { t as Computed } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/media-query.d.ts
4
- declare const isBrowser: boolean;
5
4
  /**
6
5
  * Creates a signal that tracks a CSS media query.
7
6
  *
@@ -11,4 +10,4 @@ declare const isBrowser: boolean;
11
10
  */
12
11
  declare function createMediaQuery(query: string, defaultState?: boolean): Computed<boolean>;
13
12
  //#endregion
14
- export { createMediaQuery, isBrowser };
13
+ export { createMediaQuery };
@@ -1,7 +1,7 @@
1
- import { _ as signal } from "../signals-BHmWX6ox.mjs";
1
+ import { v as signal } from "../signals-J8dK_rA4.mjs";
2
2
  import { fromEvent, sync } from "./event-driven.mjs";
3
+ import { isBrowser } from "./environment.mjs";
3
4
  //#region src/utilities/media-query.ts
4
- const isBrowser = typeof window !== "undefined";
5
5
  /**
6
6
  * Creates a signal that tracks a CSS media query.
7
7
  *
@@ -16,4 +16,4 @@ function createMediaQuery(query, defaultState) {
16
16
  return state;
17
17
  }
18
18
  //#endregion
19
- export { createMediaQuery, isBrowser };
19
+ export { createMediaQuery };
@@ -1,16 +1,13 @@
1
- import { g as onCleanup } from "../signals-BHmWX6ox.mjs";
1
+ import { observe } from "./_observe.mjs";
2
2
  //#region src/utilities/mutation-observer.ts
3
3
  /**
4
4
  * Watches `target` for DOM mutations and calls `callback` with each batch of
5
5
  * `MutationRecord`s.
6
6
  */
7
7
  function createMutationObserver(target, options, callback) {
8
- const observer = new MutationObserver((records) => callback(records));
9
- const el = target;
10
- if (el) observer.observe(el, options);
11
- const cleanup = () => observer.disconnect();
12
- onCleanup(cleanup);
13
- return { [Symbol.dispose]: cleanup };
8
+ return observe(new MutationObserver((records) => callback(records)), (o) => {
9
+ if (target) o.observe(target, options);
10
+ });
14
11
  }
15
12
  //#endregion
16
13
  export { createMutationObserver };
@@ -1,5 +1,5 @@
1
- import { d as effectScope } from "../signals-BHmWX6ox.mjs";
2
- import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { f as effectScope } from "../signals-J8dK_rA4.mjs";
2
+ import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
3
3
  import { createMutationObserver } from "./mutation-observer.mjs";
4
4
  //#region src/utilities/mutation-observer.test.ts
5
5
  afterEach(() => {
@@ -1,9 +1,9 @@
1
- import { t as Computed } from "../index-DUshSQ_6.mjs";
1
+ import { t as Computed } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/network.d.ts
4
4
  /**
5
5
  * Singleton `Computed<boolean>` — `true` when `navigator.onLine` is true.
6
- * Reacts to `online` / `offline` window events.
6
+ * Reacts to `online` / `offline` window events. Outside a browser, always `true`.
7
7
  */
8
8
  declare const online: Computed<boolean>;
9
9
  //#endregion
@@ -1,8 +1,10 @@
1
- import { _ as signal } from "../signals-BHmWX6ox.mjs";
1
+ import { v as signal } from "../signals-J8dK_rA4.mjs";
2
2
  import { on } from "./event-listener.mjs";
3
+ import { isBrowser } from "./environment.mjs";
3
4
  //#region src/utilities/network.ts
4
5
  function createOnline() {
5
- const value = signal(typeof navigator !== "undefined" ? navigator.onLine : true);
6
+ if (!isBrowser) return signal(true);
7
+ const value = signal(navigator.onLine);
6
8
  const update = () => value(navigator.onLine);
7
9
  on(window, "online", update);
8
10
  on(window, "offline", update);
@@ -10,7 +12,7 @@ function createOnline() {
10
12
  }
11
13
  /**
12
14
  * Singleton `Computed<boolean>` — `true` when `navigator.onLine` is true.
13
- * Reacts to `online` / `offline` window events.
15
+ * Reacts to `online` / `offline` window events. Outside a browser, always `true`.
14
16
  */
15
17
  const online = createOnline();
16
18
  //#endregion
@@ -1,4 +1,4 @@
1
- import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
2
2
  import { online } from "./network.mjs";
3
3
  //#region src/utilities/network.test.ts
4
4
  afterEach(() => {
@@ -1,5 +1,5 @@
1
- import { d as effectScope } from "../signals-BHmWX6ox.mjs";
2
- import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { f as effectScope } from "../signals-J8dK_rA4.mjs";
2
+ import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
3
3
  import { onClickOutside } from "./on-click-outside.mjs";
4
4
  //#region src/utilities/on-click-outside.test.ts
5
5
  afterEach(() => {
@@ -1,4 +1,4 @@
1
- import { t as Computed } from "../index-DUshSQ_6.mjs";
1
+ import { t as Computed } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/orientation.d.ts
4
4
  type OrientationResult = {
@@ -1,9 +1,17 @@
1
+ import { u as computed } from "../signals-J8dK_rA4.mjs";
1
2
  import { fromEvent, sync } from "./event-driven.mjs";
3
+ import { isBrowser } from "./environment.mjs";
2
4
  //#region src/utilities/orientation.ts
3
5
  /**
4
- * Returns reactive signals for the screen orientation.
6
+ * Returns reactive signals for the screen orientation. Outside a browser,
7
+ * returns `{ angle: 0, type: "portrait-primary" }` and a no-op disposer.
5
8
  */
6
9
  function createOrientation() {
10
+ if (!isBrowser) return {
11
+ angle: computed(() => 0),
12
+ type: computed(() => "portrait-primary"),
13
+ [Symbol.dispose]() {}
14
+ };
7
15
  const subscribe = fromEvent(screen.orientation, "change");
8
16
  const [angle, stopAngle] = sync(subscribe, () => screen.orientation?.angle ?? 0);
9
17
  const [type, stopType] = sync(subscribe, () => screen.orientation?.type ?? "portrait-primary");
@@ -1,4 +1,4 @@
1
- import { t as Computed } from "../index-DUshSQ_6.mjs";
1
+ import { t as Computed } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/previous.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { _ as signal, u as effect } from "../signals-BHmWX6ox.mjs";
1
+ import { d as effect, v as signal } from "../signals-J8dK_rA4.mjs";
2
2
  //#region src/utilities/previous.ts
3
3
  /**
4
4
  * Returns a `Computed` that always holds the *previous* value of `source`.
@@ -1,5 +1,5 @@
1
- import { _ as signal, d as effectScope } from "../signals-BHmWX6ox.mjs";
2
- import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { f as effectScope, v as signal } from "../signals-J8dK_rA4.mjs";
2
+ import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
3
3
  import { createPrevious } from "./previous.mjs";
4
4
  //#region src/utilities/previous.test.ts
5
5
  describe("createPrevious", () => {
@@ -1,4 +1,4 @@
1
- import { t as Computed } from "../index-DUshSQ_6.mjs";
1
+ import { t as Computed } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/promise.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { _ as signal, c as batch, l as computed } from "../signals-BHmWX6ox.mjs";
1
+ import { l as batch, u as computed, v as signal } from "../signals-J8dK_rA4.mjs";
2
2
  //#region src/utilities/promise.ts
3
3
  /**
4
4
  * A `Promise` subclass that exposes its state as reactive signals.
@@ -1,5 +1,5 @@
1
- import { u as effect } from "../signals-BHmWX6ox.mjs";
2
- import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { d as effect } from "../signals-J8dK_rA4.mjs";
2
+ import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
3
3
  import { ReactivePromise, promise } from "./promise.mjs";
4
4
  //#region src/utilities/promise.test.ts
5
5
  describe("ReactivePromise", () => {
@@ -1,15 +1,13 @@
1
- import { g as onCleanup } from "../signals-BHmWX6ox.mjs";
1
+ import { observe } from "./_observe.mjs";
2
2
  //#region src/utilities/resize-observer.ts
3
3
  /**
4
4
  * Raw `ResizeObserver` wrapper with automatic cleanup.
5
5
  * Use `createElementRect` for the common case.
6
6
  */
7
7
  function createResizeObserver(target, callback) {
8
- const observer = new ResizeObserver(callback);
9
- if (target) observer.observe(target);
10
- const cleanup = () => observer.disconnect();
11
- onCleanup(cleanup);
12
- return { [Symbol.dispose]: cleanup };
8
+ return observe(new ResizeObserver(callback), (o) => {
9
+ if (target) o.observe(target);
10
+ });
13
11
  }
14
12
  //#endregion
15
13
  export { createResizeObserver };
@@ -1,4 +1,4 @@
1
- import { u as effect, y as untracked } from "../signals-BHmWX6ox.mjs";
1
+ import { b as untracked, d as effect } from "../signals-J8dK_rA4.mjs";
2
2
  //#region src/utilities/retry.ts
3
3
  /**
4
4
  * Wraps `fn` to retry up to `attempts` times on failure.
@@ -1,5 +1,5 @@
1
- import { g as onCleanup } from "../signals-BHmWX6ox.mjs";
2
- import { n as vi, o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { _ as onCleanup } from "../signals-J8dK_rA4.mjs";
2
+ import { n as vi, o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
3
3
  import { retry } from "./retry.mjs";
4
4
  //#region src/utilities/retry.test.ts
5
5
  describe("retry", () => {
@@ -1,4 +1,4 @@
1
- import { t as Computed } from "../index-DUshSQ_6.mjs";
1
+ import { t as Computed } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/routing.d.ts
4
4
  declare function patchHistory(): void;
@@ -1,4 +1,4 @@
1
- import { l as computed } from "../signals-BHmWX6ox.mjs";
1
+ import { u as computed } from "../signals-J8dK_rA4.mjs";
2
2
  import { currentLocation } from "./location.mjs";
3
3
  //#region src/utilities/routing.ts
4
4
  const patchHistoryMethod = (method) => {
@@ -1,4 +1,4 @@
1
- import { i as beforeAll, n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { i as beforeAll, n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
2
2
  import { isLocalNavigationEvent, match, matches, navigate, patchHistory } from "./routing.mjs";
3
3
  //#region src/utilities/routing.test.ts
4
4
  beforeAll(() => {
@@ -1,4 +1,4 @@
1
- import { t as Computed } from "../index-DUshSQ_6.mjs";
1
+ import { t as Computed } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/search-params.d.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { d as effectScope } from "../signals-BHmWX6ox.mjs";
2
- import { o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { f as effectScope } from "../signals-J8dK_rA4.mjs";
2
+ import { o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
3
3
  import { createSearchParam } from "./search-params.mjs";
4
4
  //#region src/utilities/search-params.test.ts
5
5
  afterEach(() => {
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,64 @@
1
+ import { c as test, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
2
+ //#region src/utilities/ssr.test.ts
3
+ // @vitest-environment node
4
+ test.each([
5
+ "./active-element.ts",
6
+ "./async.ts",
7
+ "./debounced.ts",
8
+ "./element-rect.ts",
9
+ "./element-scroll.ts",
10
+ "./environment.ts",
11
+ "./event-driven.ts",
12
+ "./event-listener.ts",
13
+ "./focus-within.ts",
14
+ "./hover.ts",
15
+ "./intersection-observer.ts",
16
+ "./interval.ts",
17
+ "./location.ts",
18
+ "./long-press.ts",
19
+ "./media-devices.ts",
20
+ "./media-player.ts",
21
+ "./media-query.ts",
22
+ "./mutation-observer.ts",
23
+ "./network.ts",
24
+ "./on-click-outside.ts",
25
+ "./orientation.ts",
26
+ "./previous.ts",
27
+ "./promise.ts",
28
+ "./resize-observer.ts",
29
+ "./retry.ts",
30
+ "./routing.ts",
31
+ "./search-params.ts",
32
+ "./storage.ts",
33
+ "./throttled.ts",
34
+ "./timeout.ts",
35
+ "./window-focus.ts",
36
+ "./window-size.ts"
37
+ ])("imports %s in Node without crashing", async (path) => {
38
+ await globalExpect(import(path)).resolves.toBeDefined();
39
+ });
40
+ test("singletons return neutral values in Node", async () => {
41
+ const { windowSize } = await import("./window-size.mjs");
42
+ globalExpect(windowSize.width()).toBe(0);
43
+ globalExpect(windowSize.height()).toBe(0);
44
+ const { online } = await import("./network.mjs");
45
+ globalExpect(online()).toBe(true);
46
+ const { windowFocused } = await import("./window-focus.mjs");
47
+ globalExpect(windowFocused()).toBe(true);
48
+ const { activeElement } = await import("./active-element.mjs");
49
+ globalExpect(activeElement()).toBe(null);
50
+ const { orientation } = await import("./orientation.mjs");
51
+ globalExpect(orientation.angle()).toBe(0);
52
+ globalExpect(orientation.type()).toBe("portrait-primary");
53
+ const { currentLocation } = await import("./location.mjs");
54
+ globalExpect(currentLocation.href()).toBe("");
55
+ globalExpect(currentLocation.pathname()).toBe("");
56
+ globalExpect(currentLocation.search()).toBe("");
57
+ globalExpect(currentLocation.hash()).toBe("");
58
+ });
59
+ test("isBrowser is false in Node", async () => {
60
+ const { isBrowser } = await import("./environment.mjs");
61
+ globalExpect(isBrowser).toBe(false);
62
+ });
63
+ //#endregion
64
+ export {};
@@ -1,4 +1,4 @@
1
- import { r as Signal } from "../index-DUshSQ_6.mjs";
1
+ import { r as Signal } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/storage.d.ts
4
4
  type StorageOptions<T> = {
@@ -1,5 +1,5 @@
1
- import { d as effectScope } from "../signals-BHmWX6ox.mjs";
2
- import { o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { f as effectScope } from "../signals-J8dK_rA4.mjs";
2
+ import { o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
3
3
  import { createLocalStorage, createSessionStorage } from "./storage.mjs";
4
4
  //#region src/utilities/storage.test.ts
5
5
  describe("createLocalStorage", () => {
@@ -1,4 +1,4 @@
1
- import { t as Computed } from "../index-DUshSQ_6.mjs";
1
+ import { t as Computed } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/throttled.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { _ as signal, u as effect } from "../signals-BHmWX6ox.mjs";
1
+ import { d as effect, v as signal } from "../signals-J8dK_rA4.mjs";
2
2
  import { createTimeout } from "./timeout.mjs";
3
3
  //#region src/utilities/throttled.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { _ as signal, d as effectScope } from "../signals-BHmWX6ox.mjs";
2
- import { a as beforeEach, n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { f as effectScope, v as signal } from "../signals-J8dK_rA4.mjs";
2
+ import { a as beforeEach, n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
3
3
  import { createThrottled } from "./throttled.mjs";
4
4
  //#region src/utilities/throttled.test.ts
5
5
  beforeEach(() => {
@@ -1,4 +1,4 @@
1
- import { t as Computed } from "../index-DUshSQ_6.mjs";
1
+ import { t as Computed } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/timeout.d.ts
4
4
  type TimeoutResult = {
@@ -1,4 +1,4 @@
1
- import { _ as signal, g as onCleanup } from "../signals-BHmWX6ox.mjs";
1
+ import { _ as onCleanup, v as signal } from "../signals-J8dK_rA4.mjs";
2
2
  //#region src/utilities/timeout.ts
3
3
  /**
4
4
  * Reactive `setTimeout` wrapper with pause/resume/reset control.
@@ -1,5 +1,5 @@
1
- import { d as effectScope } from "../signals-BHmWX6ox.mjs";
2
- import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { f as effectScope } from "../signals-J8dK_rA4.mjs";
2
+ import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
3
3
  import { createTimeout } from "./timeout.mjs";
4
4
  //#region src/utilities/timeout.test.ts
5
5
  afterEach(() => {
@@ -59,6 +59,61 @@ describe("createTimeout", () => {
59
59
  vi.advanceTimersByTime(300);
60
60
  globalExpect(cb).toHaveBeenCalledOnce();
61
61
  });
62
+ it("immediate=false does not start automatically", () => {
63
+ vi.useFakeTimers();
64
+ const cb = vi.fn();
65
+ let t;
66
+ effectScope(() => {
67
+ t = createTimeout(cb, 200, false);
68
+ });
69
+ globalExpect(t.pending()).toBe(false);
70
+ vi.advanceTimersByTime(300);
71
+ globalExpect(cb).not.toHaveBeenCalled();
72
+ });
73
+ it("start() fires after delay when called manually", () => {
74
+ vi.useFakeTimers();
75
+ const cb = vi.fn();
76
+ let t;
77
+ effectScope(() => {
78
+ t = createTimeout(cb, 200, false);
79
+ });
80
+ t.start();
81
+ globalExpect(t.pending()).toBe(true);
82
+ vi.advanceTimersByTime(200);
83
+ globalExpect(cb).toHaveBeenCalledOnce();
84
+ globalExpect(t.pending()).toBe(false);
85
+ });
86
+ it("Symbol.dispose cancels the timeout", () => {
87
+ vi.useFakeTimers();
88
+ const cb = vi.fn();
89
+ let t;
90
+ effectScope(() => {
91
+ t = createTimeout(cb, 500);
92
+ });
93
+ t[Symbol.dispose]();
94
+ vi.advanceTimersByTime(1e3);
95
+ globalExpect(cb).not.toHaveBeenCalled();
96
+ });
97
+ it("stops when scope is disposed", () => {
98
+ vi.useFakeTimers();
99
+ const cb = vi.fn();
100
+ effectScope(() => {
101
+ createTimeout(cb, 200);
102
+ })();
103
+ vi.advanceTimersByTime(500);
104
+ globalExpect(cb).not.toHaveBeenCalled();
105
+ });
106
+ it("dynamic delay function is called at start", () => {
107
+ vi.useFakeTimers();
108
+ const cb = vi.fn();
109
+ const getDelay = vi.fn().mockReturnValue(300);
110
+ effectScope(() => {
111
+ createTimeout(cb, getDelay);
112
+ });
113
+ vi.advanceTimersByTime(300);
114
+ globalExpect(cb).toHaveBeenCalledOnce();
115
+ globalExpect(getDelay).toHaveBeenCalledOnce();
116
+ });
62
117
  });
63
118
  //#endregion
64
119
  export {};
@@ -1,9 +1,9 @@
1
- import { t as Computed } from "../index-DUshSQ_6.mjs";
1
+ import { t as Computed } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/window-focus.d.ts
4
4
  /**
5
5
  * Singleton `Computed<boolean>` — `true` while the browser window has focus.
6
- * Reacts to `focus` / `blur` window events.
6
+ * Reacts to `focus` / `blur` window events. Outside a browser, always `true`.
7
7
  */
8
8
  declare const windowFocused: Computed<boolean>;
9
9
  //#endregion
@@ -1,15 +1,17 @@
1
- import { _ as signal } from "../signals-BHmWX6ox.mjs";
1
+ import { v as signal } from "../signals-J8dK_rA4.mjs";
2
2
  import { on } from "./event-listener.mjs";
3
+ import { isBrowser } from "./environment.mjs";
3
4
  //#region src/utilities/window-focus.ts
4
5
  function createWindowFocused() {
5
- const value = signal(typeof document !== "undefined" ? document.hasFocus() : true);
6
+ if (!isBrowser) return signal(true);
7
+ const value = signal(document.hasFocus());
6
8
  on(window, "focus", () => value(true));
7
9
  on(window, "blur", () => value(false));
8
10
  return value;
9
11
  }
10
12
  /**
11
13
  * Singleton `Computed<boolean>` — `true` while the browser window has focus.
12
- * Reacts to `focus` / `blur` window events.
14
+ * Reacts to `focus` / `blur` window events. Outside a browser, always `true`.
13
15
  */
14
16
  const windowFocused = createWindowFocused();
15
17
  //#endregion
@@ -1,4 +1,4 @@
1
- import { t as Computed } from "../index-DUshSQ_6.mjs";
1
+ import { t as Computed } from "../index-DydGTqZU.mjs";
2
2
 
3
3
  //#region src/utilities/window-size.d.ts
4
4
  type WindowSizeResult = {
@@ -1,15 +1,20 @@
1
- import { l as computed } from "../signals-BHmWX6ox.mjs";
1
+ import { u as computed } from "../signals-J8dK_rA4.mjs";
2
2
  import { fromEvent, sync } from "./event-driven.mjs";
3
+ import { isBrowser } from "./environment.mjs";
3
4
  //#region src/utilities/window-size.ts
4
5
  /**
5
6
  * Returns reactive `width` and `height` signals tracking the browser window
6
- * inner dimensions.
7
+ * inner dimensions. Outside a browser, returns zeros and a no-op disposer.
7
8
  */
8
9
  function createWindowSize() {
9
- const isBrowser = typeof window !== "undefined";
10
+ if (!isBrowser) return {
11
+ width: computed(() => 0),
12
+ height: computed(() => 0),
13
+ [Symbol.dispose]() {}
14
+ };
10
15
  const [size, stop] = sync(fromEvent(window, "resize"), () => ({
11
- w: isBrowser ? window.innerWidth : 0,
12
- h: isBrowser ? window.innerHeight : 0
16
+ w: window.innerWidth,
17
+ h: window.innerHeight
13
18
  }));
14
19
  return {
15
20
  width: computed(() => size().w),
@@ -1,4 +1,4 @@
1
- import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
1
+ import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
2
2
  import { windowSize } from "./window-size.mjs";
3
3
  //#region src/utilities/window-size.test.ts
4
4
  describe("windowSize (singleton)", () => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elements-kit",
3
3
  "type": "module",
4
- "version": "0.0.14",
4
+ "version": "0.0.16",
5
5
  "description": "A lightweight reactive UI library that transforms native HTMLElements into reactive components with signals. Ideal for framework-agnostic applications and web components.",
6
6
  "keywords": [
7
7
  "webcomponents",
@@ -38,11 +38,21 @@
38
38
  "import": "./dist/slot.mjs",
39
39
  "types": "./dist/slot.d.ts"
40
40
  },
41
+ "./for": {
42
+ "source": "./src/for.ts",
43
+ "import": "./dist/for.mjs",
44
+ "types": "./dist/for.d.ts"
45
+ },
41
46
  "./attributes": {
42
47
  "source": "./src/attributes.ts",
43
48
  "import": "./dist/attributes.mjs",
44
49
  "types": "./dist/attributes.d.ts"
45
50
  },
51
+ "./custom-elements": {
52
+ "source": "./src/custom-elements.ts",
53
+ "import": "./dist/custom-elements.mjs",
54
+ "types": "./dist/custom-elements.d.ts"
55
+ },
46
56
  "./jsx-runtime": {
47
57
  "source": "./src/jsx-runtime/index.ts",
48
58
  "import": "./dist/jsx-runtime/index.mjs",
@@ -1,4 +0,0 @@
1
- //#region src/lib.d.ts
2
- type PrimitiveNodeType = Node | string | boolean | number | bigint | symbol | Date | RegExp | null | undefined;
3
- //#endregion
4
- export { PrimitiveNodeType as t };