@frontile/notifications 0.17.0-beta.5 → 0.17.0-beta.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontile/notifications",
3
- "version": "0.17.0-beta.5",
3
+ "version": "0.17.0-beta.8",
4
4
  "description": "Component Library for Ember Octane apps: Notifications",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -9,6 +9,24 @@
9
9
  "repository": "https://github.com/josemarluedke/frontile",
10
10
  "license": "MIT",
11
11
  "author": "",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./declarations/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./*": {
18
+ "types": "./declarations/*.d.ts",
19
+ "default": "./dist/*.js"
20
+ },
21
+ "./addon-main.js": "./addon-main.js"
22
+ },
23
+ "typesVersions": {
24
+ "*": {
25
+ "*": [
26
+ "declarations/*"
27
+ ]
28
+ }
29
+ },
12
30
  "directories": {
13
31
  "doc": "doc",
14
32
  "test": "tests"
@@ -19,56 +37,53 @@
19
37
  "dist"
20
38
  ],
21
39
  "scripts": {
22
- "build": "concurrently -m 1 'npm:build:*'",
23
- "build:js": "rollup --config",
24
- "build:types": "glint --declaration",
40
+ "build": "rollup --config",
25
41
  "lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
26
42
  "lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
27
43
  "lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
28
- "lint:js": "eslint . --cache",
29
44
  "lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
45
+ "lint:js": "eslint . --cache",
30
46
  "lint:js:fix": "eslint . --fix",
31
47
  "lint:types": "glint",
48
+ "prepack": "concurrently 'npm:build'",
32
49
  "start": "concurrently 'npm:start:*'",
33
50
  "start:js": "rollup --config --watch --no-watch.clearScreen",
34
51
  "start:types": "glint -d --watch",
35
- "test": "echo 'A v2 addon does not have tests, run tests in test-app'",
36
- "prepack": "concurrently 'npm:build'"
37
- },
38
- "peerDependencies": {
39
- "@babel/runtime": ">= 7",
40
- "ember-source": ">= 4.12.0"
52
+ "test": "echo 'A v2 addon does not have tests, run tests in test-app'"
41
53
  },
42
54
  "dependencies": {
43
55
  "@ember/render-modifiers": "^2.1.0",
44
56
  "@embroider/addon-shim": "^1.9.0",
45
- "@frontile/buttons": "0.17.0-beta.5",
46
- "@frontile/theme": "0.17.0-beta.5",
57
+ "@frontile/buttons": "0.17.0-beta.8",
58
+ "@frontile/theme": "0.17.0-beta.6",
47
59
  "ember-auto-import": "^2.7.2",
48
60
  "ember-css-transitions": "^4.4.0"
49
61
  },
50
62
  "devDependencies": {
51
- "@babel/core": "7.26.0",
52
- "@babel/plugin-proposal-class-properties": "7.18.6",
53
- "@babel/plugin-proposal-decorators": "7.25.9",
54
- "@babel/plugin-transform-class-static-block": "^7.23.4",
55
- "@babel/preset-typescript": "7.26.0",
63
+ "@babel/core": "7.26.7",
64
+ "@babel/plugin-transform-typescript": "^7.26.7",
56
65
  "@embroider/addon-dev": "7.1.1",
57
66
  "@glimmer/component": "^2.0.0",
58
67
  "@glimmer/tracking": "^1.1.2",
59
- "@glint/core": "1.5.0",
60
- "@glint/environment-ember-loose": "1.5.0",
61
- "@glint/environment-ember-template-imports": "1.5.0",
62
- "@glint/template": "1.5.0",
68
+ "@glint/core": "1.5.2",
69
+ "@glint/environment-ember-loose": "1.5.2",
70
+ "@glint/environment-ember-template-imports": "1.5.2",
71
+ "@glint/template": "1.5.2",
72
+ "@rollup/plugin-babel": "^6.0.4",
63
73
  "@rollup/plugin-node-resolve": "^16.0.0",
64
- "@tsconfig/ember": "^3.0.5",
74
+ "@tsconfig/ember": "^3.0.9",
65
75
  "babel-plugin-ember-template-compilation": "^2.2.1",
66
76
  "concurrently": "^9.1.0",
77
+ "decorator-transforms": "^2.3.0",
67
78
  "ember-source": "^6.1.0",
68
79
  "rollup": "^4.29.1",
69
- "rollup-plugin-ts": "^3.4.5",
80
+ "rollup-plugin-copy": "^3.5.0",
70
81
  "tailwindcss": "^3.4.17",
71
- "typescript": "^5.7.2"
82
+ "typescript": "^5.7.3"
83
+ },
84
+ "peerDependencies": {
85
+ "@babel/runtime": ">= 7",
86
+ "ember-source": ">= 4.12.0"
72
87
  },
73
88
  "engines": {
74
89
  "node": "10.* || >= 12"
@@ -89,23 +104,5 @@
89
104
  "./services/notifications.js": "./dist/_app_/services/notifications.js"
90
105
  }
91
106
  },
92
- "exports": {
93
- ".": {
94
- "types": "./declarations/index.d.ts",
95
- "default": "./dist/index.js"
96
- },
97
- "./*": {
98
- "types": "./declarations/*.d.ts",
99
- "default": "./dist/*.js"
100
- },
101
- "./addon-main.js": "./addon-main.js"
102
- },
103
- "typesVersions": {
104
- "*": {
105
- "*": [
106
- "declarations/*"
107
- ]
108
- }
109
- },
110
- "gitHead": "5a9a2f933b0f137f9437bbfc8cf99244ec9d5e85"
107
+ "gitHead": "7bdacbd58c410fb627559790a9e2e1c5232b94a7"
111
108
  }
@@ -1,4 +0,0 @@
1
- import { DefaultConfig } from "./types-16c08671.js";
2
- declare function getConfigOption<T extends keyof DefaultConfig>(config: DefaultConfig, key: T, defaultValue: NonNullable<DefaultConfig[T]>): NonNullable<DefaultConfig[T]>;
3
- export { getConfigOption };
4
- //# sourceMappingURL=get-config-44fc1a62.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-config-44fc1a62.d.ts","sourceRoot":"","sources":["../src/-private/get-config.ts"],"names":[],"mappings":"AACA,OAAO,iBAAsB,4BAAgB;AAE7C,iBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,aAAa,EAC3D,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,CAAC,EACN,YAAY,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAC1C,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAQ/B"}
@@ -1,13 +0,0 @@
1
- import Notification from "./notification-5242cbb9.js";
2
- import { DefaultConfig, NotificationOptions } from "./types-16c08671.js";
3
- declare class NotificationsManager {
4
- notifications: Notification[];
5
- config: DefaultConfig;
6
- constructor(context: object);
7
- add(message: string, options?: NotificationOptions): Notification;
8
- remove(notification?: Notification): void;
9
- removeAll(): void;
10
- private setupAutoRemoval;
11
- }
12
- export { NotificationsManager as default };
13
- //# sourceMappingURL=manager-F_0k8v_Z.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"manager-F_0k8v_Z.d.ts","sourceRoot":"","sources":["../src/-private/manager.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,mCAAuB;AAS1C,OAAO,sCAAsB,4BAAgB;AAG7C,cAAqB,oBAAoB;IAC9B,aAAa,EAAE,YAAY,EAAE,CAAM;IAE5C,MAAM,EAAE,aAAa,CAAM;gBAEf,OAAO,EAAE,MAAM;IAc3B,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,YAAY;IAqBrE,MAAM,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI;IAkBzC,SAAS,IAAI,IAAI;IAMjB,OAAO,CAAC,gBAAgB;CAKzB"}
@@ -1,16 +0,0 @@
1
- import Timer from "./timer-0a840cef.js";
2
- import { NotificationOptions, CustomAction, DefaultConfig } from "./types-16c08671.js";
3
- declare class Notification {
4
- readonly message: string;
5
- readonly transitionDuration: number;
6
- readonly appearance: NonNullable<NotificationOptions['appearance']>;
7
- readonly customActions?: CustomAction[];
8
- readonly allowClosing: boolean;
9
- readonly duration: number;
10
- timer?: Timer;
11
- isRemoving: boolean;
12
- constructor(config: DefaultConfig, message: string, options?: NotificationOptions);
13
- remove(): void;
14
- }
15
- export { Notification as default };
16
- //# sourceMappingURL=notification-5242cbb9.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notification-5242cbb9.d.ts","sourceRoot":"","sources":["../src/-private/notification.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,4BAAgB;AAE5B,OAAO,oDAAyD,4BAAgB;AAEhF,cAAqB,YAAY;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC;IACpE,QAAQ,CAAC,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAEjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,UAAU,UAAS;gBAG1B,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,mBAAwB;IAoBnC,MAAM,IAAI,IAAI;CAOf"}
@@ -1,14 +0,0 @@
1
- declare class Timer {
2
- remaining: number;
3
- isRunning: boolean;
4
- readonly onFinish: () => void;
5
- private timer?;
6
- private start;
7
- constructor(duration: number, onFinish: () => void);
8
- clear(): void;
9
- pause(): void;
10
- resume(): void;
11
- private setup;
12
- }
13
- export { Timer as default };
14
- //# sourceMappingURL=timer-0a840cef.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timer-0a840cef.d.ts","sourceRoot":"","sources":["../src/-private/timer.ts"],"names":[],"mappings":"AAMA,cAAqB,KAAK;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,UAAQ;IAE1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;IAC9B,OAAO,CAAC,KAAK,CAAC,CAAa;IAC3B,OAAO,CAAC,KAAK,CAAU;gBAEX,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI;IAM1C,KAAK,IAAI,IAAI;IAQb,KAAK,IAAI,IAAI;IAKb,MAAM,IAAI,IAAI;IAKtB,OAAO,CAAC,KAAK;CAad"}
@@ -1,56 +0,0 @@
1
- type containerPlacement = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
2
- interface CustomAction {
3
- /**
4
- * The label of the action
5
- */
6
- label: string;
7
- /**
8
- * The function to be called when clicked
9
- */
10
- onClick: () => void;
11
- }
12
- interface NotificationOptions {
13
- /**
14
- * If set to false, the close button will not be displayed.
15
- *
16
- * @defaultValue true
17
- */
18
- allowClosing?: boolean;
19
- /**
20
- * Preserve the notification open, no auto-dismiss.
21
- *
22
- * @defaultValue false
23
- */
24
- preserve?: boolean;
25
- /**
26
- * Duration before the notification is auto-dismissed, in milliseconds.
27
- *
28
- * @defaultValue 5000
29
- */
30
- duration?: number;
31
- transitionDuration?: number;
32
- /**
33
- * The appearance of the notification
34
- *
35
- * @defaultValue 'info'
36
- */
37
- appearance?: 'info' | 'success' | 'warning' | 'error';
38
- /**
39
- * A list of custom actions
40
- *
41
- * @defaultValue undefined
42
- */
43
- customActions?: CustomAction[];
44
- }
45
- interface DefaultConfig extends NotificationOptions {
46
- /**
47
- * If set to true, we will preserve the notification, therefore skiping the timer.
48
- * This is useful in tests because Ember will wait for any runloop to
49
- * finish before proceeding.
50
- *
51
- * @defaultValue false
52
- */
53
- skipTimer?: boolean;
54
- }
55
- export { containerPlacement, CustomAction, NotificationOptions, DefaultConfig };
56
- //# sourceMappingURL=types-16c08671.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-16c08671.d.ts","sourceRoot":"","sources":["../src/-private/types.ts"],"names":[],"mappings":"AAAA,KAAY,kBAAkB,GAC1B,UAAU,GACV,YAAY,GACZ,WAAW,GACX,aAAa,GACb,eAAe,GACf,cAAc,CAAC;AAEnB,UAAiB,YAAY;IAC3B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,UAAiB,mBAAmB;IAClC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAOlB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IAEtD;;;;OAIG;IACH,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAChC;AAED,UAAiB,aAAc,SAAQ,mBAAmB;IACxD;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
@@ -1,167 +0,0 @@
1
- import _initializerDefineProperty from '@babel/runtime/helpers/esm/initializerDefineProperty';
2
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
- import _applyDecoratedDescriptor from '@babel/runtime/helpers/esm/applyDecoratedDescriptor';
4
- import '@babel/runtime/helpers/esm/initializerWarningHelper';
5
- import { tracked } from '@glimmer/tracking';
6
- import { cancel, later } from '@ember/runloop';
7
- import { action, get } from '@ember/object';
8
- import { getOwner } from '@ember/owner';
9
- import { assert } from '@ember/debug';
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(config, key, defaultValue) {
60
- const value = get(config, 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(config, 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(config, 'appearance', 'info');
80
- this.customActions = options.customActions;
81
- this.duration = options.duration || getConfigOption(config, 'duration', 5000);
82
- this.transitionDuration = typeof options.transitionDuration !== 'undefined' ? options.transitionDuration : getConfigOption(config, '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(context) {
112
- _initializerDefineProperty(this, "notifications", _descriptor, this);
113
- _defineProperty(this, "config", {});
114
- let owner = getOwner(context);
115
- assert('NotificationsManager context must have an owner', owner);
116
- const configFactory = owner.factoryFor('config:environment');
117
- if (configFactory && configFactory.class) {
118
- this.config = configFactory.class['@frontile/notifications'] || {};
119
- }
120
- }
121
- add(message, options = {}) {
122
- const notification = new Notification(this.config, message, options);
123
- this.notifications = [...this.notifications, notification];
124
- let preserve = typeof options.preserve === 'undefined' ? getConfigOption(this.config, 'preserve', false) : options.preserve;
125
-
126
- // if default config has set skipTimer to true, we will preserve the
127
- // notification, therefore skiping the timer
128
- if (getConfigOption(this.config, 'skipTimer', false) === true) {
129
- preserve = true;
130
- }
131
- if (preserve === false) {
132
- this.setupAutoRemoval(notification, notification.duration);
133
- }
134
- return notification;
135
- }
136
- remove(notification) {
137
- if (!notification) {
138
- return;
139
- }
140
- notification.remove();
141
- later(this, () => {
142
- this.notifications = this.notifications.filter(n => {
143
- return n !== notification;
144
- });
145
- }, notification.transitionDuration);
146
- }
147
- removeAll() {
148
- this.notifications.forEach(notification => {
149
- this.remove(notification);
150
- });
151
- }
152
- setupAutoRemoval(notification, duration) {
153
- notification.timer = new Timer(duration, () => {
154
- this.remove(notification);
155
- });
156
- }
157
- }, _descriptor = _applyDecoratedDescriptor(_class.prototype, "notifications", [tracked], {
158
- configurable: true,
159
- enumerable: true,
160
- writable: true,
161
- initializer: function () {
162
- return [];
163
- }
164
- }), _class);
165
-
166
- export { Notification as N, Timer as T, NotificationsManager as a };
167
- //# sourceMappingURL=manager--2XpSzrY.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"manager--2XpSzrY.js","sources":["../src/-private/timer.ts","../src/-private/get-config.ts","../src/-private/notification.ts","../src/-private/manager.ts"],"sourcesContent":["/* eslint-disable ember/no-runloop */\nimport { 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 { get } from '@ember/object';\nimport type { DefaultConfig } from './types';\n\nexport function getConfigOption<T extends keyof DefaultConfig>(\n config: DefaultConfig,\n key: T,\n defaultValue: NonNullable<DefaultConfig[T]>\n): NonNullable<DefaultConfig[T]> {\n const value = get(config, key);\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, DefaultConfig } 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(\n config: DefaultConfig,\n message: string,\n options: NotificationOptions = {}\n ) {\n this.message = message;\n this.appearance =\n options.appearance || getConfigOption(config, 'appearance', 'info');\n this.customActions = options.customActions;\n this.duration =\n options.duration || getConfigOption(config, 'duration', 5000);\n this.transitionDuration =\n typeof options.transitionDuration !== 'undefined'\n ? options.transitionDuration\n : getConfigOption(config, '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","/* eslint-disable ember/no-runloop */\nimport Notification from './notification';\nimport Timer from './timer';\nimport { getConfigOption } from './get-config';\nimport { tracked } from '@glimmer/tracking';\nimport { later } from '@ember/runloop';\nimport { getOwner } from '@ember/owner';\nimport type { NotificationOptions } from './types';\nimport type Owner from '@ember/owner';\nimport { assert } from '@ember/debug';\nimport type { DefaultConfig } from './types';\n\nexport default class NotificationsManager {\n @tracked notifications: Notification[] = [];\n\n config: DefaultConfig = {};\n\n constructor(context: object) {\n let owner = getOwner(context) as Owner;\n assert('NotificationsManager context must have an owner', owner);\n const configFactory = owner.factoryFor('config:environment');\n\n if (configFactory && configFactory.class) {\n this.config =\n (configFactory.class as never)['@frontile/notifications'] || {};\n }\n }\n\n add(message: string, options: NotificationOptions = {}): Notification {\n const notification = new Notification(this.config, message, options);\n this.notifications = [...this.notifications, notification];\n\n let preserve =\n typeof options.preserve === 'undefined'\n ? getConfigOption(this.config, '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(this.config, '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"],"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","config","key","defaultValue","value","get","undefined","Notification","message","options","appearance","customActions","transitionDuration","allowClosing","remove","isRemoving","NotificationsManager","context","owner","getOwner","assert","configFactory","factoryFor","class","add","notification","notifications","preserve","setupAutoRemoval","filter","n","removeAll","forEach"],"mappings":";;;;;;;;;;;AAIuC,IAElBA,KAAK,IAAAC,QAAA,GAAX,MAAMD,KAAK,CAAC;AAQzBE,EAAAA,WAAWA,CAACC,QAAgB,EAAEC,QAAoB,EAAE;AAAAC,IAAAA,0BAAA,oBAAAC,aAAA,EAAA,IAAA,CAAA;AAAAD,IAAAA,0BAAA,oBAAAE,cAAA,EAAA,IAAA,CAAA;IAAAC,eAAA,CAAA,IAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA;IAAAA,eAAA,CAAA,IAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA;IAAAA,eAAA,CAAA,IAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA;IAClD,IAAI,CAACC,SAAS,GAAGN,QAAQ;IACzB,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACM,KAAK,EAAE;AACd;AAEQC,EAAAA,KAAKA,GAAS;IACpB,IAAI,CAACC,SAAS,GAAG,KAAK;IAEtB,IAAI,IAAI,CAACC,KAAK,EAAE;AACdC,MAAAA,MAAM,CAAC,IAAI,CAACD,KAAK,CAAC;AACpB;AACF;AAEQE,EAAAA,K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,CAAC;AAC5D;AACA,IAAA,OAAOqD,YAAY;AACrB;EAEAX,MAAMA,CAACW,YAA2B,EAAQ;IACxC,IAAI,CAACA,YAAY,EAAE;AACjB,MAAA;AACF;IAEAA,YAAY,CAACX,MAAM,EAAE;IAErBzB,KAAK,CACH,IAAI,EACJ,MAAM;MACJ,IAAI,CAACqC,aAAa,GAAG,IAAI,CAACA,aAAa,CAACG,MAAM,CAAEC,CAAC,IAAK;QACpD,OAAOA,CAAC,KAAKL,YAAY;AAC3B,OAAC,CAAC;AACJ,KAAC,EACDA,YAAY,CAACb,kBACf,CAAC;AACH;AAEAmB,EAAAA,SAASA,GAAS;AAChB,IAAA,IAAI,CAACL,aAAa,CAACM,OAAO,CAAEP,YAAY,IAAK;AAC3C,MAAA,IAAI,CAACX,MAAM,CAACW,YAAY,CAAC;AAC3B,KAAC,CAAC;AACJ;AAEQG,EAAAA,gBAAgBA,CAACH,YAA0B,EAAErD,QAAgB,EAAQ;IAC3EqD,YAAY,CAAC3C,KAAK,GAAG,IAAIb,KAAK,CAACG,QAAQ,EAAE,MAAM;AAC7C,MAAA,IAAI,CAAC0C,MAAM,CAACW,YAAY,CAAC;AAC3B,KAAC,CAAC;AACJ;AACF,CAAC,EAAAlD,WAAA,GAAAe,yBAAA,CAAApB,MAAA,CAAAqB,SAAA,EAAA,eAAA,EAAA,CAjEEC,OAAO,CAAA,EAAA;EAAAC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;AAAAC,EAAAA,WAAA,cAAA;AAAA,IAAA,OAAiC,EAAE;AAAA;AAAA,CAAA,CAAA,EAAA1B,MAAA;;;;"}
@@ -1,167 +0,0 @@
1
- import _initializerDefineProperty from '@babel/runtime/helpers/esm/initializerDefineProperty';
2
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
- import _applyDecoratedDescriptor from '@babel/runtime/helpers/esm/applyDecoratedDescriptor';
4
- import '@babel/runtime/helpers/esm/initializerWarningHelper';
5
- import { tracked } from '@glimmer/tracking';
6
- import { cancel, later } from '@ember/runloop';
7
- import { action, get } from '@ember/object';
8
- import { getOwner } from '@ember/owner';
9
- import { assert } from '@ember/debug';
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(config, key, defaultValue) {
60
- const value = get(config, 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(config, 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(config, 'appearance', 'info');
80
- this.customActions = options.customActions;
81
- this.duration = options.duration || getConfigOption(config, 'duration', 5000);
82
- this.transitionDuration = typeof options.transitionDuration !== 'undefined' ? options.transitionDuration : getConfigOption(config, '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(context) {
112
- _initializerDefineProperty(this, "notifications", _descriptor, this);
113
- _defineProperty(this, "config", {});
114
- const owner = getOwner(context);
115
- assert('NotificationsManager context must have an owner', owner);
116
- const configFactory = owner.factoryFor('config:environment');
117
- if (configFactory && configFactory.class) {
118
- this.config = configFactory.class['@frontile/notifications'] || {};
119
- }
120
- }
121
- add(message, options = {}) {
122
- const notification = new Notification(this.config, message, options);
123
- this.notifications = [...this.notifications, notification];
124
- let preserve = typeof options.preserve === 'undefined' ? getConfigOption(this.config, 'preserve', false) : options.preserve;
125
-
126
- // if default config has set skipTimer to true, we will preserve the
127
- // notification, therefore skiping the timer
128
- if (getConfigOption(this.config, 'skipTimer', false) === true) {
129
- preserve = true;
130
- }
131
- if (preserve === false) {
132
- this.setupAutoRemoval(notification, notification.duration);
133
- }
134
- return notification;
135
- }
136
- remove(notification) {
137
- if (!notification) {
138
- return;
139
- }
140
- notification.remove();
141
- later(this, () => {
142
- this.notifications = this.notifications.filter(n => {
143
- return n !== notification;
144
- });
145
- }, notification.transitionDuration);
146
- }
147
- removeAll() {
148
- this.notifications.forEach(notification => {
149
- this.remove(notification);
150
- });
151
- }
152
- setupAutoRemoval(notification, duration) {
153
- notification.timer = new Timer(duration, () => {
154
- this.remove(notification);
155
- });
156
- }
157
- }, _descriptor = _applyDecoratedDescriptor(_class.prototype, "notifications", [tracked], {
158
- configurable: true,
159
- enumerable: true,
160
- writable: true,
161
- initializer: function () {
162
- return [];
163
- }
164
- }), _class);
165
-
166
- export { Notification as N, Timer as T, NotificationsManager as a };
167
- //# sourceMappingURL=manager-CpMKYiRF.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"manager-CpMKYiRF.js","sources":["../src/-private/timer.ts","../src/-private/get-config.ts","../src/-private/notification.ts","../src/-private/manager.ts"],"sourcesContent":["/* eslint-disable ember/no-runloop */\nimport { 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 { get } from '@ember/object';\nimport type { DefaultConfig } from './types';\n\nexport function getConfigOption<T extends keyof DefaultConfig>(\n config: DefaultConfig,\n key: T,\n defaultValue: NonNullable<DefaultConfig[T]>\n): NonNullable<DefaultConfig[T]> {\n const value = get(config, key);\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, DefaultConfig } 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(\n config: DefaultConfig,\n message: string,\n options: NotificationOptions = {}\n ) {\n this.message = message;\n this.appearance =\n options.appearance || getConfigOption(config, 'appearance', 'info');\n this.customActions = options.customActions;\n this.duration =\n options.duration || getConfigOption(config, 'duration', 5000);\n this.transitionDuration =\n typeof options.transitionDuration !== 'undefined'\n ? options.transitionDuration\n : getConfigOption(config, '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","/* eslint-disable ember/no-runloop */\nimport Notification from './notification';\nimport Timer from './timer';\nimport { getConfigOption } from './get-config';\nimport { tracked } from '@glimmer/tracking';\nimport { later } from '@ember/runloop';\nimport { getOwner } from '@ember/owner';\nimport type { NotificationOptions } from './types';\nimport type Owner from '@ember/owner';\nimport { assert } from '@ember/debug';\nimport type { DefaultConfig } from './types';\n\nexport default class NotificationsManager {\n @tracked notifications: Notification[] = [];\n\n config: DefaultConfig = {};\n\n constructor(context: object) {\n const owner = getOwner(context) as Owner;\n assert('NotificationsManager context must have an owner', owner);\n const configFactory = owner.factoryFor('config:environment');\n\n if (configFactory && configFactory.class) {\n this.config =\n (configFactory.class as never)['@frontile/notifications'] || {};\n }\n }\n\n add(message: string, options: NotificationOptions = {}): Notification {\n const notification = new Notification(this.config, message, options);\n this.notifications = [...this.notifications, notification];\n\n let preserve =\n typeof options.preserve === 'undefined'\n ? getConfigOption(this.config, '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(this.config, '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"],"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","config","key","defaultValue","value","get","undefined","Notification","message","options","appearance","customActions","transitionDuration","allowClosing","remove","isRemoving","NotificationsManager","context","owner","getOwner","assert","configFactory","factoryFor","class","add","notification","notifications","preserve","setupAutoRemoval","filter","n","removeAll","forEach"],"mappings":";;;;;;;;;;;AAIuC,IAElBA,KAAK,IAAAC,QAAA,GAAX,MAAMD,KAAK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