@develemit/web-hooks 0.2.0 → 0.3.1
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/CHANGELOG.md +18 -0
- package/README.md +157 -0
- package/dist/chunk-4PVVTQ5V.js +74 -0
- package/dist/{chunk-OZ4PU4E3.js → chunk-5XRVPZHD.js} +14 -4
- package/dist/{chunk-3UGRXQIA.js → chunk-DQBKU7HI.js} +10 -3
- package/dist/chunk-EXEJI4FK.js +43 -0
- package/dist/{chunk-3CACI4OQ.js → chunk-FE3BQD2I.js} +1 -25
- package/dist/chunk-HTVNN2NM.js +29 -0
- package/dist/chunk-R2PFNE3U.js +154 -0
- package/dist/chunk-TNEJ34T5.js +86 -0
- package/dist/chunk-UVJBJETY.js +121 -0
- package/dist/{chunk-UZADAINO.js → chunk-WVM2LTWQ.js} +2 -21
- package/dist/chunk-WXL22EWK.js +21 -0
- package/dist/chunk-YFMMSLMB.js +41 -0
- package/dist/chunk-Z3X27PCA.js +108 -0
- package/dist/clipboard.cjs +13 -0
- package/dist/clipboard.d.cts +10 -1
- package/dist/clipboard.d.ts +10 -1
- package/dist/clipboard.js +6 -2
- package/dist/drawer-swipe.cjs +16 -4
- package/dist/drawer-swipe.d.cts +7 -3
- package/dist/drawer-swipe.d.ts +7 -3
- package/dist/drawer-swipe.js +5 -1
- package/dist/index.cjs +637 -19
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +77 -7
- package/dist/keyboard-inset.cjs +113 -0
- package/dist/keyboard-inset.d.cts +25 -0
- package/dist/keyboard-inset.d.ts +25 -0
- package/dist/keyboard-inset.js +11 -0
- package/dist/media-query.js +5 -3
- package/dist/online-status.cjs +46 -0
- package/dist/online-status.d.cts +3 -0
- package/dist/online-status.d.ts +3 -0
- package/dist/online-status.js +7 -0
- package/dist/outside-press.cjs +10 -3
- package/dist/outside-press.d.cts +4 -2
- package/dist/outside-press.d.ts +4 -2
- package/dist/outside-press.js +1 -1
- package/dist/push.cjs +209 -0
- package/dist/push.d.cts +38 -0
- package/dist/push.d.ts +38 -0
- package/dist/push.js +14 -0
- package/dist/pwa.cjs +198 -0
- package/dist/pwa.d.cts +35 -0
- package/dist/pwa.d.ts +35 -0
- package/dist/pwa.js +22 -0
- package/dist/service-worker.cjs +148 -0
- package/dist/service-worker.d.cts +24 -0
- package/dist/service-worker.d.ts +24 -0
- package/dist/service-worker.js +11 -0
- package/dist/share.cjs +139 -0
- package/dist/share.d.cts +23 -0
- package/dist/share.d.ts +23 -0
- package/dist/share.js +16 -0
- package/package.json +31 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { BACK_ZONE_PX, CLOSE_DISTANCE_PX, FORWARD_ZONE_PX, MAX_SWIPE_DURATION_MS, OPEN_DISTANCE_PX, SwipeIntent, SwipePoint, UseDrawerSwipeOptions, VERTICAL_CANCEL_PX, isInOpenZone, isInsideHorizontalScroller, resolveSwipeIntent, useDrawerSwipe } from './drawer-swipe.cjs';
|
|
1
|
+
export { BACK_ZONE_PX, CLOSE_DISTANCE_PX, DEFAULT_IGNORE_SELECTOR, FORWARD_ZONE_PX, MAX_SWIPE_DURATION_MS, OPEN_DISTANCE_PX, SwipeIntent, SwipePoint, UseDrawerSwipeOptions, VERTICAL_CANCEL_PX, isInIgnoredRegion, isInOpenZone, isInsideHorizontalScroller, resolveSwipeIntent, useDrawerSwipe } from './drawer-swipe.cjs';
|
|
2
2
|
export { FOCUSABLE_SELECTOR, UseFocusTrapOptions, focusableWithin, nextFocusTarget, useFocusTrap } from './focus-trap.cjs';
|
|
3
3
|
export { useEscape } from './escape.cjs';
|
|
4
|
-
export { CopyResult, CopyStatus, copyText, useCopyFeedback } from './clipboard.cjs';
|
|
4
|
+
export { CopyResult, CopyStatus, ReadResult, copyText, readText, useCopyFeedback } from './clipboard.cjs';
|
|
5
5
|
export { lockScroll, unlockScroll, useScrollLock } from './scroll-lock.cjs';
|
|
6
6
|
export { COARSE_POINTER_QUERY, REDUCED_MOTION_QUERY, UseMediaQueryOptions, useCoarsePointer, useMediaQuery, useReducedMotion } from './media-query.cjs';
|
|
7
7
|
export { UseOutsidePressOptions, isOutside, isPrimaryPress, useOutsidePress } from './outside-press.cjs';
|
|
@@ -11,4 +11,10 @@ export { StorageKind, StorageStateSetter, UseStorageStateOptions, useStorageStat
|
|
|
11
11
|
export { handleBeforeUnload, useUnsavedChangesGuard } from './unsaved-guard.cjs';
|
|
12
12
|
export { ParsedHotkey, UseHotkeyOptions, detectApple, isEditableTarget, matchHotkey, parseHotkey, useHotkey } from './hotkey.cjs';
|
|
13
13
|
export { NextHeight, UseAutoGrowTextareaOptions, nextHeight, useAutoGrowTextarea } from './auto-grow.cjs';
|
|
14
|
+
export { InstallPrompt, Platform, PlatformEnv, PromptOutcome, detectPlatform, isIos, isIosSafari, isStandalone, startInstallPromptCapture, useInstallPrompt, useIsStandalone } from './pwa.cjs';
|
|
15
|
+
export { useOnlineStatus } from './online-status.cjs';
|
|
16
|
+
export { ServiceWorkerState, UpdateStateInput, UseServiceWorkerOptions, deriveUpdateState, unregisterAll, useServiceWorker } from './service-worker.cjs';
|
|
17
|
+
export { ShareInput, ShareResult, ShareStatus, canShareFiles, isShareCancel, shareOrCopy, shareTextFor, useShareFeedback } from './share.cjs';
|
|
18
|
+
export { InsetReading, UseKeyboardInsetOptions, computeKeyboardInset, isEditableElement, useKeyboardInset } from './keyboard-inset.cjs';
|
|
19
|
+
export { PushEnv, PushPermission, PushSubscriptionState, PushSupport, ResubscribeInput, UsePushSubscriptionOptions, getPushSupport, shouldResubscribe, urlBase64ToUint8Array, usePushSubscription } from './push.cjs';
|
|
14
20
|
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { BACK_ZONE_PX, CLOSE_DISTANCE_PX, FORWARD_ZONE_PX, MAX_SWIPE_DURATION_MS, OPEN_DISTANCE_PX, SwipeIntent, SwipePoint, UseDrawerSwipeOptions, VERTICAL_CANCEL_PX, isInOpenZone, isInsideHorizontalScroller, resolveSwipeIntent, useDrawerSwipe } from './drawer-swipe.js';
|
|
1
|
+
export { BACK_ZONE_PX, CLOSE_DISTANCE_PX, DEFAULT_IGNORE_SELECTOR, FORWARD_ZONE_PX, MAX_SWIPE_DURATION_MS, OPEN_DISTANCE_PX, SwipeIntent, SwipePoint, UseDrawerSwipeOptions, VERTICAL_CANCEL_PX, isInIgnoredRegion, isInOpenZone, isInsideHorizontalScroller, resolveSwipeIntent, useDrawerSwipe } from './drawer-swipe.js';
|
|
2
2
|
export { FOCUSABLE_SELECTOR, UseFocusTrapOptions, focusableWithin, nextFocusTarget, useFocusTrap } from './focus-trap.js';
|
|
3
3
|
export { useEscape } from './escape.js';
|
|
4
|
-
export { CopyResult, CopyStatus, copyText, useCopyFeedback } from './clipboard.js';
|
|
4
|
+
export { CopyResult, CopyStatus, ReadResult, copyText, readText, useCopyFeedback } from './clipboard.js';
|
|
5
5
|
export { lockScroll, unlockScroll, useScrollLock } from './scroll-lock.js';
|
|
6
6
|
export { COARSE_POINTER_QUERY, REDUCED_MOTION_QUERY, UseMediaQueryOptions, useCoarsePointer, useMediaQuery, useReducedMotion } from './media-query.js';
|
|
7
7
|
export { UseOutsidePressOptions, isOutside, isPrimaryPress, useOutsidePress } from './outside-press.js';
|
|
@@ -11,4 +11,10 @@ export { StorageKind, StorageStateSetter, UseStorageStateOptions, useStorageStat
|
|
|
11
11
|
export { handleBeforeUnload, useUnsavedChangesGuard } from './unsaved-guard.js';
|
|
12
12
|
export { ParsedHotkey, UseHotkeyOptions, detectApple, isEditableTarget, matchHotkey, parseHotkey, useHotkey } from './hotkey.js';
|
|
13
13
|
export { NextHeight, UseAutoGrowTextareaOptions, nextHeight, useAutoGrowTextarea } from './auto-grow.js';
|
|
14
|
+
export { InstallPrompt, Platform, PlatformEnv, PromptOutcome, detectPlatform, isIos, isIosSafari, isStandalone, startInstallPromptCapture, useInstallPrompt, useIsStandalone } from './pwa.js';
|
|
15
|
+
export { useOnlineStatus } from './online-status.js';
|
|
16
|
+
export { ServiceWorkerState, UpdateStateInput, UseServiceWorkerOptions, deriveUpdateState, unregisterAll, useServiceWorker } from './service-worker.js';
|
|
17
|
+
export { ShareInput, ShareResult, ShareStatus, canShareFiles, isShareCancel, shareOrCopy, shareTextFor, useShareFeedback } from './share.js';
|
|
18
|
+
export { InsetReading, UseKeyboardInsetOptions, computeKeyboardInset, isEditableElement, useKeyboardInset } from './keyboard-inset.js';
|
|
19
|
+
export { PushEnv, PushPermission, PushSubscriptionState, PushSupport, ResubscribeInput, UsePushSubscriptionOptions, getPushSupport, shouldResubscribe, urlBase64ToUint8Array, usePushSubscription } from './push.js';
|
|
14
20
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
deriveUpdateState,
|
|
4
|
+
unregisterAll,
|
|
5
|
+
useServiceWorker
|
|
6
|
+
} from "./chunk-UVJBJETY.js";
|
|
7
|
+
import {
|
|
8
|
+
canShareFiles,
|
|
9
|
+
isShareCancel,
|
|
10
|
+
shareOrCopy,
|
|
11
|
+
shareTextFor,
|
|
12
|
+
useShareFeedback
|
|
13
|
+
} from "./chunk-4PVVTQ5V.js";
|
|
14
|
+
import {
|
|
15
|
+
computeKeyboardInset,
|
|
16
|
+
isEditableElement,
|
|
17
|
+
useKeyboardInset
|
|
18
|
+
} from "./chunk-TNEJ34T5.js";
|
|
19
|
+
import {
|
|
20
|
+
getPushSupport,
|
|
21
|
+
shouldResubscribe,
|
|
22
|
+
urlBase64ToUint8Array,
|
|
23
|
+
usePushSubscription
|
|
24
|
+
} from "./chunk-R2PFNE3U.js";
|
|
2
25
|
import {
|
|
3
26
|
nextDelay,
|
|
4
27
|
useVisibilityPolling
|
|
@@ -26,18 +49,34 @@ import {
|
|
|
26
49
|
nextHeight,
|
|
27
50
|
useAutoGrowTextarea
|
|
28
51
|
} from "./chunk-5CA5RIMH.js";
|
|
52
|
+
import {
|
|
53
|
+
startInstallPromptCapture,
|
|
54
|
+
useInstallPrompt,
|
|
55
|
+
useIsStandalone
|
|
56
|
+
} from "./chunk-Z3X27PCA.js";
|
|
57
|
+
import {
|
|
58
|
+
detectPlatform,
|
|
59
|
+
isIos,
|
|
60
|
+
isIosSafari,
|
|
61
|
+
isStandalone
|
|
62
|
+
} from "./chunk-YFMMSLMB.js";
|
|
63
|
+
import {
|
|
64
|
+
useOnlineStatus
|
|
65
|
+
} from "./chunk-WXL22EWK.js";
|
|
29
66
|
import {
|
|
30
67
|
BACK_ZONE_PX,
|
|
31
68
|
CLOSE_DISTANCE_PX,
|
|
69
|
+
DEFAULT_IGNORE_SELECTOR,
|
|
32
70
|
FORWARD_ZONE_PX,
|
|
33
71
|
MAX_SWIPE_DURATION_MS,
|
|
34
72
|
OPEN_DISTANCE_PX,
|
|
35
73
|
VERTICAL_CANCEL_PX,
|
|
74
|
+
isInIgnoredRegion,
|
|
36
75
|
isInOpenZone,
|
|
37
76
|
isInsideHorizontalScroller,
|
|
38
77
|
resolveSwipeIntent,
|
|
39
78
|
useDrawerSwipe
|
|
40
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-5XRVPZHD.js";
|
|
41
80
|
import {
|
|
42
81
|
FOCUSABLE_SELECTOR,
|
|
43
82
|
focusableWithin,
|
|
@@ -48,54 +87,78 @@ import {
|
|
|
48
87
|
useEscape
|
|
49
88
|
} from "./chunk-S4YKMGQE.js";
|
|
50
89
|
import {
|
|
51
|
-
|
|
90
|
+
readText,
|
|
52
91
|
useCopyFeedback
|
|
53
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-EXEJI4FK.js";
|
|
93
|
+
import {
|
|
94
|
+
copyText
|
|
95
|
+
} from "./chunk-FE3BQD2I.js";
|
|
54
96
|
import {
|
|
55
97
|
lockScroll,
|
|
56
98
|
unlockScroll,
|
|
57
99
|
useScrollLock
|
|
58
100
|
} from "./chunk-6KCRVSLS.js";
|
|
59
101
|
import {
|
|
60
|
-
COARSE_POINTER_QUERY,
|
|
61
|
-
REDUCED_MOTION_QUERY,
|
|
62
102
|
useCoarsePointer,
|
|
63
103
|
useMediaQuery,
|
|
64
104
|
useReducedMotion
|
|
65
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-HTVNN2NM.js";
|
|
106
|
+
import {
|
|
107
|
+
COARSE_POINTER_QUERY,
|
|
108
|
+
REDUCED_MOTION_QUERY
|
|
109
|
+
} from "./chunk-WVM2LTWQ.js";
|
|
66
110
|
import {
|
|
67
111
|
isOutside,
|
|
68
112
|
isPrimaryPress,
|
|
69
113
|
useOutsidePress
|
|
70
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-DQBKU7HI.js";
|
|
71
115
|
export {
|
|
72
116
|
BACK_ZONE_PX,
|
|
73
117
|
CLOSE_DISTANCE_PX,
|
|
74
118
|
COARSE_POINTER_QUERY,
|
|
119
|
+
DEFAULT_IGNORE_SELECTOR,
|
|
75
120
|
FOCUSABLE_SELECTOR,
|
|
76
121
|
FORWARD_ZONE_PX,
|
|
77
122
|
MAX_SWIPE_DURATION_MS,
|
|
78
123
|
OPEN_DISTANCE_PX,
|
|
79
124
|
REDUCED_MOTION_QUERY,
|
|
80
125
|
VERTICAL_CANCEL_PX,
|
|
126
|
+
canShareFiles,
|
|
127
|
+
computeKeyboardInset,
|
|
81
128
|
copyText,
|
|
82
129
|
createDebouncer,
|
|
130
|
+
deriveUpdateState,
|
|
83
131
|
detectApple,
|
|
132
|
+
detectPlatform,
|
|
84
133
|
focusableWithin,
|
|
134
|
+
getPushSupport,
|
|
85
135
|
handleBeforeUnload,
|
|
136
|
+
isEditableElement,
|
|
86
137
|
isEditableTarget,
|
|
138
|
+
isInIgnoredRegion,
|
|
87
139
|
isInOpenZone,
|
|
88
140
|
isInsideHorizontalScroller,
|
|
141
|
+
isIos,
|
|
142
|
+
isIosSafari,
|
|
89
143
|
isOutside,
|
|
90
144
|
isPrimaryPress,
|
|
145
|
+
isShareCancel,
|
|
146
|
+
isStandalone,
|
|
91
147
|
lockScroll,
|
|
92
148
|
matchHotkey,
|
|
93
149
|
nextDelay,
|
|
94
150
|
nextFocusTarget,
|
|
95
151
|
nextHeight,
|
|
96
152
|
parseHotkey,
|
|
153
|
+
readText,
|
|
97
154
|
resolveSwipeIntent,
|
|
155
|
+
shareOrCopy,
|
|
156
|
+
shareTextFor,
|
|
157
|
+
shouldResubscribe,
|
|
158
|
+
startInstallPromptCapture,
|
|
98
159
|
unlockScroll,
|
|
160
|
+
unregisterAll,
|
|
161
|
+
urlBase64ToUint8Array,
|
|
99
162
|
useAutoGrowTextarea,
|
|
100
163
|
useCoarsePointer,
|
|
101
164
|
useCopyFeedback,
|
|
@@ -105,10 +168,17 @@ export {
|
|
|
105
168
|
useEscape,
|
|
106
169
|
useFocusTrap,
|
|
107
170
|
useHotkey,
|
|
171
|
+
useInstallPrompt,
|
|
172
|
+
useIsStandalone,
|
|
173
|
+
useKeyboardInset,
|
|
108
174
|
useMediaQuery,
|
|
175
|
+
useOnlineStatus,
|
|
109
176
|
useOutsidePress,
|
|
177
|
+
usePushSubscription,
|
|
110
178
|
useReducedMotion,
|
|
111
179
|
useScrollLock,
|
|
180
|
+
useServiceWorker,
|
|
181
|
+
useShareFeedback,
|
|
112
182
|
useStorageState,
|
|
113
183
|
useUnsavedChangesGuard,
|
|
114
184
|
useVisibilityPolling
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/keyboard-inset/index.ts
|
|
22
|
+
var keyboard_inset_exports = {};
|
|
23
|
+
__export(keyboard_inset_exports, {
|
|
24
|
+
computeKeyboardInset: () => computeKeyboardInset,
|
|
25
|
+
isEditableElement: () => isEditableElement,
|
|
26
|
+
useKeyboardInset: () => useKeyboardInset
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(keyboard_inset_exports);
|
|
29
|
+
|
|
30
|
+
// src/keyboard-inset/use-keyboard-inset.ts
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
|
|
33
|
+
// src/keyboard-inset/compute-inset.ts
|
|
34
|
+
var DEFAULT_MIN_INSET = 150;
|
|
35
|
+
function computeKeyboardInset(r) {
|
|
36
|
+
if (!r.editableFocused) return 0;
|
|
37
|
+
const occluded = r.layoutHeight - r.visualHeight - r.visualOffsetTop;
|
|
38
|
+
return occluded >= (r.minInset ?? DEFAULT_MIN_INSET) ? Math.round(occluded) : 0;
|
|
39
|
+
}
|
|
40
|
+
var NON_TEXT_INPUT_TYPES = /* @__PURE__ */ new Set([
|
|
41
|
+
"button",
|
|
42
|
+
"checkbox",
|
|
43
|
+
"radio",
|
|
44
|
+
"range",
|
|
45
|
+
"submit",
|
|
46
|
+
"reset",
|
|
47
|
+
"file",
|
|
48
|
+
"color",
|
|
49
|
+
"image",
|
|
50
|
+
"hidden"
|
|
51
|
+
]);
|
|
52
|
+
function isEditableElement(el) {
|
|
53
|
+
if (!el) return false;
|
|
54
|
+
const tag = el.tagName.toLowerCase();
|
|
55
|
+
if (tag === "select") return !el.disabled;
|
|
56
|
+
if (tag === "textarea" || tag === "input") {
|
|
57
|
+
const field = el;
|
|
58
|
+
if (field.readOnly || field.disabled) return false;
|
|
59
|
+
return tag === "textarea" || !NON_TEXT_INPUT_TYPES.has(field.type);
|
|
60
|
+
}
|
|
61
|
+
if (el.isContentEditable === true) return true;
|
|
62
|
+
const attr = el.getAttribute("contenteditable");
|
|
63
|
+
return attr !== null && attr !== "false";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/keyboard-inset/use-keyboard-inset.ts
|
|
67
|
+
function useKeyboardInset({ minInset = DEFAULT_MIN_INSET, enabled = true } = {}) {
|
|
68
|
+
const [inset, setInset] = (0, import_react.useState)(0);
|
|
69
|
+
(0, import_react.useEffect)(() => {
|
|
70
|
+
const vv = typeof window === "undefined" ? null : window.visualViewport;
|
|
71
|
+
if (!enabled || !vv) {
|
|
72
|
+
setInset(0);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const update = () => setInset(
|
|
76
|
+
computeKeyboardInset({
|
|
77
|
+
layoutHeight: window.innerHeight,
|
|
78
|
+
visualHeight: vv.height,
|
|
79
|
+
visualOffsetTop: vv.offsetTop,
|
|
80
|
+
editableFocused: isEditableElement(document.activeElement),
|
|
81
|
+
minInset
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
let frame = 0;
|
|
85
|
+
const onFocusOut = () => {
|
|
86
|
+
cancelAnimationFrame(frame);
|
|
87
|
+
frame = requestAnimationFrame(update);
|
|
88
|
+
};
|
|
89
|
+
const onFocusIn = () => {
|
|
90
|
+
cancelAnimationFrame(frame);
|
|
91
|
+
update();
|
|
92
|
+
};
|
|
93
|
+
vv.addEventListener("resize", update);
|
|
94
|
+
vv.addEventListener("scroll", update);
|
|
95
|
+
document.addEventListener("focusin", onFocusIn);
|
|
96
|
+
document.addEventListener("focusout", onFocusOut);
|
|
97
|
+
update();
|
|
98
|
+
return () => {
|
|
99
|
+
cancelAnimationFrame(frame);
|
|
100
|
+
vv.removeEventListener("resize", update);
|
|
101
|
+
vv.removeEventListener("scroll", update);
|
|
102
|
+
document.removeEventListener("focusin", onFocusIn);
|
|
103
|
+
document.removeEventListener("focusout", onFocusOut);
|
|
104
|
+
};
|
|
105
|
+
}, [enabled, minInset]);
|
|
106
|
+
return inset;
|
|
107
|
+
}
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
computeKeyboardInset,
|
|
111
|
+
isEditableElement,
|
|
112
|
+
useKeyboardInset
|
|
113
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface UseKeyboardInsetOptions {
|
|
2
|
+
minInset?: number;
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare function useKeyboardInset({ minInset, enabled }?: UseKeyboardInsetOptions): number;
|
|
6
|
+
|
|
7
|
+
interface InsetReading {
|
|
8
|
+
layoutHeight: number;
|
|
9
|
+
visualHeight: number;
|
|
10
|
+
visualOffsetTop: number;
|
|
11
|
+
editableFocused: boolean;
|
|
12
|
+
minInset?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* How far the keyboard covers the bottom of the layout viewport. Zero unless a
|
|
16
|
+
* text field is focused: on newer iPhones the standalone PWA reports a gap
|
|
17
|
+
* between the layout and visual viewport with no keyboard up, which padded the
|
|
18
|
+
* composer ~100pt off the bottom of the screen. The smallest iOS keyboard is
|
|
19
|
+
* well over `minInset`; anything less is viewport noise (home-indicator area,
|
|
20
|
+
* toolbar, a stale post-dismiss offset).
|
|
21
|
+
*/
|
|
22
|
+
declare function computeKeyboardInset(r: InsetReading): number;
|
|
23
|
+
declare function isEditableElement(el: Element | null | undefined): boolean;
|
|
24
|
+
|
|
25
|
+
export { type InsetReading, type UseKeyboardInsetOptions, computeKeyboardInset, isEditableElement, useKeyboardInset };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface UseKeyboardInsetOptions {
|
|
2
|
+
minInset?: number;
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare function useKeyboardInset({ minInset, enabled }?: UseKeyboardInsetOptions): number;
|
|
6
|
+
|
|
7
|
+
interface InsetReading {
|
|
8
|
+
layoutHeight: number;
|
|
9
|
+
visualHeight: number;
|
|
10
|
+
visualOffsetTop: number;
|
|
11
|
+
editableFocused: boolean;
|
|
12
|
+
minInset?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* How far the keyboard covers the bottom of the layout viewport. Zero unless a
|
|
16
|
+
* text field is focused: on newer iPhones the standalone PWA reports a gap
|
|
17
|
+
* between the layout and visual viewport with no keyboard up, which padded the
|
|
18
|
+
* composer ~100pt off the bottom of the screen. The smallest iOS keyboard is
|
|
19
|
+
* well over `minInset`; anything less is viewport noise (home-indicator area,
|
|
20
|
+
* toolbar, a stale post-dismiss offset).
|
|
21
|
+
*/
|
|
22
|
+
declare function computeKeyboardInset(r: InsetReading): number;
|
|
23
|
+
declare function isEditableElement(el: Element | null | undefined): boolean;
|
|
24
|
+
|
|
25
|
+
export { type InsetReading, type UseKeyboardInsetOptions, computeKeyboardInset, isEditableElement, useKeyboardInset };
|
package/dist/media-query.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
COARSE_POINTER_QUERY,
|
|
4
|
-
REDUCED_MOTION_QUERY,
|
|
5
3
|
useCoarsePointer,
|
|
6
4
|
useMediaQuery,
|
|
7
5
|
useReducedMotion
|
|
8
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HTVNN2NM.js";
|
|
7
|
+
import {
|
|
8
|
+
COARSE_POINTER_QUERY,
|
|
9
|
+
REDUCED_MOTION_QUERY
|
|
10
|
+
} from "./chunk-WVM2LTWQ.js";
|
|
9
11
|
export {
|
|
10
12
|
COARSE_POINTER_QUERY,
|
|
11
13
|
REDUCED_MOTION_QUERY,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/online-status/index.ts
|
|
22
|
+
var online_status_exports = {};
|
|
23
|
+
__export(online_status_exports, {
|
|
24
|
+
useOnlineStatus: () => useOnlineStatus
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(online_status_exports);
|
|
27
|
+
|
|
28
|
+
// src/online-status/use-online-status.ts
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
function subscribe(callback) {
|
|
31
|
+
window.addEventListener("online", callback);
|
|
32
|
+
window.addEventListener("offline", callback);
|
|
33
|
+
return () => {
|
|
34
|
+
window.removeEventListener("online", callback);
|
|
35
|
+
window.removeEventListener("offline", callback);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
var getSnapshot = () => navigator.onLine;
|
|
39
|
+
var getServerSnapshot = () => true;
|
|
40
|
+
function useOnlineStatus() {
|
|
41
|
+
return (0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot);
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
useOnlineStatus
|
|
46
|
+
});
|
package/dist/outside-press.cjs
CHANGED
|
@@ -28,21 +28,28 @@ __export(outside_press_exports, {
|
|
|
28
28
|
module.exports = __toCommonJS(outside_press_exports);
|
|
29
29
|
|
|
30
30
|
// src/outside-press/outside-press.ts
|
|
31
|
-
function isOutside(target, elements) {
|
|
31
|
+
function isOutside(target, elements, ignoreSelector) {
|
|
32
32
|
if (!target) return false;
|
|
33
33
|
if (!target.isConnected) return false;
|
|
34
|
+
if (ignoreSelector && isInIgnoredRegion(target, ignoreSelector)) return false;
|
|
34
35
|
return !elements.some((el) => el?.contains(target));
|
|
35
36
|
}
|
|
36
37
|
function isPrimaryPress(event) {
|
|
37
38
|
return !(event.pointerType === "mouse" && event.button !== 0);
|
|
38
39
|
}
|
|
40
|
+
function isInIgnoredRegion(target, selector) {
|
|
41
|
+
const element = target instanceof Element ? target : target.parentElement;
|
|
42
|
+
return element?.closest(selector) != null;
|
|
43
|
+
}
|
|
39
44
|
|
|
40
45
|
// src/outside-press/use-outside-press.ts
|
|
41
46
|
var import_react = require("react");
|
|
42
|
-
function useOutsidePress(refs, onOutsidePress, { enabled = true } = {}) {
|
|
47
|
+
function useOutsidePress(refs, onOutsidePress, { enabled = true, ignore } = {}) {
|
|
43
48
|
const refsRef = (0, import_react.useRef)(refs);
|
|
44
49
|
const handlerRef = (0, import_react.useRef)(onOutsidePress);
|
|
50
|
+
const ignoreRef = (0, import_react.useRef)(ignore);
|
|
45
51
|
(0, import_react.useEffect)(() => {
|
|
52
|
+
ignoreRef.current = ignore;
|
|
46
53
|
refsRef.current = refs;
|
|
47
54
|
handlerRef.current = onOutsidePress;
|
|
48
55
|
});
|
|
@@ -52,7 +59,7 @@ function useOutsidePress(refs, onOutsidePress, { enabled = true } = {}) {
|
|
|
52
59
|
if (!isPrimaryPress(event)) return;
|
|
53
60
|
const list = Array.isArray(refsRef.current) ? refsRef.current : [refsRef.current];
|
|
54
61
|
const elements = list.map((ref) => ref.current);
|
|
55
|
-
if (isOutside(event.target, elements)) handlerRef.current(event);
|
|
62
|
+
if (isOutside(event.target, elements, ignoreRef.current)) handlerRef.current(event);
|
|
56
63
|
}
|
|
57
64
|
document.addEventListener("pointerdown", onPointerDown, true);
|
|
58
65
|
return () => document.removeEventListener("pointerdown", onPointerDown, true);
|
package/dist/outside-press.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
|
|
3
|
-
declare function isOutside(target: Node | null, elements: (Element | null)[]): boolean;
|
|
3
|
+
declare function isOutside(target: Node | null, elements: (Element | null)[], ignoreSelector?: string | null): boolean;
|
|
4
4
|
declare function isPrimaryPress(event: {
|
|
5
5
|
button?: number;
|
|
6
6
|
pointerType?: string;
|
|
@@ -9,7 +9,9 @@ declare function isPrimaryPress(event: {
|
|
|
9
9
|
type ElementRef = RefObject<Element | null>;
|
|
10
10
|
interface UseOutsidePressOptions {
|
|
11
11
|
enabled?: boolean;
|
|
12
|
+
/** A press inside an element matching this selector counts as inside. */
|
|
13
|
+
ignore?: string;
|
|
12
14
|
}
|
|
13
|
-
declare function useOutsidePress(refs: ElementRef | ElementRef[], onOutsidePress: (event: PointerEvent) => void, { enabled }?: UseOutsidePressOptions): void;
|
|
15
|
+
declare function useOutsidePress(refs: ElementRef | ElementRef[], onOutsidePress: (event: PointerEvent) => void, { enabled, ignore }?: UseOutsidePressOptions): void;
|
|
14
16
|
|
|
15
17
|
export { type UseOutsidePressOptions, isOutside, isPrimaryPress, useOutsidePress };
|
package/dist/outside-press.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
|
|
3
|
-
declare function isOutside(target: Node | null, elements: (Element | null)[]): boolean;
|
|
3
|
+
declare function isOutside(target: Node | null, elements: (Element | null)[], ignoreSelector?: string | null): boolean;
|
|
4
4
|
declare function isPrimaryPress(event: {
|
|
5
5
|
button?: number;
|
|
6
6
|
pointerType?: string;
|
|
@@ -9,7 +9,9 @@ declare function isPrimaryPress(event: {
|
|
|
9
9
|
type ElementRef = RefObject<Element | null>;
|
|
10
10
|
interface UseOutsidePressOptions {
|
|
11
11
|
enabled?: boolean;
|
|
12
|
+
/** A press inside an element matching this selector counts as inside. */
|
|
13
|
+
ignore?: string;
|
|
12
14
|
}
|
|
13
|
-
declare function useOutsidePress(refs: ElementRef | ElementRef[], onOutsidePress: (event: PointerEvent) => void, { enabled }?: UseOutsidePressOptions): void;
|
|
15
|
+
declare function useOutsidePress(refs: ElementRef | ElementRef[], onOutsidePress: (event: PointerEvent) => void, { enabled, ignore }?: UseOutsidePressOptions): void;
|
|
14
16
|
|
|
15
17
|
export { type UseOutsidePressOptions, isOutside, isPrimaryPress, useOutsidePress };
|