chayns-api 1.1.0-2 → 1.1.0-4

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 (76) hide show
  1. package/dist/cjs/calls/dialogs/chaynsDialog.js +3 -6
  2. package/dist/cjs/calls/dialogs/date.js +29 -2
  3. package/dist/cjs/calls/dialogs/fileSelect.js +1 -2
  4. package/dist/cjs/calls/dialogs/input.js +2 -3
  5. package/dist/cjs/calls/dialogs/select.js +2 -3
  6. package/dist/cjs/calls/getUserInfo.js +1 -2
  7. package/dist/cjs/calls/index.js +93 -82
  8. package/dist/cjs/components/AppDialogWrapper.js +7 -7
  9. package/dist/cjs/components/ChaynsContext.js +2 -4
  10. package/dist/cjs/components/ChaynsProvider.js +10 -13
  11. package/dist/cjs/components/ErrorBoundary.js +31 -0
  12. package/dist/cjs/components/moduleWrapper.js +9 -0
  13. package/dist/cjs/components/withCompatMode.js +8 -7
  14. package/dist/cjs/components/withHydrationBoundary.js +57 -0
  15. package/dist/cjs/constants/hydrationContext.js +16 -0
  16. package/dist/cjs/constants/index.js +16 -0
  17. package/dist/cjs/handler/DialogHandler.js +4 -2
  18. package/dist/cjs/hooks/useAccessToken.js +1 -0
  19. package/dist/cjs/hooks/useDialogState.js +2 -2
  20. package/dist/cjs/hooks/usePages.js +2 -2
  21. package/dist/cjs/host/ChaynsHost.js +1 -2
  22. package/dist/cjs/host/iframe/HostIframe.js +4 -6
  23. package/dist/cjs/host/iframe/utils/useUpdateData.js +1 -2
  24. package/dist/cjs/host/module/ModuleHost.js +8 -24
  25. package/dist/cjs/host/module/utils/loadComponent.js +58 -51
  26. package/dist/cjs/index.js +48 -5
  27. package/dist/cjs/types/IChaynsReact.js +140 -107
  28. package/dist/cjs/util/appCall.js +3 -4
  29. package/dist/cjs/util/deviceHelper.js +18 -13
  30. package/dist/cjs/util/transferNestedFunctions.js +36 -0
  31. package/dist/cjs/wrapper/AppWrapper.js +69 -11
  32. package/dist/cjs/wrapper/FrameWrapper.js +16 -5
  33. package/dist/cjs/wrapper/StaticChaynsApi.js +22 -0
  34. package/dist/esm/calls/index.js +22 -1
  35. package/dist/esm/components/AppDialogWrapper.js +4 -3
  36. package/dist/esm/components/ChaynsProvider.js +6 -7
  37. package/dist/esm/components/ErrorBoundary.js +23 -0
  38. package/dist/esm/components/moduleWrapper.js +3 -0
  39. package/dist/esm/components/withCompatMode.js +5 -4
  40. package/dist/esm/components/withHydrationBoundary.js +50 -0
  41. package/dist/esm/constants/hydrationContext.js +10 -0
  42. package/dist/esm/constants/index.js +1 -0
  43. package/dist/esm/handler/DialogHandler.js +6 -4
  44. package/dist/esm/hooks/useAccessToken.js +1 -0
  45. package/dist/esm/hooks/useDialogState.js +2 -2
  46. package/dist/esm/hooks/usePages.js +1 -1
  47. package/dist/esm/host/iframe/HostIframe.js +1 -2
  48. package/dist/esm/host/module/ModuleHost.js +5 -20
  49. package/dist/esm/host/module/utils/loadComponent.js +58 -50
  50. package/dist/esm/index.js +6 -1
  51. package/dist/esm/types/IChaynsReact.js +142 -87
  52. package/dist/esm/util/appCall.js +2 -2
  53. package/dist/esm/util/deviceHelper.js +17 -11
  54. package/dist/esm/util/transferNestedFunctions.js +32 -0
  55. package/dist/esm/wrapper/AppWrapper.js +70 -11
  56. package/dist/esm/wrapper/FrameWrapper.js +16 -5
  57. package/dist/esm/wrapper/StaticChaynsApi.js +20 -0
  58. package/dist/types/calls/index.d.ts +19 -5
  59. package/dist/types/components/AppDialogWrapper.d.ts +2 -2
  60. package/dist/types/components/ChaynsProvider.d.ts +1 -4
  61. package/dist/types/components/ErrorBoundary.d.ts +13 -0
  62. package/dist/types/components/moduleWrapper.d.ts +4 -0
  63. package/dist/types/components/withHydrationBoundary.d.ts +16 -0
  64. package/dist/types/constants/hydrationContext.d.ts +8 -0
  65. package/dist/types/constants/index.d.ts +1 -0
  66. package/dist/types/handler/DialogHandler.d.ts +0 -1
  67. package/dist/types/hooks/useAccessToken.d.ts +1 -0
  68. package/dist/types/host/module/ModuleHost.d.ts +1 -0
  69. package/dist/types/host/module/utils/loadComponent.d.ts +1 -1
  70. package/dist/types/index.d.ts +6 -1
  71. package/dist/types/types/IChaynsReact.d.ts +136 -28
  72. package/dist/types/util/deviceHelper.d.ts +2 -2
  73. package/dist/types/util/transferNestedFunctions.d.ts +1 -0
  74. package/dist/types/wrapper/StaticChaynsApi.d.ts +9 -0
  75. package/package.json +26 -22
  76. package/toolkit.config.js +20 -0
