@servicetitan/notifications 31.1.0 → 31.3.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.
Files changed (75) hide show
  1. package/dist/api/notifications.api.js +4 -3
  2. package/dist/api/notifications.api.js.map +1 -1
  3. package/dist/common.js +4 -3
  4. package/dist/common.js.map +1 -1
  5. package/dist/components/notifications.js +42 -22
  6. package/dist/components/notifications.js.map +1 -1
  7. package/dist/demo/action-button-preview.js +41 -23
  8. package/dist/demo/action-button-preview.js.map +1 -1
  9. package/dist/demo/action-button.js +4 -1
  10. package/dist/demo/action-button.js.map +1 -1
  11. package/dist/demo/basic-preview.js +9 -5
  12. package/dist/demo/basic-preview.js.map +1 -1
  13. package/dist/demo/basic.js +4 -1
  14. package/dist/demo/basic.js.map +1 -1
  15. package/dist/demo/container.js +44 -45
  16. package/dist/demo/container.js.map +1 -1
  17. package/dist/demo/duration-preview.js +23 -9
  18. package/dist/demo/duration-preview.js.map +1 -1
  19. package/dist/demo/duration.js +4 -1
  20. package/dist/demo/duration.js.map +1 -1
  21. package/dist/demo/index.js +1 -0
  22. package/dist/demo/index.js.map +1 -1
  23. package/dist/demo/multiline-message-preview.js +9 -5
  24. package/dist/demo/multiline-message-preview.js.map +1 -1
  25. package/dist/demo/multiline-message.js +4 -1
  26. package/dist/demo/multiline-message.js.map +1 -1
  27. package/dist/demo/prevent-duplicates-preview.js +9 -5
  28. package/dist/demo/prevent-duplicates-preview.js.map +1 -1
  29. package/dist/demo/prevent-duplicates.js +4 -1
  30. package/dist/demo/prevent-duplicates.js.map +1 -1
  31. package/dist/demo/progress-preview.js +9 -5
  32. package/dist/demo/progress-preview.js.map +1 -1
  33. package/dist/demo/progress.js +4 -1
  34. package/dist/demo/progress.js.map +1 -1
  35. package/dist/demo/server-custom-preview.js +5 -4
  36. package/dist/demo/server-custom-preview.js.map +1 -1
  37. package/dist/demo/server-custom.js +13 -7
  38. package/dist/demo/server-custom.js.map +1 -1
  39. package/dist/demo/server-default.js +66 -61
  40. package/dist/demo/server-default.js.map +1 -1
  41. package/dist/demo/status-variations-preview.js +35 -13
  42. package/dist/demo/status-variations-preview.js.map +1 -1
  43. package/dist/demo/status-variations.js +4 -1
  44. package/dist/demo/status-variations.js.map +1 -1
  45. package/dist/index.js +7 -6
  46. package/dist/index.js.map +1 -1
  47. package/dist/intercept.js +1 -0
  48. package/dist/intercept.js.map +1 -1
  49. package/dist/notifications-channel.js +1 -0
  50. package/dist/notifications-channel.js.map +1 -1
  51. package/dist/notifications-service.js +71 -69
  52. package/dist/notifications-service.js.map +1 -1
  53. package/dist/stores/notifications.store.js +210 -218
  54. package/dist/stores/notifications.store.js.map +1 -1
  55. package/dist/utils/date-from-string.js +2 -1
  56. package/dist/utils/date-from-string.js.map +1 -1
  57. package/dist/utils/use-compatible-navigate.js +4 -3
  58. package/dist/utils/use-compatible-navigate.js.map +1 -1
  59. package/package.json +8 -8
  60. package/dist/__tests__/intercept.test.js +0 -13
  61. package/dist/__tests__/intercept.test.js.map +0 -1
  62. package/dist/__tests__/notifications-service.test.js +0 -42
  63. package/dist/__tests__/notifications-service.test.js.map +0 -1
  64. package/dist/components/__tests__/notifications.test.js +0 -93
  65. package/dist/components/__tests__/notifications.test.js.map +0 -1
  66. package/dist/notifications.stories.js +0 -20
  67. package/dist/notifications.stories.js.map +0 -1
  68. package/dist/stores/__mocks__/mock-notifications-channel.js +0 -36
  69. package/dist/stores/__mocks__/mock-notifications-channel.js.map +0 -1
  70. package/dist/stores/__tests__/notifications.store.test.js +0 -367
  71. package/dist/stores/__tests__/notifications.store.test.js.map +0 -1
  72. package/dist/utils/__tests__/date-from-string.test.js +0 -45
  73. package/dist/utils/__tests__/date-from-string.test.js.map +0 -1
  74. package/dist/utils/__tests__/use-compatible-navigate.test.js +0 -27
  75. package/dist/utils/__tests__/use-compatible-navigate.test.js.map +0 -1
