@frontile/notifications 0.15.0 → 0.16.0-alpha.0
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/addon-main.js +4 -0
- package/{-private → declarations/-private}/get-config.d.ts +2 -1
- package/declarations/-private/get-config.d.ts.map +1 -0
- package/{-private → declarations/-private}/manager.d.ts +2 -1
- package/declarations/-private/manager.d.ts.map +1 -0
- package/{-private → declarations/-private}/notification.d.ts +2 -1
- package/declarations/-private/notification.d.ts.map +1 -0
- package/{-private → declarations/-private}/timer.d.ts +1 -0
- package/declarations/-private/timer.d.ts.map +1 -0
- package/{-private → declarations/-private}/types.d.ts +2 -0
- package/declarations/-private/types.d.ts.map +1 -0
- package/{components → declarations/components}/notification-card.d.ts +6 -4
- package/declarations/components/notification-card.d.ts.map +1 -0
- package/{components → declarations/components}/notifications-container.d.ts +6 -4
- package/declarations/components/notifications-container.d.ts.map +1 -0
- package/declarations/get-config-a59d13fc.d.ts +3 -0
- package/{index.d.ts → declarations/index.d.ts} +1 -0
- package/declarations/index.d.ts.map +1 -0
- package/declarations/notification-64b501e5.d.ts +15 -0
- package/declarations/notifications-02bGKw8W.d.ts +10 -0
- package/declarations/notifications-6S2s2xJm.d.ts +10 -0
- package/{services → declarations/services}/notifications.d.ts +4 -1
- package/declarations/services/notifications.d.ts.map +1 -0
- package/declarations/template-registry.d.ts +7 -0
- package/declarations/template-registry.d.ts.map +1 -0
- package/declarations/timer-dbe538e6.d.ts +13 -0
- package/declarations/types-16c08671.d.ts +55 -0
- package/dist/_app_/components/notification-card.js +1 -0
- package/dist/_app_/components/notifications-container.js +1 -0
- package/dist/_app_/services/notifications.js +1 -0
- package/dist/components/notification-card.js +105 -0
- package/dist/components/notification-card.js.map +1 -0
- package/dist/components/notifications-container.js +53 -0
- package/dist/components/notifications-container.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/notifications-02bGKw8W.js +185 -0
- package/dist/notifications-02bGKw8W.js.map +1 -0
- package/dist/services/notifications.js +4 -0
- package/dist/services/notifications.js.map +1 -0
- package/dist/template-registry.js +2 -0
- package/dist/template-registry.js.map +1 -0
- package/package.json +78 -45
- package/addon/-private/get-config.ts +0 -19
- package/addon/-private/manager.ts +0 -61
- package/addon/-private/notification.ts +0 -42
- package/addon/-private/timer.ts +0 -51
- package/addon/-private/types.ts +0 -66
- package/addon/components/notification-card.hbs +0 -44
- package/addon/components/notification-card.ts +0 -105
- package/addon/components/notifications-container.hbs +0 -19
- package/addon/components/notifications-container.md +0 -9
- package/addon/components/notifications-container.ts +0 -56
- package/addon/index.ts +0 -12
- package/addon/services/notifications.ts +0 -36
- package/app/components/notification-card.js +0 -1
- package/app/components/notifications-container.js +0 -1
- package/app/services/notifications.js +0 -1
- package/config/environment.js +0 -5
- package/docs/notifications-usage-demo/demo.md +0 -153
- package/docs/notifications-usage.md +0 -6
- package/index.js +0 -5
- package/tsconfig.json +0 -23
- package/types/dummy/index.d.ts +0 -0
- package/types/ember-get-config.d.ts +0 -3
- package/types/global.d.ts +0 -6
- package/types/index.d.ts +0 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import Service from '@ember/service';
|
|
3
|
+
import _initializerDefineProperty from '@babel/runtime/helpers/esm/initializerDefineProperty';
|
|
4
|
+
import _applyDecoratedDescriptor from '@babel/runtime/helpers/esm/applyDecoratedDescriptor';
|
|
5
|
+
import '@babel/runtime/helpers/esm/initializerWarningHelper';
|
|
6
|
+
import { tracked } from '@glimmer/tracking';
|
|
7
|
+
import { cancel, later } from '@ember/runloop';
|
|
8
|
+
import { action, get } from '@ember/object';
|
|
9
|
+
import config from 'ember-get-config';
|
|
10
|
+
|
|
11
|
+
var _class$2, _descriptor$2, _descriptor2$1;
|
|
12
|
+
let Timer = (_class$2 = class Timer {
|
|
13
|
+
constructor(duration, onFinish) {
|
|
14
|
+
_initializerDefineProperty(this, "remaining", _descriptor$2, this);
|
|
15
|
+
_initializerDefineProperty(this, "isRunning", _descriptor2$1, this);
|
|
16
|
+
_defineProperty(this, "onFinish", void 0);
|
|
17
|
+
_defineProperty(this, "timer", void 0);
|
|
18
|
+
_defineProperty(this, "start", void 0);
|
|
19
|
+
this.remaining = duration;
|
|
20
|
+
this.onFinish = onFinish;
|
|
21
|
+
this.setup();
|
|
22
|
+
}
|
|
23
|
+
clear() {
|
|
24
|
+
this.isRunning = false;
|
|
25
|
+
if (this.timer) {
|
|
26
|
+
cancel(this.timer);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
pause() {
|
|
30
|
+
this.clear();
|
|
31
|
+
this.remaining -= Date.now() - this.start;
|
|
32
|
+
}
|
|
33
|
+
resume() {
|
|
34
|
+
this.clear();
|
|
35
|
+
this.setup();
|
|
36
|
+
}
|
|
37
|
+
setup() {
|
|
38
|
+
this.start = Date.now();
|
|
39
|
+
this.isRunning = true;
|
|
40
|
+
this.timer = later(this, () => {
|
|
41
|
+
this.onFinish();
|
|
42
|
+
this.isRunning = false;
|
|
43
|
+
}, this.remaining);
|
|
44
|
+
}
|
|
45
|
+
}, (_descriptor$2 = _applyDecoratedDescriptor(_class$2.prototype, "remaining", [tracked], {
|
|
46
|
+
configurable: true,
|
|
47
|
+
enumerable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
initializer: null
|
|
50
|
+
}), _descriptor2$1 = _applyDecoratedDescriptor(_class$2.prototype, "isRunning", [tracked], {
|
|
51
|
+
configurable: true,
|
|
52
|
+
enumerable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
initializer: function () {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}), _applyDecoratedDescriptor(_class$2.prototype, "clear", [action], Object.getOwnPropertyDescriptor(_class$2.prototype, "clear"), _class$2.prototype), _applyDecoratedDescriptor(_class$2.prototype, "pause", [action], Object.getOwnPropertyDescriptor(_class$2.prototype, "pause"), _class$2.prototype), _applyDecoratedDescriptor(_class$2.prototype, "resume", [action], Object.getOwnPropertyDescriptor(_class$2.prototype, "resume"), _class$2.prototype)), _class$2);
|
|
58
|
+
|
|
59
|
+
function getConfigOption(key, defaultValue) {
|
|
60
|
+
const value = get(config['@frontile/notifications'] || {}, key);
|
|
61
|
+
if (value === undefined) {
|
|
62
|
+
return defaultValue;
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var _class$1, _descriptor$1, _descriptor2;
|
|
68
|
+
let Notification = (_class$1 = class Notification {
|
|
69
|
+
constructor(message, options = {}) {
|
|
70
|
+
_defineProperty(this, "message", void 0);
|
|
71
|
+
_defineProperty(this, "transitionDuration", void 0);
|
|
72
|
+
_defineProperty(this, "appearance", void 0);
|
|
73
|
+
_defineProperty(this, "customActions", void 0);
|
|
74
|
+
_defineProperty(this, "allowClosing", void 0);
|
|
75
|
+
_defineProperty(this, "duration", void 0);
|
|
76
|
+
_initializerDefineProperty(this, "timer", _descriptor$1, this);
|
|
77
|
+
_initializerDefineProperty(this, "isRemoving", _descriptor2, this);
|
|
78
|
+
this.message = message;
|
|
79
|
+
this.appearance = options.appearance || getConfigOption('appearance', 'info');
|
|
80
|
+
this.customActions = options.customActions;
|
|
81
|
+
this.duration = options.duration || getConfigOption('duration', 5000);
|
|
82
|
+
this.transitionDuration = typeof options.transitionDuration !== 'undefined' ? options.transitionDuration : getConfigOption('transitionDuration', 200);
|
|
83
|
+
if (options.allowClosing === false) {
|
|
84
|
+
this.allowClosing = false;
|
|
85
|
+
} else {
|
|
86
|
+
this.allowClosing = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
remove() {
|
|
90
|
+
this.isRemoving = true;
|
|
91
|
+
if (this.timer) {
|
|
92
|
+
this.timer.clear();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, (_descriptor$1 = _applyDecoratedDescriptor(_class$1.prototype, "timer", [tracked], {
|
|
96
|
+
configurable: true,
|
|
97
|
+
enumerable: true,
|
|
98
|
+
writable: true,
|
|
99
|
+
initializer: null
|
|
100
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class$1.prototype, "isRemoving", [tracked], {
|
|
101
|
+
configurable: true,
|
|
102
|
+
enumerable: true,
|
|
103
|
+
writable: true,
|
|
104
|
+
initializer: function () {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
})), _class$1);
|
|
108
|
+
|
|
109
|
+
var _class, _descriptor;
|
|
110
|
+
let NotificationsManager = (_class = class NotificationsManager {
|
|
111
|
+
constructor() {
|
|
112
|
+
_initializerDefineProperty(this, "notifications", _descriptor, this);
|
|
113
|
+
}
|
|
114
|
+
add(message, options = {}) {
|
|
115
|
+
const notification = new Notification(message, options);
|
|
116
|
+
this.notifications = [...this.notifications, notification];
|
|
117
|
+
let preserve = typeof options.preserve === 'undefined' ? getConfigOption('preserve', false) : options.preserve;
|
|
118
|
+
|
|
119
|
+
// if default config has set skipTimer to true, we will preserve the
|
|
120
|
+
// notification, therefore skiping the timer
|
|
121
|
+
if (getConfigOption('skipTimer', false) === true) {
|
|
122
|
+
preserve = true;
|
|
123
|
+
}
|
|
124
|
+
if (preserve === false) {
|
|
125
|
+
this.setupAutoRemoval(notification, notification.duration);
|
|
126
|
+
}
|
|
127
|
+
return notification;
|
|
128
|
+
}
|
|
129
|
+
remove(notification) {
|
|
130
|
+
if (!notification) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
notification.remove();
|
|
134
|
+
later(this, () => {
|
|
135
|
+
this.notifications = this.notifications.filter(n => {
|
|
136
|
+
return n !== notification;
|
|
137
|
+
});
|
|
138
|
+
}, notification.transitionDuration);
|
|
139
|
+
}
|
|
140
|
+
removeAll() {
|
|
141
|
+
this.notifications.forEach(notification => {
|
|
142
|
+
this.remove(notification);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
setupAutoRemoval(notification, duration) {
|
|
146
|
+
notification.timer = new Timer(duration, () => {
|
|
147
|
+
this.remove(notification);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "notifications", [tracked], {
|
|
151
|
+
configurable: true,
|
|
152
|
+
enumerable: true,
|
|
153
|
+
writable: true,
|
|
154
|
+
initializer: function () {
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
})), _class);
|
|
158
|
+
|
|
159
|
+
class NotificationsService extends Service {
|
|
160
|
+
constructor(...args) {
|
|
161
|
+
super(...args);
|
|
162
|
+
_defineProperty(this, "manager", new NotificationsManager());
|
|
163
|
+
_defineProperty(this, "add", (message, options) => {
|
|
164
|
+
return this.manager.add(message, options);
|
|
165
|
+
});
|
|
166
|
+
_defineProperty(this, "remove", notification => {
|
|
167
|
+
this.manager.remove(notification);
|
|
168
|
+
});
|
|
169
|
+
_defineProperty(this, "removeAll", () => {
|
|
170
|
+
this.manager.removeAll();
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
get notifications() {
|
|
174
|
+
return this.manager.notifications;
|
|
175
|
+
}
|
|
176
|
+
willDestroy() {
|
|
177
|
+
this.removeAll();
|
|
178
|
+
super.willDestroy();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// DO NOT DELETE: this is how TypeScript knows how to look up your services.
|
|
183
|
+
|
|
184
|
+
export { Notification as N, Timer as T, NotificationsService as a };
|
|
185
|
+
//# sourceMappingURL=notifications-02bGKw8W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications-02bGKw8W.js","sources":["../src/-private/timer.ts","../src/-private/get-config.ts","../src/-private/notification.ts","../src/-private/manager.ts","../src/services/notifications.ts"],"sourcesContent":["import { tracked } from '@glimmer/tracking';\nimport { later, cancel } from '@ember/runloop';\nimport type { Timer as EmberTimer } from '@ember/runloop';\nimport { action } from '@ember/object';\n\nexport default class Timer {\n @tracked remaining: number;\n @tracked isRunning = true;\n\n readonly onFinish: () => void;\n private timer?: EmberTimer;\n private start!: number;\n\n constructor(duration: number, onFinish: () => void) {\n this.remaining = duration;\n this.onFinish = onFinish;\n this.setup();\n }\n\n @action clear(): void {\n this.isRunning = false;\n\n if (this.timer) {\n cancel(this.timer);\n }\n }\n\n @action pause(): void {\n this.clear();\n this.remaining -= Date.now() - this.start;\n }\n\n @action resume(): void {\n this.clear();\n this.setup();\n }\n\n private setup(): void {\n this.start = Date.now();\n this.isRunning = true;\n\n this.timer = later(\n this,\n () => {\n this.onFinish();\n this.isRunning = false;\n },\n this.remaining\n );\n }\n}\n","import config from 'ember-get-config';\nimport { get } from '@ember/object';\nimport type { DefaultConfig } from './types';\n\nexport function getConfigOption<T extends keyof DefaultConfig>(\n key: T,\n defaultValue: NonNullable<DefaultConfig[T]>\n): NonNullable<DefaultConfig[T]> {\n const value = get(\n config['@frontile/notifications'] || ({} as never),\n key as never\n );\n\n if (value === undefined) {\n return defaultValue;\n }\n\n return value;\n}\n","import { tracked } from '@glimmer/tracking';\nimport Timer from './timer';\nimport { getConfigOption } from './get-config';\nimport type { NotificationOptions, CustomAction } from './types';\n\nexport default class Notification {\n readonly message: string;\n readonly transitionDuration: number;\n readonly appearance: NonNullable<NotificationOptions['appearance']>;\n readonly customActions?: CustomAction[];\n readonly allowClosing: boolean;\n readonly duration: number;\n\n @tracked timer?: Timer;\n @tracked isRemoving = false;\n\n constructor(message: string, options: NotificationOptions = {}) {\n this.message = message;\n this.appearance =\n options.appearance || getConfigOption('appearance', 'info');\n this.customActions = options.customActions;\n this.duration = options.duration || getConfigOption('duration', 5000);\n this.transitionDuration =\n typeof options.transitionDuration !== 'undefined'\n ? options.transitionDuration\n : getConfigOption('transitionDuration', 200);\n\n if (options.allowClosing === false) {\n this.allowClosing = false;\n } else {\n this.allowClosing = true;\n }\n }\n\n remove(): void {\n this.isRemoving = true;\n\n if (this.timer) {\n this.timer.clear();\n }\n }\n}\n","import Notification from './notification';\nimport Timer from './timer';\nimport { getConfigOption } from './get-config';\nimport { tracked } from '@glimmer/tracking';\nimport { later } from '@ember/runloop';\nimport type { NotificationOptions } from './types';\n\nexport default class NotificationsManager {\n @tracked notifications: Notification[] = [];\n\n add(message: string, options: NotificationOptions = {}): Notification {\n const notification = new Notification(message, options);\n this.notifications = [...this.notifications, notification];\n\n let preserve =\n typeof options.preserve === 'undefined'\n ? getConfigOption('preserve', false)\n : options.preserve;\n\n // if default config has set skipTimer to true, we will preserve the\n // notification, therefore skiping the timer\n if (getConfigOption('skipTimer', false) === true) {\n preserve = true;\n }\n\n if (preserve === false) {\n this.setupAutoRemoval(notification, notification.duration);\n }\n return notification;\n }\n\n remove(notification?: Notification): void {\n if (!notification) {\n return;\n }\n\n notification.remove();\n\n later(\n this,\n () => {\n this.notifications = this.notifications.filter((n) => {\n return n !== notification;\n });\n },\n notification.transitionDuration\n );\n }\n\n removeAll(): void {\n this.notifications.forEach((notification) => {\n this.remove(notification);\n });\n }\n\n private setupAutoRemoval(notification: Notification, duration: number): void {\n notification.timer = new Timer(duration, () => {\n this.remove(notification);\n });\n }\n}\n","import Service from '@ember/service';\nimport Notification from '../-private/notification';\nimport NotificationsManager from '../-private/manager';\nimport type { NotificationOptions } from '../-private/types';\n\nexport default class NotificationsService extends Service {\n manager = new NotificationsManager();\n\n get notifications(): Notification[] {\n return this.manager.notifications;\n }\n\n add = (message: string, options?: NotificationOptions): Notification => {\n return this.manager.add(message, options);\n };\n\n remove = (notification?: Notification): void => {\n this.manager.remove(notification);\n };\n\n removeAll = (): void => {\n this.manager.removeAll();\n };\n\n willDestroy(): void {\n this.removeAll();\n super.willDestroy();\n }\n}\n\n// DO NOT DELETE: this is how TypeScript knows how to look up your services.\ndeclare module '@ember/service' {\n interface Registry {\n notifications: NotificationsService;\n }\n}\n"],"names":["Timer","_class","constructor","duration","onFinish","_initializerDefineProperty","_descriptor","_descriptor2","_defineProperty","remaining","setup","clear","isRunning","timer","cancel","pause","Date","now","start","resume","later","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","getConfigOption","key","defaultValue","value","get","config","undefined","Notification","message","options","appearance","customActions","transitionDuration","allowClosing","remove","isRemoving","NotificationsManager","add","notification","notifications","preserve","setupAutoRemoval","filter","n","removeAll","forEach","NotificationsService","Service","args","manager","willDestroy"],"mappings":";;;;;;;;;;;AAGuC,IAElBA,KAAK,IAAAC,QAAA,GAAX,MAAMD,KAAK,CAAC;AAQzBE,EAAAA,WAAWA,CAACC,QAAgB,EAAEC,QAAoB,EAAE;AAAAC,IAAAA,0BAAA,oBAAAC,aAAA,EAAA,IAAA,CAAA,CAAA;AAAAD,IAAAA,0BAAA,oBAAAE,cAAA,EAAA,IAAA,CAAA,CAAA;IAAAC,eAAA,CAAA,IAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;IAAAA,eAAA,CAAA,IAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA,CAAA;IAAAA,eAAA,CAAA,IAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA,CAAA;IAClD,IAAI,CAACC,SAAS,GAAGN,QAAQ,CAAA;IACzB,IAAI,CAACC,QAAQ,GAAGA,QAAQ,CAAA;IACxB,IAAI,CAACM,KAAK,EAAE,CAAA;AACd,GAAA;AAEQC,EAAAA,KAAKA,GAAS;IACpB,IAAI,CAACC,SAAS,GAAG,KAAK,CAAA;IAEtB,IAAI,IAAI,CAACC,KAAK,EAAE;AACdC,MAAAA,MAAM,CAAC,IAAI,CAACD,KAAK,CAAC,CAAA;AACpB,KAAA;AACF,GAAA;AAEQE,EAAAA,KAAKA,GAAS;IACpB,IAAI,CAACJ,KAAK,EAAE,CAAA;IACZ,IAAI,CAACF,SAAS,IAAIO,IAAI,CAACC,GAAG,EAAE,GAAG,IAAI,CAACC,KAAK,CAAA;AAC3C,GAAA;AAEQC,EAAAA,MAAMA,GAAS;IACrB,IAAI,CAACR,KAAK,EAAE,CAAA;IACZ,IAAI,CAACD,KAAK,EAAE,CA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Y,CAAC,CAAA;KAClC,CAAA,CAAA;AAAAzC,IAAAA,eAAA,oBAEW,MAAY;AACtB,MAAA,IAAI,CAACoD,OAAO,CAACL,SAAS,EAAE,CAAA;KACzB,CAAA,CAAA;AAAA,GAAA;EAdD,IAAIL,aAAaA,GAAmB;AAClC,IAAA,OAAO,IAAI,CAACU,OAAO,CAACV,aAAa,CAAA;AACnC,GAAA;AAcAW,EAAAA,WAAWA,GAAS;IAClB,IAAI,CAACN,SAAS,EAAE,CAAA;IAChB,KAAK,CAACM,WAAW,EAAE,CAAA;AACrB,GAAA;AACF,CAAA;;AAEA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-registry.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontile/notifications",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0-alpha.0",
|
|
4
4
|
"description": "Component Library for Ember Octane apps: Notifications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -13,61 +13,63 @@
|
|
|
13
13
|
"doc": "doc",
|
|
14
14
|
"test": "tests"
|
|
15
15
|
},
|
|
16
|
+
"files": [
|
|
17
|
+
"addon-main.js",
|
|
18
|
+
"declarations",
|
|
19
|
+
"dist",
|
|
20
|
+
"tailwind"
|
|
21
|
+
],
|
|
16
22
|
"scripts": {
|
|
17
|
-
"build": "
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
23
|
+
"build": "concurrently -m 1 'npm:build:*'",
|
|
24
|
+
"build:js": "rollup --config",
|
|
25
|
+
"build:types": "glint --declaration",
|
|
26
|
+
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
|
|
27
|
+
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
|
|
28
|
+
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
|
29
|
+
"lint:js": "eslint . --cache",
|
|
30
|
+
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
|
|
31
|
+
"lint:js:fix": "eslint . --fix",
|
|
32
|
+
"lint:types": "glint",
|
|
33
|
+
"start": "concurrently 'npm:start:*'",
|
|
34
|
+
"start:js": "rollup --config --watch --no-watch.clearScreen",
|
|
35
|
+
"start:types": "glint -d --watch",
|
|
36
|
+
"test": "echo 'A v2 addon does not have tests, run tests in test-app'",
|
|
37
|
+
"prepack": "concurrently 'npm:build'"
|
|
24
38
|
},
|
|
25
39
|
"peerDependencies": {
|
|
40
|
+
"@babel/runtime": ">= 7",
|
|
26
41
|
"ember-source": "^4.0.0 || ^5.0.0"
|
|
27
42
|
},
|
|
28
43
|
"dependencies": {
|
|
29
44
|
"@ember/render-modifiers": "^2.1.0",
|
|
30
|
-
"@
|
|
45
|
+
"@embroider/addon-shim": "^1.8.7",
|
|
46
|
+
"@frontile/core": "^0.16.0-alpha.0",
|
|
31
47
|
"@frontile/tailwindcss-plugin-helpers": "^0.15.0",
|
|
32
48
|
"ember-auto-import": "^2.6.3",
|
|
33
|
-
"ember-
|
|
34
|
-
"ember-cli-htmlbars": "^6.2.0",
|
|
35
|
-
"ember-cli-typescript": "^5.2.1",
|
|
36
|
-
"ember-css-transitions": "^4.3.2",
|
|
49
|
+
"ember-css-transitions": "^4.4.0",
|
|
37
50
|
"ember-get-config": "^2.1.1"
|
|
38
51
|
},
|
|
39
52
|
"devDependencies": {
|
|
40
|
-
"@babel/core": "
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"
|
|
53
|
-
"ember-
|
|
54
|
-
"
|
|
55
|
-
"ember-
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"ember-cli-uglify": "^3.0.0",
|
|
59
|
-
"ember-disable-prototype-extensions": "^1.1.3",
|
|
60
|
-
"ember-load-initializers": "^2.1.2",
|
|
61
|
-
"ember-qunit": "^7.0.0",
|
|
62
|
-
"ember-resolver": "^11.0.0",
|
|
63
|
-
"ember-source": "^5.1.2",
|
|
64
|
-
"ember-try": "^2.0.0",
|
|
65
|
-
"loader.js": "^4.7.0",
|
|
66
|
-
"qunit": "^2.19.4",
|
|
67
|
-
"qunit-dom": "^2.0.0",
|
|
53
|
+
"@babel/core": "7.23.6",
|
|
54
|
+
"@babel/plugin-proposal-class-properties": "7.18.6",
|
|
55
|
+
"@babel/plugin-proposal-decorators": "7.23.6",
|
|
56
|
+
"@babel/plugin-transform-class-static-block": "^7.23.4",
|
|
57
|
+
"@babel/preset-typescript": "7.23.3",
|
|
58
|
+
"@embroider/addon-dev": "4.1.3",
|
|
59
|
+
"@embroider/addon-shim": "^1.8.6",
|
|
60
|
+
"@glint/core": "1.2.1",
|
|
61
|
+
"@glint/environment-ember-loose": "1.2.1",
|
|
62
|
+
"@glint/environment-ember-template-imports": "1.2.1",
|
|
63
|
+
"@glint/template": "1.2.1",
|
|
64
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
65
|
+
"@tsconfig/ember": "^3.0.0",
|
|
66
|
+
"babel-plugin-ember-template-compilation": "^2.1.1",
|
|
67
|
+
"concurrently": "^8.2.0",
|
|
68
|
+
"ember-source": "^5.5.0",
|
|
69
|
+
"rollup": "^4.9.1",
|
|
70
|
+
"rollup-plugin-ts": "^3.2.0",
|
|
68
71
|
"tailwindcss": "^3.3.3",
|
|
69
|
-
"typescript": "^5.1.6"
|
|
70
|
-
"webpack": "^5.88.2"
|
|
72
|
+
"typescript": "^5.1.6"
|
|
71
73
|
},
|
|
72
74
|
"engines": {
|
|
73
75
|
"node": "10.* || >= 12"
|
|
@@ -79,7 +81,38 @@
|
|
|
79
81
|
"edition": "octane"
|
|
80
82
|
},
|
|
81
83
|
"ember-addon": {
|
|
82
|
-
"
|
|
84
|
+
"version": 2,
|
|
85
|
+
"type": "addon",
|
|
86
|
+
"main": "addon-main.js",
|
|
87
|
+
"app-js": {
|
|
88
|
+
"./components/notification-card.js": "./dist/_app_/components/notification-card.js",
|
|
89
|
+
"./components/notifications-container.js": "./dist/_app_/components/notifications-container.js",
|
|
90
|
+
"./services/notifications.js": "./dist/_app_/services/notifications.js"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"exports": {
|
|
94
|
+
".": {
|
|
95
|
+
"types": "./declarations/index.d.ts",
|
|
96
|
+
"default": "./dist/index.js"
|
|
97
|
+
},
|
|
98
|
+
"./*": {
|
|
99
|
+
"types": "./declarations/*.d.ts",
|
|
100
|
+
"default": "./dist/*.js"
|
|
101
|
+
},
|
|
102
|
+
"./addon-main.js": "./addon-main.js",
|
|
103
|
+
"./tailwind": {
|
|
104
|
+
"default": "./tailwind/index.js"
|
|
105
|
+
},
|
|
106
|
+
"./tailwind/*": {
|
|
107
|
+
"default": "./tailwind/*.js"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"typesVersions": {
|
|
111
|
+
"*": {
|
|
112
|
+
"*": [
|
|
113
|
+
"declarations/*"
|
|
114
|
+
]
|
|
115
|
+
}
|
|
83
116
|
},
|
|
84
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "c1f2fb51b859e18d1bcb94090055ad9c1128d4d3"
|
|
85
118
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import config from 'ember-get-config';
|
|
2
|
-
import { DefaultConfig } from './types';
|
|
3
|
-
import { get } from '@ember/object';
|
|
4
|
-
|
|
5
|
-
export function getConfigOption<T extends keyof DefaultConfig>(
|
|
6
|
-
key: T,
|
|
7
|
-
defaultValue: NonNullable<DefaultConfig[T]>
|
|
8
|
-
): NonNullable<DefaultConfig[T]> {
|
|
9
|
-
const value = get(
|
|
10
|
-
config['@frontile/notifications'] || ({} as never),
|
|
11
|
-
key as never
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
if (value === undefined) {
|
|
15
|
-
return defaultValue;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import Notification from './notification';
|
|
2
|
-
import Timer from './timer';
|
|
3
|
-
import { NotificationOptions } from './types';
|
|
4
|
-
import { getConfigOption } from './get-config';
|
|
5
|
-
import { tracked } from '@glimmer/tracking';
|
|
6
|
-
import { later } from '@ember/runloop';
|
|
7
|
-
|
|
8
|
-
export default class NotificationsManager {
|
|
9
|
-
@tracked notifications: Notification[] = [];
|
|
10
|
-
|
|
11
|
-
add(message: string, options: NotificationOptions = {}): Notification {
|
|
12
|
-
const notification = new Notification(message, options);
|
|
13
|
-
this.notifications = [...this.notifications, notification];
|
|
14
|
-
|
|
15
|
-
let preserve =
|
|
16
|
-
typeof options.preserve === 'undefined'
|
|
17
|
-
? getConfigOption('preserve', false)
|
|
18
|
-
: options.preserve;
|
|
19
|
-
|
|
20
|
-
// if default config has set skipTimer to true, we will preserve the
|
|
21
|
-
// notification, therefore skiping the timer
|
|
22
|
-
if (getConfigOption('skipTimer', false) === true) {
|
|
23
|
-
preserve = true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (preserve === false) {
|
|
27
|
-
this.setupAutoRemoval(notification, notification.duration);
|
|
28
|
-
}
|
|
29
|
-
return notification;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
remove(notification?: Notification): void {
|
|
33
|
-
if (!notification) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
notification.remove();
|
|
38
|
-
|
|
39
|
-
later(
|
|
40
|
-
this,
|
|
41
|
-
() => {
|
|
42
|
-
this.notifications = this.notifications.filter((n) => {
|
|
43
|
-
return n !== notification;
|
|
44
|
-
});
|
|
45
|
-
},
|
|
46
|
-
notification.transitionDuration
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
removeAll(): void {
|
|
51
|
-
this.notifications.forEach((notification) => {
|
|
52
|
-
this.remove(notification);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
private setupAutoRemoval(notification: Notification, duration: number): void {
|
|
57
|
-
notification.timer = new Timer(duration, () => {
|
|
58
|
-
this.remove(notification);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { tracked } from '@glimmer/tracking';
|
|
2
|
-
import Timer from './timer';
|
|
3
|
-
import { NotificationOptions, CustomAction } from './types';
|
|
4
|
-
import { getConfigOption } from './get-config';
|
|
5
|
-
|
|
6
|
-
export default class Notification {
|
|
7
|
-
readonly message: string;
|
|
8
|
-
readonly transitionDuration: number;
|
|
9
|
-
readonly appearance: NonNullable<NotificationOptions['appearance']>;
|
|
10
|
-
readonly customActions?: CustomAction[];
|
|
11
|
-
readonly allowClosing: boolean;
|
|
12
|
-
readonly duration: number;
|
|
13
|
-
|
|
14
|
-
@tracked timer?: Timer;
|
|
15
|
-
@tracked isRemoving = false;
|
|
16
|
-
|
|
17
|
-
constructor(message: string, options: NotificationOptions = {}) {
|
|
18
|
-
this.message = message;
|
|
19
|
-
this.appearance =
|
|
20
|
-
options.appearance || getConfigOption('appearance', 'info');
|
|
21
|
-
this.customActions = options.customActions;
|
|
22
|
-
this.duration = options.duration || getConfigOption('duration', 5000);
|
|
23
|
-
this.transitionDuration =
|
|
24
|
-
typeof options.transitionDuration !== 'undefined'
|
|
25
|
-
? options.transitionDuration
|
|
26
|
-
: getConfigOption('transitionDuration', 200);
|
|
27
|
-
|
|
28
|
-
if (options.allowClosing === false) {
|
|
29
|
-
this.allowClosing = false;
|
|
30
|
-
} else {
|
|
31
|
-
this.allowClosing = true;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
remove(): void {
|
|
36
|
-
this.isRemoving = true;
|
|
37
|
-
|
|
38
|
-
if (this.timer) {
|
|
39
|
-
this.timer.clear();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
package/addon/-private/timer.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { tracked } from '@glimmer/tracking';
|
|
2
|
-
import { later, cancel } from '@ember/runloop';
|
|
3
|
-
import type { Timer as EmberTimer } from '@ember/runloop';
|
|
4
|
-
import { action } from '@ember/object';
|
|
5
|
-
|
|
6
|
-
export default class Timer {
|
|
7
|
-
@tracked remaining: number;
|
|
8
|
-
@tracked isRunning = true;
|
|
9
|
-
|
|
10
|
-
readonly onFinish: () => void;
|
|
11
|
-
private timer?: EmberTimer;
|
|
12
|
-
private start!: number;
|
|
13
|
-
|
|
14
|
-
constructor(duration: number, onFinish: () => void) {
|
|
15
|
-
this.remaining = duration;
|
|
16
|
-
this.onFinish = onFinish;
|
|
17
|
-
this.setup();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@action clear(): void {
|
|
21
|
-
this.isRunning = false;
|
|
22
|
-
|
|
23
|
-
if (this.timer) {
|
|
24
|
-
cancel(this.timer);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@action pause(): void {
|
|
29
|
-
this.clear();
|
|
30
|
-
this.remaining -= Date.now() - this.start;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@action resume(): void {
|
|
34
|
-
this.clear();
|
|
35
|
-
this.setup();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
private setup(): void {
|
|
39
|
-
this.start = Date.now();
|
|
40
|
-
this.isRunning = true;
|
|
41
|
-
|
|
42
|
-
this.timer = later(
|
|
43
|
-
this,
|
|
44
|
-
() => {
|
|
45
|
-
this.onFinish();
|
|
46
|
-
this.isRunning = false;
|
|
47
|
-
},
|
|
48
|
-
this.remaining
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
}
|
package/addon/-private/types.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export interface CustomAction {
|
|
2
|
-
/**
|
|
3
|
-
* The label of the action
|
|
4
|
-
*/
|
|
5
|
-
label: string;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The function to be called when clicked
|
|
9
|
-
*/
|
|
10
|
-
onClick: () => void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface NotificationOptions {
|
|
14
|
-
/**
|
|
15
|
-
* If set to false, the close button will not be displayed.
|
|
16
|
-
*
|
|
17
|
-
* @defaultValue true
|
|
18
|
-
*/
|
|
19
|
-
allowClosing?: boolean;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Preserve the notification open, no auto-dismiss.
|
|
23
|
-
*
|
|
24
|
-
* @defaultValue false
|
|
25
|
-
*/
|
|
26
|
-
preserve?: boolean;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Duration before the notification is auto-dismissed, in milliseconds.
|
|
30
|
-
*
|
|
31
|
-
* @defaultValue 5000
|
|
32
|
-
*/
|
|
33
|
-
duration?: number;
|
|
34
|
-
|
|
35
|
-
/*
|
|
36
|
-
* The duration for the transition on removal, in milliseconds.
|
|
37
|
-
*
|
|
38
|
-
* @defaultValue 200
|
|
39
|
-
*/
|
|
40
|
-
transitionDuration?: number;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The appearance of the notification
|
|
44
|
-
*
|
|
45
|
-
* @defaultValue 'info'
|
|
46
|
-
*/
|
|
47
|
-
appearance?: 'info' | 'success' | 'warning' | 'error';
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* A list of custom actions
|
|
51
|
-
*
|
|
52
|
-
* @defaultValue undefined
|
|
53
|
-
*/
|
|
54
|
-
customActions?: CustomAction[];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface DefaultConfig extends NotificationOptions {
|
|
58
|
-
/**
|
|
59
|
-
* If set to true, we will preserve the notification, therefore skiping the timer.
|
|
60
|
-
* This is useful in tests because Ember will wait for any runloop to
|
|
61
|
-
* finish before proceeding.
|
|
62
|
-
*
|
|
63
|
-
* @defaultValue false
|
|
64
|
-
*/
|
|
65
|
-
skipTimer?: boolean;
|
|
66
|
-
}
|