@vizejs/ui 0.347.7 → 0.350.2

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 (96) hide show
  1. package/dist/{button-BMIqJ_M5.d.mts → button-CVX8UBXj.d.mts} +6 -7
  2. package/dist/{button-CaLxP2l2.mjs → button-DT8AKlds.mjs} +2 -2
  3. package/dist/button.d.mts +1 -1
  4. package/dist/button.mjs +1 -1
  5. package/dist/catalog.d.mts +541 -0
  6. package/dist/catalog.mjs +784 -0
  7. package/dist/{checkbox-B4y9GUen.mjs → checkbox-BgIvwjyC.mjs} +2 -2
  8. package/dist/{checkbox-sbhaWekB.d.mts → checkbox-DP3_ko7D.d.mts} +7 -8
  9. package/dist/checkbox.d.mts +1 -1
  10. package/dist/checkbox.mjs +1 -1
  11. package/dist/collection.d.mts +2 -2
  12. package/dist/collection.mjs +1 -1
  13. package/dist/composite-navigation-QINW9GLy.d.mts +115 -0
  14. package/dist/composite-navigation-Skx3LZsv.mjs +354 -0
  15. package/dist/composite-navigation.d.mts +2 -0
  16. package/dist/composite-navigation.mjs +2 -0
  17. package/dist/controllable-state.d.mts +1 -1
  18. package/dist/dismissable-layer-4icKahVs.d.mts +119 -0
  19. package/dist/dismissable-layer-CwG1gtdz.mjs +488 -0
  20. package/dist/dismissable-layer.d.mts +2 -0
  21. package/dist/dismissable-layer.mjs +2 -0
  22. package/dist/focus-CAWi_I-0.mjs +318 -0
  23. package/dist/focus-K6dOifoZ.d.mts +112 -0
  24. package/dist/focus-guards-Bt0C-0qS.d.mts +81 -0
  25. package/dist/focus-guards-DhMPQAT8.mjs +299 -0
  26. package/dist/focus-guards.d.mts +2 -0
  27. package/dist/focus-guards.mjs +2 -0
  28. package/dist/focus-scope-CavhKWx0.d.mts +100 -0
  29. package/dist/focus-scope-D9U1aj67.mjs +340 -0
  30. package/dist/focus-scope-dom-DBwNEWxG.mjs +264 -0
  31. package/dist/focus-scope.d.mts +2 -0
  32. package/dist/focus-scope.mjs +2 -0
  33. package/dist/focus.d.mts +2 -0
  34. package/dist/focus.mjs +2 -0
  35. package/dist/hover-BXwwbSaO.d.mts +80 -0
  36. package/dist/hover.d.mts +2 -0
  37. package/dist/hover.mjs +197 -0
  38. package/dist/{id-BSgJwErt.d.mts → id-5OAUyVPd.d.mts} +2 -3
  39. package/dist/{id-CPBdeoL3.mjs → id-mziSyAse.mjs} +2 -2
  40. package/dist/id.d.mts +2 -2
  41. package/dist/id.mjs +1 -1
  42. package/dist/index.d.mts +22 -11
  43. package/dist/index.mjs +21 -10
  44. package/dist/inert-outside-CyqtoKQ4.mjs +346 -0
  45. package/dist/inert-outside-tuHRmaqJ.d.mts +43 -0
  46. package/dist/inert-outside.d.mts +2 -0
  47. package/dist/inert-outside.mjs +2 -0
  48. package/dist/interaction-modality.d.mts +2 -2
  49. package/dist/interaction-modality.mjs +1 -1
  50. package/dist/long-press-Dsul69gk.mjs +340 -0
  51. package/dist/{long-press-CRjjjJK2.d.mts → long-press-cll6z2K9.d.mts} +8 -18
  52. package/dist/long-press.d.mts +2 -2
  53. package/dist/long-press.mjs +1 -245
  54. package/dist/media-pdf.d.mts +1 -1
  55. package/dist/media-pdf.mjs +1 -1
  56. package/dist/media.d.mts +1 -1
  57. package/dist/media.mjs +1 -1
  58. package/dist/move-BOmXDYbh.d.mts +103 -0
  59. package/dist/move-BVvMHzxr.mjs +386 -0
  60. package/dist/move.d.mts +2 -0
  61. package/dist/move.mjs +2 -0
  62. package/dist/{press-Bp57IOe2.mjs → press-N_mE3Mgx.mjs} +3 -149
  63. package/dist/press-event-Cd2OPpmw.mjs +149 -0
  64. package/dist/press.d.mts +1 -1
  65. package/dist/press.mjs +1 -1
  66. package/dist/{primitive-BE28SwD7.mjs → primitive-BX31dogp.mjs} +2 -2
  67. package/dist/{primitive-Bog8qvd8.d.mts → primitive-C8jW7DLd.d.mts} +3 -4
  68. package/dist/primitive.d.mts +1 -1
  69. package/dist/primitive.mjs +1 -1
  70. package/dist/scroll-lock-BgVtX4wT.d.mts +49 -0
  71. package/dist/scroll-lock-Ckbmm0-J.mjs +313 -0
  72. package/dist/scroll-lock.d.mts +2 -0
  73. package/dist/scroll-lock.mjs +2 -0
  74. package/dist/spatial-navigation-CHj9mDZH.d.mts +106 -0
  75. package/dist/spatial-navigation-D6-UDavU.mjs +301 -0
  76. package/dist/spatial-navigation.d.mts +2 -0
  77. package/dist/spatial-navigation.mjs +2 -0
  78. package/dist/typeahead-B7KDxE_u.mjs +175 -0
  79. package/dist/typeahead-BbgUB2Bj.d.mts +71 -0
  80. package/dist/typeahead.d.mts +2 -0
  81. package/dist/typeahead.mjs +2 -0
  82. package/dist/visually-hidden-BOqfqBFt.d.mts +17 -0
  83. package/dist/{visually-hidden-CTSV3ctZ.mjs → visually-hidden-BwDOx5yf.mjs} +2 -2
  84. package/dist/visually-hidden.d.mts +1 -1
  85. package/dist/visually-hidden.mjs +1 -1
  86. package/package.json +67 -6
  87. package/dist/visually-hidden-CekDwEwR.d.mts +0 -19
  88. /package/dist/{_plugin-vue_export-helper-BVN2DL-U.mjs → _plugin-vue_export-helper-BOaGB7Aw.mjs} +0 -0
  89. /package/dist/{collection-aHZ6Pf0e.d.mts → collection-B_dFZOHO.d.mts} +0 -0
  90. /package/dist/{collection-CoOROaho.mjs → collection-eHN150dT.mjs} +0 -0
  91. /package/dist/{controllable-state-B9v6FClp.d.mts → controllable-state-BtoxKahh.d.mts} +0 -0
  92. /package/dist/{interaction-modality-CO-eQzNy.mjs → interaction-modality-DOZK0BpZ.mjs} +0 -0
  93. /package/dist/{interaction-modality-tee79ZBZ.d.mts → interaction-modality-jgHKjPFB.d.mts} +0 -0
  94. /package/dist/{pdf-source-BbZKF_dS.d.mts → pdf-source-BYFK2Pks.d.mts} +0 -0
  95. /package/dist/{pdf-source-C9zNQd9l.mjs → pdf-source-zu1LkCeE.mjs} +0 -0
  96. /package/dist/{press-types-B8Ssxqg4.d.mts → press-types-CNqStzJf.d.mts} +0 -0
