react-native-bread 0.5.2 → 0.5.3
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/lib/commonjs/constants.js +25 -1
- package/lib/commonjs/icons/CloseIcon.js +22 -1
- package/lib/commonjs/icons/GreenCheck.js +27 -1
- package/lib/commonjs/icons/InfoIcon.js +24 -1
- package/lib/commonjs/icons/RedX.js +27 -1
- package/lib/commonjs/icons/index.js +34 -1
- package/lib/commonjs/index.js +59 -1
- package/lib/commonjs/pool.js +53 -1
- package/lib/commonjs/toast-api.js +127 -1
- package/lib/commonjs/toast-icons.js +80 -1
- package/lib/commonjs/toast-provider.js +66 -1
- package/lib/commonjs/toast-store.js +252 -1
- package/lib/commonjs/toast.js +351 -1
- package/lib/commonjs/types.js +6 -1
- package/lib/commonjs/use-toast-state.js +72 -1
- package/lib/module/constants.js +21 -1
- package/lib/module/icons/CloseIcon.js +16 -1
- package/lib/module/icons/GreenCheck.js +21 -1
- package/lib/module/icons/InfoIcon.js +18 -1
- package/lib/module/icons/RedX.js +21 -1
- package/lib/module/icons/index.js +7 -1
- package/lib/module/index.js +14 -1
- package/lib/module/pool.js +47 -1
- package/lib/module/toast-api.js +123 -1
- package/lib/module/toast-icons.js +74 -1
- package/lib/module/toast-provider.js +62 -1
- package/lib/module/toast-store.js +248 -1
- package/lib/module/toast.js +345 -1
- package/lib/module/types.js +4 -1
- package/lib/module/use-toast-state.js +67 -1
- package/package.json +2 -3
|
@@ -1 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SWIPE_EXIT_OFFSET = exports.STACK_TRANSITION_DURATION = exports.STACK_SCALE_PER_ITEM = exports.STACK_OFFSET_PER_ITEM = exports.SPRING_BACK_DURATION = exports.POOL_SIZE = exports.MAX_DRAG_RESISTANCE = exports.MAX_DRAG_CLAMP = exports.ICON_SIZE = exports.ICON_ANIMATION_DURATION = exports.EXIT_OFFSET = exports.EXIT_DURATION = exports.ENTRY_OFFSET = exports.ENTRY_DURATION = exports.EASING = exports.DISMISS_VELOCITY_THRESHOLD = exports.DISMISS_THRESHOLD = void 0;
|
|
7
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
8
|
+
const ICON_SIZE = exports.ICON_SIZE = 28;
|
|
9
|
+
const POOL_SIZE = exports.POOL_SIZE = 5;
|
|
10
|
+
const ENTRY_DURATION = exports.ENTRY_DURATION = 400;
|
|
11
|
+
const EXIT_DURATION = exports.EXIT_DURATION = 350;
|
|
12
|
+
const STACK_TRANSITION_DURATION = exports.STACK_TRANSITION_DURATION = 300;
|
|
13
|
+
const SPRING_BACK_DURATION = exports.SPRING_BACK_DURATION = 650;
|
|
14
|
+
const ICON_ANIMATION_DURATION = exports.ICON_ANIMATION_DURATION = 350;
|
|
15
|
+
const ENTRY_OFFSET = exports.ENTRY_OFFSET = 80;
|
|
16
|
+
const EXIT_OFFSET = exports.EXIT_OFFSET = 100;
|
|
17
|
+
const SWIPE_EXIT_OFFSET = exports.SWIPE_EXIT_OFFSET = 200;
|
|
18
|
+
const MAX_DRAG_CLAMP = exports.MAX_DRAG_CLAMP = 180;
|
|
19
|
+
const MAX_DRAG_RESISTANCE = exports.MAX_DRAG_RESISTANCE = 60;
|
|
20
|
+
const DISMISS_THRESHOLD = exports.DISMISS_THRESHOLD = 40;
|
|
21
|
+
const DISMISS_VELOCITY_THRESHOLD = exports.DISMISS_VELOCITY_THRESHOLD = 300;
|
|
22
|
+
const STACK_OFFSET_PER_ITEM = exports.STACK_OFFSET_PER_ITEM = 10;
|
|
23
|
+
const STACK_SCALE_PER_ITEM = exports.STACK_SCALE_PER_ITEM = 0.05;
|
|
24
|
+
const EASING = exports.EASING = _reactNativeReanimated.Easing.bezier(0.25, 0.1, 0.25, 1.0);
|
|
25
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CloseIcon = void 0;
|
|
7
|
+
var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
|
+
const CloseIcon = props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.default, {
|
|
11
|
+
viewBox: "0 0 24 24",
|
|
12
|
+
width: 24,
|
|
13
|
+
height: 24,
|
|
14
|
+
fill: "none",
|
|
15
|
+
...props,
|
|
16
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
|
|
17
|
+
fill: props.fill ?? "#8993A4",
|
|
18
|
+
d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
exports.CloseIcon = CloseIcon;
|
|
22
|
+
//# sourceMappingURL=CloseIcon.js.map
|
|
@@ -1 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GreenCheck = void 0;
|
|
7
|
+
var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
|
+
const GreenCheck = props => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.default, {
|
|
11
|
+
viewBox: "0 0 30 31",
|
|
12
|
+
width: 30,
|
|
13
|
+
height: 31,
|
|
14
|
+
fill: "none",
|
|
15
|
+
...props,
|
|
16
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
|
|
17
|
+
fill: props.fill ?? "#28B770",
|
|
18
|
+
fillRule: "evenodd",
|
|
19
|
+
d: "m19.866 13.152-5.772 5.773a.933.933 0 0 1-1.326 0L9.88 16.039a.938.938 0 0 1 1.325-1.327l2.225 2.224 5.109-5.11a.938.938 0 1 1 1.326 1.326Zm.28-9.652H9.602C5.654 3.5 3 6.276 3 10.409v9.935c0 4.131 2.654 6.906 6.602 6.906h10.543c3.95 0 6.605-2.775 6.605-6.906v-9.935c0-4.133-2.654-6.909-6.604-6.909Z",
|
|
20
|
+
clipRule: "evenodd"
|
|
21
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
|
|
22
|
+
fill: "#fff",
|
|
23
|
+
d: "m19.866 13.152-5.772 5.773a.933.933 0 0 1-1.326 0L9.88 16.039a.938.938 0 0 1 1.325-1.327l2.225 2.224 5.109-5.11a.938.938 0 1 1 1.326 1.326Z"
|
|
24
|
+
})]
|
|
25
|
+
});
|
|
26
|
+
exports.GreenCheck = GreenCheck;
|
|
27
|
+
//# sourceMappingURL=GreenCheck.js.map
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InfoIcon = void 0;
|
|
7
|
+
var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
|
+
const InfoIcon = props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.default, {
|
|
11
|
+
viewBox: "0 0 24 24",
|
|
12
|
+
width: 24,
|
|
13
|
+
height: 24,
|
|
14
|
+
fill: "none",
|
|
15
|
+
...props,
|
|
16
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
|
|
17
|
+
fill: props.fill ?? "#EDBE43",
|
|
18
|
+
fillRule: "evenodd",
|
|
19
|
+
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm1 15h-2v-6h2v6Zm0-8h-2V7h2v2Z",
|
|
20
|
+
clipRule: "evenodd"
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
exports.InfoIcon = InfoIcon;
|
|
24
|
+
//# sourceMappingURL=InfoIcon.js.map
|
|
@@ -1 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RedX = void 0;
|
|
7
|
+
var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
|
+
const RedX = props => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.default, {
|
|
11
|
+
viewBox: "0 0 24 24",
|
|
12
|
+
width: 24,
|
|
13
|
+
height: 24,
|
|
14
|
+
fill: "none",
|
|
15
|
+
...props,
|
|
16
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
|
|
17
|
+
fill: props.fill ?? "#F05964",
|
|
18
|
+
fillRule: "evenodd",
|
|
19
|
+
d: "M15.58 15.572a.935.935 0 0 1-1.326 0l-2.258-2.258-2.251 2.252a.938.938 0 0 1-1.326-1.325l2.251-2.252-2.252-2.254A.936.936 0 1 1 9.742 8.41l2.253 2.252 2.252-2.25a.939.939 0 0 1 1.325 1.325l-2.25 2.252 2.257 2.257a.938.938 0 0 1 0 1.326ZM17.271.126H6.727C2.777.125.125 2.9.125 7.032v9.936c0 4.13 2.652 6.907 6.603 6.907H17.27c3.95 0 6.605-2.776 6.605-6.907V7.032c0-4.132-2.654-6.907-6.604-6.907Z",
|
|
20
|
+
clipRule: "evenodd"
|
|
21
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Path, {
|
|
22
|
+
fill: "#fff",
|
|
23
|
+
d: "M15.58 15.572a.935.935 0 0 1-1.326 0l-2.258-2.258-2.251 2.252a.938.938 0 0 1-1.326-1.325l2.251-2.252-2.252-2.254A.936.936 0 1 1 9.742 8.41l2.253 2.252 2.252-2.25a.939.939 0 0 1 1.325 1.325l-2.25 2.252 2.257 2.257a.938.938 0 0 1 0 1.326Z"
|
|
24
|
+
})]
|
|
25
|
+
});
|
|
26
|
+
exports.RedX = RedX;
|
|
27
|
+
//# sourceMappingURL=RedX.js.map
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "CloseIcon", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _CloseIcon.CloseIcon;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "GreenCheck", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _GreenCheck.GreenCheck;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "InfoIcon", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _InfoIcon.InfoIcon;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "RedX", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _RedX.RedX;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _CloseIcon = require("./CloseIcon.js");
|
|
31
|
+
var _GreenCheck = require("./GreenCheck.js");
|
|
32
|
+
var _InfoIcon = require("./InfoIcon.js");
|
|
33
|
+
var _RedX = require("./RedX.js");
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
package/lib/commonjs/index.js
CHANGED
|
@@ -1 +1,59 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BreadLoaf", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _toastProvider.BreadLoaf;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "CloseIcon", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _index.CloseIcon;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "GreenCheck", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _index.GreenCheck;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "InfoIcon", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _index.InfoIcon;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "RedX", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _index.RedX;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "ToastContainer", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _toast.ToastContainer;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "toast", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _toastApi.toast;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "toastStore", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _toastStore.toastStore;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
var _index = require("./icons/index.js");
|
|
55
|
+
var _toast = require("./toast.js");
|
|
56
|
+
var _toastApi = require("./toast-api.js");
|
|
57
|
+
var _toastProvider = require("./toast-provider.js");
|
|
58
|
+
var _toastStore = require("./toast-store.js");
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
package/lib/commonjs/pool.js
CHANGED
|
@@ -1 +1,53 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.slotTrackers = exports.releaseSlot = exports.getSlotIndex = exports.animationPool = void 0;
|
|
7
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
8
|
+
var _constants = require("./constants.js");
|
|
9
|
+
const animationPool = exports.animationPool = Array.from({
|
|
10
|
+
length: _constants.POOL_SIZE
|
|
11
|
+
}, () => ({
|
|
12
|
+
progress: (0, _reactNativeReanimated.makeMutable)(0),
|
|
13
|
+
translationY: (0, _reactNativeReanimated.makeMutable)(0),
|
|
14
|
+
stackIndex: (0, _reactNativeReanimated.makeMutable)(0)
|
|
15
|
+
}));
|
|
16
|
+
const slotTrackers = exports.slotTrackers = Array.from({
|
|
17
|
+
length: _constants.POOL_SIZE
|
|
18
|
+
}, () => ({
|
|
19
|
+
wasExiting: false,
|
|
20
|
+
prevIndex: 0,
|
|
21
|
+
initialized: false
|
|
22
|
+
}));
|
|
23
|
+
const slotAssignments = new Map();
|
|
24
|
+
const usedSlots = new Set();
|
|
25
|
+
const getSlotIndex = toastId => {
|
|
26
|
+
if (slotAssignments.has(toastId)) {
|
|
27
|
+
return slotAssignments.get(toastId) ?? 0;
|
|
28
|
+
}
|
|
29
|
+
for (let i = 0; i < _constants.POOL_SIZE; i++) {
|
|
30
|
+
if (!usedSlots.has(i)) {
|
|
31
|
+
slotAssignments.set(toastId, i);
|
|
32
|
+
usedSlots.add(i);
|
|
33
|
+
slotTrackers[i].initialized = false;
|
|
34
|
+
slotTrackers[i].wasExiting = false;
|
|
35
|
+
slotTrackers[i].prevIndex = 0;
|
|
36
|
+
return i;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return 0;
|
|
40
|
+
};
|
|
41
|
+
exports.getSlotIndex = getSlotIndex;
|
|
42
|
+
const releaseSlot = toastId => {
|
|
43
|
+
const idx = slotAssignments.get(toastId);
|
|
44
|
+
if (idx !== undefined) {
|
|
45
|
+
usedSlots.delete(idx);
|
|
46
|
+
slotAssignments.delete(toastId);
|
|
47
|
+
slotTrackers[idx].initialized = false;
|
|
48
|
+
slotTrackers[idx].wasExiting = false;
|
|
49
|
+
slotTrackers[idx].prevIndex = 0;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.releaseSlot = releaseSlot;
|
|
53
|
+
//# sourceMappingURL=pool.js.map
|
|
@@ -1 +1,127 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toast = void 0;
|
|
7
|
+
var _toastStore = require("./toast-store.js");
|
|
8
|
+
const _toast = (title, description, type, duration) => {
|
|
9
|
+
_toastStore.toastStore.show(title, description, type, duration);
|
|
10
|
+
};
|
|
11
|
+
const parseDescriptionOrOptions = arg => {
|
|
12
|
+
if (!arg) return {};
|
|
13
|
+
if (typeof arg === "string") return {
|
|
14
|
+
description: arg
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
description: arg.description,
|
|
18
|
+
duration: arg.duration,
|
|
19
|
+
options: arg
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const parseMessage = input => typeof input === "string" ? {
|
|
23
|
+
title: input
|
|
24
|
+
} : input;
|
|
25
|
+
const parseErrorMessage = (input, error) => {
|
|
26
|
+
if (typeof input === "function") {
|
|
27
|
+
return parseMessage(input(error));
|
|
28
|
+
}
|
|
29
|
+
return parseMessage(input);
|
|
30
|
+
};
|
|
31
|
+
const promiseToast = async (promise, messages) => {
|
|
32
|
+
const loadingCfg = parseMessage(messages.loading);
|
|
33
|
+
const toastId = _toastStore.toastStore.show(loadingCfg.title, loadingCfg.description, "loading", loadingCfg.duration ?? 60 * 60 * 1000);
|
|
34
|
+
try {
|
|
35
|
+
const result = await promise;
|
|
36
|
+
const successCfg = parseMessage(messages.success);
|
|
37
|
+
_toastStore.toastStore.updateToast(toastId, {
|
|
38
|
+
title: successCfg.title,
|
|
39
|
+
description: successCfg.description,
|
|
40
|
+
type: "success",
|
|
41
|
+
duration: successCfg.duration ?? 4000
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
data: result,
|
|
45
|
+
success: true
|
|
46
|
+
};
|
|
47
|
+
} catch (err) {
|
|
48
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
49
|
+
const errorCfg = parseErrorMessage(messages.error, error);
|
|
50
|
+
_toastStore.toastStore.updateToast(toastId, {
|
|
51
|
+
title: errorCfg.title,
|
|
52
|
+
description: errorCfg.description,
|
|
53
|
+
type: "error",
|
|
54
|
+
duration: errorCfg.duration ?? 4000
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
error,
|
|
58
|
+
success: false
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const toastFn = _toast;
|
|
63
|
+
toastFn.custom = (content, options) => {
|
|
64
|
+
const type = options?.type ?? "info";
|
|
65
|
+
return _toastStore.toastStore.show("", undefined, type, options?.duration, {
|
|
66
|
+
...options,
|
|
67
|
+
customContent: content
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
toastFn.success = (title, descriptionOrOptions, duration) => {
|
|
71
|
+
const {
|
|
72
|
+
description,
|
|
73
|
+
duration: optDuration,
|
|
74
|
+
options
|
|
75
|
+
} = parseDescriptionOrOptions(descriptionOrOptions);
|
|
76
|
+
_toastStore.toastStore.show(title, description, "success", duration ?? optDuration, options);
|
|
77
|
+
};
|
|
78
|
+
toastFn.error = (title, descriptionOrOptions, duration) => {
|
|
79
|
+
const {
|
|
80
|
+
description,
|
|
81
|
+
duration: optDuration,
|
|
82
|
+
options
|
|
83
|
+
} = parseDescriptionOrOptions(descriptionOrOptions);
|
|
84
|
+
_toastStore.toastStore.show(title, description, "error", duration ?? optDuration, options);
|
|
85
|
+
};
|
|
86
|
+
toastFn.info = (title, descriptionOrOptions, duration) => {
|
|
87
|
+
const {
|
|
88
|
+
description,
|
|
89
|
+
duration: optDuration,
|
|
90
|
+
options
|
|
91
|
+
} = parseDescriptionOrOptions(descriptionOrOptions);
|
|
92
|
+
_toastStore.toastStore.show(title, description, "info", duration ?? optDuration, options);
|
|
93
|
+
};
|
|
94
|
+
toastFn.promise = promiseToast;
|
|
95
|
+
toastFn.dismiss = id => {
|
|
96
|
+
_toastStore.toastStore.hide(id);
|
|
97
|
+
};
|
|
98
|
+
toastFn.dismissAll = () => {
|
|
99
|
+
_toastStore.toastStore.hideAll();
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Toast API for showing notifications.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* import { toast } from 'react-native-bread';
|
|
108
|
+
*
|
|
109
|
+
* // Basic toasts
|
|
110
|
+
* toast.success("Saved!", "Your changes have been saved");
|
|
111
|
+
* toast.error("Error", "Something went wrong");
|
|
112
|
+
* toast.info("Tip", "Swipe up to dismiss");
|
|
113
|
+
*
|
|
114
|
+
* // Promise toast (loading → success/error)
|
|
115
|
+
* toast.promise(apiCall(), {
|
|
116
|
+
* loading: { title: "Loading..." },
|
|
117
|
+
* success: { title: "Done!" },
|
|
118
|
+
* error: (err) => ({ title: "Failed", description: err.message }),
|
|
119
|
+
* });
|
|
120
|
+
*
|
|
121
|
+
* // Dismiss toasts
|
|
122
|
+
* toast.dismiss(id);
|
|
123
|
+
* toast.dismissAll();
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
const toast = exports.toast = toastFn;
|
|
127
|
+
//# sourceMappingURL=toast-api.js.map
|
|
@@ -1 +1,80 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveIcon = exports.AnimatedIcon = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
10
|
+
var _constants = require("./constants.js");
|
|
11
|
+
var _index = require("./icons/index.js");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
const resolveIcon = (type, color, custom, config) => {
|
|
15
|
+
if (custom) return typeof custom === "function" ? custom({
|
|
16
|
+
color,
|
|
17
|
+
size: _constants.ICON_SIZE
|
|
18
|
+
}) : custom;
|
|
19
|
+
if (config) return config({
|
|
20
|
+
color,
|
|
21
|
+
size: _constants.ICON_SIZE
|
|
22
|
+
});
|
|
23
|
+
switch (type) {
|
|
24
|
+
case "success":
|
|
25
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.GreenCheck, {
|
|
26
|
+
width: 36,
|
|
27
|
+
height: 36,
|
|
28
|
+
fill: color
|
|
29
|
+
});
|
|
30
|
+
case "error":
|
|
31
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.RedX, {
|
|
32
|
+
width: _constants.ICON_SIZE,
|
|
33
|
+
height: _constants.ICON_SIZE,
|
|
34
|
+
fill: color
|
|
35
|
+
});
|
|
36
|
+
case "loading":
|
|
37
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
|
|
38
|
+
size: _constants.ICON_SIZE,
|
|
39
|
+
color: color
|
|
40
|
+
});
|
|
41
|
+
case "info":
|
|
42
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.InfoIcon, {
|
|
43
|
+
width: _constants.ICON_SIZE,
|
|
44
|
+
height: _constants.ICON_SIZE,
|
|
45
|
+
fill: color
|
|
46
|
+
});
|
|
47
|
+
default:
|
|
48
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.GreenCheck, {
|
|
49
|
+
width: 36,
|
|
50
|
+
height: 36,
|
|
51
|
+
fill: color
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.resolveIcon = resolveIcon;
|
|
56
|
+
const AnimatedIcon = exports.AnimatedIcon = /*#__PURE__*/(0, _react.memo)(({
|
|
57
|
+
type,
|
|
58
|
+
color,
|
|
59
|
+
custom,
|
|
60
|
+
config
|
|
61
|
+
}) => {
|
|
62
|
+
const progress = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
63
|
+
(0, _react.useEffect)(() => {
|
|
64
|
+
progress.value = (0, _reactNativeReanimated.withTiming)(1, {
|
|
65
|
+
duration: _constants.ICON_ANIMATION_DURATION,
|
|
66
|
+
easing: _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.back(1.5))
|
|
67
|
+
});
|
|
68
|
+
}, [progress]);
|
|
69
|
+
const style = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
70
|
+
opacity: progress.value,
|
|
71
|
+
transform: [{
|
|
72
|
+
scale: 0.7 + progress.value * 0.3
|
|
73
|
+
}]
|
|
74
|
+
}));
|
|
75
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
76
|
+
style: style,
|
|
77
|
+
children: resolveIcon(type, color, custom, config)
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=toast-icons.js.map
|
|
@@ -1 +1,66 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BreadLoaf = BreadLoaf;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _toast = require("./toast.js");
|
|
10
|
+
var _toastStore = require("./toast-store.js");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
/**
|
|
13
|
+
* Toast component that enables toast notifications in your app.
|
|
14
|
+
* Add `<BreadLoaf />` to your root layout to start showing toasts.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { BreadLoaf } from 'react-native-bread';
|
|
19
|
+
*
|
|
20
|
+
* // Basic usage - add to your root layout
|
|
21
|
+
* export default function RootLayout() {
|
|
22
|
+
* return (
|
|
23
|
+
* <>
|
|
24
|
+
* <Stack />
|
|
25
|
+
* <BreadLoaf />
|
|
26
|
+
* </>
|
|
27
|
+
* );
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* // With configuration
|
|
31
|
+
* <BreadLoaf
|
|
32
|
+
* config={{
|
|
33
|
+
* position: 'bottom',
|
|
34
|
+
* stacking: false,
|
|
35
|
+
* defaultDuration: 5000,
|
|
36
|
+
* colors: {
|
|
37
|
+
* success: { accent: '#22c55e', background: '#f0fdf4' },
|
|
38
|
+
* error: { accent: '#ef4444', background: '#fef2f2' },
|
|
39
|
+
* },
|
|
40
|
+
* toastStyle: { borderRadius: 12 },
|
|
41
|
+
* }}
|
|
42
|
+
* />
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
function BreadLoaf({
|
|
46
|
+
config
|
|
47
|
+
}) {
|
|
48
|
+
(0, _react.useEffect)(() => {
|
|
49
|
+
_toastStore.toastStore.setConfig(config);
|
|
50
|
+
return () => {
|
|
51
|
+
_toastStore.toastStore.setConfig(undefined);
|
|
52
|
+
};
|
|
53
|
+
}, [config]);
|
|
54
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
55
|
+
style: styles.container,
|
|
56
|
+
pointerEvents: "box-none",
|
|
57
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_toast.ToastContainer, {})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const styles = _reactNative.StyleSheet.create({
|
|
61
|
+
container: {
|
|
62
|
+
..._reactNative.StyleSheet.absoluteFillObject,
|
|
63
|
+
zIndex: 9999
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=toast-provider.js.map
|