@@ -5,13 +5,67 @@ export type DialogButton = {
5
5
  type: DialogButtonType;
6
6
  text: string;
7
7
  };
8
- export type BaseDialog = {
8
+ export declare enum DateType {
9
+ DATE = 0,
10
+ TIME = 1,
11
+ DATE_TIME = 2
12
+ }
13
+ export interface DialogDate {
14
+ type: DialogType.DATE;
15
+ minDate: Date;
16
+ maxDate: Date;
17
+ minDuration?: number;
18
+ minuteInterval?: number;
19
+ preselect?: Date;
20
+ dateType?: DateType;
21
+ multiselect?: boolean;
22
+ monthSelect?: boolean;
23
+ yearSelect?: boolean;
24
+ }
25
+ export declare enum ToastType {
26
+ NEUTRAL = 1,
27
+ SUCCESS = 2,
28
+ WARNING = 3,
29
+ ERROR = 4
30
+ }
31
+ export interface DialogToast {
32
+ type: DialogType.TOAST;
33
+ icon?: string;
34
+ showDurationBar?: boolean;
35
+ duration?: number;
36
+ linkText?: string;
37
+ onLinkClick?: () => void;
38
+ permanent?: boolean;
39
+ showCloseIcon?: boolean;
40
+ toastType?: ToastType;
41
+ }
42
+ export interface DialogFileSelect {
43
+ type: DialogType.FILE_SELECT;
44
+ multiselect?: boolean;
45
+ contentType?: Array<string> | string;
46
+ exclude?: Array<string> | string;
47
+ directory?: boolean;
48
+ }
49
+ export interface DialogConfirm {
50
+ type: DialogType.CONFIRM;
51
+ }
52
+ export interface DialogAlert {
53
+ type: DialogType.ALERT;
54
+ }
55
+ export interface BaseDialog {
9
56
  text?: string;
10
57
  buttons?: DialogButton[];
11
- dialogId: number;
12
- };
13
- export type Dialog = BaseDialog & (DialogInput | DialogModule | DialogIFrame | DialogSelect);
14
- export type DialogModule = {
58
+ width?: string | number;
59
+ animation?: {
60
+ type: DialogAnimation;
61
+ config?: any;
62
+ };
63
+ }
64
+ export type Dialog = BaseDialog & (DialogAlert | DialogConfirm | DialogInput | DialogModule | DialogIFrame | DialogSelect | DialogDate | DialogToast | DialogFileSelect | DialogSignature);
65
+ export interface DialogSignature {
66
+ type: DialogType.SIGNATURE;
67
+ }
68
+ export interface DialogModule {
15
69
  type: DialogType.MODULE;
16
70
  system: {
17
71
  url: string;
@@ -19,27 +73,48 @@ export type DialogModule = {
19
73
  scope: string;
20
74
  };
21
75
  dialogInput: object;
22
- isClosingRequested: boolean;
23
- };
24
- export type DialogIFrame = {
76
+ }
77
+ export interface DialogIFrame {
25
78
  type: DialogType.IFRAME;
26
79
  url: string;
27
80
  dialogInput: object;
28
- isClosingRequested: boolean;
29
- };
30
- export type DialogInput = {
81
+ }
82
+ export declare enum DialogInputType {
83
+ NUMBER = "number",
84
+ PASSWORD = "password",
85
+ TELEPHONE = "tel",
86
+ TEXT = "text",
87
+ TEXTAREA = "textarea"
88
+ }
89
+ export interface DialogInput {
31
90
  type: DialogType.INPUT;
32
91
  placeholder: string;
92
+ inputType: DialogInputType;
93
+ defaultValue?: string;
94
+ formatter?: (input: string) => string;
95
+ }
96
+ export declare enum DialogSelectType {
97
+ DEFAULT = 0,
98
+ ICON = 1,
99
+ IMAGE = 2
100
+ }
101
+ export type DialogSelectListItemType = {
102
+ id: number;
103
+ name: string;
104
+ disabled?: boolean;
105
+ isSelected?: boolean;
106
+ url?: string;
107
+ className?: string;
33
108
  };
34
- export type DialogSelect = {
109
+ export interface DialogSelect {
35
110
  type: DialogType.SELECT;
36
- list: {
37
- id: number;
38
- name: string;
39
- disabled?: boolean;
40
- isSelected?: boolean;
41
- }[];
42
- };
111
+ list: DialogSelectListItemType[];
112
+ multiselect?: boolean;
113
+ quickfind?: boolean;
114
+ selectType?: DialogSelectType;
115
+ preventCloseOnClick?: boolean;
116
+ selectAllCheckbox?: string;
117
+ }
43
118
  export declare enum DialogButtonType {
44
119
  OK = 1,
45
120
  CANCEL = -1,
@@ -104,9 +179,7 @@ export type DialogHookResult = {
104
179
  addDataListener: ChaynsReactFunctions["addDialogHostEventListener"];
105
180
  };
106
181
  export type DialogDataHookResult = {
107
- inputData: {
108
- [key: string | symbol]: object;
109
- };
182
+ [key: string | symbol]: object;
110
183
  };
111
184
  /**
112
185
  * @ignore
@@ -131,7 +204,7 @@ export interface ChaynsReactValues {
131
204
  * keys are in lower case
132
205
  */
133
206
  parameters: {
134
- [key: string | symbol]: string;
207
+ [key: string | symbol]: string | string[];
135
208
  };
136
209
  environment: {
137
210
  buildEnvironment: Environment;
@@ -155,6 +228,7 @@ export interface ChaynsReactFunctions {
155
228
  throttle?: number;
156
229
  }, callback: (result: ScrollListenerResult) => void) => Promise<number>;
157
230
  addVisibilityChangeListener: (callback: (result: VisibilityChangeListenerResult) => void) => Promise<number>;
231
+ addToolbarChangeListener: (callback: (result: ToolbarChangeListenerResult) => void) => Promise<number>;
158
232
  addWindowMetricsListener: (callback: (result: WindowMetricsListenerResult) => void) => Promise<number>;
159
233
  customCallbackFunction: (type: string, data: unknown) => Promise<unknown>;
160
234
  getAvailableSharingServices: () => Promise<AvailableSharingServices>;
@@ -174,11 +248,13 @@ export interface ChaynsReactFunctions {
174
248
  openImage: (value: OpenImage) => Promise<void>;
175
249
  openUrl: (value: OpenUrl) => Promise<void>;
176
250
  openVideo: (value: OpenVideo) => Promise<void>;
251
+ openMedia: (value: OpenMedia) => Promise<void>;
177
252
  refreshData: (value: RefreshData) => Promise<void>;
178
253
  refreshAccessToken: () => Promise<void>;
179
254
  removeGeoLocationListener: (value: number) => Promise<void>;
180
255
  removeScrollListener: (value: number) => Promise<void>;
181
256
  removeVisibilityChangeListener: (value: number) => Promise<void>;
257
+ removeToolbarChangeListener: (value: number) => Promise<void>;
182
258
  removeWindowMetricsListener: (value: number) => Promise<void>;
183
259
  selectPage: (value: SelectPage) => Promise<void>;
184
260
  scrollToY: (position: number, duration: number) => Promise<void>;
@@ -202,7 +278,7 @@ export interface ChaynsReactFunctions {
202
278
  createDialog: (config: Dialog) => DialogHandler;
203
279
  openDialog: (value: any, callback: (data: any) => any) => Promise<any>;
204
280
  closeDialog: (dialogId: number) => Promise<void>;
205
- setDialogResult: (result: any) => Promise<void>;
281
+ setDialogResult: (buttonType: DialogButtonType, result: any) => Promise<void>;
206
282
  dispatchEventToDialogClient: (dialogId: number, data: object) => Promise<void>;
207
283
  addDialogClientEventListener: (dialogId: number, callback: (data: object) => void) => Promise<number>;
208
284
  removeDialogClientEventListener: (dialogId: number, id: number) => Promise<void>;
@@ -430,7 +506,7 @@ export type UserInfoQuery = {
430
506
  personId?: string;
431
507
  userId: number;
432
508
  };
433
- type OpenImageItem = {
509
+ export type OpenImageItem = {
434
510
  url: string;
435
511
  title?: string;
436
512
  description?: string;
@@ -512,10 +588,11 @@ export interface RefreshScrollEnabled {
512
588
  isEnabled: boolean;
513
589
  }
514
590
  export interface GeoLocation {
515
- accuracy: number | null;
516
591
  latitude: number;
517
592
  longitude: number;
518
593
  speed: number;
594
+ accuracy: number | null;
595
+ isAccurate: boolean | null;
519
596
  code: number;
520
597
  }
521
598
  export type DataChangeValue = {
@@ -553,6 +630,10 @@ export interface VisibilityChangeListenerResult {
553
630
  isVisible: boolean;
554
631
  tappEvent: TappEvent;
555
632
  }
633
+ export interface ToolbarChangeListenerResult {
634
+ isVisible: boolean;
635
+ toolbarHeight: number;
636
+ }
556
637
  export interface ScrollListenerResult {
557
638
  scrollX: number | null;
558
639
  scrollY: number | null;
@@ -633,7 +714,10 @@ export declare enum AppName {
633
714
  Chayns = 2,
634
715
  Location = 3,
635
716
  Intercom = 4,
636
- ChaynsLauncher = 5
717
+ ChaynsLauncher = 5,
718
+ TobitChat = 6,
719
+ Sidekick = 7,
720
+ Team = 8
637
721
  }
638
722
  export declare enum BrowserName {
639
723
  Unknown = "unknown",
@@ -703,6 +787,30 @@ export declare enum DialogType {
703
787
  MODULE = "module",
704
788
  INPUT = "input",
705
789
  SELECT = "select",
706
- TOAST = "toast"
790
+ TOAST = "toast",
791
+ SIGNATURE = "signature"
792
+ }
793
+ export declare enum MediaType {
794
+ IMAGE = "image",
795
+ VIDEO = "video"
796
+ }
797
+ export type OpenMediaItem = {
798
+ url: string;
799
+ title?: string;
800
+ description?: string;
801
+ preventCache?: boolean;
802
+ mediaType: MediaType;
803
+ };
804
+ export type OpenMedia = {
805
+ items: [OpenMediaItem, ...OpenMediaItem[]];
806
+ startIndex?: number;
807
+ };
808
+ export declare enum DialogAnimation {
809
+ CONFETTI = "confetti"
810
+ }
811
+ export declare enum DialogIconType {
812
+ SuccessIcon = "%%DialogSuccessIcon%%",
813
+ WarningIcon = "%%DialogWarningIcon%%",
814
+ ErrorIcon = "%%DialogErrorIcon%%"
707
815
  }
708
816
  export {};
@@ -1,7 +1,7 @@
1
1
  import { ChaynsApiDevice, ScreenSize } from '../types/IChaynsReact';
2
2
  declare const getDeviceInfo: (userAgent: string, acceptHeader: string) => ChaynsApiDevice;
3
3
  export declare const getClientDeviceInfo: () => {
4
- isTouch: false | MediaQueryList;
4
+ isTouch: boolean;
5
5
  };
6
- export declare const getScreenSize: (width: any, height: any) => ScreenSize;
6
+ export declare const getScreenSize: (width: any) => ScreenSize;
7
7
  export default getDeviceInfo;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { DataChangeCallback } from '../types/IChaynsReact';
2
+ declare class StaticChaynsApi {
3
+ ready: Promise<void>;
4
+ addDataListener: (cb: DataChangeCallback) => () => void;
5
+ private _wrapper;
6
+ constructor();
7
+ getSite: () => any;
8
+ }
9
+ export default StaticChaynsApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "1.1.0-2",
3
+ "version": "1.1.0-4",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -12,6 +12,7 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "start": "npm run dev",
15
+ "build:umd": "chayns-toolkit build",
15
16
  "build:cjs": "cross-env NODE_ENV=cjs babel src --out-dir dist/cjs --extensions=.ts,.tsx",
16
17
  "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --extensions=.ts,.tsx",
17
18
  "build-docs": "npm i && cd website && npm i && npm run build",
@@ -34,42 +35,45 @@
34
35
  "extends": "@chayns-toolkit"
35
36
  },
36
37
  "dependencies": {
37
- "@types/semver": "^7.3.9",
38
- "comlink": "^4.4.1",
38
+ "@module-federation/runtime": "^0.1.6",
39
+ "@types/semver": "^7.5.8",
40
+ "comlink": "4.3.1",
39
41
  "detect-browser": "^5.2.1",
40
42
  "htmlescape": "^1.1.1",
41
43
  "lodash.throttle": "^4.1.1",
42
44
  "prop-types": "^15.7.2",
43
- "scheduler": "^0.20.2",
45
+ "scheduler": "^0.23.0",
44
46
  "semaphore-async-await": "^1.5.1",
45
- "semver": "^7.3.5",
46
- "use-context-selector": "^1.3.9"
47
+ "semver": "^7.6.0",
48
+ "use-context-selector": "^1.4.4",
49
+ "util": "^0.12.5"
47
50
  },
48
51
  "devDependencies": {
49
- "@babel/cli": "^7.20.7",
50
- "@babel/core": "^7.20.12",
51
- "@babel/preset-env": "^7.16.4",
52
- "@babel/preset-react": "^7.16.0",
53
- "@babel/preset-typescript": "^7.16.0",
52
+ "@babel/cli": "^7.24.1",
53
+ "@babel/core": "^7.24.4",
54
+ "@babel/preset-env": "^7.24.4",
55
+ "@babel/preset-react": "^7.24.1",
56
+ "@babel/preset-typescript": "^7.24.1",
54
57
  "@chayns-toolkit/eslint-config": "^2.0.0",
55
58
  "@testing-library/react": "^12.1.2",
56
- "@types/htmlescape": "^1.1.1",
57
- "@types/lodash.throttle": "^4.1.6",
58
- "@types/prop-types": "^15.7.3",
59
- "@types/react": "^18.0.28",
60
- "@types/react-dom": "^18.0.10",
61
- "@typescript-eslint/parser": "^5.50.0",
62
- "concurrently": "^7.6.0",
59
+ "@types/htmlescape": "^1.1.3",
60
+ "@types/lodash.throttle": "^4.1.9",
61
+ "@types/prop-types": "^15.7.12",
62
+ "@types/react": "^18.2.78",
63
+ "@types/react-dom": "^18.2.25",
64
+ "@typescript-eslint/parser": "^7.6.0",
65
+ "chayns-toolkit": "^2.0.9",
66
+ "concurrently": "^8.2.2",
63
67
  "cross-env": "^7.0.3",
64
68
  "postcss-prefix-selector": "^1.13.0",
65
- "prettier": "^2.5.0",
66
- "prettier-plugin-packagejson": "^2.2.15",
69
+ "prettier": "^3.2.5",
70
+ "prettier-plugin-packagejson": "^2.5.0",
67
71
  "react": "^17.0.2",
68
72
  "react-dom": "^17.0.2",
69
73
  "typescript": "^4.9.5"
70
74
  },
71
75
  "peerDependencies": {
72
- "react": "^16.8 || ^17.0.1",
73
- "react-dom": "^16.8 || ^17.0.1"
76
+ "react": "^16.8 || ^17.0.1 || ^18.0.0",
77
+ "react-dom": "^16.8 || ^17.0.1 || ^18.0.0"
74
78
  }
75
79
  }
@@ -0,0 +1,20 @@
1
+ const path = require('path');
2
+
3
+ module.exports = {
4
+ development: {
5
+ host: "0.0.0.0",
6
+ port: 8081,
7
+ },
8
+ output: {
9
+ singleBundle: true,
10
+ filename: 'chayns-api.js',
11
+ path: path.resolve(__dirname, 'dist'),
12
+ },
13
+ webpack(config) {
14
+ config.output.library = {
15
+ name: 'ChaynsApi',
16
+ type: 'umd',
17
+ }
18
+ return config;
19
+ }
20
+ };