@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.
- package/dist/abort-signal.mjs +0 -62
- package/dist/active-element.mjs +0 -11
- package/dist/animate.mjs +0 -19
- package/dist/async-resource.mjs +0 -17
- package/dist/battery.mjs +0 -13
- package/dist/breakpoints.mjs +0 -24
- package/dist/capability.mjs +0 -12
- package/dist/{catalog-BRX-Wg8B.mjs → catalog-CcpCnLjb.mjs} +0 -14
- package/dist/catalog.mjs +1 -1
- package/dist/color-mode.mjs +0 -23
- package/dist/computed-with-control.mjs +0 -22
- package/dist/create-event-hook.mjs +0 -27
- package/dist/create-global-state.mjs +0 -23
- package/dist/create-shared-composable.mjs +0 -23
- package/dist/device-motion.mjs +0 -11
- package/dist/device-orientation.mjs +0 -23
- package/dist/device-pixel-ratio.mjs +0 -11
- package/dist/disposal-scope.mjs +0 -25
- package/dist/document-visibility.mjs +0 -14
- package/dist/draggable.mjs +0 -14
- package/dist/element-bounding.mjs +0 -14
- package/dist/element-by-point.mjs +0 -10
- package/dist/element-hover.mjs +0 -13
- package/dist/element-target.mjs +0 -30
- package/dist/focus.mjs +0 -23
- package/dist/fps.mjs +0 -12
- package/dist/geolocation.mjs +0 -14
- package/dist/i18n.mjs +0 -86
- package/dist/icu-message.mjs +0 -58
- package/dist/idle.mjs +0 -16
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/infinite-scroll.mjs +0 -16
- package/dist/intersection-observer.mjs +0 -27
- package/dist/locale.mjs +0 -20
- package/dist/magic-keys.mjs +0 -35
- package/dist/math.mjs +0 -37
- package/dist/media-query.mjs +0 -29
- package/dist/mouse-in-element.mjs +0 -12
- package/dist/mouse.mjs +0 -12
- package/dist/mutation-observer.mjs +0 -15
- package/dist/network.mjs +0 -24
- package/dist/on-click-outside.mjs +0 -16
- package/dist/on-key-stroke.mjs +0 -33
- package/dist/on-long-press.mjs +0 -14
- package/dist/on-start-typing.mjs +0 -23
- package/dist/page-leave.mjs +0 -11
- package/dist/parent-element.mjs +0 -9
- package/dist/pinch.mjs +0 -14
- package/dist/pointer-lock.mjs +0 -23
- package/dist/pointer.mjs +0 -18
- package/dist/preferences.mjs +0 -31
- package/dist/preferred-languages.mjs +0 -13
- package/dist/ref-auto-reset.mjs +0 -24
- package/dist/ref-debounced.mjs +0 -22
- package/dist/ref-default.mjs +0 -21
- package/dist/resize-observer.mjs +0 -31
- package/dist/resolver.mjs +1 -58
- package/dist/retry-async.mjs +0 -25
- package/dist/retry-delay.mjs +0 -23
- package/dist/scope.mjs +0 -14
- package/dist/screen-orientation.mjs +0 -15
- package/dist/scroll-lock.mjs +0 -14
- package/dist/scroll.mjs +0 -27
- package/dist/standard-schema.mjs +0 -31
- package/dist/swipe.mjs +0 -36
- package/dist/temporal.mjs +0 -30
- package/dist/text-selection.mjs +0 -15
- package/dist/textarea-autosize.mjs +0 -13
- package/dist/to-reactive.mjs +0 -20
- package/dist/transition.mjs +0 -7
- package/dist/until.mjs +0 -25
- package/dist/use-array.mjs +0 -52
- package/dist/use-barcode-detector.mjs +0 -25
- package/dist/use-bluetooth.mjs +0 -27
- package/dist/use-broadcast-channel.mjs +0 -30
- package/dist/use-builtin-ai.mjs +0 -68
- package/dist/use-clipboard.mjs +0 -27
- package/dist/use-compression-stream.mjs +0 -78
- package/dist/use-contact-picker.mjs +0 -22
- package/dist/use-cookie.mjs +0 -63
- package/dist/use-countdown.mjs +0 -22
- package/dist/use-counter.mjs +0 -29
- package/dist/use-css-var.mjs +0 -28
- package/dist/use-date-format.mjs +0 -48
- package/dist/use-date-time-format.mjs +0 -22
- package/dist/use-debounced.mjs +0 -39
- package/dist/use-display-media.mjs +0 -22
- package/dist/use-display-names.mjs +0 -19
- package/dist/use-document-title.mjs +0 -25
- package/dist/use-drop-zone.mjs +0 -36
- package/dist/use-event-source.mjs +0 -25
- package/dist/use-eye-dropper.mjs +0 -19
- package/dist/use-favicon.mjs +0 -23
- package/dist/use-fetch.mjs +0 -27
- package/dist/use-field.mjs +0 -27
- package/dist/use-file-dialog.mjs +0 -21
- package/dist/{use-form-C2JXZ0i7.mjs → use-form-BZqwMs6k.mjs} +143 -70
- package/dist/use-form-field-props.mjs +0 -57
- package/dist/use-form.d.mts +123 -18
- package/dist/use-form.mjs +1 -1
- package/dist/use-fullscreen.mjs +0 -23
- package/dist/use-gamepad.mjs +0 -50
- package/dist/use-hid.mjs +0 -25
- package/dist/use-history.mjs +0 -43
- package/dist/use-id-generator.mjs +0 -21
- package/dist/use-image.mjs +0 -22
- package/dist/use-indexed-db.mjs +0 -39
- package/dist/use-interval.mjs +0 -28
- package/dist/use-list-format.mjs +0 -18
- package/dist/use-machine.mjs +0 -34
- package/dist/use-map.mjs +0 -28
- package/dist/use-media-controls.mjs +0 -28
- package/dist/use-mounted.mjs +0 -18
- package/dist/use-navigation-api.mjs +0 -27
- package/dist/use-notification.mjs +0 -24
- package/dist/use-number-format.mjs +0 -23
- package/dist/use-object-url.mjs +0 -22
- package/dist/use-offset-pagination.mjs +0 -18
- package/dist/use-payment-request.mjs +0 -25
- package/dist/use-performance-observer.mjs +0 -27
- package/dist/use-permission.mjs +0 -26
- package/dist/use-plural-rules.mjs +0 -21
- package/dist/use-push-subscription.mjs +0 -28
- package/dist/use-queue.mjs +0 -29
- package/dist/use-raf-fn.mjs +0 -23
- package/dist/use-relative-time-format.mjs +0 -35
- package/dist/use-request-idle-callback.mjs +0 -42
- package/dist/use-route-query.mjs +0 -17
- package/dist/use-scheduler-post-task.mjs +0 -27
- package/dist/use-screen-details.mjs +0 -42
- package/dist/use-script-tag.mjs +0 -28
- package/dist/use-segmenter.mjs +0 -20
- package/dist/use-serial.mjs +0 -24
- package/dist/use-service-worker.mjs +0 -27
- package/dist/use-set.mjs +0 -23
- package/dist/use-share.mjs +0 -23
- package/dist/use-sorted-locale.mjs +0 -20
- package/dist/use-speech-recognition.mjs +0 -24
- package/dist/use-speech-synthesis.mjs +0 -26
- package/dist/use-stack.mjs +0 -27
- package/dist/use-storage-estimate.mjs +0 -41
- package/dist/use-storage.mjs +0 -68
- package/dist/use-style-tag.mjs +0 -22
- package/dist/use-supported.mjs +0 -17
- package/dist/use-throttled.mjs +0 -46
- package/dist/use-time-ago.mjs +0 -22
- package/dist/use-toggle.mjs +0 -19
- package/dist/use-url-hash.mjs +0 -28
- package/dist/use-url-search-params.mjs +0 -99
- package/dist/use-usb.mjs +0 -23
- package/dist/use-user-activation.mjs +0 -22
- package/dist/use-user-media.mjs +0 -50
- package/dist/use-vibrate.mjs +0 -21
- package/dist/use-view-transition.mjs +0 -22
- package/dist/use-visual-viewport.mjs +0 -25
- package/dist/use-wake-lock.mjs +0 -21
- package/dist/use-web-authn.mjs +0 -61
- package/dist/use-web-locks.mjs +0 -25
- package/dist/use-web-midi.mjs +0 -22
- package/dist/use-web-vitals.mjs +0 -41
- package/dist/use-websocket.mjs +0 -27
- package/dist/use-worker-fn.mjs +0 -37
- package/dist/virtual-list.mjs +0 -14
- package/dist/whenever.mjs +0 -21
- package/dist/window-size.mjs +0 -12
- package/package.json +2 -2
- package/registry/files/form-control-types.ts +260 -0
- package/registry/files/form-dirty.ts +131 -0
- package/registry/files/form-options.ts +156 -0
- package/registry/files/form-path-types.ts +135 -0
- package/registry/files/use-form.ts +102 -449
- package/registry/registry.json +28 -4
package/dist/ref-default.mjs
CHANGED
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
import { computed, toValue } from "vue";
|
|
2
2
|
//#region src/ref-default.ts
|
|
3
|
-
/**
|
|
4
|
-
* View a nullable ref through a default value.
|
|
5
|
-
*
|
|
6
|
-
* Reads return the source value, or the (possibly reactive) default while the
|
|
7
|
-
* source holds `null` or `undefined`, so the read type drops those members.
|
|
8
|
-
* Writes go straight to the source and accept its full type, including
|
|
9
|
-
* `null`/`undefined` to fall back to the default again. Pure derived state:
|
|
10
|
-
* SSR-safe and nothing to dispose.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* const raw = ref<string | undefined>();
|
|
15
|
-
* const name = refDefault(raw, "Anonymous");
|
|
16
|
-
* name.value; // "Anonymous"
|
|
17
|
-
* name.value = "Ada"; // raw.value === "Ada"
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @param source Writable nullable ref.
|
|
21
|
-
* @param defaultValue Reactive fallback.
|
|
22
|
-
* @returns A writable computed ref whose reads never yield `null`/`undefined`.
|
|
23
|
-
*/
|
|
24
3
|
function refDefault(source, defaultValue) {
|
|
25
4
|
return computed({
|
|
26
5
|
get: () => source.value ?? toValue(defaultValue),
|
package/dist/resize-observer.mjs
CHANGED
|
@@ -2,24 +2,6 @@ import { tryOnScopeDispose } from "./scope.mjs";
|
|
|
2
2
|
import { resolveElement, resolveElements } from "./element-target.mjs";
|
|
3
3
|
import { computed, hasInjectionContext, readonly, ref, shallowRef, toValue, watch, watchPostEffect } from "vue";
|
|
4
4
|
//#region src/resize-observer.ts
|
|
5
|
-
/**
|
|
6
|
-
* Observe size changes of one or more reactive elements.
|
|
7
|
-
*
|
|
8
|
-
* A single observer is (re)created whenever the resolved targets, the box
|
|
9
|
-
* option, or the host change; unresolved targets are skipped. The observer is
|
|
10
|
-
* disconnected when the owning reactive scope stops or `stop` is called.
|
|
11
|
-
* During server rendering no host resolves, `isSupported` stays `false`, and
|
|
12
|
-
* the callback never runs.
|
|
13
|
-
*
|
|
14
|
-
* Inside a component the host is read after mounting, so hydration renders
|
|
15
|
-
* the server fallback first and never mismatches.
|
|
16
|
-
*
|
|
17
|
-
* @param targets Reactive element target or list of targets.
|
|
18
|
-
* @param callback Native `ResizeObserver` callback.
|
|
19
|
-
* @param options Box model, runtime capability, and watcher timing.
|
|
20
|
-
* @default options {}
|
|
21
|
-
* @returns Support flag and stop control.
|
|
22
|
-
*/
|
|
23
5
|
function useResizeObserver(targets, callback, options = {}) {
|
|
24
6
|
const isSupported = ref(false);
|
|
25
7
|
const hydrated = shallowRef(!hasInjectionContext());
|
|
@@ -48,19 +30,6 @@ function useResizeObserver(targets, callback, options = {}) {
|
|
|
48
30
|
stop
|
|
49
31
|
};
|
|
50
32
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Track the rendered size of a reactive element.
|
|
53
|
-
*
|
|
54
|
-
* Reads the requested box from `contentBoxSize`/`borderBoxSize` (summing
|
|
55
|
-
* fragments) and falls back to `contentRect` for older engines. When the
|
|
56
|
-
* target unmounts the size resets to the initial value so stale geometry never
|
|
57
|
-
* leaks into the next render. Server renders expose `initialSize`.
|
|
58
|
-
*
|
|
59
|
-
* @param target Reactive element target.
|
|
60
|
-
* @param options Initial size, box model, capability, and watcher timing.
|
|
61
|
-
* @default options {}
|
|
62
|
-
* @returns Reactive width/height plus observer controls.
|
|
63
|
-
*/
|
|
64
33
|
function useElementSize(target, options = {}) {
|
|
65
34
|
const initial = options.initialSize ?? {
|
|
66
35
|
width: 0,
|
package/dist/resolver.mjs
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import { t as COMPOSABLE_CATALOG } from "./catalog-
|
|
1
|
+
import { t as COMPOSABLE_CATALOG } from "./catalog-CcpCnLjb.mjs";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
//#region src/resolver.ts
|
|
5
|
-
/**
|
|
6
|
-
* Build-time auto-import resolver for `@vizejs/composable`, driven by the
|
|
7
|
-
* package catalog so every new entry is picked up automatically.
|
|
8
|
-
*
|
|
9
|
-
* Every export resolves to its own subpath (`@vizejs/composable/use-toggle`),
|
|
10
|
-
* so auto-imported code tree-shakes exactly like hand-written imports; this
|
|
11
|
-
* module runs in Node (Vite/Nuxt config) and never ships to the browser.
|
|
12
|
-
* With `source: "local"`, entries pulled by `vize lib pull` (recorded in
|
|
13
|
-
* `vize-lib.lock.json`) resolve to the local copies.
|
|
14
|
-
*/
|
|
15
|
-
/** Package that owns the resolvable exports. */
|
|
16
5
|
const VIZE_COMPOSABLE_PACKAGE = "@vizejs/composable";
|
|
17
|
-
/** Subpaths that are tooling, not auto-importable runtime code. */
|
|
18
6
|
const NON_IMPORTABLE_SUBPATHS = new Set(["./catalog", "./resolver"]);
|
|
19
|
-
/** Export name -> owning entry, first catalog entry wins. */
|
|
20
7
|
function catalogExports() {
|
|
21
8
|
const exports = /* @__PURE__ */ new Map();
|
|
22
9
|
for (const entry of COMPOSABLE_CATALOG.entries) {
|
|
@@ -31,13 +18,6 @@ function catalogExports() {
|
|
|
31
18
|
function isLockfile(value) {
|
|
32
19
|
return typeof value === "object" && value !== null && "items" in value && Array.isArray(value.items) && value.items.every((item) => typeof item === "object" && item !== null && "name" in item && "kind" in item && "dir" in item && typeof item.name === "string" && typeof item.kind === "string" && typeof item.dir === "string");
|
|
33
20
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Read and validate `vize-lib.lock.json`.
|
|
36
|
-
*
|
|
37
|
-
* @param file Absolute lockfile path.
|
|
38
|
-
* @returns The parsed lockfile.
|
|
39
|
-
* @throws {Error} `[VIZE_COMPOSE_RESOLVER_LOCKFILE]` when missing or malformed.
|
|
40
|
-
*/
|
|
41
21
|
function readComposableLockfile(file) {
|
|
42
22
|
let parsed;
|
|
43
23
|
try {
|
|
@@ -64,13 +44,6 @@ function createLocator(options) {
|
|
|
64
44
|
return path.resolve(root, dir, item.source).split(path.sep).join("/");
|
|
65
45
|
};
|
|
66
46
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Every auto-importable export the options allow, with its direct subpath import.
|
|
69
|
-
*
|
|
70
|
-
* @param options Filters and source mode.
|
|
71
|
-
* @default options {}
|
|
72
|
-
* @returns Imports in catalog order.
|
|
73
|
-
*/
|
|
74
47
|
function listVizeComposableImports(options = {}) {
|
|
75
48
|
const locate = createLocator(options);
|
|
76
49
|
const names = options.names === void 0 ? void 0 : new Set(options.names);
|
|
@@ -85,45 +58,15 @@ function listVizeComposableImports(options = {}) {
|
|
|
85
58
|
}
|
|
86
59
|
return imports;
|
|
87
60
|
}
|
|
88
|
-
/**
|
|
89
|
-
* `unplugin-auto-import` resolver for every `@vizejs/composable` export.
|
|
90
|
-
*
|
|
91
|
-
* Server/SSR: build-time only; reads the lockfile once in `local` mode.
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```ts
|
|
95
|
-
* AutoImport({ resolvers: [VizeComposableResolver()] });
|
|
96
|
-
* // useToggle() -> import { useToggle } from "@vizejs/composable/use-toggle"
|
|
97
|
-
* ```
|
|
98
|
-
*
|
|
99
|
-
* @param options Filters and source mode.
|
|
100
|
-
* @default options {}
|
|
101
|
-
* @returns A name -> import resolver function.
|
|
102
|
-
*/
|
|
103
61
|
function VizeComposableResolver(options = {}) {
|
|
104
62
|
const allowed = new Map(listVizeComposableImports(options).map((item) => [item.name, item]));
|
|
105
63
|
return (name) => allowed.get(name);
|
|
106
64
|
}
|
|
107
|
-
/**
|
|
108
|
-
* `unplugin-auto-import` `imports` preset: `{ "@vizejs/composable/use-toggle": ["useToggle"] }`.
|
|
109
|
-
*
|
|
110
|
-
* @param options Filters and source mode.
|
|
111
|
-
* @default options {}
|
|
112
|
-
* @returns Export names grouped by module.
|
|
113
|
-
*/
|
|
114
65
|
function vizeComposableImports(options = {}) {
|
|
115
66
|
const grouped = {};
|
|
116
67
|
for (const { name, from } of listVizeComposableImports(options)) (grouped[from] ??= []).push(name);
|
|
117
68
|
return grouped;
|
|
118
69
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Global declarations for auto-imported composables, for setups without a
|
|
121
|
-
* generator (Nuxt and `unplugin-auto-import` emit their own).
|
|
122
|
-
*
|
|
123
|
-
* @param options Filters and source mode.
|
|
124
|
-
* @default options {}
|
|
125
|
-
* @returns A `.d.ts` module declaring each export as a global.
|
|
126
|
-
*/
|
|
127
70
|
function createVizeComposableDeclarations(options = {}) {
|
|
128
71
|
return [
|
|
129
72
|
"// Generated by @vizejs/composable/resolver. Do not edit.",
|
package/dist/retry-async.mjs
CHANGED
|
@@ -1,31 +1,6 @@
|
|
|
1
1
|
import { timeoutAbortSignal } from "./abort-signal.mjs";
|
|
2
2
|
import { calculateRetryDelay } from "./retry-delay.mjs";
|
|
3
3
|
//#region src/retry-async.ts
|
|
4
|
-
/**
|
|
5
|
-
* Execute an operation with bounded, abortable retries and deterministic delay policy.
|
|
6
|
-
*
|
|
7
|
-
* Synchronous throws and asynchronous rejections follow the same path. A
|
|
8
|
-
* successful value is returned unchanged. Exhaustion rejects with the final
|
|
9
|
-
* operation error, a negative retry decision rejects with the error that was
|
|
10
|
-
* evaluated, and cancellation rejects with the signal's exact reason. These
|
|
11
|
-
* values are deliberately not wrapped.
|
|
12
|
-
*
|
|
13
|
-
* Cancellation races every asynchronous stage, so callers are not forced to
|
|
14
|
-
* wait for an operation or hook that ignores its signal. Late settlements are
|
|
15
|
-
* still observed internally and cannot become unhandled rejections. Backoff
|
|
16
|
-
* options and entropy are evaluated lazily only after a failure is approved
|
|
17
|
-
* for retry.
|
|
18
|
-
*
|
|
19
|
-
* @typeParam Value Value produced by the operation.
|
|
20
|
-
* @param operation Work to invoke with a one-based attempt and shared signal.
|
|
21
|
-
* @param options Retry count, cancellation, policy, hooks, and delay options.
|
|
22
|
-
* @default options {}
|
|
23
|
-
* @throws {RangeError} A tagged error when `maximumRetries` or inherited delay
|
|
24
|
-
* options are outside their documented ranges.
|
|
25
|
-
* @throws {TypeError} A tagged error when `options` is not an object, a
|
|
26
|
-
* callback is not callable, or a retry decision does not resolve to a boolean.
|
|
27
|
-
* @returns The first successful operation value.
|
|
28
|
-
*/
|
|
29
4
|
async function retryAsync(operation, options = {}) {
|
|
30
5
|
if (typeof operation !== "function") throw new TypeError(`[VIZE_COMPOSE_RETRY_INVALID_OPERATION] operation must be a function; received ${typeof operation}`);
|
|
31
6
|
if (options === null || typeof options !== "object") throw new TypeError(`[VIZE_COMPOSE_RETRY_INVALID_OPTIONS] options must be an object; received ${options === null ? "null" : typeof options}`);
|
package/dist/retry-delay.mjs
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
//#region src/retry-delay.ts
|
|
2
|
-
/**
|
|
3
|
-
* Calculate a bounded exponential-backoff delay for a one-based retry.
|
|
4
|
-
*
|
|
5
|
-
* The first retry is `retryAttempt = 1`. The result is always an integer from
|
|
6
|
-
* zero through `2_147_483_647`, making it safe to pass to common host timer
|
|
7
|
-
* APIs without implementation-specific clamping. The calculation is pure
|
|
8
|
-
* unless jitter requires the supplied entropy source, and it performs no work
|
|
9
|
-
* when the module is imported.
|
|
10
|
-
*
|
|
11
|
-
* Jitter samples uniformly from the inclusive integer range
|
|
12
|
-
* `ceil(cappedDelay * (1 - jitterRatio))...cappedDelay`. Capping occurs before
|
|
13
|
-
* jitter, so neither floating-point overflow nor entropy can exceed the
|
|
14
|
-
* configured maximum.
|
|
15
|
-
*
|
|
16
|
-
* @param retryAttempt One-based retry number after a failed initial attempt.
|
|
17
|
-
* @param options Backoff, cap, jitter, and entropy configuration.
|
|
18
|
-
* @default options {}
|
|
19
|
-
* @throws {RangeError} A tagged error when the retry number, delay options, or
|
|
20
|
-
* entropy value is outside its documented range.
|
|
21
|
-
* @throws {TypeError} A tagged error when `options` is not an object or
|
|
22
|
-
* `random` is not callable.
|
|
23
|
-
* @returns An integer delay in milliseconds.
|
|
24
|
-
*/
|
|
25
2
|
function calculateRetryDelay(retryAttempt, options = {}) {
|
|
26
3
|
if (!Number.isSafeInteger(retryAttempt) || retryAttempt < 1) throw new RangeError(`[VIZE_COMPOSE_RETRY_INVALID_ATTEMPT] retryAttempt must be a positive safe integer; received ${String(retryAttempt)}`);
|
|
27
4
|
if (options === null || typeof options !== "object") throw new TypeError(`[VIZE_COMPOSE_RETRY_INVALID_OPTIONS] options must be an object; received ${options === null ? "null" : typeof options}`);
|
package/dist/scope.mjs
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
import { getCurrentScope, onScopeDispose } from "vue";
|
|
2
2
|
//#region src/scope.ts
|
|
3
|
-
/**
|
|
4
|
-
* Register cleanup in the active reactive scope when one exists.
|
|
5
|
-
*
|
|
6
|
-
* This is the shared lifecycle primitive of the package: composables hand
|
|
7
|
-
* their teardown here so owned resources are released when the surrounding
|
|
8
|
-
* scope stops.
|
|
9
|
-
*
|
|
10
|
-
* Never throws and is safe during server rendering; no browser globals are
|
|
11
|
-
* read. When no scope is active the cleanup is not registered and disposal
|
|
12
|
-
* ownership stays with the caller.
|
|
13
|
-
*
|
|
14
|
-
* @param cleanup Cleanup invoked exactly once when the scope is disposed.
|
|
15
|
-
* @returns Whether the cleanup was registered.
|
|
16
|
-
*/
|
|
17
3
|
function tryOnScopeDispose(cleanup) {
|
|
18
4
|
if (!getCurrentScope()) return false;
|
|
19
5
|
onScopeDispose(cleanup);
|
|
@@ -1,21 +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/screen-orientation.ts
|
|
4
|
-
/**
|
|
5
|
-
* Track the screen orientation.
|
|
6
|
-
*
|
|
7
|
-
* Server renders expose `ssrOrientation` with angle `0`. The `change`
|
|
8
|
-
* listener follows the reactive host and is removed with the owning scope.
|
|
9
|
-
* Lock failures (not fullscreen, unsupported) resolve `false` instead of
|
|
10
|
-
* throwing.
|
|
11
|
-
*
|
|
12
|
-
* Inside a component the host is read after mounting, so hydration renders
|
|
13
|
-
* the server fallback first and never mismatches.
|
|
14
|
-
*
|
|
15
|
-
* @param options Server fallback and window capability.
|
|
16
|
-
* @default options {}
|
|
17
|
-
* @returns Reactive orientation plus lock actions.
|
|
18
|
-
*/
|
|
19
4
|
function useScreenOrientation(options = {}) {
|
|
20
5
|
const fallback = options.ssrOrientation ?? "portrait-primary";
|
|
21
6
|
const isSupported = ref(false);
|
package/dist/scroll-lock.mjs
CHANGED
|
@@ -2,20 +2,6 @@ import { tryOnScopeDispose } from "./scope.mjs";
|
|
|
2
2
|
import { resolveElement } from "./element-target.mjs";
|
|
3
3
|
import { computed, ref, watch } from "vue";
|
|
4
4
|
//#region src/scroll-lock.ts
|
|
5
|
-
/**
|
|
6
|
-
* Lock scrolling of a single element by toggling `overflow: hidden`.
|
|
7
|
-
*
|
|
8
|
-
* The element's previous inline `overflow` is restored on unlock, target
|
|
9
|
-
* change, and scope disposal. This is intentionally element-scoped: for the
|
|
10
|
-
* document viewport (nested lock stacking, scrollbar-gap compensation,
|
|
11
|
-
* scroll restoration) use `createScrollLock` from `@vizejs/ui/scroll-lock`.
|
|
12
|
-
* Server renders never touch styles and report the requested initial value.
|
|
13
|
-
*
|
|
14
|
-
* @param target Reactive element target.
|
|
15
|
-
* @param options Initial state and touch handling.
|
|
16
|
-
* @default options {}
|
|
17
|
-
* @returns Writable locked flag.
|
|
18
|
-
*/
|
|
19
5
|
function useScrollLock(target, options = {}) {
|
|
20
6
|
const locked = ref(options.initialValue ?? false);
|
|
21
7
|
const preventTouchMove = options.preventTouchMove ?? true;
|
package/dist/scroll.mjs
CHANGED
|
@@ -8,23 +8,6 @@ const defaultScheduler = {
|
|
|
8
8
|
globalThis.clearTimeout(handle);
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Track the scroll offset, edges, and direction of an element or window.
|
|
13
|
-
*
|
|
14
|
-
* During server rendering (or while the target is unresolved) offsets are `0`,
|
|
15
|
-
* the top/left edges report arrived, and the bottom/right edges do not —
|
|
16
|
-
* matching an unscrolled page, so hydration is stable. The scroll listener is
|
|
17
|
-
* passive and removed together with the idle timer when the owning reactive
|
|
18
|
-
* scope stops.
|
|
19
|
-
*
|
|
20
|
-
* Inside a component the host is read after mounting, so hydration renders
|
|
21
|
-
* the server fallback first and never mismatches.
|
|
22
|
-
*
|
|
23
|
-
* @param target Reactive element, component, or window-like target.
|
|
24
|
-
* @param options Edge offsets, idle timing, behavior, and callbacks.
|
|
25
|
-
* @default options {}
|
|
26
|
-
* @returns Writable offsets, activity, edges, directions, and controls.
|
|
27
|
-
*/
|
|
28
11
|
function useScroll(target, options = {}) {
|
|
29
12
|
const offset = options.offset ?? {};
|
|
30
13
|
const idle = options.idle ?? 200;
|
|
@@ -148,16 +131,6 @@ function useScroll(target, options = {}) {
|
|
|
148
131
|
scrollTo
|
|
149
132
|
};
|
|
150
133
|
}
|
|
151
|
-
/**
|
|
152
|
-
* Track the document scroll position.
|
|
153
|
-
*
|
|
154
|
-
* Equivalent to {@link useScroll} with the window as target, so it shares its
|
|
155
|
-
* SSR-stable defaults and scope-bound cleanup.
|
|
156
|
-
*
|
|
157
|
-
* @param options Window capability plus every {@link useScroll} option.
|
|
158
|
-
* @default options {}
|
|
159
|
-
* @returns The same controls as {@link useScroll}.
|
|
160
|
-
*/
|
|
161
134
|
function useWindowScroll(options = {}) {
|
|
162
135
|
const { host, ...scrollOptions } = options;
|
|
163
136
|
return useScroll(() => host === void 0 ? browserScrollWindow() : toValue(host), scrollOptions);
|
package/dist/standard-schema.mjs
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
//#region src/standard-schema.ts
|
|
2
|
-
/**
|
|
3
|
-
* Whether a value implements the Standard Schema v1 protocol.
|
|
4
|
-
*
|
|
5
|
-
* @param candidate Value to test.
|
|
6
|
-
* @returns Whether `candidate["~standard"].validate` is callable with version 1.
|
|
7
|
-
*/
|
|
8
2
|
function isStandardSchema(candidate) {
|
|
9
3
|
if (typeof candidate !== "object" && typeof candidate !== "function" || candidate === null) return false;
|
|
10
4
|
const props = Reflect.get(candidate, "~standard");
|
|
11
5
|
return typeof props === "object" && props !== null && Reflect.get(props, "version") === 1 && typeof Reflect.get(props, "validate") === "function";
|
|
12
6
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Convert a Standard Schema issue path to a dotted path.
|
|
15
|
-
*
|
|
16
|
-
* `{ key }` segments are unwrapped; symbols use their description.
|
|
17
|
-
*
|
|
18
|
-
* @param path Issue path.
|
|
19
|
-
* @returns Dotted path, `""` for the root.
|
|
20
|
-
*/
|
|
21
7
|
function formatSchemaPath(path) {
|
|
22
8
|
if (!path) return "";
|
|
23
9
|
return path.map((segment) => {
|
|
@@ -25,23 +11,6 @@ function formatSchemaPath(path) {
|
|
|
25
11
|
return typeof key === "symbol" ? key.description ?? "" : String(key);
|
|
26
12
|
}).join(".");
|
|
27
13
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Validate a value with a Standard Schema and normalize the result.
|
|
30
|
-
*
|
|
31
|
-
* Synchronous and asynchronous schemas are handled identically. Throwing
|
|
32
|
-
* schemas propagate their error. Pure: safe on the server.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* const result = await validateStandardSchema(zodSchema, formValues);
|
|
37
|
-
* if (result.status === "invalid") console.log(result.issues);
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @typeParam Output Schema output type.
|
|
41
|
-
* @param schema Standard Schema v1 validator.
|
|
42
|
-
* @param value Value to validate.
|
|
43
|
-
* @returns The normalized result.
|
|
44
|
-
*/
|
|
45
14
|
async function validateStandardSchema(schema, value) {
|
|
46
15
|
const result = await schema["~standard"].validate(value);
|
|
47
16
|
if (result.issues === void 0) return {
|
package/dist/swipe.mjs
CHANGED
|
@@ -3,17 +3,6 @@ import { resolveElement } from "./element-target.mjs";
|
|
|
3
3
|
import { toPointerKind } from "./pointer.mjs";
|
|
4
4
|
import { computed, readonly, ref, shallowReactive, shallowReadonly, watch } from "vue";
|
|
5
5
|
//#region src/swipe.ts
|
|
6
|
-
/**
|
|
7
|
-
* Classify a displacement into a {@link SwipeDirection}.
|
|
8
|
-
*
|
|
9
|
-
* Pure helper shared by the swipe composables and usable for custom gesture
|
|
10
|
-
* recognizers.
|
|
11
|
-
*
|
|
12
|
-
* @param lengthX `start.x - end.x`.
|
|
13
|
-
* @param lengthY `start.y - end.y`.
|
|
14
|
-
* @param threshold Minimum travel before a direction is reported.
|
|
15
|
-
* @returns The dominant axis direction, or `"none"`.
|
|
16
|
-
*/
|
|
17
6
|
function swipeDirection(lengthX, lengthY, threshold) {
|
|
18
7
|
if (Math.max(Math.abs(lengthX), Math.abs(lengthY)) < threshold) return "none";
|
|
19
8
|
if (Math.abs(lengthX) > Math.abs(lengthY)) return lengthX > 0 ? "left" : "right";
|
|
@@ -59,19 +48,6 @@ function createGesture(threshold) {
|
|
|
59
48
|
swiping
|
|
60
49
|
};
|
|
61
50
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Detect touch swipes on an element.
|
|
64
|
-
*
|
|
65
|
-
* Tracks the first touch point from `touchstart` through `touchend`/
|
|
66
|
-
* `touchcancel`. Direction is derived from the dominant axis once the travel
|
|
67
|
-
* exceeds `threshold`. Server renders expose zeroed coordinates and
|
|
68
|
-
* `direction: "none"`; listeners are removed with the owning scope.
|
|
69
|
-
*
|
|
70
|
-
* @param target Reactive element target.
|
|
71
|
-
* @param options Threshold, passivity, and callbacks.
|
|
72
|
-
* @default options {}
|
|
73
|
-
* @returns Reactive gesture state and stop control.
|
|
74
|
-
*/
|
|
75
51
|
function useSwipe(target, options = {}) {
|
|
76
52
|
const gesture = createGesture(options.threshold ?? 50);
|
|
77
53
|
const passive = options.passive ?? true;
|
|
@@ -126,18 +102,6 @@ function useSwipe(target, options = {}) {
|
|
|
126
102
|
stop
|
|
127
103
|
};
|
|
128
104
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Detect swipes from any pointer device (mouse, touch, pen).
|
|
131
|
-
*
|
|
132
|
-
* Captures the pointer on `pointerdown` so moves outside the element still
|
|
133
|
-
* count, and ignores secondary pointers during a gesture. Shares the state
|
|
134
|
-
* shape and SSR defaults of {@link useSwipe}.
|
|
135
|
-
*
|
|
136
|
-
* @param target Reactive element target.
|
|
137
|
-
* @param options Threshold, device filter, selection handling, and callbacks.
|
|
138
|
-
* @default options {}
|
|
139
|
-
* @returns Reactive gesture state and stop control.
|
|
140
|
-
*/
|
|
141
105
|
function usePointerSwipe(target, options = {}) {
|
|
142
106
|
const gesture = createGesture(options.threshold ?? 50);
|
|
143
107
|
const pointerTypes = options.pointerTypes ?? [
|
package/dist/temporal.mjs
CHANGED
|
@@ -15,23 +15,6 @@ function shouldSchedule(options) {
|
|
|
15
15
|
if (toValue(options.paused ?? false)) return false;
|
|
16
16
|
return typeof window !== "undefined" || toValue(options.runOnServer ?? false);
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Creates a pauseable Temporal clock whose timer follows the current Vue
|
|
20
|
-
* effect scope.
|
|
21
|
-
*
|
|
22
|
-
* The timer is replaced when reactive options change and is always cancelled
|
|
23
|
-
* when the owning scope stops. Call inside an active effect scope; without
|
|
24
|
-
* one, there is no automatic timer cleanup. During
|
|
25
|
-
* server rendering, no timer starts unless
|
|
26
|
-
* {@link UseTemporalNowOptions.runOnServer} is explicitly enabled.
|
|
27
|
-
*
|
|
28
|
-
* @param options Clock scheduling, pause, and runtime overrides.
|
|
29
|
-
* @default options {}
|
|
30
|
-
* @throws `RangeError` tagged `VIZE_COMPOSE_TEMPORAL_INVALID_INTERVAL` when
|
|
31
|
-
* the resolved interval is not finite or not greater than zero, both
|
|
32
|
-
* synchronously at creation and on invalid reactive updates.
|
|
33
|
-
* @returns Reactive clock controls.
|
|
34
|
-
*/
|
|
35
18
|
function useTemporalNow(options = {}) {
|
|
36
19
|
const readNow = options.now ?? Temporal.Now.instant;
|
|
37
20
|
const instant = shallowRef(readNow());
|
|
@@ -53,19 +36,6 @@ function useTemporalNow(options = {}) {
|
|
|
53
36
|
refresh
|
|
54
37
|
};
|
|
55
38
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Creates a reactive zoned date-time derived from a scoped Temporal clock.
|
|
58
|
-
*
|
|
59
|
-
* Changes to {@link UseTemporalZonedDateTimeOptions.timeZone} are reflected
|
|
60
|
-
* without replacing the underlying timer. Scheduling, server rendering, and
|
|
61
|
-
* scope-cleanup rules are shared with {@link useTemporalNow}.
|
|
62
|
-
*
|
|
63
|
-
* @param options Clock scheduling plus the reactive time zone.
|
|
64
|
-
* @default options {}
|
|
65
|
-
* @throws `RangeError` for invalid intervals (see {@link useTemporalNow}),
|
|
66
|
-
* and on read when the reactive time zone cannot be resolved by Temporal.
|
|
67
|
-
* @returns Computed zoned date-time in the reactive time zone.
|
|
68
|
-
*/
|
|
69
39
|
function useTemporalZonedDateTime(options = {}) {
|
|
70
40
|
const clock = useTemporalNow(options);
|
|
71
41
|
return computed(() => {
|
package/dist/text-selection.mjs
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
2
|
import { computed, hasInjectionContext, shallowRef, toValue, watch, watchPostEffect } from "vue";
|
|
3
3
|
//#region src/text-selection.ts
|
|
4
|
-
/**
|
|
5
|
-
* Track the document text selection.
|
|
6
|
-
*
|
|
7
|
-
* Re-reads the selection on every `selectionchange`. Because the platform
|
|
8
|
-
* mutates the same `Selection` object in place, a revision counter is used to
|
|
9
|
-
* invalidate the derived `text`, `ranges`, and `rects`. Server renders expose
|
|
10
|
-
* an empty selection; the listener is removed with the owning scope.
|
|
11
|
-
*
|
|
12
|
-
* Inside a component the host is read after mounting, so hydration renders
|
|
13
|
-
* the server fallback first and never mismatches.
|
|
14
|
-
*
|
|
15
|
-
* @param options Document capability.
|
|
16
|
-
* @default options {}
|
|
17
|
-
* @returns Reactive selection, text, ranges, and rectangles.
|
|
18
|
-
*/
|
|
19
4
|
function useTextSelection(options = {}) {
|
|
20
5
|
const selection = shallowRef(null);
|
|
21
6
|
const revision = shallowRef(0);
|
|
@@ -3,19 +3,6 @@ import { resolveElement } from "./element-target.mjs";
|
|
|
3
3
|
import { useResizeObserver } from "./resize-observer.mjs";
|
|
4
4
|
import { ref, watch } from "vue";
|
|
5
5
|
//#region src/textarea-autosize.ts
|
|
6
|
-
/**
|
|
7
|
-
* Grow a textarea to fit its content.
|
|
8
|
-
*
|
|
9
|
-
* On each input change (and when the element width changes), the style
|
|
10
|
-
* property is reset to `auto`, and `scrollHeight` is adjusted for the element's
|
|
11
|
-
* padding, borders and box sizing before writing the CSS height in pixels.
|
|
12
|
-
* Nothing is measured during server rendering; markup keeps its declared `rows`.
|
|
13
|
-
*
|
|
14
|
-
* @param target Reactive textarea target.
|
|
15
|
-
* @param options Bound input, style property, callback, and observer capability.
|
|
16
|
-
* @default options {}
|
|
17
|
-
* @returns Bound input and a manual resize trigger.
|
|
18
|
-
*/
|
|
19
6
|
function useTextareaAutosize(target, options = {}) {
|
|
20
7
|
const input = options.input ?? ref("");
|
|
21
8
|
const styleProp = options.styleProp ?? "height";
|
package/dist/to-reactive.mjs
CHANGED
|
@@ -1,25 +1,5 @@
|
|
|
1
1
|
import { isRef, reactive, unref } from "vue";
|
|
2
2
|
//#region src/to-reactive.ts
|
|
3
|
-
/**
|
|
4
|
-
* Reactive object view over a ref that holds an object.
|
|
5
|
-
*
|
|
6
|
-
* Property reads and writes go to the ref's current object, so replacing the
|
|
7
|
-
* ref's value swaps the whole object behind a stable reactive proxy (handy
|
|
8
|
-
* for `v-bind="state"` or destructuring-free templates). Nested refs are
|
|
9
|
-
* unwrapped on read and written through on assignment. A non-ref object is
|
|
10
|
-
* simply passed to `reactive`. SSR-safe and nothing to dispose.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* const state = ref({ name: "a" });
|
|
15
|
-
* const view = toReactive(state);
|
|
16
|
-
* state.value = { name: "b" };
|
|
17
|
-
* view.name; // "b"
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @param objectRef Ref (or plain object) holding the object.
|
|
21
|
-
* @returns A reactive proxy following the ref.
|
|
22
|
-
*/
|
|
23
3
|
function toReactive(objectRef) {
|
|
24
4
|
if (!isRef(objectRef)) return reactive(objectRef);
|
|
25
5
|
return reactive(new Proxy(objectRef.value, {
|
package/dist/transition.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
2
|
import { shallowRef, toValue, watch } from "vue";
|
|
3
3
|
//#region src/transition.ts
|
|
4
|
-
/** Named cubic Bézier easing presets (the classic easings.net set). */
|
|
5
4
|
const TransitionPresets = {
|
|
6
5
|
linear: [
|
|
7
6
|
0,
|
|
@@ -203,12 +202,6 @@ function useTransition(source, options = {}) {
|
|
|
203
202
|
});
|
|
204
203
|
return output;
|
|
205
204
|
}
|
|
206
|
-
/**
|
|
207
|
-
* Build an easing function from cubic Bézier control points.
|
|
208
|
-
*
|
|
209
|
-
* @param points `[x1, y1, x2, y2]` with `x1`/`x2` in `[0, 1]`.
|
|
210
|
-
* @returns Easing function mapping progress to eased progress.
|
|
211
|
-
*/
|
|
212
205
|
function cubicBezier(points) {
|
|
213
206
|
const [x1, y1, x2, y2] = points;
|
|
214
207
|
const a = (p1, p2) => 1 - 3 * p2 + 3 * p1;
|
package/dist/until.mjs
CHANGED
|
@@ -9,31 +9,6 @@ const defaultScheduler = {
|
|
|
9
9
|
function createTimeoutError(timeout) {
|
|
10
10
|
return Object.assign(/* @__PURE__ */ new Error(`[VIZE_COMPOSE_UNTIL_TIMEOUT] condition not met within ${timeout}ms`), { code: "VIZE_COMPOSE_UNTIL_TIMEOUT" });
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Await a reactive source reaching a condition.
|
|
14
|
-
*
|
|
15
|
-
* Every matcher resolves immediately when the current value already
|
|
16
|
-
* satisfies it (except `changed`/`changedTimes`), and otherwise watches the
|
|
17
|
-
* source (`flush: "sync"` by default, which also works inside server-side
|
|
18
|
-
* `setup`). Result types are narrowed by the matcher: `toBeTruthy()` strips
|
|
19
|
-
* falsy members, `not.toBeNull()` strips `null`, `toMatch(guard)` follows the
|
|
20
|
-
* guard. Because a timeout rejects (it never resolves with an unmatched
|
|
21
|
-
* value), the narrowing is always sound. Watchers and timers are released
|
|
22
|
-
* as soon as the promise settles.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* const user = await until(currentUser).not.toBeNull({ timeout: 5_000 });
|
|
27
|
-
* const ready = await until(status).toBe("ready");
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @param source Ref or getter to observe.
|
|
31
|
-
* @throws Returned promises reject with an {@link UntilTimeoutError} on
|
|
32
|
-
* timeout, with the abort reason when the signal aborts, and with a
|
|
33
|
-
* `RangeError` tagged `VIZE_COMPOSE_UNTIL_INVALID_OPTION` for a negative or
|
|
34
|
-
* non-finite timeout or change count.
|
|
35
|
-
* @returns The fluent matcher chain.
|
|
36
|
-
*/
|
|
37
12
|
function until(source) {
|
|
38
13
|
const wait = (matches, options, checkInitial = true) => new Promise((resolve, reject) => {
|
|
39
14
|
const { timeout, signal, scheduler = defaultScheduler } = options;
|