@servicetitan/notifications 28.5.1 → 29.0.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/dist/__tests__/intercept.test.d.ts +2 -0
- package/dist/__tests__/intercept.test.d.ts.map +1 -0
- package/dist/__tests__/intercept.test.js +13 -0
- package/dist/__tests__/intercept.test.js.map +1 -0
- package/dist/__tests__/notifications-service.test.d.ts +2 -0
- package/dist/__tests__/notifications-service.test.d.ts.map +1 -0
- package/dist/__tests__/notifications-service.test.js +42 -0
- package/dist/__tests__/notifications-service.test.js.map +1 -0
- package/dist/api/notifications.api.d.ts +2 -2
- package/dist/api/notifications.api.d.ts.map +1 -1
- package/dist/common.d.ts +4 -22
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +4 -11
- package/dist/common.js.map +1 -1
- package/dist/components/__tests__/notifications.test.d.ts +2 -0
- package/dist/components/__tests__/notifications.test.d.ts.map +1 -0
- package/dist/components/__tests__/notifications.test.js +93 -0
- package/dist/components/__tests__/notifications.test.js.map +1 -0
- package/dist/components/notifications.d.ts +8 -1
- package/dist/components/notifications.d.ts.map +1 -1
- package/dist/components/notifications.js +43 -23
- package/dist/components/notifications.js.map +1 -1
- package/dist/demo/action-button-preview.d.ts.map +1 -1
- package/dist/demo/action-button-preview.js +2 -2
- package/dist/demo/action-button-preview.js.map +1 -1
- package/dist/demo/basic-preview.d.ts.map +1 -1
- package/dist/demo/basic-preview.js +1 -1
- package/dist/demo/basic-preview.js.map +1 -1
- package/dist/demo/container.d.ts +1 -3
- package/dist/demo/container.d.ts.map +1 -1
- package/dist/demo/container.js.map +1 -1
- package/dist/demo/duration-preview.d.ts.map +1 -1
- package/dist/demo/duration-preview.js +2 -2
- package/dist/demo/duration-preview.js.map +1 -1
- package/dist/demo/multiline-message-preview.d.ts.map +1 -1
- package/dist/demo/multiline-message-preview.js +2 -2
- package/dist/demo/multiline-message-preview.js.map +1 -1
- package/dist/demo/prevent-duplicates-preview.d.ts.map +1 -1
- package/dist/demo/prevent-duplicates-preview.js +2 -2
- package/dist/demo/prevent-duplicates-preview.js.map +1 -1
- package/dist/demo/progress-preview.d.ts.map +1 -1
- package/dist/demo/progress-preview.js +2 -2
- package/dist/demo/progress-preview.js.map +1 -1
- package/dist/demo/server-custom-preview.d.ts +1 -1
- package/dist/demo/server-custom-preview.d.ts.map +1 -1
- package/dist/demo/server-custom-preview.js +21 -7
- package/dist/demo/server-custom-preview.js.map +1 -1
- package/dist/demo/server-custom.d.ts +0 -1
- package/dist/demo/server-custom.d.ts.map +1 -1
- package/dist/demo/server-custom.js +25 -21
- package/dist/demo/server-custom.js.map +1 -1
- package/dist/demo/server-default.d.ts.map +1 -1
- package/dist/demo/server-default.js +1 -1
- package/dist/demo/server-default.js.map +1 -1
- package/dist/demo/status-variations-preview.d.ts.map +1 -1
- package/dist/demo/status-variations-preview.js +2 -2
- package/dist/demo/status-variations-preview.js.map +1 -1
- package/dist/demo/status-variations.d.ts.map +1 -1
- package/dist/demo/status-variations.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/intercept.d.ts +4 -0
- package/dist/intercept.d.ts.map +1 -0
- package/dist/intercept.js +5 -0
- package/dist/intercept.js.map +1 -0
- package/dist/notifications-channel.d.ts +2 -6
- package/dist/notifications-channel.d.ts.map +1 -1
- package/dist/notifications-channel.js.map +1 -1
- package/dist/notifications-service.d.ts +10 -8
- package/dist/notifications-service.d.ts.map +1 -1
- package/dist/notifications-service.js.map +1 -1
- package/dist/notifications.stories.d.ts +14 -0
- package/dist/notifications.stories.d.ts.map +1 -0
- package/dist/notifications.stories.js +20 -0
- package/dist/notifications.stories.js.map +1 -0
- package/dist/stores/__mocks__/mock-notifications-channel.d.ts +11 -0
- package/dist/stores/__mocks__/mock-notifications-channel.d.ts.map +1 -0
- package/dist/stores/__mocks__/mock-notifications-channel.js +36 -0
- package/dist/stores/__mocks__/mock-notifications-channel.js.map +1 -0
- package/dist/stores/__tests__/notifications.store.test.d.ts +2 -0
- package/dist/stores/__tests__/notifications.store.test.d.ts.map +1 -0
- package/dist/stores/__tests__/notifications.store.test.js +360 -0
- package/dist/stores/__tests__/notifications.store.test.js.map +1 -0
- package/dist/stores/notifications.store.d.ts +20 -8
- package/dist/stores/notifications.store.d.ts.map +1 -1
- package/dist/stores/notifications.store.js +156 -45
- package/dist/stores/notifications.store.js.map +1 -1
- package/dist/utils/__tests__/date-from-string.test.d.ts +2 -0
- package/dist/utils/__tests__/date-from-string.test.d.ts.map +1 -0
- package/dist/utils/__tests__/date-from-string.test.js +39 -0
- package/dist/utils/__tests__/date-from-string.test.js.map +1 -0
- package/dist/utils/__tests__/use-compatible-navigate.test.d.ts +2 -0
- package/dist/utils/__tests__/use-compatible-navigate.test.d.ts.map +1 -0
- package/dist/utils/__tests__/use-compatible-navigate.test.js +27 -0
- package/dist/utils/__tests__/use-compatible-navigate.test.js.map +1 -0
- package/dist/utils/date-from-string.d.ts.map +1 -0
- package/dist/utils/date-from-string.js +19 -0
- package/dist/utils/date-from-string.js.map +1 -0
- package/package.json +6 -6
- package/src/__tests__/intercept.test.ts +18 -0
- package/src/__tests__/notifications-service.test.ts +62 -0
- package/src/api/notifications.api.ts +2 -2
- package/src/common.ts +12 -27
- package/src/components/__tests__/notifications.test.tsx +107 -0
- package/src/components/notifications.tsx +59 -36
- package/src/demo/action-button-preview.tsx +4 -6
- package/src/demo/basic-preview.tsx +2 -4
- package/src/demo/container.tsx +1 -4
- package/src/demo/duration-preview.tsx +4 -6
- package/src/demo/multiline-message-preview.tsx +3 -9
- package/src/demo/prevent-duplicates-preview.tsx +3 -9
- package/src/demo/progress-preview.tsx +3 -9
- package/src/demo/server-custom-preview.tsx +17 -14
- package/src/demo/server-custom.tsx +30 -29
- package/src/demo/server-default.tsx +1 -3
- package/src/demo/status-variations-preview.tsx +4 -6
- package/src/demo/status-variations.tsx +0 -1
- package/src/index.ts +13 -4
- package/src/intercept.ts +14 -0
- package/src/notifications-channel.ts +2 -6
- package/src/notifications-service.ts +14 -42
- package/src/stores/__mocks__/mock-notifications-channel.ts +31 -0
- package/src/stores/__tests__/notifications.store.test.ts +458 -0
- package/src/stores/notifications.store.ts +178 -53
- package/src/utils/__tests__/date-from-string.test.ts +53 -0
- package/src/utils/__tests__/use-compatible-navigate.test.ts +43 -0
- package/src/utils/date-from-string.ts +22 -0
- package/dist/components/__tests__/container.test.d.ts +0 -2
- package/dist/components/__tests__/container.test.d.ts.map +0 -1
- package/dist/components/__tests__/container.test.js +0 -59
- package/dist/components/__tests__/container.test.js.map +0 -1
- package/dist/components/container.d.ts +0 -3
- package/dist/components/container.d.ts.map +0 -1
- package/dist/components/container.js +0 -26
- package/dist/components/container.js.map +0 -1
- package/dist/components/default-notification.d.ts +0 -7
- package/dist/components/default-notification.d.ts.map +0 -1
- package/dist/components/default-notification.js +0 -26
- package/dist/components/default-notification.js.map +0 -1
- package/dist/components/default-notification.module.css +0 -3
- package/dist/components/no-ssr.d.ts +0 -5
- package/dist/components/no-ssr.d.ts.map +0 -1
- package/dist/components/no-ssr.js +0 -9
- package/dist/components/no-ssr.js.map +0 -1
- package/dist/components/notifications-unwrapped.d.ts +0 -3
- package/dist/components/notifications-unwrapped.d.ts.map +0 -1
- package/dist/components/notifications-unwrapped.js +0 -27
- package/dist/components/notifications-unwrapped.js.map +0 -1
- package/dist/components/shadow-dom.d.ts +0 -3
- package/dist/components/shadow-dom.d.ts.map +0 -1
- package/dist/components/shadow-dom.js +0 -41
- package/dist/components/shadow-dom.js.map +0 -1
- package/dist/components/use-style-sheets.d.ts +0 -2
- package/dist/components/use-style-sheets.d.ts.map +0 -1
- package/dist/components/use-style-sheets.js +0 -15
- package/dist/components/use-style-sheets.js.map +0 -1
- package/dist/create-element.d.ts +0 -2
- package/dist/create-element.d.ts.map +0 -1
- package/dist/create-element.js +0 -8
- package/dist/create-element.js.map +0 -1
- package/dist/date-from-string.d.ts.map +0 -1
- package/dist/date-from-string.js +0 -27
- package/dist/date-from-string.js.map +0 -1
- package/dist/register.d.ts +0 -3
- package/dist/register.d.ts.map +0 -1
- package/dist/register.js +0 -5
- package/dist/register.js.map +0 -1
- package/src/components/__tests__/container.test.tsx +0 -71
- package/src/components/container.tsx +0 -35
- package/src/components/default-notification.module.css +0 -3
- package/src/components/default-notification.module.css.d.ts +0 -4
- package/src/components/default-notification.tsx +0 -59
- package/src/components/no-ssr.tsx +0 -11
- package/src/components/notifications-unwrapped.tsx +0 -51
- package/src/components/shadow-dom.tsx +0 -53
- package/src/components/use-style-sheets.ts +0 -19
- package/src/create-element.ts +0 -12
- package/src/date-from-string.ts +0 -30
- package/src/register.ts +0 -6
- /package/dist/{date-from-string.d.ts → utils/date-from-string.d.ts} +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"intercept.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/intercept.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { NotificationsStore } from '../stores/notifications.store';
|
2
|
+
import { intercept } from '../intercept';
|
3
|
+
describe(intercept.name, () => {
|
4
|
+
const fn = jest.fn();
|
5
|
+
const type = 'NotificationType';
|
6
|
+
const subject = () => intercept(type, fn);
|
7
|
+
test('registers interceptor', () => {
|
8
|
+
const interceptSpy = jest.spyOn(NotificationsStore, 'intercept');
|
9
|
+
subject();
|
10
|
+
expect(interceptSpy).toHaveBeenCalledWith(type, fn);
|
11
|
+
});
|
12
|
+
});
|
13
|
+
//# sourceMappingURL=intercept.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"intercept.test.js","sourceRoot":"","sources":["../../src/__tests__/intercept.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE;IAC1B,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IACrB,MAAM,IAAI,GAAG,kBAAkB,CAAC;IAEhC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAE1C,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;QAEjE,OAAO,EAAE,CAAC;QAEV,MAAM,CAAC,YAAY,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"notifications-service.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/notifications-service.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { Status } from '../common';
|
2
|
+
import { NotificationsService } from '../notifications-service';
|
3
|
+
describe(NotificationsService.name, () => {
|
4
|
+
const store = { add: jest.fn(), initialize: jest.fn() };
|
5
|
+
let options;
|
6
|
+
beforeEach(() => {
|
7
|
+
jest.clearAllMocks();
|
8
|
+
options = { title: 'Foo', message: 'Bar!' };
|
9
|
+
});
|
10
|
+
const subject = new NotificationsService(store);
|
11
|
+
describe('initialize', () => {
|
12
|
+
test('initializes store', () => {
|
13
|
+
const userId = 123;
|
14
|
+
subject.initialize(userId);
|
15
|
+
expect(store.initialize).toHaveBeenCalledWith(userId);
|
16
|
+
});
|
17
|
+
});
|
18
|
+
const testCases = [
|
19
|
+
{ method: 'info', status: Status.Info },
|
20
|
+
{ method: 'success', status: Status.Success },
|
21
|
+
{ method: 'warning', status: Status.Warning },
|
22
|
+
{ method: 'error', status: Status.Error },
|
23
|
+
];
|
24
|
+
describe.each(testCases)('$method', ({ method, status }) => {
|
25
|
+
test(`adds "${status}" notification`, () => {
|
26
|
+
subject[method](options);
|
27
|
+
expect(store.add).toHaveBeenCalledWith(Object.assign(Object.assign({}, options), { status }), undefined);
|
28
|
+
});
|
29
|
+
test(`passes through preventDuplicates`, () => {
|
30
|
+
const preventDuplicates = true;
|
31
|
+
subject[method](options, preventDuplicates);
|
32
|
+
expect(store.add).toHaveBeenCalledWith(expect.anything(), preventDuplicates);
|
33
|
+
});
|
34
|
+
});
|
35
|
+
describe('show', () => {
|
36
|
+
test('adds notification', () => {
|
37
|
+
subject.show(options);
|
38
|
+
expect(store.add).toHaveBeenCalledWith(options, undefined);
|
39
|
+
});
|
40
|
+
});
|
41
|
+
});
|
42
|
+
//# sourceMappingURL=notifications-service.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"notifications-service.test.js","sourceRoot":"","sources":["../../src/__tests__/notifications-service.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,MAAM,EAAE,MAAM,WAAW,CAAC;AAG/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,QAAQ,CAAC,oBAAoB,CAAC,IAAI,EAAE,GAAG,EAAE;IACrC,MAAM,KAAK,GAAgC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;IACrF,IAAI,OAAmC,CAAC;IAExC,UAAU,CAAC,GAAG,EAAE;QACZ,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAI,oBAAoB,CAAC,KAAY,CAAC,CAAC;IAEvD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QACxB,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;YAC3B,MAAM,MAAM,GAAG,GAAG,CAA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AI,CAAC,mBAAmB,EAAE,GAAG,EAAE;YAC3B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAEtB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
@@ -13,7 +13,7 @@ export interface Notification {
|
|
13
13
|
createdOn: Date;
|
14
14
|
modifiedOn: Date;
|
15
15
|
version: number;
|
16
|
-
payload?: string
|
16
|
+
payload?: string;
|
17
17
|
}
|
18
18
|
export declare enum NotificationProcessStatus {
|
19
19
|
Info = 0,
|
@@ -24,7 +24,7 @@ export declare enum NotificationProcessStatus {
|
|
24
24
|
export interface DefaultServerNotificationPayload {
|
25
25
|
title: string;
|
26
26
|
message?: string;
|
27
|
-
duration
|
27
|
+
duration?: number;
|
28
28
|
progress?: number;
|
29
29
|
action?: {
|
30
30
|
label: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"notifications.api.d.ts","sourceRoot":"","sources":["../../src/api/notifications.api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAElD,8BAAsB,gBAAgB;IAClC,QAAQ,CAAC,gBAAgB,CACrB,IAAI,EAAE,OAAO,EACb,WAAW,CAAC,EAAE,WAAW,GAC1B,YAAY,CAAC,YAAY,EAAE,CAAC;IAE/B,QAAQ,CAAC,oBAAoB,CACzB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,WAAW,GAC1B,YAAY,CAAC,IAAI,CAAC;IAErB,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC,YAAY,CAAC;CAC9F;AAED,MAAM,WAAW,YAAY;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,yBAAyB,CAAC;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"notifications.api.d.ts","sourceRoot":"","sources":["../../src/api/notifications.api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAElD,8BAAsB,gBAAgB;IAClC,QAAQ,CAAC,gBAAgB,CACrB,IAAI,EAAE,OAAO,EACb,WAAW,CAAC,EAAE,WAAW,GAC1B,YAAY,CAAC,YAAY,EAAE,CAAC;IAE/B,QAAQ,CAAC,oBAAoB,CACzB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,WAAW,GAC1B,YAAY,CAAC,IAAI,CAAC;IAErB,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC,YAAY,CAAC;CAC9F;AAED,MAAM,WAAW,YAAY;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,yBAAyB,CAAC;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,oBAAY,yBAAyB;IACjC,IAAI,IAAI;IACR,UAAU,IAAI;IACd,OAAO,IAAI;IACX,OAAO,IAAI;CACd;AAED,MAAM,WAAW,gCAAgC;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KAChB,CAAC;CACL"}
|
package/dist/common.d.ts
CHANGED
@@ -1,26 +1,7 @@
|
|
1
|
-
import { ComponentType } from 'react';
|
2
1
|
import { Notification as ServerNotification } from './api/notifications.api';
|
3
|
-
export interface Notification extends Omit<ServerNotification, 'payload'> {
|
4
|
-
payload:
|
2
|
+
export interface Notification<T extends Record<keyof any, any> = Record<keyof any, any>> extends Omit<ServerNotification, 'payload'> {
|
3
|
+
payload: T;
|
5
4
|
}
|
6
|
-
export type NotificationMapper = ComponentType<{
|
7
|
-
notification: Notification;
|
8
|
-
onClose(): void;
|
9
|
-
}>;
|
10
|
-
export declare function isNewer(prev: Notification | ServerNotification, next: Notification | ServerNotification): boolean;
|
11
|
-
export declare function toClientNotification(serverNotification: ServerNotification): {
|
12
|
-
payload: any;
|
13
|
-
id: number;
|
14
|
-
userId: number;
|
15
|
-
type: string;
|
16
|
-
status: import("./api/notifications.api").NotificationProcessStatus;
|
17
|
-
isRead: boolean;
|
18
|
-
createdOn: Date;
|
19
|
-
modifiedOn: Date;
|
20
|
-
version: number;
|
21
|
-
};
|
22
|
-
export declare const DEFAULT_CLIENT_NOTIFICATION_TYPE = "DefaultClientNotification";
|
23
|
-
export declare const DEFAULT_SERVER_NOTIFICATION_TYPE = "DefaultServerNotification";
|
24
5
|
export interface DefaultNotificationOptions {
|
25
6
|
status?: Status;
|
26
7
|
title: string;
|
@@ -42,7 +23,8 @@ export interface LinkAction {
|
|
42
23
|
}
|
43
24
|
export interface FunctionAction {
|
44
25
|
label: string;
|
45
|
-
onClick()
|
26
|
+
onClick: () => void;
|
46
27
|
}
|
47
28
|
export declare function isLinkAction(action: LinkAction | FunctionAction): action is LinkAction;
|
29
|
+
export declare function isNewer(prev: Pick<Notification, 'modifiedOn'>, next: Pick<Notification, 'modifiedOn'>): boolean;
|
48
30
|
//# sourceMappingURL=common.d.ts.map
|
package/dist/common.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7E,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,EAAE,GAAG,CAAC,CACnF,SAAQ,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC;IAC3C,OAAO,EAAE,CAAC,CAAC;CACd;AAED,MAAM,WAAW,0BAA0B;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,GAAG,cAAc,CAAC;CACxC;AAED,oBAAY,MAAM;IACd,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,KAAK,aAAa;CACrB;AAED,MAAM,WAAW,UAAU;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,cAAc,GAAG,MAAM,IAAI,UAAU,CAEtF;AAED,wBAAgB,OAAO,CACnB,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,EACtC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,WAGzC"}
|
package/dist/common.js
CHANGED
@@ -1,13 +1,3 @@
|
|
1
|
-
export function isNewer(prev, next) {
|
2
|
-
return ((!prev.modifiedOn && next.modifiedOn) ||
|
3
|
-
(prev.modifiedOn && next.modifiedOn && prev.modifiedOn < next.modifiedOn));
|
4
|
-
}
|
5
|
-
export function toClientNotification(serverNotification) {
|
6
|
-
var _a;
|
7
|
-
return Object.assign(Object.assign({}, serverNotification), { payload: JSON.parse((_a = serverNotification.payload) !== null && _a !== void 0 ? _a : '{}') });
|
8
|
-
}
|
9
|
-
export const DEFAULT_CLIENT_NOTIFICATION_TYPE = 'DefaultClientNotification';
|
10
|
-
export const DEFAULT_SERVER_NOTIFICATION_TYPE = 'DefaultServerNotification';
|
11
1
|
export var Status;
|
12
2
|
(function (Status) {
|
13
3
|
Status["Info"] = "info";
|
@@ -16,6 +6,9 @@ export var Status;
|
|
16
6
|
Status["Error"] = "critical";
|
17
7
|
})(Status || (Status = {}));
|
18
8
|
export function isLinkAction(action) {
|
19
|
-
return Object.
|
9
|
+
return Object.hasOwn(action, 'link');
|
10
|
+
}
|
11
|
+
export function isNewer(prev, next) {
|
12
|
+
return next.modifiedOn && (!prev.modifiedOn || prev.modifiedOn < next.modifiedOn);
|
20
13
|
}
|
21
14
|
//# sourceMappingURL=common.js.map
|
package/dist/common.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IACd,uBAAa,CAAA;IACb,6BAAmB,CAAA;IACnB,6BAAmB,CAAA;IACnB,4BAAkB,CAAA;AACtB,CAAC,EALW,MAAM,KAAN,MAAM,QAKjB;AAaD,MAAM,UAAU,YAAY,CAAC,MAAmC;IAC5D,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,OAAO,CACnB,IAAsC,EACtC,IAAsC;IAEtC,OAAO,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;AACtF,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"notifications.test.d.ts","sourceRoot":"","sources":["../../../src/components/__tests__/notifications.test.tsx"],"names":[],"mappings":""}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
8
|
+
import { injectable, useOptionalDependencies } from '@servicetitan/react-ioc';
|
9
|
+
import { mockComponent } from '@servicetitan/testing-library';
|
10
|
+
import { render, screen } from '@testing-library/react';
|
11
|
+
import { Fragment } from 'react';
|
12
|
+
import { NotificationsApi } from '../../api/notifications.api';
|
13
|
+
import { NotificationsStore } from '../../stores/notifications.store';
|
14
|
+
import { NotificationsService } from '../../notifications-service';
|
15
|
+
import { useCompatibleNavigate } from '../../utils/use-compatible-navigate';
|
16
|
+
import { Notifications } from '../notifications';
|
17
|
+
jest.mock('@servicetitan/anvil2', () => mockComponent('Toaster', { renderProps: false }));
|
18
|
+
jest.mock('../../utils/use-compatible-navigate', () => ({
|
19
|
+
useCompatibleNavigate: jest.fn(),
|
20
|
+
}));
|
21
|
+
let MockNotificationsApi = class MockNotificationsApi {
|
22
|
+
constructor() {
|
23
|
+
Object.defineProperty(this, "getNotification", {
|
24
|
+
enumerable: true,
|
25
|
+
configurable: true,
|
26
|
+
writable: true,
|
27
|
+
value: jest.fn()
|
28
|
+
});
|
29
|
+
Object.defineProperty(this, "getNotifications", {
|
30
|
+
enumerable: true,
|
31
|
+
configurable: true,
|
32
|
+
writable: true,
|
33
|
+
value: jest.fn()
|
34
|
+
});
|
35
|
+
Object.defineProperty(this, "changeIsReadProperty", {
|
36
|
+
enumerable: true,
|
37
|
+
configurable: true,
|
38
|
+
writable: true,
|
39
|
+
value: jest.fn()
|
40
|
+
});
|
41
|
+
}
|
42
|
+
};
|
43
|
+
MockNotificationsApi = __decorate([
|
44
|
+
injectable()
|
45
|
+
], MockNotificationsApi);
|
46
|
+
describe(Notifications.name, () => {
|
47
|
+
let providedApi;
|
48
|
+
let providedService;
|
49
|
+
let providedStore;
|
50
|
+
let props;
|
51
|
+
const Component = () => {
|
52
|
+
[providedApi, providedService, providedStore] = useOptionalDependencies(NotificationsApi, NotificationsService, NotificationsStore);
|
53
|
+
return null;
|
54
|
+
};
|
55
|
+
beforeEach(() => (props = {}));
|
56
|
+
const subject = () => render(_jsx(Notifications, Object.assign({}, props, { children: _jsx(Component, {}) })));
|
57
|
+
test('renders Toaster', () => {
|
58
|
+
subject();
|
59
|
+
expect(screen).toContainComponent('Toaster');
|
60
|
+
});
|
61
|
+
test('provides NotificationService', () => {
|
62
|
+
subject();
|
63
|
+
expect(providedService).toBeInstanceOf(NotificationsService);
|
64
|
+
});
|
65
|
+
test('provides NotificationStore', () => {
|
66
|
+
subject();
|
67
|
+
expect(providedStore).toBeInstanceOf(NotificationsStore);
|
68
|
+
});
|
69
|
+
test('sets store.navigate to useCompatibleNavigate result', () => {
|
70
|
+
const navigate = jest.fn();
|
71
|
+
jest.mocked(useCompatibleNavigate).mockReturnValue(navigate);
|
72
|
+
subject();
|
73
|
+
expect(providedStore.navigate).toBe(navigate);
|
74
|
+
});
|
75
|
+
test('disposes store when component is unmounted', () => {
|
76
|
+
const { unmount } = subject();
|
77
|
+
const disposeSpy = jest.spyOn(providedStore, 'dispose');
|
78
|
+
unmount();
|
79
|
+
expect(disposeSpy).toHaveBeenCalled();
|
80
|
+
});
|
81
|
+
test('renders one Toaster when there are are multiple notifications', () => {
|
82
|
+
render(_jsxs(Fragment, { children: [_jsx(Notifications, { children: _jsx(Notifications, {}) }), _jsx(Notifications, {})] }));
|
83
|
+
expect(screen.getAllByText('<Toaster />')).toHaveLength(1);
|
84
|
+
});
|
85
|
+
describe('when given an apiService', () => {
|
86
|
+
beforeEach(() => (props.apiService = MockNotificationsApi));
|
87
|
+
test('provides NotificationsApi', () => {
|
88
|
+
subject();
|
89
|
+
expect(providedApi).toBeInstanceOf(MockNotificationsApi);
|
90
|
+
});
|
91
|
+
});
|
92
|
+
});
|
93
|
+
//# sourceMappingURL=notifications.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"notifications.test.js","sourceRoot":"","sources":["../../../src/components/__tests__/notifications.test.tsx"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAM,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,kBAAk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V,KAAC,aAAa,KAAG,GACL,EAChB,KAAC,aAAa,KAAG,IACV,CACd,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACtC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,GAAG,oBAAoB,CAAC,CAAC,CAAC;QAE5D,IAAI,CAAC,2BAA2B,EAAE,GAAG,EAAE;YACnC,OAAO,EAAE,CAAC;YAEV,MAAM,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
@@ -1,8 +1,15 @@
|
|
1
|
-
import { FC, PropsWithChildren } from 'react';
|
2
1
|
import { interfaces } from '@servicetitan/react-ioc';
|
2
|
+
import { FC, PropsWithChildren } from 'react';
|
3
3
|
import { NotificationsApi } from '../api/notifications.api';
|
4
4
|
export interface NotificationsProps extends PropsWithChildren<{}> {
|
5
5
|
apiService?: interfaces.Newable<NotificationsApi>;
|
6
6
|
}
|
7
7
|
export declare const Notifications: FC<NotificationsProps>;
|
8
|
+
declare global {
|
9
|
+
/**
|
10
|
+
* This variable ensures there is one and only one \<Toaster />.
|
11
|
+
* It contains the unique id of the instance that owns the Toaster.
|
12
|
+
*/
|
13
|
+
var STNotificationsActiveId: string | undefined;
|
14
|
+
}
|
8
15
|
//# sourceMappingURL=notifications.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../src/components/notifications.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../src/components/notifications.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACH,EAAE,EACF,iBAAiB,EAMpB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAK5D,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB,CAAC,EAAE,CAAC;IAC7D,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACrD;AAED,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAWhD,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACX;;;OAGG;IAEH,IAAI,uBAAuB,EAAE,MAAM,GAAG,SAAS,CAAC;CACnD"}
|
@@ -1,32 +1,52 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import {
|
3
|
-
import {
|
2
|
+
import { Toaster } from '@servicetitan/anvil2';
|
3
|
+
import { Provider, useDependencies } from '@servicetitan/react-ioc';
|
4
|
+
import { useCallback, useEffect, useRef, useState, useSyncExternalStore, } from 'react';
|
5
|
+
import { NotificationsApi } from '../api/notifications.api';
|
4
6
|
import { NotificationsStore } from '../stores/notifications.store';
|
7
|
+
import { useCompatibleNavigate } from '../utils/use-compatible-navigate';
|
5
8
|
import { NotificationsService } from '../notifications-service';
|
6
|
-
import { register } from '../register';
|
7
|
-
import { DEFAULT_CLIENT_NOTIFICATION_TYPE, DEFAULT_SERVER_NOTIFICATION_TYPE, Status, } from '../common';
|
8
|
-
import { DefaultNotification } from './default-notification';
|
9
|
-
import { NotificationsUnwrapped } from './notifications-unwrapped';
|
10
9
|
export const Notifications = ({ apiService, children }) => (_jsxs(Provider, { singletons: [
|
11
10
|
...(apiService ? [{ provide: NotificationsApi, useClass: apiService }] : []),
|
12
11
|
NotificationsStore,
|
13
12
|
NotificationsService,
|
14
13
|
], children: [_jsx(NotificationsUnwrapped, {}), children] }));
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
});
|
14
|
+
const NotificationsUnwrapped = () => {
|
15
|
+
// Configure and clean up store
|
16
|
+
const [store] = useDependencies(NotificationsStore);
|
17
|
+
const navigate = useCompatibleNavigate();
|
18
|
+
useEffect(() => {
|
19
|
+
store.navigate = navigate;
|
20
|
+
return () => {
|
21
|
+
store.dispose();
|
22
|
+
};
|
23
|
+
}, [store, navigate]);
|
24
|
+
// Use useSyncExternalStore to ensure we re-render when the active id changes
|
25
|
+
const [thisId] = useState(() => makeId());
|
26
|
+
const syncExternalStoreCallback = useRef();
|
27
|
+
const subscribe = useCallback((callback) => {
|
28
|
+
syncExternalStoreCallback.current = callback;
|
29
|
+
return () => (syncExternalStoreCallback.current = undefined);
|
30
|
+
}, []);
|
31
|
+
const activeId = useSyncExternalStore(subscribe, () => globalThis.STNotificationsActiveId);
|
32
|
+
// Set and clean up active id
|
33
|
+
useEffect(() => {
|
34
|
+
var _a;
|
35
|
+
if (globalThis.STNotificationsActiveId === undefined) {
|
36
|
+
globalThis.STNotificationsActiveId = thisId;
|
37
|
+
(_a = syncExternalStoreCallback.current) === null || _a === void 0 ? void 0 : _a.call(syncExternalStoreCallback);
|
38
|
+
}
|
39
|
+
return () => {
|
40
|
+
var _a;
|
41
|
+
if (globalThis.STNotificationsActiveId === thisId) {
|
42
|
+
globalThis.STNotificationsActiveId = undefined;
|
43
|
+
(_a = syncExternalStoreCallback.current) === null || _a === void 0 ? void 0 : _a.call(syncExternalStoreCallback);
|
44
|
+
}
|
45
|
+
};
|
46
|
+
}, [syncExternalStoreCallback, thisId]);
|
47
|
+
return activeId === thisId ? _jsx(Toaster, { id: 'st-notifications-' + thisId }) : null;
|
48
|
+
};
|
49
|
+
function makeId() {
|
50
|
+
return Math.round(1e8 * Math.random()).toString(36);
|
51
|
+
}
|
32
52
|
//# sourceMappingURL=notifications.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/components/notifications.tsx"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/components/notifications.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAc,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAGH,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,EACR,oBAAoB,GACvB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAMhE,MAAM,CAAC,MAAM,aAAa,GAA2B,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC/E,MAAC,QAAQ,IACL,UAAU,EAAE;QACR,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,kBAAkB;QAClB,oBAAoB;KACvB,aAED,KAAC,sBAAsB,KAAG,EACzB,QAAQ,IACF,CACd,CAAC;AAWF,MAAM,sBAAsB,GAAO,GAAG,EAAE;IACpC,+BAA+B;IAE/B,MAAM,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,qBAAqB,EAAE,CAAC;IACzC,SAAS,CAAC,GAAG,EAAE;QACX,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC1B,O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AAC;AAEF,SAAS,MAAM;IACX,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"action-button-preview.d.ts","sourceRoot":"","sources":["../../src/demo/action-button-preview.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"action-button-preview.d.ts","sourceRoot":"","sources":["../../src/demo/action-button-preview.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,eAAO,MAAM,mBAAmB,EAAE,EAsCjC,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { Button, Flex } from '@servicetitan/anvil2';
|
2
3
|
import { useDependencies } from '@servicetitan/react-ioc';
|
3
|
-
import { ButtonGroup, Button } from '@servicetitan/design-system';
|
4
4
|
import { NotificationsService } from '..';
|
5
5
|
export const ActionButtonPreview = () => {
|
6
6
|
const [notifications] = useDependencies(NotificationsService);
|
@@ -26,6 +26,6 @@ export const ActionButtonPreview = () => {
|
|
26
26
|
onClick: () => alert("You've clicked the action button"),
|
27
27
|
},
|
28
28
|
});
|
29
|
-
return (_jsxs(
|
29
|
+
return (_jsxs(Flex, { direction: "row", gap: "2", children: [_jsx(Button, { onClick: handleWithLinkClick, children: "With Link" }), _jsx(Button, { onClick: handleWithExternalLinkClick, children: "With Link (new tab)" }), _jsx(Button, { onClick: handleWithHandlerClick, children: "With Handler" })] }));
|
30
30
|
};
|
31
31
|
//# sourceMappingURL=action-button-preview.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"action-button-preview.js","sourceRoot":"","sources":["../../src/demo/action-button-preview.tsx"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"action-button-preview.js","sourceRoot":"","sources":["../../src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+1 @@
|
|
1
|
-
{"version":3,"file":"basic-preview.d.ts","sourceRoot":"","sources":["../../src/demo/basic-preview.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"basic-preview.d.ts","sourceRoot":"","sources":["../../src/demo/basic-preview.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,eAAO,MAAM,YAAY,EAAE,EAU1B,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Button } from '@servicetitan/anvil2';
|
2
3
|
import { useDependencies } from '@servicetitan/react-ioc';
|
3
|
-
import { Button } from '@servicetitan/design-system';
|
4
4
|
import { NotificationsService } from '..';
|
5
5
|
export const BasicPreview = () => {
|
6
6
|
const [notifications] = useDependencies(NotificationsService);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"basic-preview.js","sourceRoot":"","sources":["../../src/demo/basic-preview.tsx"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"basic-preview.js","sourceRoot":"","sources":["../../src/demo/basic-preview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAE1C,MAAM,CAAC,MAAM,YAAY,GAAO,GAAG,EAAE;IACjC,MAAM,CAAC,aAAa,CAAC,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAE9D,MAAM,WAAW,GAAG,GAAG,EAAE,CACrB,aAAa,CAAC,IAAI,CAAC;QACf,KAAK,EAAE,kBAAkB;QACzB,OAAO,EAAE,yCAAyC;KACrD,CAAC,CAAC;IAEP,OAAO,KAAC,MAAM,IAAC,OAAO,EAAE,WAAW,qBAAe,CAAC;AACvD,CAAC,CAAC"}
|
package/dist/demo/container.d.ts
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
import { FC } from 'react';
|
2
2
|
import { Notification } from '../api/notifications.api';
|
3
|
-
|
4
|
-
(notification: Notification): void;
|
5
|
-
}
|
3
|
+
type EventCallback = (notification: Notification) => void;
|
6
4
|
declare class Publisher {
|
7
5
|
global_emitter: {
|
8
6
|
bind: () => void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/demo/container.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,EAAE,EAAE,MAAM,OAAO,CAAC;AAI/C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/demo/container.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,EAAE,EAAE,MAAM,OAAO,CAAC;AAI/C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD,KAAK,aAAa,GAAG,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;AAE1D,cAAM,SAAS;IAEX,cAAc;;;MAGZ;IAEF,OAAO,CAAC,YAAY,CAAC,CAAgB;IAErC,IAAI,OAAQ,MAAM,YAAY,aAAa,UAEzC;IAEF,MAAM,aAAY;IAElB,IAAI,iBAAkB,YAAY,UAIhC;CACL;AAYD,UAAU,cAAc;IACpB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC;CAC/C;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAkBxC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/demo/container.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAM,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;
|
1
|
+
{"version":3,"file":"container.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AAQ,IACL,UAAU,EAAE;YACR;gBACI,OAAO,EAAE,2BAA2B;gBACpC,QAAQ,EAAE,GAAG,EAAE,CAAC,iBAAiB;aACpC;SACJ,YAED,MAAC,aAAa,eACV,KAAC,wBAAwB,KAAG,EAC3B,QAAQ,CAAC,iBAAiB,CAAC,IAChB,GACT,CACd,CAAC;AACN,CAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"duration-preview.d.ts","sourceRoot":"","sources":["../../src/demo/duration-preview.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"duration-preview.d.ts","sourceRoot":"","sources":["../../src/demo/duration-preview.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,eAAO,MAAM,eAAe,EAAE,EAqB7B,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { Button, Flex } from '@servicetitan/anvil2';
|
2
3
|
import { useDependencies } from '@servicetitan/react-ioc';
|
3
|
-
import { ButtonGroup, Button } from '@servicetitan/design-system';
|
4
4
|
import { NotificationsService } from '..';
|
5
5
|
export const DurationPreview = () => {
|
6
6
|
const [notifications] = useDependencies(NotificationsService);
|
@@ -12,6 +12,6 @@ export const DurationPreview = () => {
|
|
12
12
|
title: "This message won't be closed automatically.",
|
13
13
|
duration: 0,
|
14
14
|
});
|
15
|
-
return (_jsxs(
|
15
|
+
return (_jsxs(Flex, { direction: "row", gap: "2", children: [_jsx(Button, { onClick: handleOneSecondClick, children: "1 second" }), _jsx(Button, { onClick: handleUnlimitedClick, children: "Unlimited" })] }));
|
16
16
|
};
|
17
17
|
//# sourceMappingURL=duration-preview.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"duration-preview.js","sourceRoot":"","sources":["../../src/demo/duration-preview.tsx"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"duration-preview.js","sourceRoot":"","sources":["../../src/demo/duration-preview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAE1C,MAAM,CAAC,MAAM,eAAe,GAAO,GAAG,EAAE;IACpC,MAAM,CAAC,aAAa,CAAC,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAE9D,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAC9B,aAAa,CAAC,IAAI,CAAC;QACf,KAAK,EAAE,0CAA0C;QACjD,QAAQ,EAAE,IAAI;KACjB,CAAC,CAAC;IAEP,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAC9B,aAAa,CAAC,IAAI,CAAC;QACf,KAAK,EAAE,6CAA6C;QACpD,QAAQ,EAAE,CAAC;KACd,CAAC,CAAC;IAEP,OAAO,CACH,MAAC,IAAI,IAAC,SAAS,EAAC,KAAK,EAAC,GAAG,EAAC,GAAG,aACzB,KAAC,MAAM,IAAC,OAAO,EAAE,oBAAoB,yBAAmB,EACxD,KAAC,MAAM,IAAC,OAAO,EAAE,oBAAoB,0BAAoB,IACtD,CACV,CAAC;AACN,CAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"multiline-message-preview.d.ts","sourceRoot":"","sources":["../../src/demo/multiline-message-preview.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"multiline-message-preview.d.ts","sourceRoot":"","sources":["../../src/demo/multiline-message-preview.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,eAAO,MAAM,uBAAuB,EAAE,EAUrC,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Button } from '@servicetitan/anvil2';
|
2
3
|
import { useDependencies } from '@servicetitan/react-ioc';
|
3
|
-
import { ButtonGroup, Button } from '@servicetitan/design-system';
|
4
4
|
import { NotificationsService } from '..';
|
5
5
|
export const MultilineMessagePreview = () => {
|
6
6
|
const [notifications] = useDependencies(NotificationsService);
|
@@ -8,6 +8,6 @@ export const MultilineMessagePreview = () => {
|
|
8
8
|
title: 'Notification with multiline message',
|
9
9
|
message: '1. First\r\n2. Second\r\n3. Third',
|
10
10
|
});
|
11
|
-
return
|
11
|
+
return _jsx(Button, { onClick: handleClick, children: "Show" });
|
12
12
|
};
|
13
13
|
//# sourceMappingURL=multiline-message-preview.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"multiline-message-preview.js","sourceRoot":"","sources":["../../src/demo/multiline-message-preview.tsx"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"multiline-message-preview.js","sourceRoot":"","sources":["../../src/demo/multiline-message-preview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAE1C,MAAM,CAAC,MAAM,uBAAuB,GAAO,GAAG,EAAE;IAC5C,MAAM,CAAC,aAAa,CAAC,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAE9D,MAAM,WAAW,GAAG,GAAG,EAAE,CACrB,aAAa,CAAC,IAAI,CAAC;QACf,KAAK,EAAE,qCAAqC;QAC5C,OAAO,EAAE,mCAAmC;KAC/C,CAAC,CAAC;IAEP,OAAO,KAAC,MAAM,IAAC,OAAO,EAAE,WAAW,qBAAe,CAAC;AACvD,CAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"prevent-duplicates-preview.d.ts","sourceRoot":"","sources":["../../src/demo/prevent-duplicates-preview.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"prevent-duplicates-preview.d.ts","sourceRoot":"","sources":["../../src/demo/prevent-duplicates-preview.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,eAAO,MAAM,wBAAwB,EAAE,EAYtC,CAAC"}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Button } from '@servicetitan/anvil2';
|
2
3
|
import { useDependencies } from '@servicetitan/react-ioc';
|
3
|
-
import { ButtonGroup, Button } from '@servicetitan/design-system';
|
4
4
|
import { NotificationsService } from '..';
|
5
5
|
export const PreventDuplicatesPreview = () => {
|
6
6
|
const [notifications] = useDependencies(NotificationsService);
|
7
7
|
const handleClick = () => notifications.show({
|
8
8
|
title: 'Equal notifications will be skipped.',
|
9
9
|
}, true);
|
10
|
-
return
|
10
|
+
return _jsx(Button, { onClick: handleClick, children: "Show" });
|
11
11
|
};
|
12
12
|
//# sourceMappingURL=prevent-duplicates-preview.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"prevent-duplicates-preview.js","sourceRoot":"","sources":["../../src/demo/prevent-duplicates-preview.tsx"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"prevent-duplicates-preview.js","sourceRoot":"","sources":["../../src/demo/prevent-duplicates-preview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAE1C,MAAM,CAAC,MAAM,wBAAwB,GAAO,GAAG,EAAE;IAC7C,MAAM,CAAC,aAAa,CAAC,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAE9D,MAAM,WAAW,GAAG,GAAG,EAAE,CACrB,aAAa,CAAC,IAAI,CACd;QACI,KAAK,EAAE,sCAAsC;KAChD,EACD,IAAI,CACP,CAAC;IAEN,OAAO,KAAC,MAAM,IAAC,OAAO,EAAE,WAAW,qBAAe,CAAC;AACvD,CAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"progress-preview.d.ts","sourceRoot":"","sources":["../../src/demo/progress-preview.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"progress-preview.d.ts","sourceRoot":"","sources":["../../src/demo/progress-preview.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,eAAO,MAAM,eAAe,EAAE,EAU7B,CAAC"}
|