@frontegg/js 6.10.0 → 6.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,24 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
1
3
  import { AppHolder } from '../AppHolder';
2
- export class AdminPortal {
3
- static show(name = 'default') {
4
- AppHolder.getInstance(name).showAdminPortal();
4
+ export var AdminPortal = /*#__PURE__*/function () {
5
+ function AdminPortal() {
6
+ _classCallCheck(this, AdminPortal);
5
7
  }
6
8
 
7
- static hide(name = 'default') {
8
- AppHolder.getInstance(name).hideAdminPortal();
9
- }
9
+ _createClass(AdminPortal, null, [{
10
+ key: "show",
11
+ value: function show() {
12
+ var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
13
+ AppHolder.getInstance(name).showAdminPortal();
14
+ }
15
+ }, {
16
+ key: "hide",
17
+ value: function hide() {
18
+ var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
19
+ AppHolder.getInstance(name).hideAdminPortal();
20
+ }
21
+ }]);
10
22
 
11
- }
23
+ return AdminPortal;
24
+ }();
@@ -1,95 +1,135 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
1
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
6
  import { createFronteggStore } from '@frontegg/redux-store';
3
7
  import { Metadata } from '@frontegg/types';
4
8
  import { FronteggApp } from '../FronteggApp';
5
9
  import { waitThemeSetter } from '../utils';
6
- export class AdminPortalRenderer {
7
- constructor(name, themeOptions, store, appOptions) {
10
+ export var AdminPortalRenderer = /*#__PURE__*/function () {
11
+ function AdminPortalRenderer(name, themeOptions, store, appOptions) {
12
+ _classCallCheck(this, AdminPortalRenderer);
13
+
8
14
  this.app = void 0;
9
15
  this.options = void 0;
10
16
  this.store = void 0;
11
17
 
12
- this.setRoute = () => {};
18
+ this.setRoute = function () {};
13
19
 
14
20
  this.themeSetter = void 0;
15
21
  this.themeOptions = {};
16
- const contextOptions = {
22
+ var contextOptions = {
17
23
  baseUrl: 'preview'
18
24
  };
19
25
  this.store = store != null ? store : createFronteggStore({
20
26
  context: contextOptions
21
27
  }, this, true, undefined, undefined, true);
22
28
  this.options = _extends({
23
- themeOptions,
29
+ themeOptions: themeOptions,
24
30
  iframeRendering: true,
25
31
  metadata: {},
26
32
  previewMode: true,
27
33
  builderMode: true,
28
34
  store: this.store,
29
- contextOptions
35
+ contextOptions: contextOptions
30
36
  }, appOptions);
31
37
  this.app = new FronteggApp(this.options, name, true);
32
38
  Metadata.set({}, name);
33
39
  }
34
40
 
35
- async render(adminPortalContainer) {
36
- let adminPortalEl = adminPortalContainer.querySelector('#root');
37
-
38
- if (!adminPortalEl) {
39
- adminPortalEl = adminPortalContainer.ownerDocument.createElement('div');
40
- adminPortalEl.setAttribute('id', 'root');
41
- adminPortalContainer.appendChild(adminPortalEl);
41
+ _createClass(AdminPortalRenderer, [{
42
+ key: "render",
43
+ value: function () {
44
+ var _render = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(adminPortalContainer) {
45
+ var _this = this;
46
+
47
+ var adminPortalEl, setThemeSetter, setStaticRouteSetter, FronteggAdminPortal;
48
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
49
+ while (1) {
50
+ switch (_context.prev = _context.next) {
51
+ case 0:
52
+ adminPortalEl = adminPortalContainer.querySelector('#root');
53
+
54
+ if (!adminPortalEl) {
55
+ adminPortalEl = adminPortalContainer.ownerDocument.createElement('div');
56
+ adminPortalEl.setAttribute('id', 'root');
57
+ adminPortalContainer.appendChild(adminPortalEl);
58
+ }
59
+
60
+ this.app.adminPortalContainer = adminPortalContainer;
61
+ this.app.adminPortalEl = adminPortalEl;
62
+
63
+ setThemeSetter = function setThemeSetter(themeSetter) {
64
+ _this.themeSetter = themeSetter;
65
+ };
66
+
67
+ setStaticRouteSetter = function setStaticRouteSetter(setStaticRoute) {
68
+ _this.setRoute = setStaticRoute;
69
+ };
70
+
71
+ _context.next = 8;
72
+ return this.app.loadScript('FronteggAdminPortal');
73
+
74
+ case 8:
75
+ FronteggAdminPortal = _context.sent;
76
+ this.app.adminPortalRenderer = FronteggAdminPortal.renderPage(adminPortalEl, {
77
+ options: this.options,
78
+ injector: this.app,
79
+ setThemeSetter: setThemeSetter,
80
+ setStaticRouteSetter: setStaticRouteSetter
81
+ });
82
+ this.app.loading = false;
83
+ _context.next = 13;
84
+ return waitThemeSetter(this);
85
+
86
+ case 13:
87
+ case "end":
88
+ return _context.stop();
89
+ }
90
+ }
91
+ }, _callee, this);
92
+ }));
93
+
94
+ function render(_x) {
95
+ return _render.apply(this, arguments);
96
+ }
97
+
98
+ return render;
99
+ }()
100
+ }, {
101
+ key: "setStaticRoute",
102
+ value: function setStaticRoute(staticRoute) {
103
+ var _this$setRoute;
104
+
105
+ (_this$setRoute = this.setRoute) == null ? void 0 : _this$setRoute.call(this, staticRoute);
42
106
  }
43
-
44
- this.app.adminPortalContainer = adminPortalContainer;
45
- this.app.adminPortalEl = adminPortalEl;
46
-
47
- const setThemeSetter = themeSetter => {
48
- this.themeSetter = themeSetter;
49
- };
50
-
51
- const setStaticRouteSetter = setStaticRoute => {
52
- this.setRoute = setStaticRoute;
53
- };
54
-
55
- const FronteggAdminPortal = await this.app.loadScript('FronteggAdminPortal');
56
- this.app.adminPortalRenderer = FronteggAdminPortal.renderPage(adminPortalEl, {
57
- options: this.options,
58
- injector: this.app,
59
- setThemeSetter,
60
- setStaticRouteSetter
61
- });
62
- this.app.loading = false;
63
- await waitThemeSetter(this);
64
- }
65
-
66
- setStaticRoute(staticRoute) {
67
- var _this$setRoute;
68
-
69
- (_this$setRoute = this.setRoute) == null ? void 0 : _this$setRoute.call(this, staticRoute);
70
- }
71
-
72
- unmount() {
73
- try {
74
- var _this$app$adminPortal;
75
-
76
- (_this$app$adminPortal = this.app.adminPortalRenderer) == null ? void 0 : _this$app$adminPortal.unmount();
77
- } catch (e) {
78
- console.error('Failed to unmount admin Portal renderer', e);
107
+ }, {
108
+ key: "unmount",
109
+ value: function unmount() {
110
+ try {
111
+ var _this$app$adminPortal;
112
+
113
+ (_this$app$adminPortal = this.app.adminPortalRenderer) == null ? void 0 : _this$app$adminPortal.unmount();
114
+ } catch (e) {
115
+ console.error('Failed to unmount admin Portal renderer', e);
116
+ }
79
117
  }
80
- }
118
+ }, {
119
+ key: "setTheme",
120
+ value: function setTheme(themeOptions) {
121
+ var _this$themeSetter;
81
122
 
82
- setTheme(themeOptions) {
83
- var _this$themeSetter;
123
+ this.themeOptions = themeOptions;
84
124
 
85
- this.themeOptions = themeOptions;
125
+ if (!this.themeSetter) {
126
+ console.warn('this.themeSetter is not defined yet');
127
+ }
86
128
 
87
- if (!this.themeSetter) {
88
- console.warn('this.themeSetter is not defined yet');
129
+ (_this$themeSetter = this.themeSetter) == null ? void 0 : _this$themeSetter.call(this, this.themeOptions);
89
130
  }
131
+ }]);
90
132
 
91
- (_this$themeSetter = this.themeSetter) == null ? void 0 : _this$themeSetter.call(this, this.themeOptions);
92
- }
93
-
94
- }
133
+ return AdminPortalRenderer;
134
+ }();
95
135
  export default AdminPortalRenderer;
@@ -1,17 +1,28 @@
1
- export class AppHolder {
2
- static setInstance(name, app) {
3
- AppHolder._apps[name] = app;
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ export var AppHolder = /*#__PURE__*/function () {
4
+ function AppHolder() {
5
+ _classCallCheck(this, AppHolder);
4
6
  }
5
7
 
6
- static getInstance(name) {
7
- const app = AppHolder._apps[name];
8
-
9
- if (!app) {
10
- throw Error(`[${name}] FronteggApp not found`);
8
+ _createClass(AppHolder, null, [{
9
+ key: "setInstance",
10
+ value: function setInstance(name, app) {
11
+ AppHolder._apps[name] = app;
11
12
  }
13
+ }, {
14
+ key: "getInstance",
15
+ value: function getInstance(name) {
16
+ var app = AppHolder._apps[name];
12
17
 
13
- return app;
14
- }
18
+ if (!app) {
19
+ throw Error("[".concat(name, "] FronteggApp not found"));
20
+ }
21
+
22
+ return app;
23
+ }
24
+ }]);
15
25
 
16
- }
26
+ return AppHolder;
27
+ }();
17
28
  AppHolder._apps = {};
@@ -1,11 +1,24 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
1
3
  import { AppHolder } from '../AppHolder';
2
- export class CheckoutDialog {
3
- static show(opts, name = 'default') {
4
- AppHolder.getInstance(name).showCheckoutDialog(opts);
4
+ export var CheckoutDialog = /*#__PURE__*/function () {
5
+ function CheckoutDialog() {
6
+ _classCallCheck(this, CheckoutDialog);
5
7
  }
6
8
 
7
- static hide(name = 'default') {
8
- AppHolder.getInstance(name).hideCheckoutDialog();
9
- }
9
+ _createClass(CheckoutDialog, null, [{
10
+ key: "show",
11
+ value: function show(opts) {
12
+ var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
13
+ AppHolder.getInstance(name).showCheckoutDialog(opts);
14
+ }
15
+ }, {
16
+ key: "hide",
17
+ value: function hide() {
18
+ var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
19
+ AppHolder.getInstance(name).hideCheckoutDialog();
20
+ }
21
+ }]);
10
22
 
11
- }
23
+ return CheckoutDialog;
24
+ }();