chayns-api 1.0.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.
- package/dist/cjs/calls/dialogs/alert.js +0 -2
- package/dist/cjs/calls/dialogs/chaynsDialog.js +2 -8
- package/dist/cjs/calls/dialogs/close.js +0 -2
- package/dist/cjs/calls/dialogs/communication.js +1 -16
- package/dist/cjs/calls/dialogs/confirm.js +0 -4
- package/dist/cjs/calls/dialogs/date.js +36 -53
- package/dist/cjs/calls/dialogs/dropUpAlert.js +0 -3
- package/dist/cjs/calls/dialogs/fileSelect.js +0 -10
- package/dist/cjs/calls/dialogs/iFrame.js +0 -8
- package/dist/cjs/calls/dialogs/index.js +0 -27
- package/dist/cjs/calls/dialogs/input.js +0 -6
- package/dist/cjs/calls/dialogs/mediaSelect.js +0 -7
- package/dist/cjs/calls/dialogs/open.js +0 -2
- package/dist/cjs/calls/dialogs/select.js +0 -9
- package/dist/cjs/calls/dialogs/signature.js +0 -5
- package/dist/cjs/calls/dialogs/toast.js +0 -3
- package/dist/cjs/calls/dialogs/utils/callback.js +0 -2
- package/dist/cjs/calls/dialogs/utils/environment.js +10 -0
- package/dist/cjs/calls/dialogs/utils/is.js +0 -4
- package/dist/cjs/calls/getUserInfo.js +0 -11
- package/dist/cjs/calls/index.js +3 -155
- package/dist/cjs/calls/sendMessage.js +0 -26
- package/dist/cjs/calls/visibilityChangeListener.js +1 -12
- package/dist/cjs/components/ChaynsContext.js +2 -4
- package/dist/cjs/components/ChaynsProvider.js +6 -28
- package/dist/cjs/components/WaitUntil.js +0 -5
- package/dist/cjs/components/withCompatMode.js +1 -16
- package/dist/cjs/helper/apiListenerHelper.js +0 -9
- package/dist/cjs/hooks/geoLocationListener.js +2 -11
- package/dist/cjs/hooks/index.js +6 -16
- package/dist/cjs/hooks/scrollListener.js +4 -23
- package/dist/cjs/hooks/useAccessToken.js +0 -5
- package/dist/cjs/hooks/useCurrentPage.js +0 -4
- package/dist/cjs/hooks/useCustomData.js +0 -4
- package/dist/cjs/hooks/useDevice.js +0 -4
- package/dist/cjs/hooks/useEnvironment.js +0 -4
- package/dist/cjs/hooks/useFunctions.js +0 -4
- package/dist/cjs/hooks/useIsAdminMode.js +0 -5
- package/dist/cjs/hooks/useLanguage.js +0 -4
- package/dist/cjs/hooks/usePages.js +22 -14
- package/dist/cjs/hooks/useParameters.js +0 -4
- package/dist/cjs/hooks/useSite.js +0 -4
- package/dist/cjs/hooks/useUser.js +0 -5
- package/dist/cjs/hooks/useValues.js +0 -4
- package/dist/cjs/hooks/windowMetricsListener.js +2 -12
- package/dist/cjs/host/ChaynsHost.js +0 -10
- package/dist/cjs/host/iframe/HostIframe.js +23 -30
- package/dist/cjs/host/iframe/utils/useUpdateData.js +0 -3
- package/dist/cjs/host/module/ModuleHost.js +3 -13
- package/dist/cjs/host/{HostIframe.js → module/PagemakerFrame.js} +23 -75
- package/dist/cjs/host/module/utils/loadComponent.js +1 -18
- package/dist/cjs/host/module/utils/useDynamicScript.js +0 -18
- package/dist/cjs/index.js +0 -19
- package/dist/cjs/types/IChaynsReact.js +27 -48
- package/dist/cjs/util/appCall.js +1 -4
- package/dist/cjs/util/deviceHelper.js +4 -21
- package/dist/cjs/util/heightHelper.js +0 -9
- package/dist/cjs/util/postIframeForm.js +0 -5
- package/dist/cjs/wrapper/AppWrapper.js +318 -159
- package/dist/cjs/wrapper/FrameWrapper.js +215 -248
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +2 -27
- package/dist/cjs/wrapper/SsrWrapper.js +0 -8
- package/dist/esm/calls/dialogs/alert.js +4 -4
- package/dist/esm/calls/dialogs/chaynsDialog.js +7 -11
- package/dist/esm/calls/dialogs/communication.js +15 -26
- package/dist/esm/calls/dialogs/confirm.js +5 -8
- package/dist/esm/calls/dialogs/date.js +85 -94
- package/dist/esm/calls/dialogs/dropUpAlert.js +1 -1
- package/dist/esm/calls/dialogs/fileSelect.js +23 -62
- package/dist/esm/calls/dialogs/iFrame.js +7 -10
- package/dist/esm/calls/dialogs/input.js +2 -5
- package/dist/esm/calls/dialogs/mediaSelect.js +18 -55
- package/dist/esm/calls/dialogs/open.js +2 -2
- package/dist/esm/calls/dialogs/select.js +5 -9
- package/dist/esm/calls/dialogs/signature.js +0 -2
- package/dist/esm/calls/dialogs/toast.js +6 -11
- package/dist/esm/calls/dialogs/utils/callback.js +3 -5
- package/dist/esm/calls/dialogs/utils/environment.js +3 -0
- package/dist/esm/calls/dialogs/utils/is.js +1 -3
- package/dist/esm/calls/getUserInfo.js +32 -92
- package/dist/esm/calls/index.js +124 -276
- package/dist/esm/calls/sendMessage.js +91 -221
- package/dist/esm/calls/visibilityChangeListener.js +10 -15
- package/dist/esm/components/ChaynsContext.js +3 -3
- package/dist/esm/components/ChaynsProvider.js +45 -86
- package/dist/esm/components/WaitUntil.js +21 -86
- package/dist/esm/components/withCompatMode.js +35 -77
- package/dist/esm/helper/apiListenerHelper.js +10 -15
- package/dist/esm/hooks/geoLocationListener.js +20 -46
- package/dist/esm/hooks/index.js +1 -1
- package/dist/esm/hooks/scrollListener.js +50 -86
- package/dist/esm/hooks/useAccessToken.js +6 -28
- package/dist/esm/hooks/useCurrentPage.js +2 -6
- package/dist/esm/hooks/useCustomData.js +2 -6
- package/dist/esm/hooks/useDevice.js +1 -6
- package/dist/esm/hooks/useEnvironment.js +1 -6
- package/dist/esm/hooks/useFunctions.js +2 -5
- package/dist/esm/hooks/useIsAdminMode.js +2 -6
- package/dist/esm/hooks/useLanguage.js +1 -6
- package/dist/esm/hooks/usePages.js +34 -27
- package/dist/esm/hooks/useParameters.js +1 -6
- package/dist/esm/hooks/useSite.js +1 -6
- package/dist/esm/hooks/useUser.js +1 -7
- package/dist/esm/hooks/useValues.js +2 -5
- package/dist/esm/hooks/windowMetricsListener.js +18 -44
- package/dist/esm/host/ChaynsHost.js +22 -29
- package/dist/esm/host/iframe/HostIframe.js +86 -142
- package/dist/esm/host/iframe/utils/useUpdateData.js +4 -6
- package/dist/esm/host/module/ModuleHost.js +42 -49
- package/dist/esm/host/module/PagemakerFrame.js +97 -0
- package/dist/esm/host/module/utils/loadComponent.js +47 -85
- package/dist/esm/host/module/utils/useDynamicScript.js +27 -74
- package/dist/esm/types/IChaynsReact.js +37 -61
- package/dist/esm/util/appCall.js +2 -4
- package/dist/esm/util/deviceHelper.js +12 -36
- package/dist/esm/util/heightHelper.js +10 -13
- package/dist/esm/util/postIframeForm.js +25 -57
- package/dist/esm/wrapper/AppWrapper.js +380 -781
- package/dist/esm/wrapper/FrameWrapper.js +258 -1509
- package/dist/esm/wrapper/ModuleFederationWrapper.js +47 -284
- package/dist/esm/wrapper/SsrWrapper.js +19 -65
- package/dist/types/calls/dialogs/confirm.d.ts +1 -1
- package/dist/types/calls/dialogs/date.d.ts +4 -4
- package/dist/types/calls/dialogs/dropUpAlert.d.ts +1 -1
- package/dist/types/calls/dialogs/fileSelect.d.ts +1 -1
- package/dist/types/calls/dialogs/iFrame.d.ts +1 -1
- package/dist/types/calls/dialogs/input.d.ts +1 -1
- package/dist/types/calls/dialogs/mediaSelect.d.ts +1 -1
- package/dist/types/calls/dialogs/signature.d.ts +1 -1
- package/dist/types/calls/dialogs/utils/environment.d.ts +3 -0
- package/dist/types/calls/index.d.ts +0 -6
- package/dist/types/components/ChaynsProvider.d.ts +1 -1
- package/dist/types/components/WaitUntil.d.ts +1 -1
- package/dist/types/components/withCompatMode.d.ts +1 -1
- package/dist/types/hooks/index.d.ts +1 -1
- package/dist/types/hooks/useAccessToken.d.ts +1 -1
- package/dist/types/hooks/usePages.d.ts +4 -0
- package/dist/types/host/ChaynsHost.d.ts +1 -1
- package/dist/types/host/iframe/HostIframe.d.ts +1 -1
- package/dist/types/host/module/ModuleHost.d.ts +2 -2
- package/dist/types/host/{HostIframe.d.ts → module/PagemakerFrame.d.ts} +7 -5
- package/dist/types/types/IChaynsReact.d.ts +55 -24
- package/dist/types/util/deviceHelper.d.ts +2 -2
- package/dist/types/wrapper/AppWrapper.d.ts +6 -4
- package/package.json +1 -1
- package/dist/cjs/bootstrap.js +0 -11
- package/dist/cjs/calls/abstractApiListener.js +0 -40
- package/dist/cjs/calls/apiEventListener.js +0 -40
- package/dist/cjs/calls/setVisibilityChangeListener.js +0 -1
- package/dist/cjs/calls/windowMetricsListener.js +0 -18
- package/dist/cjs/components/App.js +0 -32
- package/dist/cjs/components/App.spec.js +0 -16
- package/dist/cjs/components/Button.js +0 -32
- package/dist/cjs/components/ChaynsProviderExposed.js +0 -16
- package/dist/cjs/components/TestProvider.js +0 -236
- package/dist/cjs/components/Title.js +0 -162
- package/dist/cjs/functions/addApiListener.js +0 -37
- package/dist/cjs/functions/addGeoLocationListener.js +0 -26
- package/dist/cjs/functions/addScrollListener.js +0 -26
- package/dist/cjs/functions/addWindowMetricsListener.js +0 -37
- package/dist/cjs/helper/cssLoader.js +0 -28
- package/dist/cjs/hooks/addGeoLocationListener.js +0 -26
- package/dist/cjs/hooks/addScrollListener.js +0 -26
- package/dist/cjs/hooks/addWindowMetricsListener.js +0 -37
- package/dist/cjs/hooks/geoLocation.js +0 -48
- package/dist/cjs/hooks/useAddGeoLocationListener.js +0 -26
- package/dist/cjs/hooks/useAddScrollListener.js +0 -48
- package/dist/cjs/hooks/useAddWindowMetricsListener.js +0 -45
- package/dist/cjs/hooks/useAdddScrollListener.js +0 -26
- package/dist/cjs/hooks/windowMetrics.js +0 -45
- package/dist/cjs/host/ModuleHost.js +0 -11
- package/dist/cjs/host/module/utils.js +0 -25
- package/dist/cjs/index.example.js +0 -7
- package/dist/cjs/index2.js +0 -64
- package/dist/cjs/types/DynamicImport.d.js +0 -5
- package/dist/cjs/types/chayns-components.d.js +0 -1
- package/dist/cjs/types/chayns-logger.d.js +0 -1
- package/dist/cjs/types/chayns.d.js +0 -1
- package/dist/cjs/types/tobit-websocket-service-client.d.js +0 -1
- package/dist/cjs/types/toolkit-types.d.js +0 -1
- package/dist/cjs/util/useFunctionsContext.js +0 -16
- package/dist/cjs/util/useIsAdminMode.js +0 -18
- package/dist/cjs/util/useUser.js +0 -16
- package/dist/esm/bootstrap.js +0 -4
- package/dist/esm/components/App.js +0 -35
- package/dist/esm/components/App.spec.js +0 -9
- package/dist/esm/components/Button.js +0 -34
- package/dist/esm/components/ChaynsProviderExposed.js +0 -3
- package/dist/esm/components/TestProvider.js +0 -308
- package/dist/esm/components/Title.js +0 -210
- package/dist/esm/helper/cssLoader.js +0 -21
- package/dist/esm/hooks/useAddGeoLocationListener.js +0 -18
- package/dist/esm/hooks/useAddScrollListener.js +0 -18
- package/dist/esm/hooks/useAddWindowMetricsListener.js +0 -18
- package/dist/esm/host/HostIframe.js +0 -153
- package/dist/esm/index.example.js +0 -1
- package/dist/esm/index2.js +0 -5
- package/dist/esm/types/DynamicImport.d.js +0 -1
- package/dist/esm/types/chayns-components.d.js +0 -0
- package/dist/esm/types/chayns-logger.d.js +0 -0
- package/dist/esm/types/chayns.d.js +0 -0
- package/dist/esm/types/tobit-websocket-service-client.d.js +0 -0
- package/dist/esm/types/toolkit-types.d.js +0 -0
- package/dist/esm/util/useIsAdminMode.js +0 -9
- package/dist/esm/util/useUser.js +0 -7
- package/dist/types/bootstrap.d.ts +0 -1
- package/dist/types/components/App.d.ts +0 -5
- package/dist/types/components/Button.d.ts +0 -8
- package/dist/types/components/ChaynsProviderExposed.d.ts +0 -13
- package/dist/types/components/Title.d.ts +0 -3
- package/dist/types/index.example.d.ts +0 -0
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || 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
|
-
|
|
3
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
-
|
|
5
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
-
|
|
7
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
-
|
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
10
|
-
|
|
11
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
|
|
13
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
|
-
|
|
15
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
-
|
|
17
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
|
-
|
|
19
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
20
|
-
|
|
21
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
22
|
-
|
|
23
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
24
|
-
|
|
25
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
26
|
-
import { useContextSelector } from 'use-context-selector';
|
|
27
|
-
import { useUser } from '../hooks/useUser';
|
|
28
|
-
import { useIsAdminMode } from '../hooks/useIsAdminMode';
|
|
29
|
-
import { useScrollOffsetBottom, useScrollOffsetTop, useScrollPosition } from '../hooks/scrollListener';
|
|
30
|
-
import { useWindowMetrics } from '../hooks/windowMetricsListener';
|
|
31
|
-
import { ChaynsContext, ChaynsFunctionsContext } from './ChaynsContext';
|
|
32
|
-
import ChaynsHost from '../host/ChaynsHost';
|
|
33
|
-
// import './title.scss';
|
|
34
|
-
import { addScrollListener, removeScrollListener } from '../index';
|
|
35
|
-
var FirstName = /*#__PURE__*/React.memo(function () {
|
|
36
|
-
var user = useUser();
|
|
37
|
-
console.debug('render first name', user);
|
|
38
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
39
|
-
className: "firstname"
|
|
40
|
-
}, "FirstName: ", user === null || user === void 0 ? void 0 : user.firstName);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
var Title = function Title() {
|
|
44
|
-
var _URLSearchParams$get;
|
|
45
|
-
|
|
46
|
-
var isAdminModeActive = useIsAdminMode();
|
|
47
|
-
var ref = useRef(null); // const addScrollListener = useScrollListener();
|
|
48
|
-
//const { value } = useGeoLocation({ timeout: 1000, enabled: true, silent: true });
|
|
49
|
-
|
|
50
|
-
var _useScrollPosition = useScrollPosition({
|
|
51
|
-
enabled: true,
|
|
52
|
-
throttle: 100
|
|
53
|
-
}),
|
|
54
|
-
scrollY = _useScrollPosition.scrollY; // const addGeoLocationListener = useGeoLocationListener();
|
|
55
|
-
// const addWindowMetricsListener = useWindowMetricsListener();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var offsetTop = useScrollOffsetTop();
|
|
59
|
-
var offsetBottom = useScrollOffsetBottom();
|
|
60
|
-
var values = useContextSelector(ChaynsContext, function (s) {
|
|
61
|
-
return s;
|
|
62
|
-
});
|
|
63
|
-
var functions = useContextSelector(ChaynsFunctionsContext, function (s) {
|
|
64
|
-
return s;
|
|
65
|
-
});
|
|
66
|
-
var login = useContextSelector(ChaynsFunctionsContext, function (s) {
|
|
67
|
-
return s.login;
|
|
68
|
-
});
|
|
69
|
-
var logout = useContextSelector(ChaynsFunctionsContext, function (s) {
|
|
70
|
-
return s.logout;
|
|
71
|
-
}); // const [windowMetrics, setWindowMetrics] = useState(null);
|
|
72
|
-
|
|
73
|
-
var windowMetrics = useWindowMetrics();
|
|
74
|
-
console.log('offsetTop', offsetTop, offsetBottom, windowMetrics);
|
|
75
|
-
|
|
76
|
-
var _useState = useState(10),
|
|
77
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
78
|
-
testHeight = _useState2[0],
|
|
79
|
-
setTestHeight = _useState2[1];
|
|
80
|
-
|
|
81
|
-
useEffect(function () {
|
|
82
|
-
var promise = addScrollListener({}, function (r) {
|
|
83
|
-
return console.log('add scroll', r);
|
|
84
|
-
});
|
|
85
|
-
return function () {
|
|
86
|
-
void (promise === null || promise === void 0 ? void 0 : promise.then(function (id) {
|
|
87
|
-
console.log('remove scroll', id);
|
|
88
|
-
return removeScrollListener(id);
|
|
89
|
-
}));
|
|
90
|
-
};
|
|
91
|
-
}, []); // useEffect(() => addScrollListener({ throttle: 200 }, (ev) => {
|
|
92
|
-
// console.log('scroll', ev)
|
|
93
|
-
// setWindowMetrics(ev.windowMetrics);
|
|
94
|
-
// }), [addScrollListener]);
|
|
95
|
-
//
|
|
96
|
-
// useEffect(() => addGeoLocationListener({ silent: true }, (ev) => {
|
|
97
|
-
// console.log('geo location', ev);
|
|
98
|
-
// }), [addGeoLocationListener])
|
|
99
|
-
//
|
|
100
|
-
// useEffect(() => addWindowMetricsListener((ev) => {
|
|
101
|
-
// console.log('window metrics', ev);
|
|
102
|
-
// setWindowMetrics(ev);
|
|
103
|
-
// }), [addWindowMetricsListener]);
|
|
104
|
-
// console.debug('render title', scrollPosition);
|
|
105
|
-
|
|
106
|
-
var src = useRef();
|
|
107
|
-
var depth = global.location ? Number.parseInt((_URLSearchParams$get = new URLSearchParams(window.location.search).get('depth')) !== null && _URLSearchParams$get !== void 0 ? _URLSearchParams$get : '1', 10) : 1;
|
|
108
|
-
|
|
109
|
-
if (!src.current) {
|
|
110
|
-
src.current = "https://w-hn-laptop.tobit.ag:8082?depth=".concat(depth + 1); // src.current = 'https://tapp01.tobit.com/Tapps/Chaynsnet/landingpage_2020/v4/index.html?isWidget=true';
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
var maxDepth = 2;
|
|
114
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
115
|
-
className: "chayns-api"
|
|
116
|
-
}, /*#__PURE__*/React.createElement(FirstName, null), /*#__PURE__*/React.createElement("button", {
|
|
117
|
-
id: "login-button",
|
|
118
|
-
type: "button",
|
|
119
|
-
onClick: function onClick() {
|
|
120
|
-
return login({
|
|
121
|
-
ignoreAuthenticated: false
|
|
122
|
-
}, function () {}, function () {});
|
|
123
|
-
}
|
|
124
|
-
}, "Login"), /*#__PURE__*/React.createElement("button", {
|
|
125
|
-
type: "button",
|
|
126
|
-
onClick: logout
|
|
127
|
-
}, "Logout"), /*#__PURE__*/React.createElement("div", null, "AdminMode active: ", isAdminModeActive ? 'true' : 'false'), depth < maxDepth && /*#__PURE__*/React.createElement(ChaynsHost, _extends({}, values, {
|
|
128
|
-
iFrameRef: ref,
|
|
129
|
-
src: src.current,
|
|
130
|
-
iFrameProps: {
|
|
131
|
-
name: "CustomPluginIframe".concat(depth),
|
|
132
|
-
style: {
|
|
133
|
-
border: 0,
|
|
134
|
-
width: '100%'
|
|
135
|
-
},
|
|
136
|
-
height: 1
|
|
137
|
-
},
|
|
138
|
-
functions: _objectSpread(_objectSpread({}, functions), {}, {
|
|
139
|
-
getWindowMetrics: function () {
|
|
140
|
-
var _getWindowMetrics = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
141
|
-
var v;
|
|
142
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
143
|
-
while (1) {
|
|
144
|
-
switch (_context.prev = _context.next) {
|
|
145
|
-
case 0:
|
|
146
|
-
_context.next = 2;
|
|
147
|
-
return functions.getWindowMetrics();
|
|
148
|
-
|
|
149
|
-
case 2:
|
|
150
|
-
v = _context.sent;
|
|
151
|
-
return _context.abrupt("return", _objectSpread(_objectSpread({}, v), {}, {
|
|
152
|
-
offsetTop: v.offsetTop + (ref.current ? ref.current.getBoundingClientRect().top : 0)
|
|
153
|
-
}));
|
|
154
|
-
|
|
155
|
-
case 4:
|
|
156
|
-
case "end":
|
|
157
|
-
return _context.stop();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}, _callee);
|
|
161
|
-
}));
|
|
162
|
-
|
|
163
|
-
function getWindowMetrics() {
|
|
164
|
-
return _getWindowMetrics.apply(this, arguments);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return getWindowMetrics;
|
|
168
|
-
}(),
|
|
169
|
-
addWindowMetricsListener: function addWindowMetricsListener(cb) {
|
|
170
|
-
return functions.addWindowMetricsListener(function (result) {
|
|
171
|
-
return cb(_objectSpread(_objectSpread({}, result), {}, {
|
|
172
|
-
offsetTop: result.offsetTop + (ref.current ? ref.current.getBoundingClientRect().top : 0)
|
|
173
|
-
}));
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}),
|
|
177
|
-
type: "client-iframe"
|
|
178
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
179
|
-
style: {
|
|
180
|
-
position: 'absolute',
|
|
181
|
-
top: offsetTop,
|
|
182
|
-
color: 'green',
|
|
183
|
-
backgroundColor: 'white'
|
|
184
|
-
}
|
|
185
|
-
}, "456"), /*#__PURE__*/React.createElement("div", {
|
|
186
|
-
style: {
|
|
187
|
-
position: 'absolute',
|
|
188
|
-
top: Math.min(offsetBottom, window.innerHeight) - 25,
|
|
189
|
-
right: 20,
|
|
190
|
-
color: 'red',
|
|
191
|
-
backgroundColor: 'white'
|
|
192
|
-
}
|
|
193
|
-
}, "123"), /*#__PURE__*/React.createElement("button", {
|
|
194
|
-
type: "button",
|
|
195
|
-
onClick: function onClick() {
|
|
196
|
-
return setTestHeight(testHeight + 100);
|
|
197
|
-
}
|
|
198
|
-
}, "Increase height"), /*#__PURE__*/React.createElement("div", {
|
|
199
|
-
className: "nice",
|
|
200
|
-
style: {
|
|
201
|
-
height: testHeight
|
|
202
|
-
}
|
|
203
|
-
}), /*#__PURE__*/React.createElement("button", {
|
|
204
|
-
onClick: function onClick() {
|
|
205
|
-
return setTestHeight(Math.max(0, testHeight - 100));
|
|
206
|
-
}
|
|
207
|
-
}, "Reduce height"));
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
export default /*#__PURE__*/React.memo(Title);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function loadCss() {
|
|
2
|
-
var apiUrl = 'https://api.chayns.net/css/';
|
|
3
|
-
var parameters = new URLSearchParams(window.location.search.toLowerCase());
|
|
4
|
-
document.documentElement.style.visibility = 'hidden';
|
|
5
|
-
document.documentElement.style.overflow = 'hidden';
|
|
6
|
-
var head = document.getElementsByTagName('HEAD')[0];
|
|
7
|
-
var link = document.createElement('link');
|
|
8
|
-
link.rel = 'stylesheet';
|
|
9
|
-
link.type = 'text/css';
|
|
10
|
-
link.href = apiUrl + (parameters.get('siteid') || "");
|
|
11
|
-
|
|
12
|
-
link.onload = function () {
|
|
13
|
-
document.documentElement.style.visibility = 'visible';
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
link.onerror = function () {
|
|
17
|
-
document.documentElement.style.visibility = 'visible';
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
head.appendChild(link);
|
|
21
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useContextSelector } from 'use-context-selector';
|
|
2
|
-
import { ChaynsFunctionsContext } from '../components/ChaynsContext';
|
|
3
|
-
import { useCallback } from 'react';
|
|
4
|
-
export var useAddGeoLocationListener = function useAddGeoLocationListener() {
|
|
5
|
-
var addGeoLocationListener = useContextSelector(ChaynsFunctionsContext, function (v) {
|
|
6
|
-
return v === null || v === void 0 ? void 0 : v.addGeoLocationListener;
|
|
7
|
-
});
|
|
8
|
-
var removeGeoLocationListener = useContextSelector(ChaynsFunctionsContext, function (v) {
|
|
9
|
-
return v === null || v === void 0 ? void 0 : v.removeGeoLocationListener;
|
|
10
|
-
});
|
|
11
|
-
var promise;
|
|
12
|
-
return useCallback(function (value, callback) {
|
|
13
|
-
promise = addGeoLocationListener(value, callback);
|
|
14
|
-
return function () {
|
|
15
|
-
promise.then(removeGeoLocationListener);
|
|
16
|
-
};
|
|
17
|
-
}, []);
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useContextSelector } from 'use-context-selector';
|
|
2
|
-
import { ChaynsFunctionsContext } from '../components/ChaynsContext';
|
|
3
|
-
import { useCallback } from 'react';
|
|
4
|
-
export var useAddScrollListener = function useAddScrollListener() {
|
|
5
|
-
var addScrollListener = useContextSelector(ChaynsFunctionsContext, function (v) {
|
|
6
|
-
return v === null || v === void 0 ? void 0 : v.addScrollListener;
|
|
7
|
-
});
|
|
8
|
-
var removeScrollListener = useContextSelector(ChaynsFunctionsContext, function (v) {
|
|
9
|
-
return v === null || v === void 0 ? void 0 : v.removeScrollListener;
|
|
10
|
-
});
|
|
11
|
-
var promise;
|
|
12
|
-
return useCallback(function (value, callback) {
|
|
13
|
-
promise = addScrollListener(value, callback);
|
|
14
|
-
return function () {
|
|
15
|
-
promise.then(removeScrollListener);
|
|
16
|
-
};
|
|
17
|
-
}, []);
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useContextSelector } from 'use-context-selector';
|
|
2
|
-
import { ChaynsFunctionsContext } from '../components/ChaynsContext';
|
|
3
|
-
import { useCallback } from 'react';
|
|
4
|
-
export var useAddWindowMetricsListener = function useAddWindowMetricsListener() {
|
|
5
|
-
var addListener = useContextSelector(ChaynsFunctionsContext, function (v) {
|
|
6
|
-
return v === null || v === void 0 ? void 0 : v.addWindowMetricsListener;
|
|
7
|
-
});
|
|
8
|
-
var removeListener = useContextSelector(ChaynsFunctionsContext, function (v) {
|
|
9
|
-
return v === null || v === void 0 ? void 0 : v.removeWindowMetricsListener;
|
|
10
|
-
});
|
|
11
|
-
var promise;
|
|
12
|
-
return useCallback(function (callback) {
|
|
13
|
-
promise = addListener(callback);
|
|
14
|
-
return function () {
|
|
15
|
-
promise.then(removeListener);
|
|
16
|
-
};
|
|
17
|
-
}, []);
|
|
18
|
-
};
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || 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
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
-
|
|
7
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
|
|
9
|
-
import React, { useEffect, useRef } from 'react';
|
|
10
|
-
import * as comlink from 'comlink';
|
|
11
|
-
import postIframeForm from '../util/postIframeForm';
|
|
12
|
-
|
|
13
|
-
var HostIframe = function HostIframe(_ref) {
|
|
14
|
-
var iFrameProps = _ref.iFrameProps,
|
|
15
|
-
src = _ref.src,
|
|
16
|
-
_ref$postForm = _ref.postForm,
|
|
17
|
-
postForm = _ref$postForm === void 0 ? false : _ref$postForm,
|
|
18
|
-
iFrameRef = _ref.iFrameRef,
|
|
19
|
-
pages = _ref.pages,
|
|
20
|
-
isAdminModeActive = _ref.isAdminModeActive,
|
|
21
|
-
site = _ref.site,
|
|
22
|
-
user = _ref.user,
|
|
23
|
-
currentPage = _ref.currentPage,
|
|
24
|
-
functions = _ref.functions,
|
|
25
|
-
device = _ref.device;
|
|
26
|
-
var eventTarget = useRef();
|
|
27
|
-
|
|
28
|
-
var _ref2 = useRef();
|
|
29
|
-
|
|
30
|
-
var currentDataRef = useRef();
|
|
31
|
-
|
|
32
|
-
if (!eventTarget.current) {
|
|
33
|
-
eventTarget.current = global.EventTarget ? new EventTarget() : undefined;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var setHeight = function setHeight(value) {
|
|
37
|
-
if (_ref2.current) {
|
|
38
|
-
_ref2.current.height = "".concat(value, "px");
|
|
39
|
-
}
|
|
40
|
-
}; // region initialData
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var initialData = {
|
|
44
|
-
site: site,
|
|
45
|
-
isAdminModeActive: isAdminModeActive,
|
|
46
|
-
pages: pages,
|
|
47
|
-
currentPage: currentPage,
|
|
48
|
-
device: device,
|
|
49
|
-
user: user
|
|
50
|
-
}; // endregion
|
|
51
|
-
|
|
52
|
-
currentDataRef.current = initialData; // region postIframeForm
|
|
53
|
-
|
|
54
|
-
useEffect(function () {
|
|
55
|
-
if (postForm) {
|
|
56
|
-
void postIframeForm(src, JSON.stringify(_objectSpread(_objectSpread({}, initialData), {}, {
|
|
57
|
-
pages: undefined
|
|
58
|
-
})), 'chayns', iFrameProps.name);
|
|
59
|
-
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
-
|
|
61
|
-
}, []); // endregion
|
|
62
|
-
|
|
63
|
-
console.debug('functions', functions); // region expose data and functions to iframe
|
|
64
|
-
|
|
65
|
-
useEffect(function () {
|
|
66
|
-
var _ref$current;
|
|
67
|
-
|
|
68
|
-
if ((_ref$current = _ref2.current) !== null && _ref$current !== void 0 && _ref$current.contentWindow) {
|
|
69
|
-
var obj = _defineProperty({}, iFrameProps.name, {
|
|
70
|
-
functions: _objectSpread(_objectSpread({}, functions), {}, {
|
|
71
|
-
setHeight: setHeight
|
|
72
|
-
}),
|
|
73
|
-
addDataListener: function addDataListener(cb) {
|
|
74
|
-
if (eventTarget.current) eventTarget.current.addEventListener('data_update', function (e) {
|
|
75
|
-
return e.detail && cb(e.detail);
|
|
76
|
-
});
|
|
77
|
-
},
|
|
78
|
-
getInitialData: function getInitialData() {
|
|
79
|
-
return currentDataRef.current;
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
comlink.expose(obj, comlink.windowEndpoint(_ref2.current.contentWindow));
|
|
84
|
-
|
|
85
|
-
_ref2.current.contentWindow.postMessage('chayns-api-host-ready', '*'); // https://github.com/GoogleChromeLabs/comlink/pull/469 might be better approach once released
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return function () {
|
|
89
|
-
delete obj[iFrameProps.name];
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return undefined; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
-
}, []); // endregion
|
|
95
|
-
// region dispatch data update
|
|
96
|
-
|
|
97
|
-
useEffect(function () {
|
|
98
|
-
if (eventTarget.current) {
|
|
99
|
-
eventTarget.current.dispatchEvent(new CustomEvent('data_update', {
|
|
100
|
-
detail: {
|
|
101
|
-
type: 'isAdminModeActive',
|
|
102
|
-
value: isAdminModeActive
|
|
103
|
-
}
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
}, [isAdminModeActive]);
|
|
107
|
-
useEffect(function () {
|
|
108
|
-
if (eventTarget.current) {
|
|
109
|
-
eventTarget.current.dispatchEvent(new CustomEvent('data_update', {
|
|
110
|
-
detail: {
|
|
111
|
-
type: 'user',
|
|
112
|
-
value: user
|
|
113
|
-
}
|
|
114
|
-
}));
|
|
115
|
-
}
|
|
116
|
-
}, [user]);
|
|
117
|
-
useEffect(function () {
|
|
118
|
-
if (eventTarget.current) {
|
|
119
|
-
eventTarget.current.dispatchEvent(new CustomEvent('data_update', {
|
|
120
|
-
detail: {
|
|
121
|
-
type: 'site',
|
|
122
|
-
value: site
|
|
123
|
-
}
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
}, [site]);
|
|
127
|
-
useEffect(function () {
|
|
128
|
-
if (eventTarget.current) {
|
|
129
|
-
eventTarget.current.dispatchEvent(new CustomEvent('data_update', {
|
|
130
|
-
detail: {
|
|
131
|
-
type: 'pages',
|
|
132
|
-
value: pages
|
|
133
|
-
}
|
|
134
|
-
}));
|
|
135
|
-
}
|
|
136
|
-
}, [pages]); // endregion
|
|
137
|
-
|
|
138
|
-
return /*#__PURE__*/React.createElement("iframe", _extends({
|
|
139
|
-
ref: function ref(r) {
|
|
140
|
-
_ref2.current = r;
|
|
141
|
-
|
|
142
|
-
if (iFrameRef) {
|
|
143
|
-
// eslint-disable-next-line no-param-reassign
|
|
144
|
-
iFrameRef.current = r;
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
title: " "
|
|
148
|
-
}, iFrameProps, {
|
|
149
|
-
src: postForm ? undefined : src
|
|
150
|
-
}));
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export default HostIframe;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import('./bootstrap');
|
package/dist/esm/index2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { useContextSelector } from 'use-context-selector';
|
|
2
|
-
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
export var useIsAdminMode = function useIsAdminMode() {
|
|
4
|
-
var _useContextSelector;
|
|
5
|
-
|
|
6
|
-
return (_useContextSelector = useContextSelector(ChaynsContext, function (v) {
|
|
7
|
-
return v === null || v === void 0 ? void 0 : v.isAdminModeActive;
|
|
8
|
-
})) !== null && _useContextSelector !== void 0 ? _useContextSelector : false;
|
|
9
|
-
};
|
package/dist/esm/util/useUser.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { useContextSelector } from 'use-context-selector';
|
|
2
|
-
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
export var useUser = function useUser() {
|
|
4
|
-
return useContextSelector(ChaynsContext, function (v) {
|
|
5
|
-
return v === null || v === void 0 ? void 0 : v.user;
|
|
6
|
-
});
|
|
7
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
declare const _default: {
|
|
3
|
-
Component: React.ComponentType<any>;
|
|
4
|
-
CompatComponent: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
|
5
|
-
requiredVersion: string;
|
|
6
|
-
environment: string | undefined;
|
|
7
|
-
};
|
|
8
|
-
export default _default;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
declare const _default: {
|
|
3
|
-
Component: import("react").ComponentType<{
|
|
4
|
-
data?: import("..").ChaynsReactValues | undefined;
|
|
5
|
-
functions?: import("..").ChaynsReactFunctions | undefined;
|
|
6
|
-
isSSR?: boolean | undefined;
|
|
7
|
-
isModule?: boolean | undefined;
|
|
8
|
-
}>;
|
|
9
|
-
CompatComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
|
|
10
|
-
requiredVersion: any;
|
|
11
|
-
environment: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
export default _default;
|
|
File without changes
|