@celljs/ta-web 4.9.1 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +4 -3
- package/README.md +4 -3
- package/esm/browser/assistant/assistant-chat-list.js +8 -2
- package/esm/browser/assistant/assistant-extension.d.ts +8 -1
- package/esm/browser/assistant/assistant-extension.js +20 -0
- package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
- package/esm/browser/assistant/assistant-task-util.d.ts +2 -0
- package/esm/browser/assistant/assistant-task-util.js +5 -3
- package/esm/browser/assistant/assistant-view.js +81 -56
- package/esm/browser/assistant/assistant.d.ts +10 -1
- package/esm/browser/assistant/assistant.js +44 -5
- package/esm/browser/chat/chat-packages.d.ts +39 -0
- package/esm/browser/chat/chat-packages.js +70 -0
- package/esm/browser/chat/chat-protocol.d.ts +23 -1
- package/esm/browser/chat/chat-stores.d.ts +59 -0
- package/esm/browser/chat/chat-stores.js +121 -0
- package/esm/browser/chat/chat-util.d.ts +17 -0
- package/esm/browser/chat/chat-util.js +61 -0
- package/esm/browser/chat/chat-view.js +33 -12
- package/esm/browser/chat/chat.d.ts +31 -39
- package/esm/browser/chat/chat.js +226 -175
- package/esm/browser/components/app-nav.d.ts +6 -3
- package/esm/browser/components/app-nav.js +19 -10
- package/esm/browser/components/app-shell-hooks.d.ts +2 -2
- package/esm/browser/components/app-shell-hooks.js +7 -3
- package/esm/browser/components/app-view.js +75 -21
- package/esm/browser/components/chat-list.d.ts +20 -2
- package/esm/browser/components/chat-list.js +138 -22
- package/esm/browser/components/composer-box.d.ts +5 -5
- package/esm/browser/components/composer-box.js +111 -4
- package/esm/browser/components/composer.d.ts +7 -0
- package/esm/browser/components/composer.js +5 -4
- package/esm/browser/components/connection-bar.js +50 -17
- package/esm/browser/components/context-menu.d.ts +30 -4
- package/esm/browser/components/context-menu.js +199 -37
- package/esm/browser/components/conversation-scroll.d.ts +129 -6
- package/esm/browser/components/conversation-scroll.js +429 -109
- package/esm/browser/components/earlier-messages.d.ts +2 -1
- package/esm/browser/components/earlier-messages.js +2 -17
- package/esm/browser/components/editor-area.d.ts +3 -1
- package/esm/browser/components/editor-area.js +6 -5
- package/esm/browser/components/empty-pictures.d.ts +0 -2
- package/esm/browser/components/empty-pictures.js +0 -16
- package/esm/browser/components/folder-picker.d.ts +5 -2
- package/esm/browser/components/folder-picker.js +26 -8
- package/esm/browser/components/held-talk.d.ts +28 -0
- package/esm/browser/components/held-talk.js +76 -0
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/icon.d.ts +2 -2
- package/esm/browser/components/icon.js +5 -6
- package/esm/browser/components/image-viewer.d.ts +124 -0
- package/esm/browser/components/image-viewer.js +397 -0
- package/esm/browser/components/lightbox.d.ts +11 -0
- package/esm/browser/components/lightbox.js +24 -0
- package/esm/browser/components/markdown.d.ts +6 -2
- package/esm/browser/components/markdown.js +24 -10
- package/esm/browser/components/media.js +1 -10
- package/esm/browser/components/message-footer.d.ts +16 -2
- package/esm/browser/components/message-footer.js +29 -12
- package/esm/browser/components/message-list.d.ts +24 -3
- package/esm/browser/components/message-list.js +149 -20
- package/esm/browser/components/message-menu.d.ts +3 -1
- package/esm/browser/components/message-menu.js +18 -3
- package/esm/browser/components/nav-places.d.ts +16 -1
- package/esm/browser/components/nav-places.js +12 -3
- package/esm/browser/components/phone-shell.d.ts +4 -1
- package/esm/browser/components/phone-shell.js +3 -1
- package/esm/browser/components/run-status.js +3 -3
- package/esm/browser/components/session-settings.d.ts +6 -0
- package/esm/browser/components/session-settings.js +14 -1
- package/esm/browser/components/session-view.js +8 -4
- package/esm/browser/components/settings-parts.d.ts +2 -2
- package/esm/browser/components/settings-parts.js +24 -1
- package/esm/browser/components/swipe-row.d.ts +2 -2
- package/esm/browser/components/swipe-row.js +7 -3
- package/esm/browser/components/tool-view.js +14 -12
- package/esm/browser/components/voice-button.d.ts +1 -1
- package/esm/browser/components/voice-button.js +1 -1
- package/esm/browser/components/voice-talk.d.ts +43 -0
- package/esm/browser/components/voice-talk.js +222 -0
- package/esm/browser/device/device.d.ts +3 -0
- package/esm/browser/device/device.js +11 -1
- package/esm/browser/device/hold.d.ts +42 -0
- package/esm/browser/device/hold.js +136 -0
- package/esm/browser/device/launch-screen.d.ts +1 -1
- package/esm/browser/device/launch-screen.js +1 -1
- package/esm/browser/device/long-press.d.ts +2 -0
- package/esm/browser/device/long-press.js +16 -1
- package/esm/browser/device/pull-down.d.ts +4 -2
- package/esm/browser/device/pull-down.js +64 -76
- package/esm/browser/device/row-swipe.d.ts +35 -10
- package/esm/browser/device/row-swipe.js +149 -71
- package/esm/browser/device/shake-undo.d.ts +16 -0
- package/esm/browser/device/shake-undo.js +59 -0
- package/esm/browser/device/sheet-swipe.d.ts +118 -18
- package/esm/browser/device/sheet-swipe.js +406 -107
- package/esm/browser/extension/web-extension-api.d.ts +97 -1
- package/esm/browser/extension/web-extension-code.d.ts +6 -0
- package/esm/browser/extension/web-extension-code.js +24 -0
- package/esm/browser/extension/web-extension-protocol.d.ts +23 -1
- package/esm/browser/extension/web-extension-protocol.js +8 -0
- package/esm/browser/extension/web-extensions.d.ts +14 -1
- package/esm/browser/extension/web-extensions.js +122 -23
- package/esm/browser/files/files-protocol.d.ts +25 -0
- package/esm/browser/files/files-protocol.js +2 -0
- package/esm/browser/files/files.d.ts +35 -0
- package/esm/browser/files/files.js +119 -0
- package/esm/browser/i18n/locales.d.ts +24 -2
- package/esm/browser/i18n/messages.d.ts +23 -1
- package/esm/browser/i18n/messages.js +48 -4
- package/esm/browser/index.d.ts +6 -0
- package/esm/browser/index.js +6 -0
- package/esm/browser/notices/notices-protocol.d.ts +9 -1
- package/esm/browser/notices/notices.d.ts +2 -0
- package/esm/browser/notices/notices.js +20 -10
- package/esm/browser/offline/device-values.d.ts +55 -0
- package/esm/browser/offline/device-values.js +142 -0
- package/esm/browser/offline/kept-chats-protocol.d.ts +17 -0
- package/esm/browser/offline/kept-chats-protocol.js +2 -0
- package/esm/browser/offline/kept-chats.d.ts +47 -0
- package/esm/browser/offline/kept-chats.js +146 -0
- package/esm/browser/offline/offline-reads.d.ts +44 -0
- package/esm/browser/offline/offline-reads.js +107 -0
- package/esm/browser/settings/settings-protocol.d.ts +2 -0
- package/esm/browser/settings/settings-protocol.js +2 -0
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +57 -17
- package/esm/browser/style/device.js +27 -4
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +67 -15
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +2 -1
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +46 -3
- package/esm/browser/util/frame.d.ts +5 -4
- package/esm/browser/util/frame.js +5 -4
- package/esm/browser/util/markdown.d.ts +18 -1
- package/esm/browser/util/markdown.js +119 -5
- package/esm/browser/util/process.d.ts +21 -0
- package/esm/browser/util/process.js +45 -1
- package/esm/browser/util/voice.d.ts +5 -2
- package/esm/browser/util/voice.js +6 -3
- package/esm/browser/util/zoom.d.ts +46 -0
- package/esm/browser/util/zoom.js +96 -0
- package/esm/browser/workbench-calls.d.ts +59 -0
- package/esm/browser/workbench-calls.js +141 -0
- package/esm/browser/workbench-protocol.d.ts +5 -1
- package/esm/browser/workbench-util.d.ts +7 -0
- package/esm/browser/workbench-util.js +9 -2
- package/esm/browser/workbench.d.ts +14 -5
- package/esm/browser/workbench.js +51 -31
- package/lib/browser/assistant/assistant-chat-list.js +8 -2
- package/lib/browser/assistant/assistant-extension.d.ts +8 -1
- package/lib/browser/assistant/assistant-extension.js +20 -0
- package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
- package/lib/browser/assistant/assistant-task-util.d.ts +2 -0
- package/lib/browser/assistant/assistant-task-util.js +5 -3
- package/lib/browser/assistant/assistant-view.js +78 -53
- package/lib/browser/assistant/assistant.d.ts +10 -1
- package/lib/browser/assistant/assistant.js +44 -5
- package/lib/browser/chat/chat-packages.d.ts +40 -0
- package/lib/browser/chat/chat-packages.js +74 -0
- package/lib/browser/chat/chat-protocol.d.ts +23 -1
- package/lib/browser/chat/chat-stores.d.ts +60 -0
- package/lib/browser/chat/chat-stores.js +125 -0
- package/lib/browser/chat/chat-util.d.ts +18 -0
- package/lib/browser/chat/chat-util.js +64 -0
- package/lib/browser/chat/chat-view.js +33 -12
- package/lib/browser/chat/chat.d.ts +31 -39
- package/lib/browser/chat/chat.js +227 -176
- package/lib/browser/components/app-nav.d.ts +6 -3
- package/lib/browser/components/app-nav.js +17 -8
- package/lib/browser/components/app-shell-hooks.d.ts +2 -2
- package/lib/browser/components/app-shell-hooks.js +7 -3
- package/lib/browser/components/app-view.js +74 -20
- package/lib/browser/components/chat-list.d.ts +20 -2
- package/lib/browser/components/chat-list.js +137 -21
- package/lib/browser/components/composer-box.d.ts +5 -5
- package/lib/browser/components/composer-box.js +111 -4
- package/lib/browser/components/composer.d.ts +7 -0
- package/lib/browser/components/composer.js +5 -4
- package/lib/browser/components/connection-bar.js +48 -15
- package/lib/browser/components/context-menu.d.ts +30 -4
- package/lib/browser/components/context-menu.js +198 -36
- package/lib/browser/components/conversation-scroll.d.ts +129 -6
- package/lib/browser/components/conversation-scroll.js +431 -110
- package/lib/browser/components/earlier-messages.d.ts +2 -1
- package/lib/browser/components/earlier-messages.js +2 -17
- package/lib/browser/components/editor-area.d.ts +3 -1
- package/lib/browser/components/editor-area.js +5 -4
- package/lib/browser/components/empty-pictures.d.ts +0 -2
- package/lib/browser/components/empty-pictures.js +0 -17
- package/lib/browser/components/folder-picker.d.ts +5 -2
- package/lib/browser/components/folder-picker.js +26 -8
- package/lib/browser/components/held-talk.d.ts +29 -0
- package/lib/browser/components/held-talk.js +79 -0
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/icon.d.ts +2 -2
- package/lib/browser/components/icon.js +7 -6
- package/lib/browser/components/image-viewer.d.ts +125 -0
- package/lib/browser/components/image-viewer.js +435 -0
- package/lib/browser/components/lightbox.d.ts +12 -0
- package/lib/browser/components/lightbox.js +60 -0
- package/lib/browser/components/markdown.d.ts +6 -2
- package/lib/browser/components/markdown.js +24 -10
- package/lib/browser/components/media.js +2 -11
- package/lib/browser/components/message-footer.d.ts +16 -2
- package/lib/browser/components/message-footer.js +31 -12
- package/lib/browser/components/message-list.d.ts +24 -3
- package/lib/browser/components/message-list.js +146 -16
- package/lib/browser/components/message-menu.d.ts +3 -1
- package/lib/browser/components/message-menu.js +17 -2
- package/lib/browser/components/nav-places.d.ts +16 -1
- package/lib/browser/components/nav-places.js +13 -3
- package/lib/browser/components/phone-shell.d.ts +4 -1
- package/lib/browser/components/phone-shell.js +3 -1
- package/lib/browser/components/run-status.js +3 -3
- package/lib/browser/components/session-settings.d.ts +6 -0
- package/lib/browser/components/session-settings.js +14 -1
- package/lib/browser/components/session-view.js +7 -3
- package/lib/browser/components/settings-parts.d.ts +2 -2
- package/lib/browser/components/settings-parts.js +24 -1
- package/lib/browser/components/swipe-row.d.ts +2 -2
- package/lib/browser/components/swipe-row.js +7 -3
- package/lib/browser/components/tool-view.js +14 -12
- package/lib/browser/components/voice-button.d.ts +1 -1
- package/lib/browser/components/voice-button.js +1 -1
- package/lib/browser/components/voice-talk.d.ts +44 -0
- package/lib/browser/components/voice-talk.js +260 -0
- package/lib/browser/device/device.d.ts +3 -0
- package/lib/browser/device/device.js +11 -1
- package/lib/browser/device/hold.d.ts +43 -0
- package/lib/browser/device/hold.js +173 -0
- package/lib/browser/device/launch-screen.d.ts +1 -1
- package/lib/browser/device/launch-screen.js +1 -1
- package/lib/browser/device/long-press.d.ts +2 -0
- package/lib/browser/device/long-press.js +16 -1
- package/lib/browser/device/pull-down.d.ts +4 -2
- package/lib/browser/device/pull-down.js +63 -75
- package/lib/browser/device/row-swipe.d.ts +35 -10
- package/lib/browser/device/row-swipe.js +148 -70
- package/lib/browser/device/shake-undo.d.ts +17 -0
- package/lib/browser/device/shake-undo.js +63 -0
- package/lib/browser/device/sheet-swipe.d.ts +118 -18
- package/lib/browser/device/sheet-swipe.js +410 -108
- package/lib/browser/extension/web-extension-api.d.ts +97 -1
- package/lib/browser/extension/web-extension-code.d.ts +6 -0
- package/lib/browser/extension/web-extension-code.js +24 -0
- package/lib/browser/extension/web-extension-protocol.d.ts +23 -1
- package/lib/browser/extension/web-extension-protocol.js +9 -1
- package/lib/browser/extension/web-extensions.d.ts +14 -1
- package/lib/browser/extension/web-extensions.js +120 -21
- package/lib/browser/files/files-protocol.d.ts +26 -0
- package/lib/browser/files/files-protocol.js +5 -0
- package/lib/browser/files/files.d.ts +36 -0
- package/lib/browser/files/files.js +122 -0
- package/lib/browser/i18n/locales.d.ts +24 -2
- package/lib/browser/i18n/messages.d.ts +23 -1
- package/lib/browser/i18n/messages.js +48 -4
- package/lib/browser/index.d.ts +6 -0
- package/lib/browser/index.js +6 -0
- package/lib/browser/notices/notices-protocol.d.ts +9 -1
- package/lib/browser/notices/notices.d.ts +2 -0
- package/lib/browser/notices/notices.js +20 -10
- package/lib/browser/offline/device-values.d.ts +56 -0
- package/lib/browser/offline/device-values.js +148 -0
- package/lib/browser/offline/kept-chats-protocol.d.ts +18 -0
- package/lib/browser/offline/kept-chats-protocol.js +5 -0
- package/lib/browser/offline/kept-chats.d.ts +48 -0
- package/lib/browser/offline/kept-chats.js +149 -0
- package/lib/browser/offline/offline-reads.d.ts +45 -0
- package/lib/browser/offline/offline-reads.js +111 -0
- package/lib/browser/settings/settings-protocol.d.ts +2 -0
- package/lib/browser/settings/settings-protocol.js +2 -0
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +57 -17
- package/lib/browser/style/device.js +27 -4
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +67 -15
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +2 -1
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +46 -3
- package/lib/browser/util/frame.d.ts +5 -4
- package/lib/browser/util/frame.js +5 -4
- package/lib/browser/util/markdown.d.ts +18 -1
- package/lib/browser/util/markdown.js +119 -5
- package/lib/browser/util/process.d.ts +21 -0
- package/lib/browser/util/process.js +46 -2
- package/lib/browser/util/voice.d.ts +5 -2
- package/lib/browser/util/voice.js +6 -3
- package/lib/browser/util/zoom.d.ts +47 -0
- package/lib/browser/util/zoom.js +99 -0
- package/lib/browser/workbench-calls.d.ts +60 -0
- package/lib/browser/workbench-calls.js +145 -0
- package/lib/browser/workbench-protocol.d.ts +5 -1
- package/lib/browser/workbench-util.d.ts +7 -0
- package/lib/browser/workbench-util.js +10 -3
- package/lib/browser/workbench.d.ts +14 -5
- package/lib/browser/workbench.js +51 -31
- package/package.json +10 -10
- package/public/launch.svg +46 -42
|
@@ -42,6 +42,7 @@ const device_protocol_1 = require("./device-protocol");
|
|
|
42
42
|
const field_dismiss_1 = require("./field-dismiss");
|
|
43
43
|
const long_press_1 = require("./long-press");
|
|
44
44
|
const new_line_1 = require("./new-line");
|
|
45
|
+
const shake_undo_1 = require("./shake-undo");
|
|
45
46
|
/** How much of the height the keyboard has to take before it counts as open: more than the bars of a browser. */
|
|
46
47
|
const KEYBOARD_PX = 80;
|
|
47
48
|
var DeviceUtil;
|
|
@@ -134,6 +135,9 @@ class DeviceObserver {
|
|
|
134
135
|
if (env.newLine) {
|
|
135
136
|
(0, new_line_1.startNewLine)(env.document, env.newLine);
|
|
136
137
|
}
|
|
138
|
+
if (env.shakeUndo) {
|
|
139
|
+
(0, shake_undo_1.startShakeUndo)(env.document, env.shakeUndo);
|
|
140
|
+
}
|
|
137
141
|
}
|
|
138
142
|
if (env.keyboard) {
|
|
139
143
|
env.keyboard(height => this.moveKeyboard(height));
|
|
@@ -234,9 +238,15 @@ function browser() {
|
|
|
234
238
|
root: document.documentElement,
|
|
235
239
|
native: nativeBridge(),
|
|
236
240
|
keyboard: nativeKeyboard(),
|
|
237
|
-
newLine: (
|
|
241
|
+
newLine: (_a = messageHandlers()) === null || _a === void 0 ? void 0 : _a.taEditing,
|
|
242
|
+
shakeUndo: (_b = messageHandlers()) === null || _b === void 0 ? void 0 : _b.taUndo,
|
|
238
243
|
};
|
|
239
244
|
}
|
|
245
|
+
/** What the Ta app on iOS listens to from the page (TaBridgeViewController of apps/ta-mobile); none elsewhere. */
|
|
246
|
+
function messageHandlers() {
|
|
247
|
+
var _a;
|
|
248
|
+
return (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers;
|
|
249
|
+
}
|
|
240
250
|
/** One plugin of the Ta app (Capacitor), when the app has it; none in a browser, or in an app built before it. */
|
|
241
251
|
function nativePlugin(name) {
|
|
242
252
|
var _a;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* What a held finger does, as the talk button of a phone's chat: it starts once the finger has been kept still
|
|
4
|
+
* for PRESS_MS, follows the finger while it stays, and ends when it lets go.
|
|
5
|
+
*/
|
|
6
|
+
export interface Hold {
|
|
7
|
+
/** Whether a press is the hold's (a field, a button of its own are not); every press is, without it. */
|
|
8
|
+
accepts?(event: React.PointerEvent): boolean;
|
|
9
|
+
start(): void;
|
|
10
|
+
/** Where the finger is while it is held, in the coordinates of the page. */
|
|
11
|
+
move?(x: number, y: number): void;
|
|
12
|
+
/** The finger let go. */
|
|
13
|
+
end(): void;
|
|
14
|
+
/** The system took the finger (a gesture of its own, a call): nothing is given. */
|
|
15
|
+
cancel(): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* What an element takes of the pointer, for the hold it has. `data-held` takes the panning of a finger from the
|
|
19
|
+
* browser (style/device.ts): it decides that as the finger lands, too early for a hold, and a pan it began takes
|
|
20
|
+
* the finger from the page (pointercancel) as soon as it slides toward 取消.
|
|
21
|
+
*/
|
|
22
|
+
export interface HeldProps {
|
|
23
|
+
onPointerDown?(event: React.PointerEvent): void;
|
|
24
|
+
onContextMenu?(event: React.MouseEvent): void;
|
|
25
|
+
'data-held'?: '';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Something done while an element is held. A press that moves first scrolls, and one let go before PRESS_MS
|
|
29
|
+
* starts nothing, so that a tap stays a tap. Once held, the finger is the hold's until it lets go: the page does
|
|
30
|
+
* not scroll under it, the system's menu and selection do not come, the click of the finger let go is not a tap
|
|
31
|
+
* of what was under it, and the hold outlives the element (a tab bar that a page slides over).
|
|
32
|
+
*/
|
|
33
|
+
export declare function useHeld(): (hold: Hold | undefined) => HeldProps;
|
|
34
|
+
export declare namespace HeldUtil {
|
|
35
|
+
/** A light tap of the haptic engine as a held finger comes onto something (取消, 编辑): the app's, or a phone's. */
|
|
36
|
+
function tick(): void;
|
|
37
|
+
/**
|
|
38
|
+
* The click that follows a finger let go after a hold: not a tap of what was under it. A browser that sends
|
|
39
|
+
* none (a long press is no tap to it) leaves the next press its own.
|
|
40
|
+
*/
|
|
41
|
+
function swallowClick(): void;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=hold.d.ts.map
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.HeldUtil = void 0;
|
|
37
|
+
exports.useHeld = useHeld;
|
|
38
|
+
const React = __importStar(require("react"));
|
|
39
|
+
const device_1 = require("./device");
|
|
40
|
+
const long_press_1 = require("./long-press");
|
|
41
|
+
/**
|
|
42
|
+
* Something done while an element is held. A press that moves first scrolls, and one let go before PRESS_MS
|
|
43
|
+
* starts nothing, so that a tap stays a tap. Once held, the finger is the hold's until it lets go: the page does
|
|
44
|
+
* not scroll under it, the system's menu and selection do not come, the click of the finger let go is not a tap
|
|
45
|
+
* of what was under it, and the hold outlives the element (a tab bar that a page slides over).
|
|
46
|
+
*/
|
|
47
|
+
function useHeld() {
|
|
48
|
+
const current = React.useRef(undefined);
|
|
49
|
+
// Gone before it held, the press is nothing; once held, it ends when the finger lets go.
|
|
50
|
+
React.useEffect(() => () => {
|
|
51
|
+
const press = current.current;
|
|
52
|
+
if (press && !press.held) {
|
|
53
|
+
clearTimeout(press.timer);
|
|
54
|
+
press.off();
|
|
55
|
+
current.current = undefined;
|
|
56
|
+
}
|
|
57
|
+
}, []);
|
|
58
|
+
return React.useCallback((hold) => {
|
|
59
|
+
if (!hold) {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
'data-held': '',
|
|
64
|
+
onPointerDown: event => {
|
|
65
|
+
if (current.current || !event.isPrimary || event.button !== 0 || (hold.accepts && !hold.accepts(event))) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const from = { x: event.clientX, y: event.clientY };
|
|
69
|
+
const finish = (how) => {
|
|
70
|
+
if (current.current !== press) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
current.current = undefined;
|
|
74
|
+
clearTimeout(press.timer);
|
|
75
|
+
press.off();
|
|
76
|
+
if (!press.held || how === 'none') {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
HeldUtil.swallowClick();
|
|
80
|
+
if (how === 'end') {
|
|
81
|
+
hold.end();
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
hold.cancel();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const onUp = () => finish('end');
|
|
88
|
+
const onCancel = () => finish('cancel');
|
|
89
|
+
const onMove = (moved) => {
|
|
90
|
+
var _a;
|
|
91
|
+
if (press.held) {
|
|
92
|
+
(_a = hold.move) === null || _a === void 0 ? void 0 : _a.call(hold, moved.clientX, moved.clientY);
|
|
93
|
+
}
|
|
94
|
+
else if (long_press_1.LongPressUtil.moved(from, moved)) {
|
|
95
|
+
finish('none');
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
// Held, the finger drags nothing: no scroll, which would take it from the hold (pointercancel).
|
|
99
|
+
const onTouchMove = (touch) => press.held && touch.cancelable && touch.preventDefault();
|
|
100
|
+
const onSelect = (select) => press.held && select.preventDefault();
|
|
101
|
+
const press = {
|
|
102
|
+
hold,
|
|
103
|
+
held: false,
|
|
104
|
+
timer: setTimeout(() => {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
press.held = true;
|
|
107
|
+
(_a = document.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
108
|
+
hold.start();
|
|
109
|
+
(_b = hold.move) === null || _b === void 0 ? void 0 : _b.call(hold, from.x, from.y);
|
|
110
|
+
}, long_press_1.LongPressUtil.PRESS_MS),
|
|
111
|
+
off: () => {
|
|
112
|
+
document.removeEventListener('pointerup', onUp);
|
|
113
|
+
document.removeEventListener('pointercancel', onCancel);
|
|
114
|
+
document.removeEventListener('pointermove', onMove);
|
|
115
|
+
document.removeEventListener('touchmove', onTouchMove);
|
|
116
|
+
document.removeEventListener('selectstart', onSelect, true);
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
current.current = press;
|
|
120
|
+
document.addEventListener('pointerup', onUp);
|
|
121
|
+
document.addEventListener('pointercancel', onCancel);
|
|
122
|
+
document.addEventListener('pointermove', onMove);
|
|
123
|
+
document.addEventListener('touchmove', onTouchMove, { passive: false });
|
|
124
|
+
document.addEventListener('selectstart', onSelect, true);
|
|
125
|
+
},
|
|
126
|
+
// The long press of a finger (the system's, or startLongPress's) is the hold's: no menu. Taken, it is
|
|
127
|
+
// also what gives the light tap of the haptic engine in the app. A right click is the browser's.
|
|
128
|
+
onContextMenu: event => {
|
|
129
|
+
if (current.current) {
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}, []);
|
|
135
|
+
}
|
|
136
|
+
var HeldUtil;
|
|
137
|
+
(function (HeldUtil) {
|
|
138
|
+
/** A light tap of the haptic engine as a held finger comes onto something (取消, 编辑): the app's, or a phone's. */
|
|
139
|
+
function tick() {
|
|
140
|
+
var _a, _b;
|
|
141
|
+
const haptics = (0, device_1.nativePlugin)('Haptics');
|
|
142
|
+
if (haptics) {
|
|
143
|
+
haptics('impact', { style: 'LIGHT' }).catch(() => undefined);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
(_b = (_a = globalThis.navigator) === null || _a === void 0 ? void 0 : _a.vibrate) === null || _b === void 0 ? void 0 : _b.call(_a, 8);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
HeldUtil.tick = tick;
|
|
150
|
+
/**
|
|
151
|
+
* The click that follows a finger let go after a hold: not a tap of what was under it. A browser that sends
|
|
152
|
+
* none (a long press is no tap to it) leaves the next press its own.
|
|
153
|
+
*/
|
|
154
|
+
function swallowClick() {
|
|
155
|
+
const until = Date.now() + long_press_1.LongPressUtil.CLICK_GUARD_MS;
|
|
156
|
+
const off = () => {
|
|
157
|
+
document.removeEventListener('click', swallow, true);
|
|
158
|
+
document.removeEventListener('pointerdown', off, true);
|
|
159
|
+
};
|
|
160
|
+
const swallow = (event) => {
|
|
161
|
+
off();
|
|
162
|
+
if (Date.now() < until) {
|
|
163
|
+
event.preventDefault();
|
|
164
|
+
event.stopPropagation();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
document.addEventListener('click', swallow, true);
|
|
168
|
+
document.addEventListener('pointerdown', off, true);
|
|
169
|
+
setTimeout(off, long_press_1.LongPressUtil.CLICK_GUARD_MS);
|
|
170
|
+
}
|
|
171
|
+
HeldUtil.swallowClick = swallowClick;
|
|
172
|
+
})(HeldUtil || (exports.HeldUtil = HeldUtil = {}));
|
|
173
|
+
//# sourceMappingURL=hold.js.map
|
|
@@ -17,7 +17,7 @@ export interface LaunchEnvironment {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare class LaunchScreen {
|
|
19
19
|
protected readonly env: LaunchEnvironment;
|
|
20
|
-
static readonly MAX =
|
|
20
|
+
static readonly MAX = 2000;
|
|
21
21
|
static readonly FADE = 320;
|
|
22
22
|
protected done: boolean;
|
|
23
23
|
protected stops: (() => void)[];
|
|
@@ -11,6 +11,8 @@ export declare namespace LongPressUtil {
|
|
|
11
11
|
const MOVE_PX = 10;
|
|
12
12
|
/** After a menu opened, the click of the finger let go is not a tap of what was under it. */
|
|
13
13
|
const CLICK_GUARD_MS = 800;
|
|
14
|
+
/** What the finger of a long press that opened a menu pressed, while it is still down. */
|
|
15
|
+
function held(): Element | undefined;
|
|
14
16
|
function moved(from: {
|
|
15
17
|
x: number;
|
|
16
18
|
y: number;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LongPressUtil = void 0;
|
|
4
4
|
exports.startLongPress = startLongPress;
|
|
5
|
+
/** What a long press that opened a menu pressed, while the finger is still down: it may slide onto an entry (ContextMenuUtil.attach). */
|
|
6
|
+
let holding;
|
|
5
7
|
/**
|
|
6
8
|
* A long press as the right click of a finger: what a right click opens (the menus of tabs, files, chats,
|
|
7
9
|
* messages) opens under a held finger too, as in the apps of a phone. iOS fires no `contextmenu` on a long
|
|
@@ -15,6 +17,11 @@ var LongPressUtil;
|
|
|
15
17
|
LongPressUtil.MOVE_PX = 10;
|
|
16
18
|
/** After a menu opened, the click of the finger let go is not a tap of what was under it. */
|
|
17
19
|
LongPressUtil.CLICK_GUARD_MS = 800;
|
|
20
|
+
/** What the finger of a long press that opened a menu pressed, while it is still down. */
|
|
21
|
+
function held() {
|
|
22
|
+
return holding;
|
|
23
|
+
}
|
|
24
|
+
LongPressUtil.held = held;
|
|
18
25
|
function moved(from, to) {
|
|
19
26
|
return Math.hypot(to.x - from.x, to.y - from.y) > LongPressUtil.MOVE_PX;
|
|
20
27
|
}
|
|
@@ -41,6 +48,7 @@ function startLongPress(doc, native) {
|
|
|
41
48
|
const end = () => {
|
|
42
49
|
var _a;
|
|
43
50
|
cancel();
|
|
51
|
+
holding = undefined;
|
|
44
52
|
if (taken) {
|
|
45
53
|
taken = false;
|
|
46
54
|
(_a = doc.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
@@ -65,6 +73,8 @@ function startLongPress(doc, native) {
|
|
|
65
73
|
return;
|
|
66
74
|
}
|
|
67
75
|
sent = true;
|
|
76
|
+
// Before the menu renders, which may be before dispatchEvent returns.
|
|
77
|
+
holding = current.target;
|
|
68
78
|
const event = new MouseEvent('contextmenu', { bubbles: true, cancelable: true, composed: true, clientX: current.x, clientY: current.y, button: 2 });
|
|
69
79
|
current.target.dispatchEvent(event);
|
|
70
80
|
if (event.defaultPrevented) {
|
|
@@ -74,11 +84,15 @@ function startLongPress(doc, native) {
|
|
|
74
84
|
(_a = doc.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
75
85
|
native === null || native === void 0 ? void 0 : native('Haptics', 'impact', { style: 'LIGHT' }).catch(() => undefined);
|
|
76
86
|
}
|
|
87
|
+
else {
|
|
88
|
+
holding = undefined;
|
|
89
|
+
}
|
|
77
90
|
};
|
|
78
91
|
const onStart = (event) => {
|
|
79
92
|
cancel();
|
|
80
93
|
sent = false;
|
|
81
94
|
taken = false;
|
|
95
|
+
holding = undefined;
|
|
82
96
|
const touch = event.touches[0];
|
|
83
97
|
const target = event.target instanceof Element ? event.target : null;
|
|
84
98
|
if (event.touches.length !== 1 || !touch || !target || LongPressUtil.native(target)) {
|
|
@@ -107,7 +121,8 @@ function startLongPress(doc, native) {
|
|
|
107
121
|
}
|
|
108
122
|
};
|
|
109
123
|
const onClick = (event) => {
|
|
110
|
-
|
|
124
|
+
// The click of the finger let go; not an entry the finger slid onto, which the menu clicks.
|
|
125
|
+
if (event.isTrusted && Date.now() < guardUntil) {
|
|
111
126
|
guardUntil = 0;
|
|
112
127
|
event.preventDefault();
|
|
113
128
|
event.stopImmediatePropagation();
|
|
@@ -40,8 +40,10 @@ export interface PullDownOptions {
|
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Lets a finger pull the launcher down over the first tab while `enabled`. As useSheetSwipe: transforms and
|
|
43
|
-
* opacities only,
|
|
44
|
-
*
|
|
43
|
+
* opacities only, the listener that may hold a move back there only for a touch that may be a pull, the finger
|
|
44
|
+
* followed on what it touched (SwipeFinger), and let go it slides on at once as on a spring (SwipeSettle), the
|
|
45
|
+
* state following. A pull down is decided on the first move (iOS lets a scroll that started go on), only at
|
|
46
|
+
* the top of the list.
|
|
45
47
|
*/
|
|
46
48
|
export declare function usePullDown(options: PullDownOptions): void;
|
|
47
49
|
//# sourceMappingURL=pull-down.d.ts.map
|
|
@@ -121,8 +121,10 @@ function tick() {
|
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
123
|
* Lets a finger pull the launcher down over the first tab while `enabled`. As useSheetSwipe: transforms and
|
|
124
|
-
* opacities only,
|
|
125
|
-
*
|
|
124
|
+
* opacities only, the listener that may hold a move back there only for a touch that may be a pull, the finger
|
|
125
|
+
* followed on what it touched (SwipeFinger), and let go it slides on at once as on a spring (SwipeSettle), the
|
|
126
|
+
* state following. A pull down is decided on the first move (iOS lets a scroll that started go on), only at
|
|
127
|
+
* the top of the list.
|
|
126
128
|
*/
|
|
127
129
|
function usePullDown(options) {
|
|
128
130
|
const latest = React.useRef(options);
|
|
@@ -140,51 +142,18 @@ function usePullDown(options) {
|
|
|
140
142
|
const settle = new sheet_swipe_1.SwipeSettle();
|
|
141
143
|
// The strip that shows while open, with the safe area under it, as the style sizes it.
|
|
142
144
|
const peekOf = () => { var _a; return ((_a = document.querySelector(latest.current.peek)) === null || _a === void 0 ? void 0 : _a.offsetHeight) || PullUtil.PEEK_PX; };
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
const p = PullUtil.progress(offset, moved.height, moved.peek);
|
|
148
|
-
moved.sheet.style.transform = `translate3d(0, ${offset}px, 0)`;
|
|
149
|
-
if (moved.reveal) {
|
|
150
|
-
moved.reveal.style.opacity = String(p);
|
|
151
|
-
moved.reveal.style.transform = `translate3d(0, ${(p - 1) * 36}px, 0) scale(${0.94 + 0.06 * p})`;
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
const release = (elements) => {
|
|
155
|
-
var _a, _b;
|
|
156
|
-
delete root.dataset.pull;
|
|
157
|
-
elements === null || elements === void 0 ? void 0 : elements.sheet.style.removeProperty('transform');
|
|
158
|
-
(_a = elements === null || elements === void 0 ? void 0 : elements.reveal) === null || _a === void 0 ? void 0 : _a.style.removeProperty('transform');
|
|
159
|
-
(_b = elements === null || elements === void 0 ? void 0 : elements.reveal) === null || _b === void 0 ? void 0 : _b.style.removeProperty('opacity');
|
|
145
|
+
const reveal = (offset, height, peek) => {
|
|
146
|
+
const p = PullUtil.progress(offset, height, peek);
|
|
147
|
+
return { opacity: p, transform: `translate3d(0, ${(p - 1) * 36}px, 0) scale(${0.94 + 0.06 * p})` };
|
|
160
148
|
};
|
|
161
|
-
const
|
|
162
|
-
document.removeEventListener('touchmove', onMove);
|
|
149
|
+
const reset = () => {
|
|
163
150
|
start = undefined;
|
|
164
|
-
};
|
|
165
|
-
const onStart = (event) => {
|
|
166
|
-
const current = latest.current;
|
|
167
151
|
claimed = undefined;
|
|
168
|
-
|
|
169
|
-
const target = event.target instanceof Node ? event.target : null;
|
|
170
|
-
const area = target
|
|
171
|
-
? [...document.querySelectorAll(current.open ? current.closeArea : current.area)].find(element => element.contains(target))
|
|
172
|
-
: undefined;
|
|
173
|
-
const inside = !!area;
|
|
174
|
-
const free = inside && !editable(event.target) && (current.open ? atEnd(event.target, area) : atTop(event.target, area));
|
|
175
|
-
if (event.touches.length === 1 && touch && free) {
|
|
176
|
-
start = { x: touch.clientX, y: touch.clientY, t: event.timeStamp };
|
|
177
|
-
velocity.start(start);
|
|
178
|
-
document.addEventListener('touchmove', onMove, { passive: false });
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
stop();
|
|
182
|
-
}
|
|
152
|
+
moved = undefined;
|
|
183
153
|
};
|
|
184
|
-
const onMove = (event) => {
|
|
154
|
+
const onMove = (event, touch) => {
|
|
185
155
|
const current = latest.current;
|
|
186
|
-
|
|
187
|
-
if (!start || !touch || claimed === false) {
|
|
156
|
+
if (!start || claimed === false) {
|
|
188
157
|
return;
|
|
189
158
|
}
|
|
190
159
|
const dy = touch.clientY - start.y;
|
|
@@ -197,17 +166,12 @@ function usePullDown(options) {
|
|
|
197
166
|
}
|
|
198
167
|
return;
|
|
199
168
|
}
|
|
200
|
-
|
|
201
|
-
stop();
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
const sheet = document.querySelector(current.sheet);
|
|
169
|
+
const sheet = claimed ? document.querySelector(current.sheet) : null;
|
|
205
170
|
if (!sheet) {
|
|
206
171
|
claimed = false;
|
|
207
|
-
stop();
|
|
172
|
+
finger.stop();
|
|
208
173
|
return;
|
|
209
174
|
}
|
|
210
|
-
settle.clear();
|
|
211
175
|
moved = {
|
|
212
176
|
sheet,
|
|
213
177
|
reveal: document.querySelector(current.reveal),
|
|
@@ -216,6 +180,7 @@ function usePullDown(options) {
|
|
|
216
180
|
passed: current.open,
|
|
217
181
|
offset: 0,
|
|
218
182
|
};
|
|
183
|
+
settle.hold([moved.sheet, moved.reveal]);
|
|
219
184
|
// Not data-sheet-drag: the sheets off the screen (the screen, the board) stay hidden.
|
|
220
185
|
root.dataset.pull = '';
|
|
221
186
|
}
|
|
@@ -230,39 +195,62 @@ function usePullDown(options) {
|
|
|
230
195
|
tick();
|
|
231
196
|
}
|
|
232
197
|
moved.passed = passed || current.open;
|
|
233
|
-
|
|
198
|
+
moved.sheet.style.transform = `translate3d(0, ${moved.offset}px, 0)`;
|
|
199
|
+
if (moved.reveal) {
|
|
200
|
+
const { opacity, transform } = reveal(moved.offset, moved.height, moved.peek);
|
|
201
|
+
moved.reveal.style.opacity = String(opacity);
|
|
202
|
+
moved.reveal.style.transform = transform;
|
|
203
|
+
}
|
|
234
204
|
};
|
|
235
|
-
const onEnd = (event) => {
|
|
236
|
-
var _a, _b;
|
|
237
|
-
const current = latest.current;
|
|
205
|
+
const onEnd = (event, touch) => {
|
|
238
206
|
if (start && claimed && moved) {
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
current.
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
207
|
+
const current = latest.current;
|
|
208
|
+
if (touch) {
|
|
209
|
+
velocity.add({ x: touch.clientX, y: touch.clientY, t: event.timeStamp });
|
|
210
|
+
}
|
|
211
|
+
const speed = touch ? velocity.speed : 0;
|
|
212
|
+
const { sheet, height, peek, offset } = moved;
|
|
213
|
+
const open = PullUtil.settle(offset, height, current.open, speed, peek);
|
|
214
|
+
const rest = open ? height - peek : 0;
|
|
215
|
+
const motion = sheet_swipe_1.SwipeUtil.motion(offset, rest, speed, PullUtil.SETTLE_MS, [0, height - peek]);
|
|
216
|
+
settle.run(motion, [
|
|
217
|
+
{ element: sheet, transform: `translate3d(0, ${rest}px, 0)` },
|
|
218
|
+
{ element: moved.reveal, ...reveal(rest, height, peek) },
|
|
219
|
+
], () => latest.current.open === open, () => delete root.dataset.pull);
|
|
220
|
+
(0, sheet_swipe_1.afterLetGo)(open, () => latest.current);
|
|
221
|
+
}
|
|
222
|
+
reset();
|
|
223
|
+
};
|
|
224
|
+
const finger = new sheet_swipe_1.SwipeFinger({ move: onMove, end: onEnd }, true);
|
|
225
|
+
const onStart = (event) => {
|
|
226
|
+
const current = latest.current;
|
|
227
|
+
// Another finger beside the one that pulls changes nothing.
|
|
228
|
+
if (finger.down && !finger.follow(event, document)) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
finger.stop();
|
|
232
|
+
reset();
|
|
233
|
+
const touch = event.touches[0];
|
|
234
|
+
const target = event.target instanceof Node ? event.target : null;
|
|
235
|
+
const area = target
|
|
236
|
+
? [...document.querySelectorAll(current.open ? current.closeArea : current.area)].find(element => element.contains(target))
|
|
237
|
+
: undefined;
|
|
238
|
+
const free = !!area && !editable(event.target) && (current.open ? atEnd(event.target, area) : atTop(event.target, area));
|
|
239
|
+
if (touch && free && finger.follow(event, document)) {
|
|
240
|
+
start = { x: touch.clientX, y: touch.clientY, t: event.timeStamp };
|
|
241
|
+
velocity.start(start);
|
|
251
242
|
}
|
|
252
|
-
moved = undefined;
|
|
253
|
-
claimed = undefined;
|
|
254
|
-
stop();
|
|
255
243
|
};
|
|
256
244
|
document.addEventListener('touchstart', onStart, { passive: true });
|
|
257
|
-
document.addEventListener('touchend', onEnd, { passive: true });
|
|
258
|
-
document.addEventListener('touchcancel', onEnd, { passive: true });
|
|
259
245
|
return () => {
|
|
260
246
|
document.removeEventListener('touchstart', onStart);
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
247
|
+
finger.stop();
|
|
248
|
+
// A list still under the finger goes back to where it rests; one sliding on finishes its slide.
|
|
249
|
+
if (moved) {
|
|
250
|
+
delete root.dataset.pull;
|
|
251
|
+
settle.finish();
|
|
252
|
+
}
|
|
253
|
+
reset();
|
|
266
254
|
};
|
|
267
255
|
}, [enabled]);
|
|
268
256
|
}
|
|
@@ -5,23 +5,48 @@ import * as React from 'react';
|
|
|
5
5
|
* anywhere else, or another row opened. Pure, for the tests.
|
|
6
6
|
*/
|
|
7
7
|
export declare namespace RowSwipeUtil {
|
|
8
|
-
/** Past the actions, the row follows the finger this much, as a list pulled past its end. */
|
|
9
|
-
const
|
|
8
|
+
/** Past the actions, the row follows the finger this much at first, then less and less, as a list of iOS pulled past its end. */
|
|
9
|
+
const RUBBER = 0.55;
|
|
10
10
|
/** How long its style slides the row (style/device.ts). */
|
|
11
11
|
const SETTLE_MS = 300;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
|
|
12
|
+
/** How far past its actions it ever goes, however far the finger: less than what the actions fill past their edge (style/device.ts). */
|
|
13
|
+
const BEYOND_PX = 100;
|
|
14
|
+
/** Told a swipe, the row catches up with the finger over this much of its way, not at once. */
|
|
15
|
+
const CATCH_PX = 40;
|
|
16
|
+
/** Let go, where it is headed is where it would be this much later at the finger's speed: a short quick swipe opens it too. */
|
|
17
|
+
const PROJECT_MS = 150;
|
|
18
|
+
/** Where the row is, from 0 (closed) to `-width` (its actions shown) and a little past, the finger at `x` (where it took the row, and how far it moved since). */
|
|
19
|
+
function offset(x: number, width: number): number;
|
|
20
|
+
/** Where the finger would be for the row at `offset`: the other way from `offset`, so that a row taken past its actions does not jump. */
|
|
21
|
+
function finger(offset: number, width: number): number;
|
|
22
|
+
/** Whether it stays open, let go at `offset` at `speed` (pixels a millisecond, SwipeVelocity): flicked, the way it was; else where it is headed. */
|
|
23
|
+
function settle(offset: number, width: number, speed: number): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* How far the finger has moved the row, `dx` since the move was told a swipe, `lag` before (the few pixels
|
|
26
|
+
* that told it): from where it was, without a jump, a little faster than the finger until it is where the
|
|
27
|
+
* finger says (CATCH_PX), as if it had followed it from the start.
|
|
28
|
+
*/
|
|
29
|
+
function follow(dx: number, lag: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* How far each action is pushed to the right of where it rests, the row at `offset`: they come out with the
|
|
32
|
+
* row's edge, as iOS's, the first one at it, the others spread over what is shown (`share`, 1 - its index
|
|
33
|
+
* of how many there are: 1 for the first, less for those after).
|
|
34
|
+
*/
|
|
35
|
+
function shift(offset: number, width: number, share: number): number;
|
|
16
36
|
/** Whether the move so far is the row's (more sideways than down, to the left unless open); undefined until it is told. */
|
|
17
37
|
function claims(dx: number, dy: number, open: boolean): boolean | undefined;
|
|
18
38
|
}
|
|
19
39
|
/**
|
|
20
40
|
* Lets a finger swipe the row of `ref` (a SwipeRow) while `enabled`: its content moves over its actions, whose
|
|
21
|
-
* width is the way to go, and
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
41
|
+
* width is the way to go, and they come out with its edge (RowSwipeUtil.shift); let go, all slide on as on a
|
|
42
|
+
* spring from the speed the finger left them (SwipeSettle). The row sets off from where the move is told a swipe
|
|
43
|
+
* and catches up with the finger (RowSwipeUtil.follow), so it never jumps under it; past its actions it stretches less and
|
|
44
|
+
* less. Open, it closes when the finger scrolls the list from it, or holds it for its menu. Its
|
|
45
|
+
* listeners are passive (the row has `touch-action: pan-y`), so the list scrolls on the compositor; each move
|
|
46
|
+
* only sets a transform. The finger is followed on what it touched (SwipeFinger), so that a row drawn again
|
|
47
|
+
* under it does not stop half way. The style says where an open row rests (`data-swiped`); the row clips
|
|
48
|
+
* what slides out of it only while it is moved, open or on its way back (`data-swipe-clip`), so that a menu
|
|
49
|
+
* of the row is not cut at its edges.
|
|
25
50
|
*/
|
|
26
51
|
export declare function useRowSwipe(ref: React.RefObject<HTMLElement | null>, enabled: boolean): [boolean, () => void];
|
|
27
52
|
//# sourceMappingURL=row-swipe.d.ts.map
|