flash-notifications 0.0.14 → 0.0.16

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":";AAIA,iCAAgE"}
@@ -0,0 +1,6 @@
1
+ if (!globalThis.flashNotificationsConfiguration) {
2
+ globalThis.flashNotificationsConfiguration = {};
3
+ }
4
+ const configuration = globalThis.flashNotificationsConfiguration;
5
+ export default configuration;
6
+ //# 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,EAAE,CAAA;AACjD,CAAC;AAED,MAAM,aAAa,GAAG,UAAU,CAAC,+BAA+B,CAAA;AAEhE,eAAe,aAAa,CAAA","sourcesContent":["if (!globalThis.flashNotificationsConfiguration) {\n globalThis.flashNotificationsConfiguration = {}\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":";;kBAE0B,OAAO"}
@@ -1,12 +1,10 @@
1
+ import useEventEmitter from "@kaspernj/api-maker/src/use-event-emitter";
2
+ import { digg } from "diggerize";
1
3
  import React, { memo } from "react";
2
- import { shapeComponent, ShapeComponent } from "set-state-compare/src/shape-component.js";
3
4
  import { StyleSheet, View } from "react-native";
4
- import { digg } from "diggerize";
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",
@@ -21,15 +19,14 @@ export default memo(shapeComponent(class FlashNotificationsContainer extends Sha
21
19
  count: 0,
22
20
  notifications: []
23
21
  });
24
- useEventListener(globalThis, "pushNotification", this.tt.onPushNotification);
22
+ useEventEmitter(events, "pushNotification", this.tt.onPushNotification);
25
23
  }
26
24
  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 }))));
25
+ return (React.createElement(View, { dataSet: this.rootViewDataSet ||= { class: "flash-notifications-container" }, 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 }))));
28
26
  }
