@vizejs/composable 0.809.0 → 0.811.0

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 (173) hide show
  1. package/dist/abort-signal.mjs +0 -62
  2. package/dist/active-element.mjs +0 -11
  3. package/dist/animate.mjs +0 -19
  4. package/dist/async-resource.mjs +0 -17
  5. package/dist/battery.mjs +0 -13
  6. package/dist/breakpoints.mjs +0 -24
  7. package/dist/capability.mjs +0 -12
  8. package/dist/{catalog-BRX-Wg8B.mjs → catalog-CcpCnLjb.mjs} +0 -14
  9. package/dist/catalog.mjs +1 -1
  10. package/dist/color-mode.mjs +0 -23
  11. package/dist/computed-with-control.mjs +0 -22
  12. package/dist/create-event-hook.mjs +0 -27
  13. package/dist/create-global-state.mjs +0 -23
  14. package/dist/create-shared-composable.mjs +0 -23
  15. package/dist/device-motion.mjs +0 -11
  16. package/dist/device-orientation.mjs +0 -23
  17. package/dist/device-pixel-ratio.mjs +0 -11
  18. package/dist/disposal-scope.mjs +0 -25
  19. package/dist/document-visibility.mjs +0 -14
  20. package/dist/draggable.mjs +0 -14
  21. package/dist/element-bounding.mjs +0 -14
  22. package/dist/element-by-point.mjs +0 -10
  23. package/dist/element-hover.mjs +0 -13
  24. package/dist/element-target.mjs +0 -30
  25. package/dist/focus.mjs +0 -23
  26. package/dist/fps.mjs +0 -12
  27. package/dist/geolocation.mjs +0 -14
  28. package/dist/i18n.mjs +0 -86
  29. package/dist/icu-message.mjs +0 -58
  30. package/dist/idle.mjs +0 -16
  31. package/dist/index.d.mts +2 -2
  32. package/dist/index.mjs +2 -2
  33. package/dist/infinite-scroll.mjs +0 -16
  34. package/dist/intersection-observer.mjs +0 -27
  35. package/dist/locale.mjs +0 -20
  36. package/dist/magic-keys.mjs +0 -35
  37. package/dist/math.mjs +0 -37
  38. package/dist/media-query.mjs +0 -29
  39. package/dist/mouse-in-element.mjs +0 -12
  40. package/dist/mouse.mjs +0 -12
  41. package/dist/mutation-observer.mjs +0 -15
  42. package/dist/network.mjs +0 -24
  43. package/dist/on-click-outside.mjs +0 -16
  44. package/dist/on-key-stroke.mjs +0 -33
  45. package/dist/on-long-press.mjs +0 -14
  46. package/dist/on-start-typing.mjs +0 -23
  47. package/dist/page-leave.mjs +0 -11
  48. package/dist/parent-element.mjs +0 -9
  49. package/dist/pinch.mjs +0 -14
  50. package/dist/pointer-lock.mjs +0 -23
  51. package/dist/pointer.mjs +0 -18
  52. package/dist/preferences.mjs +0 -31
  53. package/dist/preferred-languages.mjs +0 -13
  54. package/dist/ref-auto-reset.mjs +0 -24
  55. package/dist/ref-debounced.mjs +0 -22
  56. package/dist/ref-default.mjs +0 -21
  57. package/dist/resize-observer.mjs +0 -31
  58. package/dist/resolver.mjs +1 -58
  59. package/dist/retry-async.mjs +0 -25
  60. package/dist/retry-delay.mjs +0 -23
  61. package/dist/scope.mjs +0 -14
  62. package/dist/screen-orientation.mjs +0 -15
  63. package/dist/scroll-lock.mjs +0 -14
  64. package/dist/scroll.mjs +0 -27
  65. package/dist/standard-schema.mjs +0 -31
  66. package/dist/swipe.mjs +0 -36
  67. package/dist/temporal.mjs +0 -30
  68. package/dist/text-selection.mjs +0 -15
  69. package/dist/textarea-autosize.mjs +0 -13
  70. package/dist/to-reactive.mjs +0 -20
  71. package/dist/transition.mjs +0 -7
  72. package/dist/until.mjs +0 -25
  73. package/dist/use-array.mjs +0 -52
  74. package/dist/use-barcode-detector.mjs +0 -25
  75. package/dist/use-bluetooth.mjs +0 -27
  76. package/dist/use-broadcast-channel.mjs +0 -30
  77. package/dist/use-builtin-ai.mjs +0 -68
  78. package/dist/use-clipboard.mjs +0 -27
  79. package/dist/use-compression-stream.mjs +0 -78
  80. package/dist/use-contact-picker.mjs +0 -22
  81. package/dist/use-cookie.mjs +0 -63
  82. package/dist/use-countdown.mjs +0 -22
  83. package/dist/use-counter.mjs +0 -29
  84. package/dist/use-css-var.mjs +0 -28
  85. package/dist/use-date-format.mjs +0 -48
  86. package/dist/use-date-time-format.mjs +0 -22
  87. package/dist/use-debounced.mjs +0 -39
  88. package/dist/use-display-media.mjs +0 -22
  89. package/dist/use-display-names.mjs +0 -19
  90. package/dist/use-document-title.mjs +0 -25
  91. package/dist/use-drop-zone.mjs +0 -36
  92. package/dist/use-event-source.mjs +0 -25
  93. package/dist/use-eye-dropper.mjs +0 -19
  94. package/dist/use-favicon.mjs +0 -23
  95. package/dist/use-fetch.mjs +0 -27
  96. package/dist/use-field.mjs +0 -27
  97. package/dist/use-file-dialog.mjs +0 -21
  98. package/dist/{use-form-C2JXZ0i7.mjs → use-form-BZqwMs6k.mjs} +143 -70
  99. package/dist/use-form-field-props.mjs +0 -57
  100. package/dist/use-form.d.mts +123 -18
  101. package/dist/use-form.mjs +1 -1
  102. package/dist/use-fullscreen.mjs +0 -23
  103. package/dist/use-gamepad.mjs +0 -50
  104. package/dist/use-hid.mjs +0 -25
  105. package/dist/use-history.mjs +0 -43
  106. package/dist/use-id-generator.mjs +0 -21
  107. package/dist/use-image.mjs +0 -22
  108. package/dist/use-indexed-db.mjs +0 -39
  109. package/dist/use-interval.mjs +0 -28
  110. package/dist/use-list-format.mjs +0 -18
  111. package/dist/use-machine.mjs +0 -34
  112. package/dist/use-map.mjs +0 -28
  113. package/dist/use-media-controls.mjs +0 -28
  114. package/dist/use-mounted.mjs +0 -18
  115. package/dist/use-navigation-api.mjs +0 -27
  116. package/dist/use-notification.mjs +0 -24
  117. package/dist/use-number-format.mjs +0 -23
  118. package/dist/use-object-url.mjs +0 -22
  119. package/dist/use-offset-pagination.mjs +0 -18
  120. package/dist/use-payment-request.mjs +0 -25
  121. package/dist/use-performance-observer.mjs +0 -27
  122. package/dist/use-permission.mjs +0 -26
  123. package/dist/use-plural-rules.mjs +0 -21
  124. package/dist/use-push-subscription.mjs +0 -28
  125. package/dist/use-queue.mjs +0 -29
  126. package/dist/use-raf-fn.mjs +0 -23
  127. package/dist/use-relative-time-format.mjs +0 -35
  128. package/dist/use-request-idle-callback.mjs +0 -42
  129. package/dist/use-route-query.mjs +0 -17
  130. package/dist/use-scheduler-post-task.mjs +0 -27
  131. package/dist/use-screen-details.mjs +0 -42
  132. package/dist/use-script-tag.mjs +0 -28
  133. package/dist/use-segmenter.mjs +0 -20
  134. package/dist/use-serial.mjs +0 -24
  135. package/dist/use-service-worker.mjs +0 -27
  136. package/dist/use-set.mjs +0 -23
  137. package/dist/use-share.mjs +0 -23
  138. package/dist/use-sorted-locale.mjs +0 -20
  139. package/dist/use-speech-recognition.mjs +0 -24
  140. package/dist/use-speech-synthesis.mjs +0 -26
  141. package/dist/use-stack.mjs +0 -27
  142. package/dist/use-storage-estimate.mjs +0 -41
  143. package/dist/use-storage.mjs +0 -68
  144. package/dist/use-style-tag.mjs +0 -22
  145. package/dist/use-supported.mjs +0 -17
  146. package/dist/use-throttled.mjs +0 -46
  147. package/dist/use-time-ago.mjs +0 -22
  148. package/dist/use-toggle.mjs +0 -19
  149. package/dist/use-url-hash.mjs +0 -28
  150. package/dist/use-url-search-params.mjs +0 -99
  151. package/dist/use-usb.mjs +0 -23
  152. package/dist/use-user-activation.mjs +0 -22
  153. package/dist/use-user-media.mjs +0 -50
  154. package/dist/use-vibrate.mjs +0 -21
  155. package/dist/use-view-transition.mjs +0 -22
  156. package/dist/use-visual-viewport.mjs +0 -25
  157. package/dist/use-wake-lock.mjs +0 -21
  158. package/dist/use-web-authn.mjs +0 -61
  159. package/dist/use-web-locks.mjs +0 -25
  160. package/dist/use-web-midi.mjs +0 -22
  161. package/dist/use-web-vitals.mjs +0 -41
  162. package/dist/use-websocket.mjs +0 -27
  163. package/dist/use-worker-fn.mjs +0 -37
  164. package/dist/virtual-list.mjs +0 -14
  165. package/dist/whenever.mjs +0 -21
  166. package/dist/window-size.mjs +0 -12
  167. package/package.json +2 -2
  168. package/registry/files/form-control-types.ts +260 -0
  169. package/registry/files/form-dirty.ts +131 -0
  170. package/registry/files/form-options.ts +156 -0
  171. package/registry/files/form-path-types.ts +135 -0
  172. package/registry/files/use-form.ts +102 -449
  173. package/registry/registry.json +28 -4
