elements-kit 0.0.15 → 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-ChF24-2z.mjs → element-CGVy_8TW.mjs} +11 -12
  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 +11 -20
  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 +2 -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 +2 -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 { 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(() => {
@@ -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.15",
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 };