authscape 1.0.192 → 1.0.196

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/index.js CHANGED
@@ -27,6 +27,8 @@ function AuthScapeApp(_ref) {
27
27
  pageProps = _ref.pageProps,
28
28
  _ref$muiTheme = _ref.muiTheme,
29
29
  muiTheme = _ref$muiTheme === void 0 ? {} : _ref$muiTheme,
30
+ _ref$enforceLoggedIn = _ref.enforceLoggedIn,
31
+ enforceLoggedIn = _ref$enforceLoggedIn === void 0 ? false : _ref$enforceLoggedIn,
30
32
  _ref$onAuthentication = _ref.onAuthenticationLoaded,
31
33
  onAuthenticationLoaded = _ref$onAuthentication === void 0 ? null : _ref$onAuthentication;
32
34
  var _useState = (0, _react.useState)(false),
@@ -56,6 +58,13 @@ function AuthScapeApp(_ref) {
56
58
  if (router.query.r != null) {
57
59
  localStorage.setItem("ref", router.query.r);
58
60
  }
61
+
62
+ // ORM module
63
+ // if (process.env.enableOEMClient)
64
+ // {
65
+ // var baseURL = window.location.protocol + "//" + window.location.host;
66
+ // apiService().get("/oem/")
67
+ // }
59
68
  }
60
69
  }, [loadedUser]);
61
70
  (0, _react.useEffect)(function () {
@@ -75,8 +84,12 @@ function AuthScapeApp(_ref) {
75
84
  isEnabled: process.env.enableAuth,
76
85
  userLoaded: function userLoaded(signedInUser) {
77
86
  setLoadedUser(true);
78
- if (onAuthenticationLoaded != null) {
79
- onAuthenticationLoaded(signedInUser);
87
+ if (enforceLoggedIn) {
88
+ authService().login();
89
+ } else {
90
+ if (onAuthenticationLoaded != null) {
91
+ onAuthenticationLoaded(signedInUser);
92
+ }
80
93
  }
81
94
  }
82
95
  }, /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
@@ -101,6 +114,107 @@ function AuthScapeApp(_ref) {
101
114
  }
102
115
  "use strict";
103
116
 
117
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
118
+ Object.defineProperty(exports, "__esModule", {
119
+ value: true
120
+ });
121
+ exports.ColorPicker = ColorPicker;
122
+ var _react = _interopRequireWildcard(require("react"));
123
+ var _reactColor = require("react-color");
124
+ var _reactcss = _interopRequireDefault(require("reactcss"));
125
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
126
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
127
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
128
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
129
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
130
+ 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."); }
131
+ 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); }
132
+ 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; }
133
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
134
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
135
+ function ColorPicker(_ref) {
136
+ var name = _ref.name,
137
+ defaultColor = _ref.defaultColor,
138
+ onColorChanged = _ref.onColorChanged;
139
+ var _useState = (0, _react.useState)(defaultColor != null ? defaultColor : "#ffffff"),
140
+ _useState2 = _slicedToArray(_useState, 2),
141
+ rgbColor = _useState2[0],
142
+ setColor = _useState2[1];
143
+ var _useState3 = (0, _react.useState)(false),
144
+ _useState4 = _slicedToArray(_useState3, 2),
145
+ displayColorPicker = _useState4[0],
146
+ setDisplayColorPicker = _useState4[1];
147
+ var _useState5 = (0, _react.useState)(null),
148
+ _useState6 = _slicedToArray(_useState5, 2),
149
+ selectedColor = _useState6[0],
150
+ setSelectedColor = _useState6[1];
151
+ var _useState7 = (0, _react.useState)(null),
152
+ _useState8 = _slicedToArray(_useState7, 2),
153
+ timeoutToken = _useState8[0],
154
+ setTimeoutToken = _useState8[1];
155
+ var styles = (0, _reactcss["default"])({
156
+ 'default': {
157
+ color: {
158
+ width: '36px',
159
+ height: '14px',
160
+ borderRadius: '2px',
161
+ background: rgbColor
162
+ },
163
+ swatch: {
164
+ padding: '5px',
165
+ background: '#fff',
166
+ borderRadius: '1px',
167
+ boxShadow: '0 0 0 1px rgba(0,0,0,.1)',
168
+ display: 'inline-block',
169
+ cursor: 'pointer'
170
+ },
171
+ popover: {
172
+ position: 'absolute',
173
+ zIndex: '2'
174
+ },
175
+ cover: {
176
+ position: 'fixed',
177
+ top: '0px',
178
+ right: '0px',
179
+ bottom: '0px',
180
+ left: '0px'
181
+ }
182
+ }
183
+ });
184
+ (0, _react.useEffect)(function () {
185
+ if (!displayColorPicker && selectedColor != null) {
186
+ clearTimeout(timeoutToken);
187
+ setTimeoutToken(setTimeout(function () {
188
+ onColorChanged(name, selectedColor);
189
+ }, 500));
190
+ }
191
+ }, [displayColorPicker, selectedColor]);
192
+ return /*#__PURE__*/_react["default"].createElement(_Box["default"], null, /*#__PURE__*/_react["default"].createElement("div", {
193
+ style: styles.swatch,
194
+ onClick: function onClick() {
195
+ setDisplayColorPicker(!displayColorPicker);
196
+ }
197
+ }, /*#__PURE__*/_react["default"].createElement("div", {
198
+ style: styles.color
199
+ })), displayColorPicker ? /*#__PURE__*/_react["default"].createElement("div", {
200
+ style: styles.popover
201
+ }, /*#__PURE__*/_react["default"].createElement("div", {
202
+ style: styles.cover,
203
+ onClick: function onClick() {
204
+ setDisplayColorPicker(false);
205
+ }
206
+ }), /*#__PURE__*/_react["default"].createElement(_reactColor.SketchPicker, {
207
+ color: rgbColor,
208
+ onChange: function onChange(color) {
209
+ setColor(color.hex);
210
+ },
211
+ onChangeComplete: function onChangeComplete(color) {
212
+ setSelectedColor(color.hex);
213
+ }
214
+ })) : null);
215
+ }
216
+ "use strict";
217
+
104
218
  Object.defineProperty(exports, "__esModule", {
105
219
  value: true
106
220
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.192",
3
+ "version": "1.0.196",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -39,6 +39,7 @@
39
39
  "next": "^13.3.2",
40
40
  "nookies": "^2.5.2",
41
41
  "query-string": "^7.1.1",
42
+ "react-color": "^2.19.3",
42
43
  "react-cool-onclickoutside": "^1.7.0",
43
44
  "react-data-table-component": "^7.5.2",
44
45
  "react-hook-form": "^7.44.2",
@@ -6,7 +6,7 @@ import { useRouter } from 'next/router';
6
6
  import { ThemeProvider } from '@mui/material/styles';
7
7
  import { Box } from '@mui/material';
8
8
 
9
- export function AuthScapeApp({Component, pageProps, muiTheme = {}, onAuthenticationLoaded = null}) {
9
+ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLoggedIn = false, onAuthenticationLoaded = null}) {
10
10
 
11
11
  const [isLoading, setIsLoading] = useState(false);
12
12
  const [loadedUser, setLoadedUser] = useState(false);
@@ -26,7 +26,15 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, onAuthenticat
26
26
  if (router.query.r != null)
27
27
  {
28
28
  localStorage.setItem("ref", router.query.r);
29
- }
29
+ }
30
+
31
+ // ORM module
32
+ // if (process.env.enableOEMClient)
33
+ // {
34
+ // var baseURL = window.location.protocol + "//" + window.location.host;
35
+ // apiService().get("/oem/")
36
+ // }
37
+
30
38
  }