@@ -1,7 +1,6 @@
1
1
  import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { computed, reactive, readonly, ref, toValue, watch } from "vue";
3
3
  //#region src/magic-keys.ts
4
- /** Default aliases resolved before matching combos. */
5
4
  const DEFAULT_KEY_ALIASES = {
6
5
  ctrl: "control",
7
6
  command: "meta",
@@ -21,32 +20,10 @@ const modifierNames = new Set([
21
20
  "alt",
22
21
  "meta"
23
22
  ]);
24
- /**
25
- * Normalize a key name the way combos are matched.
26
- *
27
- * @param name Raw `KeyboardEvent.key`/`code` or combo segment.
28
- * @param aliases Alias table (keys lowercased).
29
- * @default aliases DEFAULT_KEY_ALIASES
30
- * @returns Lowercase, alias-resolved name.
31
- */
32
23
  function normalizeKeyName(name, aliases = DEFAULT_KEY_ALIASES) {
33
24
  const lower = name.toLowerCase();
34
25
  return (aliases[lower] ?? lower).toLowerCase();
35
26
  }
36
- /**
37
- * Track pressed keys and expose reactive key combos.
38
- *
39
- * Both `event.key` and `event.code` are recorded (lowercased), so `"a"` and
40
- * `"keya"` both match. Because some platforms (notably macOS with `meta`)
41
- * swallow `keyup` for other keys while a modifier is held, releasing a
42
- * modifier clears every non-modifier key; losing window focus clears
43
- * everything. Nothing is pressed during server rendering, and listeners are
44
- * removed with the owning reactive scope.
45
- *
46
- * @param options Target, passivity, aliases, and event hook.
47
- * @default options {}
48
- * @returns Pressed set, lazily created combo refs, and controls.
49
- */
50
27
  function useMagicKeys(options = {}) {
51
28
  const aliases = { ...DEFAULT_KEY_ALIASES };
52
29
  for (const [alias, key] of Object.entries(options.aliasMap ?? {})) aliases[alias.toLowerCase()] = key.toLowerCase();
@@ -105,18 +82,6 @@ function useMagicKeys(options = {}) {
105
82
  reset
106
83
  };
107
84
  }
108
- /**
109
- * Track whether any key matching a filter is held down.
110
- *
111
- * String filters are normalized like combos (`"esc"` matches `Escape`) and
112
- * compared against both `event.key` and `event.code`. The state resets on
113
- * window blur and during server rendering is always `false`.
114
- *
115
- * @param filter Key name(s) or predicate.
116
- * @param options Target and passivity.
117
- * @default options {}
118
- * @returns Readonly ref that is `true` while a matching key is held.
119
- */
120
85
  function useKeyPressed(filter, options = {}) {
121
86
  const held = /* @__PURE__ */ new Set();
122
87
  const pressed = ref(false);
package/dist/math.mjs CHANGED
@@ -19,29 +19,10 @@ function useClamp(value, min, max) {
19
19
  }
20
20
  });
