@servicetitan/notifications 31.2.0 → 32.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.
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,10 +1,11 @@
1
1
  export class NotificationsApi {
2
2
  }
3
- export var NotificationProcessStatus;
4
- (function (NotificationProcessStatus) {
3
+ export var NotificationProcessStatus = /*#__PURE__*/ function(NotificationProcessStatus) {
5
4
  NotificationProcessStatus[NotificationProcessStatus["Info"] = 0] = "Info";
6
5
  NotificationProcessStatus[NotificationProcessStatus["InProgress"] = 1] = "InProgress";
7
6
  NotificationProcessStatus[NotificationProcessStatus["Success"] = 2] = "Success";
8
7
  NotificationProcessStatus[NotificationProcessStatus["Failure"] = 3] = "Failure";
9
- })(NotificationProcessStatus || (NotificationProcessStatus = {}));
8
+ return NotificationProcessStatus;
9
+ }({});
10
+
10
11
  //# sourceMappingURL=notifications.api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.api.js","sourceRoot":"","sources":["../../src/api/notifications.api.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,gBAAgB;CAcrC;AAcD,MAAM,CAAN,IAAY,yBAKX;AALD,WAAY,yBAAyB;IACjC,yEAAQ,CAAA;IACR,qFAAc,CAAA;IACd,+EAAW,CAAA;IACX,+EAAW,CAAA;AACf,CAAC,EALW,yBAAyB,KAAzB,yBAAyB,QAKpC"}
1
+ {"version":3,"sources":["../../src/api/notifications.api.ts"],"sourcesContent":["import { AxiosPromise, CancelToken } from 'axios';\n\nexport abstract class NotificationsApi {\n abstract getNotifications(\n read: boolean,\n cancelToken?: CancelToken\n ): AxiosPromise<Notification[]>;\n\n abstract changeIsReadProperty(\n id: number,\n read: boolean,\n version: number,\n cancelToken?: CancelToken\n ): AxiosPromise<void>;\n\n abstract getNotification(id: number, cancelToken?: CancelToken): AxiosPromise<Notification>;\n}\n\nexport interface Notification {\n id: number;\n userId: number;\n type: string;\n status: NotificationProcessStatus;\n isRead: boolean;\n createdOn: Date;\n modifiedOn: Date;\n version: number;\n payload?: string;\n}\n\nexport enum NotificationProcessStatus {\n Info = 0,\n InProgress = 1,\n Success = 2,\n Failure = 3,\n}\n\nexport interface DefaultServerNotificationPayload {\n title: string;\n message?: string;\n duration?: number;\n progress?: number;\n action?: {\n label: string;\n link: string;\n };\n}\n"],"names":["NotificationsApi","NotificationProcessStatus"],"mappings":"AAEA,OAAO,MAAeA;AActB;AAcA,OAAO,IAAA,AAAKC,mDAAAA;;;;;WAAAA;MAKX"}
package/dist/common.js CHANGED
@@ -1,14 +1,15 @@
1
- export var Status;
2
- (function (Status) {
1
+ export var Status = /*#__PURE__*/ function(Status) {
3
2
  Status["Info"] = "info";
4
3
  Status["Success"] = "success";
5
4
  Status["Warning"] = "warning";
6
5
  Status["Error"] = "critical";
7
- })(Status || (Status = {}));
6
+ return Status;
7
+ }({});
8
8
  export function isLinkAction(action) {
9
9
  return Object.hasOwn(action, 'link');
10
10
  }
11
11
  export function isNewer(prev, next) {
12
12
  return next.modifiedOn && (!prev.modifiedOn || prev.modifiedOn < next.modifiedOn);
13
13
  }
14
+
14
15
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"sources":["../src/common.ts"],"sourcesContent":["import { Notification as ServerNotification } from './api/notifications.api';\n\nexport interface Notification<T extends Record<keyof any, any> = Record<keyof any, any>>\n extends Omit<ServerNotification, 'payload'> {\n payload: T;\n}\n\nexport interface DefaultNotificationOptions {\n status?: Status;\n title: string;\n message?: string;\n duration?: number;\n progress?: number;\n action?: LinkAction | FunctionAction;\n}\n\nexport enum Status {\n Info = 'info',\n Success = 'success',\n Warning = 'warning',\n Error = 'critical',\n}\n\nexport interface LinkAction {\n label: string;\n link: string;\n external?: boolean;\n}\n\nexport interface FunctionAction {\n label: string;\n onClick: () => void;\n}\n\nexport function isLinkAction(action: LinkAction | FunctionAction): action is LinkAction {\n return Object.hasOwn(action, 'link');\n}\n\nexport function isNewer(\n prev: Pick<Notification, 'modifiedOn'>,\n next: Pick<Notification, 'modifiedOn'>\n) {\n return next.modifiedOn && (!prev.modifiedOn || prev.modifiedOn < next.modifiedOn);\n}\n"],"names":["Status","isLinkAction","action","Object","hasOwn","isNewer","prev","next","modifiedOn"],"mappings":"AAgBA,OAAO,IAAA,AAAKA,gCAAAA;;;;;WAAAA;MAKX;AAaD,OAAO,SAASC,aAAaC,MAAmC;IAC5D,OAAOC,OAAOC,MAAM,CAACF,QAAQ;AACjC;AAEA,OAAO,SAASG,QACZC,IAAsC,EACtCC,IAAsC;IAEtC,OAAOA,KAAKC,UAAU,IAAK,CAAA,CAACF,KAAKE,UAAU,IAAIF,KAAKE,UAAU,GAAGD,KAAKC,UAAU,AAAD;AACnF"}
@@ -1,52 +1,72 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Toaster } from '@servicetitan/anvil2';
3
3
  import { Provider, useDependencies } from '@servicetitan/react-ioc';
4
- import { useCallback, useEffect, useRef, useState, useSyncExternalStore, } from 'react';
4
+ import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react';
5
5
  import { NotificationsApi } from '../api/notifications.api';
