@frontile/notifications 0.17.0-beta.2 → 0.17.0-beta.20
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/declarations/-private/get-config.d.ts +1 -2
- package/declarations/-private/manager.d.ts +7 -4
- package/declarations/-private/notification.d.ts +4 -4
- package/declarations/-private/timer.d.ts +0 -1
- package/declarations/-private/types.d.ts +7 -2
- package/declarations/components/notification-card.d.ts +19 -9
- package/declarations/components/notifications-container.d.ts +13 -2
- package/declarations/index.d.ts +0 -1
- package/declarations/services/notifications.d.ts +5 -4
- package/declarations/template-registry.d.ts +0 -1
- package/dist/components/notification-card.js +40 -56
- package/dist/components/notification-card.js.map +1 -1
- package/dist/components/notifications-container.js +27 -27
- package/dist/components/notifications-container.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/manager-C1Vyhk-A.js +175 -0
- package/dist/manager-C1Vyhk-A.js.map +1 -0
- package/dist/runtime-BPCpkOf1-B5Lbloj7.js +67 -0
- package/dist/runtime-BPCpkOf1-B5Lbloj7.js.map +1 -0
- package/dist/services/notifications.js +19 -15
- package/dist/services/notifications.js.map +1 -1
- package/package.json +48 -52
- package/declarations/-private/get-config.d.ts.map +0 -1
- package/declarations/-private/manager.d.ts.map +0 -1
- package/declarations/-private/notification.d.ts.map +0 -1
- package/declarations/-private/timer.d.ts.map +0 -1
- package/declarations/-private/types.d.ts.map +0 -1
- package/declarations/components/notification-card.d.ts.map +0 -1
- package/declarations/components/notifications-container.d.ts.map +0 -1
- package/declarations/get-config-a59d13fc.d.ts +0 -4
- package/declarations/get-config-a59d13fc.d.ts.map +0 -1
- package/declarations/index.d.ts.map +0 -1
- package/declarations/manager-IxquV5I2.d.ts +0 -11
- package/declarations/manager-IxquV5I2.d.ts.map +0 -1
- package/declarations/notification-64b501e5.d.ts +0 -16
- package/declarations/notification-64b501e5.d.ts.map +0 -1
- package/declarations/services/notifications.d.ts.map +0 -1
- package/declarations/template-registry.d.ts.map +0 -1
- package/declarations/timer-0a840cef.d.ts +0 -14
- package/declarations/timer-0a840cef.d.ts.map +0 -1
- package/declarations/types-16c08671.d.ts +0 -56
- package/declarations/types-16c08671.d.ts.map +0 -1
- package/dist/manager-IxquV5I2.js +0 -159
- package/dist/manager-IxquV5I2.js.map +0 -1
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { DefaultConfig } from './types';
|
|
2
|
-
export declare function getConfigOption<T extends keyof DefaultConfig>(key: T, defaultValue: NonNullable<DefaultConfig[T]>): NonNullable<DefaultConfig[T]>;
|
|
3
|
-
//# sourceMappingURL=get-config.d.ts.map
|
|
2
|
+
export declare function getConfigOption<T extends keyof DefaultConfig>(config: DefaultConfig, key: T, defaultValue: NonNullable<DefaultConfig[T]>): NonNullable<DefaultConfig[T]>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import Notification from './notification';
|
|
2
|
+
import type { DefaultConfig } from './types';
|
|
2
3
|
import type { NotificationOptions } from './types';
|
|
3
4
|
export default class NotificationsManager {
|
|
4
|
-
notifications: Notification[];
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
notifications: Notification<Record<string, unknown>>[];
|
|
6
|
+
config: DefaultConfig;
|
|
7
|
+
onRemove?: (notification: Notification<Record<string, unknown>>) => void;
|
|
8
|
+
constructor(context: object, onRemove?: (notification: Notification<Record<string, unknown>>) => void);
|
|
9
|
+
add<TMetadata extends Record<string, unknown> = Record<string, unknown>>(message: string, options?: NotificationOptions<TMetadata>): Notification<TMetadata>;
|
|
10
|
+
remove(notification?: Notification<Record<string, unknown>>): void;
|
|
7
11
|
removeAll(): void;
|
|
8
12
|
private setupAutoRemoval;
|
|
9
13
|
}
|
|
10
|
-
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import Timer from './timer';
|
|
2
|
-
import type { NotificationOptions, CustomAction } from './types';
|
|
3
|
-
export default class Notification {
|
|
2
|
+
import type { NotificationOptions, CustomAction, DefaultConfig } from './types';
|
|
3
|
+
export default class Notification<TMetadata extends Record<string, unknown> = Record<string, unknown>> {
|
|
4
4
|
readonly message: string;
|
|
5
5
|
readonly transitionDuration: number;
|
|
6
6
|
readonly appearance: NonNullable<NotificationOptions['appearance']>;
|
|
7
7
|
readonly customActions?: CustomAction[];
|
|
8
8
|
readonly allowClosing: boolean;
|
|
9
9
|
readonly duration: number;
|
|
10
|
+
readonly metadata?: TMetadata;
|
|
10
11
|
timer?: Timer;
|
|
11
12
|
isRemoving: boolean;
|
|
12
|
-
constructor(message: string, options?: NotificationOptions);
|
|
13
|
+
constructor(config: DefaultConfig, message: string, options?: NotificationOptions<TMetadata>);
|
|
13
14
|
remove(): void;
|
|
14
15
|
}
|
|
15
|
-
//# sourceMappingURL=notification.d.ts.map
|
|
@@ -9,7 +9,7 @@ export interface CustomAction {
|
|
|
9
9
|
*/
|
|
10
10
|
onClick: () => void;
|
|
11
11
|
}
|
|
12
|
-
export interface NotificationOptions {
|
|
12
|
+
export interface NotificationOptions<TMetadata extends Record<string, unknown> = Record<string, unknown>> {
|
|
13
13
|
/**
|
|
14
14
|
* If set to false, the close button will not be displayed.
|
|
15
15
|
*
|
|
@@ -41,6 +41,12 @@ export interface NotificationOptions {
|
|
|
41
41
|
* @defaultValue undefined
|
|
42
42
|
*/
|
|
43
43
|
customActions?: CustomAction[];
|
|
44
|
+
/**
|
|
45
|
+
* Additional metadata to attach to the notification
|
|
46
|
+
*
|
|
47
|
+
* @defaultValue undefined
|
|
48
|
+
*/
|
|
49
|
+
metadata?: TMetadata;
|
|
44
50
|
}
|
|
45
51
|
export interface DefaultConfig extends NotificationOptions {
|
|
46
52
|
/**
|
|
@@ -52,4 +58,3 @@ export interface DefaultConfig extends NotificationOptions {
|
|
|
52
58
|
*/
|
|
53
59
|
skipTimer?: boolean;
|
|
54
60
|
}
|
|
55
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -4,7 +4,7 @@ import type Notification from '../-private/notification';
|
|
|
4
4
|
import type { CustomAction, containerPlacement } from '../-private/types';
|
|
5
5
|
interface NotificationCardSignature {
|
|
6
6
|
Args: {
|
|
7
|
-
notification: Notification
|
|
7
|
+
notification: Notification<Record<string, unknown>>;
|
|
8
8
|
placement: containerPlacement;
|
|
9
9
|
/**
|
|
10
10
|
* Spacing for each notification, in px.
|
|
@@ -19,13 +19,24 @@ declare class NotificationCard extends Component<NotificationCardSignature> {
|
|
|
19
19
|
notifications: NotificationsService;
|
|
20
20
|
hasEntered: boolean;
|
|
21
21
|
get styles(): unknown;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
transitionIn: import("ember-modifier").FunctionBasedModifier<{
|
|
23
|
+
Args: {
|
|
24
|
+
Positional: unknown[];
|
|
25
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
26
|
+
};
|
|
27
|
+
Element: HTMLElement;
|
|
28
|
+
}>;
|
|
29
|
+
transitionOut: import("ember-modifier").FunctionBasedModifier<{
|
|
30
|
+
Args: {
|
|
31
|
+
Positional: boolean[];
|
|
32
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
33
|
+
};
|
|
34
|
+
Element: HTMLElement;
|
|
35
|
+
}>;
|
|
36
|
+
remove: () => void;
|
|
37
|
+
pause: () => void;
|
|
38
|
+
resume: () => void;
|
|
39
|
+
handleClickCustomAction: (customAction: CustomAction) => void;
|
|
29
40
|
get classes(): {
|
|
30
41
|
base: string;
|
|
31
42
|
message: string;
|
|
@@ -36,4 +47,3 @@ declare class NotificationCard extends Component<NotificationCardSignature> {
|
|
|
36
47
|
}
|
|
37
48
|
export { NotificationCard, type NotificationCardSignature };
|
|
38
49
|
export default NotificationCard;
|
|
39
|
-
//# sourceMappingURL=notification-card.d.ts.map
|
|
@@ -2,6 +2,7 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import type NotificationsService from '../services/notifications';
|
|
3
3
|
import type Notification from '../-private/notification';
|
|
4
4
|
import { type containerPlacement } from '../-private/types';
|
|
5
|
+
import type Owner from '@ember/owner';
|
|
5
6
|
interface NotificationsContainerSignature {
|
|
6
7
|
Args: {
|
|
7
8
|
/**
|
|
@@ -20,16 +21,26 @@ interface NotificationsContainerSignature {
|
|
|
20
21
|
* Custom class name, it will override the default ones using Tailwind Merge library.
|
|
21
22
|
*/
|
|
22
23
|
class?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Callback called when a notification is dismissed
|
|
26
|
+
*/
|
|
27
|
+
onDismiss?: (notification: Notification<Record<string, unknown>>) => void;
|
|
23
28
|
};
|
|
24
29
|
Element: HTMLDivElement;
|
|
25
30
|
}
|
|
26
31
|
declare class NotificationsContainer extends Component<NotificationsContainerSignature> {
|
|
27
32
|
notifications: NotificationsService;
|
|
33
|
+
constructor(owner: Owner, args: NotificationsContainerSignature['Args']);
|
|
28
34
|
get isTopPlacement(): boolean;
|
|
29
35
|
get sortedNotifications(): Notification[];
|
|
30
36
|
get classes(): string;
|
|
31
|
-
|
|
37
|
+
setupSpacing: import("ember-modifier").FunctionBasedModifier<{
|
|
38
|
+
Args: {
|
|
39
|
+
Positional: unknown[];
|
|
40
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
41
|
+
};
|
|
42
|
+
Element: HTMLElement;
|
|
43
|
+
}>;
|
|
32
44
|
}
|
|
33
45
|
export { NotificationsContainer, type NotificationsContainerSignature };
|
|
34
46
|
export default NotificationsContainer;
|
|
35
|
-
//# sourceMappingURL=notifications-container.d.ts.map
|
package/declarations/index.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ import Notification from '../-private/notification';
|
|
|
3
3
|
import NotificationsManager from '../-private/manager';
|
|
4
4
|
import type { NotificationOptions } from '../-private/types';
|
|
5
5
|
export default class NotificationsService extends Service {
|
|
6
|
+
onRemoveCallback?: (notification: Notification<Record<string, unknown>>) => void;
|
|
6
7
|
manager: NotificationsManager;
|
|
7
|
-
get notifications(): Notification[];
|
|
8
|
-
add: (message: string, options?: NotificationOptions) => Notification
|
|
9
|
-
remove: (notification?: Notification) => void;
|
|
8
|
+
get notifications(): Notification<Record<string, unknown>>[];
|
|
9
|
+
add: <TMetadata extends Record<string, unknown> = Record<string, unknown>>(message: string, options?: NotificationOptions<TMetadata>) => Notification<TMetadata>;
|
|
10
|
+
remove: (notification?: Notification<Record<string, unknown>>) => void;
|
|
10
11
|
removeAll: () => void;
|
|
12
|
+
setOnRemoveCallback: (callback?: (notification: Notification<Record<string, unknown>>) => void) => void;
|
|
11
13
|
willDestroy(): void;
|
|
12
14
|
}
|
|
13
15
|
declare module '@ember/service' {
|
|
@@ -15,4 +17,3 @@ declare module '@ember/service' {
|
|
|
15
17
|
notifications: NotificationsService;
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
|
-
//# sourceMappingURL=notifications.d.ts.map
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import _initializerDefineProperty from '@babel/runtime/helpers/esm/initializerDefineProperty';
|
|
2
|
-
import '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
-
import _applyDecoratedDescriptor from '@babel/runtime/helpers/esm/applyDecoratedDescriptor';
|
|
4
|
-
import '@babel/runtime/helpers/esm/initializerWarningHelper';
|
|
5
1
|
import Component from '@glimmer/component';
|
|
2
|
+
import { modifier } from 'ember-modifier';
|
|
6
3
|
import { tracked } from '@glimmer/tracking';
|
|
7
|
-
import {
|
|
8
|
-
import { inject } from '@ember/service';
|
|
4
|
+
import { service } from '@ember/service';
|
|
9
5
|
import { htmlSafe } from '@ember/template';
|
|
10
6
|
import { later } from '@ember/runloop';
|
|
11
7
|
import { on } from '@ember/modifier';
|
|
12
|
-
import {
|
|
13
|
-
import didUpdate from '@ember/render-modifiers/modifiers/did-update';
|
|
14
|
-
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
|
|
8
|
+
import { fn, concat } from '@ember/helper';
|
|
15
9
|
import { CloseButton } from '@frontile/buttons';
|
|
16
10
|
import { cssTransition } from 'ember-css-transitions';
|
|
17
11
|
import { useStyles } from '@frontile/theme';
|
|
18
12
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
19
13
|
import { setComponentTemplate } from '@ember/component';
|
|
14
|
+
import { d as decorateFieldV2, i as initializeDeferredDecorator } from '../runtime-BPCpkOf1-B5Lbloj7.js';
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
_initializerDefineProperty(this, "notifications", _descriptor, this);
|
|
26
|
-
_initializerDefineProperty(this, "hasEntered", _descriptor2, this);
|
|
16
|
+
/* eslint-disable ember/no-runloop */
|
|
17
|
+
class NotificationCard extends Component {
|
|
18
|
+
static {
|
|
19
|
+
decorateFieldV2(this.prototype, "notifications", [service]);
|
|
27
20
|
}
|
|
21
|
+
#notifications = (initializeDeferredDecorator(this, "notifications"), void 0);
|
|
22
|
+
static {
|
|
23
|
+
decorateFieldV2(this.prototype, "hasEntered", [tracked], function () {
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
#hasEntered = (initializeDeferredDecorator(this, "hasEntered"), void 0);
|
|
28
28
|
get styles() {
|
|
29
29
|
const styles = [`transition-duration: ${this.args.notification.transitionDuration}ms`];
|
|
30
30
|
if (!this.hasEntered) {
|
|
@@ -32,12 +32,7 @@ let NotificationCard = (_class = (_NotificationCard = class NotificationCard ext
|
|
|
32
32
|
}
|
|
33
33
|
return htmlSafe(styles.join('; '));
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
if (this.args.placement && this.args.placement.includes('top')) {
|
|
37
|
-
element.style.marginTop = `${this.args.spacing || 16}px`;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
transitionIn(element) {
|
|
35
|
+
transitionIn = modifier(element => {
|
|
41
36
|
const spacing = typeof this.args.spacing === 'undefined' ? 16 : this.args.spacing;
|
|
42
37
|
const expectedHeight = element.offsetHeight + spacing;
|
|
43
38
|
const duration = this.args.notification.transitionDuration / 2;
|
|
@@ -52,29 +47,29 @@ let NotificationCard = (_class = (_NotificationCard = class NotificationCard ext
|
|
|
52
47
|
later(this, () => {
|
|
53
48
|
this.hasEntered = true;
|
|
54
49
|
}, this.args.notification.transitionDuration);
|
|
55
|
-
}
|
|
56
|
-
transitionOut(element, [isExiting, ..._]) {
|
|
50
|
+
});
|
|
51
|
+
transitionOut = modifier((element, [isExiting, ..._]) => {
|
|
57
52
|
if (isExiting) {
|
|
58
53
|
element.style.height = '0';
|
|
59
54
|
}
|
|
60
|
-
}
|
|
61
|
-
remove() {
|
|
55
|
+
});
|
|
56
|
+
remove = () => {
|
|
62
57
|
this.notifications.remove(this.args.notification);
|
|
63
|
-
}
|
|
64
|
-
pause() {
|
|
58
|
+
};
|
|
59
|
+
pause = () => {
|
|
65
60
|
if (this.args.notification.timer) {
|
|
66
61
|
this.args.notification.timer.pause();
|
|
67
62
|
}
|
|
68
|
-
}
|
|
69
|
-
resume() {
|
|
63
|
+
};
|
|
64
|
+
resume = () => {
|
|
70
65
|
if (this.args.notification.timer) {
|
|
71
66
|
this.args.notification.timer.resume();
|
|
72
67
|
}
|
|
73
|
-
}
|
|
74
|
-
handleClickCustomAction
|
|
68
|
+
};
|
|
69
|
+
handleClickCustomAction = customAction => {
|
|
75
70
|
customAction.onClick();
|
|
76
|
-
this.remove();
|
|
77
|
-
}
|
|
71
|
+
this.notifications.remove(this.args.notification);
|
|
72
|
+
};
|
|
78
73
|
get classes() {
|
|
79
74
|
const {
|
|
80
75
|
notificationCard
|
|
@@ -96,30 +91,19 @@ let NotificationCard = (_class = (_NotificationCard = class NotificationCard ext
|
|
|
96
91
|
closeButton: closeButton()
|
|
97
92
|
};
|
|
98
93
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}), _NotificationCard), _NotificationCard), _descriptor = _applyDecoratedDescriptor(_class.prototype, "notifications", [inject], {
|
|
111
|
-
configurable: true,
|
|
112
|
-
enumerable: true,
|
|
113
|
-
writable: true,
|
|
114
|
-
initializer: null
|
|
115
|
-
}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "hasEntered", [tracked], {
|
|
116
|
-
configurable: true,
|
|
117
|
-
enumerable: true,
|
|
118
|
-
writable: true,
|
|
119
|
-
initializer: function () {
|
|
120
|
-
return false;
|
|
94
|
+
static {
|
|
95
|
+
setComponentTemplate(precompileTemplate("\n {{!-- template-lint-disable no-invalid-interactive --}}\n {{!-- template-lint-disable no-unnecessary-concat --}}\n {{!-- template-lint-disable no-inline-styles --}}\n {{!-- template-lint-disable style-concatenation --}}\n <div {{this.transitionIn}} {{this.transitionOut @notification.isRemoving}}>\n {{#unless @notification.isRemoving}}\n <div {{on \"mouseenter\" this.pause}} {{on \"mouseleave\" this.resume}} {{cssTransition (concat \"notification-transition--slide-from-\" @placement) isEnabled=true}} class={{this.classes.base}} style=\"{{this.styles}}\" ...attributes>\n <div class={{this.classes.message}}>\n {{@notification.message}}\n </div>\n\n {{#if @notification.customActions}}\n <div class={{this.classes.customActions}}>\n {{#each @notification.customActions as |customAction|}}\n <button type=\"button\" class={{this.classes.customActionButton}} {{on \"click\" (fn this.handleClickCustomAction customAction)}}>\n {{customAction.label}}\n </button>\n {{/each}}\n </div>\n {{/if}}\n\n {{#if @notification.allowClosing}}\n <CloseButton @onPress={{this.remove}} @size=\"sm\" @class={{this.classes.closeButton}} />\n {{/if}}\n </div>\n {{/unless}}\n </div>\n ", {
|
|
96
|
+
strictMode: true,
|
|
97
|
+
scope: () => ({
|
|
98
|
+
on,
|
|
99
|
+
cssTransition,
|
|
100
|
+
concat,
|
|
101
|
+
fn,
|
|
102
|
+
CloseButton
|
|
103
|
+
})
|
|
104
|
+
}), this);
|
|
121
105
|
}
|
|
122
|
-
}
|
|
106
|
+
}
|
|
123
107
|
|
|
124
108
|
export { NotificationCard, NotificationCard as default };
|
|
125
109
|
//# sourceMappingURL=notification-card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-card.js","sources":["../../src/components/notification-card.gts"],"sourcesContent":["/* eslint-disable ember/no-at-ember-render-modifiers, ember/no-runloop */\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { inject as service } from '@ember/service';\nimport { htmlSafe } from '@ember/template';\nimport { later } from '@ember/runloop';\nimport { on } from '@ember/modifier';\nimport { fn, concat } from '@ember/helper';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport { CloseButton } from '@frontile/buttons';\nimport { cssTransition } from 'ember-css-transitions';\nimport { useStyles } from '@frontile/theme';\n\nimport type NotificationsService from '../services/notifications';\nimport type Notification from '../-private/notification';\nimport type { CustomAction, containerPlacement } from '../-private/types';\n\ninterface NotificationCardSignature {\n Args: {\n notification: Notification;\n placement: containerPlacement;\n\n /**\n * Spacing for each notification, in px.\n *\n * @defaultValue 16\n */\n spacing?: number;\n };\n Element: HTMLDivElement;\n}\n\nclass NotificationCard extends Component<NotificationCardSignature> {\n @service notifications!: NotificationsService;\n @tracked hasEntered = false;\n\n get styles(): unknown {\n const styles = [\n `transition-duration: ${this.args.notification.transitionDuration}ms`\n ];\n\n if (!this.hasEntered) {\n styles.push(\n `transition-delay: ${this.args.notification.transitionDuration}ms`\n );\n }\n\n return htmlSafe(styles.join('; '));\n }\n\n @action addSpacing(element: HTMLElement): void {\n if (this.args.placement && this.args.placement.includes('top')) {\n element.style.marginTop = `${this.args.spacing || 16}px`;\n }\n }\n\n @action transitionIn(element: HTMLElement): void {\n const spacing =\n typeof this.args.spacing === 'undefined' ? 16 : this.args.spacing;\n const expectedHeight = element.offsetHeight + spacing;\n const duration = this.args.notification.transitionDuration / 2;\n\n requestAnimationFrame(() => {\n element.style.height = '0';\n const transition = `height ${duration}ms ease-in ${duration}ms`;\n element.style.transition = transition;\n\n requestAnimationFrame(() => {\n element.style.height = `${expectedHeight}px`;\n });\n });\n\n later(\n this,\n () => {\n this.hasEntered = true;\n },\n this.args.notification.transitionDuration\n );\n }\n\n @action transitionOut(\n element: HTMLElement,\n [isExiting, ..._]: boolean[]\n ): void {\n if (isExiting) {\n element.style.height = '0';\n }\n }\n\n @action remove(): void {\n this.notifications.remove(this.args.notification);\n }\n\n @action pause(): void {\n if (this.args.notification.timer) {\n this.args.notification.timer.pause();\n }\n }\n\n @action resume(): void {\n if (this.args.notification.timer) {\n this.args.notification.timer.resume();\n }\n }\n\n @action handleClickCustomAction(customAction: CustomAction): void {\n customAction.onClick();\n this.remove();\n }\n\n get classes() {\n const { notificationCard } = useStyles();\n\n let { base, message, customActions, customActionButton, closeButton } =\n notificationCard({\n appearance: this.args.notification.appearance\n });\n\n return {\n base: base(),\n message: message(),\n customActions: customActions(),\n customActionButton: customActionButton(),\n closeButton: closeButton()\n };\n }\n\n <template>\n {{! template-lint-disable no-invalid-interactive }}\n {{! template-lint-disable no-unnecessary-concat }}\n {{! template-lint-disable no-inline-styles }}\n {{! template-lint-disable style-concatenation }}\n <div\n {{didInsert this.transitionIn}}\n {{didUpdate this.transitionOut @notification.isRemoving}}\n >\n {{#unless @notification.isRemoving}}\n <div\n {{on \"mouseenter\" this.pause}}\n {{on \"mouseleave\" this.resume}}\n {{cssTransition\n (concat \"notification-transition--slide-from-\" @placement)\n isEnabled=true\n }}\n class={{this.classes.base}}\n style=\"{{this.styles}}\"\n ...attributes\n >\n <div class={{this.classes.message}}>\n {{@notification.message}}\n </div>\n\n {{#if @notification.customActions}}\n <div class={{this.classes.customActions}}>\n {{#each @notification.customActions as |customAction|}}\n <button\n type=\"button\"\n class={{this.classes.customActionButton}}\n {{on \"click\" (fn this.handleClickCustomAction customAction)}}\n >\n {{customAction.label}}\n </button>\n {{/each}}\n </div>\n {{/if}}\n\n {{#if @notification.allowClosing}}\n <CloseButton\n @onClick={{this.remove}}\n @size=\"sm\"\n @class={{this.classes.closeButton}}\n />\n {{/if}}\n </div>\n {{/unless}}\n </div>\n </template>\n}\n\nexport { NotificationCard, type NotificationCardSignature };\nexport default NotificationCard;\n"],"names":["NotificationCard","Component","constructor","args","_initializerDefineProperty","_descriptor","_descriptor2","styles","notification","transitionDuration","hasEntered","push","htmlSafe","join","addSpacing","element","placement","includes","style","marginTop","spacing","transitionIn","expectedHeight","offsetHeight","duration","requestAnimationFrame","height","transition","later","transitionOut","isExiting","_","remove","notifications","pause","timer","resume","handleClickCustomAction","customAction","onClick","classes","notificationCard","useStyles","base","message","customActions","customActionButton","closeButton","appearance","setComponentTemplate","precompileTemplate","strictMode","scope","didInsert","didUpdate","on","cssTransition","concat","fn","CloseButton","_NotificationCard","_applyDecoratedDescriptor","_class","prototype","service","configurable","enumerable","writable","initializer","tracked","action","Object","getOwnPropertyDescriptor"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCMA,IAAAA,kDAAN,MAAMA,yBAAyBC,SAAU,CAAA;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;AAAAC,IAAAA,0BAAA,wBAAAC,WAAA,EAAA,IAAA,CAAA;AAAAD,IAAAA,0BAAA,qBAAAE,YAAA,EAAA,IAAA,CAAA;AAAA;EAIvC,IAAIC,MAAAA,GAAkB;AACpB,IAAA,MAAMA,MAAS,GAAA,CACb,CAAA,qBAAA,EAAwB,IAAI,CAACJ,IAAI,CAACK,YAAY,CAACC,kBAAkB,CAAA,EAAA,CAAI,CACtE;AAED,IAAA,IAAI,CAAC,IAAI,CAACC,UAAU,EAAE;AACpBH,MAAAA,MAAA,CAAOI,IAAI,CACT,CAAA,kBAAA,EAAqB,IAAI,CAACR,IAAI,CAACK,YAAY,CAACC,kBAAkB,CAAA,EAAA,CAAI,CAAA;AAEtE;IAEA,OAAOG,QAAA,CAASL,MAAO,CAAAM,IAAI,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CAAAF,EAAAA,yBAAA,CAAAC,MAAA,CAAAC,SAAA,EASAO,QAAAA,EAAAA,CAAAA,MAAA,GAAAC,MAAA,CAAAC,wBAAA,CAAAV,MAAA,CAAAC,SAAA,EAAA,QAAA,CAAA,EAAAD,MAAA,CAAAC,SAAA,CAAAF,EAAAA,yBAAA,CAAAC,MAAA,CAAAC,SAAA,YAIAO,MAAA,CAAA,EAAAC,MAAA,CAAAC,wBAAA,CAAAV,MAAA,CAAAC,SAAA,EAAAD,OAAAA,CAAAA,EAAAA,MAAA,CAAAC,SAAA,CAAAF,EAAAA,yBAAA,CAAAC,MAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CAMAO,MAAA,CAAA,EAAAC,MAAA,CAAAC,wBAAA,CAAAV,MAAA,CAAAC,SAAA,EAAAD,QAAAA,CAAAA,EAAAA,MAAA,CAAAC,SAAA,CAAAF,EAAAA,yBAAA,CAAAC,MAAA,CAAAC,SAAA,EAAA,yBAAA,EAAA,CAMAO,MAAA,CAAA,EAAAC,MAAA,CAAAC,wBAAA,CAAAV,MAAA,CAAAC,SAAA,EAAAD,yBAAAA,CAAAA,EAAAA,MAAA,CAAAC,SAAA,GAAAD,MAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"notification-card.js","sources":["../../src/components/notification-card.gts"],"sourcesContent":["/* eslint-disable ember/no-runloop */\nimport Component from '@glimmer/component';\nimport { modifier } from 'ember-modifier';\nimport { tracked } from '@glimmer/tracking';\nimport { service } from '@ember/service';\nimport { htmlSafe } from '@ember/template';\nimport { later } from '@ember/runloop';\nimport { on } from '@ember/modifier';\nimport { fn, concat } from '@ember/helper';\nimport { CloseButton } from '@frontile/buttons';\nimport { cssTransition } from 'ember-css-transitions';\nimport { useStyles } from '@frontile/theme';\n\nimport type NotificationsService from '../services/notifications';\nimport type Notification from '../-private/notification';\nimport type { CustomAction, containerPlacement } from '../-private/types';\n\ninterface NotificationCardSignature {\n Args: {\n notification: Notification<Record<string, unknown>>;\n placement: containerPlacement;\n\n /**\n * Spacing for each notification, in px.\n *\n * @defaultValue 16\n */\n spacing?: number;\n };\n Element: HTMLDivElement;\n}\n\nclass NotificationCard extends Component<NotificationCardSignature> {\n @service notifications!: NotificationsService;\n @tracked hasEntered = false;\n\n get styles(): unknown {\n const styles = [\n `transition-duration: ${this.args.notification.transitionDuration}ms`\n ];\n\n if (!this.hasEntered) {\n styles.push(\n `transition-delay: ${this.args.notification.transitionDuration}ms`\n );\n }\n\n return htmlSafe(styles.join('; '));\n }\n\n transitionIn = modifier((element: HTMLElement) => {\n const spacing =\n typeof this.args.spacing === 'undefined' ? 16 : this.args.spacing;\n const expectedHeight = element.offsetHeight + spacing;\n const duration = this.args.notification.transitionDuration / 2;\n\n requestAnimationFrame(() => {\n element.style.height = '0';\n const transition = `height ${duration}ms ease-in ${duration}ms`;\n element.style.transition = transition;\n\n requestAnimationFrame(() => {\n element.style.height = `${expectedHeight}px`;\n });\n });\n\n later(\n this,\n () => {\n this.hasEntered = true;\n },\n this.args.notification.transitionDuration\n );\n });\n\n transitionOut = modifier(\n (element: HTMLElement, [isExiting, ..._]: boolean[]) => {\n if (isExiting) {\n element.style.height = '0';\n }\n }\n );\n\n remove = () => {\n this.notifications.remove(this.args.notification);\n };\n\n pause = () => {\n if (this.args.notification.timer) {\n this.args.notification.timer.pause();\n }\n };\n\n resume = () => {\n if (this.args.notification.timer) {\n this.args.notification.timer.resume();\n }\n };\n\n handleClickCustomAction = (customAction: CustomAction) => {\n customAction.onClick();\n this.notifications.remove(this.args.notification);\n };\n\n get classes() {\n const { notificationCard } = useStyles();\n\n let { base, message, customActions, customActionButton, closeButton } =\n notificationCard({\n appearance: this.args.notification.appearance\n });\n\n return {\n base: base(),\n message: message(),\n customActions: customActions(),\n customActionButton: customActionButton(),\n closeButton: closeButton()\n };\n }\n\n <template>\n {{! template-lint-disable no-invalid-interactive }}\n {{! template-lint-disable no-unnecessary-concat }}\n {{! template-lint-disable no-inline-styles }}\n {{! template-lint-disable style-concatenation }}\n <div {{this.transitionIn}} {{this.transitionOut @notification.isRemoving}}>\n {{#unless @notification.isRemoving}}\n <div\n {{on \"mouseenter\" this.pause}}\n {{on \"mouseleave\" this.resume}}\n {{cssTransition\n (concat \"notification-transition--slide-from-\" @placement)\n isEnabled=true\n }}\n class={{this.classes.base}}\n style=\"{{this.styles}}\"\n ...attributes\n >\n <div class={{this.classes.message}}>\n {{@notification.message}}\n </div>\n\n {{#if @notification.customActions}}\n <div class={{this.classes.customActions}}>\n {{#each @notification.customActions as |customAction|}}\n <button\n type=\"button\"\n class={{this.classes.customActionButton}}\n {{on \"click\" (fn this.handleClickCustomAction customAction)}}\n >\n {{customAction.label}}\n </button>\n {{/each}}\n </div>\n {{/if}}\n\n {{#if @notification.allowClosing}}\n <CloseButton\n @onPress={{this.remove}}\n @size=\"sm\"\n @class={{this.classes.closeButton}}\n />\n {{/if}}\n </div>\n {{/unless}}\n </div>\n </template>\n}\n\nexport { NotificationCard, type NotificationCardSignature };\nexport default NotificationCard;\n"],"names":["NotificationCard","Component","g","prototype","service","i","void 0","tracked","styles","args","notification","transitionDuration","hasEntered","push","htmlSafe","join","transitionIn","modifier","element","spacing","expectedHeight","offsetHeight","duration","requestAnimationFrame","style","height","transition","later","transitionOut","isExiting","_","remove","notifications","pause","timer","resume","handleClickCustomAction","customAction","onClick","classes","notificationCard","useStyles","base","message","customActions","customActionButton","closeButton","appearance","setComponentTemplate","precompileTemplate","strictMode","scope","on","cssTransition","concat","fn","CloseButton"],"mappings":";;;;;;;;;;;;;;;AAAA;AAgCA,MAAMA,yBAAyBC,SAAA,CAAU;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,eAAA,EAAA,CACtCC,OAAA,CAAA,CAAA;AAAA;AAAA,EAAA,cAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,eAAA,CAAA,EAAAC,MAAA;AAAA,EAAA;IAAAJ,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAAA,EAAA,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C,IAAI;MAAEC,OAAO;MAAEC,aAAa;MAAEC,kBAAkB;AAAEC,MAAAA;KAAa,GACnEN,gBAAA,CAAiB;AACfO,MAAAA,UAAA,EAAY,IAAI,CAACtC,IAAI,CAACC,YAAY,CAACqC;AACrC,KAAA,CAAA;IAEF,OAAO;MACLL,IAAA,EAAMA,IAAA,EAAA;MACNC,OAAA,EAASA,OAAA,EAAA;MACTC,aAAA,EAAeA,aAAA,EAAA;MACfC,kBAAA,EAAoBA,kBAAA,EAAA;MACpBC,WAAA,EAAaA,WAAA;KACf;AACF,EAAA;AAEA,EAAA;IAAAE,oBAAA,CAAAC,kBAAA,CAAA,62CAAA,EA8CA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,EAAA;QAAAC,aAAA;QAAAC,MAAA;QAAAC,EAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import _initializerDefineProperty from '@babel/runtime/helpers/esm/initializerDefineProperty';
|
|
2
|
-
import '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
-
import _applyDecoratedDescriptor from '@babel/runtime/helpers/esm/applyDecoratedDescriptor';
|
|
4
|
-
import '@babel/runtime/helpers/esm/initializerWarningHelper';
|
|
5
1
|
import Component from '@glimmer/component';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
|
|
2
|
+
import { service } from '@ember/service';
|
|
3
|
+
import { modifier } from 'ember-modifier';
|
|
4
|
+
import { registerDestructor } from '@ember/destroyable';
|
|
10
5
|
import { NotificationCard } from './notification-card.js';
|
|
11
6
|
import { useStyles } from '@frontile/theme';
|
|
12
7
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
13
8
|
import { setComponentTemplate } from '@ember/component';
|
|
9
|
+
import { d as decorateFieldV2, i as initializeDeferredDecorator } from '../runtime-BPCpkOf1-B5Lbloj7.js';
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
class NotificationsContainer extends Component {
|
|
12
|
+
static {
|
|
13
|
+
decorateFieldV2(this.prototype, "notifications", [service]);
|
|
14
|
+
}
|
|
15
|
+
#notifications = (initializeDeferredDecorator(this, "notifications"), void 0);
|
|
16
|
+
constructor(owner, args) {
|
|
17
|
+
super(owner, args);
|
|
18
|
+
// Set the onDismiss callback on the service
|
|
19
|
+
this.notifications.setOnRemoveCallback(this.args.onDismiss);
|
|
20
|
+
// Clean up when component is destroyed
|
|
21
|
+
registerDestructor(this, () => {
|
|
22
|
+
this.notifications.setOnRemoveCallback(undefined);
|
|
23
|
+
});
|
|
20
24
|
}
|
|
21
25
|
get isTopPlacement() {
|
|
22
26
|
return !!(this.args.placement && this.args.placement.includes('top'));
|
|
@@ -37,25 +41,21 @@ let NotificationsContainer = (_class = (_NotificationsContainer = class Notifica
|
|
|
37
41
|
class: this.args.class
|
|
38
42
|
});
|
|
39
43
|
}
|
|
40
|
-
|
|
44
|
+
setupSpacing = modifier(element => {
|
|
41
45
|
const spacing = typeof this.args.spacing === 'undefined' ? 16 : this.args.spacing;
|
|
42
46
|
if (this.isTopPlacement) {
|
|
43
47
|
element.style.marginTop = `${spacing}px`;
|
|
44
48
|
}
|
|
49
|
+
});
|
|
50
|
+
static {
|
|
51
|
+
setComponentTemplate(precompileTemplate("\n {{#if this.sortedNotifications}}\n <div {{this.setupSpacing @spacing @placement}} class={{this.classes}} role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" ...attributes>\n {{#each this.sortedNotifications as |notification|}}\n <NotificationCard @spacing={{@spacing}} @placement={{if @placement @placement \"bottom-right\"}} @notification={{notification}} />\n {{/each}}\n </div>\n {{/if}}\n ", {
|
|
52
|
+
strictMode: true,
|
|
53
|
+
scope: () => ({
|
|
54
|
+
NotificationCard
|
|
55
|
+
})
|
|
56
|
+
}), this);
|
|
45
57
|
}
|
|
46
|
-
}
|
|
47
|
-
strictMode: true,
|
|
48
|
-
scope: () => ({
|
|
49
|
-
didInsert,
|
|
50
|
-
didUpdate,
|
|
51
|
-
NotificationCard
|
|
52
|
-
})
|
|
53
|
-
}), _NotificationsContainer), _NotificationsContainer), _descriptor = _applyDecoratedDescriptor(_class.prototype, "notifications", [inject], {
|
|
54
|
-
configurable: true,
|
|
55
|
-
enumerable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
initializer: null
|
|
58
|
-
}), _applyDecoratedDescriptor(_class.prototype, "addSpacing", [action], Object.getOwnPropertyDescriptor(_class.prototype, "addSpacing"), _class.prototype), _class);
|
|
58
|
+
}
|
|
59
59
|
|
|
60
60
|
export { NotificationsContainer, NotificationsContainer as default };
|
|
61
61
|
//# sourceMappingURL=notifications-container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications-container.js","sources":["../../src/components/notifications-container.gts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"notifications-container.js","sources":["../../src/components/notifications-container.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { service } from '@ember/service';\nimport { modifier } from 'ember-modifier';\nimport { registerDestructor } from '@ember/destroyable';\nimport NotificationCard from './notification-card';\nimport type NotificationsService from '../services/notifications';\nimport type Notification from '../-private/notification';\nimport { type containerPlacement } from '../-private/types';\nimport { useStyles } from '@frontile/theme';\nimport type Owner from '@ember/owner';\n\ninterface NotificationsContainerSignature {\n Args: {\n /**\n * The placement of the notifications\n *\n * @defaultValue 'bottom-right'\n */\n placement?: containerPlacement;\n /**\n * Spacing for each notification, in px.\n *\n * @defaultValue 16\n */\n spacing?: number;\n\n /**\n * Custom class name, it will override the default ones using Tailwind Merge library.\n */\n class?: string;\n\n /**\n * Callback called when a notification is dismissed\n */\n onDismiss?: (notification: Notification<Record<string, unknown>>) => void;\n };\n Element: HTMLDivElement;\n}\n\nclass NotificationsContainer extends Component<NotificationsContainerSignature> {\n @service notifications!: NotificationsService;\n\n constructor(owner: Owner, args: NotificationsContainerSignature['Args']) {\n super(owner, args);\n\n // Set the onDismiss callback on the service\n this.notifications.setOnRemoveCallback(this.args.onDismiss);\n\n // Clean up when component is destroyed\n registerDestructor(this, () => {\n this.notifications.setOnRemoveCallback(undefined);\n });\n }\n\n get isTopPlacement(): boolean {\n return !!(this.args.placement && this.args.placement.includes('top'));\n }\n\n get sortedNotifications(): Notification[] {\n if (this.isTopPlacement) {\n return this.notifications.notifications.slice().reverse();\n } else {\n return this.notifications.notifications;\n }\n }\n\n get classes() {\n const { notificationsContainer } = useStyles();\n\n return notificationsContainer({\n placement: this.args.placement,\n class: this.args.class\n });\n }\n\n setupSpacing = modifier((element: HTMLElement) => {\n const spacing =\n typeof this.args.spacing === 'undefined' ? 16 : this.args.spacing;\n if (this.isTopPlacement) {\n element.style.marginTop = `${spacing}px`;\n }\n });\n\n <template>\n {{#if this.sortedNotifications}}\n <div\n {{this.setupSpacing @spacing @placement}}\n class={{this.classes}}\n role=\"alert\"\n aria-live=\"assertive\"\n aria-atomic=\"true\"\n ...attributes\n >\n {{#each this.sortedNotifications as |notification|}}\n <NotificationCard\n @spacing={{@spacing}}\n @placement={{if @placement @placement \"bottom-right\"}}\n @notification={{notification}}\n />\n {{/each}}\n </div>\n {{/if}}\n </template>\n}\n\nexport { NotificationsContainer, type NotificationsContainerSignature };\nexport default NotificationsContainer;\n"],"names":["NotificationsContainer","Component","g","prototype","service","i","void 0","constructor","owner","args","notifications","setOnRemoveCallback","onDismiss","registerDestructor","undefined","isTopPlacement","placement","includes","sortedNotifications","slice","reverse","classes","notificationsContainer","useStyles","class","setupSpacing","modifier","element","spacing","style","marginTop","setComponentTemplate","precompileTemplate","strictMode","scope","NotificationCard"],"mappings":";;;;;;;;;;AAuCA,MAAMA,+BAA+BC,SAAA,CAAU;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,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AO,KAAK,WAAA,GAAc,EAAA,GAAK,IAAI,CAACnB,IAAI,CAACmB,OAAO;IACnE,IAAI,IAAI,CAACb,cAAc,EAAE;AACvBY,MAAAA,OAAA,CAAQE,KAAK,CAACC,SAAS,GAAG,CAAA,EAAGF,OAAA,CAAA,EAAA,CAAW;AAC1C,IAAA;AACF,EAAA,CAAA,CAAA;AAEA,EAAA;IAAAG,oBAAA,CAAAC,kBAAA,CAAA,8bAAA,EAmBA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { N as Notification, T as Timer } from './manager-
|
|
2
|
-
import '@babel/runtime/helpers/esm/defineProperty';
|
|
1
|
+
export { N as Notification, T as Timer } from './manager-C1Vyhk-A.js';
|
|
3
2
|
import '@ember/service';
|
|
4
3
|
export { NotificationCard } from './components/notification-card.js';
|
|
5
4
|
export { NotificationsContainer } from './components/notifications-container.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|