@reykjavik/webtools 0.3.12 → 0.3.13
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/CHANGELOG.md +7 -0
- package/README.md +32 -5
- package/alertsStore/index.d.ts +2 -2
- package/alertsStore/index.js +4 -1
- package/esm/alertsStore/index.d.ts +2 -2
- package/esm/alertsStore/index.js +4 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1034,17 +1034,44 @@ alerter.success({
|
|
|
1034
1034
|
message: 'All is good',
|
|
1035
1035
|
// flags: ['pristine'],
|
|
1036
1036
|
duration: 'MEDIUM',
|
|
1037
|
-
delay: 500, // Optional delay
|
|
1037
|
+
delay: 500, // Optional delay in milliseconds
|
|
1038
1038
|
});
|
|
1039
|
-
|
|
1040
|
-
|
|
1039
|
+
alerter.info('Simple message!'); // Shorthand syntax
|
|
1040
|
+
|
|
1041
|
+
// On the next event loop tick the "info" alert (with no delay) is emitted, and all
|
|
1042
|
+
// subscribers are notified. The subscriber in `appRoot.ts` will log the following;
|
|
1041
1043
|
/*
|
|
1042
1044
|
Current alerts: [
|
|
1043
1045
|
{
|
|
1044
|
-
id: '_234566-
|
|
1046
|
+
id: '_234566-28_', // auto-generated
|
|
1047
|
+
level: 'info',
|
|
1048
|
+
message: 'Simple message!',
|
|
1049
|
+
duration: 5000, // ms
|
|
1050
|
+
dismiss: <Function>,
|
|
1051
|
+
setFalgs: <Function>,
|
|
1052
|
+
}
|
|
1053
|
+
]
|
|
1054
|
+
Change type: 'add'
|
|
1055
|
+
Affected alert IDs: ['_234566-28_']
|
|
1056
|
+
*/
|
|
1057
|
+
|
|
1058
|
+
// Then after 500ms the "success" alert is added to the store, and all subscribers
|
|
1059
|
+
// are notified again. The subscriber in `appRoot.ts` will log the following;
|
|
1060
|
+
/*
|
|
1061
|
+
Current alerts: [
|
|
1062
|
+
{
|
|
1063
|
+
id: '_234566-28_',
|
|
1064
|
+
level: 'info',
|
|
1065
|
+
message: 'Simple message!',
|
|
1066
|
+
duration: 5000, // ms
|
|
1067
|
+
dismiss: <Function>,
|
|
1068
|
+
setFalgs: <Function>,
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
id: '_234566-27_',
|
|
1045
1072
|
level: 'success',
|
|
1046
1073
|
message: 'All is good',
|
|
1047
|
-
duration: 5000,
|
|
1074
|
+
duration: 5000,
|
|
1048
1075
|
dismiss: <Function>,
|
|
1049
1076
|
setFalgs: <Function>,
|
|
1050
1077
|
}
|
package/alertsStore/index.d.ts
CHANGED
|
@@ -121,7 +121,7 @@ export declare const createAlerterStore: <Level extends string = (typeof default
|
|
|
121
121
|
*
|
|
122
122
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#createalerterstore
|
|
123
123
|
*/
|
|
124
|
-
alerter: Record<Level, (payload: {
|
|
124
|
+
alerter: Record<Level, (payload: AlertMessage | ({
|
|
125
125
|
/**
|
|
126
126
|
* A simple string containing the alert message.
|
|
127
127
|
*
|
|
@@ -163,7 +163,7 @@ export declare const createAlerterStore: <Level extends string = (typeof default
|
|
|
163
163
|
* May also be used for more basic styling or categorization purposes.
|
|
164
164
|
*/
|
|
165
165
|
type?: Type;
|
|
166
|
-
})) => void>;
|
|
166
|
+
}))) => void>;
|
|
167
167
|
/**
|
|
168
168
|
* Subscribes to alert events. The provided callback will be called whenever a
|
|
169
169
|
* alert is added or cleared.
|
package/alertsStore/index.js
CHANGED
|
@@ -225,7 +225,10 @@ const createAlerterStore = (cfg = {}) => {
|
|
|
225
225
|
}, showAt - Date.now());
|
|
226
226
|
};
|
|
227
227
|
const _addAlert = (payload, level) => {
|
|
228
|
-
const
|
|
228
|
+
const _payload = typeof payload === 'string' || Array.isArray(payload)
|
|
229
|
+
? { message: payload }
|
|
230
|
+
: payload;
|
|
231
|
+
const notification = buildNotification(_payload, level);
|
|
229
232
|
if (!notification.showAt) {
|
|
230
233
|
// Notification starts active. Clone the array.
|
|
231
234
|
alerts.active = [...alerts.active, addMethodsToAlertInfo(notification)];
|
|
@@ -121,7 +121,7 @@ export declare const createAlerterStore: <Level extends string = (typeof default
|
|
|
121
121
|
*
|
|
122
122
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#createalerterstore
|
|
123
123
|
*/
|
|
124
|
-
alerter: Record<Level, (payload: {
|
|
124
|
+
alerter: Record<Level, (payload: AlertMessage | ({
|
|
125
125
|
/**
|
|
126
126
|
* A simple string containing the alert message.
|
|
127
127
|
*
|
|
@@ -163,7 +163,7 @@ export declare const createAlerterStore: <Level extends string = (typeof default
|
|
|
163
163
|
* May also be used for more basic styling or categorization purposes.
|
|
164
164
|
*/
|
|
165
165
|
type?: Type;
|
|
166
|
-
})) => void>;
|
|
166
|
+
}))) => void>;
|
|
167
167
|
/**
|
|
168
168
|
* Subscribes to alert events. The provided callback will be called whenever a
|
|
169
169
|
* alert is added or cleared.
|
package/esm/alertsStore/index.js
CHANGED
|
@@ -189,7 +189,10 @@ export const createAlerterStore = (cfg = {}) => {
|
|
|
189
189
|
}, showAt - Date.now());
|
|
190
190
|
};
|
|
191
191
|
const _addAlert = (payload, level) => {
|
|
192
|
-
const
|
|
192
|
+
const _payload = typeof payload === 'string' || Array.isArray(payload)
|
|
193
|
+
? { message: payload }
|
|
194
|
+
: payload;
|
|
195
|
+
const notification = buildNotification(_payload, level);
|
|
193
196
|
if (!notification.showAt) {
|
|
194
197
|
// Notification starts active. Clone the array.
|
|
195
198
|
alerts.active = [...alerts.active, addMethodsToAlertInfo(notification)];
|
package/package.json
CHANGED