authscape 1.0.324 → 1.0.326
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 +77 -0
- package/package.json +1 -1
- package/src/components/AutoSaveTextField.js +50 -0
package/index.js
CHANGED
|
@@ -115,6 +115,83 @@ function AuthScapeApp(_ref) {
|
|
|
115
115
|
}
|
|
116
116
|
"use strict";
|
|
117
117
|
|
|
118
|
+
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); }
|
|
119
|
+
Object.defineProperty(exports, "__esModule", {
|
|
120
|
+
value: true
|
|
121
|
+
});
|
|
122
|
+
exports.AutoSaveTextField = AutoSaveTextField;
|
|
123
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
124
|
+
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
125
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
126
|
+
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); }
|
|
127
|
+
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; }
|
|
128
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
129
|
+
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."); }
|
|
130
|
+
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); }
|
|
131
|
+
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; }
|
|
132
|
+
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; } }
|
|
133
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
134
|
+
function AutoSaveTextField(_ref) {
|
|
135
|
+
var _ref$label = _ref.label,
|
|
136
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
137
|
+
_ref$variant = _ref.variant,
|
|
138
|
+
variant = _ref$variant === void 0 ? "outlined" : _ref$variant,
|
|
139
|
+
_ref$timeout = _ref.timeout,
|
|
140
|
+
timeout = _ref$timeout === void 0 ? 2000 : _ref$timeout,
|
|
141
|
+
_ref$isMultiLine = _ref.isMultiLine,
|
|
142
|
+
isMultiLine = _ref$isMultiLine === void 0 ? false : _ref$isMultiLine,
|
|
143
|
+
_ref$rows = _ref.rows,
|
|
144
|
+
rows = _ref$rows === void 0 ? 1 : _ref$rows,
|
|
145
|
+
_ref$fullWidth = _ref.fullWidth,
|
|
146
|
+
fullWidth = _ref$fullWidth === void 0 ? false : _ref$fullWidth,
|
|
147
|
+
_ref$onChanged = _ref.onChanged,
|
|
148
|
+
onChanged = _ref$onChanged === void 0 ? null : _ref$onChanged;
|
|
149
|
+
var _useState = (0, _react.useState)(''),
|
|
150
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
151
|
+
text = _useState2[0],
|
|
152
|
+
setText = _useState2[1];
|
|
153
|
+
var _useState3 = (0, _react.useState)(false),
|
|
154
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
155
|
+
isComponentMounted = _useState4[0],
|
|
156
|
+
setComponentMounted = _useState4[1];
|
|
157
|
+
(0, _react.useEffect)(function () {
|
|
158
|
+
// Set the componentMounted flag to true after the initial render
|
|
159
|
+
setComponentMounted(true);
|
|
160
|
+
}, []);
|
|
161
|
+
(0, _react.useEffect)(function () {
|
|
162
|
+
if (isComponentMounted) {
|
|
163
|
+
// Simulate saving text to a server or any storage mechanism
|
|
164
|
+
// In a real-world scenario, you would send a request to a server to save the text
|
|
165
|
+
// For this example, we'll just update the savedText state after 2 seconds
|
|
166
|
+
var saveTimeout = setTimeout(function () {
|
|
167
|
+
if (onChanged != null) {
|
|
168
|
+
onChanged(text);
|
|
169
|
+
}
|
|
170
|
+
}, timeout);
|
|
171
|
+
|
|
172
|
+
// Clean up the timeout to avoid unnecessary saves if the text changes again
|
|
173
|
+
return function () {
|
|
174
|
+
return clearTimeout(saveTimeout);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}, [text, isComponentMounted]);
|
|
178
|
+
var handleTextChange = function handleTextChange(event) {
|
|
179
|
+
var newText = event.target.value;
|
|
180
|
+
setText(newText);
|
|
181
|
+
};
|
|
182
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
183
|
+
label: label,
|
|
184
|
+
fullWidth: fullWidth,
|
|
185
|
+
variant: variant,
|
|
186
|
+
multiline: isMultiLine,
|
|
187
|
+
rows: rows,
|
|
188
|
+
value: text,
|
|
189
|
+
onChange: handleTextChange
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
;
|
|
193
|
+
"use strict";
|
|
194
|
+
|
|
118
195
|
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); }
|
|
119
196
|
Object.defineProperty(exports, "__esModule", {
|
|
120
197
|
value: true
|
package/package.json
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import TextField from '@mui/material/TextField';
|
|
3
|
+
|
|
4
|
+
export function AutoSaveTextField ({label = "", variant = "outlined", timeout = 2000, isMultiLine = false, rows = 1, fullWidth = false, onChanged = null}) {
|
|
5
|
+
const [text, setText] = useState('');
|
|
6
|
+
const [isComponentMounted, setComponentMounted] = useState(false);
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
// Set the componentMounted flag to true after the initial render
|
|
10
|
+
setComponentMounted(true);
|
|
11
|
+
}, []);
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
|
|
15
|
+
if (isComponentMounted)
|
|
16
|
+
{
|
|
17
|
+
// Simulate saving text to a server or any storage mechanism
|
|
18
|
+
// In a real-world scenario, you would send a request to a server to save the text
|
|
19
|
+
// For this example, we'll just update the savedText state after 2 seconds
|
|
20
|
+
const saveTimeout = setTimeout(() => {
|
|
21
|
+
if (onChanged != null)
|
|
22
|
+
{
|
|
23
|
+
onChanged(text);
|
|
24
|
+
}
|
|
25
|
+
}, timeout);
|
|
26
|
+
|
|
27
|
+
// Clean up the timeout to avoid unnecessary saves if the text changes again
|
|
28
|
+
return () => clearTimeout(saveTimeout);
|
|
29
|
+
}
|
|
30
|
+
}, [text, isComponentMounted]);
|
|
31
|
+
|
|
32
|
+
const handleTextChange = (event) => {
|
|
33
|
+
const newText = event.target.value;
|
|
34
|
+
setText(newText);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div>
|
|
39
|
+
<TextField
|
|
40
|
+
label={label}
|
|
41
|
+
fullWidth={fullWidth}
|
|
42
|
+
variant={variant}
|
|
43
|
+
multiline={isMultiLine}
|
|
44
|
+
rows={rows}
|
|
45
|
+
value={text}
|
|
46
|
+
onChange={handleTextChange}
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
};
|