chayns-api 1.0.13 → 1.1.0-2

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 (139) hide show
  1. package/.babelrc +30 -30
  2. package/.eslintrc +17 -17
  3. package/.github/workflows/deploy_docs.yml +28 -28
  4. package/.github/workflows/publish.yml +21 -21
  5. package/LICENSE +21 -21
  6. package/README.md +54 -54
  7. package/dist/cjs/calls/dialogs/date.js +10 -10
  8. package/dist/cjs/calls/index.js +102 -97
  9. package/dist/cjs/calls/sendMessage.js +8 -8
  10. package/dist/cjs/calls/visibilityChangeListener.js +4 -4
  11. package/dist/cjs/components/AppDialogWrapper.js +42 -0
  12. package/dist/cjs/components/ChaynsProvider.js +5 -2
  13. package/dist/cjs/handler/DialogHandler.js +63 -0
  14. package/dist/cjs/hooks/geoLocationListener.js +4 -4
  15. package/dist/cjs/hooks/index.js +14 -1
  16. package/dist/cjs/hooks/scrollListener.js +8 -8
  17. package/dist/cjs/hooks/useAccessToken.js +2 -2
  18. package/dist/cjs/hooks/useCurrentPage.js +2 -2
  19. package/dist/cjs/hooks/useCustomData.js +2 -2
  20. package/dist/cjs/hooks/useDevice.js +2 -2
  21. package/dist/cjs/hooks/useDialogState.js +39 -0
  22. package/dist/cjs/hooks/useEnvironment.js +2 -2
  23. package/dist/cjs/hooks/useFunctions.js +2 -2
  24. package/dist/cjs/hooks/useIsAdminMode.js +2 -2
  25. package/dist/cjs/hooks/useLanguage.js +2 -2
  26. package/dist/cjs/hooks/usePages.js +4 -4
  27. package/dist/cjs/hooks/useParameters.js +2 -2
  28. package/dist/cjs/hooks/useSite.js +2 -2
  29. package/dist/cjs/hooks/useUser.js +2 -2
  30. package/dist/cjs/hooks/useValues.js +2 -2
  31. package/dist/cjs/hooks/windowMetricsListener.js +4 -4
  32. package/dist/cjs/host/ChaynsHost.js +10 -5
  33. package/dist/cjs/host/iframe/HostIframe.js +5 -2
  34. package/dist/cjs/host/module/ModuleHost.js +4 -0
  35. package/dist/cjs/types/IChaynsReact.js +22 -2
  36. package/dist/cjs/util/deviceHelper.js +7 -6
  37. package/dist/cjs/wrapper/AppWrapper.js +42 -6
  38. package/dist/cjs/wrapper/FrameWrapper.js +52 -1
  39. package/dist/cjs/wrapper/ModuleFederationWrapper.js +4 -0
  40. package/dist/esm/calls/dialogs/date.js +34 -34
  41. package/dist/esm/calls/index.js +102 -96
  42. package/dist/esm/calls/sendMessage.js +8 -8
  43. package/dist/esm/calls/visibilityChangeListener.js +4 -4
  44. package/dist/esm/components/AppDialogWrapper.js +33 -0
  45. package/dist/esm/components/ChaynsProvider.js +5 -2
  46. package/dist/esm/handler/DialogHandler.js +59 -0
  47. package/dist/esm/hooks/geoLocationListener.js +4 -4
  48. package/dist/esm/hooks/index.js +2 -1
  49. package/dist/esm/hooks/scrollListener.js +8 -8
  50. package/dist/esm/hooks/useAccessToken.js +2 -2
  51. package/dist/esm/hooks/useCurrentPage.js +2 -2
  52. package/dist/esm/hooks/useCustomData.js +2 -2
  53. package/dist/esm/hooks/useDevice.js +2 -2
  54. package/dist/esm/hooks/useDialogState.js +32 -0
  55. package/dist/esm/hooks/useEnvironment.js +2 -2
  56. package/dist/esm/hooks/useFunctions.js +2 -2
  57. package/dist/esm/hooks/useIsAdminMode.js +2 -2
  58. package/dist/esm/hooks/useLanguage.js +2 -2
  59. package/dist/esm/hooks/usePages.js +4 -4
  60. package/dist/esm/hooks/useParameters.js +2 -2
  61. package/dist/esm/hooks/useSite.js +2 -2
  62. package/dist/esm/hooks/useUser.js +2 -2
  63. package/dist/esm/hooks/useValues.js +2 -2
  64. package/dist/esm/hooks/windowMetricsListener.js +4 -4
  65. package/dist/esm/host/ChaynsHost.js +10 -5
  66. package/dist/esm/host/iframe/HostIframe.js +5 -2
  67. package/dist/esm/host/module/ModuleHost.js +4 -0
  68. package/dist/esm/types/IChaynsReact.js +19 -1
  69. package/dist/esm/util/deviceHelper.js +7 -6
  70. package/dist/esm/wrapper/AppWrapper.js +42 -6
  71. package/dist/esm/wrapper/FrameWrapper.js +52 -1
  72. package/dist/esm/wrapper/ModuleFederationWrapper.js +4 -0
  73. package/dist/types/calls/dialogs/alert.d.ts +1 -1
  74. package/dist/types/calls/dialogs/chaynsDialog.d.ts +24 -24
  75. package/dist/types/calls/dialogs/close.d.ts +1 -1
  76. package/dist/types/calls/dialogs/communication.d.ts +3 -3
  77. package/dist/types/calls/dialogs/confirm.d.ts +13 -13
  78. package/dist/types/calls/dialogs/date.d.ts +96 -96
  79. package/dist/types/calls/dialogs/dropUpAlert.d.ts +5 -5
  80. package/dist/types/calls/dialogs/fileSelect.d.ts +16 -16
  81. package/dist/types/calls/dialogs/iFrame.d.ts +10 -10
  82. package/dist/types/calls/dialogs/index.d.ts +14 -14
  83. package/dist/types/calls/dialogs/input.d.ts +15 -15
  84. package/dist/types/calls/dialogs/mediaSelect.d.ts +8 -8
  85. package/dist/types/calls/dialogs/open.d.ts +1 -1
  86. package/dist/types/calls/dialogs/select.d.ts +6 -6
  87. package/dist/types/calls/dialogs/signature.d.ts +7 -7
  88. package/dist/types/calls/dialogs/toast.d.ts +1 -1
  89. package/dist/types/calls/dialogs/utils/callback.d.ts +1 -1
  90. package/dist/types/calls/dialogs/utils/is.d.ts +4 -4
  91. package/dist/types/calls/getUserInfo.d.ts +9 -9
  92. package/dist/types/calls/index.d.ts +237 -233
  93. package/dist/types/calls/sendMessage.d.ts +13 -13
  94. package/dist/types/calls/visibilityChangeListener.d.ts +9 -9
  95. package/dist/types/components/AppDialogWrapper.d.ts +5 -0
  96. package/dist/types/components/ChaynsContext.d.ts +3 -3
  97. package/dist/types/components/ChaynsProvider.d.ts +14 -14
  98. package/dist/types/components/WaitUntil.d.ts +7 -8
  99. package/dist/types/components/withCompatMode.d.ts +13 -13
  100. package/dist/types/handler/DialogHandler.d.ts +19 -0
  101. package/dist/types/helper/apiListenerHelper.d.ts +6 -6
  102. package/dist/types/hooks/geoLocationListener.d.ts +18 -18
  103. package/dist/types/hooks/index.d.ts +17 -16
  104. package/dist/types/hooks/scrollListener.d.ts +28 -28
  105. package/dist/types/hooks/useAccessToken.d.ts +5 -5
  106. package/dist/types/hooks/useCurrentPage.d.ts +4 -4
  107. package/dist/types/hooks/useCustomData.d.ts +4 -4
  108. package/dist/types/hooks/useDevice.d.ts +5 -5
  109. package/dist/types/hooks/useDialogState.d.ts +9 -0
  110. package/dist/types/hooks/useEnvironment.d.ts +5 -5
  111. package/dist/types/hooks/useFunctions.d.ts +5 -5
  112. package/dist/types/hooks/useIsAdminMode.d.ts +4 -4
  113. package/dist/types/hooks/useLanguage.d.ts +5 -5
  114. package/dist/types/hooks/usePages.d.ts +18 -18
  115. package/dist/types/hooks/useParameters.d.ts +5 -5
  116. package/dist/types/hooks/useSite.d.ts +5 -5
  117. package/dist/types/hooks/useUser.d.ts +5 -5
  118. package/dist/types/hooks/useValues.d.ts +5 -5
  119. package/dist/types/hooks/windowMetricsListener.d.ts +11 -11
  120. package/dist/types/host/ChaynsHost.d.ts +30 -29
  121. package/dist/types/host/iframe/HostIframe.d.ts +26 -25
  122. package/dist/types/host/iframe/utils/useUpdateData.d.ts +3 -3
  123. package/dist/types/host/module/ModuleHost.d.ts +26 -25
  124. package/dist/types/host/module/utils/loadComponent.d.ts +1 -1
  125. package/dist/types/host/module/utils/useDynamicScript.d.ts +9 -9
  126. package/dist/types/index.d.ts +16 -16
  127. package/dist/types/types/IChaynsReact.d.ts +708 -624
  128. package/dist/types/types/dialog.d.ts +41 -41
  129. package/dist/types/util/appCall.d.ts +2 -2
  130. package/dist/types/util/deviceHelper.d.ts +7 -7
  131. package/dist/types/util/heightHelper.d.ts +1 -1
  132. package/dist/types/util/postIframeForm.d.ts +1 -1
  133. package/dist/types/util/url.d.ts +1 -1
  134. package/dist/types/wrapper/AppWrapper.d.ts +22 -18
  135. package/dist/types/wrapper/FrameWrapper.d.ts +15 -15
  136. package/dist/types/wrapper/ModuleFederationWrapper.d.ts +10 -10
  137. package/dist/types/wrapper/SsrWrapper.d.ts +11 -11
  138. package/package.json +75 -75
  139. package/tsconfig.json +56 -56
@@ -1,70 +1,70 @@
1
1
  import { moduleWrapper } from '../components/ChaynsProvider';
2
- /**
3
- * This adds a listener to determine your location.
4
- * @category Event listener
2
+ /**
3
+ * This adds a listener to determine your location.
4
+ * @category Event listener
5
5
  */
6
6
  export const addGeoLocationListener = function () {
7
7
  return moduleWrapper.current.functions.addGeoLocationListener(...arguments);
8
8
  };
9
- /**
10
- * Adds a listener for scroll event by user.
11
- * @category Event listener
9
+ /**
10
+ * Adds a listener for scroll event by user.
11
+ * @category Event listener
12
12
  */
13
13
  export const addScrollListener = function () {
14
14
  return moduleWrapper.current.functions.addScrollListener(...arguments);
15
15
  };
16
- /**
17
- * This method will be executed when the page gets displayed or hidden.
18
- * @category Event listener
16
+ /**
17
+ * This method will be executed when the page gets displayed or hidden.
18
+ * @category Event listener
19
19
  */
20
20
  export const addVisibilityChangeListener = function () {
21
21
  return moduleWrapper.current.functions.addVisibilityChangeListener(...arguments);
22
22
  };
23
- /**
24
- * This adds a listener to get the actual height of the page.
25
- * @category Event listener
23
+ /**
24
+ * This adds a listener to get the actual height of the page.
25
+ * @category Event listener
26
26
  */
27
27
  export const addWindowMetricsListener = function () {
28
28
  return moduleWrapper.current.functions.addWindowMetricsListener(...arguments);
29
- }; /**
30
- * Allows a custom callback function to be defined
29
+ }; /**
30
+ * Allows a custom callback function to be defined
31
31
  */
32
32
  export const customCallbackFunction = function () {
33
33
  return moduleWrapper.current.functions.customCallbackFunction(...arguments);
34
34
  };
35
- /**
36
- * Get the accessToken from the user.
35
+ /**
36
+ * Get the accessToken from the user.
37
37
  */
38
38
  export const getAccessToken = function () {
39
39
  return moduleWrapper.current.functions.getAccessToken(...arguments);
40
40
  };
41
- /**
42
- * This method returns a list of installed share/social media apps.
41
+ /**
42
+ * This method returns a list of installed share/social media apps.
43
43
  */
44
44
  export const getAvailableSharingServices = function () {
45
45
  return moduleWrapper.current.functions.getAvailableSharingServices(...arguments);
46
46
  };
47
- /**
48
- * This method determines your location. If you want to track a route, use addGeoLocationListener.
47
+ /**
48
+ * This method determines your location. If you want to track a route, use addGeoLocationListener.
49
49
  */
50
50
  export const getGeoLocation = function () {
51
51
  return moduleWrapper.current.functions.getGeoLocation(...arguments);
52
52
  };
53
- /**
54
- * This method returns user information for a specific user.
55
- * @category User functions
53
+ /**
54
+ * This method returns user information for a specific user.
55
+ * @category User functions
56
56
  */
57
57
  export const getUserInfo = function () {
58
58
  return moduleWrapper.current.functions.getUserInfo(...arguments);
59
59
  };
60
- /**
61
- * Return the current scroll position of the top frame
60
+ /**
61
+ * Return the current scroll position of the top frame
62
62
  */
63
63
  export const getScrollPosition = function () {
64
64
  return moduleWrapper.current.functions.getScrollPosition(...arguments);
65
65
  };
66
- /**
67
- * Returns the window metrics.
66
+ /**
67
+ * Returns the window metrics.
68
68
  */
69
69
  export const getWindowMetrics = function () {
70
70
  return moduleWrapper.current.functions.getWindowMetrics(...arguments);
@@ -77,199 +77,205 @@ export const invokeCall = function () {
77
77
  export const invokeDialogCall = function () {
78
78
  return moduleWrapper.current.functions.invokeDialogCall(...arguments);
79
79
  };
80
- /**
81
- * This method will show a login dialog where the user has the opportunity to log in.
80
+ /**
81
+ * This method will show a login dialog where the user has the opportunity to log in.
82
82
  */
83
83
  export const login = function () {
84
84
  return moduleWrapper.current.functions.login(...arguments);
85
85
  };
86
- /**
87
- * This method will logout the user
86
+ /**
87
+ * This method will logout the user
88
88
  */
89
89
  export const logout = function () {
90
90
  return moduleWrapper.current.functions.logout(...arguments);
91
91
  };
92
- /**
93
- * This function navigates you to the previous site.
92
+ /**
93
+ * This function navigates you to the previous site.
94
94
  */
95
95
  export const navigateBack = function () {
96
96
  return moduleWrapper.current.functions.navigateBack(...arguments);
97
97
  };
98
- /**
99
- * The images specified in the url array is shown in gallery mode.
98
+ /**
99
+ * The images specified in the url array is shown in gallery mode.
100
100
  */
101
101
  export const openImage = function () {
102
102
  return moduleWrapper.current.functions.openImage(...arguments);
103
103
  };
104
- /**
105
- * Opens an URL in the chayns environment.
104
+ /**
105
+ * Opens an URL in the chayns environment.
106
106
  */
107
107
  export const openUrl = function () {
108
108
  return moduleWrapper.current.functions.openUrl(...arguments);
109
109
  };
110
- /**
111
- * The video specified in the URL is shown in video mode.
110
+ /**
111
+ * The video specified in the URL is shown in video mode.
112
112
  */
113
113
  export const openVideo = function () {
114
114
  return moduleWrapper.current.functions.openVideo(...arguments);
115
115
  };
116
- /**
117
- * Refresh badge count in navigation, user information and pages
116
+ /**
117
+ * Refresh badge count in navigation, user information and pages
118
118
  */
119
119
  export const refreshData = function () {
120
120
  return moduleWrapper.current.functions.refreshData(...arguments);
121
121
  };
122
- /**
123
- * Refresh accesstoken, should only be used when user object changes, not when token is invalid
122
+ /**
123
+ * Refresh accesstoken, should only be used when user object changes, not when token is invalid
124
124
  */
125
125
  export const refreshAccessToken = function () {
126
126
  return moduleWrapper.current.functions.refreshAccessToken(...arguments);
127
127
  };
128
- /**
129
- * This removes a listener to determine your location.
130
- * @category Event listener
128
+ /**
129
+ * This removes a listener to determine your location.
130
+ * @category Event listener
131
131
  */
132
132
  export const removeGeoLocationListener = function () {
133
133
  return moduleWrapper.current.functions.removeGeoLocationListener(...arguments);
134
134
  };
135
- /**
136
- * Removes scroll listener.
137
- * @category Event listener
135
+ /**
136
+ * Removes scroll listener.
137
+ * @category Event listener
138
138
  */
139
139
  export const removeScrollListener = function () {
140
140
  return moduleWrapper.current.functions.removeScrollListener(...arguments);
141
141
  };
142
- /**
143
- * Removes visibility change listener.
144
- * @category Event listener
142
+ /**
143
+ * Removes visibility change listener.
144
+ * @category Event listener
145
145
  */
146
146
  export const removeVisibilityChangeListener = function () {
147
147
  return moduleWrapper.current.functions.removeVisibilityChangeListener(...arguments);
148
148
  };
149
- /**
150
- * Removes window metrics listener.
151
- * @category Event listener
149
+ /**
150
+ * Removes window metrics listener.
151
+ * @category Event listener
152
152
  */
153
153
  export const removeWindowMetricsListener = function () {
154
154
  return moduleWrapper.current.functions.removeWindowMetricsListener(...arguments);
155
155
  };
156
- /**
157
- * Select other page on chayns site.
156
+ /**
157
+ * Select other page on chayns site.
158
158
  */
159
159
  export const selectPage = function () {
160
160
  return moduleWrapper.current.functions.selectPage(...arguments);
161
161
  };
162
- /**
163
- * Scrolls by specific amount.
162
+ /**
163
+ * Scrolls by specific amount.
164
164
  */
165
165
  export const scrollByY = function () {
166
166
  return moduleWrapper.current.functions.scrollByY(...arguments);
167
167
  };
168
- /**
169
- * Scrolls to specific position.
168
+ /**
169
+ * Scrolls to specific position.
170
170
  */
171
171
  export const scrollToY = function () {
172
172
  return moduleWrapper.current.functions.scrollToY(...arguments);
173
173
  };
174
- /**
175
- * Sends intercom message to group.
174
+ /**
175
+ * Sends intercom message to group.
176
176
  */
177
177
  export const sendMessageToGroup = function () {
178
178
  return moduleWrapper.current.functions.sendMessageToGroup(...arguments);
179
179
  };
180
- /**
181
- * Sends intercom message to page.
180
+ /**
181
+ * Sends intercom message to page.
182
182
  */
183
183
  export const sendMessageToPage = function () {
184
184
  return moduleWrapper.current.functions.sendMessageToPage(...arguments);
185
185
  };
186
- /**
187
- * Sends intercom message to an user.
186
+ /**
187
+ * Sends intercom message to an user.
188
188
  */
189
189
  export const sendMessageToUser = function () {
190
190
  return moduleWrapper.current.functions.sendMessageToUser(...arguments);
191
191
  };
192
- /**
193
- * Switches admin mode, also toggles admin switch in top frame.
192
+ /**
193
+ * Switches admin mode, also toggles admin switch in top frame.
194
194
  */
195
195
  export const setAdminMode = function () {
196
196
  return moduleWrapper.current.functions.setAdminMode(...arguments);
197
197
  };
198
- /**
199
- * Sets the display timeout, only works in chayns App.
198
+ /**
199
+ * Sets the display timeout, only works in chayns App.
200
200
  */
201
201
  export const setDisplayTimeout = function () {
202
202
  return moduleWrapper.current.functions.setDisplayTimeout(...arguments);
203
203
  };
204
- /**
205
- * Enables or disables a button which floats over the page.
204
+ /**
205
+ * Enables or disables a button which floats over the page.
206
206
  */
207
207
  export const setFloatingButton = function () {
208
208
  return moduleWrapper.current.functions.setFloatingButton(...arguments);
209
209
  };
210
- /**
211
- * Sets the height of the page.
210
+ /**
211
+ * Sets the height of the page.
212
212
  */
213
213
  export const setHeight = function () {
214
214
  return moduleWrapper.current.functions.setHeight(...arguments);
215
215
  };
216
- /**
217
- * Enables or disables the ability to refresh a page
216
+ /**
217
+ * Enables or disables the ability to refresh a page
218
218
  */
219
219
  export const setRefreshScrollEnabled = function () {
220
220
  return moduleWrapper.current.functions.setRefreshScrollEnabled(...arguments);
221
221
  };
222
- /**
223
- * Scans a qr-code and returns the result
222
+ /**
223
+ * Scans a qr-code and returns the result
224
224
  */
225
225
  export const setScanQrCode = function () {
226
226
  return moduleWrapper.current.functions.setScanQrCode(...arguments);
227
227
  };
228
- /**
229
- * Temporarily change design settings in top frame
228
+ /**
229
+ * Temporarily change design settings in top frame
230
230
  */
231
231
  export const setTempDesignSettings = function () {
232
232
  return moduleWrapper.current.functions.setTempDesignSettings(...arguments);
233
233
  };
234
- /**
235
- * Shows or hide a waitcursor
234
+ /**
235
+ * Shows or hide a waitcursor
236
236
  */
237
237
  export const setWaitCursor = function () {
238
238
  return moduleWrapper.current.functions.setWaitCursor(...arguments);
239
239
  };
240
- /**
241
- * Retrieves the value that is assigned to the key from a storage outside the frame
240
+ /**
241
+ * Retrieves the value that is assigned to the key from a storage outside the frame
242
242
  */
243
243
  export const storageGetItem = function () {
244
244
  return moduleWrapper.current.functions.storageGetItem(...arguments);
245
245
  };
246
- /**
247
- * Removes the value that is assigned to the key from a storage outside the frame
246
+ /**
247
+ * Removes the value that is assigned to the key from a storage outside the frame
248
248
  */
249
249
  export const storageRemoveItem = function () {
250
250
  return moduleWrapper.current.functions.storageRemoveItem(...arguments);
251
251
  };
252
- /**
253
- * Sets the value that is assigned to the key from a storage outside the frame
252
+ /**
253
+ * Sets the value that is assigned to the key from a storage outside the frame
254
254
  */
255
255
  export const storageSetItem = function () {
256
256
  return moduleWrapper.current.functions.storageSetItem(...arguments);
257
257
  };
258
- /**
259
- * This method lets a smartphone vibrate for the given time.
258
+ /**
259
+ * This method lets a smartphone vibrate for the given time.
260
260
  */
261
261
  export const vibrate = function () {
262
262
  return moduleWrapper.current.functions.vibrate(...arguments);
263
263
  };
264
- /**
265
- * Displays an overlay
264
+ /**
265
+ * This method creates a dialog
266
+ */
267
+ export const createDialog = function () {
268
+ return moduleWrapper.current.functions.createDialog(...arguments);
269
+ };
270
+ /**
271
+ * Displays an overlay
266
272
  */
267
273
  export const setOverlay = function () {
268
274
  return moduleWrapper.current.functions.setOverlay(...arguments);
269
275
  };
270
- /**
271
- * Returns user information, only when user is logged in
272
- * @category User functions
276
+ /**
277
+ * Returns user information, only when user is logged in
278
+ * @category User functions
273
279
  */
274
280
  export const getUser = () => moduleWrapper.current.values.user;
275
281
  export const getSite = () => moduleWrapper.current.values.site;
@@ -1,6 +1,6 @@
1
1
  const INTERCOM_URL = 'https://sub54.tobit.com/rest/api';
2
- /**
3
- * @category Intercom functions
2
+ /**
3
+ * @category Intercom functions
4
4
  */
5
5
  export const sendMessageToUser = async (api, object, receiverUserId) => {
6
6
  var _api$values$user;
@@ -34,8 +34,8 @@ export const sendMessageToUser = async (api, object, receiverUserId) => {
34
34
  }
35
35
  });
36
36
  };
37
- /**
38
- * @category Intercom functions
37
+ /**
38
+ * @category Intercom functions
39
39
  */
40
40
  export const sendMessageToPage = async (api, object) => {
41
41
  var _api$values$user2;
@@ -66,8 +66,8 @@ export const sendMessageToPage = async (api, object) => {
66
66
  }
67
67
  });
68
68
  };
69
- /**
70
- * @category Intercom functions
69
+ /**
70
+ * @category Intercom functions
71
71
  */
72
72
  export const sendMessageToGroup = async (api, object, groupId) => {
73
73
  if (!object.text) {
@@ -96,8 +96,8 @@ export const sendMessageToGroup = async (api, object, groupId) => {
96
96
  }
97
97
  });
98
98
  };
99
- /**
100
- * @category Intercom functions
99
+ /**
100
+ * @category Intercom functions
101
101
  */
102
102
  function sendMessage(endpoint, token, body) {
103
103
  return fetch(`${INTERCOM_URL}${endpoint}`, {
@@ -6,8 +6,8 @@ const handleVisibilityChange = () => {
6
6
  });
7
7
  };
8
8
 
9
- /**
10
- * @category Event listener
9
+ /**
10
+ * @category Event listener
11
11
  */
12
12
  export const addVisibilityChangeListener = callback => {
13
13
  const {
@@ -19,8 +19,8 @@ export const addVisibilityChangeListener = callback => {
19
19
  }
20
20
  return id;
21
21
  };
22
- /**
23
- * @category Event listener
22
+ /**
23
+ * @category Event listener
24
24
  */
25
25
  export const removeVisibilityChangeListener = id => {
26
26
  const shouldRemove = removeApiListener(key, id);
@@ -0,0 +1,33 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ import React, { useEffect, useState } from 'react';
3
+ import ChaynsHost from '../host/ChaynsHost';
4
+ import { useFunctions, useValues } from '../hooks';
5
+ const AppDialogWrapper = _ref => {
6
+ let {
7
+ dialogEventTarget
8
+ } = _ref;
9
+ const functions = useFunctions();
10
+ const data = useValues();
11
+ const [dialogData, setDialogData] = useState({
12
+ dialogs: []
13
+ });
14
+ useEffect(() => {
15
+ dialogEventTarget.addEventListener('change', e => {
16
+ setDialogData({
17
+ dialogs: e.detail
18
+ });
19
+ });
20
+ }, []);
21
+ return /*#__PURE__*/React.createElement(ChaynsHost, _extends({
22
+ type: "client-module",
23
+ system: {
24
+ module: './AppWrapper',
25
+ url: 'https://tapp-staging.chayns-static.space/api/dialog-v2/v1/remoteEntry.js',
26
+ scope: 'dialog_v2'
27
+ }
28
+ }, data, {
29
+ functions: functions,
30
+ customData: dialogData
31
+ }));
32
+ };
33
+ export default AppDialogWrapper;
@@ -7,6 +7,7 @@ import { FrameWrapper } from '../wrapper/FrameWrapper';
7
7
  import { ModuleFederationWrapper } from '../wrapper/ModuleFederationWrapper';
8
8
  import { SsrWrapper } from '../wrapper/SsrWrapper';
9
9
  import { ChaynsContext, ChaynsFunctionsContext } from './ChaynsContext';
10
+ import AppDialogWrapper from "./AppDialogWrapper";
10
11
 
11
12
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
12
13
  export const moduleWrapper = {
@@ -30,7 +31,7 @@ const InitialDataProvider = /*#__PURE__*/React.memo(_ref => {
30
31
  });
31
32
  }, () => true);
32
33
  const ChaynsProvider = _ref2 => {
33
- var _customWrapper$curren, _customWrapper$curren2, _customWrapper$curren3;
34
+ var _customWrapper$curren, _customWrapper$curren2, _customWrapper$curren3, _customWrapper$curren4;
34
35
  let {
35
36
  children,
36
37
  data,
@@ -101,7 +102,9 @@ const ChaynsProvider = _ref2 => {
101
102
  value: state
102
103
  }, /*#__PURE__*/React.createElement(ChaynsFunctionsContext.Provider, {
103
104
  value: (_customWrapper$curren3 = customWrapper.current) === null || _customWrapper$curren3 === void 0 ? void 0 : _customWrapper$curren3.functions
104
- }, children)), /*#__PURE__*/React.createElement(InitialDataProvider, {
105
+ }, children, customWrapper.current instanceof AppWrapper ? /*#__PURE__*/React.createElement(AppDialogWrapper, {
106
+ dialogEventTarget: (_customWrapper$curren4 = customWrapper.current) === null || _customWrapper$curren4 === void 0 ? void 0 : _customWrapper$curren4.getDialogEventTarget()
107
+ }) : false)), /*#__PURE__*/React.createElement(InitialDataProvider, {
105
108
  data: state,
106
109
  renderedByServer: renderedByServer
107
110
  }));
@@ -0,0 +1,59 @@
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4
+ export default class DialogHandler {
5
+ constructor(config, open, close, dispatchEvent, addDataListener) {
6
+ _defineProperty(this, "isOpen", false);
7
+ _defineProperty(this, "result", undefined);
8
+ _defineProperty(this, "listeners", []);
9
+ this._open = open;
10
+ this._close = close;
11
+ this._config = config;
12
+ this._dispatchEvent = dispatchEvent;
13
+ this._addDataListener = addDataListener;
14
+ }
15
+ async open() {
16
+ if (this.isOpen) {
17
+ throw new Error('cannot open a dialog which is already open');
18
+ }
19
+ const res = await new Promise(async resolve => {
20
+ const callback = data => {
21
+ this.isOpen = false;
22
+ resolve(data);
23
+ };
24
+ this.isOpen = true;
25
+ this.dialogId = await this._open(this._config, callback);
26
+ console.log('dialogId', this.dialogId);
27
+ this._addDataListener(this.dialogId, data => {
28
+ console.log('[DialogHandler]dataListener', this.dialogId, data);
29
+ this.listeners.forEach(cb => cb(data));
30
+ });
31
+ });
32
+ return this.result = res;
33
+ }
34
+ close(buttonType, data) {
35
+ if (!this.isOpen) {
36
+ return;
37
+ }
38
+ this.isOpen = false;
39
+ this._close(this.dialogId, data);
40
+ }
41
+ dispatchEvent(data) {
42
+ if (!this.isOpen) {
43
+ return;
44
+ }
45
+ this._dispatchEvent(this.dialogId, data);
46
+ }
47
+ addDataListener(listener) {
48
+ this.listeners.push(listener);
49
+ }
50
+ removeDataListener(listener) {
51
+ const index = this.listeners.findIndex(l => l === listener);
52
+ if (index > -1) {
53
+ this.listeners.splice(index, 1);
54
+ }
55
+ }
56
+ getResult() {
57
+ return this.result;
58
+ }
59
+ }
@@ -1,8 +1,8 @@
1
1
  import { useContextSelector } from 'use-context-selector';
2
2
  import { useCallback, useEffect, useRef, useState } from 'react';
3
3
  import { ChaynsFunctionsContext } from '../components/ChaynsContext';
4
- /**
5
- * @category Hooks
4
+ /**
5
+ * @category Hooks
6
6
  */
7
7
  export const useGeoLocationListener = () => {
8
8
  const addListener = useContextSelector(ChaynsFunctionsContext, v => v.addGeoLocationListener);
@@ -17,8 +17,8 @@ export const useGeoLocationListener = () => {
17
17
  // eslint-disable-next-line react-hooks/exhaustive-deps
18
18
  }, []);
19
19
  };
20
- /**
21
- * @category Hooks
20
+ /**
21
+ * @category Hooks
22
22
  */
23
23
  export const useGeoLocation = function () {
24
24
  let {
@@ -13,4 +13,5 @@ export { useLanguage } from './useLanguage';
13
13
  export { useValues } from './useValues';
14
14
  export { useFunctions } from './useFunctions';
15
15
  export { useCurrentPage } from './useCurrentPage';
16
- export { useCustomData } from './useCustomData';
16
+ export { useCustomData } from './useCustomData';
17
+ export { useDialogState, useDialogData } from './useDialogState';
@@ -2,8 +2,8 @@ import { useContextSelector } from 'use-context-selector';
2
2
  import { useCallback, useEffect, useRef, useState } from 'react';
3
3
  import { ChaynsFunctionsContext } from '../components/ChaynsContext';
4
4
  import { useWindowMetrics } from './windowMetricsListener';
5
- /**
6
- * @category Hooks
5
+ /**
6
+ * @category Hooks
7
7
  */
8
8
  export const useScrollListener = () => {
9
9
  const addListener = useContextSelector(ChaynsFunctionsContext, v => v.addScrollListener);
@@ -18,8 +18,8 @@ export const useScrollListener = () => {
18
18
  // eslint-disable-next-line react-hooks/exhaustive-deps
19
19
  }, []);
20
20
  };
21
- /**
22
- * @category Hooks
21
+ /**
22
+ * @category Hooks
23
23
  */
24
24
  export const useScrollPosition = function () {
25
25
  let {
@@ -46,8 +46,8 @@ export const useScrollPosition = function () {
46
46
  }, [getScrollPosition]);
47
47
  return value;
48
48
  };
49
- /**
50
- * @category Hooks
49
+ /**
50
+ * @category Hooks
51
51
  */
52
52
  export const useScrollOffsetTop = function () {
53
53
  let {
@@ -69,8 +69,8 @@ export const useScrollOffsetTop = function () {
69
69
  }
70
70
  return 0;
71
71
  };
72
- /**
73
- * @category Hooks
72
+ /**
73
+ * @category Hooks
74
74
  */
75
75
  export const useScrollOffsetBottom = function () {
76
76
  let {
@@ -2,8 +2,8 @@ import { useEffect, useState } from "react";
2
2
  import { useContextSelector } from "use-context-selector";
3
3
  import { ChaynsFunctionsContext } from "../components/ChaynsContext";
4
4
 
5
- /**
6
- * @category Hooks
5
+ /**
6
+ * @category Hooks
7
7
  */
8
8
  export const useAccessToken = accessToken => {
9
9
  const [token, setToken] = useState(null);
@@ -1,7 +1,7 @@
1
1
  import { useContextSelector } from 'use-context-selector';
2
2
  import { ChaynsContext } from '../components/ChaynsContext';
3
3
 
4
- /**
5
- * @category Hooks
4
+ /**
5
+ * @category Hooks
6
6
  */
7
7
  export const useCurrentPage = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.currentPage);
@@ -1,7 +1,7 @@
1
1
  import { useContextSelector } from 'use-context-selector';
2
2
  import { ChaynsContext } from '../components/ChaynsContext';
3
3
 
4
- /**
5
- * @category Hooks
4
+ /**
5
+ * @category Hooks
6
6
  */
7
7
  export const useCustomData = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.customData);
@@ -1,6 +1,6 @@
1
1
  import { useContextSelector } from 'use-context-selector';
2
2
  import { ChaynsContext } from '../components/ChaynsContext';
3
- /**
4
- * @category Hooks
3
+ /**
4
+ * @category Hooks
5
5
  */
6
6
  export const useDevice = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.device);