@tamagui/toast 2.7.7 → 3.0.0-beta.1091.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/dist/cjs/ToastComposable.cjs +769 -882
- package/dist/cjs/ToastComposable.native.cjs +916 -0
- package/dist/cjs/ToastComposable.native.js +848 -968
- package/dist/cjs/ToastComposable.native.js.map +1 -1
- package/dist/cjs/ToastItemFrame.cjs +47 -119
- package/dist/cjs/ToastItemFrame.native.cjs +75 -0
- package/dist/cjs/ToastItemFrame.native.js +49 -120
- package/dist/cjs/ToastItemFrame.native.js.map +1 -1
- package/dist/cjs/ToastState.cjs +280 -290
- package/dist/cjs/ToastState.native.cjs +300 -0
- package/dist/cjs/ToastState.native.js +272 -294
- package/dist/cjs/ToastState.native.js.map +1 -1
- package/dist/cjs/createNativeToast.cjs +37 -44
- package/dist/cjs/createNativeToast.native.cjs +53 -0
- package/dist/cjs/createNativeToast.native.js +35 -40
- package/dist/cjs/createNativeToast.native.js.map +1 -1
- package/dist/cjs/dispatchNativeToast.cjs +31 -35
- package/dist/cjs/dispatchNativeToast.native.cjs +47 -0
- package/dist/cjs/dispatchNativeToast.native.js +33 -36
- package/dist/cjs/dispatchNativeToast.native.js.map +1 -1
- package/dist/cjs/index.cjs +24 -12
- package/dist/cjs/index.native.cjs +34 -0
- package/dist/cjs/index.native.js +25 -12
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +9 -11
- package/dist/cjs/types.native.cjs +18 -0
- package/dist/cjs/types.native.js +9 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/useAnimatedDragGesture.cjs +196 -194
- package/dist/cjs/useAnimatedDragGesture.native.cjs +209 -0
- package/dist/cjs/useAnimatedDragGesture.native.js +178 -191
- package/dist/cjs/useAnimatedDragGesture.native.js.map +1 -1
- package/dist/cjs/useReducedMotion.cjs +46 -55
- package/dist/cjs/useReducedMotion.native.cjs +73 -0
- package/dist/cjs/useReducedMotion.native.js +52 -60
- package/dist/cjs/useReducedMotion.native.js.map +1 -1
- package/dist/cjs/useToastAnimations.cjs +197 -270
- package/dist/cjs/useToastAnimations.native.cjs +228 -0
- package/dist/cjs/useToastAnimations.native.js +204 -276
- package/dist/cjs/useToastAnimations.native.js.map +1 -1
- package/dist/esm/ToastComposable.mjs +749 -854
- package/dist/esm/ToastComposable.mjs.map +1 -1
- package/dist/esm/ToastComposable.native.js +828 -941
- package/dist/esm/ToastComposable.native.js.map +1 -1
- package/dist/esm/ToastItemFrame.mjs +31 -99
- package/dist/esm/ToastItemFrame.mjs.map +1 -1
- package/dist/esm/ToastItemFrame.native.js +34 -102
- package/dist/esm/ToastItemFrame.native.js.map +1 -1
- package/dist/esm/ToastState.mjs +266 -273
- package/dist/esm/ToastState.mjs.map +1 -1
- package/dist/esm/ToastState.native.js +258 -278
- package/dist/esm/ToastState.native.js.map +1 -1
- package/dist/esm/createNativeToast.mjs +22 -26
- package/dist/esm/createNativeToast.mjs.map +1 -1
- package/dist/esm/createNativeToast.native.js +21 -23
- package/dist/esm/createNativeToast.native.js.map +1 -1
- package/dist/esm/dispatchNativeToast.mjs +19 -17
- package/dist/esm/dispatchNativeToast.mjs.map +1 -1
- package/dist/esm/dispatchNativeToast.native.js +21 -19
- package/dist/esm/dispatchNativeToast.native.js.map +1 -1
- package/dist/esm/index.js +5 -2
- package/dist/esm/index.mjs +5 -2
- package/dist/esm/index.native.js +5 -2
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.native.js +0 -2
- package/dist/esm/useAnimatedDragGesture.mjs +181 -168
- package/dist/esm/useAnimatedDragGesture.mjs.map +1 -1
- package/dist/esm/useAnimatedDragGesture.native.js +163 -166
- package/dist/esm/useAnimatedDragGesture.native.js.map +1 -1
- package/dist/esm/useReducedMotion.mjs +31 -29
- package/dist/esm/useReducedMotion.mjs.map +1 -1
- package/dist/esm/useReducedMotion.native.js +37 -35
- package/dist/esm/useReducedMotion.native.js.map +1 -1
- package/dist/esm/useToastAnimations.mjs +183 -245
- package/dist/esm/useToastAnimations.mjs.map +1 -1
- package/dist/esm/useToastAnimations.native.js +190 -252
- package/dist/esm/useToastAnimations.native.js.map +1 -1
- package/dist/jsx/ToastComposable.mjs +749 -854
- package/dist/jsx/ToastComposable.mjs.map +1 -1
- package/dist/jsx/ToastComposable.native.cjs +916 -0
- package/dist/jsx/ToastComposable.native.js +848 -968
- package/dist/jsx/ToastComposable.native.js.map +1 -1
- package/dist/jsx/ToastItemFrame.mjs +31 -99
- package/dist/jsx/ToastItemFrame.mjs.map +1 -1
- package/dist/jsx/ToastItemFrame.native.cjs +75 -0
- package/dist/jsx/ToastItemFrame.native.js +49 -120
- package/dist/jsx/ToastItemFrame.native.js.map +1 -1
- package/dist/jsx/ToastState.mjs +266 -273
- package/dist/jsx/ToastState.mjs.map +1 -1
- package/dist/jsx/ToastState.native.cjs +300 -0
- package/dist/jsx/ToastState.native.js +272 -294
- package/dist/jsx/ToastState.native.js.map +1 -1
- package/dist/jsx/createNativeToast.mjs +22 -26
- package/dist/jsx/createNativeToast.mjs.map +1 -1
- package/dist/jsx/createNativeToast.native.cjs +53 -0
- package/dist/jsx/createNativeToast.native.js +35 -40
- package/dist/jsx/createNativeToast.native.js.map +1 -1
- package/dist/jsx/dispatchNativeToast.mjs +19 -17
- package/dist/jsx/dispatchNativeToast.mjs.map +1 -1
- package/dist/jsx/dispatchNativeToast.native.cjs +47 -0
- package/dist/jsx/dispatchNativeToast.native.js +33 -36
- package/dist/jsx/dispatchNativeToast.native.js.map +1 -1
- package/dist/jsx/index.js +5 -2
- package/dist/jsx/index.mjs +5 -2
- package/dist/jsx/index.native.cjs +34 -0
- package/dist/jsx/index.native.js +25 -12
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.native.cjs +18 -0
- package/dist/jsx/types.native.js +9 -10
- package/dist/jsx/types.native.js.map +1 -1
- package/dist/jsx/useAnimatedDragGesture.mjs +181 -168
- package/dist/jsx/useAnimatedDragGesture.mjs.map +1 -1
- package/dist/jsx/useAnimatedDragGesture.native.cjs +209 -0
- package/dist/jsx/useAnimatedDragGesture.native.js +178 -191
- package/dist/jsx/useAnimatedDragGesture.native.js.map +1 -1
- package/dist/jsx/useReducedMotion.mjs +31 -29
- package/dist/jsx/useReducedMotion.mjs.map +1 -1
- package/dist/jsx/useReducedMotion.native.cjs +73 -0
- package/dist/jsx/useReducedMotion.native.js +52 -60
- package/dist/jsx/useReducedMotion.native.js.map +1 -1
- package/dist/jsx/useToastAnimations.mjs +183 -245
- package/dist/jsx/useToastAnimations.mjs.map +1 -1
- package/dist/jsx/useToastAnimations.native.cjs +228 -0
- package/dist/jsx/useToastAnimations.native.js +204 -276
- package/dist/jsx/useToastAnimations.native.js.map +1 -1
- package/package.json +22 -38
- package/src/ToastComposable.tsx +62 -99
- package/src/ToastItemFrame.tsx +22 -81
- package/src/ToastState.ts +1 -0
- package/src/index.ts +34 -2
- package/src/types.ts +11 -0
- package/src/useAnimatedDragGesture.native.ts +1 -1
- package/src/useAnimatedDragGesture.ts +1 -1
- package/src/useToastAnimations.ts +23 -40
- package/types/ToastComposable.d.ts +124 -47
- package/types/ToastComposable.d.ts.map +1 -1
- package/types/ToastItemFrame.d.ts +52 -21
- package/types/ToastItemFrame.d.ts.map +1 -1
- package/types/ToastState.d.ts +15 -11
- package/types/ToastState.d.ts.map +1 -1
- package/types/index.d.ts +6 -2
- package/types/index.d.ts.map +1 -1
- package/types/types.d.ts +1 -0
- package/types/types.d.ts.map +1 -1
- package/types/useAnimatedDragGesture.d.ts +1 -1
- package/types/useAnimatedDragGesture.d.ts.map +1 -1
- package/types/useAnimatedDragGesture.native.d.ts +1 -1
- package/types/useAnimatedDragGesture.native.d.ts.map +1 -1
- package/types/useToastAnimations.d.ts +4 -11
- package/types/useToastAnimations.d.ts.map +1 -1
- package/dist/cjs/Toast.cjs +0 -178
- package/dist/cjs/Toast.native.js +0 -181
- package/dist/cjs/Toast.native.js.map +0 -1
- package/dist/cjs/ToastAnnounce.cjs +0 -103
- package/dist/cjs/ToastAnnounce.native.js +0 -111
- package/dist/cjs/ToastAnnounce.native.js.map +0 -1
- package/dist/cjs/ToastImperative.cjs +0 -119
- package/dist/cjs/ToastImperative.native.js +0 -130
- package/dist/cjs/ToastImperative.native.js.map +0 -1
- package/dist/cjs/ToastImpl.cjs +0 -354
- package/dist/cjs/ToastImpl.native.js +0 -364
- package/dist/cjs/ToastImpl.native.js.map +0 -1
- package/dist/cjs/ToastPortal.cjs +0 -49
- package/dist/cjs/ToastPortal.native.js +0 -52
- package/dist/cjs/ToastPortal.native.js.map +0 -1
- package/dist/cjs/ToastProvider.cjs +0 -150
- package/dist/cjs/ToastProvider.native.js +0 -161
- package/dist/cjs/ToastProvider.native.js.map +0 -1
- package/dist/cjs/ToastViewport.cjs +0 -319
- package/dist/cjs/ToastViewport.native.js +0 -343
- package/dist/cjs/ToastViewport.native.js.map +0 -1
- package/dist/cjs/Toaster.cjs +0 -87
- package/dist/cjs/Toaster.native.js +0 -91
- package/dist/cjs/Toaster.native.js.map +0 -1
- package/dist/cjs/constants.cjs +0 -30
- package/dist/cjs/constants.native.js +0 -33
- package/dist/cjs/constants.native.js.map +0 -1
- package/dist/cjs/v2.cjs +0 -36
- package/dist/cjs/v2.native.js +0 -39
- package/dist/cjs/v2.native.js.map +0 -1
- package/dist/esm/Toast.mjs +0 -137
- package/dist/esm/Toast.mjs.map +0 -1
- package/dist/esm/Toast.native.js +0 -137
- package/dist/esm/Toast.native.js.map +0 -1
- package/dist/esm/ToastAnnounce.mjs +0 -66
- package/dist/esm/ToastAnnounce.mjs.map +0 -1
- package/dist/esm/ToastAnnounce.native.js +0 -71
- package/dist/esm/ToastAnnounce.native.js.map +0 -1
- package/dist/esm/ToastImperative.mjs +0 -80
- package/dist/esm/ToastImperative.mjs.map +0 -1
- package/dist/esm/ToastImperative.native.js +0 -88
- package/dist/esm/ToastImperative.native.js.map +0 -1
- package/dist/esm/ToastImpl.mjs +0 -316
- package/dist/esm/ToastImpl.mjs.map +0 -1
- package/dist/esm/ToastImpl.native.js +0 -329
- package/dist/esm/ToastImpl.native.js.map +0 -1
- package/dist/esm/ToastPortal.mjs +0 -24
- package/dist/esm/ToastPortal.mjs.map +0 -1
- package/dist/esm/ToastPortal.native.js +0 -24
- package/dist/esm/ToastPortal.native.js.map +0 -1
- package/dist/esm/ToastProvider.mjs +0 -110
- package/dist/esm/ToastProvider.mjs.map +0 -1
- package/dist/esm/ToastProvider.native.js +0 -118
- package/dist/esm/ToastProvider.native.js.map +0 -1
- package/dist/esm/ToastViewport.mjs +0 -280
- package/dist/esm/ToastViewport.mjs.map +0 -1
- package/dist/esm/ToastViewport.native.js +0 -301
- package/dist/esm/ToastViewport.native.js.map +0 -1
- package/dist/esm/Toaster.mjs +0 -51
- package/dist/esm/Toaster.mjs.map +0 -1
- package/dist/esm/Toaster.native.js +0 -52
- package/dist/esm/Toaster.native.js.map +0 -1
- package/dist/esm/constants.mjs +0 -4
- package/dist/esm/constants.mjs.map +0 -1
- package/dist/esm/constants.native.js +0 -4
- package/dist/esm/constants.native.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js.map +0 -1
- package/dist/esm/v2.mjs +0 -6
- package/dist/esm/v2.mjs.map +0 -1
- package/dist/esm/v2.native.js +0 -6
- package/dist/esm/v2.native.js.map +0 -1
- package/dist/jsx/Toast.mjs +0 -137
- package/dist/jsx/Toast.mjs.map +0 -1
- package/dist/jsx/Toast.native.js +0 -181
- package/dist/jsx/Toast.native.js.map +0 -1
- package/dist/jsx/ToastAnnounce.mjs +0 -66
- package/dist/jsx/ToastAnnounce.mjs.map +0 -1
- package/dist/jsx/ToastAnnounce.native.js +0 -111
- package/dist/jsx/ToastAnnounce.native.js.map +0 -1
- package/dist/jsx/ToastImperative.mjs +0 -80
- package/dist/jsx/ToastImperative.mjs.map +0 -1
- package/dist/jsx/ToastImperative.native.js +0 -130
- package/dist/jsx/ToastImperative.native.js.map +0 -1
- package/dist/jsx/ToastImpl.mjs +0 -316
- package/dist/jsx/ToastImpl.mjs.map +0 -1
- package/dist/jsx/ToastImpl.native.js +0 -364
- package/dist/jsx/ToastImpl.native.js.map +0 -1
- package/dist/jsx/ToastPortal.mjs +0 -24
- package/dist/jsx/ToastPortal.mjs.map +0 -1
- package/dist/jsx/ToastPortal.native.js +0 -52
- package/dist/jsx/ToastPortal.native.js.map +0 -1
- package/dist/jsx/ToastProvider.mjs +0 -110
- package/dist/jsx/ToastProvider.mjs.map +0 -1
- package/dist/jsx/ToastProvider.native.js +0 -161
- package/dist/jsx/ToastProvider.native.js.map +0 -1
- package/dist/jsx/ToastViewport.mjs +0 -280
- package/dist/jsx/ToastViewport.mjs.map +0 -1
- package/dist/jsx/ToastViewport.native.js +0 -343
- package/dist/jsx/ToastViewport.native.js.map +0 -1
- package/dist/jsx/Toaster.mjs +0 -51
- package/dist/jsx/Toaster.mjs.map +0 -1
- package/dist/jsx/Toaster.native.js +0 -91
- package/dist/jsx/Toaster.native.js.map +0 -1
- package/dist/jsx/constants.mjs +0 -4
- package/dist/jsx/constants.mjs.map +0 -1
- package/dist/jsx/constants.native.js +0 -33
- package/dist/jsx/constants.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/types.mjs.map +0 -1
- package/dist/jsx/v2.mjs +0 -6
- package/dist/jsx/v2.mjs.map +0 -1
- package/dist/jsx/v2.native.js +0 -39
- package/dist/jsx/v2.native.js.map +0 -1
- package/src/Toast.tsx +0 -219
- package/src/ToastAnnounce.tsx +0 -103
- package/src/ToastImperative.tsx +0 -192
- package/src/ToastImpl.tsx +0 -514
- package/src/ToastPortal.tsx +0 -19
- package/src/ToastProvider.tsx +0 -204
- package/src/ToastViewport.tsx +0 -430
- package/src/Toaster.tsx +0 -181
- package/src/constants.ts +0 -2
- package/src/v2.ts +0 -31
- package/types/Toast.d.ts +0 -84
- package/types/Toast.d.ts.map +0 -1
- package/types/ToastAnnounce.d.ts +0 -18
- package/types/ToastAnnounce.d.ts.map +0 -1
- package/types/ToastImperative.d.ts +0 -95
- package/types/ToastImperative.d.ts.map +0 -1
- package/types/ToastImpl.d.ts +0 -109
- package/types/ToastImpl.d.ts.map +0 -1
- package/types/ToastPortal.d.ts +0 -8
- package/types/ToastPortal.d.ts.map +0 -1
- package/types/ToastProvider.d.ts +0 -92
- package/types/ToastProvider.d.ts.map +0 -1
- package/types/ToastViewport.d.ts +0 -75
- package/types/ToastViewport.d.ts.map +0 -1
- package/types/Toaster.d.ts +0 -112
- package/types/Toaster.d.ts.map +0 -1
- package/types/constants.d.ts +0 -3
- package/types/constants.d.ts.map +0 -1
- package/types/v2.d.ts +0 -10
- package/types/v2.d.ts.map +0 -1
- package/v2/index.cjs +0 -2
- package/v2/index.js +0 -2
- package/v2/index.native.cjs +0 -2
- package/v2/index.native.js +0 -2
|
@@ -7,77 +7,69 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
14
|
};
|
|
15
15
|
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
23
|
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
-
value: mod,
|
|
31
|
-
enumerable: true
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
32
27
|
}) : target, mod));
|
|
33
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
-
value: true
|
|
35
|
-
}), mod);
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
29
|
var useReducedMotion_exports = {};
|
|
37
|
-
__export(useReducedMotion_exports, {
|
|
38
|
-
useReducedMotion: () => useReducedMotion
|
|
39
|
-
});
|
|
30
|
+
__export(useReducedMotion_exports, { useReducedMotion: () => useReducedMotion });
|
|
40
31
|
module.exports = __toCommonJS(useReducedMotion_exports);
|
|
41
32
|
var import_constants = require("@tamagui/constants");
|
|
42
33
|
var React = __toESM(require("react"), 1);
|
|
43
34
|
var cachedResult = null;
|
|
44
35
|
function getReducedMotion() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
36
|
+
var _window_matchMedia, _window_matchMedia1, _window;
|
|
37
|
+
if (cachedResult !== null) return cachedResult;
|
|
38
|
+
if (!import_constants.isWeb) {
|
|
39
|
+
cachedResult = false;
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (typeof window === "undefined") {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
var _window_matchMedia_matches;
|
|
46
|
+
cachedResult = (_window_matchMedia_matches = (_window_matchMedia1 = (_window = window).matchMedia) === null || _window_matchMedia1 === void 0 ? void 0 : (_window_matchMedia = _window_matchMedia1.call(_window, "(prefers-reduced-motion: reduce)")) === null || _window_matchMedia === void 0 ? void 0 : _window_matchMedia.matches) !== null && _window_matchMedia_matches !== void 0 ? _window_matchMedia_matches : false;
|
|
47
|
+
return cachedResult;
|
|
57
48
|
}
|
|
58
49
|
function useReducedMotion(forceReducedMotion) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
50
|
+
var [reducedMotion, setReducedMotion] = React.useState(function() {
|
|
51
|
+
return forceReducedMotion !== null && forceReducedMotion !== void 0 ? forceReducedMotion : getReducedMotion();
|
|
52
|
+
});
|
|
53
|
+
React.useEffect(function() {
|
|
54
|
+
var _window_matchMedia, _window, _mediaQuery_addEventListener;
|
|
55
|
+
if (forceReducedMotion !== void 0) {
|
|
56
|
+
setReducedMotion(forceReducedMotion);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!import_constants.isWeb || typeof window === "undefined") return;
|
|
60
|
+
var mediaQuery = (_window_matchMedia = (_window = window).matchMedia) === null || _window_matchMedia === void 0 ? void 0 : _window_matchMedia.call(_window, "(prefers-reduced-motion: reduce)");
|
|
61
|
+
if (!mediaQuery) return;
|
|
62
|
+
var handleChange = function(e) {
|
|
63
|
+
cachedResult = e.matches;
|
|
64
|
+
setReducedMotion(e.matches);
|
|
65
|
+
};
|
|
66
|
+
(_mediaQuery_addEventListener = mediaQuery.addEventListener) === null || _mediaQuery_addEventListener === void 0 ? void 0 : _mediaQuery_addEventListener.call(mediaQuery, "change", handleChange);
|
|
67
|
+
return function() {
|
|
68
|
+
var _mediaQuery_removeEventListener;
|
|
69
|
+
(_mediaQuery_removeEventListener = mediaQuery.removeEventListener) === null || _mediaQuery_removeEventListener === void 0 ? void 0 : _mediaQuery_removeEventListener.call(mediaQuery, "change", handleChange);
|
|
70
|
+
};
|
|
71
|
+
}, [forceReducedMotion]);
|
|
72
|
+
return reducedMotion;
|
|
82
73
|
}
|
|
74
|
+
|
|
83
75
|
//# sourceMappingURL=useReducedMotion.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useReducedMotion.native.js","names":[],"sources":["jsx/useReducedMotion.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar useReducedMotion_exports = {};\n__export(useReducedMotion_exports, {\n useReducedMotion: () => useReducedMotion\n});\nmodule.exports = __toCommonJS(useReducedMotion_exports);\nvar import_constants = require(\"@tamagui/constants\");\nvar React = __toESM(require(\"react\"), 1);\nvar cachedResult = null;\nfunction getReducedMotion() {\n var _window_matchMedia, _window_matchMedia1, _window;\n if (cachedResult !== null) return cachedResult;\n if (!import_constants.isWeb) {\n cachedResult = false;\n return false;\n }\n if (typeof window === \"undefined\") {\n return false;\n }\n var _window_matchMedia_matches;\n cachedResult = (_window_matchMedia_matches = (_window_matchMedia1 = (_window = window).matchMedia) === null || _window_matchMedia1 === void 0 ? void 0 : (_window_matchMedia = _window_matchMedia1.call(_window, \"(prefers-reduced-motion: reduce)\")) === null || _window_matchMedia === void 0 ? void 0 : _window_matchMedia.matches) !== null && _window_matchMedia_matches !== void 0 ? _window_matchMedia_matches : false;\n return cachedResult;\n}\nfunction useReducedMotion(forceReducedMotion) {\n var [reducedMotion, setReducedMotion] = React.useState(function() {\n return forceReducedMotion !== null && forceReducedMotion !== void 0 ? forceReducedMotion : getReducedMotion();\n });\n React.useEffect(function() {\n var _window_matchMedia, _window, _mediaQuery_addEventListener;\n if (forceReducedMotion !== void 0) {\n setReducedMotion(forceReducedMotion);\n return;\n }\n if (!import_constants.isWeb || typeof window === \"undefined\") return;\n var mediaQuery = (_window_matchMedia = (_window = window).matchMedia) === null || _window_matchMedia === void 0 ? void 0 : _window_matchMedia.call(_window, \"(prefers-reduced-motion: reduce)\");\n if (!mediaQuery) return;\n var handleChange = function(e) {\n cachedResult = e.matches;\n setReducedMotion(e.matches);\n };\n (_mediaQuery_addEventListener = mediaQuery.addEventListener) === null || _mediaQuery_addEventListener === void 0 ? void 0 : _mediaQuery_addEventListener.call(mediaQuery, \"change\", handleChange);\n return function() {\n var _mediaQuery_removeEventListener;\n (_mediaQuery_removeEventListener = mediaQuery.removeEventListener) === null || _mediaQuery_removeEventListener === void 0 ? void 0 : _mediaQuery_removeEventListener.call(mediaQuery, \"change\", handleChange);\n };\n }, [\n forceReducedMotion\n ]);\n return reducedMotion;\n}\n//# sourceMappingURL=useReducedMotion.js.map\n"],"mappings":"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"}
|
|
@@ -1,256 +1,194 @@
|
|
|
1
1
|
import { isWeb } from "@tamagui/constants";
|
|
2
|
-
import {
|
|
2
|
+
import { View, useAnimatedNumber, useAnimatedNumbersStyle, useAnimationDriver, useEvent } from "@tamagui/core";
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
|
|
4
5
|
const SPRING_CONFIG = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
type: "spring",
|
|
7
|
+
damping: 30,
|
|
8
|
+
stiffness: 400,
|
|
9
|
+
mass: .5
|
|
9
10
|
};
|
|
10
11
|
const EXIT_DISTANCE = 200;
|
|
11
12
|
function animateSpring(element, fromX, fromY, toX, toY, config, onComplete) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
animationId = requestAnimationFrame(step);
|
|
59
|
-
return () => {
|
|
60
|
-
if (animationId) {
|
|
61
|
-
cancelAnimationFrame(animationId);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
13
|
+
const { damping = 30, stiffness = 400, mass = .5, initialVelocityX = 0, initialVelocityY = 0, fadeOut = false } = config;
|
|
14
|
+
let x = fromX;
|
|
15
|
+
let y = fromY;
|
|
16
|
+
let velocityX = initialVelocityX;
|
|
17
|
+
let velocityY = initialVelocityY;
|
|
18
|
+
let animationId = null;
|
|
19
|
+
const targetX = toX;
|
|
20
|
+
const targetY = toY;
|
|
21
|
+
const totalDistance = Math.sqrt((toX - fromX) ** 2 + (toY - fromY) ** 2) || 1;
|
|
22
|
+
function step() {
|
|
23
|
+
const forceX = -stiffness * (x - targetX);
|
|
24
|
+
const forceY = -stiffness * (y - targetY);
|
|
25
|
+
const dampingForceX = -damping * velocityX;
|
|
26
|
+
const dampingForceY = -damping * velocityY;
|
|
27
|
+
const accelerationX = (forceX + dampingForceX) / mass;
|
|
28
|
+
const accelerationY = (forceY + dampingForceY) / mass;
|
|
29
|
+
velocityX += accelerationX * .016;
|
|
30
|
+
velocityY += accelerationY * .016;
|
|
31
|
+
x += velocityX * .016;
|
|
32
|
+
y += velocityY * .016;
|
|
33
|
+
element.style.transform = `translate3d(${x}px, ${y}px, 0)`;
|
|
34
|
+
if (fadeOut) {
|
|
35
|
+
const distanceTraveled = Math.sqrt((x - fromX) ** 2 + (y - fromY) ** 2);
|
|
36
|
+
const progress = Math.min(distanceTraveled / totalDistance, 1);
|
|
37
|
+
element.style.opacity = String(1 - progress);
|
|
38
|
+
}
|
|
39
|
+
const distanceX = Math.abs(x - targetX);
|
|
40
|
+
const distanceY = Math.abs(y - targetY);
|
|
41
|
+
const speed = Math.sqrt(velocityX * velocityX + velocityY * velocityY);
|
|
42
|
+
if (distanceX < .5 && distanceY < .5 && speed < .5) {
|
|
43
|
+
element.style.transform = `translate3d(${targetX}px, ${targetY}px, 0)`;
|
|
44
|
+
if (fadeOut) {
|
|
45
|
+
element.style.opacity = "0";
|
|
46
|
+
}
|
|
47
|
+
onComplete?.();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
animationId = requestAnimationFrame(step);
|
|
51
|
+
}
|
|
52
|
+
animationId = requestAnimationFrame(step);
|
|
53
|
+
return () => {
|
|
54
|
+
if (animationId) {
|
|
55
|
+
cancelAnimationFrame(animationId);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
64
58
|
}
|
|
65
59
|
function useToastAnimations(options = {}) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
onComplete?.();
|
|
198
|
-
onExitComplete?.();
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
const velocityScale = (velocity ?? 0) * 500;
|
|
202
|
-
const initialVelocityX = direction === "left" ? -velocityScale : direction === "right" ? velocityScale : 0;
|
|
203
|
-
const initialVelocityY = direction === "up" ? -velocityScale : direction === "down" ? velocityScale : 0;
|
|
204
|
-
const exitConfig = {
|
|
205
|
-
damping: 25,
|
|
206
|
-
stiffness: 350,
|
|
207
|
-
mass: 0.4,
|
|
208
|
-
initialVelocityX,
|
|
209
|
-
initialVelocityY,
|
|
210
|
-
fadeOut: true
|
|
211
|
-
};
|
|
212
|
-
if (useDirectDom && dragRef.current) {
|
|
213
|
-
const {
|
|
214
|
-
x,
|
|
215
|
-
y
|
|
216
|
-
} = currentOffsetRef.current;
|
|
217
|
-
cancelAnimationRef.current = animateSpring(dragRef.current, x, y, exitX, exitY, exitConfig, () => {
|
|
218
|
-
onComplete?.();
|
|
219
|
-
onExitComplete?.();
|
|
220
|
-
});
|
|
221
|
-
} else {
|
|
222
|
-
const springConfig = {
|
|
223
|
-
type: "spring",
|
|
224
|
-
damping: 25,
|
|
225
|
-
stiffness: 350,
|
|
226
|
-
mass: 0.4
|
|
227
|
-
};
|
|
228
|
-
translateX.setValue(exitX, springConfig);
|
|
229
|
-
translateY.setValue(exitY, springConfig, () => {
|
|
230
|
-
onComplete?.();
|
|
231
|
-
onExitComplete?.();
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
const stop = useEvent(() => {
|
|
236
|
-
cancelAnimationRef.current?.();
|
|
237
|
-
translateX.stop();
|
|
238
|
-
translateY.stop();
|
|
239
|
-
});
|
|
240
|
-
React.useEffect(() => {
|
|
241
|
-
return () => {
|
|
242
|
-
cancelAnimationRef.current?.();
|
|
243
|
-
};
|
|
244
|
-
}, []);
|
|
245
|
-
return {
|
|
246
|
-
setDragOffset,
|
|
247
|
-
springBack,
|
|
248
|
-
animateOut,
|
|
249
|
-
stop,
|
|
250
|
-
animatedStyle,
|
|
251
|
-
AnimatedView,
|
|
252
|
-
dragRef
|
|
253
|
-
};
|
|
60
|
+
const { onExitComplete, reducedMotion } = options;
|
|
61
|
+
const animationDriver = useAnimationDriver();
|
|
62
|
+
const AnimatedView = animationDriver.View ?? View;
|
|
63
|
+
const dragRef = React.useRef(null);
|
|
64
|
+
const cancelAnimationRef = React.useRef(null);
|
|
65
|
+
const currentOffsetRef = React.useRef({
|
|
66
|
+
x: 0,
|
|
67
|
+
y: 0
|
|
68
|
+
});
|
|
69
|
+
const useDirectDom = isWeb;
|
|
70
|
+
const translateX = useAnimatedNumber(0);
|
|
71
|
+
const translateY = useAnimatedNumber(0);
|
|
72
|
+
const animatedStyle = useAnimatedNumbersStyle([translateX, translateY], (x, y) => {
|
|
73
|
+
"worklet";
|
|
74
|
+
return { transform: [{ translateX: x }, { translateY: y }] };
|
|
75
|
+
});
|
|
76
|
+
const setDragOffset = useEvent((x, y) => {
|
|
77
|
+
cancelAnimationRef.current?.();
|
|
78
|
+
cancelAnimationRef.current = null;
|
|
79
|
+
currentOffsetRef.current = {
|
|
80
|
+
x,
|
|
81
|
+
y
|
|
82
|
+
};
|
|
83
|
+
if (useDirectDom && dragRef.current) {
|
|
84
|
+
dragRef.current.style.transform = `translate3d(${x}px, ${y}px, 0)`;
|
|
85
|
+
dragRef.current.style.opacity = "1";
|
|
86
|
+
} else {
|
|
87
|
+
translateX.setValue(x, { type: "direct" });
|
|
88
|
+
translateY.setValue(y, { type: "direct" });
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const springBack = useEvent((onComplete) => {
|
|
92
|
+
cancelAnimationRef.current?.();
|
|
93
|
+
if (reducedMotion) {
|
|
94
|
+
if (useDirectDom && dragRef.current) {
|
|
95
|
+
dragRef.current.style.transform = "translate3d(0px, 0px, 0)";
|
|
96
|
+
} else {
|
|
97
|
+
translateX.setValue(0, { type: "direct" });
|
|
98
|
+
translateY.setValue(0, { type: "direct" });
|
|
99
|
+
}
|
|
100
|
+
currentOffsetRef.current = {
|
|
101
|
+
x: 0,
|
|
102
|
+
y: 0
|
|
103
|
+
};
|
|
104
|
+
onComplete?.();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (useDirectDom && dragRef.current) {
|
|
108
|
+
const { x, y } = currentOffsetRef.current;
|
|
109
|
+
cancelAnimationRef.current = animateSpring(dragRef.current, x, y, 0, 0, SPRING_CONFIG, () => {
|
|
110
|
+
currentOffsetRef.current = {
|
|
111
|
+
x: 0,
|
|
112
|
+
y: 0
|
|
113
|
+
};
|
|
114
|
+
onComplete?.();
|
|
115
|
+
});
|
|
116
|
+
} else {
|
|
117
|
+
translateX.setValue(0, SPRING_CONFIG);
|
|
118
|
+
translateY.setValue(0, SPRING_CONFIG, onComplete);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const animateOut = useEvent((direction, velocity, onComplete) => {
|
|
122
|
+
cancelAnimationRef.current?.();
|
|
123
|
+
const { x: curX, y: curY } = currentOffsetRef.current;
|
|
124
|
+
let exitX = direction === "left" ? -EXIT_DISTANCE : direction === "right" ? EXIT_DISTANCE : 0;
|
|
125
|
+
let exitY = direction === "up" ? -EXIT_DISTANCE : direction === "down" ? EXIT_DISTANCE : 0;
|
|
126
|
+
if (direction === "left" && curX < exitX) exitX = curX - 50;
|
|
127
|
+
else if (direction === "right" && curX > exitX) exitX = curX + 50;
|
|
128
|
+
if (direction === "up" && curY < exitY) exitY = curY - 50;
|
|
129
|
+
else if (direction === "down" && curY > exitY) exitY = curY + 50;
|
|
130
|
+
if (reducedMotion) {
|
|
131
|
+
if (useDirectDom && dragRef.current) {
|
|
132
|
+
dragRef.current.style.transform = `translate3d(${exitX}px, ${exitY}px, 0)`;
|
|
133
|
+
} else {
|
|
134
|
+
translateX.setValue(exitX, { type: "direct" });
|
|
135
|
+
translateY.setValue(exitY, { type: "direct" });
|
|
136
|
+
}
|
|
137
|
+
onComplete?.();
|
|
138
|
+
onExitComplete?.();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const velocityScale = (velocity ?? 0) * 500;
|
|
142
|
+
const initialVelocityX = direction === "left" ? -velocityScale : direction === "right" ? velocityScale : 0;
|
|
143
|
+
const initialVelocityY = direction === "up" ? -velocityScale : direction === "down" ? velocityScale : 0;
|
|
144
|
+
const exitConfig = {
|
|
145
|
+
damping: 25,
|
|
146
|
+
stiffness: 350,
|
|
147
|
+
mass: .4,
|
|
148
|
+
initialVelocityX,
|
|
149
|
+
initialVelocityY,
|
|
150
|
+
fadeOut: true
|
|
151
|
+
};
|
|
152
|
+
if (useDirectDom && dragRef.current) {
|
|
153
|
+
const { x, y } = currentOffsetRef.current;
|
|
154
|
+
cancelAnimationRef.current = animateSpring(dragRef.current, x, y, exitX, exitY, exitConfig, () => {
|
|
155
|
+
onComplete?.();
|
|
156
|
+
onExitComplete?.();
|
|
157
|
+
});
|
|
158
|
+
} else {
|
|
159
|
+
const springConfig = {
|
|
160
|
+
type: "spring",
|
|
161
|
+
damping: 25,
|
|
162
|
+
stiffness: 350,
|
|
163
|
+
mass: .4
|
|
164
|
+
};
|
|
165
|
+
translateX.setValue(exitX, springConfig);
|
|
166
|
+
translateY.setValue(exitY, springConfig, () => {
|
|
167
|
+
onComplete?.();
|
|
168
|
+
onExitComplete?.();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const stop = useEvent(() => {
|
|
173
|
+
cancelAnimationRef.current?.();
|
|
174
|
+
translateX.stop();
|
|
175
|
+
translateY.stop();
|
|
176
|
+
});
|
|
177
|
+
React.useEffect(() => {
|
|
178
|
+
return () => {
|
|
179
|
+
cancelAnimationRef.current?.();
|
|
180
|
+
};
|
|
181
|
+
}, []);
|
|
182
|
+
return {
|
|
183
|
+
setDragOffset,
|
|
184
|
+
springBack,
|
|
185
|
+
animateOut,
|
|
186
|
+
stop,
|
|
187
|
+
animatedStyle,
|
|
188
|
+
AnimatedView,
|
|
189
|
+
dragRef
|
|
190
|
+
};
|
|
254
191
|
}
|
|
192
|
+
|
|
255
193
|
export { useToastAnimations };
|
|
256
194
|
//# sourceMappingURL=useToastAnimations.mjs.map
|