flash-notifications 0.0.15 → 0.0.17

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/.eslintrc.js CHANGED
@@ -2,4 +2,10 @@ module.exports = {
2
2
  root: true,
3
3
  extends: ['universe/native', 'universe/web'],
4
4
  ignorePatterns: ['build'],
5
- };
5
+ rules: {
6
+ "eqeqeq": "off",
7
+ "no-return-assign": "off",
8
+ "prettier/prettier": "off",
9
+ "react-hooks/rules-of-hooks": "off"
10
+ }
11
+ }
@@ -0,0 +1,3 @@
1
+ export default configuration;
2
+ declare const configuration: any;
3
+ //# sourceMappingURL=configuration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../src/configuration.js"],"names":[],"mappings":";AAMA,iCAAgE"}
@@ -0,0 +1,8 @@
1
+ if (!globalThis.flashNotificationsConfiguration) {
2
+ globalThis.flashNotificationsConfiguration = {
3
+ translate: (msgId) => msgId
4
+ };
5
+ }
6
+ const configuration = globalThis.flashNotificationsConfiguration;
7
+ export default configuration;
8
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/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,EAAE,CAAC,KAAK;KAC5B,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) => msgId\n }\n}\n\nconst configuration = globalThis.flashNotificationsConfiguration\n\nexport default configuration\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/container/index.jsx"],"names":[],"mappings":";;kBAA0B,OAAO"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/container/index.jsx"],"names":[],"mappings":";;kBAEqC,OAAO"}
@@ -1,12 +1,10 @@
1
- import React, { memo } from "react";
2
- import { shapeComponent, ShapeComponent } from "set-state-compare/src/shape-component.js";
3
- import { StyleSheet, View } from "react-native";
1
+ import useEventEmitter from "@kaspernj/api-maker/build/use-event-emitter";
4
2
  import { digg } from "diggerize";
3
+ import React, { memo, useEffect } from "react";
4
+ import { StyleSheet, View } from "react-native";
5
+ import { shapeComponent, ShapeComponent } from "set-state-compare/src/shape-component";
6
+ import events from "../events";
5
7
  import Notification from "./notification";
