@vizejs/ui 0.343.0 → 0.347.7
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/{button-D7sM9Xmj.d.mts → button-BMIqJ_M5.d.mts} +1 -1
- package/dist/button.d.mts +1 -1
- package/dist/button.mjs +1 -1
- package/dist/{checkbox-DkwZFC80.d.mts → checkbox-sbhaWekB.d.mts} +1 -1
- package/dist/checkbox.d.mts +1 -1
- package/dist/collection-CoOROaho.mjs +453 -0
- package/dist/collection-aHZ6Pf0e.d.mts +185 -0
- package/dist/collection.d.mts +2 -0
- package/dist/collection.mjs +2 -0
- package/dist/controllable-state.d.mts +1 -1
- package/dist/id-BSgJwErt.d.mts +127 -0
- package/dist/id-CPBdeoL3.mjs +137 -0
- package/dist/id.d.mts +2 -0
- package/dist/id.mjs +2 -0
- package/dist/index.d.mts +12 -6
- package/dist/index.mjs +9 -4
- package/dist/interaction-modality-CO-eQzNy.mjs +304 -0
- package/dist/interaction-modality-tee79ZBZ.d.mts +89 -0
- package/dist/interaction-modality.d.mts +2 -0
- package/dist/interaction-modality.mjs +2 -0
- package/dist/long-press-CRjjjJK2.d.mts +115 -0
- package/dist/long-press.d.mts +2 -0
- package/dist/long-press.mjs +246 -0
- package/dist/media-pdf.d.mts +1 -1
- package/dist/media-pdf.mjs +1 -1
- package/dist/media.d.mts +1 -1
- package/dist/media.mjs +1 -1
- package/dist/press-Bp57IOe2.mjs +615 -0
- package/dist/press-types-B8Ssxqg4.d.mts +112 -0
- package/dist/press.d.mts +14 -0
- package/dist/press.mjs +2 -0
- package/dist/primitive.d.mts +1 -1
- package/dist/primitive.mjs +1 -1
- package/dist/visually-hidden.d.mts +1 -1
- package/dist/visually-hidden.mjs +1 -1
- package/package.json +34 -7
- /package/dist/{button-8BOlFJNu.mjs → button-CaLxP2l2.mjs} +0 -0
- /package/dist/{controllable-state-DXsYJ3yl.d.mts → controllable-state-B9v6FClp.d.mts} +0 -0
- /package/dist/{pdf-source-COxN3A1l.d.mts → pdf-source-BbZKF_dS.d.mts} +0 -0
- /package/dist/{pdf-source-C52YE8tp.mjs → pdf-source-C9zNQd9l.mjs} +0 -0
- /package/dist/{primitive-DJB7pOf3.mjs → primitive-BE28SwD7.mjs} +0 -0
- /package/dist/{primitive-BtvwikH1.d.mts → primitive-Bog8qvd8.d.mts} +0 -0
- /package/dist/{visually-hidden-QENRapzW.mjs → visually-hidden-CTSV3ctZ.mjs} +0 -0
- /package/dist/{visually-hidden-BegtnMng.d.mts → visually-hidden-CekDwEwR.d.mts} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as useControllableState, n as ControllableStateOptions, r as StateUpdate, t as ControllableState } from "./controllable-state-
|
|
1
|
+
import { i as useControllableState, n as ControllableStateOptions, r as StateUpdate, t as ControllableState } from "./controllable-state-B9v6FClp.mjs";
|
|
2
2
|
export { ControllableState, ControllableStateOptions, StateUpdate, useControllableState };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
|
+
import { ComputedRef, MaybeRefOrGetter } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/deterministic-id.d.ts
|
|
5
|
+
declare const deterministicIdBrand: unique symbol;
|
|
6
|
+
/** A validated DOM identifier created or accepted by the deterministic ID system. */
|
|
7
|
+
type DeterministicId = string & {
|
|
8
|
+
readonly [deterministicIdBrand]: "DeterministicId";
|
|
9
|
+
};
|
|
10
|
+
/** Stable request, island, or subtree seed accepted by an ID scope. */
|
|
11
|
+
type DeterministicIdSeed = string | number;
|
|
12
|
+
/** Options for a root deterministic ID scope. */
|
|
13
|
+
interface DeterministicIdScopeOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Namespace prefix used by every ID in the scope.
|
|
16
|
+
*
|
|
17
|
+
* @default "vize"
|
|
18
|
+
*/
|
|
19
|
+
readonly prefix?: string;
|
|
20
|
+
/** Stable request, island, or application seed. */
|
|
21
|
+
readonly seed: DeterministicIdSeed;
|
|
22
|
+
}
|
|
23
|
+
/** Options for a nested deterministic ID scope. */
|
|
24
|
+
interface DeterministicIdChildScopeOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Namespace prefix for the child scope.
|
|
27
|
+
*
|
|
28
|
+
* @default The parent scope prefix
|
|
29
|
+
*/
|
|
30
|
+
readonly prefix?: string;
|
|
31
|
+
/** Stable seed that identifies the child subtree. */
|
|
32
|
+
readonly seed: DeterministicIdSeed;
|
|
33
|
+
}
|
|
34
|
+
/** One request-local namespace that allocates stable, collision-resistant DOM IDs. */
|
|
35
|
+
interface DeterministicIdScope {
|
|
36
|
+
/** Validated namespace prefix. */
|
|
37
|
+
readonly prefix: string;
|
|
38
|
+
/** Complete namespace shared by IDs allocated from this scope. */
|
|
39
|
+
readonly namespace: string;
|
|
40
|
+
/**
|
|
41
|
+
* Allocate the next ID during component setup.
|
|
42
|
+
*
|
|
43
|
+
* The sequence is intentionally independent from child-scope allocation so
|
|
44
|
+
* adding a nested provider cannot renumber sibling control IDs.
|
|
45
|
+
*/
|
|
46
|
+
readonly nextId: (hint?: string) => DeterministicId;
|
|
47
|
+
/** Create a request-local child namespace without sharing its ID counter. */
|
|
48
|
+
readonly createChild: (options: DeterministicIdChildScopeOptions) => DeterministicIdScope;
|
|
49
|
+
}
|
|
50
|
+
/** Options for {@link useDeterministicId}. */
|
|
51
|
+
interface DeterministicIdOptions {
|
|
52
|
+
/**
|
|
53
|
+
* Consumer-owned ID. `null` and `undefined` select the generated fallback.
|
|
54
|
+
*
|
|
55
|
+
* @default undefined
|
|
56
|
+
*/
|
|
57
|
+
readonly id?: MaybeRefOrGetter<string | null | undefined>;
|
|
58
|
+
/**
|
|
59
|
+
* Human-readable role appended to a generated ID.
|
|
60
|
+
*
|
|
61
|
+
* @default "id"
|
|
62
|
+
*/
|
|
63
|
+
readonly hint?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Prefix used when no {@link IdProvider} is present.
|
|
66
|
+
*
|
|
67
|
+
* @default "vize"
|
|
68
|
+
*/
|
|
69
|
+
readonly prefix?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validate and brand a consumer-owned HTML ID.
|
|
73
|
+
*
|
|
74
|
+
* HTML permits a broad character set, but forbids an empty value and ASCII
|
|
75
|
+
* whitespace. This contract additionally rejects ASCII controls. Consumers
|
|
76
|
+
* remain free to use Unicode and punctuation; CSS selectors may need
|
|
77
|
+
* `CSS.escape()` for those IDs.
|
|
78
|
+
*/
|
|
79
|
+
declare function toDeterministicId(value: string): DeterministicId;
|
|
80
|
+
/** Append a validated semantic part to an existing DOM ID. */
|
|
81
|
+
declare function deriveDeterministicId(id: string, part: string): DeterministicId;
|
|
82
|
+
/** Create an isolated deterministic ID scope for an application or SSR request. */
|
|
83
|
+
declare function createDeterministicIdScope(options: DeterministicIdScopeOptions): DeterministicIdScope;
|
|
84
|
+
/**
|
|
85
|
+
* Allocate one stable ID for the current component instance.
|
|
86
|
+
*
|
|
87
|
+
* Generated IDs use the nearest provider scope. Without a provider, Vue's
|
|
88
|
+
* hydration-stable `useId()` sequence supplies the seed, including a safe
|
|
89
|
+
* application `idPrefix`. The generated fallback is allocated once; changing
|
|
90
|
+
* an explicit reactive ID back to `undefined` restores that same fallback.
|
|
91
|
+
*/
|
|
92
|
+
declare function useDeterministicId(options?: DeterministicIdOptions): ComputedRef<DeterministicId>;
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/DeterministicIdProvider.vue.d.ts
|
|
95
|
+
type __VLS_Props = {
|
|
96
|
+
/**
|
|
97
|
+
* Namespace prefix for this subtree.
|
|
98
|
+
*
|
|
99
|
+
* @default The parent prefix when nested; otherwise "vize"
|
|
100
|
+
*/
|
|
101
|
+
readonly prefix?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Stable request, island, or subtree seed.
|
|
104
|
+
*
|
|
105
|
+
* @default Vue's SSR- and hydration-stable useId() value
|
|
106
|
+
*/
|
|
107
|
+
readonly seed?: string | number;
|
|
108
|
+
};
|
|
109
|
+
type __VLS_Slots = {
|
|
110
|
+
default(props: {
|
|
111
|
+
readonly namespace: string;
|
|
112
|
+
readonly prefix: string;
|
|
113
|
+
}): unknown;
|
|
114
|
+
};
|
|
115
|
+
declare const __VLS_base: _$vue.DefineComponent<__VLS_Props, {
|
|
116
|
+
namespace: string;
|
|
117
|
+
prefix: string;
|
|
118
|
+
}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
119
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
120
|
+
declare const _default: typeof __VLS_export;
|
|
121
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
122
|
+
new (): {
|
|
123
|
+
$slots: S;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
//#endregion
|
|
127
|
+
export { DeterministicIdScope as a, createDeterministicIdScope as c, useDeterministicId as d, DeterministicIdOptions as i, deriveDeterministicId as l, DeterministicId as n, DeterministicIdScopeOptions as o, DeterministicIdChildScopeOptions as r, DeterministicIdSeed as s, _default as t, toDeterministicId as u };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper-BVN2DL-U.mjs";
|
|
2
|
+
import { computed, defineComponent, getCurrentInstance, inject, provide, renderSlot, toValue, unref, useId } from "vue";
|
|
3
|
+
//#region src/deterministic-id.ts
|
|
4
|
+
const deterministicIdScopeKey = Symbol("VizeUiDeterministicIdScope");
|
|
5
|
+
const safePrefix = /^[A-Za-z][A-Za-z0-9_-]*$/;
|
|
6
|
+
const safeSegment = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
7
|
+
/**
|
|
8
|
+
* Validate and brand a consumer-owned HTML ID.
|
|
9
|
+
*
|
|
10
|
+
* HTML permits a broad character set, but forbids an empty value and ASCII
|
|
11
|
+
* whitespace. This contract additionally rejects ASCII controls. Consumers
|
|
12
|
+
* remain free to use Unicode and punctuation; CSS selectors may need
|
|
13
|
+
* `CSS.escape()` for those IDs.
|
|
14
|
+
*/
|
|
15
|
+
function toDeterministicId(value) {
|
|
16
|
+
if (!isValidHtmlId(value)) throw new Error("VIZE_UI_ID_VALUE: an id must be non-empty and contain no ASCII whitespace or controls");
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function isValidHtmlId(value) {
|
|
20
|
+
if (value.length === 0) return false;
|
|
21
|
+
for (let index = 0; index < value.length; index++) {
|
|
22
|
+
const code = value.charCodeAt(index);
|
|
23
|
+
if (code <= 32 || code === 127) return false;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
/** Append a validated semantic part to an existing DOM ID. */
|
|
28
|
+
function deriveDeterministicId(id, part) {
|
|
29
|
+
return toDeterministicId(`${toDeterministicId(id)}-${normalizeSegment(part, "part")}`);
|
|
30
|
+
}
|
|
31
|
+
/** Create an isolated deterministic ID scope for an application or SSR request. */
|
|
32
|
+
function createDeterministicIdScope(options) {
|
|
33
|
+
const prefix = normalizePrefix(options.prefix ?? "vize");
|
|
34
|
+
return createScope(prefix, `${prefix}-${normalizeSeed(options.seed)}`);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Allocate one stable ID for the current component instance.
|
|
38
|
+
*
|
|
39
|
+
* Generated IDs use the nearest provider scope. Without a provider, Vue's
|
|
40
|
+
* hydration-stable `useId()` sequence supplies the seed, including a safe
|
|
41
|
+
* application `idPrefix`. The generated fallback is allocated once; changing
|
|
42
|
+
* an explicit reactive ID back to `undefined` restores that same fallback.
|
|
43
|
+
*/
|
|
44
|
+
function useDeterministicId(options = {}) {
|
|
45
|
+
if (getCurrentInstance() === null) throw new Error("VIZE_UI_ID_SETUP: useDeterministicId() must run during component setup");
|
|
46
|
+
const vueId = useId();
|
|
47
|
+
const scope = useOptionalDeterministicIdScope();
|
|
48
|
+
const hint = normalizeSegment(options.hint ?? "id", "hint");
|
|
49
|
+
const generated = scope?.nextId(hint) ?? toDeterministicId(`${normalizePrefix(options.prefix ?? "vize")}-${normalizeSeed(vueId)}-${hint}`);
|
|
50
|
+
return computed(() => {
|
|
51
|
+
const explicit = options.id === void 0 ? void 0 : toValue(options.id);
|
|
52
|
+
return explicit === null || explicit === void 0 ? generated : toDeterministicId(explicit);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** @internal Provide the scope owned by `IdProvider.vue`. */
|
|
56
|
+
function provideDeterministicIdScope(scope) {
|
|
57
|
+
provide(deterministicIdScopeKey, scope);
|
|
58
|
+
return scope;
|
|
59
|
+
}
|
|
60
|
+
/** @internal Read the nearest provider without requiring one. */
|
|
61
|
+
function useOptionalDeterministicIdScope() {
|
|
62
|
+
return inject(deterministicIdScopeKey, void 0);
|
|
63
|
+
}
|
|
64
|
+
function createScope(prefix, namespace) {
|
|
65
|
+
let idSequence = 0;
|
|
66
|
+
let childSequence = 0;
|
|
67
|
+
return Object.freeze({
|
|
68
|
+
prefix,
|
|
69
|
+
namespace,
|
|
70
|
+
nextId: (hint = "id") => toDeterministicId(`${namespace}-${normalizeSegment(hint, "hint")}-${idSequence++}`),
|
|
71
|
+
createChild: (options) => {
|
|
72
|
+
const childPrefix = options.prefix === void 0 ? prefix : normalizePrefix(options.prefix);
|
|
73
|
+
const childSeed = normalizeSeed(options.seed);
|
|
74
|
+
const inheritedNamespace = `${namespace}-scope-${childSequence++}-${childSeed}`;
|
|
75
|
+
return createScope(childPrefix, childPrefix === prefix ? inheritedNamespace : `${childPrefix}-${inheritedNamespace}`);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function normalizePrefix(value) {
|
|
80
|
+
if (!safePrefix.test(value)) throw new Error("VIZE_UI_ID_PREFIX: a prefix must start with an ASCII letter and contain only letters, digits, _ or -");
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
function normalizeSeed(value) {
|
|
84
|
+
if (typeof value === "number") {
|
|
85
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new Error("VIZE_UI_ID_SEED: a numeric seed must be a non-negative safe integer");
|
|
86
|
+
return String(value);
|
|
87
|
+
}
|
|
88
|
+
return normalizeSegment(value, "seed");
|
|
89
|
+
}
|
|
90
|
+
function normalizeSegment(value, role) {
|
|
91
|
+
if (!safeSegment.test(value)) throw new Error(`VIZE_UI_ID_${role.toUpperCase()}: ${role} must contain only ASCII letters, digits, _ or - and may not start with punctuation`);
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/DeterministicIdProvider.vue
|
|
96
|
+
var DeterministicIdProvider_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
|
|
97
|
+
__name: "DeterministicIdProvider",
|
|
98
|
+
props: {
|
|
99
|
+
prefix: {
|
|
100
|
+
type: String,
|
|
101
|
+
required: false,
|
|
102
|
+
default: () => void 0
|
|
103
|
+
},
|
|
104
|
+
seed: {
|
|
105
|
+
type: [String, Number],
|
|
106
|
+
required: false,
|
|
107
|
+
default: () => void 0
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
setup(__props, { expose: __expose }) {
|
|
111
|
+
const vueSeed = useId();
|
|
112
|
+
const parent = useOptionalDeterministicIdScope();
|
|
113
|
+
const resolvedSeed = __props.seed ?? vueSeed;
|
|
114
|
+
const scope = parent === void 0 ? createDeterministicIdScope({
|
|
115
|
+
prefix: __props.prefix ?? "vize",
|
|
116
|
+
seed: resolvedSeed
|
|
117
|
+
}) : __props.prefix === void 0 ? parent.createChild({ seed: resolvedSeed }) : parent.createChild({
|
|
118
|
+
prefix: __props.prefix,
|
|
119
|
+
seed: resolvedSeed
|
|
120
|
+
});
|
|
121
|
+
provideDeterministicIdScope(scope);
|
|
122
|
+
const namespace = scope.namespace;
|
|
123
|
+
const resolvedPrefix = scope.prefix;
|
|
124
|
+
__expose({
|
|
125
|
+
namespace,
|
|
126
|
+
prefix: resolvedPrefix
|
|
127
|
+
});
|
|
128
|
+
return (_ctx, _cache) => {
|
|
129
|
+
return renderSlot(_ctx.$slots, "default", {
|
|
130
|
+
namespace: unref(namespace),
|
|
131
|
+
prefix: unref(resolvedPrefix)
|
|
132
|
+
}, void 0, true);
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}), [["__scopeId", "data-v-2521c635"]]);
|
|
136
|
+
//#endregion
|
|
137
|
+
export { useDeterministicId as a, toDeterministicId as i, createDeterministicIdScope as n, deriveDeterministicId as r, DeterministicIdProvider_default as t };
|
package/dist/id.d.mts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DeterministicIdScope, c as createDeterministicIdScope, d as useDeterministicId, i as DeterministicIdOptions, l as deriveDeterministicId, n as DeterministicId, o as DeterministicIdScopeOptions, r as DeterministicIdChildScopeOptions, s as DeterministicIdSeed, t as _default, u as toDeterministicId } from "./id-BSgJwErt.mjs";
|
|
2
|
+
export { DeterministicId, DeterministicIdChildScopeOptions, DeterministicIdOptions, DeterministicIdScope, DeterministicIdScopeOptions, DeterministicIdSeed, _default as IdProvider, createDeterministicIdScope, deriveDeterministicId, toDeterministicId, useDeterministicId };
|
package/dist/id.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as useDeterministicId, i as toDeterministicId, n as createDeterministicIdScope, r as deriveDeterministicId, t as DeterministicIdProvider_default } from "./id-CPBdeoL3.mjs";
|
|
2
|
+
export { DeterministicIdProvider_default as IdProvider, createDeterministicIdScope, deriveDeterministicId, toDeterministicId, useDeterministicId };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { i as getButtonKeyboardAction, n as ButtonKeyboardAction, r as ButtonKeyboardPhase, t as _default } from "./button-
|
|
2
|
-
import { n as PrimitiveElement, r as _default$
|
|
3
|
-
import { n as CheckboxState, r as getCheckboxState, t as _default$1 } from "./checkbox-
|
|
4
|
-
import { i as useControllableState, n as ControllableStateOptions, r as StateUpdate, t as ControllableState } from "./controllable-state-
|
|
1
|
+
import { i as getButtonKeyboardAction, n as ButtonKeyboardAction, r as ButtonKeyboardPhase, t as _default } from "./button-BMIqJ_M5.mjs";
|
|
2
|
+
import { n as PrimitiveElement, r as _default$3, t as PrimitiveAs } from "./primitive-Bog8qvd8.mjs";
|
|
3
|
+
import { n as CheckboxState, r as getCheckboxState, t as _default$1 } from "./checkbox-sbhaWekB.mjs";
|
|
4
|
+
import { i as useControllableState, n as ControllableStateOptions, r as StateUpdate, t as ControllableState } from "./controllable-state-B9v6FClp.mjs";
|
|
5
|
+
import { a as CollectionActiveChangeReason, c as CollectionItemInput, d as CollectionNavigationOptions, f as CollectionRegistration, h as CollectionTextSearchOptions, i as CollectionActiveChange, l as CollectionKey, m as CollectionRegistryOptions, n as normalizeCollectionTextValue, o as CollectionDisabledBehavior, p as CollectionRegistry, r as createCollectionRegistry, s as CollectionItem, t as extractCollectionTextValue, u as CollectionNavigationDirection } from "./collection-aHZ6Pf0e.mjs";
|
|
5
6
|
import { ComponentContext, createContext } from "./context.mjs";
|
|
6
|
-
import { t as _default$
|
|
7
|
-
|
|
7
|
+
import { a as DeterministicIdScope, c as createDeterministicIdScope, d as useDeterministicId, i as DeterministicIdOptions, l as deriveDeterministicId, n as DeterministicId, o as DeterministicIdScopeOptions, r as DeterministicIdChildScopeOptions, s as DeterministicIdSeed, t as _default$2, u as toDeterministicId } from "./id-BSgJwErt.mjs";
|
|
8
|
+
import { a as InteractionModalityChange, c as InteractionModalityTracker, i as InteractionModality, n as isElementFocusVisible, o as InteractionModalityChangeReason, r as useInteractionModality, s as InteractionModalityOptions, t as createInteractionModalityTracker } from "./interaction-modality-tee79ZBZ.mjs";
|
|
9
|
+
import { a as PressOptions, i as PressKeyboardBehavior, n as PressEvent, o as PressPointerType, r as PressEventType, s as PressProps, t as PressController } from "./press-types-B8Ssxqg4.mjs";
|
|
10
|
+
import { a as LongPressEventType, c as LongPressProps, i as LongPressEvent, n as useLongPress, o as LongPressOptions, r as LongPressController, s as LongPressPointerType, t as createLongPress } from "./long-press-CRjjjJK2.mjs";
|
|
11
|
+
import { createPress, usePress } from "./press.mjs";
|
|
12
|
+
import { t as _default$4 } from "./visually-hidden-CekDwEwR.mjs";
|
|
13
|
+
export { _default as Button, ButtonKeyboardAction, ButtonKeyboardPhase, _default$1 as Checkbox, CheckboxState, CollectionActiveChange, CollectionActiveChangeReason, CollectionDisabledBehavior, CollectionItem, CollectionItemInput, CollectionKey, CollectionNavigationDirection, CollectionNavigationOptions, CollectionRegistration, CollectionRegistry, CollectionRegistryOptions, CollectionTextSearchOptions, ComponentContext, ControllableState, ControllableStateOptions, DeterministicId, DeterministicIdChildScopeOptions, DeterministicIdOptions, DeterministicIdScope, DeterministicIdScopeOptions, DeterministicIdSeed, _default$2 as IdProvider, InteractionModality, InteractionModalityChange, InteractionModalityChangeReason, InteractionModalityOptions, InteractionModalityTracker, LongPressController, LongPressEvent, LongPressEventType, LongPressOptions, LongPressPointerType, LongPressProps, PressController, PressEvent, PressEventType, PressKeyboardBehavior, PressOptions, PressPointerType, PressProps, _default$3 as Primitive, PrimitiveAs, PrimitiveElement, StateUpdate, _default$4 as VisuallyHidden, createCollectionRegistry, createContext, createDeterministicIdScope, createInteractionModalityTracker, createLongPress, createPress, deriveDeterministicId, extractCollectionTextValue, getButtonKeyboardAction, getCheckboxState, isElementFocusVisible, normalizeCollectionTextValue, toDeterministicId, useControllableState, useDeterministicId, useInteractionModality, useLongPress, usePress };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { n as getCheckboxState, t as CheckboxControl_default } from "./checkbox-B4y9GUen.mjs";
|
|
2
2
|
import { useControllableState } from "./controllable-state.mjs";
|
|
3
|
+
import { n as extractCollectionTextValue, r as normalizeCollectionTextValue, t as createCollectionRegistry } from "./collection-CoOROaho.mjs";
|
|
3
4
|
import { createContext } from "./context.mjs";
|
|
4
|
-
import { n as getButtonKeyboardAction, t as ActionButton_default } from "./button-
|
|
5
|
-
import { t as
|
|
6
|
-
import { t as
|
|
7
|
-
|
|
5
|
+
import { n as getButtonKeyboardAction, t as ActionButton_default } from "./button-CaLxP2l2.mjs";
|
|
6
|
+
import { a as useDeterministicId, i as toDeterministicId, n as createDeterministicIdScope, r as deriveDeterministicId, t as DeterministicIdProvider_default } from "./id-CPBdeoL3.mjs";
|
|
7
|
+
import { n as isElementFocusVisible, r as useInteractionModality, t as createInteractionModalityTracker } from "./interaction-modality-CO-eQzNy.mjs";
|
|
8
|
+
import { n as usePress, t as createPress } from "./press-Bp57IOe2.mjs";
|
|
9
|
+
import { createLongPress, useLongPress } from "./long-press.mjs";
|
|
10
|
+
import { t as PrimitiveElement_default } from "./primitive-BE28SwD7.mjs";
|
|
11
|
+
import { t as VisuallyHidden_default } from "./visually-hidden-CTSV3ctZ.mjs";
|
|
12
|
+
export { ActionButton_default as Button, CheckboxControl_default as Checkbox, DeterministicIdProvider_default as IdProvider, PrimitiveElement_default as Primitive, VisuallyHidden_default as VisuallyHidden, createCollectionRegistry, createContext, createDeterministicIdScope, createInteractionModalityTracker, createLongPress, createPress, deriveDeterministicId, extractCollectionTextValue, getButtonKeyboardAction, getCheckboxState, isElementFocusVisible, normalizeCollectionTextValue, toDeterministicId, useControllableState, useDeterministicId, useInteractionModality, useLongPress, usePress };
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { computed, getCurrentScope, isRef, onScopeDispose, shallowReadonly, shallowRef, toValue, watch } from "vue";
|
|
2
|
+
//#region src/interaction-modality-events.ts
|
|
3
|
+
const modifierKeys = new Set([
|
|
4
|
+
"Alt",
|
|
5
|
+
"AltGraph",
|
|
6
|
+
"Control",
|
|
7
|
+
"Meta"
|
|
8
|
+
]);
|
|
9
|
+
/** Classify keyboard intent while excluding composition and modified shortcuts. */
|
|
10
|
+
function classifyKeyboardEvent(event) {
|
|
11
|
+
if (event.isComposing || event.altKey || event.ctrlKey || event.metaKey || modifierKeys.has(event.key)) return null;
|
|
12
|
+
return {
|
|
13
|
+
modality: "keyboard",
|
|
14
|
+
reason: "keyboard",
|
|
15
|
+
originalEvent: event
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Map pointer hardware into the stable public modality vocabulary. */
|
|
19
|
+
function classifyPointerEvent(event) {
|
|
20
|
+
if (event.pointerId === -1 && event.pointerType === "") return {
|
|
21
|
+
modality: "virtual",
|
|
22
|
+
reason: "virtual",
|
|
23
|
+
originalEvent: event
|
|
24
|
+
};
|
|
25
|
+
const modality = event.pointerType === "touch" ? "touch" : "pointer";
|
|
26
|
+
return {
|
|
27
|
+
modality,
|
|
28
|
+
reason: modality,
|
|
29
|
+
originalEvent: event
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Classify coordinate-free clicks used by keyboards and assistive technology. */
|
|
33
|
+
function classifyVirtualClick(event, current) {
|
|
34
|
+
if (event.detail !== 0 || current === "keyboard") return null;
|
|
35
|
+
return {
|
|
36
|
+
modality: "virtual",
|
|
37
|
+
reason: "virtual",
|
|
38
|
+
originalEvent: event
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/interaction-modality-hub.ts
|
|
43
|
+
const hubs = /* @__PURE__ */ new WeakMap();
|
|
44
|
+
/** Install one capture listener set for all consumers in a document. */
|
|
45
|
+
function createHub(document, initialModality) {
|
|
46
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
47
|
+
const pendingUpdates = [];
|
|
48
|
+
let publishing = false;
|
|
49
|
+
const hub = {
|
|
50
|
+
subscribers,
|
|
51
|
+
modality: initialModality,
|
|
52
|
+
disposeListeners: () => void 0,
|
|
53
|
+
publish: () => false
|
|
54
|
+
};
|
|
55
|
+
hub.publish = (update) => {
|
|
56
|
+
if (hub.modality === update.modality && pendingUpdates.length === 0) return false;
|
|
57
|
+
pendingUpdates.push(update);
|
|
58
|
+
if (publishing) return true;
|
|
59
|
+
publishing = true;
|
|
60
|
+
const errors = [];
|
|
61
|
+
try {
|
|
62
|
+
while (pendingUpdates.length > 0) {
|
|
63
|
+
const nextUpdate = pendingUpdates.shift();
|
|
64
|
+
if (hub.modality === nextUpdate.modality) continue;
|
|
65
|
+
hub.modality = nextUpdate.modality;
|
|
66
|
+
for (const subscriber of Array.from(subscribers)) {
|
|
67
|
+
if (!subscribers.has(subscriber)) continue;
|
|
68
|
+
try {
|
|
69
|
+
subscriber(nextUpdate);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
errors.push(error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} finally {
|
|
76
|
+
publishing = false;
|
|
77
|
+
}
|
|
78
|
+
if (errors.length === 1) throw errors[0];
|
|
79
|
+
if (errors.length > 1) throw new AggregateError(errors, "Interaction modality subscribers failed");
|
|
80
|
+
return true;
|
|
81
|
+
};
|
|
82
|
+
let lastTouchTime = Number.NEGATIVE_INFINITY;
|
|
83
|
+
const onKeyDown = (event) => {
|
|
84
|
+
const update = classifyKeyboardEvent(event);
|
|
85
|
+
if (update) hub.publish(update);
|
|
86
|
+
};
|
|
87
|
+
const onPointerDown = (event) => hub.publish(classifyPointerEvent(event));
|
|
88
|
+
const onMouseDown = (event) => {
|
|
89
|
+
const elapsedSinceTouch = event.timeStamp - lastTouchTime;
|
|
90
|
+
if (elapsedSinceTouch >= 0 && elapsedSinceTouch < 800) return;
|
|
91
|
+
hub.publish({
|
|
92
|
+
modality: "pointer",
|
|
93
|
+
reason: "pointer",
|
|
94
|
+
originalEvent: event
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const onTouchStart = (event) => {
|
|
98
|
+
lastTouchTime = event.timeStamp;
|
|
99
|
+
hub.publish({
|
|
100
|
+
modality: "touch",
|
|
101
|
+
reason: "touch",
|
|
102
|
+
originalEvent: event
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
const onClick = (event) => {
|
|
106
|
+
const update = classifyVirtualClick(event, hub.modality);
|
|
107
|
+
if (update) hub.publish(update);
|
|
108
|
+
};
|
|
109
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
110
|
+
document.addEventListener("click", onClick, true);
|
|
111
|
+
const supportsPointerEvents = Boolean(document.defaultView?.PointerEvent);
|
|
112
|
+
if (supportsPointerEvents) document.addEventListener("pointerdown", onPointerDown, true);
|
|
113
|
+
else {
|
|
114
|
+
document.addEventListener("mousedown", onMouseDown, true);
|
|
115
|
+
document.addEventListener("touchstart", onTouchStart, true);
|
|
116
|
+
}
|
|
117
|
+
hub.disposeListeners = () => {
|
|
118
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
119
|
+
document.removeEventListener("click", onClick, true);
|
|
120
|
+
if (supportsPointerEvents) document.removeEventListener("pointerdown", onPointerDown, true);
|
|
121
|
+
else {
|
|
122
|
+
document.removeEventListener("mousedown", onMouseDown, true);
|
|
123
|
+
document.removeEventListener("touchstart", onTouchStart, true);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
return hub;
|
|
127
|
+
}
|
|
128
|
+
/** Subscribe to shared document state and return an idempotent release callback. */
|
|
129
|
+
function subscribeToDocumentModality(document, initialModality, subscriber) {
|
|
130
|
+
let hub = hubs.get(document);
|
|
131
|
+
if (!hub) {
|
|
132
|
+
hub = createHub(document, initialModality);
|
|
133
|
+
hubs.set(document, hub);
|
|
134
|
+
}
|
|
135
|
+
hub.subscribers.add(subscriber);
|
|
136
|
+
let released = false;
|
|
137
|
+
return {
|
|
138
|
+
current: hub.modality,
|
|
139
|
+
release: () => {
|
|
140
|
+
if (released) return;
|
|
141
|
+
released = true;
|
|
142
|
+
hub?.subscribers.delete(subscriber);
|
|
143
|
+
if (hub?.subscribers.size === 0) {
|
|
144
|
+
hub.disposeListeners();
|
|
145
|
+
hubs.delete(document);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Synchronize an explicit consumer update with every peer in a document. */
|
|
151
|
+
function publishDocumentModality(document, update) {
|
|
152
|
+
return hubs.get(document)?.publish(update) ?? false;
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/interaction-modality.ts
|
|
156
|
+
const disposedDiagnostic = "VIZE_UI_INTERACTION_MODALITY_DISPOSED";
|
|
157
|
+
const invalidDocumentDiagnostic = "VIZE_UI_INTERACTION_MODALITY_DOCUMENT";
|
|
158
|
+
const setupDiagnostic = "VIZE_UI_INTERACTION_MODALITY_SETUP";
|
|
159
|
+
const invalidValueDiagnostic = "VIZE_UI_INTERACTION_MODALITY_VALUE";
|
|
160
|
+
const modalities = new Set([
|
|
161
|
+
"keyboard",
|
|
162
|
+
"pointer",
|
|
163
|
+
"touch",
|
|
164
|
+
"virtual"
|
|
165
|
+
]);
|
|
166
|
+
function defaultDocument() {
|
|
167
|
+
return typeof globalThis.document === "undefined" ? null : globalThis.document;
|
|
168
|
+
}
|
|
169
|
+
/** Accept cross-realm documents without relying on an unreliable instanceof check. */
|
|
170
|
+
function toDocument(value) {
|
|
171
|
+
if (value == null) return null;
|
|
172
|
+
if (value.nodeType !== 9 || typeof value.addEventListener !== "function" || typeof value.removeEventListener !== "function") throw new TypeError(`${invalidDocumentDiagnostic}: expected a Document, null, or undefined`);
|
|
173
|
+
return value;
|
|
174
|
+
}
|
|
175
|
+
/** Validate JavaScript callers without widening the closed TypeScript union. */
|
|
176
|
+
function toModality(value) {
|
|
177
|
+
if (value === null || modalities.has(value)) return value;
|
|
178
|
+
throw new TypeError(`${invalidValueDiagnostic}: expected keyboard, pointer, touch, virtual, or null`);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Create an SSR-safe, document-scoped interaction-modality observer.
|
|
182
|
+
*
|
|
183
|
+
* Trackers in one document share native capture listeners and state. Separate
|
|
184
|
+
* documents, including iframes, remain isolated. Call {@link InteractionModalityTracker.dispose}
|
|
185
|
+
* when using this factory outside a Vue effect scope.
|
|
186
|
+
*/
|
|
187
|
+
function createInteractionModalityTracker(options = {}) {
|
|
188
|
+
const ownerDocument = shallowRef(null);
|
|
189
|
+
const modality = shallowRef(toModality(options.initialModality ?? null));
|
|
190
|
+
let releaseDocument = null;
|
|
191
|
+
let disposed = false;
|
|
192
|
+
const assertActive = () => {
|
|
193
|
+
if (disposed) throw new Error(`${disposedDiagnostic}: the tracker has been disposed`);
|
|
194
|
+
};
|
|
195
|
+
const apply = (update) => {
|
|
196
|
+
if (modality.value === update.modality) return false;
|
|
197
|
+
const previousModality = modality.value;
|
|
198
|
+
modality.value = update.modality;
|
|
199
|
+
const change = Object.freeze({
|
|
200
|
+
modality: update.modality,
|
|
201
|
+
previousModality,
|
|
202
|
+
reason: update.reason,
|
|
203
|
+
originalEvent: update.originalEvent,
|
|
204
|
+
document: ownerDocument.value
|
|
205
|
+
});
|
|
206
|
+
options.onChange?.(change);
|
|
207
|
+
return true;
|
|
208
|
+
};
|
|
209
|
+
const releaseCurrentDocument = () => {
|
|
210
|
+
const changed = ownerDocument.value !== null;
|
|
211
|
+
releaseDocument?.();
|
|
212
|
+
releaseDocument = null;
|
|
213
|
+
ownerDocument.value = null;
|
|
214
|
+
return changed;
|
|
215
|
+
};
|
|
216
|
+
const attach = (nextDocument) => {
|
|
217
|
+
assertActive();
|
|
218
|
+
const resolved = toDocument(nextDocument);
|
|
219
|
+
if (ownerDocument.value === resolved) return false;
|
|
220
|
+
releaseCurrentDocument();
|
|
221
|
+
if (!resolved) return true;
|
|
222
|
+
ownerDocument.value = resolved;
|
|
223
|
+
try {
|
|
224
|
+
const subscription = subscribeToDocumentModality(resolved, modality.value, apply);
|
|
225
|
+
releaseDocument = subscription.release;
|
|
226
|
+
if (subscription.current !== modality.value) apply({
|
|
227
|
+
modality: subscription.current,
|
|
228
|
+
reason: "document",
|
|
229
|
+
originalEvent: null
|
|
230
|
+
});
|
|
231
|
+
} catch (error) {
|
|
232
|
+
releaseCurrentDocument();
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
return true;
|
|
236
|
+
};
|
|
237
|
+
const detach = () => {
|
|
238
|
+
assertActive();
|
|
239
|
+
return releaseCurrentDocument();
|
|
240
|
+
};
|
|
241
|
+
const setModality = (nextModality) => {
|
|
242
|
+
assertActive();
|
|
243
|
+
const update = {
|
|
244
|
+
modality: toModality(nextModality),
|
|
245
|
+
reason: "manual",
|
|
246
|
+
originalEvent: null
|
|
247
|
+
};
|
|
248
|
+
if (ownerDocument.value) return publishDocumentModality(ownerDocument.value, update);
|
|
249
|
+
return apply(update);
|
|
250
|
+
};
|
|
251
|
+
let stopDocumentWatch = () => void 0;
|
|
252
|
+
if (options.document === void 0) attach(defaultDocument());
|
|
253
|
+
else if (isRef(options.document) || typeof options.document === "function") stopDocumentWatch = watch(() => toValue(options.document), (nextDocument) => attach(toDocument(nextDocument)), {
|
|
254
|
+
flush: "sync",
|
|
255
|
+
immediate: true
|
|
256
|
+
});
|
|
257
|
+
else attach(toDocument(options.document));
|
|
258
|
+
const dispose = () => {
|
|
259
|
+
if (disposed) return;
|
|
260
|
+
stopDocumentWatch();
|
|
261
|
+
releaseCurrentDocument();
|
|
262
|
+
disposed = true;
|
|
263
|
+
};
|
|
264
|
+
return Object.freeze({
|
|
265
|
+
document: shallowReadonly(ownerDocument),
|
|
266
|
+
modality: shallowReadonly(modality),
|
|
267
|
+
isFocusVisible: computed(() => modality.value === "keyboard" || modality.value === "virtual"),
|
|
268
|
+
attach,
|
|
269
|
+
detach,
|
|
270
|
+
setModality,
|
|
271
|
+
dispose
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Create a tracker owned by the current Vue effect scope.
|
|
276
|
+
*
|
|
277
|
+
* The tracker is disposed automatically when its component or effect scope is
|
|
278
|
+
* destroyed, preventing document-listener leaks.
|
|
279
|
+
*/
|
|
280
|
+
function useInteractionModality(options = {}) {
|
|
281
|
+
if (!getCurrentScope()) throw new Error(`${setupDiagnostic}: use inside component setup or an active effect scope`);
|
|
282
|
+
const tracker = createInteractionModalityTracker(options);
|
|
283
|
+
onScopeDispose(tracker.dispose);
|
|
284
|
+
return tracker;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Determine whether a focused element should expose its focus indicator.
|
|
288
|
+
*
|
|
289
|
+
* Native `:focus-visible` semantics take precedence. The modality fallback is
|
|
290
|
+
* used only when the selector is unsupported, preserving text-input and
|
|
291
|
+
* platform heuristics implemented by the browser.
|
|
292
|
+
*/
|
|
293
|
+
function isElementFocusVisible(element, modality) {
|
|
294
|
+
if (!element) return false;
|
|
295
|
+
const root = element.getRootNode();
|
|
296
|
+
if ((root && "activeElement" in root ? root.activeElement : element.ownerDocument.activeElement) !== element) return false;
|
|
297
|
+
try {
|
|
298
|
+
return element.matches(":focus-visible");
|
|
299
|
+
} catch {
|
|
300
|
+
return modality === "keyboard" || modality === "virtual";
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
//#endregion
|
|
304
|
+
export { isElementFocusVisible as n, useInteractionModality as r, createInteractionModalityTracker as t };
|