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/custom/build/esm/components/Inputs/ drwxr-xr-x | |
| Viewing file: Select action/file-type: var _excluded = ["customInputs", "description", "error", "id", "label", "name", "onBlur", "onChange", "translatedErrors", "type", "validations", "value"];
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
/**
*
* Inputs
*
*/
import React, { useMemo, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import { get, isEmpty, isFunction, isUndefined } from 'lodash';
import { DatePicker, Checkbox, Enumeration, Error, InputNumber, InputText, Label, Select, Textarea, TimePicker, Toggle, UnknownInput } from '@buffetjs/core';
import { Description, ErrorMessage, Tooltip } from '@buffetjs/styles';
import DateTime from '../DateTime';
import Wrapper, { IconWrapper } from './Wrapper';
/* eslint-disable react/forbid-prop-types */
var inputs = {
bool: Toggle,
checkbox: Checkbox,
date: DatePicker,
datetime: DateTime,
"enum": Enumeration,
number: InputNumber,
text: InputText,
textarea: Textarea,
time: TimePicker,
select: Select,
email: InputText,
password: InputText,
search: InputText
};
function Inputs(_ref) {
var customInputs = _ref.customInputs,
description = _ref.description,
inputError = _ref.error,
id = _ref.id,
label = _ref.label,
name = _ref.name,
handleBlur = _ref.onBlur,
_onChange = _ref.onChange,
translatedErrors = _ref.translatedErrors,
type = _ref.type,
validations = _ref.validations,
value = _ref.value,
rest = _objectWithoutProperties(_ref, _excluded);
var _useState = useState(false),
_useState2 = _slicedToArray(_useState, 2),
isOver = _useState2[0],
setIsOver = _useState2[1];
var inputValue = useMemo(function () {
var ret;
switch (type) {
case 'checkbox':
ret = value || false;
break;
case 'bool':
ret = value;
break;
case 'number':
ret = isUndefined(value) ? '' : value;
break;
default:
ret = value || '';
}
return ret;
}, [type, value]);
var allInputs = useRef(Object.assign(inputs, customInputs));
var InputComponent = allInputs.current[type] || UnknownInput;
var inputId = useMemo(function () {
return id || name;
}, [id, name]);
var descriptionId = "description-".concat(inputId);
var errorId = "error-".concat(inputId);
var handleMouseEvent = function handleMouseEvent() {
setIsOver(function (prev) {
return !prev;
});
};
if (get(customInputs, type, null) !== null) {
return /*#__PURE__*/React.createElement(InputComponent, _extends({
description: description,
error: inputError,
label: label,
name: name,
onBlur: handleBlur,
onChange: _onChange,
type: type,
validations: validations,
value: value
}, rest));
}
return /*#__PURE__*/React.createElement(Error, {
inputError: inputError,
name: name,
translatedErrors: translatedErrors,
type: type,
validations: validations
}, function (_ref2) {
var canCheck = _ref2.canCheck,
onBlur = _ref2.onBlur,
error = _ref2.error,
dispatch = _ref2.dispatch;
return /*#__PURE__*/React.createElement(Wrapper, {
error: error
}, type !== 'checkbox' && /*#__PURE__*/React.createElement(Label, {
htmlFor: inputId
}, /*#__PURE__*/React.createElement("span", null, label, isEmpty(label) && /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0")), rest.labelIcon && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconWrapper, {
"data-tip": rest.labelIcon.title,
"data-for": "icon-title",
onMouseEnter: handleMouseEvent,
onMouseLeave: handleMouseEvent
}, rest.labelIcon.icon), isOver && /*#__PURE__*/React.createElement(Tooltip, {
id: "icon-title"
}))), /*#__PURE__*/React.createElement(InputComponent, _extends({}, rest, {
message: label // Only for the checkbox
,
name: name,
id: inputId,
"aria-describedby": "".concat(!error && description ? descriptionId : '', " ").concat(error ? errorId : ''),
"aria-invalid": error ? 'true' : 'false',
onBlur: isFunction(handleBlur) ? handleBlur : onBlur,
onChange: function onChange(e) {
if (!canCheck) {
dispatch({
type: 'SET_CHECK'
});
}
dispatch({
type: 'SET_ERROR',
error: null
});
_onChange(e);
},
type: type,
value: inputValue
})), !error && description && /*#__PURE__*/React.createElement(Description, {
id: descriptionId,
title: description
}, description), error && /*#__PURE__*/React.createElement(ErrorMessage, {
id: errorId
}, error));
});
}
Inputs.defaultProps = {
customInputs: null,
description: null,
id: null,
error: null,
label: null,
labelIcon: null,
onBlur: null,
onChange: function onChange() {},
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'
},
validations: {},
value: null
};
Inputs.propTypes = {
customInputs: PropTypes.object,
description: PropTypes.string,
error: PropTypes.string,
id: PropTypes.string,
label: PropTypes.string,
labelIcon: PropTypes.shape({
icon: PropTypes.any,
title: PropTypes.string
}),
name: PropTypes.string.isRequired,
onBlur: PropTypes.func,
onChange: function onChange() {},
translatedErrors: PropTypes.objectOf(PropTypes.string),
type: PropTypes.string.isRequired,
validations: PropTypes.object,
value: PropTypes.any
};
export default Inputs; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0201 ]-- |