@hanzogui/toast 7.0.0 → 7.3.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/dist/cjs/Toast.cjs +178 -0
- package/dist/cjs/Toast.native.js +181 -0
- package/dist/cjs/Toast.native.js.map +1 -0
- package/dist/cjs/ToastAnnounce.cjs +103 -0
- package/dist/cjs/ToastAnnounce.native.js +111 -0
- package/dist/cjs/ToastAnnounce.native.js.map +1 -0
- package/dist/cjs/ToastComposable.cjs +933 -0
- package/dist/cjs/ToastComposable.native.js +1025 -0
- package/dist/cjs/ToastComposable.native.js.map +1 -0
- package/dist/cjs/ToastImperative.cjs +119 -0
- package/dist/cjs/ToastImperative.native.js +130 -0
- package/dist/cjs/ToastImperative.native.js.map +1 -0
- package/dist/cjs/ToastImpl.cjs +354 -0
- package/dist/cjs/ToastImpl.native.js +364 -0
- package/dist/cjs/ToastImpl.native.js.map +1 -0
- package/dist/cjs/ToastItemFrame.cjs +143 -0
- package/dist/cjs/ToastItemFrame.native.js +148 -0
- package/dist/cjs/ToastItemFrame.native.js.map +1 -0
- package/dist/cjs/ToastPortal.cjs +49 -0
- package/dist/cjs/ToastPortal.native.js +52 -0
- package/dist/cjs/ToastPortal.native.js.map +1 -0
- package/dist/cjs/ToastProvider.cjs +150 -0
- package/dist/cjs/ToastProvider.native.js +161 -0
- package/dist/cjs/ToastProvider.native.js.map +1 -0
- package/dist/cjs/ToastState.cjs +311 -0
- package/dist/cjs/ToastState.native.js +324 -0
- package/dist/cjs/ToastState.native.js.map +1 -0
- package/dist/cjs/ToastViewport.cjs +319 -0
- package/dist/cjs/ToastViewport.native.js +343 -0
- package/dist/cjs/ToastViewport.native.js.map +1 -0
- package/dist/cjs/Toaster.cjs +87 -0
- package/dist/cjs/Toaster.native.js +91 -0
- package/dist/cjs/Toaster.native.js.map +1 -0
- package/dist/cjs/constants.cjs +30 -0
- package/dist/cjs/constants.native.js +33 -0
- package/dist/cjs/constants.native.js.map +1 -0
- package/dist/cjs/createNativeToast.cjs +59 -0
- package/dist/cjs/createNativeToast.native.js +60 -0
- package/dist/cjs/createNativeToast.native.js.map +1 -0
- package/dist/cjs/dispatchNativeToast.cjs +47 -0
- package/dist/cjs/dispatchNativeToast.native.js +52 -0
- package/dist/cjs/dispatchNativeToast.native.js.map +1 -0
- package/dist/cjs/index.cjs +20 -0
- package/dist/cjs/index.native.js +23 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/types.cjs +18 -0
- package/dist/cjs/types.native.js +21 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/cjs/useAnimatedDragGesture.cjs +214 -0
- package/dist/cjs/useAnimatedDragGesture.native.js +224 -0
- package/dist/cjs/useAnimatedDragGesture.native.js.map +1 -0
- package/dist/cjs/useReducedMotion.cjs +74 -0
- package/dist/cjs/useReducedMotion.native.js +83 -0
- package/dist/cjs/useReducedMotion.native.js.map +1 -0
- package/dist/cjs/useToastAnimations.cjs +294 -0
- package/dist/cjs/useToastAnimations.native.js +304 -0
- package/dist/cjs/useToastAnimations.native.js.map +1 -0
- package/dist/cjs/v2.cjs +36 -0
- package/dist/cjs/v2.native.js +39 -0
- package/dist/cjs/v2.native.js.map +1 -0
- package/dist/esm/Toast.mjs +137 -0
- package/dist/esm/Toast.mjs.map +1 -0
- package/dist/esm/Toast.native.js +137 -0
- package/dist/esm/Toast.native.js.map +1 -0
- package/dist/esm/ToastAnnounce.mjs +66 -0
- package/dist/esm/ToastAnnounce.mjs.map +1 -0
- package/dist/esm/ToastAnnounce.native.js +71 -0
- package/dist/esm/ToastAnnounce.native.js.map +1 -0
- package/dist/esm/ToastComposable.mjs +895 -0
- package/dist/esm/ToastComposable.mjs.map +1 -0
- package/dist/esm/ToastComposable.native.js +984 -0
- package/dist/esm/ToastComposable.native.js.map +1 -0
- package/dist/esm/ToastImperative.mjs +80 -0
- package/dist/esm/ToastImperative.mjs.map +1 -0
- package/dist/esm/ToastImperative.native.js +88 -0
- package/dist/esm/ToastImperative.native.js.map +1 -0
- package/dist/esm/ToastImpl.mjs +316 -0
- package/dist/esm/ToastImpl.mjs.map +1 -0
- package/dist/esm/ToastImpl.native.js +323 -0
- package/dist/esm/ToastImpl.native.js.map +1 -0
- package/dist/esm/ToastItemFrame.mjs +114 -0
- package/dist/esm/ToastItemFrame.mjs.map +1 -0
- package/dist/esm/ToastItemFrame.native.js +116 -0
- package/dist/esm/ToastItemFrame.native.js.map +1 -0
- package/dist/esm/ToastPortal.mjs +24 -0
- package/dist/esm/ToastPortal.mjs.map +1 -0
- package/dist/esm/ToastPortal.native.js +24 -0
- package/dist/esm/ToastPortal.native.js.map +1 -0
- package/dist/esm/ToastProvider.mjs +110 -0
- package/dist/esm/ToastProvider.mjs.map +1 -0
- package/dist/esm/ToastProvider.native.js +118 -0
- package/dist/esm/ToastProvider.native.js.map +1 -0
- package/dist/esm/ToastState.mjs +285 -0
- package/dist/esm/ToastState.mjs.map +1 -0
- package/dist/esm/ToastState.native.js +295 -0
- package/dist/esm/ToastState.native.js.map +1 -0
- package/dist/esm/ToastViewport.mjs +280 -0
- package/dist/esm/ToastViewport.mjs.map +1 -0
- package/dist/esm/ToastViewport.native.js +301 -0
- package/dist/esm/ToastViewport.native.js.map +1 -0
- package/dist/esm/Toaster.mjs +51 -0
- package/dist/esm/Toaster.mjs.map +1 -0
- package/dist/esm/Toaster.native.js +52 -0
- package/dist/esm/Toaster.native.js.map +1 -0
- package/dist/esm/constants.mjs +4 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/constants.native.js +4 -0
- package/dist/esm/constants.native.js.map +1 -0
- package/dist/esm/createNativeToast.mjs +32 -0
- package/dist/esm/createNativeToast.mjs.map +1 -0
- package/dist/esm/createNativeToast.native.js +30 -0
- package/dist/esm/createNativeToast.native.js.map +1 -0
- package/dist/esm/dispatchNativeToast.mjs +22 -0
- package/dist/esm/dispatchNativeToast.mjs.map +1 -0
- package/dist/esm/dispatchNativeToast.native.js +24 -0
- package/dist/esm/dispatchNativeToast.native.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +2 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -0
- package/dist/esm/types.native.js.map +1 -0
- package/dist/esm/useAnimatedDragGesture.mjs +178 -0
- package/dist/esm/useAnimatedDragGesture.mjs.map +1 -0
- package/dist/esm/useAnimatedDragGesture.native.js +185 -0
- package/dist/esm/useAnimatedDragGesture.native.js.map +1 -0
- package/dist/esm/useReducedMotion.mjs +38 -0
- package/dist/esm/useReducedMotion.mjs.map +1 -0
- package/dist/esm/useReducedMotion.native.js +44 -0
- package/dist/esm/useReducedMotion.native.js.map +1 -0
- package/dist/esm/useToastAnimations.mjs +258 -0
- package/dist/esm/useToastAnimations.mjs.map +1 -0
- package/dist/esm/useToastAnimations.native.js +265 -0
- package/dist/esm/useToastAnimations.native.js.map +1 -0
- package/dist/esm/v2.mjs +6 -0
- package/dist/esm/v2.mjs.map +1 -0
- package/dist/esm/v2.native.js +6 -0
- package/dist/esm/v2.native.js.map +1 -0
- package/dist/jsx/Toast.mjs +137 -0
- package/dist/jsx/Toast.mjs.map +1 -0
- package/dist/jsx/Toast.native.js +181 -0
- package/dist/jsx/Toast.native.js.map +1 -0
- package/dist/jsx/ToastAnnounce.mjs +66 -0
- package/dist/jsx/ToastAnnounce.mjs.map +1 -0
- package/dist/jsx/ToastAnnounce.native.js +111 -0
- package/dist/jsx/ToastAnnounce.native.js.map +1 -0
- package/dist/jsx/ToastComposable.mjs +895 -0
- package/dist/jsx/ToastComposable.mjs.map +1 -0
- package/dist/jsx/ToastComposable.native.js +1025 -0
- package/dist/jsx/ToastComposable.native.js.map +1 -0
- package/dist/jsx/ToastImperative.mjs +80 -0
- package/dist/jsx/ToastImperative.mjs.map +1 -0
- package/dist/jsx/ToastImperative.native.js +130 -0
- package/dist/jsx/ToastImperative.native.js.map +1 -0
- package/dist/jsx/ToastImpl.mjs +316 -0
- package/dist/jsx/ToastImpl.mjs.map +1 -0
- package/dist/jsx/ToastImpl.native.js +364 -0
- package/dist/jsx/ToastImpl.native.js.map +1 -0
- package/dist/jsx/ToastItemFrame.mjs +114 -0
- package/dist/jsx/ToastItemFrame.mjs.map +1 -0
- package/dist/jsx/ToastItemFrame.native.js +148 -0
- package/dist/jsx/ToastItemFrame.native.js.map +1 -0
- package/dist/jsx/ToastPortal.mjs +24 -0
- package/dist/jsx/ToastPortal.mjs.map +1 -0
- package/dist/jsx/ToastPortal.native.js +52 -0
- package/dist/jsx/ToastPortal.native.js.map +1 -0
- package/dist/jsx/ToastProvider.mjs +110 -0
- package/dist/jsx/ToastProvider.mjs.map +1 -0
- package/dist/jsx/ToastProvider.native.js +161 -0
- package/dist/jsx/ToastProvider.native.js.map +1 -0
- package/dist/jsx/ToastState.mjs +285 -0
- package/dist/jsx/ToastState.mjs.map +1 -0
- package/dist/jsx/ToastState.native.js +324 -0
- package/dist/jsx/ToastState.native.js.map +1 -0
- package/dist/jsx/ToastViewport.mjs +280 -0
- package/dist/jsx/ToastViewport.mjs.map +1 -0
- package/dist/jsx/ToastViewport.native.js +343 -0
- package/dist/jsx/ToastViewport.native.js.map +1 -0
- package/dist/jsx/Toaster.mjs +51 -0
- package/dist/jsx/Toaster.mjs.map +1 -0
- package/dist/jsx/Toaster.native.js +91 -0
- package/dist/jsx/Toaster.native.js.map +1 -0
- package/dist/jsx/constants.mjs +4 -0
- package/dist/jsx/constants.mjs.map +1 -0
- package/dist/jsx/constants.native.js +33 -0
- package/dist/jsx/constants.native.js.map +1 -0
- package/dist/jsx/createNativeToast.mjs +32 -0
- package/dist/jsx/createNativeToast.mjs.map +1 -0
- package/dist/jsx/createNativeToast.native.js +60 -0
- package/dist/jsx/createNativeToast.native.js.map +1 -0
- package/dist/jsx/dispatchNativeToast.mjs +22 -0
- package/dist/jsx/dispatchNativeToast.mjs.map +1 -0
- package/dist/jsx/dispatchNativeToast.native.js +52 -0
- package/dist/jsx/dispatchNativeToast.native.js.map +1 -0
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/index.mjs +2 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/index.native.js +23 -0
- package/dist/jsx/index.native.js.map +1 -0
- package/dist/jsx/types.mjs +2 -0
- package/dist/jsx/types.mjs.map +1 -0
- package/dist/jsx/types.native.js +21 -0
- package/dist/jsx/types.native.js.map +1 -0
- package/dist/jsx/useAnimatedDragGesture.mjs +178 -0
- package/dist/jsx/useAnimatedDragGesture.mjs.map +1 -0
- package/dist/jsx/useAnimatedDragGesture.native.js +224 -0
- package/dist/jsx/useAnimatedDragGesture.native.js.map +1 -0
- package/dist/jsx/useReducedMotion.mjs +38 -0
- package/dist/jsx/useReducedMotion.mjs.map +1 -0
- package/dist/jsx/useReducedMotion.native.js +83 -0
- package/dist/jsx/useReducedMotion.native.js.map +1 -0
- package/dist/jsx/useToastAnimations.mjs +258 -0
- package/dist/jsx/useToastAnimations.mjs.map +1 -0
- package/dist/jsx/useToastAnimations.native.js +304 -0
- package/dist/jsx/useToastAnimations.native.js.map +1 -0
- package/dist/jsx/v2.mjs +6 -0
- package/dist/jsx/v2.mjs.map +1 -0
- package/dist/jsx/v2.native.js +39 -0
- package/dist/jsx/v2.native.js.map +1 -0
- package/package.json +26 -24
- package/src/Toast.tsx +5 -5
- package/src/ToastAnnounce.tsx +2 -2
- package/src/ToastComposable.tsx +8 -8
- package/src/ToastImpl.tsx +6 -6
- package/src/ToastItemFrame.tsx +4 -4
- package/src/ToastProvider.tsx +5 -5
- package/src/ToastViewport.tsx +7 -7
- package/src/Toaster.tsx +2 -2
- package/src/useToastAnimations.ts +3 -3
- package/types/Toast.d.ts +14 -14
- package/types/Toast.d.ts.map +1 -0
- package/types/ToastAnnounce.d.ts +3 -3
- package/types/ToastAnnounce.d.ts.map +1 -0
- package/types/ToastComposable.d.ts +15 -15
- package/types/ToastComposable.d.ts.map +1 -0
- package/types/ToastImperative.d.ts +1 -1
- package/types/ToastImperative.d.ts.map +1 -0
- package/types/ToastImpl.d.ts +4 -4
- package/types/ToastImpl.d.ts.map +1 -0
- package/types/ToastItemFrame.d.ts +5 -5
- package/types/ToastItemFrame.d.ts.map +1 -0
- package/types/ToastPortal.d.ts +1 -1
- package/types/ToastPortal.d.ts.map +1 -0
- package/types/ToastProvider.d.ts +7 -7
- package/types/ToastProvider.d.ts.map +1 -0
- package/types/ToastState.d.ts.map +1 -0
- package/types/ToastViewport.d.ts +5 -5
- package/types/ToastViewport.d.ts.map +1 -0
- package/types/Toaster.d.ts +2 -2
- package/types/Toaster.d.ts.map +1 -0
- package/types/constants.d.ts.map +1 -0
- package/types/createNativeToast.d.ts.map +1 -0
- package/types/createNativeToast.native.d.ts.map +1 -0
- package/types/dispatchNativeToast.d.ts.map +1 -0
- package/types/index.d.ts.map +1 -0
- package/types/types.d.ts.map +1 -0
- package/types/useAnimatedDragGesture.d.ts.map +1 -0
- package/types/useAnimatedDragGesture.native.d.ts.map +1 -0
- package/types/useReducedMotion.d.ts.map +1 -0
- package/types/useToastAnimations.d.ts.map +1 -0
- package/types/v2.d.ts.map +1 -0
- package/v2/index.cjs +1 -1
- package/v2/index.native.cjs +1 -1
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
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
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
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
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
36
|
+
var useToastAnimations_exports = {};
|
|
37
|
+
__export(useToastAnimations_exports, {
|
|
38
|
+
useToastAnimations: () => useToastAnimations
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(useToastAnimations_exports);
|
|
41
|
+
var import_constants = require("@hanzogui/constants");
|
|
42
|
+
var import_core = require("@hanzogui/core");
|
|
43
|
+
var React = __toESM(require("react"), 1);
|
|
44
|
+
var SPRING_CONFIG = {
|
|
45
|
+
type: "spring",
|
|
46
|
+
damping: 30,
|
|
47
|
+
stiffness: 400,
|
|
48
|
+
mass: 0.5
|
|
49
|
+
};
|
|
50
|
+
var EXIT_DISTANCE = 200;
|
|
51
|
+
function animateSpring(element, fromX, fromY, toX, toY, config, onComplete) {
|
|
52
|
+
var {
|
|
53
|
+
damping = 30,
|
|
54
|
+
stiffness = 400,
|
|
55
|
+
mass = 0.5,
|
|
56
|
+
initialVelocityX = 0,
|
|
57
|
+
initialVelocityY = 0,
|
|
58
|
+
fadeOut = false
|
|
59
|
+
} = config;
|
|
60
|
+
var x = fromX;
|
|
61
|
+
var y = fromY;
|
|
62
|
+
var velocityX = initialVelocityX;
|
|
63
|
+
var velocityY = initialVelocityY;
|
|
64
|
+
var animationId = null;
|
|
65
|
+
var targetX = toX;
|
|
66
|
+
var targetY = toY;
|
|
67
|
+
var totalDistance = Math.sqrt(Math.pow(toX - fromX, 2) + Math.pow(toY - fromY, 2)) || 1;
|
|
68
|
+
function step() {
|
|
69
|
+
var forceX = -stiffness * (x - targetX);
|
|
70
|
+
var forceY = -stiffness * (y - targetY);
|
|
71
|
+
var dampingForceX = -damping * velocityX;
|
|
72
|
+
var dampingForceY = -damping * velocityY;
|
|
73
|
+
var accelerationX = (forceX + dampingForceX) / mass;
|
|
74
|
+
var accelerationY = (forceY + dampingForceY) / mass;
|
|
75
|
+
velocityX += accelerationX * 0.016;
|
|
76
|
+
velocityY += accelerationY * 0.016;
|
|
77
|
+
x += velocityX * 0.016;
|
|
78
|
+
y += velocityY * 0.016;
|
|
79
|
+
element.style.transform = `translate3d(${x}px, ${y}px, 0)`;
|
|
80
|
+
if (fadeOut) {
|
|
81
|
+
var distanceTraveled = Math.sqrt(Math.pow(x - fromX, 2) + Math.pow(y - fromY, 2));
|
|
82
|
+
var progress = Math.min(distanceTraveled / totalDistance, 1);
|
|
83
|
+
element.style.opacity = String(1 - progress);
|
|
84
|
+
}
|
|
85
|
+
var distanceX = Math.abs(x - targetX);
|
|
86
|
+
var distanceY = Math.abs(y - targetY);
|
|
87
|
+
var speed = Math.sqrt(velocityX * velocityX + velocityY * velocityY);
|
|
88
|
+
if (distanceX < 0.5 && distanceY < 0.5 && speed < 0.5) {
|
|
89
|
+
element.style.transform = `translate3d(${targetX}px, ${targetY}px, 0)`;
|
|
90
|
+
if (fadeOut) {
|
|
91
|
+
element.style.opacity = "0";
|
|
92
|
+
}
|
|
93
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
animationId = requestAnimationFrame(step);
|
|
97
|
+
}
|
|
98
|
+
animationId = requestAnimationFrame(step);
|
|
99
|
+
return function () {
|
|
100
|
+
if (animationId) {
|
|
101
|
+
cancelAnimationFrame(animationId);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function useToastAnimations() {
|
|
106
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
107
|
+
var {
|
|
108
|
+
onExitComplete,
|
|
109
|
+
reducedMotion,
|
|
110
|
+
swipeAxis = "horizontal"
|
|
111
|
+
} = options;
|
|
112
|
+
var {
|
|
113
|
+
animationDriver
|
|
114
|
+
} = (0, import_core.useConfiguration)();
|
|
115
|
+
if (!animationDriver) {
|
|
116
|
+
throw new Error("Toast requires an animation driver to be set in GuiProvider");
|
|
117
|
+
}
|
|
118
|
+
var {
|
|
119
|
+
useAnimatedNumber,
|
|
120
|
+
useAnimatedNumberStyle,
|
|
121
|
+
useAnimatedNumbersStyle
|
|
122
|
+
} = animationDriver;
|
|
123
|
+
var _animationDriver_View;
|
|
124
|
+
var AnimatedView = (_animationDriver_View = animationDriver.View) !== null && _animationDriver_View !== void 0 ? _animationDriver_View : import_core.View;
|
|
125
|
+
var dragRef = React.useRef(null);
|
|
126
|
+
var cancelAnimationRef = React.useRef(null);
|
|
127
|
+
var currentOffsetRef = React.useRef({
|
|
128
|
+
x: 0,
|
|
129
|
+
y: 0
|
|
130
|
+
});
|
|
131
|
+
var useDirectDom = import_constants.isWeb;
|
|
132
|
+
var translateX = useAnimatedNumber(0);
|
|
133
|
+
var translateY = useAnimatedNumber(0);
|
|
134
|
+
var animatedStyleMulti = useAnimatedNumbersStyle ? useAnimatedNumbersStyle([translateX, translateY], function (x, y) {
|
|
135
|
+
"worklet";
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
transform: [{
|
|
139
|
+
translateX: x
|
|
140
|
+
}, {
|
|
141
|
+
translateY: y
|
|
142
|
+
}]
|
|
143
|
+
};
|
|
144
|
+
}) : null;
|
|
145
|
+
var animatedStyleFallback = useAnimatedNumberStyle(swipeAxis === "vertical" ? translateY : translateX, function (primary) {
|
|
146
|
+
"worklet";
|
|
147
|
+
|
|
148
|
+
var secondary = swipeAxis === "vertical" ? translateX.getValue() : translateY.getValue();
|
|
149
|
+
return swipeAxis === "vertical" ? {
|
|
150
|
+
transform: [{
|
|
151
|
+
translateX: secondary
|
|
152
|
+
}, {
|
|
153
|
+
translateY: primary
|
|
154
|
+
}]
|
|
155
|
+
} : {
|
|
156
|
+
transform: [{
|
|
157
|
+
translateX: primary
|
|
158
|
+
}, {
|
|
159
|
+
translateY: secondary
|
|
160
|
+
}]
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
var animatedStyle = animatedStyleMulti !== null && animatedStyleMulti !== void 0 ? animatedStyleMulti : animatedStyleFallback;
|
|
164
|
+
var setDragOffset = (0, import_core.useEvent)(function (x, y) {
|
|
165
|
+
var _cancelAnimationRef_current;
|
|
166
|
+
(_cancelAnimationRef_current = cancelAnimationRef.current) === null || _cancelAnimationRef_current === void 0 ? void 0 : _cancelAnimationRef_current.call(cancelAnimationRef);
|
|
167
|
+
cancelAnimationRef.current = null;
|
|
168
|
+
currentOffsetRef.current = {
|
|
169
|
+
x,
|
|
170
|
+
y
|
|
171
|
+
};
|
|
172
|
+
if (useDirectDom && dragRef.current) {
|
|
173
|
+
dragRef.current.style.transform = `translate3d(${x}px, ${y}px, 0)`;
|
|
174
|
+
dragRef.current.style.opacity = "1";
|
|
175
|
+
} else {
|
|
176
|
+
translateX.setValue(x, {
|
|
177
|
+
type: "direct"
|
|
178
|
+
});
|
|
179
|
+
translateY.setValue(y, {
|
|
180
|
+
type: "direct"
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
var springBack = (0, import_core.useEvent)(function (onComplete) {
|
|
185
|
+
var _cancelAnimationRef_current;
|
|
186
|
+
(_cancelAnimationRef_current = cancelAnimationRef.current) === null || _cancelAnimationRef_current === void 0 ? void 0 : _cancelAnimationRef_current.call(cancelAnimationRef);
|
|
187
|
+
if (reducedMotion) {
|
|
188
|
+
if (useDirectDom && dragRef.current) {
|
|
189
|
+
dragRef.current.style.transform = "translate3d(0px, 0px, 0)";
|
|
190
|
+
} else {
|
|
191
|
+
translateX.setValue(0, {
|
|
192
|
+
type: "direct"
|
|
193
|
+
});
|
|
194
|
+
translateY.setValue(0, {
|
|
195
|
+
type: "direct"
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
currentOffsetRef.current = {
|
|
199
|
+
x: 0,
|
|
200
|
+
y: 0
|
|
201
|
+
};
|
|
202
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (useDirectDom && dragRef.current) {
|
|
206
|
+
var {
|
|
207
|
+
x,
|
|
208
|
+
y
|
|
209
|
+
} = currentOffsetRef.current;
|
|
210
|
+
cancelAnimationRef.current = animateSpring(dragRef.current, x, y, 0, 0, SPRING_CONFIG, function () {
|
|
211
|
+
currentOffsetRef.current = {
|
|
212
|
+
x: 0,
|
|
213
|
+
y: 0
|
|
214
|
+
};
|
|
215
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
216
|
+
});
|
|
217
|
+
} else {
|
|
218
|
+
translateX.setValue(0, SPRING_CONFIG);
|
|
219
|
+
translateY.setValue(0, SPRING_CONFIG, onComplete);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
var animateOut = (0, import_core.useEvent)(function (direction, velocity, onComplete) {
|
|
223
|
+
var _cancelAnimationRef_current;
|
|
224
|
+
(_cancelAnimationRef_current = cancelAnimationRef.current) === null || _cancelAnimationRef_current === void 0 ? void 0 : _cancelAnimationRef_current.call(cancelAnimationRef);
|
|
225
|
+
var {
|
|
226
|
+
x: curX,
|
|
227
|
+
y: curY
|
|
228
|
+
} = currentOffsetRef.current;
|
|
229
|
+
var exitX = direction === "left" ? -EXIT_DISTANCE : direction === "right" ? EXIT_DISTANCE : 0;
|
|
230
|
+
var exitY = direction === "up" ? -EXIT_DISTANCE : direction === "down" ? EXIT_DISTANCE : 0;
|
|
231
|
+
if (direction === "left" && curX < exitX) exitX = curX - 50;else if (direction === "right" && curX > exitX) exitX = curX + 50;
|
|
232
|
+
if (direction === "up" && curY < exitY) exitY = curY - 50;else if (direction === "down" && curY > exitY) exitY = curY + 50;
|
|
233
|
+
if (reducedMotion) {
|
|
234
|
+
if (useDirectDom && dragRef.current) {
|
|
235
|
+
dragRef.current.style.transform = `translate3d(${exitX}px, ${exitY}px, 0)`;
|
|
236
|
+
} else {
|
|
237
|
+
translateX.setValue(exitX, {
|
|
238
|
+
type: "direct"
|
|
239
|
+
});
|
|
240
|
+
translateY.setValue(exitY, {
|
|
241
|
+
type: "direct"
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
245
|
+
onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
var velocityScale = (velocity !== null && velocity !== void 0 ? velocity : 0) * 500;
|
|
249
|
+
var initialVelocityX = direction === "left" ? -velocityScale : direction === "right" ? velocityScale : 0;
|
|
250
|
+
var initialVelocityY = direction === "up" ? -velocityScale : direction === "down" ? velocityScale : 0;
|
|
251
|
+
var exitConfig = {
|
|
252
|
+
damping: 25,
|
|
253
|
+
stiffness: 350,
|
|
254
|
+
mass: 0.4,
|
|
255
|
+
initialVelocityX,
|
|
256
|
+
initialVelocityY,
|
|
257
|
+
fadeOut: true
|
|
258
|
+
};
|
|
259
|
+
if (useDirectDom && dragRef.current) {
|
|
260
|
+
var {
|
|
261
|
+
x,
|
|
262
|
+
y
|
|
263
|
+
} = currentOffsetRef.current;
|
|
264
|
+
cancelAnimationRef.current = animateSpring(dragRef.current, x, y, exitX, exitY, exitConfig, function () {
|
|
265
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
266
|
+
onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
|
|
267
|
+
});
|
|
268
|
+
} else {
|
|
269
|
+
var springConfig = {
|
|
270
|
+
type: "spring",
|
|
271
|
+
damping: 25,
|
|
272
|
+
stiffness: 350,
|
|
273
|
+
mass: 0.4
|
|
274
|
+
};
|
|
275
|
+
translateX.setValue(exitX, springConfig);
|
|
276
|
+
translateY.setValue(exitY, springConfig, function () {
|
|
277
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
278
|
+
onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
var stop = (0, import_core.useEvent)(function () {
|
|
283
|
+
var _cancelAnimationRef_current;
|
|
284
|
+
(_cancelAnimationRef_current = cancelAnimationRef.current) === null || _cancelAnimationRef_current === void 0 ? void 0 : _cancelAnimationRef_current.call(cancelAnimationRef);
|
|
285
|
+
translateX.stop();
|
|
286
|
+
translateY.stop();
|
|
287
|
+
});
|
|
288
|
+
React.useEffect(function () {
|
|
289
|
+
return function () {
|
|
290
|
+
var _cancelAnimationRef_current;
|
|
291
|
+
(_cancelAnimationRef_current = cancelAnimationRef.current) === null || _cancelAnimationRef_current === void 0 ? void 0 : _cancelAnimationRef_current.call(cancelAnimationRef);
|
|
292
|
+
};
|
|
293
|
+
}, []);
|
|
294
|
+
return {
|
|
295
|
+
setDragOffset,
|
|
296
|
+
springBack,
|
|
297
|
+
animateOut,
|
|
298
|
+
stop,
|
|
299
|
+
animatedStyle,
|
|
300
|
+
AnimatedView,
|
|
301
|
+
dragRef
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=useToastAnimations.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","useToastAnimations_exports","useToastAnimations","module","exports","import_constants","require","import_core","React","SPRING_CONFIG","type","damping","stiffness","mass","EXIT_DISTANCE","animateSpring","element","fromX","fromY","toX","toY","config","onComplete","initialVelocityX","initialVelocityY","fadeOut","x","y","velocityX","velocityY","animationId","targetX","targetY","totalDistance","Math","sqrt","pow","step","forceX","forceY","dampingForceX","dampingForceY","accelerationX","accelerationY","style","transform","distanceTraveled","progress","min","opacity","String","distanceX","abs","distanceY","speed","requestAnimationFrame","cancelAnimationFrame","options","arguments","length","onExitComplete","reducedMotion","swipeAxis","animationDriver","useConfiguration","Error","useAnimatedNumber","useAnimatedNumberStyle","useAnimatedNumbersStyle","_animationDriver_View","AnimatedView","View","dragRef","useRef","cancelAnimationRef","currentOffsetRef","useDirectDom","isWeb","translateX","translateY","animatedStyleMulti","animatedStyleFallback","primary","secondary","getValue","animatedStyle","setDragOffset","useEvent","_cancelAnimationRef_current","current","setValue","springBack","animateOut","direction","velocity","curX","curY","exitX","exitY"],"sources":["../../src/useToastAnimations.ts"],"sourcesContent":[null],"mappings":"AAgBA,YAAS;;AACT,IAAAA,QAAS,GAAAC,MAAA,CAAAC,MAAkB;AAC3B,IAAAC,SAAY,GAAAF,MAAA,CAAWG,cAAA;AAyCvB,IAAAC,gBAAM,GAAgBJ,MAAA,CAAAK,wBAAA;AAAA,IACpBC,iBAAM,GAAAN,MAAA,CAAAO,mBAAA;AAAA,IACNC,YAAS,GAAAR,MAAA,CAAAS,c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,KAAA,EAAAA,KAAA,GAAAF,IAAA,WACA,IAAAF,SAAA,gBAAAE,IAAA,GAAAE,KAAA,EAAAA,KAAA,GAAAF,IAAA;IACA,IAAAF,SAAA,aAAAG,IAAA,GAAAE,KAAA,EAAAA,KAAA,GAAAF,IAAA,WACA,IAAAH,SAAA,eAAAG,IAAA,GAAAE,KAAA,EAAAA,KAAA,GAAAF,IAAA;IACF,IAAAnC,aAAA;MACF,IAAAe,YAAA,IAAAJ,OAAA,CAAAiB,OAAA","ignoreList":[]}
|
package/dist/jsx/v2.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Toast, useToasts, useToastItem } from "./ToastComposable.mjs";
|
|
2
|
+
import { toast } from "./ToastState.mjs";
|
|
3
|
+
import { Toaster } from "./Toaster.mjs";
|
|
4
|
+
import { requestNotificationPermission } from "./createNativeToast.mjs";
|
|
5
|
+
export { Toast, Toaster, requestNotificationPermission, toast, useToastItem, useToasts };
|
|
6
|
+
//# sourceMappingURL=v2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Toast","useToasts","useToastItem","toast","Toaster","requestNotificationPermission"],"sources":["../../src/v2.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,KAAA,EAAOC,SAAA,EAAWC,YAAA,QAAoB;AAY/C,SAASC,KAAA,QAAa;AAYtB,SAASC,OAAA,QAAe;AAKxB,SAASC,6BAAA,QAAqC","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
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) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var v2_exports = {};
|
|
26
|
+
__export(v2_exports, {
|
|
27
|
+
Toast: () => import_ToastComposable.Toast,
|
|
28
|
+
Toaster: () => import_Toaster.Toaster,
|
|
29
|
+
requestNotificationPermission: () => import_createNativeToast.requestNotificationPermission,
|
|
30
|
+
toast: () => import_ToastState.toast,
|
|
31
|
+
useToastItem: () => import_ToastComposable.useToastItem,
|
|
32
|
+
useToasts: () => import_ToastComposable.useToasts
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(v2_exports);
|
|
35
|
+
var import_ToastComposable = require("./ToastComposable.native.js");
|
|
36
|
+
var import_ToastState = require("./ToastState.native.js");
|
|
37
|
+
var import_Toaster = require("./Toaster.native.js");
|
|
38
|
+
var import_createNativeToast = require("./createNativeToast.native.js");
|
|
39
|
+
//# sourceMappingURL=v2.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames"],"sources":["../../src/v2.ts"],"sourcesContent":[null],"mappings":"AACA,YAAS;;AAYT,IAAAA,SAAS,GAAAC,MAAa,CAAAC,cAAA;AAYtB,IAAAC,gBAAS,GAAAF,MAAe,CAAAG,wBAAA;AAKxB,IAAAC,iBAAS,GAAAJ,MAAA,CAAAK,mBAAqC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzogui/toast",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -40,31 +40,31 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
|
-
"build": "
|
|
44
|
-
"watch": "
|
|
45
|
-
"clean": "
|
|
46
|
-
"clean:build": "
|
|
43
|
+
"build": "gui-build",
|
|
44
|
+
"watch": "gui-build --watch",
|
|
45
|
+
"clean": "gui-build clean",
|
|
46
|
+
"clean:build": "gui-build clean:build"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@hanzogui/animate-presence": "
|
|
50
|
-
"@hanzogui/collection": "
|
|
51
|
-
"@hanzogui/compose-refs": "
|
|
52
|
-
"@hanzogui/constants": "
|
|
53
|
-
"@hanzogui/core": "
|
|
54
|
-
"@hanzogui/create-context": "
|
|
55
|
-
"@hanzogui/dismissable": "
|
|
56
|
-
"@hanzogui/helpers": "
|
|
57
|
-
"@hanzogui/native": "
|
|
58
|
-
"@hanzogui/polyfill-dev": "
|
|
59
|
-
"@hanzogui/portal": "
|
|
60
|
-
"@hanzogui/stacks": "
|
|
61
|
-
"@hanzogui/start-transition": "
|
|
62
|
-
"@hanzogui/text": "
|
|
63
|
-
"@hanzogui/use-controllable-state": "
|
|
64
|
-
"@hanzogui/visually-hidden": "
|
|
49
|
+
"@hanzogui/animate-presence": "7.3.0",
|
|
50
|
+
"@hanzogui/collection": "7.3.0",
|
|
51
|
+
"@hanzogui/compose-refs": "7.3.0",
|
|
52
|
+
"@hanzogui/constants": "7.3.0",
|
|
53
|
+
"@hanzogui/core": "7.3.0",
|
|
54
|
+
"@hanzogui/create-context": "7.3.0",
|
|
55
|
+
"@hanzogui/dismissable": "7.3.0",
|
|
56
|
+
"@hanzogui/helpers": "7.3.0",
|
|
57
|
+
"@hanzogui/native": "7.3.0",
|
|
58
|
+
"@hanzogui/polyfill-dev": "7.3.0",
|
|
59
|
+
"@hanzogui/portal": "7.3.0",
|
|
60
|
+
"@hanzogui/stacks": "7.3.0",
|
|
61
|
+
"@hanzogui/start-transition": "7.3.0",
|
|
62
|
+
"@hanzogui/text": "7.3.0",
|
|
63
|
+
"@hanzogui/use-controllable-state": "7.3.0",
|
|
64
|
+
"@hanzogui/visually-hidden": "7.3.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@hanzogui/build": "
|
|
67
|
+
"@hanzogui/build": "7.3.0",
|
|
68
68
|
"react": ">=19",
|
|
69
69
|
"react-native": "0.83.2"
|
|
70
70
|
},
|
|
@@ -79,5 +79,7 @@
|
|
|
79
79
|
"./types/v2.d.ts"
|
|
80
80
|
]
|
|
81
81
|
}
|
|
82
|
-
}
|
|
83
|
-
|
|
82
|
+
},
|
|
83
|
+
"license": "BSD-3-Clause",
|
|
84
|
+
"author": "Hanzo AI <dev@hanzo.ai>"
|
|
85
|
+
}
|
package/src/Toast.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnimatePresence } from '@hanzogui/animate-presence'
|
|
2
|
-
import type { GetProps, NativePlatform, NativeValue,
|
|
2
|
+
import type { GetProps, NativePlatform, NativeValue, GuiElement } from '@hanzogui/core'
|
|
3
3
|
import { styled, useEvent } from '@hanzogui/core'
|
|
4
4
|
import { composeEventHandlers, withStaticProperties } from '@hanzogui/helpers'
|
|
5
5
|
import { YStack } from '@hanzogui/stacks'
|
|
@@ -35,7 +35,7 @@ const ToastTitle = styled(SizableText, {
|
|
|
35
35
|
} as const,
|
|
36
36
|
|
|
37
37
|
defaultVariants: {
|
|
38
|
-
unstyled: process.env.
|
|
38
|
+
unstyled: process.env.GUI_HEADLESS === '1',
|
|
39
39
|
},
|
|
40
40
|
})
|
|
41
41
|
|
|
@@ -60,7 +60,7 @@ const ToastDescription = styled(SizableText, {
|
|
|
60
60
|
} as const,
|
|
61
61
|
|
|
62
62
|
defaultVariants: {
|
|
63
|
-
unstyled: process.env.
|
|
63
|
+
unstyled: process.env.GUI_HEADLESS === '1',
|
|
64
64
|
},
|
|
65
65
|
})
|
|
66
66
|
|
|
@@ -84,7 +84,7 @@ type ToastActionProps = ScopedProps<
|
|
|
84
84
|
}
|
|
85
85
|
>
|
|
86
86
|
|
|
87
|
-
const ToastAction = React.forwardRef<
|
|
87
|
+
const ToastAction = React.forwardRef<GuiElement, ScopedProps<ToastActionProps>>(
|
|
88
88
|
function ToastAction(props, forwardedRef) {
|
|
89
89
|
const { altText, ...actionProps } = props
|
|
90
90
|
if (!altText) return null
|
|
@@ -119,7 +119,7 @@ const ToastCloseFrame = styled(YStack, {
|
|
|
119
119
|
type ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>
|
|
120
120
|
type ToastCloseProps = ScopedProps<ToastCloseFrameProps & {}>
|
|
121
121
|
|
|
122
|
-
const ToastClose = React.forwardRef<
|
|
122
|
+
const ToastClose = React.forwardRef<GuiElement, ToastCloseProps>(
|
|
123
123
|
function ToastClose(props, forwardedRef) {
|
|
124
124
|
const { scope, ...closeProps } = props
|
|
125
125
|
const interactiveContext = useToastInteractiveContext(scope)
|
package/src/ToastAnnounce.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useIsomorphicLayoutEffect } from '@hanzogui/constants'
|
|
2
|
-
import type { GetProps,
|
|
2
|
+
import type { GetProps, GuiElement } from '@hanzogui/core'
|
|
3
3
|
import { View, Text, styled, useEvent } from '@hanzogui/core'
|
|
4
4
|
import { Portal } from '@hanzogui/portal'
|
|
5
5
|
import { startTransition } from '@hanzogui/start-transition'
|
|
@@ -22,7 +22,7 @@ type ToastAnnounceExcludeExtraProps = {
|
|
|
22
22
|
type ToastAnnounceExcludeProps = ToastAnnounceExcludeFrameProps &
|
|
23
23
|
ToastAnnounceExcludeExtraProps
|
|
24
24
|
|
|
25
|
-
const ToastAnnounceExclude = React.forwardRef<
|
|
25
|
+
const ToastAnnounceExclude = React.forwardRef<GuiElement, ToastAnnounceExcludeProps>(
|
|
26
26
|
(props, forwardedRef) => {
|
|
27
27
|
const { altText, ...announceExcludeProps } = props
|
|
28
28
|
|
package/src/ToastComposable.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnimatePresence } from '@hanzogui/animate-presence'
|
|
2
2
|
import { isWeb } from '@hanzogui/constants'
|
|
3
3
|
import { getGestureHandler } from '@hanzogui/native'
|
|
4
|
-
import type { GetProps,
|
|
4
|
+
import type { GetProps, GuiElement } from '@hanzogui/core'
|
|
5
5
|
import {
|
|
6
6
|
createStyledContext,
|
|
7
7
|
styled,
|
|
@@ -225,7 +225,7 @@ function resolveSwipeDirection(
|
|
|
225
225
|
return 'horizontal'
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
const ToastRoot = React.forwardRef<
|
|
228
|
+
const ToastRoot = React.forwardRef<GuiElement, ToastRootProps>(
|
|
229
229
|
function ToastRoot(props, _ref) {
|
|
230
230
|
const {
|
|
231
231
|
children,
|
|
@@ -447,7 +447,7 @@ const ToastViewportFrame = styled(View, {
|
|
|
447
447
|
} as const,
|
|
448
448
|
|
|
449
449
|
defaultVariants: {
|
|
450
|
-
unstyled: process.env.
|
|
450
|
+
unstyled: process.env.GUI_HEADLESS === '1',
|
|
451
451
|
},
|
|
452
452
|
})
|
|
453
453
|
|
|
@@ -491,7 +491,7 @@ const ToastViewport = ToastViewportFrame.styleable<ToastViewportProps>(
|
|
|
491
491
|
} = props
|
|
492
492
|
|
|
493
493
|
const ctx = useToastContext()
|
|
494
|
-
const listRef = React.useRef<
|
|
494
|
+
const listRef = React.useRef<GuiElement>(null)
|
|
495
495
|
const hoverTimeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
496
496
|
const hoverCooldownRef = React.useRef(false)
|
|
497
497
|
const deferredCollapseRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
@@ -504,8 +504,8 @@ const ToastViewport = ToastViewportFrame.styleable<ToastViewportProps>(
|
|
|
504
504
|
|
|
505
505
|
// offset styles
|
|
506
506
|
// on native, get safe area insets to avoid status bar / Dynamic Island / home indicator
|
|
507
|
-
// use insets from
|
|
508
|
-
// same pattern as Slider — works on native when
|
|
507
|
+
// use insets from GuiProvider (passed via useConfiguration)
|
|
508
|
+
// same pattern as Slider — works on native when GuiProvider has insets prop
|
|
509
509
|
const { insets: safeInsets } = useConfiguration()
|
|
510
510
|
|
|
511
511
|
const offsetStyles = React.useMemo(() => {
|
|
@@ -1243,7 +1243,7 @@ const ToastTitle = styled(SizableText, {
|
|
|
1243
1243
|
} as const,
|
|
1244
1244
|
|
|
1245
1245
|
defaultVariants: {
|
|
1246
|
-
unstyled: process.env.
|
|
1246
|
+
unstyled: process.env.GUI_HEADLESS === '1',
|
|
1247
1247
|
},
|
|
1248
1248
|
})
|
|
1249
1249
|
|
|
@@ -1264,7 +1264,7 @@ const ToastDescription = styled(SizableText, {
|
|
|
1264
1264
|
} as const,
|
|
1265
1265
|
|
|
1266
1266
|
defaultVariants: {
|
|
1267
|
-
unstyled: process.env.
|
|
1267
|
+
unstyled: process.env.GUI_HEADLESS === '1',
|
|
1268
1268
|
},
|
|
1269
1269
|
})
|
|
1270
1270
|
|
package/src/ToastImpl.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useIsPresent } from '@hanzogui/animate-presence'
|
|
2
2
|
import { useComposedRefs } from '@hanzogui/compose-refs'
|
|
3
3
|
import { isWeb } from '@hanzogui/constants'
|
|
4
|
-
import type { GetProps,
|
|
4
|
+
import type { GetProps, GuiElement } from '@hanzogui/core'
|
|
5
5
|
import {
|
|
6
6
|
View,
|
|
7
7
|
Theme,
|
|
@@ -26,7 +26,7 @@ import type {
|
|
|
26
26
|
|
|
27
27
|
// Lazy load PanResponder only on native to avoid SSR issues
|
|
28
28
|
const getPanResponder = (): typeof PanResponderType | null => {
|
|
29
|
-
if (process.env.
|
|
29
|
+
if (process.env.GUI_TARGET === 'native') {
|
|
30
30
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
31
31
|
return require('react-native').PanResponder
|
|
32
32
|
}
|
|
@@ -62,7 +62,7 @@ const ToastImplFrame = styled(YStack, {
|
|
|
62
62
|
} as const,
|
|
63
63
|
|
|
64
64
|
defaultVariants: {
|
|
65
|
-
unstyled: process.env.
|
|
65
|
+
unstyled: process.env.GUI_HEADLESS === '1',
|
|
66
66
|
},
|
|
67
67
|
})
|
|
68
68
|
|
|
@@ -161,7 +161,7 @@ type ToastImplProps = ScopedProps<
|
|
|
161
161
|
ToastImplPrivateProps & ToastImplFrameProps & ToastExtraProps
|
|
162
162
|
>
|
|
163
163
|
|
|
164
|
-
const ToastImpl = React.forwardRef<
|
|
164
|
+
const ToastImpl = React.forwardRef<GuiElement, ToastImplProps>(
|
|
165
165
|
(props, forwardedRef) => {
|
|
166
166
|
const {
|
|
167
167
|
scope,
|
|
@@ -181,7 +181,7 @@ const ToastImpl = React.forwardRef<HanzoguiElement, ToastImplProps>(
|
|
|
181
181
|
} = props
|
|
182
182
|
const isPresent = useIsPresent()
|
|
183
183
|
const context = useToastProviderContext(scope)
|
|
184
|
-
const [node, setNode] = React.useState<
|
|
184
|
+
const [node, setNode] = React.useState<GuiElement | null>(null)
|
|
185
185
|
const composedRefs = useComposedRefs(forwardedRef, setNode)
|
|
186
186
|
const duration = durationProp || context.duration
|
|
187
187
|
const closeTimerStartTimeRef = React.useRef(0)
|
|
@@ -270,7 +270,7 @@ const ToastImpl = React.forwardRef<HanzoguiElement, ToastImplProps>(
|
|
|
270
270
|
|
|
271
271
|
const { animationDriver } = useConfiguration()
|
|
272
272
|
if (!animationDriver) {
|
|
273
|
-
throw new Error('Must set animations in
|
|
273
|
+
throw new Error('Must set animations in gui.config.ts')
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
const { useAnimatedNumber, useAnimatedNumberStyle } = animationDriver
|
package/src/ToastItemFrame.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import { SizableText } from '@hanzogui/text'
|
|
|
9
9
|
|
|
10
10
|
/* -------------------------------------------------------------------------------------------------
|
|
11
11
|
* ToastPositionWrapper - handles absolute positioning and stacking animations
|
|
12
|
-
* On web: uses
|
|
12
|
+
* On web: uses Gui transition/enterStyle/exitStyle
|
|
13
13
|
* On native: replaced by Animated.View with useAnimatedStyle
|
|
14
14
|
* -----------------------------------------------------------------------------------------------*/
|
|
15
15
|
|
|
@@ -58,7 +58,7 @@ export const ToastItemFrame = styled(YStack, {
|
|
|
58
58
|
} as const,
|
|
59
59
|
|
|
60
60
|
defaultVariants: {
|
|
61
|
-
unstyled: process.env.
|
|
61
|
+
unstyled: process.env.GUI_HEADLESS === '1',
|
|
62
62
|
},
|
|
63
63
|
})
|
|
64
64
|
|
|
@@ -92,7 +92,7 @@ export const ToastCloseFrame = styled(XStack, {
|
|
|
92
92
|
} as const,
|
|
93
93
|
|
|
94
94
|
defaultVariants: {
|
|
95
|
-
unstyled: process.env.
|
|
95
|
+
unstyled: process.env.GUI_HEADLESS === '1',
|
|
96
96
|
},
|
|
97
97
|
})
|
|
98
98
|
|
|
@@ -121,7 +121,7 @@ export const ToastActionFrame = styled(XStack, {
|
|
|
121
121
|
} as const,
|
|
122
122
|
|
|
123
123
|
defaultVariants: {
|
|
124
|
-
unstyled: process.env.
|
|
124
|
+
unstyled: process.env.GUI_HEADLESS === '1',
|
|
125
125
|
},
|
|
126
126
|
})
|
|
127
127
|
|