6
6
  import { NotificationsStore } from '../stores/notifications.store';
7
7
  import { useCompatibleNavigate } from '../utils/use-compatible-navigate';
8
8
  import { NotificationsService } from '../notifications-service';
9
- export const Notifications = ({ apiService, children }) => (_jsxs(Provider, { singletons: [
10
- ...(apiService ? [{ provide: NotificationsApi, useClass: apiService }] : []),
11
- NotificationsStore,
12
- NotificationsService,
13
- ], children: [_jsx(NotificationsUnwrapped, {}), children] }));
14
- const NotificationsUnwrapped = () => {
9
+ export const Notifications = ({ apiService, children })=>/*#__PURE__*/ _jsxs(Provider, {
10
+ singletons: [
11
+ ...apiService ? [
12
+ {
13
+ provide: NotificationsApi,
14
+ useClass: apiService
15
+ }
16
+ ] : [],
17
+ NotificationsStore,
18
+ NotificationsService
19
+ ],
20
+ children: [
21
+ /*#__PURE__*/ _jsx(NotificationsUnwrapped, {}),
22
+ children
23
+ ]
24
+ });
25
+ const NotificationsUnwrapped = ()=>{
15
26
  // Configure and clean up store
16
27
  const [store] = useDependencies(NotificationsStore);
17
28
  const navigate = useCompatibleNavigate();
18
- useEffect(() => {
29
+ useEffect(()=>{
19
30
  store.navigate = navigate;
20
- return () => {
31
+ return ()=>{
21
32
  store.dispose();
22
33
  };
23
- }, [store, navigate]);
34
+ }, [
35
+ store,
36
+ navigate
37
+ ]);
24
38
  // Use useSyncExternalStore to ensure we re-render when the active id changes
25
- const [thisId] = useState(() => makeId());
39
+ const [thisId] = useState(()=>makeId());
26
40
  const syncExternalStoreCallback = useRef();
27
- const subscribe = useCallback((callback) => {
41
+ const subscribe = useCallback((callback)=>{
28
42
  syncExternalStoreCallback.current = callback;
29
- return () => (syncExternalStoreCallback.current = undefined);
43
+ return ()=>syncExternalStoreCallback.current = undefined;
30
44
  }, []);
31
- const activeId = useSyncExternalStore(subscribe, () => globalThis.STNotificationsActiveId);
45
+ const activeId = useSyncExternalStore(subscribe, ()=>globalThis.STNotificationsActiveId);
32
46
  // Set and clean up active id
33
- useEffect(() => {
34
- var _a;
47
+ useEffect(()=>{
35
48
  if (globalThis.STNotificationsActiveId === undefined) {
49
+ var _syncExternalStoreCallback_current;
36
50
  globalThis.STNotificationsActiveId = thisId;
37
- (_a = syncExternalStoreCallback.current) === null || _a === void 0 ? void 0 : _a.call(syncExternalStoreCallback);
51
+ (_syncExternalStoreCallback_current = syncExternalStoreCallback.current) === null || _syncExternalStoreCallback_current === void 0 ? void 0 : _syncExternalStoreCallback_current.call(syncExternalStoreCallback);
38
52
  }
39
- return () => {
40
- var _a;
53
+ return ()=>{
41
54
  if (globalThis.STNotificationsActiveId === thisId) {
55
+ var _syncExternalStoreCallback_current;
42
56
  globalThis.STNotificationsActiveId = undefined;
43
- (_a = syncExternalStoreCallback.current) === null || _a === void 0 ? void 0 : _a.call(syncExternalStoreCallback);
57
+ (_syncExternalStoreCallback_current = syncExternalStoreCallback.current) === null || _syncExternalStoreCallback_current === void 0 ? void 0 : _syncExternalStoreCallback_current.call(syncExternalStoreCallback);
44
58
  }
45
59
  };
46
- }, [syncExternalStoreCallback, thisId]);
47
- return activeId === thisId ? _jsx(Toaster, { id: 'st-notifications-' + thisId }) : null;
60
+ }, [
61
+ syncExternalStoreCallback,
62
+ thisId
63
+ ]);
64
+ return activeId === thisId ? /*#__PURE__*/ _jsx(Toaster, {
65
+ id: 'st-notifications-' + thisId
66
+ }) : null;
48
67
  };
49
68
  function makeId() {
50
69
  return Math.round(1e8 * Math.random()).toString(36);
51
70
  }
71
+
52
72
  //# sourceMappingURL=notifications.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/components/notifications.tsx"],"names":[],"mappings":"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"}
1
+ {"version":3,"sources":["../../src/components/notifications.tsx"],"sourcesContent":["import { Toaster } from '@servicetitan/anvil2';\nimport { Provider, interfaces, useDependencies } from '@servicetitan/react-ioc';\nimport {\n FC,\n PropsWithChildren,\n useCallback,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\n\nimport { NotificationsApi } from '../api/notifications.api';\nimport { NotificationsStore } from '../stores/notifications.store';\nimport { useCompatibleNavigate } from '../utils/use-compatible-navigate';\nimport { NotificationsService } from '../notifications-service';\n\nexport interface NotificationsProps extends PropsWithChildren<{}> {\n apiService?: interfaces.Newable<NotificationsApi>;\n}\n\nexport const Notifications: FC<NotificationsProps> = ({ apiService, children }) => (\n <Provider\n singletons={[\n ...(apiService ? [{ provide: NotificationsApi, useClass: apiService }] : []),\n NotificationsStore,\n NotificationsService,\n ]}\n >\n <NotificationsUnwrapped />\n {children}\n </Provider>\n);\n\ndeclare global {\n /**\n * This variable ensures there is one and only one \\<Toaster />.\n * It contains the unique id of the instance that owns the Toaster.\n */\n // eslint-disable-next-line no-var\n var STNotificationsActiveId: string | undefined;\n}\n\nconst NotificationsUnwrapped: FC = () => {\n // Configure and clean up store\n\n const [store] = useDependencies(NotificationsStore);\n const navigate = useCompatibleNavigate();\n useEffect(() => {\n store.navigate = navigate;\n return () => {\n store.dispose();\n };\n }, [store, navigate]);\n\n // Use useSyncExternalStore to ensure we re-render when the active id changes\n\n const [thisId] = useState(() => makeId());\n const syncExternalStoreCallback = useRef<Function>();\n const subscribe = useCallback((callback: Function) => {\n syncExternalStoreCallback.current = callback;\n return () => (syncExternalStoreCallback.current = undefined);\n }, []);\n const activeId = useSyncExternalStore(subscribe, () => globalThis.STNotificationsActiveId);\n\n // Set and clean up active id\n\n useEffect(() => {\n if (globalThis.STNotificationsActiveId === undefined) {\n globalThis.STNotificationsActiveId = thisId;\n syncExternalStoreCallback.current?.();\n }\n return () => {\n if (globalThis.STNotificationsActiveId === thisId) {\n globalThis.STNotificationsActiveId = undefined;\n syncExternalStoreCallback.current?.();\n }\n };\n }, [syncExternalStoreCallback, thisId]);\n\n return activeId === thisId ? <Toaster id={'st-notifications-' + thisId} /> : null;\n};\n\nfunction makeId() {\n return Math.round(1e8 * Math.random()).toString(36);\n}\n"],"names":["Toaster","Provider","useDependencies","useCallback","useEffect","useRef","useState","useSyncExternalStore","NotificationsApi","NotificationsStore","useCompatibleNavigate","NotificationsService","Notifications","apiService","children","singletons","provide","useClass","NotificationsUnwrapped","store","navigate","dispose","thisId","makeId","syncExternalStoreCallback","subscribe","callback","current","undefined","activeId","globalThis","STNotificationsActiveId","id","Math","round","random","toString"],"mappings":";AAAA,SAASA,OAAO,QAAQ,uBAAuB;AAC/C,SAASC,QAAQ,EAAcC,eAAe,QAAQ,0BAA0B;AAChF,SAGIC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACRC,oBAAoB,QACjB,QAAQ;AAEf,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,qBAAqB,QAAQ,mCAAmC;AACzE,SAASC,oBAAoB,QAAQ,2BAA2B;AAMhE,OAAO,MAAMC,gBAAwC,CAAC,EAAEC,UAAU,EAAEC,QAAQ,EAAE,iBAC1E,MAACb;QACGc,YAAY;eACJF,aAAa;gBAAC;oBAAEG,SAASR;oBAAkBS,UAAUJ;gBAAW;aAAE,GAAG,EAAE;YAC3EJ;YACAE;SACH;;0BAED,KAACO;YACAJ;;OAEP;AAWF,MAAMI,yBAA6B;IAC/B,+BAA+B;IAE/B,MAAM,CAACC,MAAM,GAAGjB,gBAAgBO;IAChC,MAAMW,WAAWV;IACjBN,UAAU;QACNe,MAAMC,QAAQ,GAAGA;QACjB,OAAO;YACHD,MAAME,OAAO;QACjB;IACJ,GAAG;QAACF;QAAOC;KAAS;IAEpB,6EAA6E;IAE7E,MAAM,CAACE,OAAO,GAAGhB,SAAS,IAAMiB;IAChC,MAAMC,4BAA4BnB;IAClC,MAAMoB,YAAYtB,YAAY,CAACuB;QAC3BF,0BAA0BG,OAAO,GAAGD;QACpC,OAAO,IAAOF,0BAA0BG,OAAO,GAAGC;IACtD,GAAG,EAAE;IACL,MAAMC,WAAWtB,qBAAqBkB,WAAW,IAAMK,WAAWC,uBAAuB;IAEzF,6BAA6B;IAE7B3B,UAAU;QACN,IAAI0B,WAAWC,uBAAuB,KAAKH,WAAW;gBAElDJ;YADAM,WAAWC,uBAAuB,GAAGT;aACrCE,qCAAAA,0BAA0BG,OAAO,cAAjCH,yDAAAA,wCAAAA;QACJ;QACA,OAAO;YACH,IAAIM,WAAWC,uBAAuB,KAAKT,QAAQ;oBAE/CE;gBADAM,WAAWC,uBAAuB,GAAGH;iBACrCJ,qCAAAA,0BAA0BG,OAAO,cAAjCH,yDAAAA,wCAAAA;YACJ;QACJ;IACJ,GAAG;QAACA;QAA2BF;KAAO;IAEtC,OAAOO,aAAaP,uBAAS,KAACtB;QAAQgC,IAAI,sBAAsBV;SAAa;AACjF;AAEA,SAASC;IACL,OAAOU,KAAKC,KAAK,CAAC,MAAMD,KAAKE,MAAM,IAAIC,QAAQ,CAAC;AACpD"}
@@ -2,30 +2,48 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button, Flex } from '@servicetitan/anvil2';
3
3
  import { useDependencies } from '@servicetitan/react-ioc';
4
4
  import { NotificationsService } from '..';
5
- export const ActionButtonPreview = () => {
5
+ export const ActionButtonPreview = ()=>{
6
6
  const [notifications] = useDependencies(NotificationsService);
7
- const handleWithLinkClick = () => notifications.show({
8
- title: 'The action button will move you to the "Table (Master/Detail)" page.',
9
- action: {
10
- label: 'Click me!',
11
- link: '/table-master-detail',
12
- },
7
+ const handleWithLinkClick = ()=>notifications.show({
8
+ title: 'The action button will move you to the "Table (Master/Detail)" page.',
9
+ action: {
10
+ label: 'Click me!',
11
+ link: '/table-master-detail'
12
+ }
13
+ });
14
+ const handleWithExternalLinkClick = ()=>notifications.show({
15
+ title: 'The action button will move you to the "Table (State Caching)" page.',
16
+ action: {
17
+ label: 'Click me!',
18
+ link: '/table-state-caching',
19
+ external: true
20
+ }
21
+ });
22
+ const handleWithHandlerClick = ()=>notifications.show({
23
+ title: 'The action button will show you an alert message.',
24
+ action: {
25
+ label: 'Click me!',
26
+ onClick: ()=>alert("You've clicked the action button")
27
+ }
28
+ });
29
+ return /*#__PURE__*/ _jsxs(Flex, {
30
+ direction: "row",
31
+ gap: "2",
32
+ children: [
33
+ /*#__PURE__*/ _jsx(Button, {
34
+ onClick: handleWithLinkClick,
35
+ children: "With Link"
36
+ }),
37
+ /*#__PURE__*/ _jsx(Button, {
38
+ onClick: handleWithExternalLinkClick,
39
+ children: "With Link (new tab)"
40
+ }),
41
+ /*#__PURE__*/ _jsx(Button, {
42
+ onClick: handleWithHandlerClick,
43
+ children: "With Handler"
44
+ })
45
+ ]
13
46
  });
14
- const handleWithExternalLinkClick = () => notifications.show({
15
- title: 'The action button will move you to the "Table (State Caching)" page.',
16
- action: {
17
- label: 'Click me!',
18
- link: '/table-state-caching',
19
- external: true,
20
- },
21
- });
22
- const handleWithHandlerClick = () => notifications.show({
23
- title: 'The action button will show you an alert message.',
24
- action: {
25
- label: 'Click me!',
26
- onClick: () => alert("You've clicked the action button"),
27
- },
28
- });
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
47
  };
48
+
31
49
  //# 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":";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,mBAAmB,GAAO,GAAG,EAAE;IACxC,MAAM,CAAC,aAAa,CAAC,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAE9D,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAC7B,aAAa,CAAC,IAAI,CAAC;QACf,KAAK,EAAE,sEAAsE;QAC7E,MAAM,EAAE;YACJ,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,sBAAsB;SAC/B;KACJ,CAAC,CAAC;IAEP,MAAM,2BAA2B,GAAG,GAAG,EAAE,CACrC,aAAa,CAAC,IAAI,CAAC;QACf,KAAK,EAAE,sEAAsE;QAC7E,MAAM,EAAE;YACJ,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,sBAAsB;YAC5B,QAAQ,EAAE,IAAI;SACjB;KACJ,CAAC,CAAC;IAEP,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAChC,aAAa,CAAC,IAAI,CAAC;QACf,KAAK,EAAE,mDAAmD;QAC1D,MAAM,EAAE;YACJ,KAAK,EAAE,WAAW;YAClB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,kCAAkC,CAAC;SAC3D;KACJ,CAAC,CAAC;IAEP,OAAO,CACH,MAAC,IAAI,IAAC,SAAS,EAAC,KAAK,EAAC,GAAG,EAAC,GAAG,aACzB,KAAC,MAAM,IAAC,OAAO,EAAE,mBAAmB,0BAAoB,EACxD,KAAC,MAAM,IAAC,OAAO,EAAE,2BAA2B,oCAA8B,EAC1E,KAAC,MAAM,IAAC,OAAO,EAAE,sBAAsB,6BAAuB,IAC3D,CACV,CAAC;AACN,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/demo/action-button-preview.tsx"],"sourcesContent":["import { Button, Flex } from '@servicetitan/anvil2';\nimport { useDependencies } from '@servicetitan/react-ioc';\nimport { FC } from 'react';\n\nimport { NotificationsService } from '..';\n\nexport const ActionButtonPreview: FC = () => {\n const [notifications] = useDependencies(NotificationsService);\n\n const handleWithLinkClick = () =>\n notifications.show({\n title: 'The action button will move you to the \"Table (Master/Detail)\" page.',\n action: {\n label: 'Click me!',\n link: '/table-master-detail',\n },\n });\n\n const handleWithExternalLinkClick = () =>\n notifications.show({\n title: 'The action button will move you to the \"Table (State Caching)\" page.',\n action: {\n label: 'Click me!',\n link: '/table-state-caching',\n external: true,\n },\n });\n\n const handleWithHandlerClick = () =>\n notifications.show({\n title: 'The action button will show you an alert message.',\n action: {\n label: 'Click me!',\n onClick: () => alert(\"You've clicked the action button\"),\n },\n });\n\n return (\n <Flex direction=\"row\" gap=\"2\">\n <Button onClick={handleWithLinkClick}>With Link</Button>\n <Button onClick={handleWithExternalLinkClick}>With Link (new tab)</Button>\n <Button onClick={handleWithHandlerClick}>With Handler</Button>\n </Flex>\n );\n};\n"],"names":["Button","Flex","useDependencies","NotificationsService","ActionButtonPreview","notifications","handleWithLinkClick","show","title","action","label","link","handleWithExternalLinkClick","external","handleWithHandlerClick","onClick","alert","direction","gap"],"mappings":";AAAA,SAASA,MAAM,EAAEC,IAAI,QAAQ,uBAAuB;AACpD,SAASC,eAAe,QAAQ,0BAA0B;AAG1D,SAASC,oBAAoB,QAAQ,KAAK;AAE1C,OAAO,MAAMC,sBAA0B;IACnC,MAAM,CAACC,cAAc,GAAGH,gBAAgBC;IAExC,MAAMG,sBAAsB,IACxBD,cAAcE,IAAI,CAAC;YACfC,OAAO;YACPC,QAAQ;gBACJC,OAAO;gBACPC,MAAM;YACV;QACJ;IAEJ,MAAMC,8BAA8B,IAChCP,cAAcE,IAAI,CAAC;YACfC,OAAO;YACPC,QAAQ;gBACJC,OAAO;gBACPC,MAAM;gBACNE,UAAU;YACd;QACJ;IAEJ,MAAMC,yBAAyB,IAC3BT,cAAcE,IAAI,CAAC;YACfC,OAAO;YACPC,QAAQ;gBACJC,OAAO;gBACPK,SAAS,IAAMC,MAAM;YACzB;QACJ;IAEJ,qBACI,MAACf;QAAKgB,WAAU;QAAMC,KAAI;;0BACtB,KAAClB;gBAAOe,SAAST;0BAAqB;;0BACtC,KAACN;gBAAOe,SAASH;0BAA6B;;0BAC9C,KAACZ;gBAAOe,SAASD;0BAAwB;;;;AAGrD,EAAE"}
@@ -1,5 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Container } from './container';
3
3
  import { ActionButtonPreview } from './action-button-preview';
4
- export const ActionButtonExample = () => _jsx(Container, { children: () => _jsx(ActionButtonPreview, {}) });
4
+ export const ActionButtonExample = ()=>/*#__PURE__*/ _jsx(Container, {
5
+ children: ()=>/*#__PURE__*/ _jsx(ActionButtonPreview, {})
6
+ });
7
+
5
8
  //# sourceMappingURL=action-button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"action-button.js","sourceRoot":"","sources":["../../src/demo/action-button.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,CAAC,MAAM,mBAAmB,GAAO,GAAG,EAAE,CAAC,KAAC,SAAS,cAAE,GAAG,EAAE,CAAC,KAAC,mBAAmB,KAAG,GAAa,CAAC"}
1
+ {"version":3,"sources":["../../src/demo/action-button.tsx"],"sourcesContent":["import { FC } from 'react';\n\nimport { Container } from './container';\nimport { ActionButtonPreview } from './action-button-preview';\n\nexport const ActionButtonExample: FC = () => <Container>{() => <ActionButtonPreview />}</Container>;\n"],"names":["Container","ActionButtonPreview","ActionButtonExample"],"mappings":";AAEA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,OAAO,MAAMC,sBAA0B,kBAAM,KAACF;kBAAW,kBAAM,KAACC;OAAoC"}
@@ -2,12 +2,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Button } from '@servicetitan/anvil2';
3
3
  import { useDependencies } from '@servicetitan/react-ioc';
4
4
  import { NotificationsService } from '..';
5
- export const BasicPreview = () => {
5
+ export const BasicPreview = ()=>{
6
6
  const [notifications] = useDependencies(NotificationsService);
7
- const handleClick = () => notifications.show({
8
- title: 'Congratulations!',
9
- message: "You've successfully clicked the button.",
7
+ const handleClick = ()=>notifications.show({
8
+ title: 'Congratulations!',
9
+ message: "You've successfully clicked the button."
10
+ });
11
+ return /*#__PURE__*/ _jsx(Button, {
12
+ onClick: handleClick,
13
+ children: "Show"
10
14
  });
11
- return _jsx(Button, { onClick: handleClick, children: "Show" });
12
15
  };
16
+
13
17
  //# sourceMappingURL=basic-preview.js.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"sources":["../../src/demo/basic-preview.tsx"],"sourcesContent":["import { Button } from '@servicetitan/anvil2';\nimport { useDependencies } from '@servicetitan/react-ioc';\nimport { FC } from 'react';\n\nimport { NotificationsService } from '..';\n\nexport const BasicPreview: FC = () => {\n const [notifications] = useDependencies(NotificationsService);\n\n const handleClick = () =>\n notifications.show({\n title: 'Congratulations!',\n message: \"You've successfully clicked the button.\",\n });\n\n return <Button onClick={handleClick}>Show</Button>;\n};\n"],"names":["Button","useDependencies","NotificationsService","BasicPreview","notifications","handleClick","show","title","message","onClick"],"mappings":";AAAA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,eAAe,QAAQ,0BAA0B;AAG1D,SAASC,oBAAoB,QAAQ,KAAK;AAE1C,OAAO,MAAMC,eAAmB;IAC5B,MAAM,CAACC,cAAc,GAAGH,gBAAgBC;IAExC,MAAMG,cAAc,IAChBD,cAAcE,IAAI,CAAC;YACfC,OAAO;YACPC,SAAS;QACb;IAEJ,qBAAO,KAACR;QAAOS,SAASJ;kBAAa;;AACzC,EAAE"}
@@ -1,5 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Container } from './container';
3
3
  import { BasicPreview } from './basic-preview';
4
- export const BasicExample = () => _jsx(Container, { children: () => _jsx(BasicPreview, {}) });
4
+ export const BasicExample = ()=>/*#__PURE__*/ _jsx(Container, {
5
+ children: ()=>/*#__PURE__*/ _jsx(BasicPreview, {})
6
+ });
7
+
5
8
  //# sourceMappingURL=basic.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"basic.js","sourceRoot":"","sources":["../../src/demo/basic.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,MAAM,YAAY,GAAO,GAAG,EAAE,CAAC,KAAC,SAAS,cAAE,GAAG,EAAE,CAAC,KAAC,YAAY,KAAG,GAAa,CAAC"}
1
+ {"version":3,"sources":["../../src/demo/basic.tsx"],"sourcesContent":["import { FC } from 'react';\n\nimport { Container } from './container';\nimport { BasicPreview } from './basic-preview';\n\nexport const BasicExample: FC = () => <Container>{() => <BasicPreview />}</Container>;\n"],"names":["Container","BasicPreview","BasicExample"],"mappings":";AAEA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,OAAO,MAAMC,eAAmB,kBAAM,KAACF;kBAAW,kBAAM,KAACC;OAA6B"}
@@ -1,65 +1,64 @@
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
+ }
1
14
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
15
  import { useEffect, useMemo } from 'react';
3
16
  import { Provider, useDependencies } from '@servicetitan/react-ioc';
4
17
  import { NOTIFICATIONS_CHANNEL_TOKEN, Notifications, NotificationsService } from '..';
5
18
  class Publisher {
6
- constructor() {
19
+ constructor(){
7
20
  // eslint-disable-next-line @typescript-eslint/naming-convention
8
- Object.defineProperty(this, "global_emitter", {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value: {
13
- bind: () => { },
14
- unbind: () => { },
15
- }
16
- });
17
- Object.defineProperty(this, "subscription", {
18
- enumerable: true,
19
- configurable: true,
20
- writable: true,
21
- value: void 0
22
- });
23
- Object.defineProperty(this, "bind", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: (_0, callback) => {
28
- this.subscription = callback;
29
- }
21
+ _define_property(this, "global_emitter", {
22
+ bind: ()=>{},
23
+ unbind: ()=>{}
30
24
  });
31
- Object.defineProperty(this, "unbind", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: () => { }
25
+ _define_property(this, "subscription", void 0);
26
+ _define_property(this, "bind", (_0, callback)=>{
27
+ this.subscription = callback;
36
28
  });
37
- Object.defineProperty(this, "fire", {
38
- enumerable: true,
39
- configurable: true,
40
- writable: true,
41
- value: (notification) => {
42
- if (this.subscription) {
43
- this.subscription(notification);
44
- }
29
+ _define_property(this, "unbind", ()=>{});
30
+ _define_property(this, "fire", (notification)=>{
31
+ if (this.subscription) {
32
+ this.subscription(notification);
45
33
  }
46
34
  });
47
35
  }
48
36
  }
49
- const NotificationsInitializer = () => {
37
+ const NotificationsInitializer = ()=>{
50
38
  const [notifications] = useDependencies(NotificationsService);
51
- useEffect(() => {
39
+ useEffect(()=>{
52
40
  notifications.initialize();
53
- }, [notifications]);
41
+ }, [
42
+ notifications
43
+ ]);
54
44
  return null;
55
45
  };
56
- export const Container = ({ children }) => {
57
- const publisherInstance = useMemo(() => new Publisher(), []);
58
- return (_jsx(Provider, { singletons: [
46
+ export const Container = ({ children })=>{
47
+ const publisherInstance = useMemo(()=>new Publisher(), []);
48
+ return /*#__PURE__*/ _jsx(Provider, {
49
+ singletons: [
59
50
  {
60
51
  provide: NOTIFICATIONS_CHANNEL_TOKEN,
61
- useValue: () => publisherInstance,
62
- },
63
- ], children: _jsxs(Notifications, { children: [_jsx(NotificationsInitializer, {}), children(publisherInstance)] }) }));
52
+ useValue: ()=>publisherInstance
53
+ }
54
+ ],
55
+ children: /*#__PURE__*/ _jsxs(Notifications, {
56
+ children: [
57
+ /*#__PURE__*/ _jsx(NotificationsInitializer, {}),
58
+ children(publisherInstance)
59
+ ]
60
+ })
61
+ });
64
62
  };
63
+
65
64
  //# sourceMappingURL=container.js.map
@@ -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;AAGpE,OAAO,EAAE,2BAA2B,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAItF,MAAM,SAAS;IAAf;QACI,gEAAgE;QAChE;;;;mBAAiB;gBACb,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;gBACd,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;aACnB;WAAC;QAEM;;;;;WAA6B;QAErC;;;;mBAAO,CAAC,EAAU,EAAE,QAAuB,EAAE,EAAE;gBAC3C,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;YACjC,CAAC;WAAC;QAEF;;;;mBAAS,GAAG,EAAE,GAAE,CAAC;WAAC;QAElB;;;;mBAAO,CAAC,YAA0B,EAAE,EAAE;gBAClC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;oBACpB,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;gBACpC,CAAC;YACL,CAAC;WAAC;IACN,CAAC;CAAA;AAED,MAAM,wBAAwB,GAAO,GAAG,EAAE;IACtC,MAAM,CAAC,aAAa,CAAC,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE;QACX,aAAa,CAAC,UAAU,EAAE,CAAC;IAC/B,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAMF,MAAM,CAAC,MAAM,SAAS,GAAuB,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC1D,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;IAE7D,OAAO,CACH,KAAC,QAAQ,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
+ {"version":3,"sources":["../../src/demo/container.tsx"],"sourcesContent":["import { useEffect, useMemo, FC } from 'react';\n\nimport { Provider, useDependencies } from '@servicetitan/react-ioc';\n\nimport { Notification } from '../api/notifications.api';\nimport { NOTIFICATIONS_CHANNEL_TOKEN, Notifications, NotificationsService } from '..';\n\ntype EventCallback = (notification: Notification) => void;\n\nclass Publisher {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n global_emitter = {\n bind: () => {},\n unbind: () => {},\n };\n\n private subscription?: EventCallback;\n\n bind = (_0: string, callback: EventCallback) => {\n this.subscription = callback;\n };\n\n unbind = () => {};\n\n fire = (notification: Notification) => {\n if (this.subscription) {\n this.subscription(notification);\n }\n };\n}\n\nconst NotificationsInitializer: FC = () => {\n const [notifications] = useDependencies(NotificationsService);\n\n useEffect(() => {\n notifications.initialize();\n }, [notifications]);\n\n return null;\n};\n\ninterface ContainerProps {\n children(publisher: Publisher): JSX.Element;\n}\n\nexport const Container: FC<ContainerProps> = ({ children }) => {\n const publisherInstance = useMemo(() => new Publisher(), []);\n\n return (\n <Provider\n singletons={[\n {\n provide: NOTIFICATIONS_CHANNEL_TOKEN,\n useValue: () => publisherInstance,\n },\n ]}\n >\n <Notifications>\n <NotificationsInitializer />\n {children(publisherInstance)}\n </Notifications>\n </Provider>\n );\n};\n"],"names":["useEffect","useMemo","Provider","useDependencies","NOTIFICATIONS_CHANNEL_TOKEN","Notifications","NotificationsService","Publisher","global_emitter","bind","unbind","subscription","_0","callback","fire","notification","NotificationsInitializer","notifications","initialize","Container","children","publisherInstance","singletons","provide","useValue"],"mappings":";;;;;;;;;;;;;;AAAA,SAASA,SAAS,EAAEC,OAAO,QAAY,QAAQ;AAE/C,SAASC,QAAQ,EAAEC,eAAe,QAAQ,0BAA0B;AAGpE,SAASC,2BAA2B,EAAEC,aAAa,EAAEC,oBAAoB,QAAQ,KAAK;AAItF,MAAMC;;QACF,gEAAgE;QAChEC,uBAAAA,kBAAiB;YACbC,MAAM,KAAO;YACbC,QAAQ,KAAO;QACnB;QAEA,uBAAQC,gBAAR,KAAA;QAEAF,uBAAAA,QAAO,CAACG,IAAYC;YAChB,IAAI,CAACF,YAAY,GAAGE;QACxB;QAEAH,uBAAAA,UAAS,KAAO;QAEhBI,uBAAAA,QAAO,CAACC;YACJ,IAAI,IAAI,CAACJ,YAAY,EAAE;gBACnB,IAAI,CAACA,YAAY,CAACI;YACtB;QACJ;;AACJ;AAEA,MAAMC,2BAA+B;IACjC,MAAM,CAACC,cAAc,GAAGd,gBAAgBG;IAExCN,UAAU;QACNiB,cAAcC,UAAU;IAC5B,GAAG;QAACD;KAAc;IAElB,OAAO;AACX;AAMA,OAAO,MAAME,YAAgC,CAAC,EAAEC,QAAQ,EAAE;IACtD,MAAMC,oBAAoBpB,QAAQ,IAAM,IAAIM,aAAa,EAAE;IAE3D,qBACI,KAACL;QACGoB,YAAY;YACR;gBACIC,SAASnB;gBACToB,UAAU,IAAMH;YACpB;SACH;kBAED,cAAA,MAAChB;;8BACG,KAACW;gBACAI,SAASC;;;;AAI1B,EAAE"}
@@ -2,16 +2,30 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button, Flex } from '@servicetitan/anvil2';
3
3
  import { useDependencies } from '@servicetitan/react-ioc';
4
4
  import { NotificationsService } from '..';
5
- export const DurationPreview = () => {
5
+ export const DurationPreview = ()=>{
6
6
  const [notifications] = useDependencies(NotificationsService);
7
- const handleOneSecondClick = () => notifications.show({
8
- title: 'This message will be closed in 1 second.',
9
- duration: 1000,
7
+ const handleOneSecondClick = ()=>notifications.show({
8
+ title: 'This message will be closed in 1 second.',
9
+ duration: 1000
10
+ });
11
+ const handleUnlimitedClick = ()=>notifications.show({
12
+ title: "This message won't be closed automatically.",
13
+ duration: 0
14
+ });
15
+ return /*#__PURE__*/ _jsxs(Flex, {
16
+ direction: "row",
17
+ gap: "2",
18
+ children: [
19
+ /*#__PURE__*/ _jsx(Button, {
20
+ onClick: handleOneSecondClick,
21
+ children: "1 second"
22
+ }),
23
+ /*#__PURE__*/ _jsx(Button, {
24
+ onClick: handleUnlimitedClick,
25
+ children: "Unlimited"
26
+ })
27
+ ]
10
28
  });
11
- const handleUnlimitedClick = () => notifications.show({
12
- title: "This message won't be closed automatically.",
13
- duration: 0,
14
- });
15
- return (_jsxs(Flex, { direction: "row", gap: "2", children: [_jsx(Button, { onClick: handleOneSecondClick, children: "1 second" }), _jsx(Button, { onClick: handleUnlimitedClick, children: "Unlimited" })] }));
16
29
  };
30
+
17
31
  //# sourceMappingURL=duration-preview.js.map
@@ -1 +1 @@
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
+ {"version":3,"sources":["../../src/demo/duration-preview.tsx"],"sourcesContent":["import { Button, Flex } from '@servicetitan/anvil2';\nimport { useDependencies } from '@servicetitan/react-ioc';\nimport { FC } from 'react';\n\nimport { NotificationsService } from '..';\n\nexport const DurationPreview: FC = () => {\n const [notifications] = useDependencies(NotificationsService);\n\n const handleOneSecondClick = () =>\n notifications.show({\n title: 'This message will be closed in 1 second.',\n duration: 1000,\n });\n\n const handleUnlimitedClick = () =>\n notifications.show({\n title: \"This message won't be closed automatically.\",\n duration: 0,\n });\n\n return (\n <Flex direction=\"row\" gap=\"2\">\n <Button onClick={handleOneSecondClick}>1 second</Button>\n <Button onClick={handleUnlimitedClick}>Unlimited</Button>\n </Flex>\n );\n};\n"],"names":["Button","Flex","useDependencies","NotificationsService","DurationPreview","notifications","handleOneSecondClick","show","title","duration","handleUnlimitedClick","direction","gap","onClick"],"mappings":";AAAA,SAASA,MAAM,EAAEC,IAAI,QAAQ,uBAAuB;AACpD,SAASC,eAAe,QAAQ,0BAA0B;AAG1D,SAASC,oBAAoB,QAAQ,KAAK;AAE1C,OAAO,MAAMC,kBAAsB;IAC/B,MAAM,CAACC,cAAc,GAAGH,gBAAgBC;IAExC,MAAMG,uBAAuB,IACzBD,cAAcE,IAAI,CAAC;YACfC,OAAO;YACPC,UAAU;QACd;IAEJ,MAAMC,uBAAuB,IACzBL,cAAcE,IAAI,CAAC;YACfC,OAAO;YACPC,UAAU;QACd;IAEJ,qBACI,MAACR;QAAKU,WAAU;QAAMC,KAAI;;0BACtB,KAACZ;gBAAOa,SAASP;0BAAsB;;0BACvC,KAACN;gBAAOa,SAASH;0BAAsB;;;;AAGnD,EAAE"}
@@ -1,5 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Container } from './container';
3
3
  import { DurationPreview } from './duration-preview';
4
- export const DurationExample = () => _jsx(Container, { children: () => _jsx(DurationPreview, {}) });
4
+ export const DurationExample = ()=>/*#__PURE__*/ _jsx(Container, {
5
+ children: ()=>/*#__PURE__*/ _jsx(DurationPreview, {})
6
+ });
7
+
5
8
  //# sourceMappingURL=duration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/demo/duration.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,CAAC,MAAM,eAAe,GAAO,GAAG,EAAE,CAAC,KAAC,SAAS,cAAE,GAAG,EAAE,CAAC,KAAC,eAAe,KAAG,GAAa,CAAC"}
1
+ {"version":3,"sources":["../../src/demo/duration.tsx"],"sourcesContent":["import { FC } from 'react';\n\nimport { Container } from './container';\nimport { DurationPreview } from './duration-preview';\n\nexport const DurationExample: FC = () => <Container>{() => <DurationPreview />}</Container>;\n"],"names":["Container","DurationPreview","DurationExample"],"mappings":";AAEA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,eAAe,QAAQ,qBAAqB;AAErD,OAAO,MAAMC,kBAAsB,kBAAM,KAACF;kBAAW,kBAAM,KAACC;OAAgC"}
@@ -7,4 +7,5 @@ export * from './prevent-duplicates';
7
7
  export * from './multiline-message';
8
8
  export * from './server-default';
9
9
  export * from './server-custom';
10
+
10
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/demo/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"sources":["../../src/demo/index.ts"],"sourcesContent":["export * from './basic';\nexport * from './status-variations';\nexport * from './duration';\nexport * from './action-button';\nexport * from './progress';\nexport * from './prevent-duplicates';\nexport * from './multiline-message';\nexport * from './server-default';\nexport * from './server-custom';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,sBAAsB;AACpC,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,aAAa;AAC3B,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,kBAAkB"}
@@ -2,12 +2,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Button } from '@servicetitan/anvil2';
3
3
  import { useDependencies } from '@servicetitan/react-ioc';
4
4
  import { NotificationsService } from '..';
5
- export const MultilineMessagePreview = () => {
5
+ export const MultilineMessagePreview = ()=>{
6
6
  const [notifications] = useDependencies(NotificationsService);
7
- const handleClick = () => notifications.show({
8
- title: 'Notification with multiline message',
9
- message: '1. First\r\n2. Second\r\n3. Third',
7
+ const handleClick = ()=>notifications.show({
8
+ title: 'Notification with multiline message',
9
+ message: '1. First\r\n2. Second\r\n3. Third'
10
+ });
11
+ return /*#__PURE__*/ _jsx(Button, {
12
+ onClick: handleClick,
13
+ children: "Show"
10
14
  });
11
- return _jsx(Button, { onClick: handleClick, children: "Show" });
12
15
  };
16
+
13
17
  //# 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":";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
+ {"version":3,"sources":["../../src/demo/multiline-message-preview.tsx"],"sourcesContent":["import { Button } from '@servicetitan/anvil2';\nimport { useDependencies } from '@servicetitan/react-ioc';\nimport { FC } from 'react';\n\nimport { NotificationsService } from '..';\n\nexport const MultilineMessagePreview: FC = () => {\n const [notifications] = useDependencies(NotificationsService);\n\n const handleClick = () =>\n notifications.show({\n title: 'Notification with multiline message',\n message: '1. First\\r\\n2. Second\\r\\n3. Third',\n });\n\n return <Button onClick={handleClick}>Show</Button>;\n};\n"],"names":["Button","useDependencies","NotificationsService","MultilineMessagePreview","notifications","handleClick","show","title","message","onClick"],"mappings":";AAAA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,eAAe,QAAQ,0BAA0B;AAG1D,SAASC,oBAAoB,QAAQ,KAAK;AAE1C,OAAO,MAAMC,0BAA8B;IACvC,MAAM,CAACC,cAAc,GAAGH,gBAAgBC;IAExC,MAAMG,cAAc,IAChBD,cAAcE,IAAI,CAAC;YACfC,OAAO;YACPC,SAAS;QACb;IAEJ,qBAAO,KAACR;QAAOS,SAASJ;kBAAa;;AACzC,EAAE"}
@@ -1,5 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Container } from './container';
3
3
  import { MultilineMessagePreview } from './multiline-message-preview';
4
- export const MultilineMessageExample = () => (_jsx(Container, { children: () => _jsx(MultilineMessagePreview, {}) }));
4
+ export const MultilineMessageExample = ()=>/*#__PURE__*/ _jsx(Container, {
5
+ children: ()=>/*#__PURE__*/ _jsx(MultilineMessagePreview, {})
6
+ });
7
+
5
8
  //# sourceMappingURL=multiline-message.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"multiline-message.js","sourceRoot":"","sources":["../../src/demo/multiline-message.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,MAAM,CAAC,MAAM,uBAAuB,GAAO,GAAG,EAAE,CAAC,CAC7C,KAAC,SAAS,cAAE,GAAG,EAAE,CAAC,KAAC,uBAAuB,KAAG,GAAa,CAC7D,CAAC"}
1
+ {"version":3,"sources":["../../src/demo/multiline-message.tsx"],"sourcesContent":["import { FC } from 'react';\n\nimport { Container } from './container';\nimport { MultilineMessagePreview } from './multiline-message-preview';\n\nexport const MultilineMessageExample: FC = () => (\n <Container>{() => <MultilineMessagePreview />}</Container>\n);\n"],"names":["Container","MultilineMessagePreview","MultilineMessageExample"],"mappings":";AAEA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,uBAAuB,QAAQ,8BAA8B;AAEtE,OAAO,MAAMC,0BAA8B,kBACvC,KAACF;kBAAW,kBAAM,KAACC;OACrB"}