@@ -1,80 +1,82 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _ts_decorate(decorators, target, key, desc) {
2
15
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
16
  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;
17
+ 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
18
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
19
+ }
20
+ function _ts_metadata(k, v) {
8
21
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
12
- };
22
+ }
23
+ function _ts_param(paramIndex, decorator) {
24
+ return function(target, key) {
25
+ decorator(target, key, paramIndex);
26
+ };
27
+ }
13
28
  import { injectable, inject } from '@servicetitan/react-ioc';
14
29
  import { Status } from './common';
15
30
  import { NotificationsStore } from './stores/notifications.store';
16
- let NotificationsService = class NotificationsService {
17
- constructor(store) {
18
- Object.defineProperty(this, "store", {
19
- enumerable: true,
20
- configurable: true,
21
- writable: true,
22
- value: store
23
- });
24
- Object.defineProperty(this, "initialize", {
25
- enumerable: true,
26
- configurable: true,
27
- writable: true,
28
- value: async (userId = 0) => {
29
- await this.store.initialize(userId);
30
- }
31
- });
32
- Object.defineProperty(this, "show", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: (options, preventDuplicates) => {
37
- this.store.add(options, preventDuplicates);
38
- }
39
- });
40
- Object.defineProperty(this, "info", {
41
- enumerable: true,
42
- configurable: true,
43
- writable: true,
44
- value: (options, preventDuplicates) => {
45
- this.store.add({ ...options, status: Status.Info }, preventDuplicates);
46
- }
47
- });
48
- Object.defineProperty(this, "success", {
49
- enumerable: true,
50
- configurable: true,
51
- writable: true,
52
- value: (options, preventDuplicates) => {
53
- this.store.add({ ...options, status: Status.Success }, preventDuplicates);
54
- }
55
- });
56
- Object.defineProperty(this, "warning", {
57
- enumerable: true,
58
- configurable: true,
59
- writable: true,
60
- value: (options, preventDuplicates) => {
61
- this.store.add({ ...options, status: Status.Warning }, preventDuplicates);
62
- }
63
- });
64
- Object.defineProperty(this, "error", {
65
- enumerable: true,
66
- configurable: true,
67
- writable: true,
68
- value: (options, preventDuplicates) => {
69
- this.store.add({ ...options, status: Status.Error }, preventDuplicates);
70
- }
71
- });
31
+ export class NotificationsService {
32
+ constructor(store){
33
+ _define_property(this, "store", void 0);
34
+ _define_property(this, "initialize", void 0);
35
+ _define_property(this, "show", void 0);
36
+ _define_property(this, "info", void 0);
37
+ _define_property(this, "success", void 0);
38
+ _define_property(this, "warning", void 0);
39
+ _define_property(this, "error", void 0);
40
+ this.store = store;
41
+ this.initialize = async (userId = 0)=>{
42
+ await this.store.initialize(userId);
43
+ };
44
+ this.show = (options, preventDuplicates)=>{
45
+ this.store.add(options, preventDuplicates);
46
+ };
47
+ this.info = (options, preventDuplicates)=>{
48
+ this.store.add({
49
+ ...options,
50
+ status: Status.Info
51
+ }, preventDuplicates);
52
+ };
53
+ this.success = (options, preventDuplicates)=>{
54
+ this.store.add({
55
+ ...options,
56
+ status: Status.Success
57
+ }, preventDuplicates);
58
+ };
59
+ this.warning = (options, preventDuplicates)=>{
60
+ this.store.add({
61
+ ...options,
62
+ status: Status.Warning
63
+ }, preventDuplicates);
64
+ };
65
+ this.error = (options, preventDuplicates)=>{
66
+ this.store.add({
67
+ ...options,
68
+ status: Status.Error
69
+ }, preventDuplicates);
70
+ };
72
71
  }
73
- };
74
- NotificationsService = __decorate([
72
+ }
73
+ NotificationsService = _ts_decorate([
75
74
  injectable(),
76
- __param(0, inject(NotificationsStore)),
77
- __metadata("design:paramtypes", [NotificationsStore])
75
+ _ts_param(0, inject(NotificationsStore)),
76
+ _ts_metadata("design:type", Function),
77
+ _ts_metadata("design:paramtypes", [
78
+ typeof NotificationsStore === "undefined" ? Object : NotificationsStore
79
+ ])
78
80
  ], NotificationsService);
79
- export { NotificationsService };
81
+
80
82
  //# sourceMappingURL=notifications-service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications-service.js","sourceRoot":"","sources":["../src/notifications-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAA8B,MAAM,EAAE,MAAM,UAAU,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAc3D,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC7B,YAAwC,KAA0C;QAAtE;;;;mBAA6C,KAAK;WAAoB;QAElF;;;;mBAAa,KAAK,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE;gBAC9B,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YACxC,CAAC;WAAC;QAEF;;;;mBAAO,CAAC,OAAmC,EAAE,iBAA2B,EAAE,EAAE;gBACxE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;YAC/C,CAAC;WAAC;QAEF;;;;mBAAO,CAAC,OAA6B,EAAE,iBAA2B,EAAE,EAAE;gBAClE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,iBAAiB,CAAC,CAAC;YAC3E,CAAC;WAAC;QAEF;;;;mBAAU,CAAC,OAA6B,EAAE,iBAA2B,EAAE,EAAE;gBACrE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,iBAAiB,CAAC,CAAC;YAC9E,CAAC;WAAC;QAEF;;;;mBAAU,CAAC,OAA6B,EAAE,iBAA2B,EAAE,EAAE;gBACrE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,iBAAiB,CAAC,CAAC;YAC9E,CAAC;WAAC;QAEF;;;;mBAAQ,CAAC,OAA6B,EAAE,iBAA2B,EAAE,EAAE;gBACnE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,EAAE,iBAAiB,CAAC,CAAC;YAC5E,CAAC;WAAC;IAxBmF,CAAC;CAyBzF,CAAA;AA1BY,oBAAoB;IADhC,UAAU,EAAE;IAEI,WAAA,MAAM,CAAC,kBAAkB,CAAC,CAAA;qCAAyB,kBAAkB;GADzE,oBAAoB,CA0BhC"}
1
+ {"version":3,"sources":["../src/notifications-service.ts"],"sourcesContent":["import { injectable, inject } from '@servicetitan/react-ioc';\n\nimport { DefaultNotificationOptions, Status } from './common';\n\nimport { NotificationsStore } from './stores/notifications.store';\n\ntype OptionsWithoutStatus = Omit<DefaultNotificationOptions, 'status'>;\n\nexport interface INotificationsService {\n initialize(userId?: number): Promise<void>;\n show(options: DefaultNotificationOptions, preventDuplicates?: boolean): void;\n info(options: OptionsWithoutStatus, preventDuplicates?: boolean): void;\n success(options: OptionsWithoutStatus, preventDuplicates?: boolean): void;\n warning(options: OptionsWithoutStatus, preventDuplicates?: boolean): void;\n error(options: OptionsWithoutStatus, preventDuplicates?: boolean): void;\n}\n\n@injectable()\nexport class NotificationsService implements INotificationsService {\n constructor(@inject(NotificationsStore) private readonly store: NotificationsStore) {}\n\n initialize = async (userId = 0) => {\n await this.store.initialize(userId);\n };\n\n show = (options: DefaultNotificationOptions, preventDuplicates?: boolean) => {\n this.store.add(options, preventDuplicates);\n };\n\n info = (options: OptionsWithoutStatus, preventDuplicates?: boolean) => {\n this.store.add({ ...options, status: Status.Info }, preventDuplicates);\n };\n\n success = (options: OptionsWithoutStatus, preventDuplicates?: boolean) => {\n this.store.add({ ...options, status: Status.Success }, preventDuplicates);\n };\n\n warning = (options: OptionsWithoutStatus, preventDuplicates?: boolean) => {\n this.store.add({ ...options, status: Status.Warning }, preventDuplicates);\n };\n\n error = (options: OptionsWithoutStatus, preventDuplicates?: boolean) => {\n this.store.add({ ...options, status: Status.Error }, preventDuplicates);\n };\n}\n"],"names":["injectable","inject","Status","NotificationsStore","NotificationsService","constructor","store","initialize","show","info","success","warning","error","userId","options","preventDuplicates","add","status","Info","Success","Warning","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,UAAU,EAAEC,MAAM,QAAQ,0BAA0B;AAE7D,SAAqCC,MAAM,QAAQ,WAAW;AAE9D,SAASC,kBAAkB,QAAQ,+BAA+B;AAclE,OAAO,MAAMC;IACTC,YAAY,AAA6CC,KAAyB,CAAE;;QAEpFC,uBAAAA,cAAAA,KAAAA;QAIAC,uBAAAA,QAAAA,KAAAA;QAIAC,uBAAAA,QAAAA,KAAAA;QAIAC,uBAAAA,WAAAA,KAAAA;QAIAC,uBAAAA,WAAAA,KAAAA;QAIAC,uBAAAA,SAAAA,KAAAA;aAtByDN,QAAAA;aAEzDC,aAAa,OAAOM,SAAS,CAAC;YAC1B,MAAM,IAAI,CAACP,KAAK,CAACC,UAAU,CAACM;QAChC;aAEAL,OAAO,CAACM,SAAqCC;YACzC,IAAI,CAACT,KAAK,CAACU,GAAG,CAACF,SAASC;QAC5B;aAEAN,OAAO,CAACK,SAA+BC;YACnC,IAAI,CAACT,KAAK,CAACU,GAAG,CAAC;gBAAE,GAAGF,OAAO;gBAAEG,QAAQf,OAAOgB,IAAI;YAAC,GAAGH;QACxD;aAEAL,UAAU,CAACI,SAA+BC;YACtC,IAAI,CAACT,KAAK,CAACU,GAAG,CAAC;gBAAE,GAAGF,OAAO;gBAAEG,QAAQf,OAAOiB,OAAO;YAAC,GAAGJ;QAC3D;aAEAJ,UAAU,CAACG,SAA+BC;YACtC,IAAI,CAACT,KAAK,CAACU,GAAG,CAAC;gBAAE,GAAGF,OAAO;gBAAEG,QAAQf,OAAOkB,OAAO;YAAC,GAAGL;QAC3D;aAEAH,QAAQ,CAACE,SAA+BC;YACpC,IAAI,CAACT,KAAK,CAACU,GAAG,CAAC;gBAAE,GAAGF,OAAO;gBAAEG,QAAQf,OAAOmB,KAAK;YAAC,GAAGN;QACzD;IAxBqF;AAyBzF"}