21
21
  }
22
- /** Multiply by `10 ** places` exactly, by editing the decimal exponent. */
23
22
  function shiftExponent(value, places) {
24
23
  const [mantissa, exponent = "0"] = String(value).split("e");
25
24
  return Number(`${mantissa}e${Number(exponent) + places}`);
26
25
  }
27
- /**
28
- * Reactive rounding with decimal precision.
29
- *
30
- * Uses exponent shifting instead of multiplying by powers of ten, so values
31
- * such as `1.005` round to `1.01` at two decimals. Pure derived state.
32
- *
33
- * @example
34
- * ```ts
35
- * const price = useRound(rawPrice, { precision: 2 });
36
- * ```
37
- *
38
- * @param value Reactive number.
39
- * @param options Precision and method.
40
- * @default options {}
41
- * @throws `RangeError` tagged `VIZE_COMPOSE_MATH_INVALID_PRECISION` on read
42
- * when the precision is not an integer.
43
- * @returns Computed rounded number.
44
- */
45
26
  function useRound(value, options = {}) {
46
27
  return computed(() => {
47
28
  const precision = toValue(options.precision ?? 0);
@@ -52,24 +33,6 @@ function useRound(value, options = {}) {
52
33
  return shiftExponent(round(shiftExponent(number, precision)), -precision);
53
34
  });
54
35
  }
55
- /**
56
- * Linearly map a value from one domain to another.
57
- *
58
- * Domains are reactive tuples and may be reversed (`[100, 0]`). A degenerate
59
- * source domain maps everything to the target start. Pure derived state.
60
- *
61
- * @example
62
- * ```ts
63
- * const percent = useProjection(scrollY, () => [0, maxScroll.value], [0, 100], { clamp: true });
64
- * ```
65
- *
66
- * @param value Reactive number in the source domain.
67
- * @param from Reactive source domain.
68
- * @param to Reactive target domain.
69
- * @param options Clamping.
70
- * @default options {}
71
- * @returns Computed projected number.
72
- */
73
36
  function useProjection(value, from, to, options = {}) {
74
37
  return computed(() => {
75
38
  const [fromStart, fromEnd] = toValue(from);
@@ -1,23 +1,5 @@
1
1
  import { computed, hasInjectionContext, readonly, ref, toValue, watchEffect } from "vue";
2
2
  //#region src/media-query.ts
3
- /**
4
- * Evaluate a reactive media query without requiring browser globals.
5
- *
6
- * During server rendering (or whenever no capability host resolves) the ref
7
- * holds the configured server value and no subscription is created. Inside a
8
- * component the first match is read after mounting, so hydration renders the
9
- * server value first and never mismatches. The
10
- * change subscription follows the reactive query and host: each
11
- * re-evaluation removes the previous listener, and the final listener is
12
- * removed when the owning reactive scope stops. Call inside an active scope
13
- * so the subscription is released. A host whose matcher throws propagates
14
- * the error to the active effect run; the browser default never throws.
15
- *
16
- * @param query Reactive media-query source.
17
- * @param options Runtime capability and server-rendered fallback.
18
- * @default options {}
19
- * @returns Readonly ref that is `true` while the query matches.
20
- */
21
3
  function useMediaQuery(query, options = {}) {
22
4
  const matches = ref(options.ssrValue ?? false);
23
5
  watchEffect((onCleanup) => {
@@ -36,17 +18,6 @@ function useMediaQuery(query, options = {}) {
36
18
  }, { flush: hasInjectionContext() ? "post" : "pre" });
37
19
  return readonly(matches);
38
20
  }
39
- /**
40
- * Return the reactive user motion preference.
41
- *
42
- * Shares {@link useMediaQuery} semantics: during server rendering the
43
- * preference is `"no-preference"` unless `ssrValue` is `true`, and the
44
- * underlying subscription is removed when the owning reactive scope stops.
45
- *
46
- * @param options Runtime capability and server-rendered fallback.
47
- * @default options {}
48
- * @returns Computed preference for `(prefers-reduced-motion: reduce)`.
49
- */
50
21
  function useReducedMotion(options = {}) {
51
22
  const reduced = useMediaQuery("(prefers-reduced-motion: reduce)", options);
52
23
  return computed(() => reduced.value ? "reduce" : "no-preference");
@@ -3,18 +3,6 @@ import { resolveElement } from "./element-target.mjs";
3
3
  import { useMouse } from "./mouse.mjs";
4
4
  import { computed, readonly, ref, watch } from "vue";
5
5
  //#region src/mouse-in-element.ts
6
- /**
7
- * Track the pointer position relative to an element.
8
- *
9
- * Built on {@link useMouse} in client coordinates: every move re-reads the
10
- * element rectangle, so transforms and scrolling are reflected. Server
11
- * renders report zero geometry and `isOutside: true`.
12
- *
13
- * @param target Reactive element target.
14
- * @param options Outside handling plus {@link useMouse} options.
15
- * @default options {}
16
- * @returns Pointer, element-relative, and geometry refs.
17
- */
18
6
  function useMouseInElement(target, options = {}) {
19
7
  const handleOutside = options.handleOutside ?? true;
20
8
  const mouse = useMouse({
package/dist/mouse.mjs CHANGED
@@ -1,18 +1,6 @@
1
1
  import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { readonly, ref, toValue, watch } from "vue";
3
3
  //#region src/mouse.ts
4
- /**
5
- * Track the mouse (and optionally touch) position.
6
- *
7
- * Listens passively for `mousemove`, `dragover`, and touch events on the
8
- * target; listeners follow the reactive target and are removed with the
9
- * owning reactive scope. Server renders expose `initialValue` with a `null`
10
- * source type.
11
- *
12
- * @param options Coordinate space, target, touch handling, and initial value.
13
- * @default options {}
14
- * @returns Reactive coordinates and input source.
15
- */
16
4
  function useMouse(options = {}) {
17
5
  const { touch = true, resetOnTouchEnds = false } = options;
18
6
  const initial = options.initialValue ?? {
@@ -2,21 +2,6 @@ import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { resolveElements } from "./element-target.mjs";
3
3
  import { hasInjectionContext, onMounted, readonly, ref, shallowRef, toValue, watch } from "vue";
4
4
  //#region src/mutation-observer.ts
5
- /**
6
- * Observe DOM mutations of reactive elements.
7
- *
8
- * The observer is recreated when the resolved targets or host change and is
9
- * disconnected when the owning reactive scope stops. At least one of
10
- * `attributes`, `childList`, or `characterData` must be enabled (directly or
11
- * implicitly), mirroring the platform contract. No work happens during
12
- * server rendering.
13
- *
14
- * @param targets Reactive element target or list of targets.
15
- * @param callback Native `MutationObserver` callback.
16
- * @param options Observation filter, capability, and timing.
17
- * @default options {}
18
- * @returns Support flag, record draining, and stop control.
19
- */
20
5
  function useMutationObserver(targets, callback, options = {}) {
21
6
  const isSupported = ref(false);
22
7
  const mounted = shallowRef(!hasInjectionContext());
package/dist/network.mjs CHANGED
@@ -1,20 +1,6 @@
1
1
  import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { hasInjectionContext, readonly, ref, shallowRef, toValue, watch, watchPostEffect } from "vue";
3
3
  //#region src/network.ts
4
- /**
5
- * Track connectivity and connection quality.
6
- *
7
- * Listens for `online`/`offline` on the window and `change` on
8
- * `navigator.connection` where available. Unknown or future enum values
9
- * normalize to `null` so the public unions stay closed. Server renders
10
- * report `ssrOnline` with every quality metric `null`. Inside a component
11
- * the connection is read after mounting, so hydration renders the server
12
- * values first. Listeners are removed with the owning reactive scope.
13
- *
14
- * @param options Server fallback and window capability.
15
- * @default options {}
16
- * @returns Reactive connectivity and connection metrics.
17
- */
18
4
  function useNetwork(options = {}) {
19
5
  const ssrOnline = options.ssrOnline ?? true;
20
6
  const isSupported = ref(false);
@@ -81,16 +67,6 @@ function useNetwork(options = {}) {
81
67
  type: readonly(type)
82
68
  };
83
69
  }
84
- /**
85
- * Track whether the browser reports being online.
86
- *
87
- * Shorthand for `useNetwork(options).isOnline` with the same SSR fallback
88
- * and cleanup semantics.
89
- *
90
- * @param options Server fallback and window capability.
91
- * @default options {}
92
- * @returns Readonly online flag.
93
- */
94
70
  function useOnline(options = {}) {
95
71
  return useNetwork(options).isOnline;
96
72
  }
@@ -8,22 +8,6 @@ const defaultScheduler = {
8
8
  globalThis.clearTimeout(handle);
9
9
  }
10
10
  };
11
- /**
12
- * Call a handler when the user clicks (or focuses an iframe) outside an element.
13
- *
14
- * A click counts as outside only when its `pointerdown` also started outside
15
- * the target, so drags that begin inside (e.g. text selection) and end
16
- * outside are ignored. Event paths (`composedPath()`) make shadow-DOM targets
17
- * work. The host is resolved once, when called. Nothing is registered
18
- * during server rendering; listeners are removed with the owning scope or by
19
- * the returned stop function.
20
- *
21
- * @param target Reactive element target.
22
- * @param handler Called with the outside `PointerEvent`/`MouseEvent` or `FocusEvent`.
23
- * @param options Ignore list, phase, iframe detection, and capabilities.
24
- * @default options {}
25
- * @returns Stop function.
26
- */
27
11
  function onClickOutside(target, handler, options = {}) {
28
12
  const host = options.host === void 0 ? browserClickHost() : toValue(options.host);
29
13
  if (!host) return () => void 0;
@@ -2,21 +2,6 @@ import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { normalizeKeyName } from "./magic-keys.mjs";
3
3
  import { toValue, watch } from "vue";
4
4
  //#region src/on-key-stroke.ts
5
- /**
6
- * Run a handler when matching keys are pressed.
7
- *
8
- * `key` accepts a name, a list of names (normalized like combos, so `"esc"`
9
- * matches `Escape` and `"a"` matches `KeyA`), a predicate, or `true` for every
10
- * key. The listener follows the reactive target and is removed with the
11
- * owning scope or the returned stop function; nothing is registered during
12
- * server rendering.
13
- *
14
- * @param key Key filter, or `true` for any key.
15
- * @param handler Called with the matching `KeyboardEvent`.
16
- * @param options Event name, target, passivity, and dedupe.
17
- * @default options {}
18
- * @returns Stop function.
19
- */
20
5
  function onKeyStroke(key, handler, options = {}) {
21
6
  const eventName = options.eventName ?? "keydown";
22
7
  const names = key === true || typeof key === "function" ? void 0 : new Set((typeof key === "string" ? [key] : key).map((name) => normalizeKeyName(name)));
@@ -39,30 +24,12 @@ function onKeyStroke(key, handler, options = {}) {
39
24
  tryOnScopeDispose(dispose);
40
25
  return dispose;
41
26
  }
42
- /**
43
- * {@link onKeyStroke} for `keydown`.
44
- *
45
- * @param key Key filter, or `true` for any key.
46
- * @param handler Called with the matching `KeyboardEvent`.
47
- * @param options Target, passivity, and dedupe.
48
- * @default options {}
49
- * @returns Stop function.
50
- */
51
27
  function onKeyDown(key, handler, options = {}) {
52
28
  return onKeyStroke(key, handler, {
53
29
  ...options,
54
30
  eventName: "keydown"
55
31
  });
56
32
  }
57
- /**
58
- * {@link onKeyStroke} for `keyup`.
59
- *
60
- * @param key Key filter, or `true` for any key.
61
- * @param handler Called with the matching `KeyboardEvent`.
62
- * @param options Target, passivity, and dedupe.
63
- * @default options {}
64
- * @returns Stop function.
65
- */
66
33
  function onKeyUp(key, handler, options = {}) {
67
34
  return onKeyStroke(key, handler, {
68
35
  ...options,
@@ -8,20 +8,6 @@ const defaultScheduler = {
8
8
  globalThis.clearTimeout(handle);
9
9
  }
10
10
  };
11
- /**
12
- * Call a handler when an element is pressed and held.
13
- *
14
- * Uses Pointer Events, so mouse, touch, and pen behave alike. Moving more than
15
- * `distanceThreshold` or releasing early cancels the press. Nothing is
16
- * registered during server rendering; listeners and the timer are released
17
- * with the owning scope or the returned stop function.
18
- *
19
- * @param target Reactive element target.
20
- * @param handler Called with the initiating `pointerdown` event.
21
- * @param options Delay, threshold, modifiers, and callbacks.
22
- * @default options {}
23
- * @returns Stop function.
24
- */
25
11
  function onLongPress(target, handler, options = {}) {
26
12
  const { delay = 500, distanceThreshold = 10, modifiers = {}, now = Date.now, scheduler = defaultScheduler } = options;
27
13
  let handle;
@@ -1,33 +1,10 @@
1
1
  import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { toValue, watch } from "vue";
3
3
  //#region src/on-start-typing.ts
4
- /**
5
- * Whether a keyboard event would type a printable character.
6
- *
7
- * Single-character keys (letters, digits, punctuation; not space) without
8
- * `ctrl`/`meta`/`alt` qualify.
9
- *
10
- * @param event Keyboard event.
11
- * @returns Whether the event starts typing.
12
- */
13
4
  function isTypingKeystroke(event) {
14
5
  if (event.ctrlKey || event.metaKey || event.altKey) return false;
15
6
  return event.key.length === 1 && event.key !== " ";
16
7
  }
17
- /**
18
- * Call a handler when the user starts typing while no editable element has
19
- * focus — typically to focus a search field.
20
- *
21
- * Editable means `input`, `textarea`, `select`, or any element with
22
- * `isContentEditable`, and elements with `role="textbox"`/`"searchbox"`/`"combobox"`.
23
- * Nothing is registered during server rendering; the listener is removed with
24
- * the owning scope or the returned stop function.
25
- *
26
- * @param handler Called with the initiating `keydown` event.
27
- * @param options Document capability.
28
- * @default options {}
29
- * @returns Stop function.
30
- */
31
8
  function onStartTyping(handler, options = {}) {
32
9
  const stop = watch(() => options.host === void 0 ? browserTypingHost() : toValue(options.host), (host, _previous, onCleanup) => {
33
10
  if (!host) return;
@@ -1,17 +1,6 @@
1
1
  import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { readonly, ref, toValue, watch } from "vue";
3
3
  //#region src/page-leave.ts
4
- /**
5
- * Detect when the mouse leaves the page (for exit-intent UI).
6
- *
7
- * A `mouseout` without a `relatedTarget` means the pointer left the
8
- * document; any `mouseover` means it came back. Server renders report
9
- * `false`; listeners are removed with the owning reactive scope.
10
- *
11
- * @param options Window capability.
12
- * @default options {}
13
- * @returns Readonly ref that is `true` while the pointer is outside the page.
14
- */
15
4
  function usePageLeave(options = {}) {
16
5
  const left = ref(false);
17
6
  const onOut = (event) => {
@@ -2,15 +2,6 @@ import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { isElementNode, resolveElement } from "./element-target.mjs";
3
3
  import { shallowRef, watch } from "vue";
4
4
  //#region src/parent-element.ts
5
- /**
6
- * Track the parent element of a reactive element target.
7
- *
8
- * Re-reads `parentElement` whenever the target resolves or changes (after
9
- * the DOM update). Server renders expose `null`.
10
- *
11
- * @param target Reactive element target.
12
- * @returns Readonly shallow ref of the parent element.
13
- */
14
5
  function useParentElement(target) {
15
6
  const parent = shallowRef(null);
16
7
  const stop = watch(() => resolveElement(target), (element) => {
package/dist/pinch.mjs CHANGED
@@ -2,20 +2,6 @@ import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { resolveElement } from "./element-target.mjs";
3
3
  import { readonly, ref, shallowReactive, shallowReadonly, watch } from "vue";
4
4
  //#region src/pinch.ts
5
- /**
6
- * Recognize two-pointer pinch/rotate gestures on an element.
7
- *
8
- * Tracks active pointers with Pointer Events (touch, pen, or mouse chords).
9
- * The first two pointers define the gesture; additional pointers are
10
- * ignored. Pair it with `touch-action: none` on the element so the browser
11
- * does not claim the gesture for zooming. Server renders expose scale `1`,
12
- * rotation `0`, and `isPinching: false`.
13
- *
14
- * @param target Reactive element target.
15
- * @param options Gesture lifecycle callbacks.
16
- * @default options {}
17
- * @returns Reactive gesture state plus reset/stop controls.
18
- */
19
5
  function usePinch(target, options = {}) {
20
6
  const isPinching = ref(false);
21
7
  const scale = ref(1);
@@ -2,37 +2,14 @@ import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { resolveElement } from "./element-target.mjs";
3
3
  import { hasInjectionContext, readonly, ref, shallowRef, toValue, watch, watchPostEffect } from "vue";
4
4
  //#region src/pointer-lock.ts
5
- /** Error thrown when pointer lock cannot be acquired or released. */
6
5
  var PointerLockError = class extends Error {
7
- /** Machine-readable failure code. */
8
6
  code;
9
- /**
10
- * @param code Machine-readable failure code.
11
- * @param message Human-readable explanation.
12
- */
13
7
  constructor(code, message) {
14
8
  super(message);
15
9
  this.name = "PointerLockError";
16
10
  this.code = code;
17
11
  }
18
12
  };
19
- /**
20
- * Reactive wrapper around the Pointer Lock API.
21
- *
22
- * Tracks `pointerlockchange` on the document and exposes promise-based lock
23
- * and unlock actions that settle on the platform confirmation events.
24
- * Rejections are {@link PointerLockError}s with stable codes. Nothing runs
25
- * during server rendering; listeners are removed with the owning scope.
26
- *
27
- * Inside a component the host is read after mounting, so hydration renders
28
- * the server fallback first and never mismatches.
29
- *
30
- * @param target Default reactive element to lock.
31
- * @param options Movement mode and document capability.
32
- * @default target undefined
33
- * @default options {}
34
- * @returns Support flag, lock state, and actions.
35
- */
36
13
  function usePointerLock(target, options = {}) {
37
14
  const isSupported = ref(false);
38
15
  const element = shallowRef(null);
package/dist/pointer.mjs CHANGED
@@ -1,18 +1,6 @@
1
1
  import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { readonly, ref, shallowReactive, shallowReadonly, toValue, watch } from "vue";
3
3
  //#region src/pointer.ts
4
- /**
5
- * Track the latest pointer (mouse, touch, or pen) state.
6
- *
7
- * Listens passively for `pointerdown`, `pointermove`, `pointerup`, and
8
- * `pointerleave` on the reactive target and filters by device kind.
9
- * Listeners are removed with the owning reactive scope; server renders expose
10
- * the initial snapshot.
11
- *
12
- * @param options Device filter, target, and initial snapshot.
13
- * @default options {}
14
- * @returns Reactive snapshot and inside flag.
15
- */
16
4
  function usePointer(options = {}) {
17
5
  const pointerTypes = options.pointerTypes ?? [
18
6
  "mouse",
@@ -76,12 +64,6 @@ function usePointer(options = {}) {
76
64
  isInside: readonly(isInside)
77
65
  };
78
66
  }
79
- /**
80
- * Narrow a platform `pointerType` string to the closed {@link PointerKind} union.
81
- *
82
- * @param value Raw `PointerEvent.pointerType`.
83
- * @returns The matching kind, or `null` for unknown/future device kinds.
84
- */
85
67
  function toPointerKind(value) {
86
68
  return value === "mouse" || value === "touch" || value === "pen" ? value : null;
87
69
  }
@@ -1,26 +1,9 @@
1
1
  import { useMediaQuery } from "./media-query.mjs";
2
2
  import { computed } from "vue";
3
3
  //#region src/preferences.ts
4
- /**
5
- * Whether the user prefers a dark color scheme.
6
- *
7
- * Shares {@link useMediaQuery} semantics: `ssrValue` (default `false`) during
8
- * server rendering and subscription cleanup with the owning scope.
9
- *
10
- * @param options Runtime capability and server fallback.
11
- * @default options {}
12
- * @returns Readonly ref for `(prefers-color-scheme: dark)`.
13
- */
14
4
  function usePreferredDark(options = {}) {
15
5
  return useMediaQuery("(prefers-color-scheme: dark)", options);
16
6
  }
17
- /**
18
- * Reactive color scheme preference.
19
- *
20
- * @param options Runtime capability and server fallback.
21
- * @default options {}
22
- * @returns Computed closed preference.
23
- */
24
7
  function usePreferredColorScheme(options = {}) {
25
8
  const fallback = options.ssrPreference ?? "no-preference";
26
9
  const query = (value) => useMediaQuery(`(prefers-color-scheme: ${value})`, withSsr(options, fallback === value));
@@ -28,13 +11,6 @@ function usePreferredColorScheme(options = {}) {
28
11
  const light = query("light");
29
12
  return computed(() => dark.value ? "dark" : light.value ? "light" : "no-preference");
30
13
  }
31
- /**
32
- * Reactive contrast preference.
33
- *
34
- * @param options Runtime capability and server fallback.
35
- * @default options {}
36
- * @returns Computed closed preference.
37
- */
38
14
  function usePreferredContrast(options = {}) {
39
15
  const fallback = options.ssrPreference ?? "no-preference";
40
16
  const query = (value) => useMediaQuery(`(prefers-contrast: ${value})`, withSsr(options, fallback === value));
@@ -43,13 +19,6 @@ function usePreferredContrast(options = {}) {
43
19
  const custom = query("custom");
44
20
  return computed(() => more.value ? "more" : less.value ? "less" : custom.value ? "custom" : "no-preference");
45
21
  }
46
- /**
47
- * Whether the user prefers reduced transparency.
48
- *
49
- * @param options Runtime capability and server fallback.
50
- * @default options {}
51
- * @returns Readonly ref for `(prefers-reduced-transparency: reduce)`.
52
- */
53
22
  function usePreferredReducedTransparency(options = {}) {
54
23
  return useMediaQuery("(prefers-reduced-transparency: reduce)", options);
55
24
  }
@@ -1,19 +1,6 @@
1
1
  import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { hasInjectionContext, readonly, shallowRef, toValue, watch, watchPostEffect } from "vue";
3
3
  //#region src/preferred-languages.ts
4
- /**
5
- * Track the user's preferred languages (`navigator.languages`).
6
- *
7
- * Updates on `languagechange`. The default host is gated on `window`, so
8
- * Node's own `navigator` never leaks the server locale into the render;
9
- * server renders expose `ssrLanguages`. Inside a component the languages are
10
- * read after mounting, so hydration renders `ssrLanguages` first. The
11
- * listener is removed with the owning reactive scope.
12
- *
13
- * @param options Server fallback and window capability.
14
- * @default options {}
15
- * @returns Readonly ref of BCP 47 language tags, most preferred first.
16
- */
17
4
  function usePreferredLanguages(options = {}) {
18
5
  const fallback = options.ssrLanguages ?? ["en"];
19
6
  const languages = shallowRef(fallback);
@@ -11,30 +11,6 @@ function resolveResetMs(value) {
11
11
  if (!Number.isFinite(value) || value < 0) throw new RangeError(`[VIZE_COMPOSE_REF_AUTO_RESET_INVALID_DELAY] afterMs must be finite and at least zero; received ${String(value)}`);
12
12
  return Math.trunc(value);
13
13
  }
14
- /**
15
- * Writable ref that falls back to a default value `afterMs` milliseconds
16
- * after each write.
17
- *
18
- * Typical for transient UI state such as "Copied!" labels. Every write
19
- * restarts the timer; the default (itself possibly reactive) is read when the
20
- * reset happens, and the ref reads the current default until the first write.
21
- * The pending reset is cancelled when the owning reactive scope stops.
22
- * Without a browser `window` (and without `runOnServer`) no timer starts.
23
- *
24
- * @example
25
- * ```ts
26
- * const message = refAutoReset("", 2_000);
27
- * message.value = "Copied!"; // back to "" after two seconds
28
- * ```
29
- *
30
- * @param defaultValue Reactive value restored after the delay.
31
- * @param afterMs Reactive delay in milliseconds, finite and at least zero.
32
- * @param options Server and scheduler policy.
33
- * @default options {}
34
- * @throws `RangeError` tagged `VIZE_COMPOSE_REF_AUTO_RESET_INVALID_DELAY` for
35
- * invalid delays, synchronously at creation and on every write.
36
- * @returns A writable ref.
37
- */
38
14
  function refAutoReset(defaultValue, afterMs, options = {}) {
39
15
  const scheduler = options.scheduler ?? defaultScheduler;
40
16
  resolveResetMs(toValue(afterMs));
@@ -1,27 +1,5 @@
1
1
  import { useDebounced } from "./use-debounced.mjs";
2
2
  //#region src/ref-debounced.ts
3
- /**
4
- * Readonly ref that follows `source` after it stayed quiet for `waitMs`.
5
- *
6
- * Shorthand for `useDebounced(source, waitMs, options).debounced` when the
7
- * pending flag and cancel/flush controls are not needed. Inherits every rule
8
- * of {@link useDebounced}: synchronous mirroring on the server, reactive
9
- * wait, and scope-bound cleanup.
10
- *
11
- * @example
12
- * ```ts
13
- * const query = ref("");
14
- * const debouncedQuery = refDebounced(query, 300);
15
- * ```
16
- *
17
- * @param source Reactive source.
18
- * @param waitMs Reactive quiet period in milliseconds.
19
- * @param options Server and scheduler policy.
20
- * @default options {}
21
- * @throws `RangeError` tagged `VIZE_COMPOSE_DEBOUNCE_INVALID_WAIT` for invalid
22
- * waits (see {@link useDebounced}).
23
- * @returns The debounced readonly ref.
24
- */
25
3
  function refDebounced(source, waitMs, options = {}) {
26
4
  return useDebounced(source, waitMs, options).debounced;
27
5
  }