29
- onPushNotification = (event) => {
30
- const detail = digg(event, "detail");
27
+ onPushNotification = (detail) => {
31
28
  const count = this.s.count + 1;
32
- // setTimeout(() => this.removeNotification(count), 4000)
29
+ setTimeout(() => this.removeNotification(count), 4000);
33
30
  const notification = {
34
31
  count,
35
32
  message: digg(detail, "message"),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/container/index.jsx"],"names":[],"mappings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AgB,EAC1C,KAAK,EAAE,YAAY,CAAC,KAAK,EACzB,IAAI,EAAE,YAAY,CAAC,IAAI,GACvB,CACH,CACI,CACR,CAAA;IACH,CAAC;IAED,kBAAkB,GAAG,CAAC,KAAK,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAA;QAE9B,yDAAyD;QAEzD,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,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,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,2CAA2C,CAAA;AACvE,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,KAAK,EAAE,EAAC,IAAI,EAAC,MAAM,OAAO,CAAA;AACjC,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,M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AAO,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,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,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/src/use-event-emitter\"\nimport {digg} from \"diggerize\"\nimport React, {memo} 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 setup() {\n this.useStates({\n count: 0,\n notifications: []\n })\n\n useEventEmitter(events, \"pushNotification\", this.tt.onPushNotification)\n }\n\n render() {\n return (\n <View\n dataSet={this.rootViewDataSet ||= {class: \"flash-notifications-container\"}}\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 = (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 +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,
@@ -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,EA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,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":[],"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,uCAAuC,CAAA;AAEpF,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;QACvC,eAAe,EAAE,qBAAqB;KACvC;IACD,SAAS,EAAE;QACT,MAAM,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AAC,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 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 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"]}
@@ -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
1
  import BaseError from "@kaspernj/api-maker/src/base-error";
2
2
  import ValidationError from "@kaspernj/api-maker/src/validation-error";
3
- export default class FlashMessage {
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":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oCAAoC,CAAA;AAC1D,OAAO,eAAe,MAAM,0CAA0C,CAAA;AAEtE,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,MAAM,CAAC,KAAK,CAAC,OAAO;QAClB,YAAY,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC,CAAA;IACnD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK;QAChB,IAAI,KAAK,YAAY,SAAS,EAAE,CAAC;YAC/B,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBACtD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAA;gBACxD,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;oBACzC,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;wBAC7B,OAAO,KAAK,CAAA;oBACd,CAAC;oBAED,OAAO,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;gBAC/B,CAAC,CAAC,CAAA;gBAEF,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC9C,CAAC;iBAAM,CAAC;gBACN,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;YAC5C,IAAI,KAAK,CAAC,kBAAkB,EAAE,EAAE,CAAC;gBAC/B,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC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AAC,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,oCAAoC,CAAA;AAC1D,OAAO,eAAe,MAAM,0CAA0C,CAAA;AACtE,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAE9B,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,OAAO,MAAM,MAAM,UAAU,CAAA;AAE7B,MAAM,CAAC,OAAO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ation-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.14",
3
+ "version": "0.0.16",
4
4
  "description": "My new module",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -29,15 +29,16 @@
29
29
  "license": "MIT",
30
30
  "homepage": "https://github.com/kaspernj/flash-notifications#readme",
31
31
  "dependencies": {
32
+ "classnames": "^2.5.1",
32
33
  "diggerize": "*",
33
34
  "prop-types-exact": "*",
34
35
  "set-state-compare": "*"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@types/react": "~18.3.12",
39
+ "expo": "~53.0.9",
38
40
  "expo-module-scripts": "^4.0.2",
39
- "expo": "~52.0.0",
40
- "react-native": "0.76.0"
41
+ "react-native": "~0.76.9"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "expo": "*",
package/peak_flow.yml ADDED
@@ -0,0 +1,4 @@
1
+ before_script:
2
+ - npm install
3
+ script:
4
+ - npm run lint
@@ -0,0 +1,7 @@
1
+ if (!globalThis.flashNotificationsConfiguration) {
2
+ globalThis.flashNotificationsConfiguration = {}
3
+ }
4
+
5
+ const configuration = globalThis.flashNotificationsConfiguration
6
+
7
+ export default configuration
@@ -1,13 +1,11 @@
1
+ import useEventEmitter from "@kaspernj/api-maker/src/use-event-emitter"
2
+ import {digg} from "diggerize"
1
3
  import React, {memo} from "react"
2
- import {shapeComponent, ShapeComponent} from "set-state-compare/src/shape-component.js"
3
4
  import {StyleSheet, View} from "react-native"
4
- import {digg} from "diggerize"
5
- import Notification from "./notification"
6
- import useEventListener from "@kaspernj/api-maker/src/use-event-listener"
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: {
@@ -25,13 +23,13 @@ export default memo(shapeComponent(class FlashNotificationsContainer extends Sha
25
23
  notifications: []
26
24
  })
27
25
 
28
- useEventListener(globalThis, "pushNotification", this.tt.onPushNotification)
26
+ useEventEmitter(events, "pushNotification", this.tt.onPushNotification)
29
27
  }
30
28
 
31
29
  render() {
32
30
  return (
33
31
  <View
34
- dataSet={dataSets.view}
32
+ dataSet={this.rootViewDataSet ||= {class: "flash-notifications-container"}}
35
33
  style={styles.view}
36
34
  >
37
35
  {this.s.notifications.map((notification) =>
@@ -48,11 +46,10 @@ export default memo(shapeComponent(class FlashNotificationsContainer extends Sha
48
46
  )
49
47
  }
50
48
 
51
- onPushNotification = (event) => {
52
- const detail = digg(event, "detail")
49
+ onPushNotification = (detail) => {
53
50
  const count = this.s.count + 1
54
51
 
55
- // setTimeout(() => this.removeNotification(count), 4000)
52
+ setTimeout(() => this.removeNotification(count), 4000)
56
53
 
57
54
  const notification = {
58
55
  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: {
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
1
  import BaseError from "@kaspernj/api-maker/src/base-error"
2
2
  import ValidationError from "@kaspernj/api-maker/src/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
  }