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/build/esm/components/Error/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 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) { 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; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
/**
*
* Error
*
*/
import React, { useEffect, useReducer, useRef } from 'react';
import PropTypes from 'prop-types';
import { isEmpty } from 'lodash';
import { createYupSchema } from '@buffetjs/utils';
import reducer from './reducer';
function Error(_ref) {
var children = _ref.children,
inputError = _ref.inputError,
translatedErrors = _ref.translatedErrors,
type = _ref.type,
validations = _ref.validations,
value = _ref.value;
var _useReducer = useReducer(reducer, {
error: false,
canCheck: !isEmpty(value)
}),
_useReducer2 = _slicedToArray(_useReducer, 2),
state = _useReducer2[0],
dispatch = _useReducer2[1];
var ref = useRef();
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 = /*#__PURE__*/function () {
var _ref3 = _asyncToGenerator( /*#__PURE__*/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 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 /*#__PURE__*/React.createElement(React.Fragment, null, children({
canCheck: canCheck,
dispatch: dispatch,
error: error,
onBlur: handleBlur
}), /*#__PURE__*/React.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.func,
translatedErrors: PropTypes.objectOf(PropTypes.string),
type: PropTypes.string,
validations: PropTypes.objectOf(PropTypes.any),
value: PropTypes.any // eslint-disable-line react/forbid-prop-types
};
export default Error; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0218 ]-- |