@@ -0,0 +1,340 @@
1
+ import { n as disableTextSelection, t as createPressEvent } from "./press-event-Cd2OPpmw.mjs";
2
+ import { t as createPress } from "./press-N_mE3Mgx.mjs";
3
+ import { getCurrentScope, onScopeDispose, shallowReadonly, shallowRef, toValue } from "vue";
4
+ //#region src/long-press-internal.ts
5
+ const defaultThreshold = 500;
6
+ const invalidOptionDiagnostic = "VIZE_UI_LONG_PRESS_OPTION";
7
+ const hardwarePointers = new Set([
8
+ "mouse",
9
+ "pen",
10
+ "pointer",
11
+ "touch"
12
+ ]);
13
+ function isHardwarePointer(value) {
14
+ return hardwarePointers.has(value);
15
+ }
16
+ function ownerOf(event) {
17
+ const original = event.originalEvent;
18
+ if (original && "pointerId" in original) return {
19
+ id: Number(original.pointerId),
20
+ source: "pointer"
21
+ };
22
+ if (original && "changedTouches" in original) {
23
+ const id = original.changedTouches.item(0)?.identifier;
24
+ if (id !== void 0) return {
25
+ id,
26
+ source: "touch"
27
+ };
28
+ }
29
+ return { source: "mouse" };
30
+ }
31
+ function ownerMatches(owner, event) {
32
+ const original = event.originalEvent;
33
+ if (owner.source === "pointer") return Boolean(original && "pointerId" in original && Number(original.pointerId) === owner.id);
34
+ if (owner.source === "touch") return Boolean(original && "changedTouches" in original && Array.from(original.changedTouches).some(({ identifier }) => identifier === owner.id));
35
+ return Boolean(original && !("pointerId" in original) && !("changedTouches" in original));
36
+ }
37
+ function captureError(errors, callback) {
38
+ try {
39
+ callback();
40
+ } catch (error) {
41
+ errors.push(error);
42
+ }
43
+ }
44
+ function surfaceErrors(errors, message) {
45
+ if (errors.length === 1) throw errors[0];
46
+ if (errors.length < 2) return;
47
+ const Aggregate = globalThis.AggregateError;
48
+ if (typeof Aggregate === "function") throw new Aggregate(errors, message);
49
+ const fallback = Object.assign(new Error(message), { errors: [...errors] });
50
+ fallback.name = "AggregateError";
51
+ throw fallback;
52
+ }
53
+ function readBoolean(value, name) {
54
+ const resolved = toValue(value);
55
+ if (resolved === void 0) return false;
56
+ if (typeof resolved !== "boolean") throw new TypeError(`${invalidOptionDiagnostic}: ${name} must resolve to a boolean`);
57
+ return resolved;
58
+ }
59
+ function readPointerType(value) {
60
+ const resolved = toValue(value) ?? null;
61
+ if (resolved !== null && !hardwarePointers.has(resolved)) throw new TypeError(`${invalidOptionDiagnostic}: pointerType must resolve to mouse, pen, pointer, or touch`);
62
+ return resolved;
63
+ }
64
+ function readThreshold(value) {
65
+ const resolved = toValue(value) ?? defaultThreshold;
66
+ if (typeof resolved !== "number" || !Number.isFinite(resolved) || resolved < 0) throw new TypeError(`${invalidOptionDiagnostic}: threshold must resolve to a finite number >= 0`);
67
+ return resolved;
68
+ }
69
+ function readText(value, name) {
70
+ const resolved = toValue(value);
71
+ if (resolved === void 0 || resolved === "") return void 0;
72
+ if (typeof resolved !== "string") throw new TypeError(`${invalidOptionDiagnostic}: ${name} must resolve to a string`);
73
+ return resolved;
74
+ }
75
+ function toLongPressEvent(type, event, originalEvent = event.originalEvent, isCanceled = event.isCanceled, touchIdentifier = null) {
76
+ const snapshot = createPressEvent("pressend", event.target, event.pointerType, originalEvent, isCanceled, touchIdentifier);
77
+ return Object.freeze({
78
+ ...snapshot,
79
+ type
80
+ });
81
+ }
82
+ function validateOptions(options) {
83
+ for (const name of [
84
+ "onLongPress",
85
+ "onLongPressEnd",
86
+ "onLongPressStart",
87
+ "onPress"
88
+ ]) {
89
+ const callback = options[name];
90
+ if (callback !== void 0 && typeof callback !== "function") throw new TypeError(`${invalidOptionDiagnostic}: ${name} must be a function`);
91
+ }
92
+ if (typeof options.threshold !== "function") readThreshold(options.threshold);
93
+ if (typeof options.pointerType !== "function") readPointerType(options.pointerType);
94
+ }
95
+ /** Install physical-release listeners for an already triggered attempt. */
96
+ function installTriggeredRelease(current, finish) {
97
+ const removals = [];
98
+ const document = current.target.ownerDocument;
99
+ const listen = (owner, type, callback, capture = true) => {
100
+ owner.addEventListener(type, callback, capture);
101
+ removals.push(() => owner.removeEventListener(type, callback, capture));
102
+ };
103
+ try {
104
+ if (current.owner.source === "pointer") {
105
+ const id = current.owner.id;
106
+ listen(document, "pointerup", ((event) => {
107
+ if (event.pointerId === id) finish(event);
108
+ }));
109
+ listen(document, "pointercancel", ((event) => {
110
+ if (event.pointerId === id) finish(event, true);
111
+ }));
112
+ } else if (current.owner.source === "touch") {
113
+ const id = current.owner.id;
114
+ const ownsTouch = (event) => Array.from(event.changedTouches).some((touch) => touch.identifier === id);
115
+ listen(document, "touchend", ((event) => {
116
+ if (ownsTouch(event)) finish(event);
117
+ }));
118
+ listen(document, "touchcancel", ((event) => {
119
+ if (ownsTouch(event)) finish(event, true);
120
+ }));
121
+ } else listen(document, "mouseup", ((event) => {
122
+ if (event.button === 0) finish(event);
123
+ }));
124
+ listen(document, "dragstart", (event) => finish(event, true));
125
+ listen(document, "visibilitychange", (() => {
126
+ if (document.visibilityState === "hidden") finish(null, true);
127
+ }));
128
+ if (document.defaultView) listen(document.defaultView, "blur", (event) => finish(event, true), false);
129
+ } catch (error) {
130
+ const errors = [error];
131
+ for (const remove of removals.reverse()) captureError(errors, remove);
132
+ surfaceErrors(errors, "Long-press listener setup failed");
133
+ throw error;
134
+ }
135
+ return () => {
136
+ const errors = [];
137
+ for (const remove of removals.splice(0)) captureError(errors, remove);
138
+ surfaceErrors(errors, "Long-press listener cleanup failed");
139
+ };
140
+ }
141
+ //#endregion
142
+ //#region src/long-press.ts
143
+ const contextMenuLingerMs = 50;
144
+ const disposedDiagnostic = "VIZE_UI_LONG_PRESS_DISPOSED";
145
+ const setupDiagnostic = "VIZE_UI_LONG_PRESS_SETUP";
146
+ /** Create an SSR-safe long-press recognizer for one host element. */
147
+ function createLongPress(options = {}) {
148
+ validateOptions(options);
149
+ const isPressed = shallowRef(false);
150
+ const isLongPressed = shallowRef(false);
151
+ let attempt = null;
152
+ let releaseTriggered = null;
153
+ let restoreTriggeredSelection = null;
154
+ let contextMenuPointer = null;
155
+ let contextMenuTimer = null;
156
+ let endingAtThreshold = false;
157
+ let disposed = false;
158
+ const clearContextMenuTimer = () => {
159
+ if (contextMenuTimer !== null) clearTimeout(contextMenuTimer);
160
+ contextMenuTimer = null;
161
+ };
162
+ const lingerContextMenuSuppression = () => {
163
+ clearContextMenuTimer();
164
+ contextMenuTimer = setTimeout(() => {
165
+ contextMenuPointer = null;
166
+ contextMenuTimer = null;
167
+ }, contextMenuLingerMs);
168
+ };
169
+ const clearRelease = () => {
170
+ const release = releaseTriggered;
171
+ const restore = restoreTriggeredSelection;
172
+ releaseTriggered = null;
173
+ restoreTriggeredSelection = null;
174
+ const errors = [];
175
+ try {
176
+ captureError(errors, () => release?.());
177
+ } finally {
178
+ captureError(errors, () => restore?.());
179
+ }
180
+ surfaceErrors(errors, "Long-press release cleanup failed");
181
+ };
182
+ const clearAttempt = (owner = attempt) => {
183
+ if (!owner || attempt !== owner) return false;
184
+ const timer = owner.timer;
185
+ if (timer != null) clearTimeout(timer);
186
+ attempt = null;
187
+ return true;
188
+ };
189
+ const finishTriggered = (owner, originalEvent, isCanceled) => {
190
+ if (!isLongPressed.value || attempt !== owner) return false;
191
+ const errors = [];
192
+ captureError(errors, clearRelease);
193
+ clearAttempt(owner);
194
+ isPressed.value = false;
195
+ isLongPressed.value = false;
196
+ captureError(errors, lingerContextMenuSuppression);
197
+ let canceled = isCanceled;
198
+ try {
199
+ canceled ||= readBoolean(options.isDisabled, "isDisabled");
200
+ } catch (error) {
201
+ canceled = true;
202
+ errors.push(error);
203
+ }
204
+ captureError(errors, () => options.onLongPressEnd?.(toLongPressEvent("longpressend", owner.event, originalEvent, canceled, owner.touchIdentifier)));
205
+ surfaceErrors(errors, "Long-press completion failed");
206
+ return true;
207
+ };
208
+ let press;
209
+ const trigger = (current) => {
210
+ if (disposed || attempt !== current) return;
211
+ current.timer = null;
212
+ if (readBoolean(options.isDisabled, "isDisabled")) {
213
+ press.cancel();
214
+ return;
215
+ }
216
+ isLongPressed.value = true;
217
+ try {
218
+ releaseTriggered = installTriggeredRelease(current, (event, canceled = false) => finishTriggered(current, event, canceled));
219
+ } catch (error) {
220
+ const errors = [error];
221
+ clearAttempt(current);
222
+ isPressed.value = false;
223
+ isLongPressed.value = false;
224
+ contextMenuPointer = null;
225
+ endingAtThreshold = true;
226
+ try {
227
+ captureError(errors, press.cancel);
228
+ } finally {
229
+ endingAtThreshold = false;
230
+ }
231
+ surfaceErrors(errors, "Long-press trigger setup failed");
232
+ return;
233
+ }
234
+ endingAtThreshold = true;
235
+ try {
236
+ press.cancel();
237
+ } finally {
238
+ endingAtThreshold = false;
239
+ }
240
+ const focusable = current.target;
241
+ if ((current.pointerType === "touch" || current.pointerType === "pen") && current.target.ownerDocument.activeElement !== current.target && typeof focusable.focus === "function") try {
242
+ focusable.focus({ preventScroll: true });
243
+ } catch {
244
+ focusable.focus();
245
+ }
246
+ if (!readBoolean(options.allowTextSelectionOnPress, "allowTextSelectionOnPress")) restoreTriggeredSelection = disableTextSelection(current.target);
247
+ options.onLongPress?.(toLongPressEvent("longpress", current.event, current.event.originalEvent, current.event.isCanceled, current.touchIdentifier));
248
+ };
249
+ press = createPress({
250
+ ...options.isDisabled === void 0 ? {} : { isDisabled: options.isDisabled },
251
+ ...options.allowTextSelectionOnPress === void 0 ? {} : { allowTextSelectionOnPress: options.allowTextSelectionOnPress },
252
+ ...options.preventFocusOnPress === void 0 ? {} : { preventFocusOnPress: options.preventFocusOnPress },
253
+ shouldCancelOnPointerExit: true,
254
+ onPressStart(event) {
255
+ if (!isHardwarePointer(event.pointerType)) return;
256
+ const pointerType = event.pointerType;
257
+ const filter = readPointerType(options.pointerType);
258
+ if (filter && filter !== pointerType) return;
259
+ if (attempt) {
260
+ press.cancel();
261
+ return;
262
+ }
263
+ contextMenuPointer = pointerType;
264
+ clearContextMenuTimer();
265
+ const owner = ownerOf(event);
266
+ const touchIdentifier = owner.source === "touch" ? owner.id : null;
267
+ const start = toLongPressEvent("longpressstart", event, event.originalEvent, event.isCanceled, touchIdentifier);
268
+ const current = {
269
+ event: start,
270
+ owner,
271
+ pointerType,
272
+ target: event.target,
273
+ touchIdentifier,
274
+ timer: null
275
+ };
276
+ attempt = current;
277
+ isPressed.value = true;
278
+ current.timer = setTimeout(() => trigger(current), readThreshold(options.threshold));
279
+ options.onLongPressStart?.(start);
280
+ },
281
+ onPressEnd(event) {
282
+ if (!attempt || endingAtThreshold) return;
283
+ const current = attempt;
284
+ if (!ownerMatches(current.owner, event)) return;
285
+ clearAttempt(current);
286
+ isPressed.value = false;
287
+ if (current.pointerType === "touch" || current.pointerType === "pen") lingerContextMenuSuppression();
288
+ else contextMenuPointer = null;
289
+ options.onLongPressEnd?.(toLongPressEvent("longpressend", current.event, event.originalEvent, event.isCanceled, current.touchIdentifier));
290
+ },
291
+ ...options.onPress ? { onPress: options.onPress } : {}
292
+ });
293
+ const attributes = {
294
+ ...press.pressProps,
295
+ get "aria-describedby"() {
296
+ if (readBoolean(options.isDisabled, "isDisabled") || !options.onLongPress) return void 0;
297
+ return readText(options.accessibilityDescriptionId, "accessibilityDescriptionId");
298
+ },
299
+ get "aria-description"() {
300
+ if (readBoolean(options.isDisabled, "isDisabled") || !options.onLongPress) return void 0;
301
+ if (readText(options.accessibilityDescriptionId, "accessibilityDescriptionId")) return void 0;
302
+ return readText(options.accessibilityDescription, "accessibilityDescription");
303
+ },
304
+ onContextmenu(event) {
305
+ if (contextMenuPointer === "touch" || contextMenuPointer === "pen") event.preventDefault();
306
+ }
307
+ };
308
+ return Object.freeze({
309
+ isPressed: shallowReadonly(isPressed),
310
+ isLongPressed: shallowReadonly(isLongPressed),
311
+ longPressProps: Object.freeze(attributes),
312
+ cancel: () => {
313
+ if (disposed) throw new Error(`${disposedDiagnostic}: the controller has been disposed`);
314
+ if (attempt && finishTriggered(attempt, null, true)) return true;
315
+ return press.cancel();
316
+ },
317
+ dispose: () => {
318
+ if (disposed) return;
319
+ disposed = true;
320
+ const errors = [];
321
+ captureError(errors, clearRelease);
322
+ captureError(errors, () => clearAttempt());
323
+ captureError(errors, clearContextMenuTimer);
324
+ contextMenuPointer = null;
325
+ isPressed.value = false;
326
+ isLongPressed.value = false;
327
+ captureError(errors, press.dispose);
328
+ surfaceErrors(errors, "Long-press disposal failed");
329
+ }
330
+ });
331
+ }
332
+ /** Create a long-press recognizer disposed with the current Vue effect scope. */
333
+ function useLongPress(options = {}) {
334
+ if (!getCurrentScope()) throw new Error(`${setupDiagnostic}: use inside component setup or an active effect scope`);
335
+ const controller = createLongPress(options);
336
+ onScopeDispose(controller.dispose);
337
+ return controller;
338
+ }
339
+ //#endregion
340
+ export { useLongPress as n, createLongPress as t };
@@ -1,4 +1,4 @@
1
- import { n as PressEvent, o as PressPointerType, s as PressProps } from "./press-types-B8Ssxqg4.mjs";
1
+ import { n as PressEvent, o as PressPointerType, s as PressProps } from "./press-types-CNqStzJf.mjs";
2
2
  import { MaybeRefOrGetter, ShallowRef } from "vue";