6
- import useEventListener from "@kaspernj/api-maker/src/use-event-listener";
7
- const dataSets = {
8
- view: { class: "flash-notifications-container" }
9
- };
10
8
  const styles = StyleSheet.create({
11
9
  view: {
12
10
  position: "fixed",
@@ -16,20 +14,28 @@ const styles = StyleSheet.create({
16
14
  }
17
15
  });
18
16
  export default memo(shapeComponent(class FlashNotificationsContainer extends ShapeComponent {
17
+ timeouts = [];
19
18
  setup() {
20
19
  this.useStates({
21
20
  count: 0,
22
21
  notifications: []
23
22
  });
24
- useEventListener(globalThis, "pushNotification", this.tt.onPushNotification);
23
+ useEventEmitter(events, "pushNotification", this.tt.onPushNotification);
24
+ useEffect(() => {
25
+ return () => {
26
+ for (const timeout of this.tt.timeouts) {
27
+ clearTimeout(timeout);
28
+ }
29
+ };
30
+ }, []);
25
31
  }
26
32
  render() {
27
- return (React.createElement(View, { dataSet: dataSets.view, style: styles.view }, this.s.notifications.map((notification) => React.createElement(Notification, { key: `notification-${notification.count}`, message: notification.message, notification: notification, onRemovedClicked: this.tt.onRemovedClicked, title: notification.title, type: notification.type }))));
33
+ return (React.createElement(View, { dataSet: this.rootViewDataSet ||= { component: "flash-notifications-container" }, style: styles.view, testID: "flash-notificaitons/container" }, this.s.notifications.map((notification) => React.createElement(Notification, { count: notification.count, key: `notification-${notification.count}`, message: notification.message, notification: notification, onRemovedClicked: this.tt.onRemovedClicked, title: notification.title, type: notification.type }))));
28
34
  }
29
- onPushNotification = (event) => {
30
- const detail = digg(event, "detail");
35
+ onPushNotification = (detail) => {
31
36
  const count = this.s.count + 1;
32
- setTimeout(() => this.removeNotification(count), 4000);
37
+ const timeout = setTimeout(() => this.removeNotification(count), 4000);
38
+ this.tt.timeouts.push(timeout);
33
39
  const notification = {
34
40
  count,
35
41
  message: digg(detail, "message"),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/container/index.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,IAAI,EAAC,MAAM,OAAO,CAAA;AACjC,OAAO,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,0CAA0C,CAAA;AACvF,OAAO,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,YAAY,MAAM,gBAAgB,CAAA;AACzC,OAAO,gBAAgB,MAAM,4CAA4C,CAAA;AAEzE,MAAM,QAAQ,GAAG;IACf,IAAI,EAAE,EAAC,KAAK,EAAE,+BAA+B,EAAC;CAC/C,CAAA;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,QAAQ,EAAE,OAAO;QACjB,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,EAAE;QACP,KAAK,EAAE,EAAE;KACV;CACF,CAAC,CAAA;AAEF,eAAe,IAAI,CAAC,cAAc,CAAC,MAAM,2BAA4B,SAAQ,cAAc;IACzF,KAAK;QACH,IAAI,CAAC,SAAS,CAAC;YACb,KAAK,EAAE,CAAC;YACR,aAAa,EAAE,EAAE;SAClB,CAAC,CAAA;QAEF,gBAAgB,CAAC,UAAU,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAA;IAC9E,CAAC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AI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAA;IAEzF,kBAAkB,GAAG,CAAC,KAAK,EAAE,EAAE;QAC7B,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":["import React, {memo} from \"react\"\nimport {shapeComponent, ShapeComponent} from \"set-state-compare/src/shape-component.js\"\nimport {StyleSheet, View} from \"react-native\"\nimport {digg} from \"diggerize\"\nimport Notification from \"./notification\"\nimport useEventListener from \"@kaspernj/api-maker/src/use-event-listener\"\n\nconst dataSets = {\n view: {class: \"flash-notifications-container\"}\n}\n\nconst styles = StyleSheet.create({\n view: {\n position: \"fixed\",\n zIndex: 99999,\n top: 20,\n right: 20\n }\n})\n\nexport default memo(shapeComponent(class FlashNotificationsContainer extends ShapeComponent {\n setup() {\n this.useStates({\n count: 0,\n notifications: []\n })\n\n useEventListener(globalThis, \"pushNotification\", this.tt.onPushNotification)\n }\n\n render() {\n return (\n <View\n dataSet={dataSets.view}\n style={styles.view}\n >\n {this.s.notifications.map((notification) =>\n <Notification\n key={`notification-${notification.count}`}\n message={notification.message}\n notification={notification}\n onRemovedClicked={this.tt.onRemovedClicked}\n title={notification.title}\n type={notification.type}\n />\n )}\n </View>\n )\n }\n\n onPushNotification = (event) => {\n const detail = digg(event, \"detail\")\n const count = this.s.count + 1\n\n setTimeout(() => this.removeNotification(count), 4000)\n\n const notification = {\n count,\n message: digg(detail, \"message\"),\n title: digg(detail, \"title\"),\n type: digg(detail, \"type\")\n }\n\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 this.setState({\n notifications: this.s.notifications.filter((notification) => notification.count != count)\n })\n }\n}))\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/container/index.jsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,6CAA6C,CAAA;AACzE,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,KAAK,EAAE,EAAC,IAAI,EAAE,SAAS,EAAC,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,uCAAuC,CAAA;AAEpF,OAAO,MAAM,MAAM,WAAW,CAAA;AAC9B,OAAO,YAAY,MAAM,gBAAgB,CAAA;AAEzC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,QAAQ,EAAE,OAAO;QACjB,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,EAAE;QACP,KAAK,EAAE,EAAE;KACV;CACF,CAAC,CAAA;AAEF,eAAe,IAAI,CAAC,cAAc,CAAC,MAAM,2BAA4B,SAAQ,cAAc;IACzF,QAAQ,GAAG,EAAE,CAAA;IAEb,KAAK;QACH,IAAI,CAAC,SAAS,CAAC;YACb,KAAK,EAAE,CAAC;YACR,aAAa,EAAE,EAAE;SAClB,CAAC,CAAA;QAEF,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAA;QACvE,SAAS,CAAC,GAAG,EAAE;YACb,OAAO,GAAG,EAAE;gBACV,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;oBACvC,YAAY,CAAC,OAAO,CAAC,CAAA;gBACvB,CAAC;YACH,CAAC,CAAA;QACH,CAAC,EAAE,EAAE,CAAC,CAAA;IACR,CAAC;IAED,MAAM;QACJ,OAAO,CACL,oBAAC,IAAI,IACH,OAAO,EAAE,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,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,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":["import useEventEmitter from \"@kaspernj/api-maker/build/use-event-emitter\"\nimport {digg} from \"diggerize\"\nimport React, {memo, useEffect} from \"react\"\nimport {StyleSheet, View} from \"react-native\"\nimport {shapeComponent, ShapeComponent} from \"set-state-compare/src/shape-component\"\n\nimport events from \"../events\"\nimport Notification from \"./notification\"\n\nconst styles = StyleSheet.create({\n view: {\n position: \"fixed\",\n zIndex: 99999,\n top: 20,\n right: 20\n }\n})\n\nexport default memo(shapeComponent(class FlashNotificationsContainer extends ShapeComponent {\n timeouts = []\n\n setup() {\n this.useStates({\n count: 0,\n notifications: []\n })\n\n useEventEmitter(events, \"pushNotification\", this.tt.onPushNotification)\n useEffect(() => {\n return () => {\n for (const timeout of this.tt.timeouts) {\n clearTimeout(timeout)\n }\n }\n }, [])\n }\n\n render() {\n return (\n <View\n dataSet={this.rootViewDataSet ||= {component: \"flash-notifications-container\"}}\n style={styles.view}\n testID=\"flash-notificaitons/container\"\n >\n {this.s.notifications.map((notification) =>\n <Notification\n count={notification.count}\n key={`notification-${notification.count}`}\n message={notification.message}\n notification={notification}\n onRemovedClicked={this.tt.onRemovedClicked}\n title={notification.title}\n type={notification.type}\n />\n )}\n </View>\n )\n }\n\n onPushNotification = (detail) => {\n const count = this.s.count + 1\n const timeout = setTimeout(() => this.removeNotification(count), 4000)\n\n this.tt.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 this.setState({count, notifications: this.s.notifications.concat([notification])})\n }\n\n onRemovedClicked = (notification) => this.removeNotification(digg(notification, \"count\"))\n\n removeNotification = (count) => {\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":["../../src/container/notification.jsx"],"names":[],"mappings":";;kBAEmC,OAAO"}
1
+ {"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../../src/container/notification.jsx"],"names":[],"mappings":";;kBAGmC,OAAO"}
@@ -1,9 +1,9 @@
1
- import { Pressable, StyleSheet, Text, View } from "react-native";
2
- import { shapeComponent, ShapeComponent } from "set-state-compare/src/shape-component.js";
3
- import React, { memo, useMemo } from "react";
4
1
  import classNames from "classnames";
5
2
  import PropTypes from "prop-types";
6
3
  import PropTypesExact from "prop-types-exact";
4
+ import React, { memo, useMemo } from "react";
5
+ import { Pressable, StyleSheet, Text, View } from "react-native";
6
+ import { shapeComponent, ShapeComponent } from "set-state-compare/src/shape-component";
7
7
  const styles = StyleSheet.create({
8
8
  view: {
9
9
  width: 300,
@@ -41,6 +41,7 @@ const messageViewDataSet = { class: "notification-message" };
41
41
  export default memo(shapeComponent(class NotificationsNotification extends ShapeComponent {
42
42
  static propTypes = PropTypesExact({
43
43
  className: PropTypes.string,
44
+ count: PropTypes.number.isRequired,
44
45
  message: PropTypes.string.isRequired,
45
46
  notification: PropTypes.object.isRequired,
46
47
  onRemovedClicked: PropTypes.func.isRequired,
@@ -48,7 +49,8 @@ export default memo(shapeComponent(class NotificationsNotification extends Shape
48
49
  type: PropTypes.string.isRequired
49
50
  });
50
51
  render() {
51
- const { className, message, title, type } = this.props;
52
+ const { count, message, title, type } = this.p;
53
+ const { className } = this.props;
52
54
  const viewStyles = useMemo(() => {
53
55
  const viewStyles = [styles.view];
54
56
  if (type == "error")
@@ -66,9 +68,9 @@ export default memo(shapeComponent(class NotificationsNotification extends Shape
66
68
  return (React.createElement(Pressable, { dataSet: pressableDataSet, onPress: this.tt.onRemovedClicked },
67
69
  React.createElement(View, { style: viewStyles },
68
70
  React.createElement(View, { dataSet: titleViewDataSet, style: styles.titleview },
69
- React.createElement(Text, { style: styles.titleText }, title)),
71
+ React.createElement(Text, { style: styles.titleText, testID: `flash-notifications/notification-${count}/title` }, title)),
70
72
  React.createElement(View, { dataSet: messageViewDataSet },
71
- React.createElement(Text, { style: styles.messageText }, message)))));
73
+ React.createElement(Text, { style: styles.messageText, testID: `flash-notifications/notification-${count}/message` }, message)))));
72
74
  }
73
75
  onRemovedClicked = () => this.p.onRemovedClicked(this.p.notification);
74
76
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"notification.js","sourceRoot":"","sources":["../../src/container/notification.jsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,0CAA0C,CAAA;AACvF,OAAO,KAAK,EAAE,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AAC1C,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAE7C,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,MAAM;QAChB,YAAY,EAAE,EAAE;QAChB,OAAO,EAAE,EAAE;QACX,YAAY,EAAE,EAAE;QAChB,MAAM,EAAE,SAAS;KAClB;IACD,SAAS,EAAE;QACT,MAAM,EAAE,mCAAmC;QAC3C,eAAe,EAAE,yBAAyB;KAC3C;IACD,WAAW,EAAE;QACX,MAAM,EAAE,+BAA+B;Q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I,IAAI,IAAI,OAAO;gBAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YAEtD,OAAO,UAAU,CAAA;QACnB,CAAC,EACD,CAAC,IAAI,CAAC,CACP,CAAA;QAED,MAAM,gBAAgB,GAAG,OAAO,CAC9B,GAAG,EAAE,CAAC,CAAC;YACL,KAAK,EAAE,UAAU,CAAC,kCAAkC,EAAE,SAAS,CAAC;YAChE,IAAI;SACL,CAAC,EACF,CAAC,SAAS,EAAE,IAAI,CAAC,CAClB,CAAA;QAED,OAAO,CACL,oBAAC,SAAS,IAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,gBAAgB;YACrE,oBAAC,IAAI,IAAC,KAAK,EAAE,UAAU;gBACrB,oBAAC,IAAI,IAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,CAAC,SAAS;oBACtD,oBAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,IAC1B,KAAK,CACD,CACF;gBACP,oBAAC,IAAI,IAAC,OAAO,EAAE,kBAAkB;oBAC/B,oBAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,WAAW,IAC5B,OAAO,CACH,CACF,CACF,CACG,CACb,CAAA;IACH,CAAC;IAED,gBAAgB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAA;CACtE,CAAC,CAAC,CAAA","sourcesContent":["import {Pressable, StyleSheet, Text, View} from \"react-native\"\nimport {shapeComponent, ShapeComponent} from \"set-state-compare/src/shape-component.js\"\nimport React, {memo, useMemo} from \"react\"\nimport classNames from \"classnames\"\nimport PropTypes from \"prop-types\"\nimport PropTypesExact from \"prop-types-exact\"\n\nconst styles = StyleSheet.create({\n view: {\n width: 300,\n maxWidth: \"100%\",\n marginBottom: 15,\n padding: 15,\n borderRadius: 11,\n cursor: \"pointer\"\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 NotificationsNotification extends ShapeComponent {\n static propTypes = PropTypesExact({\n className: PropTypes.string,\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 {className, message, title, type} = this.props\n\n const viewStyles = useMemo(\n () => {\n const viewStyles = [styles.view]\n\n if (type == \"error\") viewStyles.push(styles.viewError)\n if (type == \"success\") viewStyles.push(styles.viewSuccess)\n if (type == \"alert\") viewStyles.push(styles.viewAlert)\n\n return viewStyles\n },\n [type]\n )\n\n const pressableDataSet = useMemo(\n () => ({\n class: classNames(\"flash-notifications-notification\", className),\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}>\n {title}\n </Text>\n </View>\n <View dataSet={messageViewDataSet}>\n <Text style={styles.messageText}>\n {message}\n </Text>\n </View>\n </View>\n </Pressable>\n )\n }\n\n onRemovedClicked = () => this.p.onRemovedClicked(this.p.notification)\n}))\n"]}
1
+ {"version":3,"file":"notification.js","sourceRoot":"","sources":["../../src/container/notification.jsx"],"names":[],"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;YACrE,oBAAC,IAAI,IAAC,KAAK,EAAE,UAAU;gBACrB,oBAAC,IAAI,IAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,CAAC,SAAS;oBACtD,oBAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,oCAAoC,KAAK,QAAQ,IACrF,KAAK,CACD,CACF;gBACP,oBAAC,IAAI,IAAC,OAAO,EAAE,kBAAkB;oBAC/B,oBAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,oCAAoC,KAAK,UAAU,IACzF,OAAO,CACH,CACF,CACF,CACG,CACb,CAAA;IACH,CAAC;IAED,gBAAgB,GAAG,GAAG,EAAE,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/src/shape-component\"\n\nconst styles = StyleSheet.create({\n view: {\n width: 300,\n maxWidth: \"100%\",\n marginBottom: 15,\n padding: 15,\n borderRadius: 11,\n cursor: \"pointer\"\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 NotificationsNotification 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 = useMemo(\n () => {\n const viewStyles = [styles.view]\n\n if (type == \"error\") viewStyles.push(styles.viewError)\n if (type == \"success\") viewStyles.push(styles.viewSuccess)\n if (type == \"alert\") viewStyles.push(styles.viewAlert)\n\n return viewStyles\n },\n [type]\n )\n\n const pressableDataSet = useMemo(\n () => ({\n class: classNames(\"flash-notifications-notification\", className),\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"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.js"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import EventEmitter from "events";
2
+ if (!globalThis.flashNotificationsEvents) {
3
+ globalThis.flashNotificationsEvents = new EventEmitter();
4
+ }
5
+ export default globalThis.flashNotificationsEvents;
6
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/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,4 +1,4 @@
1
- export default class FlashMessage {
1
+ export default class FlashNotifications {
2
2
  static alert(message: any): void;
3
3
  static error(error: any): void;
4
4
  static errorResponse(error: any): void;
@@ -1 +1 @@
1
- {"version":3,"file":"flash-notifications.d.ts","sourceRoot":"","sources":["../src/flash-notifications.js"],"names":[],"mappings":"AAGA;IACE,iCAEC;IAED,+BA0BC;IAED,uCAEC;IAED,mCAEC;IAED,6BAsBC;CACF"}
1
+ {"version":3,"file":"flash-notifications.d.ts","sourceRoot":"","sources":["../src/flash-notifications.js"],"names":[],"mappings":"AAOA;IACE,iCAEC;IAED,+BA4BC;IAED,uCAEC;IAED,mCAEC;IAED,6BAkBC;CACF"}
@@ -1,8 +1,11 @@
1
- import BaseError from "@kaspernj/api-maker/src/base-error";
2
- import ValidationError from "@kaspernj/api-maker/src/validation-error";
3
- export default class FlashMessage {
1
+ import BaseError from "@kaspernj/api-maker/build/base-error";
2
+ import ValidationError from "@kaspernj/api-maker/build/validation-error";
3
+ import { digg } from "diggerize";
4
+ import configuration from "./configuration";
5
+ import events from "./events";
6
+ export default class FlashNotifications {
4
7
  static alert(message) {
5
- FlashMessage.show({ type: "alert", text: message });
8
+ FlashNotifications.show({ type: "alert", text: message });
6
9
  }
7
10
  static error(error) {
8
11
  if (error instanceof BaseError) {
@@ -14,7 +17,7 @@ export default class FlashMessage {
14
17
  }
15
18
  return digg(error, "message");
16
19
  });
17
- FlashMessage.alert(errorMessages.join(". "));
20
+ FlashNotifications.alert(errorMessages.join(". "));
18
21
  }
19
22
  else {
20
23
  throw error;
@@ -22,10 +25,11 @@ export default class FlashMessage {
22
25
  }
23
26
  else if (error instanceof ValidationError) {
24
27
  if (error.hasUnhandledErrors()) {
25
- FlashMessage.alert(error.message);
28
+ FlashNotifications.alert(error.message);
26
29
  }
27
30
  else {
28
- FlashMessage.alert(I18n.t("js.notification.couldnt_submit_because_of_validation_errors"));
31
+ const defaultValue = "Couldn't submit because of validation errors.";
32
+ FlashNotifications.alert(configuration.translate("js.notification.couldnt_submit_because_of_validation_errors", { defaultValue }));
29
33
  }
30
34
  }
31
35
  else {
@@ -37,30 +41,27 @@ export default class FlashMessage {
37
41
  this.error(error);
38
42
  }
39
43
  static success(message) {
40
- FlashMessage.show({ type: "success", text: message });
44
+ FlashNotifications.show({ type: "success", text: message });
41
45
  }
42
46
  static show(args) {
43
47
  let title;
44
48
  if (args.type == "alert") {
45
- title = I18n.t("js.shared.alert");
49
+ title = configuration.translate("js.shared.alert", { defaultValue: "Alert" });
46
50
  }
47
51
  else if (args.type == "error") {
48
- title = I18n.t("js.shared.error");
52
+ title = configuration.translate("js.shared.error", { defaultValue: "Error" });
49
53
  }
50
54
  else if (args.type == "success") {
51
- title = I18n.t("js.shared.success");
55
+ title = configuration.translate("js.shared.success", { defaultValue: "Success" });
52
56
  }
53
57
  else {
54
- title = I18n.t("js.shared.notification");
58
+ title = configuration.translate("js.shared.notification", { defaultValue: "Notification" });
55
59
  }
56
- const event = new CustomEvent("pushNotification", {
57
- detail: {
58
- message: args.text,
59
- title,
60
- type: args.type
61
- }
60
+ events.emit("pushNotification", {
61
+ message: args.text,
62
+ title,
63
+ type: args.type
62
64
  });
63
- globalThis.dispatchEvent(event);
64
65
  }
65
66
  }
66
67
  //# sourceMappingURL=flash-notifications.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flash-notifications.js","sourceRoot":"","sources":["../src/flash-notifications.js"],"names":[],"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AC;YACN,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAA;YAC7D,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,KAAK;QACxB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACnB,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,OAAO;QACpB,YAAY,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC,CAAA;IACrD,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,IAAI;QACd,IAAI,KAAK,CAAA;QAET,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;YACzB,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAA;QACnC,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;YAChC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAA;QACnC,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC;YAClC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAA;QACrC,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAA;QAC1C,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,kBAAkB,EAAE;YAChD,MAAM,EAAE;gBACN,OAAO,EAAE,IAAI,CAAC,IAAI;gBAClB,KAAK;gBACL,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB;SACF,CAAC,CAAA;QAEF,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IACjC,CAAC;CACF","sourcesContent":["import BaseError from \"@kaspernj/api-maker/src/base-error\"\nimport ValidationError from \"@kaspernj/api-maker/src/validation-error\"\n\nexport default class FlashMessage {\n static alert(message) {\n FlashMessage.show({type: \"alert\", text: message})\n }\n\n static error(error) {\n if (error instanceof BaseError) {\n if (error.args.response && error.args.response.errors) {\n const errors = 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 FlashMessage.alert(errorMessages.join(\". \"))\n } else {\n throw error\n }\n } else if (error instanceof ValidationError) {\n if (error.hasUnhandledErrors()) {\n FlashMessage.alert(error.message)\n } else {\n FlashMessage.alert(I18n.t(\"js.notification.couldnt_submit_because_of_validation_errors\"))\n }\n } else {\n console.error(\"Didnt know what to do with that error\", error)\n throw error\n }\n }\n\n static errorResponse(error) {\n this.error(error)\n }\n\n static success(message) {\n FlashMessage.show({type: \"success\", text: message})\n }\n\n static show(args) {\n let title\n\n if (args.type == \"alert\") {\n title = I18n.t(\"js.shared.alert\")\n } else if (args.type == \"error\") {\n title = I18n.t(\"js.shared.error\")\n } else if (args.type == \"success\") {\n title = I18n.t(\"js.shared.success\")\n } else {\n title = I18n.t(\"js.shared.notification\")\n }\n\n const event = new CustomEvent(\"pushNotification\", {\n detail: {\n message: args.text,\n title,\n type: args.type\n }\n })\n\n globalThis.dispatchEvent(event)\n }\n}\n"]}
1
+ {"version":3,"file":"flash-notifications.js","sourceRoot":"","sources":["../src/flash-notifications.js"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,sCAAsC,CAAA;AAC5D,OAAO,eAAe,MAAM,4CAA4C,CAAA;AACxE,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAE9B,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,OAAO,MAAM,MAAM,UAAU,CAAA;AAE7B,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACrC,MAAM,CAAC,KAAK,CAAC,OAAO;QAClB,kBAAkB,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC,CAAA;IACzD,C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A;IACnB,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,OAAO;QACpB,kBAAkB,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC,CAAA;IAC3D,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,IAAI;QACd,IAAI,KAAK,CAAA;QAET,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;YACzB,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,iBAAiB,EAAE,EAAC,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":["import BaseError from \"@kaspernj/api-maker/build/base-error\"\nimport ValidationError from \"@kaspernj/api-maker/build/validation-error\"\nimport {digg} from \"diggerize\"\n\nimport configuration from \"./configuration\"\nimport events from \"./events\"\n\nexport default class FlashNotifications {\n static alert(message) {\n FlashNotifications.show({type: \"alert\", text: message})\n }\n\n static error(error) {\n if (error instanceof BaseError) {\n if (error.args.response && error.args.response.errors) {\n const errors = 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.alert(errorMessages.join(\". \"))\n } else {\n throw error\n }\n } else if (error instanceof ValidationError) {\n if (error.hasUnhandledErrors()) {\n FlashNotifications.alert(error.message)\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 } else {\n console.error(\"Didnt know what to do with that error\", error)\n throw error\n }\n }\n\n static errorResponse(error) {\n this.error(error)\n }\n\n static success(message) {\n FlashNotifications.show({type: \"success\", text: message})\n }\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 CHANGED
@@ -1,4 +1,5 @@
1
+ import configuration from "./configuration";
1
2
  import Container from "./container";
2
3
  import FlashNotifications from "./flash-notifications";
3
- export { Container, FlashNotifications };
4
+ export { configuration, Container, FlashNotifications };
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"sBAAsB,aAAa;+BACJ,uBAAuB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"0BAA0B,iBAAiB;sBACrB,aAAa;+BACJ,uBAAuB"}
package/build/index.js CHANGED
@@ -1,4 +1,8 @@
1
+ import configuration from "./configuration";
1
2
  import Container from "./container";
2
3
  import FlashNotifications from "./flash-notifications";
3
- export { Container, FlashNotifications };
4
+ if (!configuration) {
5
+ throw new Error("No configuration object given?");
6
+ }
7
+ export { configuration, Container, FlashNotifications };
4
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,kBAAkB,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EACL,SAAS,EACT,kBAAkB,EACnB,CAAA","sourcesContent":["import Container from \"./container\"\nimport FlashNotifications from \"./flash-notifications\"\n\nexport {\n Container,\n FlashNotifications\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,kBAAkB,MAAM,uBAAuB,CAAA;AAEtD,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":["import configuration from \"./configuration\"\nimport Container from \"./container\"\nimport FlashNotifications from \"./flash-notifications\"\n\nif (!configuration) {\n throw new Error(\"No configuration object given?\")\n}\n\nexport {\n configuration,\n Container,\n FlashNotifications\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flash-notifications",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "My new module",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -8,7 +8,8 @@
8
8
  "build": "expo-module build",
9
9
  "clean": "expo-module clean",
10
10
  "lint": "expo-module lint",
11
- "test": "expo-module test",
11
+ "test": "jest --detectOpenHandles",
12
+ "test-expo": "expo-module test",
12
13
  "prepare": "expo-module prepare",
13
14
  "prepublishOnly": "expo-module prepublishOnly",
14
15
  "expo-module": "expo-module",
@@ -28,18 +29,28 @@
28
29
  "author": "kaspernj <kasper@diestoeckels.de> (https://github.com/kaspernj)",
29
30
  "license": "MIT",
30
31
  "homepage": "https://github.com/kaspernj/flash-notifications#readme",
32
+ "jest": {
33
+ "preset": "jest-expo",
34
+ "transformIgnorePatterns": [
35
+ "node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@sentry/react-native|native-base|react-native-svg|diggerize|fetching-object|set-state-compare|@kaspernj/api-maker)"
36
+ ]
37
+ },
31
38
  "dependencies": {
32
- "diggerize": "*",
39
+ "classnames": "^2.5.1",
40
+ "diggerize": "^1.0.9",
41
+ "fetching-object": "^1.0.3",
33
42
  "prop-types-exact": "*",
34
- "set-state-compare": "*"
43
+ "set-state-compare": "^1.0.57"
35
44
  },
36
45
  "devDependencies": {
46
+ "@testing-library/react-native": "~13.0.1",
37
47
  "@types/react": "~18.3.12",
48
+ "expo": "~53.0.9",
38
49
  "expo-module-scripts": "^4.0.2",
39
- "expo": "~52.0.0",
40
- "react-native": "0.76.0"
50
+ "react-native": "~0.76.9"
41
51
  },
42
52
  "peerDependencies": {
53
+ "@kaspernj/api-maker": "*",
43
54
  "expo": "*",
44
55
  "react": "*",
45
56
  "react-native": "*"
package/peak_flow.yml ADDED
@@ -0,0 +1,5 @@
1
+ before_script:
2
+ - npm install
3
+ script:
4
+ - npm run test
5
+ - npm run lint
@@ -0,0 +1,9 @@
1
+ if (!globalThis.flashNotificationsConfiguration) {
2
+ globalThis.flashNotificationsConfiguration = {
3
+ translate: (msgId) => msgId
4
+ }
5
+ }
6
+
7
+ const configuration = globalThis.flashNotificationsConfiguration
8
+
9
+ export default configuration
@@ -1,13 +1,11 @@
1
- import React, {memo} from "react"
2
- import {shapeComponent, ShapeComponent} from "set-state-compare/src/shape-component.js"
3
- import {StyleSheet, View} from "react-native"
1
+ import useEventEmitter from "@kaspernj/api-maker/build/use-event-emitter"
4
2
  import {digg} from "diggerize"
5
- import Notification from "./notification"
6
- import useEventListener from "@kaspernj/api-maker/src/use-event-listener"
3
+ import React, {memo, useEffect} from "react"
4
+ import {StyleSheet, View} from "react-native"
5
+ import {shapeComponent, ShapeComponent} from "set-state-compare/src/shape-component"
7
6
 
8
- const dataSets = {
9
- view: {class: "flash-notifications-container"}
10
- }
7
+ import events from "../events"
8
+ import Notification from "./notification"
11
9
 
12
10
  const styles = StyleSheet.create({
13
11
  view: {
@@ -19,23 +17,34 @@ const styles = StyleSheet.create({
19
17
  })
20
18
 
21
19
  export default memo(shapeComponent(class FlashNotificationsContainer extends ShapeComponent {
20
+ timeouts = []
21
+
22
22
  setup() {
23
23
  this.useStates({
24
24
  count: 0,
25
25
  notifications: []
26
26
  })
27
27
 
28
- useEventListener(globalThis, "pushNotification", this.tt.onPushNotification)
28
+ useEventEmitter(events, "pushNotification", this.tt.onPushNotification)
29
+ useEffect(() => {
30
+ return () => {
31
+ for (const timeout of this.tt.timeouts) {
32
+ clearTimeout(timeout)
33
+ }
34
+ }
35
+ }, [])
29
36
  }
30
37
 
31
38
  render() {
32
39
  return (
33
40
  <View
34
- dataSet={dataSets.view}
41
+ dataSet={this.rootViewDataSet ||= {component: "flash-notifications-container"}}
35
42
  style={styles.view}
43
+ testID="flash-notificaitons/container"
36
44
  >
37
45
  {this.s.notifications.map((notification) =>
38
46
  <Notification
47
+ count={notification.count}
39
48
  key={`notification-${notification.count}`}
40
49
  message={notification.message}
41
50
  notification={notification}
@@ -48,11 +57,11 @@ export default memo(shapeComponent(class FlashNotificationsContainer extends Sha
48
57
  )
49
58
  }
50
59
 
51
- onPushNotification = (event) => {
52
- const detail = digg(event, "detail")
60
+ onPushNotification = (detail) => {
53
61
  const count = this.s.count + 1
62
+ const timeout = setTimeout(() => this.removeNotification(count), 4000)
54
63
 
55
- setTimeout(() => this.removeNotification(count), 4000)
64
+ this.tt.timeouts.push(timeout)
56
65
 
57
66
  const notification = {
58
67
  count,
@@ -1,9 +1,9 @@
1
- import {Pressable, StyleSheet, Text, View} from "react-native"
2
- import {shapeComponent, ShapeComponent} from "set-state-compare/src/shape-component.js"
3
- import React, {memo, useMemo} from "react"
4
1
  import classNames from "classnames"
5
2
  import PropTypes from "prop-types"
6
3
  import PropTypesExact from "prop-types-exact"
4
+ import React, {memo, useMemo} from "react"
5
+ import {Pressable, StyleSheet, Text, View} from "react-native"
6
+ import {shapeComponent, ShapeComponent} from "set-state-compare/src/shape-component"
7
7
 
8
8
  const styles = StyleSheet.create({
9
9
  view: {
@@ -44,6 +44,7 @@ const messageViewDataSet = {class: "notification-message"}
44
44
  export default memo(shapeComponent(class NotificationsNotification extends ShapeComponent {
45
45
  static propTypes = PropTypesExact({
46
46
  className: PropTypes.string,
47
+ count: PropTypes.number.isRequired,
47
48
  message: PropTypes.string.isRequired,
48
49
  notification: PropTypes.object.isRequired,
49
50
  onRemovedClicked: PropTypes.func.isRequired,
@@ -52,7 +53,8 @@ export default memo(shapeComponent(class NotificationsNotification extends Shape
52
53
  })
53
54
 
54
55
  render() {
55
- const {className, message, title, type} = this.props
56
+ const {count, message, title, type} = this.p
57
+ const {className} = this.props
56
58
 
57
59
  const viewStyles = useMemo(
58
60
  () => {
@@ -79,12 +81,12 @@ export default memo(shapeComponent(class NotificationsNotification extends Shape
79
81
  <Pressable dataSet={pressableDataSet} onPress={this.tt.onRemovedClicked}>
80
82
  <View style={viewStyles}>
81
83
  <View dataSet={titleViewDataSet} style={styles.titleview}>
82
- <Text style={styles.titleText}>
84
+ <Text style={styles.titleText} testID={`flash-notifications/notification-${count}/title`}>
83
85
  {title}
84
86
  </Text>
85
87
  </View>
86
88
  <View dataSet={messageViewDataSet}>
87
- <Text style={styles.messageText}>
89
+ <Text style={styles.messageText} testID={`flash-notifications/notification-${count}/message`}>
88
90
  {message}
89
91
  </Text>
90
92
  </View>
package/src/events.js ADDED
@@ -0,0 +1,7 @@
1
+ import EventEmitter from "events"
2
+
3
+ if (!globalThis.flashNotificationsEvents) {
4
+ globalThis.flashNotificationsEvents = new EventEmitter()
5
+ }
6
+
7
+ export default globalThis.flashNotificationsEvents
@@ -1,9 +1,13 @@
1
- import BaseError from "@kaspernj/api-maker/src/base-error"
2
- import ValidationError from "@kaspernj/api-maker/src/validation-error"
1
+ import BaseError from "@kaspernj/api-maker/build/base-error"
2
+ import ValidationError from "@kaspernj/api-maker/build/validation-error"
3
+ import {digg} from "diggerize"
3
4
 
4
- export default class FlashMessage {
5
+ import configuration from "./configuration"
6
+ import events from "./events"
7
+
8
+ export default class FlashNotifications {
5
9
  static alert(message) {
6
- FlashMessage.show({type: "alert", text: message})
10
+ FlashNotifications.show({type: "alert", text: message})
7
11
  }
8
12
 
9
13
  static error(error) {
@@ -18,15 +22,17 @@ export default class FlashMessage {
18
22
  return digg(error, "message")
19
23
  })
20
24
 
21
- FlashMessage.alert(errorMessages.join(". "))
25
+ FlashNotifications.alert(errorMessages.join(". "))
22
26
  } else {
23
27
  throw error
24
28
  }
25
29
  } else if (error instanceof ValidationError) {
26
30
  if (error.hasUnhandledErrors()) {
27
- FlashMessage.alert(error.message)
31
+ FlashNotifications.alert(error.message)
28
32
  } else {
29
- FlashMessage.alert(I18n.t("js.notification.couldnt_submit_because_of_validation_errors"))
33
+ const defaultValue = "Couldn't submit because of validation errors."
34
+
35
+ FlashNotifications.alert(configuration.translate("js.notification.couldnt_submit_because_of_validation_errors", {defaultValue}))
30
36
  }
31
37
  } else {
32
38
  console.error("Didnt know what to do with that error", error)
@@ -39,30 +45,26 @@ export default class FlashMessage {
39
45
  }
40
46
 
41
47
  static success(message) {
42
- FlashMessage.show({type: "success", text: message})
48
+ FlashNotifications.show({type: "success", text: message})
43
49
  }
44
50
 
45
51
  static show(args) {
46
52
  let title
47
53
 
48
54
  if (args.type == "alert") {
49
- title = I18n.t("js.shared.alert")
55
+ title = configuration.translate("js.shared.alert", {defaultValue: "Alert"})
50
56
  } else if (args.type == "error") {
51
- title = I18n.t("js.shared.error")
57
+ title = configuration.translate("js.shared.error", {defaultValue: "Error"})
52
58
  } else if (args.type == "success") {
53
- title = I18n.t("js.shared.success")
59
+ title = configuration.translate("js.shared.success", {defaultValue: "Success"})
54
60
  } else {
55
- title = I18n.t("js.shared.notification")
61
+ title = configuration.translate("js.shared.notification", {defaultValue: "Notification"})
56
62
  }
57
63
 
58
- const event = new CustomEvent("pushNotification", {
59
- detail: {
60
- message: args.text,
61
- title,
62
- type: args.type
63
- }
64
+ events.emit("pushNotification", {
65
+ message: args.text,
66
+ title,
67
+ type: args.type
64
68
  })
65
-
66
- globalThis.dispatchEvent(event)
67
69
  }
68
70
  }
package/src/index.js CHANGED
@@ -1,7 +1,13 @@
1
+ import configuration from "./configuration"
1
2
  import Container from "./container"
2
3
  import FlashNotifications from "./flash-notifications"
3
4
 
5
+ if (!configuration) {
6
+ throw new Error("No configuration object given?")
7
+ }
8
+
4
9
  export {
10
+ configuration,
5
11
  Container,
6
12
  FlashNotifications
7
13
  }