@tamagui/toast 1.7.10 → 1.8.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.
Files changed (131) hide show
  1. package/dist/cjs/Toast.js +95 -543
  2. package/dist/cjs/Toast.js.map +3 -3
  3. package/dist/cjs/ToastAnnounce.js +93 -0
  4. package/dist/cjs/ToastAnnounce.js.map +7 -0
  5. package/dist/cjs/ToastImpl.js +354 -0
  6. package/dist/cjs/ToastImpl.js.map +7 -0
  7. package/dist/cjs/ToastProvider.js +109 -0
  8. package/dist/cjs/ToastProvider.js.map +7 -0
  9. package/dist/cjs/ToastViewport.js +307 -0
  10. package/dist/cjs/ToastViewport.js.map +7 -0
  11. package/dist/cjs/constants.js +29 -0
  12. package/dist/cjs/constants.js.map +7 -0
  13. package/dist/cjs/createNativeToast.js +49 -0
  14. package/dist/cjs/createNativeToast.js.map +7 -0
  15. package/dist/cjs/createNativeToast.native.js +37 -0
  16. package/dist/cjs/createNativeToast.native.js.map +7 -0
  17. package/dist/cjs/createToast.js +88 -0
  18. package/dist/cjs/createToast.js.map +7 -0
  19. package/dist/cjs/types.js +17 -0
  20. package/dist/cjs/types.js.map +7 -0
  21. package/dist/esm/Toast.js +101 -531
  22. package/dist/esm/Toast.js.map +3 -3
  23. package/dist/esm/Toast.mjs +101 -531
  24. package/dist/esm/Toast.mjs.map +3 -3
  25. package/dist/esm/ToastAnnounce.js +64 -0
  26. package/dist/esm/ToastAnnounce.js.map +7 -0
  27. package/dist/esm/ToastAnnounce.mjs +64 -0
  28. package/dist/esm/ToastAnnounce.mjs.map +7 -0
  29. package/dist/esm/ToastImpl.js +330 -0
  30. package/dist/esm/ToastImpl.js.map +7 -0
  31. package/dist/esm/ToastImpl.mjs +330 -0
  32. package/dist/esm/ToastImpl.mjs.map +7 -0
  33. package/dist/esm/ToastProvider.js +70 -0
  34. package/dist/esm/ToastProvider.js.map +7 -0
  35. package/dist/esm/ToastProvider.mjs +70 -0
  36. package/dist/esm/ToastProvider.mjs.map +7 -0
  37. package/dist/esm/ToastViewport.js +274 -0
  38. package/dist/esm/ToastViewport.js.map +7 -0
  39. package/dist/esm/ToastViewport.mjs +274 -0
  40. package/dist/esm/ToastViewport.mjs.map +7 -0
  41. package/dist/esm/constants.js +5 -0
  42. package/dist/esm/constants.js.map +7 -0
  43. package/dist/esm/constants.mjs +5 -0
  44. package/dist/esm/constants.mjs.map +7 -0
  45. package/dist/esm/createNativeToast.js +25 -0
  46. package/dist/esm/createNativeToast.js.map +7 -0
  47. package/dist/esm/createNativeToast.mjs +25 -0
  48. package/dist/esm/createNativeToast.mjs.map +7 -0
  49. package/dist/esm/createNativeToast.native.js +13 -0
  50. package/dist/esm/createNativeToast.native.js.map +7 -0
  51. package/dist/esm/createNativeToast.native.mjs +13 -0
  52. package/dist/esm/createNativeToast.native.mjs.map +7 -0
  53. package/dist/esm/createToast.js +54 -0
  54. package/dist/esm/createToast.js.map +7 -0
  55. package/dist/esm/createToast.mjs +54 -0
  56. package/dist/esm/createToast.mjs.map +7 -0
  57. package/dist/esm/types.js +1 -0
  58. package/dist/esm/types.js.map +7 -0
  59. package/dist/esm/types.mjs +1 -0
  60. package/dist/esm/types.mjs.map +7 -0
  61. package/dist/jsx/Toast.js +97 -509
  62. package/dist/jsx/Toast.js.map +3 -3
  63. package/dist/jsx/Toast.mjs +97 -509
  64. package/dist/jsx/Toast.mjs.map +3 -3
  65. package/dist/jsx/ToastAnnounce.js +60 -0
  66. package/dist/jsx/ToastAnnounce.js.map +7 -0
  67. package/dist/jsx/ToastAnnounce.mjs +60 -0
  68. package/dist/jsx/ToastAnnounce.mjs.map +7 -0
  69. package/dist/jsx/ToastImpl.js +309 -0
  70. package/dist/jsx/ToastImpl.js.map +7 -0
  71. package/dist/jsx/ToastImpl.mjs +309 -0
  72. package/dist/jsx/ToastImpl.mjs.map +7 -0
  73. package/dist/jsx/ToastProvider.js +65 -0
  74. package/dist/jsx/ToastProvider.js.map +7 -0
  75. package/dist/jsx/ToastProvider.mjs +65 -0
  76. package/dist/jsx/ToastProvider.mjs.map +7 -0
  77. package/dist/jsx/ToastViewport.js +254 -0
  78. package/dist/jsx/ToastViewport.js.map +7 -0
  79. package/dist/jsx/ToastViewport.mjs +254 -0
  80. package/dist/jsx/ToastViewport.mjs.map +7 -0
  81. package/dist/jsx/constants.js +5 -0
  82. package/dist/jsx/constants.js.map +7 -0
  83. package/dist/jsx/constants.mjs +5 -0
  84. package/dist/jsx/constants.mjs.map +7 -0
  85. package/dist/jsx/createNativeToast.js +25 -0
  86. package/dist/jsx/createNativeToast.js.map +7 -0
  87. package/dist/jsx/createNativeToast.mjs +25 -0
  88. package/dist/jsx/createNativeToast.mjs.map +7 -0
  89. package/dist/jsx/createNativeToast.native.js +13 -0
  90. package/dist/jsx/createNativeToast.native.js.map +7 -0
  91. package/dist/jsx/createNativeToast.native.mjs +13 -0
  92. package/dist/jsx/createNativeToast.native.mjs.map +7 -0
  93. package/dist/jsx/createToast.js +49 -0
  94. package/dist/jsx/createToast.js.map +7 -0
  95. package/dist/jsx/createToast.mjs +49 -0
  96. package/dist/jsx/createToast.mjs.map +7 -0
  97. package/dist/jsx/types.js +1 -0
  98. package/dist/jsx/types.js.map +7 -0
  99. package/dist/jsx/types.mjs +1 -0
  100. package/dist/jsx/types.mjs.map +7 -0
  101. package/package.json +14 -13
  102. package/src/Toast.tsx +139 -908
  103. package/src/ToastAnnounce.tsx +97 -0
  104. package/src/ToastImpl.tsx +439 -0
  105. package/src/ToastProvider.tsx +134 -0
  106. package/src/ToastViewport.tsx +354 -0
  107. package/src/constants.ts +1 -0
  108. package/src/createNativeToast.native.tsx +16 -0
  109. package/src/createNativeToast.tsx +25 -0
  110. package/src/createToast.tsx +93 -0
  111. package/src/types.ts +21 -0
  112. package/types/Toast.d.ts +429 -106
  113. package/types/Toast.d.ts.map +1 -1
  114. package/types/ToastAnnounce.d.ts +35 -0
  115. package/types/ToastAnnounce.d.ts.map +1 -0
  116. package/types/ToastImpl.d.ts +267 -0
  117. package/types/ToastImpl.d.ts.map +1 -0
  118. package/types/ToastProvider.d.ts +80 -0
  119. package/types/ToastProvider.d.ts.map +1 -0
  120. package/types/ToastViewport.d.ts +115 -0
  121. package/types/ToastViewport.d.ts.map +1 -0
  122. package/types/constants.d.ts +2 -0
  123. package/types/constants.d.ts.map +1 -0
  124. package/types/createNativeToast.d.ts +3 -0
  125. package/types/createNativeToast.d.ts.map +1 -0
  126. package/types/createNativeToast.native.d.ts +3 -0
  127. package/types/createNativeToast.native.d.ts.map +1 -0
  128. package/types/createToast.d.ts +42 -0
  129. package/types/createToast.d.ts.map +1 -0
  130. package/types/types.d.ts +17 -0
  131. package/types/types.d.ts.map +1 -0
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var createNativeToast_native_exports = {};
20
+ __export(createNativeToast_native_exports, {
21
+ createNativeToast: () => createNativeToast
22
+ });
23
+ module.exports = __toCommonJS(createNativeToast_native_exports);
24
+ const createNativeToast = (title, { message, duration, preset = "done" }) => {
25
+ const Burnt = require("burnt");
26
+ Burnt.toast({
27
+ title,
28
+ message: message ?? "",
29
+ preset,
30
+ duration
31
+ });
32
+ };
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ createNativeToast
36
+ });
37
+ //# sourceMappingURL=createNativeToast.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/createNativeToast.native.tsx"],
4
+ "sourcesContent": ["import { CreateNativeToastsOptions, CreateNativeToastsOptionsFn } from './types'\n\nexport const createNativeToast: CreateNativeToastsOptionsFn = (\n title,\n { message, duration, preset = 'done' }: CreateNativeToastsOptions\n) => {\n // import inline to allow lazy usage of native dependecy:\n const Burnt = require('burnt')\n\n Burnt.toast({\n title,\n message: message ?? '',\n preset,\n duration,\n })\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,oBAAiD,CAC5D,OACA,EAAE,SAAS,UAAU,SAAS,OAAO,MAClC;AAEH,QAAM,QAAQ,QAAQ,OAAO;AAE7B,QAAM,MAAM;AAAA,IACV;AAAA,IACA,SAAS,WAAW;AAAA,IACpB;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -0,0 +1,88 @@
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 createToast_exports = {};
30
+ __export(createToast_exports, {
31
+ createToast: () => createToast
32
+ });
33
+ module.exports = __toCommonJS(createToast_exports);
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_core = require("@tamagui/core");
36
+ var import_create_context = require("@tamagui/create-context");
37
+ var import_react = __toESM(require("react"));
38
+ var import_createNativeToast = require("./createNativeToast");
39
+ const [createImperativeToastContext, createImperativeToastScope] = (0, import_create_context.createContextScope)("ImperativeToast");
40
+ const [ImperativeToastProvider, useToastProviderContext] = createImperativeToastContext("ImperativeToastProvider");
41
+ const createToast = (options = {}) => {
42
+ return {
43
+ ImperativeToastProvider: ({
44
+ __scopeToast,
45
+ children
46
+ }) => {
47
+ const counterRef = (0, import_react.useRef)(0);
48
+ const [toast, setToast] = import_react.default.useState(null);
49
+ const addToast = import_react.default.useCallback(
50
+ (title, options2) => {
51
+ counterRef.current++;
52
+ setToast({ title, id: counterRef.current.toString(), ...options2 });
53
+ },
54
+ [setToast]
55
+ );
56
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
57
+ ImperativeToastProvider,
58
+ {
59
+ scope: __scopeToast,
60
+ addToast,
61
+ currentToast: toast,
62
+ children
63
+ }
64
+ );
65
+ },
66
+ useToast: () => {
67
+ const context = useToastProviderContext("useToast", void 0);
68
+ return {
69
+ /**
70
+ * The toast to get and show if not using native
71
+ */
72
+ currentToast: context.currentToast,
73
+ show(title, showOptions) {
74
+ const native = (showOptions == null ? void 0 : showOptions.native) || options.native;
75
+ if (native === true || Array.isArray(options.native) && (import_core.isWeb && options.native.includes("web") || !import_core.isWeb && options.native.includes("mobile"))) {
76
+ return (0, import_createNativeToast.createNativeToast)(title, showOptions ?? {});
77
+ }
78
+ context.addToast(title, showOptions ?? {});
79
+ }
80
+ };
81
+ }
82
+ };
83
+ };
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ createToast
87
+ });
88
+ //# sourceMappingURL=createToast.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/createToast.tsx"],
4
+ "sourcesContent": ["import { isWeb } from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport React, { useRef } from 'react'\n\nimport { createNativeToast } from './createNativeToast'\nimport { CreateNativeToastsOptions, CreateNativeToastsOptionsFn } from './types'\n\ntype NativeValue = boolean | 'web' | 'mobile'\ninterface CreateToastOptions {\n /**\n * Will show a native toast if is true or is set to the current platform. On iOS, it wraps `SPIndicator` and `SPAlert`. On Android, it wraps `ToastAndroid`. On web, it wraps Notification API. Mobile's native features are handled by `burnt`.\n */\n native?: NativeValue\n}\ninterface ToastOptions extends CreateNativeToastsOptions {\n /**\n * Used when need custom data\n */\n additionalInfo?: Record<string, any>\n /**\n * Overrides the native option on `createToast()`\n */\n native?: NativeValue\n}\ntype ScopedProps<P> = P & { __scopeToast?: Scope }\n\ntype ToastData = { title: string; id: string } & CreateNativeToastsOptions\n\ninterface ImperativeToastContextValue {\n currentToast: ToastData | null\n addToast: CreateNativeToastsOptionsFn\n}\n\nconst [createImperativeToastContext, createImperativeToastScope] =\n createContextScope('ImperativeToast')\n\nconst [ImperativeToastProvider, useToastProviderContext] =\n createImperativeToastContext<ImperativeToastContextValue>('ImperativeToastProvider')\n\nconst createToast = (options = {} as CreateToastOptions) => {\n return {\n ImperativeToastProvider: ({\n __scopeToast,\n children,\n }: ScopedProps<{ children: React.ReactNode }>) => {\n const counterRef = useRef(0)\n const [toast, setToast] =\n React.useState<ImperativeToastContextValue['currentToast']>(null)\n const addToast = React.useCallback<CreateNativeToastsOptionsFn>(\n (title, options) => {\n counterRef.current++\n setToast({ title, id: counterRef.current.toString(), ...options })\n },\n [setToast]\n )\n\n return (\n <ImperativeToastProvider\n scope={__scopeToast}\n addToast={addToast}\n currentToast={toast}\n >\n {children}\n </ImperativeToastProvider>\n )\n },\n useToast: () => {\n const context = useToastProviderContext('useToast', undefined)\n\n return {\n /**\n * The toast to get and show if not using native\n */\n currentToast: context.currentToast,\n show(title: string, showOptions?: ToastOptions) {\n const native = showOptions?.native || options.native\n if (\n native === true ||\n (Array.isArray(options.native) &&\n ((isWeb && options.native.includes('web')) ||\n (!isWeb && options.native.includes('mobile'))))\n ) {\n return createNativeToast(title, showOptions ?? {})\n }\n context.addToast(title, showOptions ?? {})\n },\n }\n },\n }\n}\n\nexport { createToast }\nexport type { CreateToastOptions }\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyDQ;AAzDR,kBAAsB;AACtB,4BAA0C;AAC1C,mBAA8B;AAE9B,+BAAkC;AA6BlC,MAAM,CAAC,8BAA8B,0BAA0B,QAC7D,0CAAmB,iBAAiB;AAEtC,MAAM,CAAC,yBAAyB,uBAAuB,IACrD,6BAA0D,yBAAyB;AAErF,MAAM,cAAc,CAAC,UAAU,CAAC,MAA4B;AAC1D,SAAO;AAAA,IACL,yBAAyB,CAAC;AAAA,MACxB;AAAA,MACA;AAAA,IACF,MAAkD;AAChD,YAAM,iBAAa,qBAAO,CAAC;AAC3B,YAAM,CAAC,OAAO,QAAQ,IACpB,aAAAA,QAAM,SAAsD,IAAI;AAClE,YAAM,WAAW,aAAAA,QAAM;AAAA,QACrB,CAAC,OAAOC,aAAY;AAClB,qBAAW;AACX,mBAAS,EAAE,OAAO,IAAI,WAAW,QAAQ,SAAS,GAAG,GAAGA,SAAQ,CAAC;AAAA,QACnE;AAAA,QACA,CAAC,QAAQ;AAAA,MACX;AAEA,aACE;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,UACP;AAAA,UACA,cAAc;AAAA,UAEb;AAAA;AAAA,MACH;AAAA,IAEJ;AAAA,IACA,UAAU,MAAM;AACd,YAAM,UAAU,wBAAwB,YAAY,MAAS;AAE7D,aAAO;AAAA;AAAA;AAAA;AAAA,QAIL,cAAc,QAAQ;AAAA,QACtB,KAAK,OAAe,aAA4B;AAC9C,gBAAM,UAAS,2CAAa,WAAU,QAAQ;AAC9C,cACE,WAAW,QACV,MAAM,QAAQ,QAAQ,MAAM,MACzB,qBAAS,QAAQ,OAAO,SAAS,KAAK,KACrC,CAAC,qBAAS,QAAQ,OAAO,SAAS,QAAQ,IAC/C;AACA,uBAAO,4CAAkB,OAAO,eAAe,CAAC,CAAC;AAAA,UACnD;AACA,kBAAQ,SAAS,OAAO,eAAe,CAAC,CAAC;AAAA,QAC3C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": ["React", "options"]
7
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/types.ts"],
4
+ "sourcesContent": ["import { ToastOptions as BurntToastOptions } from 'burnt/build/types'\n\nexport interface CreateNativeToastsOptions {\n /**\n * Body of the toast\n */\n message?: BurntToastOptions['message']\n /**\n * Only supported on native iOS driver\n */\n preset?: BurntToastOptions['preset']\n /**\n * Duration of toast\n */\n duration?: BurntToastOptions['duration']\n}\n\nexport type CreateNativeToastsOptionsFn = (\n title: string,\n options: CreateNativeToastsOptions\n) => void\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }