chayns-api 1.0.1 → 1.0.3

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 (263) 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 -0
  5. package/LICENSE +21 -21
  6. package/README.md +47 -47
  7. package/dist/cjs/calls/dialogs/alert.js +0 -2
  8. package/dist/cjs/calls/dialogs/chaynsDialog.js +2 -8
  9. package/dist/cjs/calls/dialogs/close.js +0 -2
  10. package/dist/cjs/calls/dialogs/communication.js +1 -16
  11. package/dist/cjs/calls/dialogs/confirm.js +0 -4
  12. package/dist/cjs/calls/dialogs/date.js +46 -63
  13. package/dist/cjs/calls/dialogs/dropUpAlert.js +0 -3
  14. package/dist/cjs/calls/dialogs/fileSelect.js +0 -10
  15. package/dist/cjs/calls/dialogs/iFrame.js +0 -8
  16. package/dist/cjs/calls/dialogs/index.js +0 -27
  17. package/dist/cjs/calls/dialogs/input.js +0 -6
  18. package/dist/cjs/calls/dialogs/mediaSelect.js +0 -7
  19. package/dist/cjs/calls/dialogs/open.js +0 -2
  20. package/dist/cjs/calls/dialogs/select.js +0 -9
  21. package/dist/cjs/calls/dialogs/signature.js +0 -5
  22. package/dist/cjs/calls/dialogs/toast.js +0 -3
  23. package/dist/cjs/calls/dialogs/utils/callback.js +0 -2
  24. package/dist/cjs/calls/dialogs/utils/is.js +0 -4
  25. package/dist/cjs/calls/getUserInfo.js +0 -11
  26. package/dist/cjs/calls/index.js +95 -247
  27. package/dist/cjs/calls/sendMessage.js +8 -34
  28. package/dist/cjs/calls/visibilityChangeListener.js +5 -16
  29. package/dist/cjs/components/ChaynsContext.js +2 -4
  30. package/dist/cjs/components/ChaynsProvider.js +6 -28
  31. package/dist/cjs/components/WaitUntil.js +0 -5
  32. package/dist/cjs/components/withCompatMode.js +1 -16
  33. package/dist/cjs/helper/apiListenerHelper.js +0 -9
  34. package/dist/cjs/hooks/geoLocationListener.js +6 -15
  35. package/dist/cjs/hooks/index.js +6 -16
  36. package/dist/cjs/hooks/scrollListener.js +12 -31
  37. package/dist/cjs/hooks/useAccessToken.js +2 -7
  38. package/dist/cjs/hooks/useCurrentPage.js +2 -6
  39. package/dist/cjs/hooks/useCustomData.js +2 -6
  40. package/dist/cjs/hooks/useDevice.js +2 -6
  41. package/dist/cjs/hooks/useEnvironment.js +2 -6
  42. package/dist/cjs/hooks/useFunctions.js +2 -6
  43. package/dist/cjs/hooks/useIsAdminMode.js +2 -7
  44. package/dist/cjs/hooks/useLanguage.js +2 -6
  45. package/dist/cjs/hooks/usePages.js +26 -18
  46. package/dist/cjs/hooks/useParameters.js +2 -6
  47. package/dist/cjs/hooks/useSite.js +2 -6
  48. package/dist/cjs/hooks/useUser.js +2 -7
  49. package/dist/cjs/hooks/useValues.js +2 -6
  50. package/dist/cjs/hooks/windowMetricsListener.js +6 -16
  51. package/dist/cjs/host/ChaynsHost.js +0 -10
  52. package/dist/cjs/host/iframe/HostIframe.js +23 -30
  53. package/dist/cjs/host/iframe/utils/useUpdateData.js +0 -3
  54. package/dist/cjs/host/module/ModuleHost.js +3 -13
  55. package/dist/cjs/host/module/utils/loadComponent.js +1 -18
  56. package/dist/cjs/host/module/utils/useDynamicScript.js +0 -18
  57. package/dist/cjs/index.js +0 -19
  58. package/dist/cjs/types/IChaynsReact.js +27 -48
  59. package/dist/cjs/util/appCall.js +1 -4
  60. package/dist/cjs/util/deviceHelper.js +5 -22
  61. package/dist/cjs/util/heightHelper.js +0 -9
  62. package/dist/cjs/util/postIframeForm.js +0 -5
  63. package/dist/cjs/wrapper/AppWrapper.js +323 -159
  64. package/dist/cjs/wrapper/FrameWrapper.js +219 -248
  65. package/dist/cjs/wrapper/ModuleFederationWrapper.js +2 -27
  66. package/dist/cjs/wrapper/SsrWrapper.js +0 -8
  67. package/dist/esm/calls/dialogs/alert.js +4 -4
  68. package/dist/esm/calls/dialogs/chaynsDialog.js +7 -11
  69. package/dist/esm/calls/dialogs/communication.js +15 -26
  70. package/dist/esm/calls/dialogs/confirm.js +5 -8
  71. package/dist/esm/calls/dialogs/date.js +119 -128
  72. package/dist/esm/calls/dialogs/dropUpAlert.js +1 -1
  73. package/dist/esm/calls/dialogs/fileSelect.js +23 -62
  74. package/dist/esm/calls/dialogs/iFrame.js +7 -10
  75. package/dist/esm/calls/dialogs/input.js +2 -5
  76. package/dist/esm/calls/dialogs/mediaSelect.js +18 -55
  77. package/dist/esm/calls/dialogs/open.js +2 -2
  78. package/dist/esm/calls/dialogs/select.js +5 -9
  79. package/dist/esm/calls/dialogs/signature.js +0 -2
  80. package/dist/esm/calls/dialogs/toast.js +6 -11
  81. package/dist/esm/calls/dialogs/utils/callback.js +3 -5
  82. package/dist/esm/calls/dialogs/utils/is.js +1 -3
  83. package/dist/esm/calls/getUserInfo.js +32 -92
  84. package/dist/esm/calls/index.js +297 -449
  85. package/dist/esm/calls/sendMessage.js +99 -229
  86. package/dist/esm/calls/visibilityChangeListener.js +14 -19
  87. package/dist/esm/components/ChaynsContext.js +3 -3
  88. package/dist/esm/components/ChaynsProvider.js +45 -86
  89. package/dist/esm/components/WaitUntil.js +21 -86
  90. package/dist/esm/components/withCompatMode.js +35 -77
  91. package/dist/esm/helper/apiListenerHelper.js +10 -15
  92. package/dist/esm/hooks/geoLocationListener.js +24 -50
  93. package/dist/esm/hooks/index.js +1 -1
  94. package/dist/esm/hooks/scrollListener.js +58 -94
  95. package/dist/esm/hooks/useAccessToken.js +8 -30
  96. package/dist/esm/hooks/useCurrentPage.js +4 -8
  97. package/dist/esm/hooks/useCustomData.js +4 -8
  98. package/dist/esm/hooks/useDevice.js +3 -8
  99. package/dist/esm/hooks/useEnvironment.js +3 -8
  100. package/dist/esm/hooks/useFunctions.js +4 -7
  101. package/dist/esm/hooks/useIsAdminMode.js +4 -8
  102. package/dist/esm/hooks/useLanguage.js +3 -8
  103. package/dist/esm/hooks/usePages.js +38 -31
  104. package/dist/esm/hooks/useParameters.js +3 -8
  105. package/dist/esm/hooks/useSite.js +3 -8
  106. package/dist/esm/hooks/useUser.js +3 -9
  107. package/dist/esm/hooks/useValues.js +4 -7
  108. package/dist/esm/hooks/windowMetricsListener.js +22 -48
  109. package/dist/esm/host/ChaynsHost.js +22 -29
  110. package/dist/esm/host/iframe/HostIframe.js +86 -142
  111. package/dist/esm/host/iframe/utils/useUpdateData.js +4 -6
  112. package/dist/esm/host/module/ModuleHost.js +42 -49
  113. package/dist/esm/host/module/utils/loadComponent.js +47 -85
  114. package/dist/esm/host/module/utils/useDynamicScript.js +27 -74
  115. package/dist/esm/types/IChaynsReact.js +37 -61
  116. package/dist/esm/util/appCall.js +2 -4
  117. package/dist/esm/util/deviceHelper.js +13 -37
  118. package/dist/esm/util/heightHelper.js +10 -13
  119. package/dist/esm/util/postIframeForm.js +25 -57
  120. package/dist/esm/wrapper/AppWrapper.js +385 -781
  121. package/dist/esm/wrapper/FrameWrapper.js +262 -1509
  122. package/dist/esm/wrapper/ModuleFederationWrapper.js +47 -284
  123. package/dist/esm/wrapper/SsrWrapper.js +19 -65
  124. package/dist/types/calls/dialogs/alert.d.ts +1 -1
  125. package/dist/types/calls/dialogs/chaynsDialog.d.ts +24 -24
  126. package/dist/types/calls/dialogs/close.d.ts +1 -1
  127. package/dist/types/calls/dialogs/communication.d.ts +3 -3
  128. package/dist/types/calls/dialogs/confirm.d.ts +13 -13
  129. package/dist/types/calls/dialogs/date.d.ts +96 -96
  130. package/dist/types/calls/dialogs/dropUpAlert.d.ts +5 -5
  131. package/dist/types/calls/dialogs/fileSelect.d.ts +16 -16
  132. package/dist/types/calls/dialogs/iFrame.d.ts +10 -10
  133. package/dist/types/calls/dialogs/index.d.ts +14 -14
  134. package/dist/types/calls/dialogs/input.d.ts +15 -15
  135. package/dist/types/calls/dialogs/mediaSelect.d.ts +8 -8
  136. package/dist/types/calls/dialogs/open.d.ts +1 -1
  137. package/dist/types/calls/dialogs/select.d.ts +6 -6
  138. package/dist/types/calls/dialogs/signature.d.ts +7 -7
  139. package/dist/types/calls/dialogs/toast.d.ts +1 -1
  140. package/dist/types/calls/dialogs/utils/callback.d.ts +1 -1
  141. package/dist/types/calls/dialogs/utils/is.d.ts +4 -4
  142. package/dist/types/calls/getUserInfo.d.ts +9 -9
  143. package/dist/types/calls/index.d.ts +225 -231
  144. package/dist/types/calls/sendMessage.d.ts +13 -13
  145. package/dist/types/calls/visibilityChangeListener.d.ts +9 -9
  146. package/dist/types/components/ChaynsContext.d.ts +3 -3
  147. package/dist/types/components/ChaynsProvider.d.ts +13 -13
  148. package/dist/types/components/WaitUntil.d.ts +7 -7
  149. package/dist/types/components/withCompatMode.d.ts +13 -13
  150. package/dist/types/helper/apiListenerHelper.d.ts +6 -6
  151. package/dist/types/hooks/geoLocationListener.d.ts +18 -18
  152. package/dist/types/hooks/index.d.ts +16 -16
  153. package/dist/types/hooks/scrollListener.d.ts +28 -28
  154. package/dist/types/hooks/useAccessToken.d.ts +5 -5
  155. package/dist/types/hooks/useCurrentPage.d.ts +4 -4
  156. package/dist/types/hooks/useCustomData.d.ts +4 -4
  157. package/dist/types/hooks/useDevice.d.ts +5 -5
  158. package/dist/types/hooks/useEnvironment.d.ts +5 -5
  159. package/dist/types/hooks/useFunctions.d.ts +5 -5
  160. package/dist/types/hooks/useIsAdminMode.d.ts +4 -4
  161. package/dist/types/hooks/useLanguage.d.ts +5 -5
  162. package/dist/types/hooks/usePages.d.ts +18 -14
  163. package/dist/types/hooks/useParameters.d.ts +5 -5
  164. package/dist/types/hooks/useSite.d.ts +5 -5
  165. package/dist/types/hooks/useUser.d.ts +5 -5
  166. package/dist/types/hooks/useValues.d.ts +5 -5
  167. package/dist/types/hooks/windowMetricsListener.d.ts +11 -11
  168. package/dist/types/host/ChaynsHost.d.ts +28 -28
  169. package/dist/types/host/iframe/HostIframe.d.ts +24 -24
  170. package/dist/types/host/iframe/utils/useUpdateData.d.ts +3 -3
  171. package/dist/types/host/module/ModuleHost.d.ts +23 -23
  172. package/dist/types/host/module/utils/loadComponent.d.ts +1 -1
  173. package/dist/types/host/module/utils/useDynamicScript.d.ts +9 -9
  174. package/dist/types/index.d.ts +16 -16
  175. package/dist/types/types/IChaynsReact.d.ts +622 -590
  176. package/dist/types/types/dialog.d.ts +41 -41
  177. package/dist/types/util/appCall.d.ts +2 -2
  178. package/dist/types/util/deviceHelper.d.ts +7 -7
  179. package/dist/types/util/heightHelper.d.ts +1 -1
  180. package/dist/types/util/postIframeForm.d.ts +1 -1
  181. package/dist/types/wrapper/AppWrapper.d.ts +18 -16
  182. package/dist/types/wrapper/FrameWrapper.d.ts +15 -15
  183. package/dist/types/wrapper/ModuleFederationWrapper.d.ts +10 -10
  184. package/dist/types/wrapper/SsrWrapper.d.ts +11 -11
  185. package/package.json +76 -76
  186. package/toolkit.config.js +52 -52
  187. package/tsconfig.json +56 -56
  188. package/dist/cjs/bootstrap.js +0 -11
  189. package/dist/cjs/calls/abstractApiListener.js +0 -40
  190. package/dist/cjs/calls/apiEventListener.js +0 -40
  191. package/dist/cjs/calls/setVisibilityChangeListener.js +0 -1
  192. package/dist/cjs/calls/windowMetricsListener.js +0 -18
  193. package/dist/cjs/client.js +0 -93
  194. package/dist/cjs/components/App.js +0 -32
  195. package/dist/cjs/components/App.spec.js +0 -16
  196. package/dist/cjs/components/Button.js +0 -32
  197. package/dist/cjs/components/ChaynsModuleProvider.js +0 -457
  198. package/dist/cjs/components/ChaynsProviderExposed.js +0 -16
  199. package/dist/cjs/components/TestProvider.js +0 -236
  200. package/dist/cjs/components/Title.js +0 -162
  201. package/dist/cjs/functions/addApiListener.js +0 -37
  202. package/dist/cjs/functions/addGeoLocationListener.js +0 -26
  203. package/dist/cjs/functions/addScrollListener.js +0 -26
  204. package/dist/cjs/functions/addWindowMetricsListener.js +0 -37
  205. package/dist/cjs/helper/cssLoader.js +0 -28
  206. package/dist/cjs/hooks/addGeoLocationListener.js +0 -26
  207. package/dist/cjs/hooks/addScrollListener.js +0 -26
  208. package/dist/cjs/hooks/addWindowMetricsListener.js +0 -37
  209. package/dist/cjs/hooks/geoLocation.js +0 -48
  210. package/dist/cjs/hooks/useAddGeoLocationListener.js +0 -26
  211. package/dist/cjs/hooks/useAddScrollListener.js +0 -48
  212. package/dist/cjs/hooks/useAddWindowMetricsListener.js +0 -45
  213. package/dist/cjs/hooks/useAdddScrollListener.js +0 -26
  214. package/dist/cjs/hooks/windowMetrics.js +0 -45
  215. package/dist/cjs/host/HostIframe.js +0 -157
  216. package/dist/cjs/host/ModuleHost.js +0 -11
  217. package/dist/cjs/host/module/utils.js +0 -25
  218. package/dist/cjs/index.example.js +0 -7
  219. package/dist/cjs/index2.js +0 -64
  220. package/dist/cjs/types/DynamicApiImport.d.js +0 -5
  221. package/dist/cjs/types/DynamicImport.d.js +0 -5
  222. package/dist/cjs/types/chayns-components.d.js +0 -1
  223. package/dist/cjs/types/chayns-logger.d.js +0 -1
  224. package/dist/cjs/types/chayns.d.js +0 -1
  225. package/dist/cjs/types/tobit-websocket-service-client.d.js +0 -1
  226. package/dist/cjs/types/toolkit-types.d.js +0 -1
  227. package/dist/cjs/util/useFunctionsContext.js +0 -16
  228. package/dist/cjs/util/useIsAdminMode.js +0 -18
  229. package/dist/cjs/util/useUser.js +0 -16
  230. package/dist/esm/bootstrap.js +0 -4
  231. package/dist/esm/client.js +0 -8
  232. package/dist/esm/components/App.js +0 -35
  233. package/dist/esm/components/App.spec.js +0 -9
  234. package/dist/esm/components/Button.js +0 -34
  235. package/dist/esm/components/ChaynsModuleProvider.js +0 -517
  236. package/dist/esm/components/ChaynsProviderExposed.js +0 -3
  237. package/dist/esm/components/TestProvider.js +0 -308
  238. package/dist/esm/components/Title.js +0 -210
  239. package/dist/esm/helper/cssLoader.js +0 -21
  240. package/dist/esm/hooks/useAddGeoLocationListener.js +0 -18
  241. package/dist/esm/hooks/useAddScrollListener.js +0 -18
  242. package/dist/esm/hooks/useAddWindowMetricsListener.js +0 -18
  243. package/dist/esm/host/HostIframe.js +0 -153
  244. package/dist/esm/index.example.js +0 -1
  245. package/dist/esm/index2.js +0 -5
  246. package/dist/esm/types/DynamicApiImport.d.js +0 -1
  247. package/dist/esm/types/DynamicImport.d.js +0 -1
  248. package/dist/esm/types/chayns-components.d.js +0 -0
  249. package/dist/esm/types/chayns-logger.d.js +0 -0
  250. package/dist/esm/types/chayns.d.js +0 -0
  251. package/dist/esm/types/tobit-websocket-service-client.d.js +0 -0
  252. package/dist/esm/types/toolkit-types.d.js +0 -0
  253. package/dist/esm/util/useIsAdminMode.js +0 -9
  254. package/dist/esm/util/useUser.js +0 -7
  255. package/dist/types/bootstrap.d.ts +0 -1
  256. package/dist/types/client.d.ts +0 -7
  257. package/dist/types/components/App.d.ts +0 -5
  258. package/dist/types/components/Button.d.ts +0 -8
  259. package/dist/types/components/ChaynsModuleProvider.d.ts +0 -170
  260. package/dist/types/components/ChaynsProviderExposed.d.ts +0 -13
  261. package/dist/types/components/Title.d.ts +0 -3
  262. package/dist/types/host/HostIframe.d.ts +0 -20
  263. package/dist/types/index.example.d.ts +0 -0
package/.babelrc CHANGED
@@ -1,30 +1,30 @@
1
- {
2
- "env": {
3
- "esm": {
4
- "presets": [
5
- [
6
- "@babel/preset-env",
7
- {
8
- "targets": ">0.5%, not dead, not op_mini all, chrome 71",
9
- "modules": false
10
- }
11
- ],
12
- "@babel/preset-react",
13
- "@babel/preset-typescript"
14
- ]
15
- },
16
- "cjs": {
17
- "presets": [
18
- [
19
- "@babel/preset-env",
20
- {
21
- "targets": { "node": 12 },
22
- "modules": "commonjs"
23
- }
24
- ],
25
- "@babel/preset-react",
26
- "@babel/preset-typescript"
27
- ]
28
- }
29
- }
30
- }
1
+ {
2
+ "env": {
3
+ "esm": {
4
+ "presets": [
5
+ [
6
+ "@babel/preset-env",
7
+ {
8
+ "targets": ">0.5%, not dead, not op_mini all, chrome 71",
9
+ "modules": false
10
+ }
11
+ ],
12
+ "@babel/preset-react",
13
+ "@babel/preset-typescript"
14
+ ]
15
+ },
16
+ "cjs": {
17
+ "presets": [
18
+ [
19
+ "@babel/preset-env",
20
+ {
21
+ "targets": { "node": 12 },
22
+ "modules": "commonjs"
23
+ }
24
+ ],
25
+ "@babel/preset-react",
26
+ "@babel/preset-typescript"
27
+ ]
28
+ }
29
+ }
30
+ }
package/.eslintrc CHANGED
@@ -1,17 +1,17 @@
1
- {
2
- "extends": "@chayns-toolkit",
3
- "rules": {
4
- "no-void": "off",
5
- "react/function-component-definition": [
6
- "error",
7
- {
8
- "namedComponents": "arrow-function",
9
- "unnamedComponents": "arrow-function"
10
- }
11
- ],
12
- "@typescript-eslint/require-await": "off",
13
- "@typescript-eslint/no-explicit-any": "off",
14
- "class-methods-use-this": "off",
15
- "react/jsx-props-no-spreading": "off"
16
- }
17
- }
1
+ {
2
+ "extends": "@chayns-toolkit",
3
+ "rules": {
4
+ "no-void": "off",
5
+ "react/function-component-definition": [
6
+ "error",
7
+ {
8
+ "namedComponents": "arrow-function",
9
+ "unnamedComponents": "arrow-function"
10
+ }
11
+ ],
12
+ "@typescript-eslint/require-await": "off",
13
+ "@typescript-eslint/no-explicit-any": "off",
14
+ "class-methods-use-this": "off",
15
+ "react/jsx-props-no-spreading": "off"
16
+ }
17
+ }
@@ -1,28 +1,28 @@
1
- name: Deploy Docs to GitHub Pages
2
-
3
- on:
4
- push:
5
- paths:
6
- - "website/**"
7
- workflow_dispatch:
8
-
9
- jobs:
10
- deploy:
11
- runs-on: ubuntu-20.04
12
- steps:
13
- - name: Checkout repo
14
- uses: actions/checkout@v2
15
-
16
- - name: Use Node 16
17
- uses: actions/setup-node@v1
18
- with:
19
- node-version: 16
20
-
21
- - name: Build
22
- run: npm run build-docs
23
-
24
- - name: Deploy to GitHub Pages
25
- uses: peaceiris/actions-gh-pages@v3
26
- with:
27
- github_token: ${{ secrets.GITHUB_TOKEN }}
28
- publish_dir: ./website/build
1
+ name: Deploy Docs to GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - "website/**"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ deploy:
11
+ runs-on: ubuntu-20.04
12
+ steps:
13
+ - name: Checkout repo
14
+ uses: actions/checkout@v2
15
+
16
+ - name: Use Node 16
17
+ uses: actions/setup-node@v1
18
+ with:
19
+ node-version: 16
20
+
21
+ - name: Build
22
+ run: npm run build-docs
23
+
24
+ - name: Deploy to GitHub Pages
25
+ uses: peaceiris/actions-gh-pages@v3
26
+ with:
27
+ github_token: ${{ secrets.GITHUB_TOKEN }}
28
+ publish_dir: ./website/build
@@ -0,0 +1,21 @@
1
+ name: Publish to NPM
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ tags:
7
+ - 'v*'
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - uses: actions/setup-node@v1
15
+ with:
16
+ node-version: '14.21.1'
17
+ registry-url: https://registry.npmjs.org/
18
+ - run: npm install
19
+ - run: npm publish
20
+ env:
21
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Tobit.Software
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Tobit.Software
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,47 +1,47 @@
1
- # [chayns react api](https://github.com/TobitSoftware/chayns-api) · [![license](https://img.shields.io/github/license/TobitSoftware/chayns-api.svg)]() [![GitHub pull requests](https://img.shields.io/github/issues-pr/TobitSoftware/chayns-api.svg)]() [![](https://img.shields.io/github/issues-pr-closed-raw/TobitSoftware/chayns-api.svg)]()
2
-
3
- The chayns-api provides information and useful functions to your page. The information and functions are provided by react hooks and normal functions.
4
- A list of all functions and hooks can be found [here](https://tobitsoftware.github.io/chayns-api/docs).
5
-
6
- ## Installation
7
-
8
- It is recommended to setup your new chayns page with the [create-chayns-app](https://github.com/TobitSoftware/create-chayns-app).
9
-
10
-
11
- ### Migrate old project
12
- 1. Install chayns-api package
13
- ```sh
14
- # NPM
15
- $ npm install chayns-api
16
-
17
- # Yarn
18
- $ yarn add chayns-api
19
- ```
20
-
21
- 2. Wrap your App component with the "ChaynsProvider" component. In all components which are under the ChaynsProvider you can use hooks and chayns functions.
22
- ```jsx
23
- <ChaynsProvider>
24
- <App/>
25
- </ChaynsProvider>
26
- ```
27
-
28
- ## Example
29
-
30
- ```jsx
31
- import { useUser } from 'chayns-api';
32
-
33
- const FirstName = () => {
34
- const user = useUser();
35
-
36
- return (
37
- <div>{user?.firstName}</div>
38
- );
39
- }
40
- ```
41
-
42
- ## Getting started
43
-
44
- More information to setup chayns-api can be found in the [documentation](https://tobitsoftware.github.io/chayns-api/docs).
45
-
46
-
47
- ## License
1
+ # [chayns react api](https://github.com/TobitSoftware/chayns-api) &middot; [![license](https://img.shields.io/github/license/TobitSoftware/chayns-api.svg)]() [![GitHub pull requests](https://img.shields.io/github/issues-pr/TobitSoftware/chayns-api.svg)]() [![](https://img.shields.io/github/issues-pr-closed-raw/TobitSoftware/chayns-api.svg)]()
2
+
3
+ The chayns-api provides information and useful functions to your page. The information and functions are provided by react hooks and normal functions.
4
+ A list of all functions and hooks can be found [here](https://tobitsoftware.github.io/chayns-api/docs).
5
+
6
+ ## Installation
7
+
8
+ It is recommended to setup your new chayns page with the [create-chayns-app](https://github.com/TobitSoftware/create-chayns-app).
9
+
10
+
11
+ ### Migrate old project
12
+ 1. Install chayns-api package
13
+ ```sh
14
+ # NPM
15
+ $ npm install chayns-api
16
+
17
+ # Yarn
18
+ $ yarn add chayns-api
19
+ ```
20
+
21
+ 2. Wrap your App component with the "ChaynsProvider" component. In all components which are under the ChaynsProvider you can use hooks and chayns functions.
22
+ ```jsx
23
+ <ChaynsProvider>
24
+ <App/>
25
+ </ChaynsProvider>
26
+ ```
27
+
28
+ ## Example
29
+
30
+ ```jsx
31
+ import { useUser } from 'chayns-api';
32
+
33
+ const FirstName = () => {
34
+ const user = useUser();
35
+
36
+ return (
37
+ <div>{user?.firstName}</div>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ## Getting started
43
+
44
+ More information to setup chayns-api can be found in the [documentation](https://tobitsoftware.github.io/chayns-api/docs).
45
+
46
+
47
+ ## License
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.alert = alert;
7
-
8
7
  var _chaynsDialog = require("./chaynsDialog");
9
-
10
8
  function alert(title = '', message = '') {
11
9
  return (0, _chaynsDialog.chaynsDialog)({
12
10
  'dialog': {
@@ -6,11 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.buttonType = exports.buttonText = void 0;
7
7
  exports.chaynsDialog = chaynsDialog;
8
8
  exports.dialogAction = void 0;
9
-
10
9
  var _open = require("./open");
11
-
12
10
  var _callback = require("./utils/callback");
13
-
14
11
  const buttonText = {
15
12
  'YES': {
16
13
  'de': 'Ja',
@@ -50,16 +47,13 @@ const dialogAction = {
50
47
  'IFRAME': 191
51
48
  };
52
49
  exports.dialogAction = dialogAction;
53
-
54
50
  function chaynsDialog(config) {
55
51
  const callbackName = 'chaynsDialog';
56
52
  config.callback = (0, _callback.getCallbackName)(callbackName);
57
-
58
53
  if (config.dialog) {
59
- config.dialog.callType = dialogAction.ALERT_CONFIRM; // @ts-ignore
60
-
54
+ config.dialog.callType = dialogAction.ALERT_CONFIRM;
55
+ // @ts-ignore
61
56
  return (0, _open.open)(config.dialog).then(data => Promise.resolve(data.selection ? data : data.buttonType));
62
57
  }
63
-
64
58
  return "unsupported";
65
59
  }
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.close = close;
7
-
8
7
  var _index = require("../index");
9
-
10
8
  function close() {
11
9
  return (0, _index.invokeDialogCall)({
12
10
  action: 113,
@@ -6,10 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.addDialogDataListener = addDialogDataListener;
7
7
  exports.removeDialogDataListener = removeDialogDataListener;
8
8
  exports.sendData = sendData;
9
-
10
9
  var _index = require("../index");
11
-
12
10
  // @ts-nocheck
11
+
13
12
  function sendData(data, isApiEvent) {
14
13
  return (0, _index.invokeDialogCall)({
15
14
  action: 218,
@@ -19,22 +18,17 @@ function sendData(data, isApiEvent) {
19
18
  }
20
19
  });
21
20
  }
22
-
23
21
  const listeners = [];
24
22
  const apiListeners = [];
25
-
26
23
  function _dialogDataListener(e = {}) {
27
24
  if (!e.data || !e.data.action && typeof e.data !== 'string') {
28
25
  return;
29
26
  }
30
-
31
27
  const messageObj = e.data.action ? e.data : JSON.parse(e.data.match(/(\{(?:.*)\})/)[0]);
32
-
33
28
  if (messageObj.action === 218) {
34
29
  const {
35
30
  data
36
31
  } = messageObj.value;
37
-
38
32
  if (messageObj.value.isApiEvent) {
39
33
  apiListeners.forEach(listener => {
40
34
  listener(data);
@@ -46,41 +40,32 @@ function _dialogDataListener(e = {}) {
46
40
  }
47
41
  }
48
42
  }
49
-
50
43
  function addDialogDataListener(callback, getApiEvents = false) {
51
44
  if (listeners.length === 0 || apiListeners.length === 0) {
52
45
  window.addEventListener('message', _dialogDataListener);
53
46
  }
54
-
55
47
  if (getApiEvents) {
56
48
  apiListeners.push(callback);
57
49
  } else {
58
50
  listeners.push(callback);
59
51
  }
60
-
61
52
  return true;
62
53
  }
63
-
64
54
  function removeDialogDataListener(callback, getApiEvents = false) {
65
55
  let index;
66
-
67
56
  if (getApiEvents) {
68
57
  index = apiListeners.indexOf(callback);
69
-
70
58
  if (index !== -1) {
71
59
  apiListeners.splice(index, 1);
72
60
  }
73
61
  } else {
74
62
  index = listeners.indexOf(callback);
75
-
76
63
  if (index !== -1) {
77
64
  listeners.splice(index, 1);
78
65
  }
79
66
  }
80
-
81
67
  if (listeners.length === 0 && apiListeners.length === 0) {
82
68
  window.removeEventListener('message', _dialogDataListener);
83
69
  }
84
-
85
70
  return index !== -1;
86
71
  }
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.confirm = confirm;
7
-
8
7
  var _chaynsDialog = require("./chaynsDialog");
9
-
10
8
  function confirm(title = '', message = '', config = {}) {
11
9
  // backward compatibility
12
10
  if (Array.isArray(config)) {
@@ -14,7 +12,6 @@ function confirm(title = '', message = '', config = {}) {
14
12
  'buttons': config
15
13
  };
16
14
  }
17
-
18
15
  if (!config.buttons || !Array.isArray(config.buttons)) {
19
16
  config.buttons = [{
20
17
  'text': _chaynsDialog.buttonText.YES,
@@ -24,7 +21,6 @@ function confirm(title = '', message = '', config = {}) {
24
21
  'buttonType': _chaynsDialog.buttonType.NEGATIVE
25
22
  }];
26
23
  }
27
-
28
24
  return (0, _chaynsDialog.chaynsDialog)({
29
25
  'dialog': {
30
26
  title,
@@ -6,38 +6,32 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.advancedDate = advancedDate;
7
7
  exports.date = date;
8
8
  exports.dateType = void 0;
9
-
10
9
  var _chaynsDialog = require("./chaynsDialog");
11
-
12
10
  var _is = require("./utils/is");
13
-
14
11
  var _open = require("./open");
15
-
16
12
  var _index = require("../index");
17
-
18
13
  function date(config = {}) {
19
14
  let {
20
- preSelect,
21
- minDate,
22
- maxDate,
23
- title,
24
- message,
25
- minuteInterval,
26
- autoSelectDate
27
- } = config,
28
- type = config.dateType || dateType.DATE; // This will fix the iOS problem with not preselectedDate without user interaction. That it return the wrog time.
29
-
15
+ preSelect,
16
+ minDate,
17
+ maxDate,
18
+ title,
19
+ message,
20
+ minuteInterval,
21
+ autoSelectDate
22
+ } = config,
23
+ type = config.dateType || dateType.DATE;
24
+
25
+ // This will fix the iOS problem with not preselectedDate without user interaction. That it return the wrog time.
30
26
  const {
31
27
  os,
32
28
  app
33
29
  } = (0, _index.getDevice)();
34
-
35
30
  if (minuteInterval && minuteInterval > 1 && os === 'iOS' && app) {
36
31
  preSelect = roundInterval(preSelect, minuteInterval);
37
32
  } else {
38
33
  preSelect = validateValue(preSelect);
39
34
  }
40
-
41
35
  minDate = validateValue(minDate);
42
36
  maxDate = validateValue(maxDate);
43
37
  let buttons = [];
@@ -61,31 +55,30 @@ function date(config = {}) {
61
55
  return Promise.resolve(data.selectedDate);
62
56
  });
63
57
  }
64
-
65
58
  function advancedDate(config = {}) {
66
59
  let {
67
- preSelect,
68
- minDate,
69
- maxDate,
70
- title,
71
- message,
72
- minuteInterval,
73
- buttons,
74
- multiselect,
75
- disabledDates,
76
- textBlocks,
77
- monthSelect,
78
- yearSelect,
79
- interval,
80
- maxInterval,
81
- minInterval,
82
- disabledIntervals,
83
- disabledWeekDayIntervals,
84
- getLocalTime,
85
- autoSelectDate
86
- } = config,
87
- // minInterval and maxInterval in minutes
88
- type = config.dateType || dateType.DATE;
60
+ preSelect,
61
+ minDate,
62
+ maxDate,
63
+ title,
64
+ message,
65
+ minuteInterval,
66
+ buttons,
67
+ multiselect,
68
+ disabledDates,
69
+ textBlocks,
70
+ monthSelect,
71
+ yearSelect,
72
+ interval,
73
+ maxInterval,
74
+ minInterval,
75
+ disabledIntervals,
76
+ disabledWeekDayIntervals,
77
+ getLocalTime,
78
+ autoSelectDate
79
+ } = config,
80
+ // minInterval and maxInterval in minutes
81
+ type = config.dateType || dateType.DATE;
89
82
  minDate = validateValue(minDate);
90
83
  maxDate = validateValue(maxDate);
91
84
  const {
@@ -93,7 +86,6 @@ function advancedDate(config = {}) {
93
86
  app
94
87
  } = (0, _index.getDevice)();
95
88
  if (!preSelect) preSelect = {};
96
-
97
89
  if (Array.isArray(preSelect)) {
98
90
  preSelect = preSelect.map(p => validateValue(p));
99
91
  } else if ((0, _is.isObject)(preSelect)) {
@@ -113,18 +105,15 @@ function advancedDate(config = {}) {
113
105
  preSelect = validateValue(preSelect);
114
106
  }
115
107
  }
116
-
117
108
  if (Array.isArray(disabledDates)) {
118
109
  disabledDates = disabledDates.map(d => validateValue(d));
119
110
  }
120
-
121
111
  if (!buttons || !Array.isArray(buttons)) {
122
112
  buttons = [{
123
113
  'text': _chaynsDialog.buttonText.OK,
124
114
  'buttonType': _chaynsDialog.buttonType.POSITIVE
125
115
  }];
126
116
  }
127
-
128
117
  return (0, _open.open)({
129
118
  'callType': _chaynsDialog.dialogAction.ADVANCED_DATE,
130
119
  type,
@@ -152,41 +141,36 @@ function advancedDate(config = {}) {
152
141
  return Promise.resolve(data);
153
142
  });
154
143
  }
155
- /**
156
- * @typedef {number} dateDialogType
157
- */
158
144
 
159
- /**
160
- * Enum for date dialog
161
- * <div>DATE will open a dialog where you can select a special day</div>
162
- * <div>TIME will open a dialog where you can only select a special time</div>
163
- * <div>DATE_TIME will open a dialog where you can select a special time on a special day</div>
164
- * @readonly
165
- * @enum {dateDialogType}
166
- * @type {{DATE: number, TIME: number, DATE_TIME: number}}
145
+ /**
146
+ * @typedef {number} dateDialogType
167
147
  */
168
148
 
169
-
149
+ /**
150
+ * Enum for date dialog
151
+ * <div>DATE will open a dialog where you can select a special day</div>
152
+ * <div>TIME will open a dialog where you can only select a special time</div>
153
+ * <div>DATE_TIME will open a dialog where you can select a special time on a special day</div>
154
+ * @readonly
155
+ * @enum {dateDialogType}
156
+ * @type {{DATE: number, TIME: number, DATE_TIME: number}}
157
+ */
170
158
  const dateType = {
171
159
  'DATE': 1,
172
160
  'TIME': 2,
173
161
  'DATE_TIME': 3
174
162
  };
175
163
  exports.dateType = dateType;
176
-
177
164
  function validateValue(value) {
178
165
  if (!(0, _is.isNumber)(value)) {
179
166
  if ((0, _is.isDate)(value)) {
180
167
  // TODO: Find out whats the purpose of parsing to int
181
168
  return parseInt(value.getTime() / 1000 + "", 10);
182
169
  }
183
-
184
170
  return undefined;
185
171
  }
186
-
187
172
  return value;
188
173
  }
189
-
190
174
  function roundInterval(preDate = new Date(), interval) {
191
175
  if (!(0, _is.isDate)(preDate)) {
192
176
  if ((0, _is.isNumber)(preDate)) {
@@ -195,10 +179,9 @@ function roundInterval(preDate = new Date(), interval) {
195
179
  return -1;
196
180
  }
197
181
  }
198
-
199
182
  let minutes = preDate.getMinutes();
200
183
  preDate.setMinutes(minutes - minutes % interval);
201
- preDate.setSeconds(0); // TODO: Why?
202
-
184
+ preDate.setSeconds(0);
185
+ // TODO: Why?
203
186
  return parseInt(preDate.getTime() / 1000 + "", 10);
204
187
  }
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.dropUpAlert = dropUpAlert;
7
-
8
7
  var _open = require("./open");
9
-
10
8
  var _chaynsDialog = require("./chaynsDialog");
11
-
12
9
  function dropUpAlert(dialog = {}) {
13
10
  dialog.callType = _chaynsDialog.dialogAction.DROP_UP_ALERT;
14
11
  return (0, _open.open)(dialog);