Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/@buffetjs/core/dist/components/Error/ drwxr-xr-x | |
| Viewing file: Select action/file-type: "use strict";
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _lodash = require("lodash");
var _utils = require("@buffetjs/utils");
var _reducer = _interopRequireDefault(require("./reducer"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
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); } }
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); }); }; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
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."); }
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); }
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; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_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; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function Error(_ref) {
var children = _ref.children,
inputError = _ref.inputError,
translatedErrors = _ref.translatedErrors,
type = _ref.type,
validations = _ref.validations,
value = _ref.value;
var _useReducer = (0, _react.useReducer)(_reducer["default"], {
error: false,
canCheck: !(0, _lodash.isEmpty)(value)
}),
_useReducer2 = _slicedToArray(_useReducer, 2),
state = _useReducer2[0],
dispatch = _useReducer2[1];
var ref = (0, _react.useRef)();
(0, _react.useEffect)(function () {
dispatch({
type: 'SET_ERROR',
error: inputError
});
}, [inputError]);
var error = state.error,
canCheck = state.canCheck;
var resetError = function resetError() {
if (!ref.current) {
return;
}
dispatch({
type: 'SET_ERROR',
error: null
});
};
var setError = function setError(message) {
if (!ref.current) {
return;
}
dispatch({
type: 'SET_ERROR',
error: message
});
};
var handleBlur = function () {
var _ref3 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(_ref2) {
var target, message;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
target = _ref2.target;
if (!canCheck) {
_context.next = 12;
break;
}
_context.prev = 2;
_context.next = 5;
return (0, _utils.createYupSchema)(type, validations, translatedErrors).validate(target.value);
case 5:
resetError();
_context.next = 12;
break;
case 8:
_context.prev = 8;
_context.t0 = _context["catch"](2);
message = _context.t0.message;
setError(message);
case 12:
case "end":
return _context.stop();
}
}
}, _callee, null, [[2, 8]]);
}));
return function handleBlur(_x) {
return _ref3.apply(this, arguments);
};
}();
if (children) {
return _react["default"].createElement(_react["default"].Fragment, null, children({
canCheck: canCheck,
dispatch: dispatch,
error: error,
onBlur: handleBlur
}), _react["default"].createElement("span", {
style: {
display: 'none'
},
ref: ref
}));
}
}
Error.defaultProps = {
children: function children() {},
translatedErrors: {
date: 'This is not a date',
email: 'This is not an email',
string: 'This is not a string',
number: 'This is not a number',
json: 'This is not a JSON',
max: 'This is too high',
maxLength: 'This is too long',
min: 'This is too small',
minLength: 'This is too short',
required: 'This value is required',
regex: 'This does not match the format',
uppercase: 'This must be a upper case string'
},
type: null,
validations: {},
value: null
};
Error.propTypes = {
children: _propTypes["default"].func,
translatedErrors: _propTypes["default"].objectOf(_propTypes["default"].string),
type: _propTypes["default"].string,
validations: _propTypes["default"].objectOf(_propTypes["default"].any),
value: _propTypes["default"].any
};
var _default = Error;
exports["default"] = _default; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.004 ]-- |