31
39
  }, [loadedUser]);
32
40
 
@@ -61,9 +69,16 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, onAuthenticat
61
69
  <AuthorizationComponent setCurrentUser={setCurrentUser} isEnabled={process.env.enableAuth} userLoaded={(signedInUser) => {
62
70
  setLoadedUser(true);
63
71
 
64
- if (onAuthenticationLoaded != null)
72
+ if (enforceLoggedIn)
73
+ {
74
+ authService().login();
75
+ }
76
+ else
65
77
  {
66
- onAuthenticationLoaded(signedInUser);
78
+ if (onAuthenticationLoaded != null)
79
+ {
80
+ onAuthenticationLoaded(signedInUser);
81
+ }
67
82
  }
68
83
  }}>
69
84
  <Component {...pageProps} currentUser={currentUser} toast={toast} setIsLoading={setIsLoading} loadedUser={loadedUser} logEvent={logEvent} />
@@ -0,0 +1,82 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { SketchPicker } from 'react-color';
3
+ import reactCSS from 'reactcss';
4
+ import Box from '@mui/material/Box';
5
+
6
+ export function ColorPicker({name, defaultColor, onColorChanged}) {
7
+
8
+ const [rgbColor, setColor] = useState(defaultColor != null ? defaultColor : "#ffffff");
9
+
10
+ const [displayColorPicker, setDisplayColorPicker] = useState(false);
11
+ const [selectedColor, setSelectedColor] = useState(null);
12
+ const [timeoutToken, setTimeoutToken] = useState(null);
13
+
14
+ const styles = reactCSS({
15
+ 'default': {
16
+ color: {
17
+ width: '36px',
18
+ height: '14px',
19
+ borderRadius: '2px',
20
+ background: rgbColor,
21
+ },
22
+ swatch: {
23
+ padding: '5px',
24
+ background: '#fff',
25
+ borderRadius: '1px',
26
+ boxShadow: '0 0 0 1px rgba(0,0,0,.1)',
27
+ display: 'inline-block',
28
+ cursor: 'pointer',
29
+ },
30
+ popover: {
31
+ position: 'absolute',
32
+ zIndex: '2',
33
+ },
34
+ cover: {
35
+ position: 'fixed',
36
+ top: '0px',
37
+ right: '0px',
38
+ bottom: '0px',
39
+ left: '0px',
40
+ },
41
+ },
42
+ });
43
+
44
+ useEffect(() => {
45
+
46
+ if (!displayColorPicker && selectedColor != null)
47
+ {
48
+ clearTimeout(timeoutToken);
49
+ setTimeoutToken(setTimeout(() => {
50
+
51
+ onColorChanged(name, selectedColor);
52
+
53
+ }, 500));
54
+ }
55
+
56
+ }, [displayColorPicker, selectedColor]);
57
+
58
+ return (
59
+ <Box>
60
+ <div style={ styles.swatch } onClick={() => {
61
+ setDisplayColorPicker(!displayColorPicker);
62
+ }}>
63
+ <div style={ styles.color } />
64
+ </div>
65
+
66
+ { displayColorPicker ? <div style={ styles.popover }>
67
+ <div style={ styles.cover } onClick={() => {
68
+ setDisplayColorPicker(false);
69
+ }}/>
70
+ <SketchPicker color={ rgbColor } onChange={(color) => {
71
+
72
+ setColor(color.hex);
73
+
74
+ }} onChangeComplete={(color) => {
75
+
76
+ setSelectedColor(color.hex);
77
+
78
+ }} />
79
+ </div> : null }
80
+ </Box>
81
+ );
82
+ }