flash-notifications 0.0.26 → 0.0.28
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/build/configuration.d.ts.map +1 -1
- package/build/configuration.js.map +1 -1
- package/build/container/index.d.ts +1 -1
- package/build/container/index.d.ts.map +1 -1
- package/build/container/index.js +1 -6
- package/build/container/index.js.map +1 -1
- package/build/container/notification.d.ts +1 -1
- package/build/container/notification.d.ts.map +1 -1
- package/build/container/notification.js +1 -1
- package/build/container/notification.js.map +1 -1
- package/build/events.d.ts.map +1 -1
- package/build/events.js.map +1 -1
- package/build/flash-notifications.d.ts.map +1 -1
- package/build/flash-notifications.js +4 -4
- package/build/flash-notifications.js.map +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/build/listener.d.ts.map +1 -1
- package/build/listener.js.map +1 -1
- package/package.json +3 -3
- package/src/container/index.jsx +1 -7
- package/src/container/notification.jsx +1 -1
- package/src/flash-notifications.js +4 -4
- package/tsconfig.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"/src/","sources":["configuration.js"],"names":[],"mappings":";AAMA,iCAAgE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"/src/","sources":["configuration.js"],"names":[],"mappings":"AAAA,IAAI,CAAC,UAAU,CAAC,+BAA+B,EAAE,CAAC;IAChD,UAAU,CAAC,+BAA+B,GAAG;QAC3C,SAAS,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,YAAY,IAAI,KAAK;KACxD,CAAA;AACH,CAAC;AAED,MAAM,aAAa,GAAG,UAAU,CAAC,+BAA+B,CAAA;AAEhE,eAAe,aAAa,CAAA","sourcesContent":["if (!globalThis.flashNotificationsConfiguration) {\n globalThis.flashNotificationsConfiguration = {\n translate: (msgId, args) => args?.defaultValue || msgId\n }\n}\n\nconst configuration = globalThis.flashNotificationsConfiguration\n\nexport default configuration\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/src/","sources":["container/index.jsx"],"names":[],"mappings":";;;WAiBc,MAAM;aACN,MAAM;WACN,MAAM;UACN,MAAM;;kBAf0B,OAAO"}
|
package/build/container/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { digg } from "diggerize";
|
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import propTypesExact from "prop-types-exact";
|
|
5
5
|
import React, { memo, useEffect, useMemo } from "react";
|
|
6
|
-
import { shapeComponent, ShapeComponent } from "set-state-compare/
|
|
6
|
+
import { shapeComponent, ShapeComponent } from "set-state-compare/build/shape-component.js";
|
|
7
7
|
import useBreakpoint from "@kaspernj/api-maker/build/use-breakpoint.js";
|
|
8
8
|
import useEventEmitter from "@kaspernj/api-maker/build/use-event-emitter.js";
|
|
9
9
|
import useEnvSense from "env-sense/src/use-env-sense.js";
|
|
@@ -24,7 +24,6 @@ export default memo(shapeComponent(class FlashNotificationsContainer extends Sha
|
|
|
24
24
|
/** @type {number[]} */
|
|
25
25
|
timeouts = [];
|
|
26
26
|
setup() {
|
|
27
|
-
// @ts-expect-error
|
|
28
27
|
this.useStates({
|
|
29
28
|
count: 0,
|
|
30
29
|
notifications: []
|
|
@@ -39,9 +38,7 @@ export default memo(shapeComponent(class FlashNotificationsContainer extends Sha
|
|
|
39
38
|
}, []);
|
|
40
39
|
}
|
|
41
40
|
render() {
|
|
42
|
-
// @ts-expect-error
|
|
43
41
|
const { notifications } = this.s;
|
|
44
|
-
// @ts-expect-error
|
|
45
42
|
const insets = this.props.insets || {};
|
|
46
43
|
const { smDown, mdUp } = useBreakpoint();
|
|
47
44
|
const { isNative } = useEnvSense();
|
|
@@ -84,7 +81,6 @@ export default memo(shapeComponent(class FlashNotificationsContainer extends Sha
|
|
|
84
81
|
* @returns {void}
|
|
85
82
|
*/
|
|
86
83
|
onPushNotification = (detail) => {
|
|
87
|
-
// @ts-expect-error
|
|
88
84
|
const count = this.s.count + 1;
|
|
89
85
|
const timeout = setTimeout(() => this.removeNotification(count), 4000);
|
|
90
86
|
this.timeouts.push(timeout);
|
|
@@ -101,7 +97,6 @@ export default memo(shapeComponent(class FlashNotificationsContainer extends Sha
|
|
|
101
97
|
removeNotification = (count) => {
|
|
102
98
|
// @ts-expect-error
|
|
103
99
|
this.setState({
|
|
104
|
-
// @ts-expect-error
|
|
105
100
|
notifications: this.s.notifications.filter((notification) => notification.count != count)
|
|
106
101
|
});
|
|
107
102
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/src/","sources":["container/index.jsx"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AACrD,OAAO,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,4CAA4C,CAAA;AACzF,OAAO,aAAa,MAAM,6CAA6C,CAAA;AACvE,OAAO,eAAe,MAAM,gDAAgD,CAAA;AAC5E,OAAO,WAAW,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AAEjC,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,YAAY,MAAM,gBAAgB,CAAA;AAEzC;;;;;;GAMG;AAEH,eAAe,IAAI,CAAC,cAAc,CAA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AO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;QAEtE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAE3B,MAAM,YAAY,GAAG;YACnB,KAAK;YACL,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC;YAChC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;YAC5B,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;SAC3B,CAAA;QAED,mBAAmB;QACnB,IAAI,CAAC,QAAQ,CAAC,EAAC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,EAAC,CAAC,CAAA;IACpF,CAAC,CAAA;IAED,gBAAgB,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAA;IAEzF,kBAAkB,GAAG,CAAC,KAAK,EAAE,EAAE;QAC7B,mBAAmB;QACnB,IAAI,CAAC,QAAQ,CAAC;YACZ,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,IAAI,KAAK,CAAC;SAC1F,CAAC,CAAA;IACJ,CAAC,CAAA;CACF,CAAC,CAAC,CAAA","sourcesContent":["// @ts-check\n\nimport {digg} from \"diggerize\"\nimport PropTypes from \"prop-types\"\nimport propTypesExact from \"prop-types-exact\"\nimport React, {memo, useEffect, useMemo} from \"react\"\nimport {shapeComponent, ShapeComponent} from \"set-state-compare/build/shape-component.js\"\nimport useBreakpoint from \"@kaspernj/api-maker/build/use-breakpoint.js\"\nimport useEventEmitter from \"@kaspernj/api-maker/build/use-event-emitter.js\"\nimport useEnvSense from \"env-sense/src/use-env-sense.js\"\nimport {View} from \"react-native\"\n\nimport events from \"../events.js\"\nimport Notification from \"./notification\"\n\n/**\n * @typedef {object} NotificationObjectType\n * @property {number} count\n * @property {string} message\n * @property {string} title\n * @property {string} type\n */\n\nexport default memo(shapeComponent(class FlashNotificationsContainer extends ShapeComponent {\n static propTypes = propTypesExact({\n insets: PropTypes.object\n })\n\n /** @type {number[]} */\n timeouts = []\n\n setup() {\n this.useStates({\n count: 0,\n notifications: []\n })\n\n useEventEmitter(events, \"pushNotification\", this.onPushNotification)\n useEffect(() => {\n return () => {\n for (const timeout of this.timeouts) {\n clearTimeout(timeout)\n }\n }\n }, [])\n }\n\n render() {\n const {notifications} = this.s\n const insets = this.props.insets || {}\n\n const {smDown, mdUp} = useBreakpoint()\n const {isNative} = useEnvSense()\n\n const viewStyle = useMemo(() => {\n let top = 20\n let right = 0\n let left = undefined\n\n if (insets.top) top += insets.top\n if (insets.right) right += insets.right\n\n if (smDown) {\n left = 20\n\n if (insets.left) left += insets.left\n\n right += 20\n } else if (mdUp) {\n right += 20\n }\n\n const style = {\n position: isNative ? \"absolute\" : \"fixed\",\n top,\n right,\n left,\n zIndex: 99999\n }\n\n return style\n }, [isNative, smDown, mdUp, insets.top, insets.right, insets.left])\n\n return (\n <View\n // @ts-expect-error\n dataSet={this.rootViewDataSet ||= {component: \"flash-notifications-container\"}}\n // @ts-expect-error\n style={viewStyle}\n testID=\"flash-notificaitons/container\"\n >\n {notifications.map((notification) =>\n <Notification\n count={notification.count}\n key={`notification-${notification.count}`}\n message={notification.message}\n notification={notification}\n onRemovedClicked={this.onRemovedClicked}\n title={notification.title}\n type={notification.type}\n />\n )}\n </View>\n )\n }\n\n /**\n * @param {NotificationObjectType} detail\n * @returns {void}\n */\n onPushNotification = (detail) => {\n const count = this.s.count + 1\n const timeout = setTimeout(() => this.removeNotification(count), 4000)\n\n this.timeouts.push(timeout)\n\n const notification = {\n count,\n message: digg(detail, \"message\"),\n title: digg(detail, \"title\"),\n type: digg(detail, \"type\")\n }\n\n // @ts-expect-error\n this.setState({count, notifications: this.s.notifications.concat([notification])})\n }\n\n onRemovedClicked = (notification) => this.removeNotification(digg(notification, \"count\"))\n\n removeNotification = (count) => {\n // @ts-expect-error\n this.setState({\n notifications: this.s.notifications.filter((notification) => notification.count != count)\n })\n }\n}))\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"notification.d.ts","sourceRoot":"/src/","sources":["container/notification.jsx"],"names":[],"mappings":";;kBAGmC,OAAO"}
|
|
@@ -3,7 +3,7 @@ import PropTypes from "prop-types";
|
|
|
3
3
|
import PropTypesExact from "prop-types-exact";
|
|
4
4
|
import React, { memo, useMemo } from "react";
|
|
5
5
|
import { Pressable, StyleSheet, Text, View } from "react-native";
|
|
6
|
-
import { shapeComponent, ShapeComponent } from "set-state-compare/
|
|
6
|
+
import { shapeComponent, ShapeComponent } from "set-state-compare/build/shape-component.js";
|
|
7
7
|
import useStyles from "@kaspernj/api-maker/build/use-styles.js";
|
|
8
8
|
const styles = StyleSheet.create({
|
|
9
9
|
view: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"notification.js","sourceRoot":"/src/","sources":["container/notification.jsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,4CAA4C,CAAA;AACzF,OAAO,S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AE,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAA;CACtE,CAAC,CAAC,CAAA","sourcesContent":["import classNames from \"classnames\"\nimport PropTypes from \"prop-types\"\nimport PropTypesExact from \"prop-types-exact\"\nimport React, {memo, useMemo} from \"react\"\nimport {Pressable, StyleSheet, Text, View} from \"react-native\"\nimport {shapeComponent, ShapeComponent} from \"set-state-compare/build/shape-component.js\"\nimport useStyles from \"@kaspernj/api-maker/build/use-styles.js\"\n\nconst styles = StyleSheet.create({\n view: {\n marginBottom: 15,\n padding: 15,\n borderRadius: 11,\n cursor: \"pointer\"\n },\n viewSmDown: {\n width: \"100%\"\n },\n viewMdUp: {\n width: 300,\n maxWidth: \"100%\"\n },\n viewError: {\n border: \"1px solid rgba(161, 34, 32, 0.95)\",\n backgroundColor: \"rgba(161, 34, 32, 0.87)\"\n },\n viewSuccess: {\n border: \"1px solid rgba(0, 0, 0, 0.95)\",\n backgroundColor: \"rgba(0, 0, 0, 0.87)\"\n },\n viewAlert: {\n border: \"1px solid rgba(204, 51, 0, 0.95)\",\n backgroundColor: \"rgba(204, 51, 0, 0.87)\"\n },\n titleview: {\n marginBottom: 5\n },\n titleText: {\n color: \"#fff\",\n fontWeight: \"bold\"\n },\n messageText: {\n color: \"#fff\"\n }\n})\n\nconst titleViewDataSet = {class: \"notification-title\"}\nconst messageViewDataSet = {class: \"notification-message\"}\n\nexport default memo(shapeComponent(class FlashNotificationsNotification extends ShapeComponent {\n static propTypes = PropTypesExact({\n className: PropTypes.string,\n count: PropTypes.number.isRequired,\n message: PropTypes.string.isRequired,\n notification: PropTypes.object.isRequired,\n onRemovedClicked: PropTypes.func.isRequired,\n title: PropTypes.string.isRequired,\n type: PropTypes.string.isRequired\n })\n\n render() {\n const {count, message, title, type} = this.p\n const {className} = this.props\n\n const viewStyles = useStyles(styles, [\"view\", {\n viewError: type == \"error\",\n viewSuccess: type == \"success\",\n viewAlert: type == \"alert\"\n }])\n\n const pressableDataSet = useMemo(\n () => ({\n class: classNames(\"flash-notifications-notification\", className),\n role: \"dialog\",\n type\n }),\n [className, type]\n )\n\n return (\n <Pressable dataSet={pressableDataSet} onPress={this.tt.onRemovedClicked}>\n <View style={viewStyles}>\n <View dataSet={titleViewDataSet} style={styles.titleview}>\n <Text style={styles.titleText} testID={`flash-notifications/notification-${count}/title`}>\n {title}\n </Text>\n </View>\n <View dataSet={messageViewDataSet}>\n <Text style={styles.messageText} testID={`flash-notifications/notification-${count}/message`}>\n {message}\n </Text>\n </View>\n </View>\n </Pressable>\n )\n }\n\n onRemovedClicked = () => this.p.onRemovedClicked(this.p.notification)\n}))\n"]}
|
package/build/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"/src/","sources":["events.js"],"names":[],"mappings":""}
|
package/build/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"/src/","sources":["events.js"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,QAAQ,CAAA;AAEjC,IAAI,CAAC,UAAU,CAAC,wBAAwB,EAAE,CAAC;IACzC,UAAU,CAAC,wBAAwB,GAAG,IAAI,YAAY,EAAE,CAAA;AAC1D,CAAC;AAED,eAAe,UAAU,CAAC,wBAAwB,CAAA","sourcesContent":["import EventEmitter from \"events\"\n\nif (!globalThis.flashNotificationsEvents) {\n globalThis.flashNotificationsEvents = new EventEmitter()\n}\n\nexport default globalThis.flashNotificationsEvents\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flash-notifications.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"flash-notifications.d.ts","sourceRoot":"/src/","sources":["flash-notifications.js"],"names":[],"mappings":"AAOA;IACE;;;OAGG;IACH,sBAHW,MAAM,GACJ,IAAI,CAIhB;IAED;;;OAGG;IACH,sBAHW,MAAM,GACJ,IAAI,CAIhB;IAED;;;OAGG;IACH,4BAHW,KAAK,GACH,IAAI,CAqChB;IAED;;;OAGG;IACH,wBAHW,MAAM,GACJ,IAAI,CAIhB;IAED;;;;;OAKG;IACH,kBAJG;QAAqB,IAAI,EAAjB,MAAM;QACO,IAAI,EAAjB,MAAM;KACd,GAAU,IAAI,CAoBhB;CACF"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import BaseError from "@kaspernj/api-maker/build/base-error.js";
|
|
3
|
-
import ValidationError from "@kaspernj/api-maker/build/validation-error.js";
|
|
4
2
|
import { digg } from "diggerize";
|
|
5
3
|
import configuration from "./configuration.js";
|
|
6
4
|
import events from "./events.js";
|
|
@@ -24,7 +22,8 @@ export default class FlashNotifications {
|
|
|
24
22
|
* @returns {void}
|
|
25
23
|
*/
|
|
26
24
|
static errorResponse(error) {
|
|
27
|
-
|
|
25
|
+
// @ts-expect-error
|
|
26
|
+
if (error.apiMakerType == "ValidationError") {
|
|
28
27
|
// @ts-expect-error
|
|
29
28
|
if (error.hasUnhandledErrors()) {
|
|
30
29
|
// @ts-expect-error
|
|
@@ -35,8 +34,9 @@ export default class FlashNotifications {
|
|
|
35
34
|
const defaultValue = "Couldn't submit because of validation errors.";
|
|
36
35
|
FlashNotifications.alert(configuration.translate("js.notification.couldnt_submit_because_of_validation_errors", { defaultValue }));
|
|
37
36
|
}
|
|
37
|
+
// @ts-expect-error
|
|
38
38
|
}
|
|
39
|
-
else if (error
|
|
39
|
+
else if (error.apiMakerType == "BaseError") {
|
|
40
40
|
// @ts-expect-error
|
|
41
41
|
if (error.args.response && error.args.response.errors) {
|
|
42
42
|
const errors = /** @type {Array<string | {message: string}[]>} */ (digg(error, "args", "response", "errors"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flash-notifications.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"flash-notifications.js","sourceRoot":"/src/","sources":["flash-notifications.js"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAE9B,OAAO,aAAa,MAAM,oBAAoB,CAAA;AAC9C,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACrC;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO;QAClB,kBAAkB,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC,CAAA;IACzD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO;QAClB,kBAAkB,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC,CAAA;IACzD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK;QACxB,mBAAmB;QACnB,IAAI,KAAK,CAAC,YAAY,IAAI,iBAAiB,EAAE,CAAC;YAC5C,mBAAmB;YACnB,IAAI,KAAK,CAAC,kBAAkB,EAAE,EAAE,CAAC;gBAC/B,mBAAmB;gBACnB,MAAM,sBAAsB,GAAG,KAAK,CAAC,kBAAkB,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;gBAEnH,kBAAkB,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC7D,CAAC;iBAAM,CAAC;gBACN,MAAM,YAAY,GAAG,+CAA+C,CAAA;gBAEpE,kBAAkB,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,6DAA6D,EAAE,EAAC,YAAY,EAAC,CAAC,CAAC,CAAA;YAClI,CAA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AC,YAAY,EAAE,OAAO,EAAC,CAAC,CAAA;QAC7E,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;YAChC,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,iBAAiB,EAAE,EAAC,YAAY,EAAE,OAAO,EAAC,CAAC,CAAA;QAC7E,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC;YAClC,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,mBAAmB,EAAE,EAAC,YAAY,EAAE,SAAS,EAAC,CAAC,CAAA;QACjF,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,wBAAwB,EAAE,EAAC,YAAY,EAAE,cAAc,EAAC,CAAC,CAAA;QAC3F,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC9B,OAAO,EAAE,IAAI,CAAC,IAAI;YAClB,KAAK;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["// @ts-check\n\nimport {digg} from \"diggerize\"\n\nimport configuration from \"./configuration.js\"\nimport events from \"./events.js\"\n\nexport default class FlashNotifications {\n /**\n * @param {string} message\n * @returns {void}\n */\n static alert(message) {\n FlashNotifications.show({type: \"alert\", text: message})\n }\n\n /**\n * @param {string} message\n * @returns {void}\n */\n static error(message) {\n FlashNotifications.show({type: \"error\", text: message})\n }\n\n /**\n * @param {Error} error\n * @returns {void}\n */\n static errorResponse(error) {\n // @ts-expect-error\n if (error.apiMakerType == \"ValidationError\") {\n // @ts-expect-error\n if (error.hasUnhandledErrors()) {\n // @ts-expect-error\n const unhandledErrorMessages = error.getUnhandledErrors().map((subError) => subError.getFullErrorMessages()).flat()\n\n FlashNotifications.error(unhandledErrorMessages.join(\". \"))\n } else {\n const defaultValue = \"Couldn't submit because of validation errors.\"\n\n FlashNotifications.alert(configuration.translate(\"js.notification.couldnt_submit_because_of_validation_errors\", {defaultValue}))\n }\n // @ts-expect-error\n } else if (error.apiMakerType == \"BaseError\") {\n // @ts-expect-error\n if (error.args.response && error.args.response.errors) {\n const errors = /** @type {Array<string | {message: string}[]>} */ (digg(error, \"args\", \"response\", \"errors\"))\n const errorMessages = errors.map((error) => {\n if (typeof error == \"string\") {\n return error\n }\n\n return digg(error, \"message\")\n })\n\n FlashNotifications.error(errorMessages.join(\". \"))\n } else {\n throw error\n }\n } else {\n console.error(`Didnt know what to do with that ${error.constructor.name}: ${error.message}`)\n throw error\n }\n }\n\n /**\n * @param {string} message\n * @returns {void}\n */\n static success(message) {\n FlashNotifications.show({type: \"success\", text: message})\n }\n\n /**\n * @param {object} args\n * @param {string} args.text\n * @param {string} args.type\n * @returns {void}\n */\n static show(args) {\n let title\n\n if (args.type == \"alert\") {\n title = configuration.translate(\"js.shared.alert\", {defaultValue: \"Alert\"})\n } else if (args.type == \"error\") {\n title = configuration.translate(\"js.shared.error\", {defaultValue: \"Error\"})\n } else if (args.type == \"success\") {\n title = configuration.translate(\"js.shared.success\", {defaultValue: \"Success\"})\n } else {\n title = configuration.translate(\"js.shared.notification\", {defaultValue: \"Notification\"})\n }\n\n events.emit(\"pushNotification\", {\n message: args.text,\n title,\n type: args.type\n })\n }\n}\n"]}
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/src/","sources":["index.js"],"names":[],"mappings":"0BAE0B,oBAAoB;sBACxB,aAAa;+BACJ,0BAA0B"}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/src/","sources":["index.js"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,aAAa,MAAM,oBAAoB,CAAA;AAC9C,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,kBAAkB,MAAM,0BAA0B,CAAA;AAEzD,IAAI,CAAC,aAAa,EAAE,CAAC;IACnB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;AACnD,CAAC;AAED,OAAO,EACL,aAAa,EACb,SAAS,EACT,kBAAkB,EACnB,CAAA","sourcesContent":["// @ts-check\n\nimport configuration from \"./configuration.js\"\nimport Container from \"./container\"\nimport FlashNotifications from \"./flash-notifications.js\"\n\nif (!configuration) {\n throw new Error(\"No configuration object given?\")\n}\n\nexport {\n configuration,\n Container,\n FlashNotifications\n}\n"]}
|
package/build/listener.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"listener.d.ts","sourceRoot":"/src/","sources":["listener.js"],"names":[],"mappings":"AAEA;IAGE,sBAQC;IAVD,qBAAkB;IAYlB,2BAEC;IAED,+BA+BC;IAED,gDAEC;CACF"}
|
package/build/listener.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listener.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"listener.js","sourceRoot":"/src/","sources":["listener.js"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,MAAM,CAAC,OAAO,OAAO,0BAA0B;IAC7C,aAAa,GAAG,EAAE,CAAA;IAElB,MAAM,CAAC,OAAO;QACZ,IAAI,CAAC,UAAU,CAAC,0BAA0B,EAAE,CAAC;YAC3C,UAAU,CAAC,0BAA0B,GAAG,IAAI,0BAA0B,EAAE,CAAA;YAExE,UAAU,CAAC,0BAA0B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACvD,CAAC;QAED,OAAO,UAAU,CAAC,0BAA0B,CAAA;IAC9C,CAAC;IAED,OAAO,CAAC,MAAM;QACZ,MAAM,CAAC,WAAW,CAAC,kBAAkB,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\n\n static current() {\n if (!globalThis.flashNotificationsListener) {\n globalThis.flashNotificationsListener = new FlashNotificationsListener()\n\n globalThis.flashNotificationsListener.connect(events)\n }\n\n return globalThis.flashNotificationsListener\n }\n\n connect(events) {\n events.addListener(\"pushNotification\", this.onPushNotification)\n }\n\n findAndPop(argument) {\n for (const notificationIndex in this.notifications) {\n const notification = this.notifications[notificationIndex]\n let result\n\n if (typeof argument == \"function\") {\n result = argument(notification)\n } else if (typeof argument == \"object\") {\n let allEqual = true\n\n for (const key in argument) {\n const value = argument[key]\n\n if (value !== notification[key]) {\n allEqual = false\n }\n }\n\n result = allEqual\n } else {\n throw new Error(`Unknown type of argument: ${typeof argument}`)\n }\n\n if (result) {\n delete this.notifications[notificationIndex]\n\n return notification\n }\n }\n\n throw new Error(`Couldn't find the expected notification in: ${JSON.stringify(this.notifications)}`)\n }\n\n onPushNotification = (notification) => {\n this.notifications.push(notification)\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flash-notifications",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "My new module",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"env-sense": "^1.0.1",
|
|
42
42
|
"fetching-object": "^1.0.3",
|
|
43
43
|
"prop-types-exact": "*",
|
|
44
|
-
"set-state-compare": "^1.0.
|
|
44
|
+
"set-state-compare": "^1.0.61"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@testing-library/react-native": "~13.2.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"react-native": "~0.76.9"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@kaspernj/api-maker": ">= 1.0.
|
|
54
|
+
"@kaspernj/api-maker": ">= 1.0.2054",
|
|
55
55
|
"expo": "*",
|
|
56
56
|
"react": "*",
|
|
57
57
|
"react-native": "*"
|
package/src/container/index.jsx
CHANGED
|
@@ -4,7 +4,7 @@ import {digg} from "diggerize"
|
|
|
4
4
|
import PropTypes from "prop-types"
|
|
5
5
|
import propTypesExact from "prop-types-exact"
|
|
6
6
|
import React, {memo, useEffect, useMemo} from "react"
|
|
7
|
-
import {shapeComponent, ShapeComponent} from "set-state-compare/
|
|
7
|
+
import {shapeComponent, ShapeComponent} from "set-state-compare/build/shape-component.js"
|
|
8
8
|
import useBreakpoint from "@kaspernj/api-maker/build/use-breakpoint.js"
|
|
9
9
|
import useEventEmitter from "@kaspernj/api-maker/build/use-event-emitter.js"
|
|
10
10
|
import useEnvSense from "env-sense/src/use-env-sense.js"
|
|
@@ -30,7 +30,6 @@ export default memo(shapeComponent(class FlashNotificationsContainer extends Sha
|
|
|
30
30
|
timeouts = []
|
|
31
31
|
|
|
32
32
|
setup() {
|
|
33
|
-
// @ts-expect-error
|
|
34
33
|
this.useStates({
|
|
35
34
|
count: 0,
|
|
36
35
|
notifications: []
|
|
@@ -47,10 +46,7 @@ export default memo(shapeComponent(class FlashNotificationsContainer extends Sha
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
render() {
|
|
50
|
-
// @ts-expect-error
|
|
51
49
|
const {notifications} = this.s
|
|
52
|
-
|
|
53
|
-
// @ts-expect-error
|
|
54
50
|
const insets = this.props.insets || {}
|
|
55
51
|
|
|
56
52
|
const {smDown, mdUp} = useBreakpoint()
|
|
@@ -113,7 +109,6 @@ export default memo(shapeComponent(class FlashNotificationsContainer extends Sha
|
|
|
113
109
|
* @returns {void}
|
|
114
110
|
*/
|
|
115
111
|
onPushNotification = (detail) => {
|
|
116
|
-
// @ts-expect-error
|
|
117
112
|
const count = this.s.count + 1
|
|
118
113
|
const timeout = setTimeout(() => this.removeNotification(count), 4000)
|
|
119
114
|
|
|
@@ -135,7 +130,6 @@ export default memo(shapeComponent(class FlashNotificationsContainer extends Sha
|
|
|
135
130
|
removeNotification = (count) => {
|
|
136
131
|
// @ts-expect-error
|
|
137
132
|
this.setState({
|
|
138
|
-
// @ts-expect-error
|
|
139
133
|
notifications: this.s.notifications.filter((notification) => notification.count != count)
|
|
140
134
|
})
|
|
141
135
|
}
|
|
@@ -3,7 +3,7 @@ import PropTypes from "prop-types"
|
|
|
3
3
|
import PropTypesExact from "prop-types-exact"
|
|
4
4
|
import React, {memo, useMemo} from "react"
|
|
5
5
|
import {Pressable, StyleSheet, Text, View} from "react-native"
|
|
6
|
-
import {shapeComponent, ShapeComponent} from "set-state-compare/
|
|
6
|
+
import {shapeComponent, ShapeComponent} from "set-state-compare/build/shape-component.js"
|
|
7
7
|
import useStyles from "@kaspernj/api-maker/build/use-styles.js"
|
|
8
8
|
|
|
9
9
|
const styles = StyleSheet.create({
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
import BaseError from "@kaspernj/api-maker/build/base-error.js"
|
|
4
|
-
import ValidationError from "@kaspernj/api-maker/build/validation-error.js"
|
|
5
3
|
import {digg} from "diggerize"
|
|
6
4
|
|
|
7
5
|
import configuration from "./configuration.js"
|
|
@@ -29,7 +27,8 @@ export default class FlashNotifications {
|
|
|
29
27
|
* @returns {void}
|
|
30
28
|
*/
|
|
31
29
|
static errorResponse(error) {
|
|
32
|
-
|
|
30
|
+
// @ts-expect-error
|
|
31
|
+
if (error.apiMakerType == "ValidationError") {
|
|
33
32
|
// @ts-expect-error
|
|
34
33
|
if (error.hasUnhandledErrors()) {
|
|
35
34
|
// @ts-expect-error
|
|
@@ -41,7 +40,8 @@ export default class FlashNotifications {
|
|
|
41
40
|
|
|
42
41
|
FlashNotifications.alert(configuration.translate("js.notification.couldnt_submit_because_of_validation_errors", {defaultValue}))
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
// @ts-expect-error
|
|
44
|
+
} else if (error.apiMakerType == "BaseError") {
|
|
45
45
|
// @ts-expect-error
|
|
46
46
|
if (error.args.response && error.args.response.errors) {
|
|
47
47
|
const errors = /** @type {Array<string | {message: string}[]>} */ (digg(error, "args", "response", "errors"))
|
package/tsconfig.json
CHANGED