@tamagui/demos 1.9.0 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ToastDemo.js +74 -33
- package/dist/cjs/ToastDemo.js.map +2 -2
- package/dist/cjs/ToastDuplicateDemo.js +77 -0
- package/dist/cjs/ToastDuplicateDemo.js.map +7 -0
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/ToastDemo.js +85 -35
- package/dist/esm/ToastDemo.js.map +2 -2
- package/dist/esm/ToastDemo.mjs +85 -35
- package/dist/esm/ToastDemo.mjs.map +2 -2
- package/dist/esm/ToastDuplicateDemo.js +43 -0
- package/dist/esm/ToastDuplicateDemo.js.map +7 -0
- package/dist/esm/ToastDuplicateDemo.mjs +43 -0
- package/dist/esm/ToastDuplicateDemo.mjs.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +2 -2
- package/dist/jsx/ToastDemo.js +75 -29
- package/dist/jsx/ToastDemo.js.map +2 -2
- package/dist/jsx/ToastDemo.mjs +75 -29
- package/dist/jsx/ToastDemo.mjs.map +2 -2
- package/dist/jsx/ToastDuplicateDemo.js +34 -0
- package/dist/jsx/ToastDuplicateDemo.js.map +7 -0
- package/dist/jsx/ToastDuplicateDemo.mjs +34 -0
- package/dist/jsx/ToastDuplicateDemo.mjs.map +7 -0
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/index.js.map +2 -2
- package/dist/jsx/index.mjs +2 -0
- package/dist/jsx/index.mjs.map +2 -2
- package/package.json +17 -17
- package/src/ToastDemo.tsx +99 -39
- package/src/ToastDuplicateDemo.tsx +43 -0
- package/src/index.tsx +1 -0
- package/types/ToastDemo.d.ts.map +1 -1
- package/types/ToastDuplicateDemo.d.ts +3 -0
- package/types/ToastDuplicateDemo.d.ts.map +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
package/dist/cjs/ToastDemo.js
CHANGED
|
@@ -36,49 +36,90 @@ var import_lucide_icons = require("@tamagui/lucide-icons");
|
|
|
36
36
|
var import_react = __toESM(require("react"));
|
|
37
37
|
var import_tamagui = require("tamagui");
|
|
38
38
|
const ToastDemo = () => {
|
|
39
|
-
const [
|
|
40
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.YStack, {
|
|
39
|
+
const [native, setNative] = import_react.default.useState([]);
|
|
40
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.YStack, { space: "$5", children: [
|
|
41
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.ToastImperativeProvider, { options: { native }, children: [
|
|
42
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastControl, {}),
|
|
43
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CurrentToast, {})
|
|
44
|
+
] }),
|
|
45
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(NativeOptions, { native, setNative })
|
|
46
|
+
] });
|
|
47
|
+
};
|
|
48
|
+
const CurrentToast = () => {
|
|
49
|
+
const { currentToast } = (0, import_tamagui.useToast)();
|
|
50
|
+
if (!currentToast || currentToast.isHandledNatively)
|
|
51
|
+
return null;
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
53
|
+
import_tamagui.Toast,
|
|
54
|
+
{
|
|
55
|
+
duration: currentToast.duration,
|
|
56
|
+
enterStyle: { opacity: 0, scale: 0.5, y: -25 },
|
|
57
|
+
exitStyle: { opacity: 0, scale: 1, y: -20 },
|
|
58
|
+
y: 0,
|
|
59
|
+
opacity: 1,
|
|
60
|
+
scale: 1,
|
|
61
|
+
animation: "100ms",
|
|
62
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.YStack, { children: [
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Toast.Title, { children: currentToast.title }),
|
|
64
|
+
!!currentToast.message && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Toast.Description, { children: currentToast.message })
|
|
65
|
+
] })
|
|
66
|
+
},
|
|
67
|
+
currentToast.id
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
const ToastControl = () => {
|
|
71
|
+
const toast = (0, import_tamagui.useToast)();
|
|
72
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.XStack, { space: "$2", jc: "center", children: [
|
|
41
73
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
42
74
|
import_tamagui.Button,
|
|
43
75
|
{
|
|
44
76
|
onPress: () => {
|
|
45
|
-
|
|
77
|
+
toast.show("Successfully saved!", {
|
|
78
|
+
message: "Don't worry, we've got your data."
|
|
79
|
+
});
|
|
46
80
|
},
|
|
47
|
-
children: "Show
|
|
81
|
+
children: "Show"
|
|
48
82
|
}
|
|
49
83
|
),
|
|
50
|
-
|
|
51
|
-
import_tamagui.
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
85
|
+
import_tamagui.Button,
|
|
52
86
|
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
animation: "100ms",
|
|
60
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.XStack, { space: true, ai: "center", children: [
|
|
61
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
62
|
-
import_tamagui.YStack,
|
|
63
|
-
{
|
|
64
|
-
animation: "quick",
|
|
65
|
-
enterStyle: { scale: 0, rotate: "-100deg", x: 10 },
|
|
66
|
-
x: 0,
|
|
67
|
-
scale: 1,
|
|
68
|
-
rotate: "0deg",
|
|
69
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_icons.CheckCircle2, {})
|
|
70
|
-
}
|
|
71
|
-
),
|
|
72
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.YStack, { children: [
|
|
73
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Toast.Title, { enterStyle: { x: 40 }, x: 0, animation: "quick", children: "Successfully saved!" }),
|
|
74
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Toast.Description, { enterStyle: { x: 20 }, x: 0, animation: "quick", children: "Don't worry... We've got your data." })
|
|
75
|
-
] })
|
|
76
|
-
] })
|
|
77
|
-
},
|
|
78
|
-
index
|
|
79
|
-
))
|
|
87
|
+
onPress: () => {
|
|
88
|
+
toast.hide();
|
|
89
|
+
},
|
|
90
|
+
children: "Hide"
|
|
91
|
+
}
|
|
92
|
+
)
|
|
80
93
|
] });
|
|
81
94
|
};
|
|
95
|
+
const NativeOptions = ({
|
|
96
|
+
native,
|
|
97
|
+
setNative
|
|
98
|
+
}) => {
|
|
99
|
+
const supportedNativePlatforms = ["web", "mobile"];
|
|
100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.XStack, { space: true, children: supportedNativePlatforms.map((platform) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.XStack, { ai: "center", space: "$2", children: [
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
102
|
+
import_tamagui.Checkbox,
|
|
103
|
+
{
|
|
104
|
+
id: platform,
|
|
105
|
+
checked: native == null ? void 0 : native.includes(platform),
|
|
106
|
+
onCheckedChange: (checked) => {
|
|
107
|
+
if (checked)
|
|
108
|
+
setNative([...native, platform]);
|
|
109
|
+
else
|
|
110
|
+
setNative(native.filter((val) => val !== platform));
|
|
111
|
+
},
|
|
112
|
+
size: "$3",
|
|
113
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Checkbox.Indicator, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_icons.Check, {}) })
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.Label, { size: "$3", htmlFor: platform, children: [
|
|
117
|
+
"Native ",
|
|
118
|
+
platform,
|
|
119
|
+
" toast"
|
|
120
|
+
] })
|
|
121
|
+
] }, platform)) });
|
|
122
|
+
};
|
|
82
123
|
// Annotate the CommonJS export names for ESM import in node:
|
|
83
124
|
0 && (module.exports = {
|
|
84
125
|
ToastDemo
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ToastDemo.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { Check } from '@tamagui/lucide-icons'\nimport React from 'react'\nimport {\n Button,\n Checkbox,\n Label,\n Toast,\n ToastImperativeProvider,\n ToastNativePlatform,\n XStack,\n YStack,\n useToast,\n} from 'tamagui'\n\nexport const ToastDemo = () => {\n const [native, setNative] = React.useState<ToastNativePlatform[]>([])\n\n return (\n <YStack space=\"$5\">\n <ToastImperativeProvider options={{ native }}>\n <ToastControl />\n <CurrentToast />\n </ToastImperativeProvider>\n\n <NativeOptions native={native} setNative={setNative} />\n </YStack>\n )\n}\n\nconst CurrentToast = () => {\n const { currentToast } = useToast()\n\n if (!currentToast || currentToast.isHandledNatively) return null\n return (\n <Toast\n key={currentToast.id}\n duration={currentToast.duration}\n enterStyle={{ opacity: 0, scale: 0.5, y: -25 }}\n exitStyle={{ opacity: 0, scale: 1, y: -20 }}\n y={0}\n opacity={1}\n scale={1}\n animation=\"100ms\"\n >\n <YStack>\n <Toast.Title>{currentToast.title}</Toast.Title>\n {!!currentToast.message && (\n <Toast.Description>{currentToast.message}</Toast.Description>\n )}\n </YStack>\n </Toast>\n )\n}\n\nconst ToastControl = () => {\n const toast = useToast()\n return (\n <XStack space=\"$2\" jc=\"center\">\n <Button\n onPress={() => {\n toast.show('Successfully saved!', {\n message: \"Don't worry, we've got your data.\",\n })\n }}\n >\n Show\n </Button>\n <Button\n onPress={() => {\n toast.hide()\n }}\n >\n Hide\n </Button>\n </XStack>\n )\n}\n\nconst NativeOptions = ({\n native,\n setNative,\n}: {\n native: ToastNativePlatform[]\n setNative: (native: ToastNativePlatform[]) => void\n}) => {\n const supportedNativePlatforms: ToastNativePlatform[] = ['web', 'mobile']\n\n return (\n <XStack space>\n {supportedNativePlatforms.map((platform) => (\n <XStack ai=\"center\" space=\"$2\" key={platform}>\n <Checkbox\n id={platform}\n checked={native?.includes(platform)}\n onCheckedChange={(checked) => {\n if (checked) setNative([...native, platform])\n else setNative(native.filter((val) => val !== platform))\n }}\n size=\"$3\"\n >\n <Checkbox.Indicator>\n <Check />\n </Checkbox.Indicator>\n </Checkbox>\n <Label size=\"$3\" htmlFor={platform}>\n Native {platform} toast\n </Label>\n </XStack>\n ))}\n </XStack>\n )\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBM;AAnBN,0BAAsB;AACtB,mBAAkB;AAClB,qBAUO;AAEA,MAAM,YAAY,MAAM;AAC7B,QAAM,CAAC,QAAQ,SAAS,IAAI,aAAAA,QAAM,SAAgC,CAAC,CAAC;AAEpE,SACE,6CAAC,yBAAO,OAAM,MACZ;AAAA,iDAAC,0CAAwB,SAAS,EAAE,OAAO,GACzC;AAAA,kDAAC,gBAAa;AAAA,MACd,4CAAC,gBAAa;AAAA,OAChB;AAAA,IAEA,4CAAC,iBAAc,QAAgB,WAAsB;AAAA,KACvD;AAEJ;AAEA,MAAM,eAAe,MAAM;AACzB,QAAM,EAAE,aAAa,QAAI,yBAAS;AAElC,MAAI,CAAC,gBAAgB,aAAa;AAAmB,WAAO;AAC5D,SACE;AAAA,IAAC;AAAA;A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ACzD;AAAA,QACA,MAAK;AAAA,QAEL,sDAAC,wBAAS,WAAT,EACC,sDAAC,6BAAM,GACT;AAAA;AAAA,IACF;AAAA,IACA,6CAAC,wBAAM,MAAK,MAAK,SAAS,UAAU;AAAA;AAAA,MAC1B;AAAA,MAAS;AAAA,OACnB;AAAA,OAhBkC,QAiBpC,CACD,GACH;AAEJ;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var ToastDuplicateDemo_exports = {};
|
|
30
|
+
__export(ToastDuplicateDemo_exports, {
|
|
31
|
+
ToastDuplicateDemo: () => ToastDuplicateDemo
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(ToastDuplicateDemo_exports);
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_lucide_icons = require("@tamagui/lucide-icons");
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_tamagui = require("tamagui");
|
|
38
|
+
const ToastDuplicateDemo = () => {
|
|
39
|
+
const [savedCount, setSavedCount] = import_react.default.useState(0);
|
|
40
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.YStack, { ai: "center", children: [
|
|
41
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
42
|
+
import_tamagui.Button,
|
|
43
|
+
{
|
|
44
|
+
onPress: () => {
|
|
45
|
+
setSavedCount((old) => old + 1);
|
|
46
|
+
},
|
|
47
|
+
children: "Show toast"
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
[...Array(savedCount)].map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
51
|
+
import_tamagui.Toast,
|
|
52
|
+
{
|
|
53
|
+
viewportName: "viewport-multiple",
|
|
54
|
+
duration: 4e3,
|
|
55
|
+
enterStyle: { opacity: 0, scale: 0.5, y: -25 },
|
|
56
|
+
exitStyle: { opacity: 0, scale: 1, y: -20 },
|
|
57
|
+
y: 0,
|
|
58
|
+
opacity: 1,
|
|
59
|
+
scale: 1,
|
|
60
|
+
animation: "100ms",
|
|
61
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.XStack, { space: true, ai: "center", children: [
|
|
62
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_icons.CheckCircle2, {}) }),
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.YStack, { children: [
|
|
64
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Toast.Title, { children: "Successfully saved!" }),
|
|
65
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Toast.Description, { children: "Don't worry... We've got your data." })
|
|
66
|
+
] })
|
|
67
|
+
] })
|
|
68
|
+
},
|
|
69
|
+
index
|
|
70
|
+
))
|
|
71
|
+
] });
|
|
72
|
+
};
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
ToastDuplicateDemo
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=ToastDuplicateDemo.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ToastDuplicateDemo.tsx"],
|
|
4
|
+
"sourcesContent": ["import { CheckCircle2 } from '@tamagui/lucide-icons'\nimport React from 'react'\nimport { Button, Toast, XStack, YStack } from 'tamagui'\n\nexport const ToastDuplicateDemo = () => {\n const [savedCount, setSavedCount] = React.useState(0)\n\n return (\n <YStack ai=\"center\">\n <Button\n onPress={() => {\n setSavedCount((old) => old + 1)\n }}\n >\n Show toast\n </Button>\n {[...Array(savedCount)].map((_, index) => (\n <Toast\n viewportName=\"viewport-multiple\" // Sends to a viewport that supports multiple toasts with the `multipleToasts` prop\n key={index}\n duration={4000}\n enterStyle={{ opacity: 0, scale: 0.5, y: -25 }}\n exitStyle={{ opacity: 0, scale: 1, y: -20 }}\n y={0}\n opacity={1}\n scale={1}\n animation=\"100ms\"\n >\n <XStack space ai=\"center\">\n <YStack>\n <CheckCircle2 />\n </YStack>\n\n <YStack>\n <Toast.Title>Successfully saved!</Toast.Title>\n <Toast.Description>Don't worry... We've got your data.</Toast.Description>\n </YStack>\n </XStack>\n </Toast>\n ))}\n </YStack>\n )\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASM;AATN,0BAA6B;AAC7B,mBAAkB;AAClB,qBAA8C;AAEvC,MAAM,qBAAqB,MAAM;AACtC,QAAM,CAAC,YAAY,aAAa,IAAI,aAAAA,QAAM,SAAS,CAAC;AAEpD,SACE,6CAAC,yBAAO,IAAG,UACT;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,SAAS,MAAM;AACb,wBAAc,CAAC,QAAQ,MAAM,CAAC;AAAA,QAChC;AAAA,QACD;AAAA;AAAA,IAED;AAAA,IACC,CAAC,GAAG,MAAM,UAAU,CAAC,EAAE,IAAI,CAAC,GAAG,UAC9B;AAAA,MAAC;AAAA;AAAA,QACC,cAAa;AAAA,QAEb,UAAU;AAAA,QACV,YAAY,EAAE,SAAS,GAAG,OAAO,KAAK,GAAG,IAAI;AAAA,QAC7C,WAAW,EAAE,SAAS,GAAG,OAAO,GAAG,GAAG,IAAI;AAAA,QAC1C,GAAG;AAAA,QACH,SAAS;AAAA,QACT,OAAO;AAAA,QACP,WAAU;AAAA,QAEV,uDAAC,yBAAO,OAAK,MAAC,IAAG,UACf;AAAA,sDAAC,yBACC,sDAAC,oCAAa,GAChB;AAAA,UAEA,6CAAC,yBACC;AAAA,wDAAC,qBAAM,OAAN,EAAY,iCAAmB;AAAA,YAChC,4CAAC,qBAAM,aAAN,EAAkB,iDAAmC;AAAA,aACxD;AAAA,WACF;AAAA;AAAA,MAlBK;AAAA,IAmBP,CACD;AAAA,KACH;AAEJ;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -58,6 +58,7 @@ __export(src_exports, {
|
|
|
58
58
|
TextDemo: () => import_TextDemo.TextDemo,
|
|
59
59
|
ThemeInverseDemo: () => import_ThemeInverseDemo.ThemeInverseDemo,
|
|
60
60
|
ToastDemo: () => import_ToastDemo.ToastDemo,
|
|
61
|
+
ToastDuplicateDemo: () => import_ToastDuplicateDemo.ToastDuplicateDemo,
|
|
61
62
|
TokensDemo: () => import_TokensDemo.TokensDemo,
|
|
62
63
|
TooltipDemo: () => import_TooltipDemo.TooltipDemo,
|
|
63
64
|
UpdateThemeDemo: () => import_UpdateThemeDemo.UpdateThemeDemo
|
|
@@ -103,6 +104,7 @@ var import_TooltipDemo = require("./TooltipDemo");
|
|
|
103
104
|
var import_ColorsDemo = require("./ColorsDemo");
|
|
104
105
|
var import_TokensDemo = require("./TokensDemo");
|
|
105
106
|
var import_ToastDemo = require("./ToastDemo");
|
|
107
|
+
var import_ToastDuplicateDemo = require("./ToastDuplicateDemo");
|
|
106
108
|
var import_TabsDemo = require("./TabsDemo");
|
|
107
109
|
var import_TabsAdvancedDemo = require("./TabsAdvancedDemo");
|
|
108
110
|
__reExport(src_exports, require("./useOnIntersecting"), module.exports);
|
|
@@ -147,6 +149,7 @@ __reExport(src_exports, require("./useOnIntersecting"), module.exports);
|
|
|
147
149
|
TextDemo,
|
|
148
150
|
ThemeInverseDemo,
|
|
149
151
|
ToastDemo,
|
|
152
|
+
ToastDuplicateDemo,
|
|
150
153
|
TokensDemo,
|
|
151
154
|
TooltipDemo,
|
|
152
155
|
UpdateThemeDemo
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["export { AlertDialogDemo } from './AlertDialogDemo'\nexport { AnimationsDemo } from './AnimationsDemo'\nexport { AnimationsEnterDemo } from './AnimationsEnterDemo'\nexport { AnimationsHoverDemo } from './AnimationsHoverDemo'\nexport { AnimationsTimingDemo } from './AnimationsTimingDemo'\nexport { AnimationsPresenceDemo } from './AnimationsPresenceDemo'\nexport { AvatarDemo } from './AvatarDemo'\nexport { ButtonDemo } from './ButtonDemo'\nexport { CardDemo } from './CardDemo'\nexport { DialogDemo } from './DialogDemo'\nexport { AddThemeDemo } from './AddThemeDemo'\nexport { UpdateThemeDemo } from './UpdateThemeDemo'\nexport { FormsDemo } from './FormsDemo'\nexport { InputsDemo } from './InputsDemo'\nexport { GroupDemo } from './GroupDemo'\nexport { HeadingsDemo } from './HeadingsDemo'\nexport { ImageDemo } from './ImageDemo'\nexport { LabelDemo } from './LabelDemo'\nexport { LinearGradientDemo } from './LinearGradientDemo'\nexport { ListItemDemo } from './ListItemDemo'\nexport { LucideIconsDemo } from './LucideIconsDemo'\nexport { PopoverDemo } from './PopoverDemo'\nexport { ProgressDemo } from './ProgressDemo'\nexport { RadioGroupDemo } from './RadioGroupDemo'\nexport { SelectDemo } from './SelectDemo'\nexport { SeparatorDemo } from './SeparatorDemo'\nexport { ShapesDemo } from './ShapesDemo'\nexport { ScrollViewDemo } from './ScrollViewDemo'\nexport { SheetDemo } from './SheetDemo'\nexport { SliderDemo } from './SliderDemo'\nexport { SpinnerDemo } from './SpinnerDemo'\nexport { StacksDemo } from './StacksDemo'\nexport { SwitchDemo } from './SwitchDemo'\nexport { CheckboxDemo } from './CheckboxDemo'\nexport { TextDemo } from './TextDemo'\nexport { ThemeInverseDemo } from './ThemeInverseDemo'\nexport { TooltipDemo } from './TooltipDemo'\nexport { ColorsDemo } from './ColorsDemo'\nexport { TokensDemo } from './TokensDemo'\nexport { ToastDemo } from './ToastDemo'\nexport { TabsDemo } from './TabsDemo'\nexport { TabsAdvancedDemo } from './TabsAdvancedDemo'\nexport * from './useOnIntersecting'\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAgC;AAChC,4BAA+B;AAC/B,iCAAoC;AACpC,iCAAoC;AACpC,kCAAqC;AACrC,oCAAuC;AACvC,wBAA2B;AAC3B,wBAA2B;AAC3B,sBAAyB;AACzB,wBAA2B;AAC3B,0BAA6B;AAC7B,6BAAgC;AAChC,uBAA0B;AAC1B,wBAA2B;AAC3B,uBAA0B;AAC1B,0BAA6B;AAC7B,uBAA0B;AAC1B,uBAA0B;AAC1B,gCAAmC;AACnC,0BAA6B;AAC7B,6BAAgC;AAChC,yBAA4B;AAC5B,0BAA6B;AAC7B,4BAA+B;AAC/B,wBAA2B;AAC3B,2BAA8B;AAC9B,wBAA2B;AAC3B,4BAA+B;AAC/B,uBAA0B;AAC1B,wBAA2B;AAC3B,yBAA4B;AAC5B,wBAA2B;AAC3B,wBAA2B;AAC3B,0BAA6B;AAC7B,sBAAyB;AACzB,8BAAiC;AACjC,yBAA4B;AAC5B,wBAA2B;AAC3B,wBAA2B;AAC3B,uBAA0B;AAC1B,sBAAyB;AACzB,8BAAiC;AACjC,wBAAc,
|
|
4
|
+
"sourcesContent": ["export { AlertDialogDemo } from './AlertDialogDemo'\nexport { AnimationsDemo } from './AnimationsDemo'\nexport { AnimationsEnterDemo } from './AnimationsEnterDemo'\nexport { AnimationsHoverDemo } from './AnimationsHoverDemo'\nexport { AnimationsTimingDemo } from './AnimationsTimingDemo'\nexport { AnimationsPresenceDemo } from './AnimationsPresenceDemo'\nexport { AvatarDemo } from './AvatarDemo'\nexport { ButtonDemo } from './ButtonDemo'\nexport { CardDemo } from './CardDemo'\nexport { DialogDemo } from './DialogDemo'\nexport { AddThemeDemo } from './AddThemeDemo'\nexport { UpdateThemeDemo } from './UpdateThemeDemo'\nexport { FormsDemo } from './FormsDemo'\nexport { InputsDemo } from './InputsDemo'\nexport { GroupDemo } from './GroupDemo'\nexport { HeadingsDemo } from './HeadingsDemo'\nexport { ImageDemo } from './ImageDemo'\nexport { LabelDemo } from './LabelDemo'\nexport { LinearGradientDemo } from './LinearGradientDemo'\nexport { ListItemDemo } from './ListItemDemo'\nexport { LucideIconsDemo } from './LucideIconsDemo'\nexport { PopoverDemo } from './PopoverDemo'\nexport { ProgressDemo } from './ProgressDemo'\nexport { RadioGroupDemo } from './RadioGroupDemo'\nexport { SelectDemo } from './SelectDemo'\nexport { SeparatorDemo } from './SeparatorDemo'\nexport { ShapesDemo } from './ShapesDemo'\nexport { ScrollViewDemo } from './ScrollViewDemo'\nexport { SheetDemo } from './SheetDemo'\nexport { SliderDemo } from './SliderDemo'\nexport { SpinnerDemo } from './SpinnerDemo'\nexport { StacksDemo } from './StacksDemo'\nexport { SwitchDemo } from './SwitchDemo'\nexport { CheckboxDemo } from './CheckboxDemo'\nexport { TextDemo } from './TextDemo'\nexport { ThemeInverseDemo } from './ThemeInverseDemo'\nexport { TooltipDemo } from './TooltipDemo'\nexport { ColorsDemo } from './ColorsDemo'\nexport { TokensDemo } from './TokensDemo'\nexport { ToastDemo } from './ToastDemo'\nexport { ToastDuplicateDemo } from './ToastDuplicateDemo'\nexport { TabsDemo } from './TabsDemo'\nexport { TabsAdvancedDemo } from './TabsAdvancedDemo'\nexport * from './useOnIntersecting'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAgC;AAChC,4BAA+B;AAC/B,iCAAoC;AACpC,iCAAoC;AACpC,kCAAqC;AACrC,oCAAuC;AACvC,wBAA2B;AAC3B,wBAA2B;AAC3B,sBAAyB;AACzB,wBAA2B;AAC3B,0BAA6B;AAC7B,6BAAgC;AAChC,uBAA0B;AAC1B,wBAA2B;AAC3B,uBAA0B;AAC1B,0BAA6B;AAC7B,uBAA0B;AAC1B,uBAA0B;AAC1B,gCAAmC;AACnC,0BAA6B;AAC7B,6BAAgC;AAChC,yBAA4B;AAC5B,0BAA6B;AAC7B,4BAA+B;AAC/B,wBAA2B;AAC3B,2BAA8B;AAC9B,wBAA2B;AAC3B,4BAA+B;AAC/B,uBAA0B;AAC1B,wBAA2B;AAC3B,yBAA4B;AAC5B,wBAA2B;AAC3B,wBAA2B;AAC3B,0BAA6B;AAC7B,sBAAyB;AACzB,8BAAiC;AACjC,yBAA4B;AAC5B,wBAA2B;AAC3B,wBAA2B;AAC3B,uBAA0B;AAC1B,gCAAmC;AACnC,sBAAyB;AACzB,8BAAiC;AACjC,wBAAc,gCA3Cd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/ToastDemo.js
CHANGED
|
@@ -1,51 +1,101 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Check } from "@tamagui/lucide-icons";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
Checkbox,
|
|
7
|
+
Label,
|
|
8
|
+
Toast,
|
|
9
|
+
ToastImperativeProvider,
|
|
10
|
+
XStack,
|
|
11
|
+
YStack,
|
|
12
|
+
useToast
|
|
13
|
+
} from "tamagui";
|
|
5
14
|
const ToastDemo = () => {
|
|
6
|
-
const [
|
|
7
|
-
return /* @__PURE__ */ jsxs(YStack, {
|
|
15
|
+
const [native, setNative] = React.useState([]);
|
|
16
|
+
return /* @__PURE__ */ jsxs(YStack, { space: "$5", children: [
|
|
17
|
+
/* @__PURE__ */ jsxs(ToastImperativeProvider, { options: { native }, children: [
|
|
18
|
+
/* @__PURE__ */ jsx(ToastControl, {}),
|
|
19
|
+
/* @__PURE__ */ jsx(CurrentToast, {})
|
|
20
|
+
] }),
|
|
21
|
+
/* @__PURE__ */ jsx(NativeOptions, { native, setNative })
|
|
22
|
+
] });
|
|
23
|
+
};
|
|
24
|
+
const CurrentToast = () => {
|
|
25
|
+
const { currentToast } = useToast();
|
|
26
|
+
if (!currentToast || currentToast.isHandledNatively)
|
|
27
|
+
return null;
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
Toast,
|
|
30
|
+
{
|
|
31
|
+
duration: currentToast.duration,
|
|
32
|
+
enterStyle: { opacity: 0, scale: 0.5, y: -25 },
|
|
33
|
+
exitStyle: { opacity: 0, scale: 1, y: -20 },
|
|
34
|
+
y: 0,
|
|
35
|
+
opacity: 1,
|
|
36
|
+
scale: 1,
|
|
37
|
+
animation: "100ms",
|
|
38
|
+
children: /* @__PURE__ */ jsxs(YStack, { children: [
|
|
39
|
+
/* @__PURE__ */ jsx(Toast.Title, { children: currentToast.title }),
|
|
40
|
+
!!currentToast.message && /* @__PURE__ */ jsx(Toast.Description, { children: currentToast.message })
|
|
41
|
+
] })
|
|
42
|
+
},
|
|
43
|
+
currentToast.id
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
const ToastControl = () => {
|
|
47
|
+
const toast = useToast();
|
|
48
|
+
return /* @__PURE__ */ jsxs(XStack, { space: "$2", jc: "center", children: [
|
|
8
49
|
/* @__PURE__ */ jsx(
|
|
9
50
|
Button,
|
|
10
51
|
{
|
|
11
52
|
onPress: () => {
|
|
12
|
-
|
|
53
|
+
toast.show("Successfully saved!", {
|
|
54
|
+
message: "Don't worry, we've got your data."
|
|
55
|
+
});
|
|
13
56
|
},
|
|
14
|
-
children: "Show
|
|
57
|
+
children: "Show"
|
|
15
58
|
}
|
|
16
59
|
),
|
|
17
|
-
|
|
18
|
-
|
|
60
|
+
/* @__PURE__ */ jsx(
|
|
61
|
+
Button,
|
|
19
62
|
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
animation: "100ms",
|
|
27
|
-
children: /* @__PURE__ */ jsxs(XStack, { space: true, ai: "center", children: [
|
|
28
|
-
/* @__PURE__ */ jsx(
|
|
29
|
-
YStack,
|
|
30
|
-
{
|
|
31
|
-
animation: "quick",
|
|
32
|
-
enterStyle: { scale: 0, rotate: "-100deg", x: 10 },
|
|
33
|
-
x: 0,
|
|
34
|
-
scale: 1,
|
|
35
|
-
rotate: "0deg",
|
|
36
|
-
children: /* @__PURE__ */ jsx(CheckCircle2, {})
|
|
37
|
-
}
|
|
38
|
-
),
|
|
39
|
-
/* @__PURE__ */ jsxs(YStack, { children: [
|
|
40
|
-
/* @__PURE__ */ jsx(Toast.Title, { enterStyle: { x: 40 }, x: 0, animation: "quick", children: "Successfully saved!" }),
|
|
41
|
-
/* @__PURE__ */ jsx(Toast.Description, { enterStyle: { x: 20 }, x: 0, animation: "quick", children: "Don't worry... We've got your data." })
|
|
42
|
-
] })
|
|
43
|
-
] })
|
|
44
|
-
},
|
|
45
|
-
index
|
|
46
|
-
))
|
|
63
|
+
onPress: () => {
|
|
64
|
+
toast.hide();
|
|
65
|
+
},
|
|
66
|
+
children: "Hide"
|
|
67
|
+
}
|
|
68
|
+
)
|
|
47
69
|
] });
|
|
48
70
|
};
|
|
71
|
+
const NativeOptions = ({
|
|
72
|
+
native,
|
|
73
|
+
setNative
|
|
74
|
+
}) => {
|
|
75
|
+
const supportedNativePlatforms = ["web", "mobile"];
|
|
76
|
+
return /* @__PURE__ */ jsx(XStack, { space: true, children: supportedNativePlatforms.map((platform) => /* @__PURE__ */ jsxs(XStack, { ai: "center", space: "$2", children: [
|
|
77
|
+
/* @__PURE__ */ jsx(
|
|
78
|
+
Checkbox,
|
|
79
|
+
{
|
|
80
|
+
id: platform,
|
|
81
|
+
checked: native == null ? void 0 : native.includes(platform),
|
|
82
|
+
onCheckedChange: (checked) => {
|
|
83
|
+
if (checked)
|
|
84
|
+
setNative([...native, platform]);
|
|
85
|
+
else
|
|
86
|
+
setNative(native.filter((val) => val !== platform));
|
|
87
|
+
},
|
|
88
|
+
size: "$3",
|
|
89
|
+
children: /* @__PURE__ */ jsx(Checkbox.Indicator, { children: /* @__PURE__ */ jsx(Check, {}) })
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ jsxs(Label, { size: "$3", htmlFor: platform, children: [
|
|
93
|
+
"Native ",
|
|
94
|
+
platform,
|
|
95
|
+
" toast"
|
|
96
|
+
] })
|
|
97
|
+
] }, platform)) });
|
|
98
|
+
};
|
|
49
99
|
export {
|
|
50
100
|
ToastDemo
|
|
51
101
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ToastDemo.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { Check } from '@tamagui/lucide-icons'\nimport React from 'react'\nimport {\n Button,\n Checkbox,\n Label,\n Toast,\n ToastImperativeProvider,\n ToastNativePlatform,\n XStack,\n YStack,\n useToast,\n} from 'tamagui'\n\nexport const ToastDemo = () => {\n const [native, setNative] = React.useState<ToastNativePlatform[]>([])\n\n return (\n <YStack space=\"$5\">\n <ToastImperativeProvider options={{ native }}>\n <ToastControl />\n <CurrentToast />\n </ToastImperativeProvider>\n\n <NativeOptions native={native} setNative={setNative} />\n </YStack>\n )\n}\n\nconst CurrentToast = () => {\n const { currentToast } = useToast()\n\n if (!currentToast || currentToast.isHandledNatively) return null\n return (\n <Toast\n key={currentToast.id}\n duration={currentToast.duration}\n enterStyle={{ opacity: 0, scale: 0.5, y: -25 }}\n exitStyle={{ opacity: 0, scale: 1, y: -20 }}\n y={0}\n opacity={1}\n scale={1}\n animation=\"100ms\"\n >\n <YStack>\n <Toast.Title>{currentToast.title}</Toast.Title>\n {!!currentToast.message && (\n <Toast.Description>{currentToast.message}</Toast.Description>\n )}\n </YStack>\n </Toast>\n )\n}\n\nconst ToastControl = () => {\n const toast = useToast()\n return (\n <XStack space=\"$2\" jc=\"center\">\n <Button\n onPress={() => {\n toast.show('Successfully saved!', {\n message: \"Don't worry, we've got your data.\",\n })\n }}\n >\n Show\n </Button>\n <Button\n onPress={() => {\n toast.hide()\n }}\n >\n Hide\n </Button>\n </XStack>\n )\n}\n\nconst NativeOptions = ({\n native,\n setNative,\n}: {\n native: ToastNativePlatform[]\n setNative: (native: ToastNativePlatform[]) => void\n}) => {\n const supportedNativePlatforms: ToastNativePlatform[] = ['web', 'mobile']\n\n return (\n <XStack space>\n {supportedNativePlatforms.map((platform) => (\n <XStack ai=\"center\" space=\"$2\" key={platform}>\n <Checkbox\n id={platform}\n checked={native?.includes(platform)}\n onCheckedChange={(checked) => {\n if (checked) setNative([...native, platform])\n else setNative(native.filter((val) => val !== platform))\n }}\n size=\"$3\"\n >\n <Checkbox.Indicator>\n <Check />\n </Checkbox.Indicator>\n </Checkbox>\n <Label size=\"$3\" htmlFor={platform}>\n Native {platform} toast\n </Label>\n </XStack>\n ))}\n </XStack>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAmBM,SACE,KADF;AAnBN,SAAS,aAAa;AACtB,OAAO,WAAW;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,YAAY,MAAM;AAC7B,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAgC,CAAC,CAAC;AAEpE,SACE,qBAAC,UAAO,OAAM,MACZ;AAAA,yBAAC,2BAAwB,SAAS,EAAE,OAAO,GACzC;AAAA,0BAAC,gBAAa;AAAA,MACd,oBAAC,gBAAa;AAAA,OAChB;AAAA,IAEA,oBAAC,iBAAc,QAAgB,WAAsB;AAAA,KACv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,YAAY;AAC5B,cAAI;AAAS,sBAAU,CAAC,GAAG,QAAQ,QAAQ,CAAC;AAAA;AACvC,sBAAU,OAAO,OAAO,CAAC,QAAQ,QAAQ,QAAQ,CAAC;AAAA,QACzD;AAAA,QACA,MAAK;AAAA,QAEL,8BAAC,SAAS,WAAT,EACC,8BAAC,SAAM,GACT;AAAA;AAAA,IACF;AAAA,IACA,qBAAC,SAAM,MAAK,MAAK,SAAS,UAAU;AAAA;AAAA,MAC1B;AAAA,MAAS;AAAA,OACnB;AAAA,OAhBkC,QAiBpC,CACD,GACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/ToastDemo.mjs
CHANGED
|
@@ -1,51 +1,101 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Check } from "@tamagui/lucide-icons";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
Checkbox,
|
|
7
|
+
Label,
|
|
8
|
+
Toast,
|
|
9
|
+
ToastImperativeProvider,
|
|
10
|
+
XStack,
|
|
11
|
+
YStack,
|
|
12
|
+
useToast
|
|
13
|
+
} from "tamagui";
|
|
5
14
|
const ToastDemo = () => {
|
|
6
|
-
const [
|
|
7
|
-
return /* @__PURE__ */ jsxs(YStack, {
|
|
15
|
+
const [native, setNative] = React.useState([]);
|
|
16
|
+
return /* @__PURE__ */ jsxs(YStack, { space: "$5", children: [
|
|
17
|
+
/* @__PURE__ */ jsxs(ToastImperativeProvider, { options: { native }, children: [
|
|
18
|
+
/* @__PURE__ */ jsx(ToastControl, {}),
|
|
19
|
+
/* @__PURE__ */ jsx(CurrentToast, {})
|
|
20
|
+
] }),
|
|
21
|
+
/* @__PURE__ */ jsx(NativeOptions, { native, setNative })
|
|
22
|
+
] });
|
|
23
|
+
};
|
|
24
|
+
const CurrentToast = () => {
|
|
25
|
+
const { currentToast } = useToast();
|
|
26
|
+
if (!currentToast || currentToast.isHandledNatively)
|
|
27
|
+
return null;
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
Toast,
|
|
30
|
+
{
|
|
31
|
+
duration: currentToast.duration,
|
|
32
|
+
enterStyle: { opacity: 0, scale: 0.5, y: -25 },
|
|
33
|
+
exitStyle: { opacity: 0, scale: 1, y: -20 },
|
|
34
|
+
y: 0,
|
|
35
|
+
opacity: 1,
|
|
36
|
+
scale: 1,
|
|
37
|
+
animation: "100ms",
|
|
38
|
+
children: /* @__PURE__ */ jsxs(YStack, { children: [
|
|
39
|
+
/* @__PURE__ */ jsx(Toast.Title, { children: currentToast.title }),
|
|
40
|
+
!!currentToast.message && /* @__PURE__ */ jsx(Toast.Description, { children: currentToast.message })
|
|
41
|
+
] })
|
|
42
|
+
},
|
|
43
|
+
currentToast.id
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
const ToastControl = () => {
|
|
47
|
+
const toast = useToast();
|
|
48
|
+
return /* @__PURE__ */ jsxs(XStack, { space: "$2", jc: "center", children: [
|
|
8
49
|
/* @__PURE__ */ jsx(
|
|
9
50
|
Button,
|
|
10
51
|
{
|
|
11
52
|
onPress: () => {
|
|
12
|
-
|
|
53
|
+
toast.show("Successfully saved!", {
|
|
54
|
+
message: "Don't worry, we've got your data."
|
|
55
|
+
});
|
|
13
56
|
},
|
|
14
|
-
children: "Show
|
|
57
|
+
children: "Show"
|
|
15
58
|
}
|
|
16
59
|
),
|
|
17
|
-
|
|
18
|
-
|
|
60
|
+
/* @__PURE__ */ jsx(
|
|
61
|
+
Button,
|
|
19
62
|
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
animation: "100ms",
|
|
27
|
-
children: /* @__PURE__ */ jsxs(XStack, { space: true, ai: "center", children: [
|
|
28
|
-
/* @__PURE__ */ jsx(
|
|
29
|
-
YStack,
|
|
30
|
-
{
|
|
31
|
-
animation: "quick",
|
|
32
|
-
enterStyle: { scale: 0, rotate: "-100deg", x: 10 },
|
|
33
|
-
x: 0,
|
|
34
|
-
scale: 1,
|
|
35
|
-
rotate: "0deg",
|
|
36
|
-
children: /* @__PURE__ */ jsx(CheckCircle2, {})
|
|
37
|
-
}
|
|
38
|
-
),
|
|
39
|
-
/* @__PURE__ */ jsxs(YStack, { children: [
|
|
40
|
-
/* @__PURE__ */ jsx(Toast.Title, { enterStyle: { x: 40 }, x: 0, animation: "quick", children: "Successfully saved!" }),
|
|
41
|
-
/* @__PURE__ */ jsx(Toast.Description, { enterStyle: { x: 20 }, x: 0, animation: "quick", children: "Don't worry... We've got your data." })
|
|
42
|
-
] })
|
|
43
|
-
] })
|
|
44
|
-
},
|
|
45
|
-
index
|
|
46
|
-
))
|
|
63
|
+
onPress: () => {
|
|
64
|
+
toast.hide();
|
|
65
|
+
},
|
|
66
|
+
children: "Hide"
|
|
67
|
+
}
|
|
68
|
+
)
|
|
47
69
|
] });
|
|
48
70
|
};
|
|
71
|
+
const NativeOptions = ({
|
|
72
|
+
native,
|
|
73
|
+
setNative
|
|
74
|
+
}) => {
|
|
75
|
+
const supportedNativePlatforms = ["web", "mobile"];
|
|
76
|
+
return /* @__PURE__ */ jsx(XStack, { space: true, children: supportedNativePlatforms.map((platform) => /* @__PURE__ */ jsxs(XStack, { ai: "center", space: "$2", children: [
|
|
77
|
+
/* @__PURE__ */ jsx(
|
|
78
|
+
Checkbox,
|
|
79
|
+
{
|
|
80
|
+
id: platform,
|
|
81
|
+
checked: native == null ? void 0 : native.includes(platform),
|
|
82
|
+
onCheckedChange: (checked) => {
|
|
83
|
+
if (checked)
|
|
84
|
+
setNative([...native, platform]);
|
|
85
|
+
else
|
|
86
|
+
setNative(native.filter((val) => val !== platform));
|
|
87
|
+
},
|
|
88
|
+
size: "$3",
|
|
89
|
+
children: /* @__PURE__ */ jsx(Checkbox.Indicator, { children: /* @__PURE__ */ jsx(Check, {}) })
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ jsxs(Label, { size: "$3", htmlFor: platform, children: [
|
|
93
|
+
"Native ",
|
|
94
|
+
platform,
|
|
95
|
+
" toast"
|
|
96
|
+
] })
|
|
97
|
+
] }, platform)) });
|
|
98
|
+
};
|
|
49
99
|
export {
|
|
50
100
|
ToastDemo
|
|
51
101
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ToastDemo.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { Check } from '@tamagui/lucide-icons'\nimport React from 'react'\nimport {\n Button,\n Checkbox,\n Label,\n Toast,\n ToastImperativeProvider,\n ToastNativePlatform,\n XStack,\n YStack,\n useToast,\n} from 'tamagui'\n\nexport const ToastDemo = () => {\n const [native, setNative] = React.useState<ToastNativePlatform[]>([])\n\n return (\n <YStack space=\"$5\">\n <ToastImperativeProvider options={{ native }}>\n <ToastControl />\n <CurrentToast />\n </ToastImperativeProvider>\n\n <NativeOptions native={native} setNative={setNative} />\n </YStack>\n )\n}\n\nconst CurrentToast = () => {\n const { currentToast } = useToast()\n\n if (!currentToast || currentToast.isHandledNatively) return null\n return (\n <Toast\n key={currentToast.id}\n duration={currentToast.duration}\n enterStyle={{ opacity: 0, scale: 0.5, y: -25 }}\n exitStyle={{ opacity: 0, scale: 1, y: -20 }}\n y={0}\n opacity={1}\n scale={1}\n animation=\"100ms\"\n >\n <YStack>\n <Toast.Title>{currentToast.title}</Toast.Title>\n {!!currentToast.message && (\n <Toast.Description>{currentToast.message}</Toast.Description>\n )}\n </YStack>\n </Toast>\n )\n}\n\nconst ToastControl = () => {\n const toast = useToast()\n return (\n <XStack space=\"$2\" jc=\"center\">\n <Button\n onPress={() => {\n toast.show('Successfully saved!', {\n message: \"Don't worry, we've got your data.\",\n })\n }}\n >\n Show\n </Button>\n <Button\n onPress={() => {\n toast.hide()\n }}\n >\n Hide\n </Button>\n </XStack>\n )\n}\n\nconst NativeOptions = ({\n native,\n setNative,\n}: {\n native: ToastNativePlatform[]\n setNative: (native: ToastNativePlatform[]) => void\n}) => {\n const supportedNativePlatforms: ToastNativePlatform[] = ['web', 'mobile']\n\n return (\n <XStack space>\n {supportedNativePlatforms.map((platform) => (\n <XStack ai=\"center\" space=\"$2\" key={platform}>\n <Checkbox\n id={platform}\n checked={native?.includes(platform)}\n onCheckedChange={(checked) => {\n if (checked) setNative([...native, platform])\n else setNative(native.filter((val) => val !== platform))\n }}\n size=\"$3\"\n >\n <Checkbox.Indicator>\n <Check />\n </Checkbox.Indicator>\n </Checkbox>\n <Label size=\"$3\" htmlFor={platform}>\n Native {platform} toast\n </Label>\n </XStack>\n ))}\n </XStack>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAmBM,SACE,KADF;AAnBN,SAAS,aAAa;AACtB,OAAO,WAAW;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,YAAY,MAAM;AAC7B,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAgC,CAAC,CAAC;AAEpE,SACE,qBAAC,UAAO,OAAM,MACZ;AAAA,yBAAC,2BAAwB,SAAS,EAAE,OAAO,GACzC;AAAA,0BAAC,gBAAa;AAAA,MACd,oBAAC,gBAAa;AAAA,OAChB;AAAA,IAEA,oBAAC,iBAAc,QAAgB,WAAsB;AAAA,KACvD;AAEJ;AAEA,MAAM,eAAe,MAAM;AACzB,QAAM,EAAE,aAAa,IAAI,SAAS;AAElC,MAAI,CAAC,gBAAgB,aAAa;AAAmB,WAAO;AAC5D,SACE;AAAA,IAAC;AAAA;AAAA,MAEC,UAAU,aAAa;AAAA,MACvB,YAAY,EAAE,SAAS,GAAG,OAAO,KAAK,GAAG,IAAI;AAAA,MAC7C,WAAW,EAAE,SAAS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