linear-react-components-ui 1.1.25-rc.9 → 1.1.25
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/lib/{BaseMask-0c14ef51.d.ts → BaseMask-78847f45.d.ts} +1 -1
- package/lib/{Cnpj-bde01dd0.d.ts → Cnpj-8366781f.d.ts} +1 -1
- package/lib/{Cpf-3fa496ad.d.ts → Cpf-3dfd54eb.d.ts} +1 -1
- package/lib/{Phone-2bb0b397.d.ts → Phone-1962c0f2.d.ts} +1 -1
- package/lib/{ZipCode-09460e18.d.ts → ZipCode-be9c5b3b.d.ts} +1 -1
- package/lib/assets/styles/drawers.scss +0 -2
- package/lib/assets/styles/split.scss +1 -1
- package/lib/assets/styles/tooltip.scss +5 -4
- package/lib/drawer/Drawer.js +2 -3
- package/lib/drawer/index.js +1 -1
- package/lib/{index-3b70931d.d.ts → index-02a27c19.d.ts} +2 -20
- package/lib/index-053f615b.d.ts +26 -0
- package/lib/{index-7dfa8924.d.ts → index-25b80f32.d.ts} +1 -1
- package/lib/{index-afb7b5a9.d.ts → index-696662fe.d.ts} +1 -1
- package/lib/{index-9e576346.d.ts → index-6f5c772d.d.ts} +1 -1
- package/lib/{index-208e7f62.d.ts → index-6fcf446c.d.ts} +2 -20
- package/lib/index-7159df18.d.ts +21 -0
- package/lib/inputs2/checkboxfield/base.d.ts +29 -0
- package/lib/inputs2/checkboxfield/base.js +134 -0
- package/lib/inputs2/checkboxfield/index.d.ts +3 -2
- package/lib/inputs2/checkboxfield/index.js +32 -125
- package/lib/inputs2/colorfield/index.d.ts +6 -5
- package/lib/inputs2/date/datefield/base.d.ts +13 -0
- package/lib/inputs2/date/datefield/base.js +330 -0
- package/lib/inputs2/date/datefield/index.js +34 -322
- package/lib/inputs2/date/datefield/types.d.ts +5 -3
- package/lib/inputs2/date/dateperiodfield/base.d.ts +13 -0
- package/lib/inputs2/date/dateperiodfield/base.js +595 -0
- package/lib/inputs2/date/dateperiodfield/index.js +34 -587
- package/lib/inputs2/date/dateperiodfield/types.d.ts +5 -3
- package/lib/inputs2/filefield/index.d.ts +6 -5
- package/lib/inputs2/index.d.ts +18 -15
- package/lib/inputs2/mask/BaseMask.d.ts +6 -5
- package/lib/inputs2/mask/Cnpj.d.ts +7 -6
- package/lib/inputs2/mask/Cpf.d.ts +7 -6
- package/lib/inputs2/mask/Phone.d.ts +7 -6
- package/lib/inputs2/mask/ZipCode.d.ts +7 -6
- package/lib/inputs2/numberfield/currency.d.ts +5 -4
- package/lib/inputs2/numberfield/decimal.d.ts +5 -4
- package/lib/inputs2/numberfield/index.d.ts +5 -4
- package/lib/inputs2/numberfield/types.d.ts +5 -4
- package/lib/inputs2/radiofield/base.d.ts +12 -0
- package/lib/inputs2/radiofield/base.js +156 -0
- package/lib/inputs2/radiofield/index.d.ts +1 -1
- package/lib/inputs2/radiofield/index.js +25 -126
- package/lib/inputs2/radiofield/types.d.ts +6 -4
- package/lib/inputs2/selectfield/base.d.ts +11 -0
- package/lib/inputs2/selectfield/base.js +513 -0
- package/lib/inputs2/selectfield/index.d.ts +1 -1
- package/lib/inputs2/selectfield/index.js +35 -502
- package/lib/inputs2/selectfield/types.d.ts +8 -6
- package/lib/inputs2/textareafield/base.d.ts +26 -0
- package/lib/inputs2/textareafield/base.js +166 -0
- package/lib/inputs2/textareafield/index.d.ts +4 -3
- package/lib/inputs2/textareafield/index.js +30 -154
- package/lib/inputs2/textfield/base.d.ts +26 -0
- package/lib/inputs2/textfield/base.js +131 -0
- package/lib/inputs2/textfield/index.d.ts +5 -4
- package/lib/inputs2/textfield/index.js +30 -120
- package/lib/tooltip/TooltipContent.js +1 -1
- package/lib/tooltip/useTooltip.js +25 -0
- package/package.json +1 -1
- package/lib/index-19761a50.d.ts +0 -26
- package/lib/index-4bda404f.d.ts +0 -42
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InputBase = void 0;
|
|
7
|
+
require("../../assets/styles/textfield.scss");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
|
+
var _hint = _interopRequireDefault(require("../../hint"));
|
|
11
|
+
var _tooltip = require("../../tooltip");
|
|
12
|
+
var _textContent = _interopRequireDefault(require("../../textContent"));
|
|
13
|
+
var _helpers = require("../../form2/helpers");
|
|
14
|
+
var _popover = _interopRequireWildcard(require("../../popover"));
|
|
15
|
+
var _slot = require("../slot");
|
|
16
|
+
const _excluded = ["name", "label", "errors", "children", "maxLength", "customClass", "customClassLabel", "customClassWrapper", "customClassInputContainer", "textAlign", "labelUppercase", "skeletonize", "hintPosition", "themePopover", "popoverAlign", "tooltip", "tooltipPosition", "tooltipWidth", "hint", "disabled", "readOnly"];
|
|
17
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
20
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
21
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
22
|
+
const InputBase = exports.InputBase = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
23
|
+
var _props$hint;
|
|
24
|
+
const {
|
|
25
|
+
name,
|
|
26
|
+
label,
|
|
27
|
+
errors,
|
|
28
|
+
children,
|
|
29
|
+
maxLength = undefined,
|
|
30
|
+
customClass = '',
|
|
31
|
+
customClassLabel = '',
|
|
32
|
+
customClassWrapper = '',
|
|
33
|
+
customClassInputContainer = '',
|
|
34
|
+
textAlign = 'left',
|
|
35
|
+
labelUppercase = false,
|
|
36
|
+
skeletonize = false,
|
|
37
|
+
hintPosition = 'below',
|
|
38
|
+
themePopover = 'light',
|
|
39
|
+
popoverAlign = 'left',
|
|
40
|
+
tooltip,
|
|
41
|
+
tooltipPosition,
|
|
42
|
+
tooltipWidth,
|
|
43
|
+
hint,
|
|
44
|
+
disabled,
|
|
45
|
+
readOnly
|
|
46
|
+
} = props,
|
|
47
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
48
|
+
const inputRef = _react.default.useRef(null);
|
|
49
|
+
const counterRef = _react.default.useRef(null);
|
|
50
|
+
const textAreaInternalRef = _react.default.useRef(null);
|
|
51
|
+
const hasLabel = !_lodash.default.isEmpty(props === null || props === void 0 ? void 0 : props.label);
|
|
52
|
+
const hasHintMessages = Boolean((_props$hint = props.hint) === null || _props$hint === void 0 ? void 0 : _props$hint.length);
|
|
53
|
+
const hintMustBeOnLabel = hintPosition === 'onLabelRight';
|
|
54
|
+
const hasValidationErrors = Boolean(errors === null || errors === void 0 ? void 0 : errors.length);
|
|
55
|
+
const hasMaxLengthCondition = Boolean(maxLength);
|
|
56
|
+
const {
|
|
57
|
+
leftSlotElements,
|
|
58
|
+
rightSlotElements
|
|
59
|
+
} = _react.default.useMemo(() => {
|
|
60
|
+
const left = [];
|
|
61
|
+
const right = [];
|
|
62
|
+
_react.default.Children.map(children, (childElement, index) => {
|
|
63
|
+
if (/*#__PURE__*/_react.default.isValidElement(childElement)) {
|
|
64
|
+
var _childElement$key;
|
|
65
|
+
const clonedChild = /*#__PURE__*/_react.default.cloneElement(childElement, {
|
|
66
|
+
key: (_childElement$key = childElement.key) !== null && _childElement$key !== void 0 ? _childElement$key : "slot-".concat(index),
|
|
67
|
+
disabled: disabled,
|
|
68
|
+
'aria-disabled': disabled
|
|
69
|
+
});
|
|
70
|
+
if (childElement.type === _slot.LeftSlot) left.push(clonedChild);
|
|
71
|
+
if (childElement.type === _slot.RightSlot) right.push(clonedChild);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
leftSlotElements: left,
|
|
76
|
+
rightSlotElements: right
|
|
77
|
+
};
|
|
78
|
+
}, [children, disabled]);
|
|
79
|
+
const hasLeftSlotElements = Boolean(leftSlotElements === null || leftSlotElements === void 0 ? void 0 : leftSlotElements.length);
|
|
80
|
+
const hasRightSlotElements = Boolean(rightSlotElements === null || rightSlotElements === void 0 ? void 0 : rightSlotElements.length);
|
|
81
|
+
const handleOnInputData = event => {
|
|
82
|
+
const target = event.target;
|
|
83
|
+
const currentLength = target.value.length;
|
|
84
|
+
if (counterRef.current) {
|
|
85
|
+
counterRef.current.textContent = "".concat(currentLength, "/").concat(maxLength);
|
|
86
|
+
/**
|
|
87
|
+
* Cálculo faz referência ao tamanho do espaço ocupado do contador de caracteres.
|
|
88
|
+
* Isso evita quebra de layout da interface.
|
|
89
|
+
*/
|
|
90
|
+
counterRef.current.style.width = "".concat(_lodash.default.toNumber(maxLength === null || maxLength === void 0 ? void 0 : maxLength.toString().length) * 7 * 2 + 6, "px");
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
_react.default.useEffect(() => {
|
|
94
|
+
var _textAreaInternalRef$;
|
|
95
|
+
textAreaInternalRef === null || textAreaInternalRef === void 0 ? void 0 : (_textAreaInternalRef$ = textAreaInternalRef.current) === null || _textAreaInternalRef$ === void 0 ? void 0 : _textAreaInternalRef$.addEventListener('input', handleOnInputData);
|
|
96
|
+
return () => {
|
|
97
|
+
var _textAreaInternalRef$2;
|
|
98
|
+
textAreaInternalRef === null || textAreaInternalRef === void 0 ? void 0 : (_textAreaInternalRef$2 = textAreaInternalRef.current) === null || _textAreaInternalRef$2 === void 0 ? void 0 : _textAreaInternalRef$2.removeEventListener('input', handleOnInputData);
|
|
99
|
+
};
|
|
100
|
+
}, []);
|
|
101
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
102
|
+
ref: inputRef,
|
|
103
|
+
className: "text-field-root ".concat(customClassWrapper),
|
|
104
|
+
"data-state-error": hasValidationErrors
|
|
105
|
+
}, hasLabel && /*#__PURE__*/_react.default.createElement("span", {
|
|
106
|
+
className: "root-label ".concat(customClassLabel),
|
|
107
|
+
"data-state-skeletonize": skeletonize
|
|
108
|
+
}, /*#__PURE__*/_react.default.createElement("label", {
|
|
109
|
+
className: "label",
|
|
110
|
+
title: label,
|
|
111
|
+
htmlFor: name,
|
|
112
|
+
"data-state-disabled": disabled,
|
|
113
|
+
"data-state-read-only": readOnly,
|
|
114
|
+
"data-state-input-required": props.required,
|
|
115
|
+
"data-state-label-uppercase": labelUppercase
|
|
116
|
+
}, label), hint && hintPosition === 'onLabelRight' && !skeletonize && /*#__PURE__*/_react.default.createElement(_popover.default, {
|
|
117
|
+
customClass: "label-popover",
|
|
118
|
+
theme: themePopover,
|
|
119
|
+
align: popoverAlign,
|
|
120
|
+
iconColor: "#03bde2"
|
|
121
|
+
}, /*#__PURE__*/_react.default.createElement(_popover.PopoverText, {
|
|
122
|
+
text: hint
|
|
123
|
+
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
124
|
+
"data-state-skeletonize": skeletonize,
|
|
125
|
+
className: "container ".concat(customClassInputContainer)
|
|
126
|
+
}, hasLeftSlotElements && !skeletonize && leftSlotElements, /*#__PURE__*/_react.default.createElement("textarea", _extends({
|
|
127
|
+
ref: (0, _helpers.mergeRefs)(ref, textAreaInternalRef),
|
|
128
|
+
id: name,
|
|
129
|
+
readOnly: readOnly,
|
|
130
|
+
disabled: disabled,
|
|
131
|
+
maxLength: maxLength,
|
|
132
|
+
className: "input ".concat(customClass),
|
|
133
|
+
tabIndex: !readOnly ? 0 : -1,
|
|
134
|
+
placeholder: rest.placeholder,
|
|
135
|
+
"data-state-error": hasValidationErrors,
|
|
136
|
+
"data-state-read-only": readOnly,
|
|
137
|
+
"data-state-text-align": textAlign,
|
|
138
|
+
"data-state-skeletonize": skeletonize
|
|
139
|
+
}, rest)), hasRightSlotElements && !skeletonize && rightSlotElements), /*#__PURE__*/_react.default.createElement("div", {
|
|
140
|
+
className: "footer",
|
|
141
|
+
"data-state-has-max-length": hasMaxLengthCondition,
|
|
142
|
+
"data-state-has-hint": hasHintMessages && !hintMustBeOnLabel
|
|
143
|
+
}, /*#__PURE__*/_react.default.createElement(_hint.default, {
|
|
144
|
+
customClass: "hint",
|
|
145
|
+
description: hint,
|
|
146
|
+
disabled: disabled,
|
|
147
|
+
skeletonize: skeletonize,
|
|
148
|
+
visible: !hintMustBeOnLabel && hasHintMessages
|
|
149
|
+
}), hasMaxLengthCondition && /*#__PURE__*/_react.default.createElement(_textContent.default, {
|
|
150
|
+
ref: counterRef,
|
|
151
|
+
as: "span",
|
|
152
|
+
className: "max-length-counter"
|
|
153
|
+
}, "0/", _lodash.default.toNumber(maxLength))), hasValidationErrors && /*#__PURE__*/_react.default.createElement("span", {
|
|
154
|
+
className: "error",
|
|
155
|
+
"data-state-skeletonize": skeletonize,
|
|
156
|
+
"aria-describedby": String(name).concat('-errors')
|
|
157
|
+
}, errors === null || errors === void 0 ? void 0 : errors.map((error, index) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
158
|
+
key: "".concat(index + 1, "-").concat(error)
|
|
159
|
+
}, error, "\xA0")))), /*#__PURE__*/_react.default.createElement(_tooltip.Tooltip, {
|
|
160
|
+
targetRef: inputRef,
|
|
161
|
+
text: tooltip,
|
|
162
|
+
width: tooltipWidth,
|
|
163
|
+
position: tooltipPosition
|
|
164
|
+
}));
|
|
165
|
+
});
|
|
166
|
+
InputBase.displayName = 'TextAreaFieldInputBase';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
+
import '../../@types/PermissionAttr.js';
|
|
3
|
+
export { LeftSlot, RightSlot } from '../slot/index.js';
|
|
4
|
+
import './base.js';
|
|
5
|
+
export { I as Input, T as TextAreaFieldInputProps } from '../../index-6fcf446c.js';
|
|
2
6
|
import '../../@types/Align.js';
|
|
3
7
|
import '../../@types/ColorStyles.js';
|
|
4
8
|
import '../../@types/Position.js';
|
|
5
|
-
import '../../@types/PermissionAttr.js';
|
|
6
|
-
export { LeftSlot, RightSlot } from '../slot/index.js';
|
|
7
9
|
import '../../tooltip/types.js';
|
|
8
|
-
export { I as Input, T as TextAreaFieldInputProps } from '../../index-208e7f62.js';
|
|
@@ -18,49 +18,30 @@ Object.defineProperty(exports, "RightSlot", {
|
|
|
18
18
|
});
|
|
19
19
|
require("../../assets/styles/textfield.scss");
|
|
20
20
|
var _react = _interopRequireDefault(require("react"));
|
|
21
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
22
21
|
var _gridlayout = _interopRequireDefault(require("../../gridlayout"));
|
|
23
|
-
var _hint = _interopRequireDefault(require("../../hint"));
|
|
24
|
-
var _tooltip = require("../../tooltip");
|
|
25
|
-
var _textContent = _interopRequireDefault(require("../../textContent"));
|
|
26
|
-
var _helpers = require("../../form2/helpers");
|
|
27
|
-
var _popover = _interopRequireWildcard(require("../../popover"));
|
|
28
22
|
var _permissionValidations = require("../../permissionValidations");
|
|
29
23
|
var _slot = require("../slot");
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
var _base = require("./base");
|
|
25
|
+
const _excluded = ["readOnly", "disabled", "onDeniedActions", "permissionAttr", "gridLayout"];
|
|
32
26
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
33
27
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
28
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
31
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
32
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
34
33
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
35
34
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
36
35
|
const options = [_permissionValidations.OPTIONS_ON_DENIED.disabled, _permissionValidations.OPTIONS_ON_DENIED.unvisible, _permissionValidations.OPTIONS_ON_DENIED.readOnly, _permissionValidations.OPTIONS_ON_DENIED.hideContent];
|
|
37
|
-
const Input = exports.Input = /*#__PURE__*/_react.default.forwardRef((
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
label,
|
|
42
|
-
errors,
|
|
43
|
-
children,
|
|
44
|
-
maxLength = undefined,
|
|
36
|
+
const Input = exports.Input = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
37
|
+
let {
|
|
38
|
+
readOnly,
|
|
39
|
+
disabled,
|
|
45
40
|
onDeniedActions = undefined,
|
|
46
41
|
permissionAttr = undefined,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
customClassInputContainer = '',
|
|
51
|
-
textAlign = 'left',
|
|
52
|
-
labelUppercase = false,
|
|
53
|
-
skeletonize = false,
|
|
54
|
-
hintPosition = 'below',
|
|
55
|
-
gridLayout = undefined,
|
|
56
|
-
themePopover = 'light',
|
|
57
|
-
popoverAlign = 'left',
|
|
58
|
-
tooltip,
|
|
59
|
-
tooltipPosition,
|
|
60
|
-
tooltipWidth,
|
|
61
|
-
hint
|
|
62
|
-
} = props,
|
|
63
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
42
|
+
gridLayout
|
|
43
|
+
} = _ref,
|
|
44
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
64
45
|
const onDenied = _react.default.useMemo(() => {
|
|
65
46
|
return onDeniedActions || (0, _permissionValidations.actionsOnPermissionDenied)(options, permissionAttr);
|
|
66
47
|
}, [onDeniedActions, permissionAttr]);
|
|
@@ -68,127 +49,22 @@ const Input = exports.Input = /*#__PURE__*/_react.default.forwardRef((props, ref
|
|
|
68
49
|
hideContent,
|
|
69
50
|
unvisible
|
|
70
51
|
} = onDenied;
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const hasLabel = !_lodash.default.isEmpty(props === null || props === void 0 ? void 0 : props.label);
|
|
75
|
-
const isReadOnly = Boolean(props.readOnly || onDenied.readOnly);
|
|
76
|
-
const isDisabled = Boolean(props.disabled || onDenied.disabled);
|
|
77
|
-
const hasHintMessages = Boolean((_props$hint = props.hint) === null || _props$hint === void 0 ? void 0 : _props$hint.length);
|
|
78
|
-
const hintMustBeOnLabel = hintPosition === 'onLabelRight';
|
|
79
|
-
const hasValidationErrors = Boolean(errors === null || errors === void 0 ? void 0 : errors.length);
|
|
80
|
-
const hasMaxLengthCondition = Boolean(maxLength);
|
|
81
|
-
const {
|
|
82
|
-
leftSlotElements,
|
|
83
|
-
rightSlotElements
|
|
84
|
-
} = _react.default.useMemo(() => {
|
|
85
|
-
const left = [];
|
|
86
|
-
const right = [];
|
|
87
|
-
_react.default.Children.map(children, (childElement, index) => {
|
|
88
|
-
if (/*#__PURE__*/_react.default.isValidElement(childElement)) {
|
|
89
|
-
var _childElement$key;
|
|
90
|
-
const clonedChild = /*#__PURE__*/_react.default.cloneElement(childElement, {
|
|
91
|
-
key: (_childElement$key = childElement.key) !== null && _childElement$key !== void 0 ? _childElement$key : "slot-".concat(index),
|
|
92
|
-
disabled: isDisabled,
|
|
93
|
-
'aria-disabled': isDisabled
|
|
94
|
-
});
|
|
95
|
-
if (childElement.type === _slot.LeftSlot) left.push(clonedChild);
|
|
96
|
-
if (childElement.type === _slot.RightSlot) right.push(clonedChild);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
return {
|
|
100
|
-
leftSlotElements: left,
|
|
101
|
-
rightSlotElements: right
|
|
102
|
-
};
|
|
103
|
-
}, [children, isDisabled]);
|
|
104
|
-
const hasLeftSlotElements = Boolean(leftSlotElements === null || leftSlotElements === void 0 ? void 0 : leftSlotElements.length);
|
|
105
|
-
const hasRightSlotElements = Boolean(rightSlotElements === null || rightSlotElements === void 0 ? void 0 : rightSlotElements.length);
|
|
106
|
-
const handleOnInputData = event => {
|
|
107
|
-
const target = event.target;
|
|
108
|
-
const currentLength = target.value.length;
|
|
109
|
-
if (counterRef.current) {
|
|
110
|
-
counterRef.current.textContent = "".concat(currentLength, "/").concat(maxLength);
|
|
111
|
-
/**
|
|
112
|
-
* Cálculo faz referência ao tamanho do espaço ocupado do contador de caracteres.
|
|
113
|
-
* Isso evita quebra de layout da interface.
|
|
114
|
-
*/
|
|
115
|
-
counterRef.current.style.width = "".concat(_lodash.default.toNumber(maxLength === null || maxLength === void 0 ? void 0 : maxLength.toString().length) * 7 * 2 + 6, "px");
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
_react.default.useEffect(() => {
|
|
119
|
-
var _textAreaInternalRef$;
|
|
120
|
-
textAreaInternalRef === null || textAreaInternalRef === void 0 ? void 0 : (_textAreaInternalRef$ = textAreaInternalRef.current) === null || _textAreaInternalRef$ === void 0 ? void 0 : _textAreaInternalRef$.addEventListener('input', handleOnInputData);
|
|
121
|
-
return () => {
|
|
122
|
-
var _textAreaInternalRef$2;
|
|
123
|
-
textAreaInternalRef === null || textAreaInternalRef === void 0 ? void 0 : (_textAreaInternalRef$2 = textAreaInternalRef.current) === null || _textAreaInternalRef$2 === void 0 ? void 0 : _textAreaInternalRef$2.removeEventListener('input', handleOnInputData);
|
|
124
|
-
};
|
|
125
|
-
}, []);
|
|
126
|
-
if (unvisible || hideContent) return null;
|
|
127
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
|
|
128
|
-
cols: gridLayout
|
|
129
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
130
|
-
ref: inputRef,
|
|
131
|
-
className: "text-field-root ".concat(customClassWrapper),
|
|
132
|
-
"data-state-error": hasValidationErrors
|
|
133
|
-
}, hasLabel && /*#__PURE__*/_react.default.createElement("span", {
|
|
134
|
-
className: "root-label ".concat(customClassLabel),
|
|
135
|
-
"data-state-skeletonize": skeletonize
|
|
136
|
-
}, /*#__PURE__*/_react.default.createElement("label", {
|
|
137
|
-
className: "label",
|
|
138
|
-
title: label,
|
|
139
|
-
htmlFor: name,
|
|
140
|
-
"data-state-disabled": isDisabled,
|
|
141
|
-
"data-state-read-only": isReadOnly,
|
|
142
|
-
"data-state-input-required": props.required,
|
|
143
|
-
"data-state-label-uppercase": labelUppercase
|
|
144
|
-
}, label), hint && hintPosition === 'onLabelRight' && !skeletonize && /*#__PURE__*/_react.default.createElement(_popover.default, {
|
|
145
|
-
customClass: "label-popover",
|
|
146
|
-
theme: themePopover,
|
|
147
|
-
align: popoverAlign,
|
|
148
|
-
iconColor: "#03bde2"
|
|
149
|
-
}, /*#__PURE__*/_react.default.createElement(_popover.PopoverText, {
|
|
150
|
-
text: hint
|
|
151
|
-
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
152
|
-
"data-state-skeletonize": skeletonize,
|
|
153
|
-
className: "container ".concat(customClassInputContainer)
|
|
154
|
-
}, hasLeftSlotElements && !skeletonize && leftSlotElements, /*#__PURE__*/_react.default.createElement("textarea", _extends({
|
|
155
|
-
ref: (0, _helpers.mergeRefs)(ref, textAreaInternalRef),
|
|
156
|
-
id: name,
|
|
52
|
+
const isReadOnly = Boolean(readOnly || onDenied.readOnly);
|
|
53
|
+
const isDisabled = Boolean(disabled || onDenied.disabled);
|
|
54
|
+
const inputProps = _objectSpread({
|
|
157
55
|
readOnly: isReadOnly,
|
|
158
|
-
disabled: isDisabled
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}, /*#__PURE__*/_react.default.createElement(_hint.default, {
|
|
172
|
-
customClass: "hint",
|
|
173
|
-
description: hint,
|
|
174
|
-
disabled: isDisabled,
|
|
175
|
-
skeletonize: skeletonize,
|
|
176
|
-
visible: !hintMustBeOnLabel && hasHintMessages
|
|
177
|
-
}), hasMaxLengthCondition && /*#__PURE__*/_react.default.createElement(_textContent.default, {
|
|
178
|
-
ref: counterRef,
|
|
179
|
-
as: "span",
|
|
180
|
-
className: "max-length-counter"
|
|
181
|
-
}, "0/", _lodash.default.toNumber(maxLength))), hasValidationErrors && /*#__PURE__*/_react.default.createElement("span", {
|
|
182
|
-
className: "error",
|
|
183
|
-
"data-state-skeletonize": skeletonize,
|
|
184
|
-
"aria-describedby": String(name).concat('-errors')
|
|
185
|
-
}, errors === null || errors === void 0 ? void 0 : errors.map((error, index) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
186
|
-
key: "".concat(index + 1, "-").concat(error)
|
|
187
|
-
}, error, "\xA0"))))), /*#__PURE__*/_react.default.createElement(_tooltip.Tooltip, {
|
|
188
|
-
targetRef: inputRef,
|
|
189
|
-
text: tooltip,
|
|
190
|
-
width: tooltipWidth,
|
|
191
|
-
position: tooltipPosition
|
|
192
|
-
}));
|
|
56
|
+
disabled: isDisabled
|
|
57
|
+
}, props);
|
|
58
|
+
if (unvisible || hideContent) return null;
|
|
59
|
+
if (gridLayout) {
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
|
|
61
|
+
cols: gridLayout
|
|
62
|
+
}, /*#__PURE__*/_react.default.createElement(_base.InputBase, _extends({
|
|
63
|
+
ref: ref
|
|
64
|
+
}, inputProps)));
|
|
65
|
+
}
|
|
66
|
+
return /*#__PURE__*/_react.default.createElement(_base.InputBase, _extends({
|
|
67
|
+
ref: ref
|
|
68
|
+
}, inputProps));
|
|
193
69
|
});
|
|
194
70
|
Input.displayName = 'TextAreaFieldInput';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { ITooltipCommonProps } from '../../tooltip/types.js';
|
|
3
|
+
import { TextAlign } from '../../@types/Align.js';
|
|
4
|
+
import { ColorTheme } from '../../@types/ColorStyles.js';
|
|
5
|
+
import { HintPosition, Position } from '../../@types/Position.js';
|
|
6
|
+
|
|
7
|
+
interface TextFieldInputBaseProps extends React__default.ComponentPropsWithoutRef<'input'>, ITooltipCommonProps {
|
|
8
|
+
hint?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
errors?: string[];
|
|
11
|
+
customClass?: string;
|
|
12
|
+
customClassLabel?: string;
|
|
13
|
+
customClassWrapper?: string;
|
|
14
|
+
customClassInputContainer?: string;
|
|
15
|
+
rounded?: boolean;
|
|
16
|
+
readOnly?: boolean;
|
|
17
|
+
skeletonize?: boolean;
|
|
18
|
+
labelUppercase?: boolean;
|
|
19
|
+
textAlign?: TextAlign;
|
|
20
|
+
hintPosition?: HintPosition;
|
|
21
|
+
themePopover?: ColorTheme;
|
|
22
|
+
popoverAlign?: Extract<Position, 'left' | 'right'>;
|
|
23
|
+
}
|
|
24
|
+
declare const InputBase: React__default.ForwardRefExoticComponent<TextFieldInputBaseProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
25
|
+
|
|
26
|
+
export { InputBase, TextFieldInputBaseProps };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InputBase = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
+
var _tooltip = require("../../tooltip");
|
|
10
|
+
var _popover = _interopRequireWildcard(require("../../popover"));
|
|
11
|
+
var _hint = _interopRequireDefault(require("../../hint"));
|
|
12
|
+
var _slot = require("../slot");
|
|
13
|
+
const _excluded = ["type", "name", "label", "errors", "children", "disabled", "readOnly", "customClass", "customClassLabel", "customClassWrapper", "customClassInputContainer", "textAlign", "labelUppercase", "skeletonize", "hintPosition", "themePopover", "popoverAlign", "tooltip", "tooltipPosition", "tooltipWidth", "hint"];
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
17
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
18
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
19
|
+
const InputBase = exports.InputBase = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
20
|
+
var _props$hint;
|
|
21
|
+
const {
|
|
22
|
+
type = 'text',
|
|
23
|
+
name,
|
|
24
|
+
label,
|
|
25
|
+
errors,
|
|
26
|
+
children,
|
|
27
|
+
disabled,
|
|
28
|
+
readOnly,
|
|
29
|
+
customClass = '',
|
|
30
|
+
customClassLabel = '',
|
|
31
|
+
customClassWrapper = '',
|
|
32
|
+
customClassInputContainer = '',
|
|
33
|
+
textAlign = 'left',
|
|
34
|
+
labelUppercase = false,
|
|
35
|
+
skeletonize = false,
|
|
36
|
+
hintPosition = 'below',
|
|
37
|
+
themePopover = 'light',
|
|
38
|
+
popoverAlign = 'left',
|
|
39
|
+
tooltip,
|
|
40
|
+
tooltipPosition,
|
|
41
|
+
tooltipWidth,
|
|
42
|
+
hint
|
|
43
|
+
} = props,
|
|
44
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
45
|
+
const inputRef = (0, _react.useRef)(null);
|
|
46
|
+
const hasLabel = !_lodash.default.isEmpty(props === null || props === void 0 ? void 0 : props.label);
|
|
47
|
+
const hasHintMessages = Boolean((_props$hint = props.hint) === null || _props$hint === void 0 ? void 0 : _props$hint.length);
|
|
48
|
+
const hasValidationErrors = Boolean(errors === null || errors === void 0 ? void 0 : errors.length);
|
|
49
|
+
const {
|
|
50
|
+
leftSlotElements,
|
|
51
|
+
rightSlotElements
|
|
52
|
+
} = _react.default.useMemo(() => {
|
|
53
|
+
const left = [];
|
|
54
|
+
const right = [];
|
|
55
|
+
_react.default.Children.map(children, (childElement, index) => {
|
|
56
|
+
if (/*#__PURE__*/_react.default.isValidElement(childElement)) {
|
|
57
|
+
var _childElement$key;
|
|
58
|
+
const clonedChild = /*#__PURE__*/_react.default.cloneElement(childElement, {
|
|
59
|
+
key: (_childElement$key = childElement.key) !== null && _childElement$key !== void 0 ? _childElement$key : "slot-".concat(index),
|
|
60
|
+
disabled: disabled,
|
|
61
|
+
'aria-disabled': disabled
|
|
62
|
+
});
|
|
63
|
+
if (childElement.type === _slot.LeftSlot) left.push(clonedChild);
|
|
64
|
+
if (childElement.type === _slot.RightSlot) right.push(clonedChild);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
leftSlotElements: left,
|
|
69
|
+
rightSlotElements: right
|
|
70
|
+
};
|
|
71
|
+
}, [children, disabled]);
|
|
72
|
+
const hasLeftSlotElements = Boolean(leftSlotElements === null || leftSlotElements === void 0 ? void 0 : leftSlotElements.length);
|
|
73
|
+
const hasRightSlotElements = Boolean(rightSlotElements === null || rightSlotElements === void 0 ? void 0 : rightSlotElements.length);
|
|
74
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
75
|
+
ref: inputRef,
|
|
76
|
+
className: "text-field-root ".concat(customClassWrapper),
|
|
77
|
+
"data-state-error": hasValidationErrors
|
|
78
|
+
}, hasLabel && /*#__PURE__*/_react.default.createElement("span", {
|
|
79
|
+
className: "root-label ".concat(customClassLabel),
|
|
80
|
+
"data-state-skeletonize": skeletonize
|
|
81
|
+
}, /*#__PURE__*/_react.default.createElement("label", {
|
|
82
|
+
className: "label",
|
|
83
|
+
title: label,
|
|
84
|
+
htmlFor: name,
|
|
85
|
+
"data-state-disabled": disabled,
|
|
86
|
+
"data-state-read-only": readOnly,
|
|
87
|
+
"data-state-input-required": props.required,
|
|
88
|
+
"data-state-label-uppercase": labelUppercase
|
|
89
|
+
}, label), hint && hintPosition === 'onLabelRight' && !skeletonize && /*#__PURE__*/_react.default.createElement(_popover.default, {
|
|
90
|
+
customClass: "label-popover",
|
|
91
|
+
theme: themePopover,
|
|
92
|
+
align: popoverAlign,
|
|
93
|
+
iconColor: "#03bde2"
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement(_popover.PopoverText, {
|
|
95
|
+
text: hint
|
|
96
|
+
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
97
|
+
"data-state-skeletonize": skeletonize,
|
|
98
|
+
className: "container ".concat(customClassInputContainer)
|
|
99
|
+
}, hasLeftSlotElements && !skeletonize && leftSlotElements, /*#__PURE__*/_react.default.createElement("input", _extends({
|
|
100
|
+
ref: ref,
|
|
101
|
+
id: name,
|
|
102
|
+
type: type,
|
|
103
|
+
readOnly: readOnly,
|
|
104
|
+
disabled: disabled,
|
|
105
|
+
className: "input ".concat(customClass),
|
|
106
|
+
tabIndex: !readOnly ? 0 : -1,
|
|
107
|
+
placeholder: rest.placeholder,
|
|
108
|
+
"data-state-error": hasValidationErrors,
|
|
109
|
+
"data-state-read-only": readOnly,
|
|
110
|
+
"data-state-text-align": textAlign,
|
|
111
|
+
"data-state-skeletonize": skeletonize
|
|
112
|
+
}, rest)), hasRightSlotElements && !skeletonize && rightSlotElements), hintPosition === 'below' && /*#__PURE__*/_react.default.createElement(_hint.default, {
|
|
113
|
+
customClass: "hint",
|
|
114
|
+
description: hint,
|
|
115
|
+
disabled: disabled,
|
|
116
|
+
skeletonize: skeletonize,
|
|
117
|
+
visible: hasHintMessages
|
|
118
|
+
}), hasValidationErrors && /*#__PURE__*/_react.default.createElement("span", {
|
|
119
|
+
className: "error",
|
|
120
|
+
"data-state-skeletonize": skeletonize,
|
|
121
|
+
"aria-describedby": String(name).concat('-errors')
|
|
122
|
+
}, errors === null || errors === void 0 ? void 0 : errors.map((error, index) => /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
123
|
+
key: "".concat(index + 1, "-").concat(error)
|
|
124
|
+
}, error, "\xA0")))), /*#__PURE__*/_react.default.createElement(_tooltip.Tooltip, {
|
|
125
|
+
targetRef: inputRef,
|
|
126
|
+
text: tooltip,
|
|
127
|
+
width: tooltipWidth,
|
|
128
|
+
position: tooltipPosition
|
|
129
|
+
}));
|
|
130
|
+
});
|
|
131
|
+
InputBase.displayName = 'TextFieldInputBase';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
import '../../@types/Align.js';
|
|
3
|
-
import '../../@types/ColorStyles.js';
|
|
4
|
-
import '../../@types/Position.js';
|
|
5
2
|
import '../../@types/PermissionAttr.js';
|
|
6
3
|
export { LeftSlot, RightSlot } from '../slot/index.js';
|
|
4
|
+
import './base.js';
|
|
5
|
+
export { I as Input, T as TextFieldInputProps } from '../../index-02a27c19.js';
|
|
7
6
|
import '../../tooltip/types.js';
|
|
8
|
-
|
|
7
|
+
import '../../@types/Position.js';
|
|
8
|
+
import '../../@types/Align.js';
|
|
9
|
+
import '../../@types/ColorStyles.js';
|