3
3
 
4
4
  //#region src/long-press-types.d.ts
@@ -7,26 +7,11 @@ type LongPressPointerType = Extract<PressPointerType, "mouse" | "pen" | "pointer
7
7
  /** Lifecycle notification emitted by a long-press controller. */
8
8
  type LongPressEventType = "longpress" | "longpressend" | "longpressstart";
9
9
  /** Immutable snapshot of one long-press lifecycle event. */
10
- interface LongPressEvent {
10
+ interface LongPressEvent extends Omit<PressEvent, "type" | "pointerType"> {
11
11
  /** Long-press lifecycle phase represented by this snapshot. */
12
12
  readonly type: LongPressEventType;
13
13
  /** Pointing-device family that initiated the interaction. */
14
14
  readonly pointerType: LongPressPointerType;
15
- /** Element whose bound props own the interaction. */
16
- readonly target: Element;
17
- /** Native event responsible for this phase, or `null` for manual cancellation. */
18
- readonly originalEvent: Event | null;
19
- /** Viewport coordinate when supplied by pointing hardware. */
20
- readonly x: number | null;
21
- /** Viewport coordinate when supplied by pointing hardware. */
22
- readonly y: number | null;
23
- /** Modifier-key snapshots captured from the native event. */
24
- readonly altKey: boolean;
25
- readonly ctrlKey: boolean;
26
- readonly metaKey: boolean;
27
- readonly shiftKey: boolean;
28
- /** Whether the attempt ended without reaching a normal release. */
29
- readonly isCanceled: boolean;
30
15
  }
31
16
  /** Options shared by {@link createLongPress} and {@link useLongPress}. */
32
17
  interface LongPressOptions {
@@ -100,7 +85,12 @@ interface LongPressController {
100
85
  readonly isLongPressed: Readonly<ShallowRef<boolean>>;
101
86
  /** Stable handlers and accessibility attributes for exactly one host. */
102
87
  readonly longPressProps: Readonly<LongPressProps>;
103
- /** Cancel the current pending or triggered interaction. */
88
+ /**
89
+ * Cancel the current pending or triggered interaction.
90
+ * Returns `true` when an interaction was canceled.
91
+ *
92
+ * @throws Error with `VIZE_UI_LONG_PRESS_DISPOSED` after disposal.
93
+ */
104
94
  readonly cancel: () => boolean;
105
95
  /** Release timers, listeners, selection guards, and reactive state. */
106
96
  readonly dispose: () => void;
@@ -1,2 +1,2 @@
1
- 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";
2
- export { LongPressController, LongPressEvent, LongPressEventType, LongPressOptions, LongPressPointerType, LongPressProps, createLongPress, useLongPress };
1
+ 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-cll6z2K9.mjs";
2
+ export { type LongPressController, type LongPressEvent, type LongPressEventType, type LongPressOptions, type LongPressPointerType, type LongPressProps, createLongPress, useLongPress };
@@ -1,246 +1,2 @@
1
- import { i as disableTextSelection, r as createPressEvent, t as createPress } from "./press-Bp57IOe2.mjs";
2
- import { getCurrentScope, onScopeDispose, shallowReadonly, shallowRef, toValue } from "vue";
3
- //#region src/long-press.ts
4
- const defaultThreshold = 500;
5
- const invalidOptionDiagnostic = "VIZE_UI_LONG_PRESS_OPTION";
6
- const disposedDiagnostic = "VIZE_UI_LONG_PRESS_DISPOSED";
7
- const setupDiagnostic = "VIZE_UI_LONG_PRESS_SETUP";
8
- const hardwarePointers = new Set([
9
- "mouse",
10
- "pen",
11
- "pointer",
12
- "touch"
13
- ]);
14
- function readBoolean(value, name) {
15
- const resolved = toValue(value);
16
- if (resolved === void 0) return false;
17
- if (typeof resolved !== "boolean") throw new TypeError(`${invalidOptionDiagnostic}: ${name} must resolve to a boolean`);
18
- return resolved;
19
- }
20
- function readPointerType(value) {
21
- const resolved = toValue(value) ?? null;
22
- if (resolved !== null && !hardwarePointers.has(resolved)) throw new TypeError(`${invalidOptionDiagnostic}: pointerType must resolve to mouse, pen, pointer, or touch`);
23
- return resolved;
24
- }
25
- function readThreshold(value) {
26
- const resolved = toValue(value) ?? defaultThreshold;
27
- if (typeof resolved !== "number" || !Number.isFinite(resolved) || resolved < 0) throw new TypeError(`${invalidOptionDiagnostic}: threshold must resolve to a finite number >= 0`);
28
- return resolved;
29
- }
30
- function readText(value, name) {
31
- const resolved = toValue(value);
32
- if (resolved === void 0 || resolved === "") return void 0;
33
- if (typeof resolved !== "string") throw new TypeError(`${invalidOptionDiagnostic}: ${name} must resolve to a string`);
34
- return resolved;
35
- }
36
- function toLongPressEvent(type, event, originalEvent = event.originalEvent, isCanceled = event.isCanceled) {
37
- const snapshot = createPressEvent("pressend", event.target, event.pointerType, originalEvent, isCanceled);
38
- return Object.freeze({
39
- ...snapshot,
40
- type
41
- });
42
- }
43
- function validateOptions(options) {
44
- for (const name of [
45
- "onLongPress",
46
- "onLongPressEnd",
47
- "onLongPressStart",
48
- "onPress"
49
- ]) {
50
- const callback = options[name];
51
- if (callback !== void 0 && typeof callback !== "function") throw new TypeError(`${invalidOptionDiagnostic}: ${name} must be a function`);
52
- }
53
- if (typeof options.threshold !== "function") readThreshold(options.threshold);
54
- if (typeof options.pointerType !== "function") readPointerType(options.pointerType);
55
- }
56
- /** Create an SSR-safe long-press recognizer for one host element. */
57
- function createLongPress(options = {}) {
58
- validateOptions(options);
59
- const isPressed = shallowRef(false);
60
- const isLongPressed = shallowRef(false);
61
- let attempt = null;
62
- let releaseTriggered = null;
63
- let restoreTriggeredSelection = null;
64
- let contextMenuPointer = null;
65
- let contextMenuTimer = null;
66
- let endingAtThreshold = false;
67
- let disposed = false;
68
- const clearContextMenuTimer = () => {
69
- if (contextMenuTimer !== null) clearTimeout(contextMenuTimer);
70
- contextMenuTimer = null;
71
- };
72
- const lingerContextMenuSuppression = () => {
73
- clearContextMenuTimer();
74
- contextMenuTimer = setTimeout(() => {
75
- contextMenuPointer = null;
76
- contextMenuTimer = null;
77
- }, 50);
78
- };
79
- const clearRelease = () => {
80
- releaseTriggered?.();
81
- releaseTriggered = null;
82
- restoreTriggeredSelection?.();
83
- restoreTriggeredSelection = null;
84
- };
85
- const clearAttempt = () => {
86
- const timer = attempt?.timer;
87
- if (timer != null) clearTimeout(timer);
88
- attempt = null;
89
- };
90
- const finishTriggered = (originalEvent, isCanceled) => {
91
- if (!isLongPressed.value || !attempt) return false;
92
- const current = attempt;
93
- const canceled = isCanceled || readBoolean(options.isDisabled, "isDisabled");
94
- clearRelease();
95
- clearAttempt();
96
- isPressed.value = false;
97
- isLongPressed.value = false;
98
- lingerContextMenuSuppression();
99
- options.onLongPressEnd?.(toLongPressEvent("longpressend", current.event, originalEvent, canceled));
100
- return true;
101
- };
102
- const installTriggeredRelease = (current) => {
103
- const removals = [];
104
- const document = current.target.ownerDocument;
105
- const start = current.event.originalEvent;
106
- const listen = (owner, type, callback, capture = true) => {
107
- owner.addEventListener(type, callback, capture);
108
- removals.push(() => owner.removeEventListener(type, callback, capture));
109
- };
110
- const finish = (event, canceled = false) => finishTriggered(event, canceled);
111
- if (start && "pointerId" in start) {
112
- const id = Number(start.pointerId);
113
- listen(document, "pointerup", ((event) => {
114
- if (event.pointerId === id) finish(event);
115
- }));
116
- listen(document, "pointercancel", ((event) => {
117
- if (event.pointerId === id) finish(event, true);
118
- }));
119
- } else if (start && "changedTouches" in start) {
120
- const id = start.changedTouches.item(0)?.identifier;
121
- const ownsTouch = (event) => id !== void 0 && Array.from(event.changedTouches).some((touch) => touch.identifier === id);
122
- listen(document, "touchend", ((event) => {
123
- if (ownsTouch(event)) finish(event);
124
- }));
125
- listen(document, "touchcancel", ((event) => {
126
- if (ownsTouch(event)) finish(event, true);
127
- }));
128
- } else listen(document, "mouseup", ((event) => {
129
- if (event.button === 0) finish(event);
130
- }));
131
- listen(document, "dragstart", (event) => finish(event, true));
132
- listen(document, "visibilitychange", (() => {
133
- if (document.visibilityState === "hidden") finish(null, true);
134
- }));
135
- if (document.defaultView) listen(document.defaultView, "blur", (event) => finish(event, true), false);
136
- return () => {
137
- for (const remove of removals.splice(0)) remove();
138
- };
139
- };
140
- let press;
141
- const trigger = (current) => {
142
- if (disposed || attempt !== current) return;
143
- current.timer = null;
144
- if (readBoolean(options.isDisabled, "isDisabled")) {
145
- press.cancel();
146
- return;
147
- }
148
- isLongPressed.value = true;
149
- releaseTriggered = installTriggeredRelease(current);
150
- endingAtThreshold = true;
151
- try {
152
- press.cancel();
153
- } finally {
154
- endingAtThreshold = false;
155
- }
156
- const focusable = current.target;
157
- if ((current.pointerType === "touch" || current.pointerType === "pen") && current.target.ownerDocument.activeElement !== current.target && typeof focusable.focus === "function") try {
158
- focusable.focus({ preventScroll: true });
159
- } catch {
160
- focusable.focus();
161
- }
162
- if (!readBoolean(options.allowTextSelectionOnPress, "allowTextSelectionOnPress")) restoreTriggeredSelection = disableTextSelection(current.target);
163
- options.onLongPress?.(toLongPressEvent("longpress", current.event));
164
- };
165
- press = createPress({
166
- ...options.isDisabled === void 0 ? {} : { isDisabled: options.isDisabled },
167
- ...options.allowTextSelectionOnPress === void 0 ? {} : { allowTextSelectionOnPress: options.allowTextSelectionOnPress },
168
- ...options.preventFocusOnPress === void 0 ? {} : { preventFocusOnPress: options.preventFocusOnPress },
169
- shouldCancelOnPointerExit: true,
170
- onPressStart(event) {
171
- if (!hardwarePointers.has(event.pointerType)) return;
172
- const pointerType = event.pointerType;
173
- const filter = readPointerType(options.pointerType);
174
- if (filter && filter !== pointerType) return;
175
- clearAttempt();
176
- contextMenuPointer = pointerType;
177
- clearContextMenuTimer();
178
- const start = toLongPressEvent("longpressstart", event);
179
- const current = {
180
- event: start,
181
- pointerType,
182
- target: event.target,
183
- timer: null
184
- };
185
- attempt = current;
186
- isPressed.value = true;
187
- current.timer = setTimeout(() => trigger(current), readThreshold(options.threshold));
188
- options.onLongPressStart?.(start);
189
- },
190
- onPressEnd(event) {
191
- if (!attempt || endingAtThreshold) return;
192
- const current = attempt;
193
- clearAttempt();
194
- isPressed.value = false;
195
- if (current.pointerType === "touch" || current.pointerType === "pen") lingerContextMenuSuppression();
196
- else contextMenuPointer = null;
197
- options.onLongPressEnd?.(toLongPressEvent("longpressend", current.event, event.originalEvent, event.isCanceled));
198
- },
199
- ...options.onPress ? { onPress: options.onPress } : {}
200
- });
201
- const attributes = {
202
- ...press.pressProps,
203
- get "aria-describedby"() {
204
- if (readBoolean(options.isDisabled, "isDisabled") || !options.onLongPress) return void 0;
205
- return readText(options.accessibilityDescriptionId, "accessibilityDescriptionId");
206
- },
207
- get "aria-description"() {
208
- if (readBoolean(options.isDisabled, "isDisabled") || !options.onLongPress) return void 0;
209
- if (readText(options.accessibilityDescriptionId, "accessibilityDescriptionId")) return void 0;
210
- return readText(options.accessibilityDescription, "accessibilityDescription");
211
- },
212
- onContextmenu(event) {
213
- if (contextMenuPointer === "touch" || contextMenuPointer === "pen") event.preventDefault();
214
- }
215
- };
216
- return Object.freeze({
217
- isPressed: shallowReadonly(isPressed),
218
- isLongPressed: shallowReadonly(isLongPressed),
219
- longPressProps: Object.freeze(attributes),
220
- cancel: () => {
221
- if (disposed) throw new Error(`${disposedDiagnostic}: the controller has been disposed`);
222
- if (finishTriggered(null, true)) return true;
223
- return press.cancel();
224
- },
225
- dispose: () => {
226
- if (disposed) return;
227
- clearRelease();
228
- clearAttempt();
229
- clearContextMenuTimer();
230
- contextMenuPointer = null;
231
- isPressed.value = false;
232
- isLongPressed.value = false;
233
- press.dispose();
234
- disposed = true;
235
- }
236
- });
237
- }
238
- /** Create a long-press recognizer disposed with the current Vue effect scope. */
239
- function useLongPress(options = {}) {
240
- if (!getCurrentScope()) throw new Error(`${setupDiagnostic}: use inside component setup or an active effect scope`);
241
- const controller = createLongPress(options);
242
- onScopeDispose(controller.dispose);
243
- return controller;
244
- }
245
- //#endregion
1
+ import { n as useLongPress, t as createLongPress } from "./long-press-Dsul69gk.mjs";
246
2
  export { createLongPress, useLongPress };
@@ -1,2 +1,2 @@
1
- import { n as createPDFSource, t as CreatePDFSourceOptions } from "./pdf-source-BbZKF_dS.mjs";
1
+ import { n as createPDFSource, t as CreatePDFSourceOptions } from "./pdf-source-BYFK2Pks.mjs";
2
2
  export { type CreatePDFSourceOptions, createPDFSource };
@@ -1,2 +1,2 @@
1
- import { t as createPDFSource } from "./pdf-source-C9zNQd9l.mjs";
1
+ import { t as createPDFSource } from "./pdf-source-zu1LkCeE.mjs";
2
2
  export { createPDFSource };
package/dist/media.d.mts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { MediaSourceKind, NormalizeMediaSourceOptions, normalizeMediaSource } from "./media-source.mjs";
2
- import { n as createPDFSource, t as CreatePDFSourceOptions } from "./pdf-source-BbZKF_dS.mjs";
2
+ import { n as createPDFSource, t as CreatePDFSourceOptions } from "./pdf-source-BYFK2Pks.mjs";
3
3
  export { type CreatePDFSourceOptions, type MediaSourceKind, type NormalizeMediaSourceOptions, createPDFSource, normalizeMediaSource };
package/dist/media.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import { normalizeMediaSource } from "./media-source.mjs";
2
- import { t as createPDFSource } from "./pdf-source-C9zNQd9l.mjs";
2
+ import { t as createPDFSource } from "./pdf-source-zu1LkCeE.mjs";
3
3
  export { createPDFSource, normalizeMediaSource };