linear-react-components-ui 1.1.25-beta.7 → 1.1.25-beta.8
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-53bfd6ab.d.ts → Cnpj-8366781f.d.ts} +1 -2
- package/lib/{Cpf-019b21e0.d.ts → Cpf-3dfd54eb.d.ts} +1 -2
- 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/split.scss +1 -1
- package/lib/form2/useForm/index.js +21 -8
- 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-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 +17 -14
- package/lib/inputs2/mask/BaseMask.d.ts +6 -5
- package/lib/inputs2/mask/Cnpj.d.ts +7 -6
- package/lib/inputs2/mask/Cnpj.js +18 -21
- package/lib/inputs2/mask/Cpf.d.ts +7 -6
- package/lib/inputs2/mask/Cpf.js +12 -19
- 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.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/package.json +1 -1
- package/lib/index-19761a50.d.ts +0 -26
- package/lib/index-4bda404f.d.ts +0 -42
|
@@ -29,523 +29,56 @@ Object.defineProperty(exports, "RightSlot", {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
require("../../assets/styles/selectfield.scss");
|
|
32
|
-
var _react =
|
|
33
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
34
|
-
var _uuid = require("uuid");
|
|
35
|
-
var _reactDom = require("react-dom");
|
|
36
|
-
var _hint = _interopRequireDefault(require("../../hint"));
|
|
32
|
+
var _react = _interopRequireDefault(require("react"));
|
|
37
33
|
var _gridlayout = _interopRequireDefault(require("../../gridlayout"));
|
|
38
|
-
var _popover = _interopRequireWildcard(require("../../popover"));
|
|
39
|
-
var _tooltip = require("../../tooltip");
|
|
40
|
-
var _helpers = require("../../form2/helpers");
|
|
41
34
|
var _permissionValidations = require("../../permissionValidations");
|
|
42
35
|
var _slot = require("../slot");
|
|
43
|
-
var _listbox = require("./listbox");
|
|
44
|
-
var _triggers = require("./triggers");
|
|
45
|
-
var _selections = require("./selections");
|
|
46
|
-
var _context = require("./context");
|
|
47
36
|
var _options = require("./options");
|
|
48
37
|
var _item = require("./item");
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
const _excluded = ["
|
|
38
|
+
var _helpers = require("./helpers");
|
|
39
|
+
var _base = require("./base");
|
|
40
|
+
const _excluded = ["onDeniedActions", "permissionAttr", "gridLayout", "disabled", "readOnly"];
|
|
52
41
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
53
|
-
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); }
|
|
54
42
|
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); }
|
|
43
|
+
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; }
|
|
44
|
+
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; }
|
|
45
|
+
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; }
|
|
46
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
47
|
+
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); }
|
|
55
48
|
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; }
|
|
56
49
|
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; }
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
name,
|
|
62
|
-
label,
|
|
63
|
-
errors,
|
|
64
|
-
children,
|
|
50
|
+
const Input = exports.Input = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
51
|
+
let {
|
|
52
|
+
onDeniedActions,
|
|
53
|
+
permissionAttr,
|
|
65
54
|
gridLayout,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
hintPosition = 'below',
|
|
71
|
-
themePopover = 'light',
|
|
72
|
-
popoverAlign = 'left',
|
|
73
|
-
skeletonize = false,
|
|
74
|
-
striped = false,
|
|
75
|
-
undigitable = false,
|
|
76
|
-
externalSearch = false,
|
|
77
|
-
openDropdownOnFocus = true,
|
|
78
|
-
showClearButton = true,
|
|
79
|
-
textAlign = 'left',
|
|
80
|
-
searchOnDropdown = false,
|
|
81
|
-
onSearch = undefined,
|
|
82
|
-
permissionAttr = undefined,
|
|
83
|
-
customClass = '',
|
|
84
|
-
customClassLabel = '',
|
|
85
|
-
customClassWrapper = '',
|
|
86
|
-
customClassInputContainer = '',
|
|
87
|
-
onDeniedActions = undefined,
|
|
88
|
-
notFoundFilterLabel = 'Nenhuma opção encontrada.',
|
|
89
|
-
multipleInputLabelEmpty = 'Nenhum registro selecionado',
|
|
90
|
-
multipleInputLabelManySelection = 'Múltiplos registros selecionados',
|
|
91
|
-
searchInputPlaceholder = 'Pesquisar registros',
|
|
92
|
-
dropdownAlignButton = 'left'
|
|
93
|
-
} = props,
|
|
94
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
55
|
+
disabled,
|
|
56
|
+
readOnly
|
|
57
|
+
} = _ref,
|
|
58
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
95
59
|
const onDenied = _react.default.useMemo(() => {
|
|
96
|
-
return onDeniedActions || (0, _permissionValidations.actionsOnPermissionDenied)(
|
|
60
|
+
return onDeniedActions || (0, _permissionValidations.actionsOnPermissionDenied)(_helpers.options, permissionAttr);
|
|
97
61
|
}, [onDeniedActions, permissionAttr]);
|
|
98
62
|
const {
|
|
99
63
|
hideContent,
|
|
100
64
|
unvisible
|
|
101
65
|
} = onDenied;
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
optionsMap.set(child.props.value, child.props.label);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
return optionsMap;
|
|
123
|
-
}, [children]);
|
|
124
|
-
_react.default.useEffect(() => {
|
|
125
|
-
if (isMultipleWithCheckboxes) {
|
|
126
|
-
setInputValue(multipleInputLabelEmpty);
|
|
127
|
-
}
|
|
128
|
-
}, []);
|
|
129
|
-
_react.default.useEffect(() => {
|
|
130
|
-
if (openDropdownOnFocus && listBoxOpen) {
|
|
131
|
-
requestAnimationFrame(() => {
|
|
132
|
-
if (isMultipleWithCheckboxes) {
|
|
133
|
-
var _selectSearchInputRef, _selectSearchInputRef2;
|
|
134
|
-
(_selectSearchInputRef = selectSearchInputRef.current) === null || _selectSearchInputRef === void 0 ? void 0 : (_selectSearchInputRef2 = _selectSearchInputRef.focus) === null || _selectSearchInputRef2 === void 0 ? void 0 : _selectSearchInputRef2.call(_selectSearchInputRef);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}, [listBoxOpen]);
|
|
139
|
-
_react.default.useEffect(() => {
|
|
140
|
-
if (!isMultipleWithCheckboxes && !(props !== null && props !== void 0 && props.value)) setInputValue('');
|
|
141
|
-
if (!(props !== null && props !== void 0 && props.value) || document.activeElement === selectInputRef.current) return;
|
|
142
|
-
const lazyInputValue = listOptionsMap.get(rest.value);
|
|
143
|
-
if (!isMultipleWithCheckboxes) setInputValue(lazyInputValue !== null && lazyInputValue !== void 0 ? lazyInputValue : '');
|
|
144
|
-
if (isMultipleWithCheckboxes) {
|
|
145
|
-
const firstSelectionLabel = listOptionsMap.get(props === null || props === void 0 ? void 0 : props.value[0]);
|
|
146
|
-
switch (_lodash.default.size(props === null || props === void 0 ? void 0 : props.value)) {
|
|
147
|
-
case 0:
|
|
148
|
-
return setInputValue(multipleInputLabelEmpty);
|
|
149
|
-
case 1:
|
|
150
|
-
return setInputValue(firstSelectionLabel !== null && firstSelectionLabel !== void 0 ? firstSelectionLabel : '');
|
|
151
|
-
default:
|
|
152
|
-
return setInputValue(multipleInputLabelManySelection);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}, [props === null || props === void 0 ? void 0 : props.value, listOptionsMap]);
|
|
156
|
-
const hasLabel = !_lodash.default.isEmpty(props === null || props === void 0 ? void 0 : props.label);
|
|
157
|
-
const hasHintMessages = Boolean((_props$hint = props.hint) === null || _props$hint === void 0 ? void 0 : _props$hint.length);
|
|
158
|
-
const hasValidationErrors = Boolean(errors === null || errors === void 0 ? void 0 : errors.length);
|
|
159
|
-
const isReadOnly = Boolean(props.readOnly || onDenied.readOnly);
|
|
160
|
-
const isDisabled = Boolean(props.disabled || onDenied.disabled);
|
|
161
|
-
const {
|
|
162
|
-
childrenItems
|
|
163
|
-
} = _react.default.useMemo(() => {
|
|
164
|
-
const itens = [];
|
|
165
|
-
_react.default.Children.map(children, (childElement, index) => {
|
|
166
|
-
if (/*#__PURE__*/_react.default.isValidElement(childElement)) {
|
|
167
|
-
var _childElement$key;
|
|
168
|
-
const clonedChild = /*#__PURE__*/_react.default.cloneElement(childElement, {
|
|
169
|
-
key: (_childElement$key = childElement.key) !== null && _childElement$key !== void 0 ? _childElement$key : "child-item-".concat(index + 1)
|
|
170
|
-
});
|
|
171
|
-
if (childElement.type === _item.Item) itens.push(clonedChild);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
return {
|
|
175
|
-
childrenItems: itens
|
|
176
|
-
};
|
|
177
|
-
}, [children, isDisabled]);
|
|
178
|
-
const {
|
|
179
|
-
leftSlotElements,
|
|
180
|
-
rightSlotElements
|
|
181
|
-
} = _react.default.useMemo(() => {
|
|
182
|
-
const left = [];
|
|
183
|
-
const right = [];
|
|
184
|
-
_react.default.Children.map(children, (childElement, index) => {
|
|
185
|
-
if (/*#__PURE__*/_react.default.isValidElement(childElement)) {
|
|
186
|
-
var _childElement$key2;
|
|
187
|
-
const clonedChild = /*#__PURE__*/_react.default.cloneElement(childElement, {
|
|
188
|
-
key: (_childElement$key2 = childElement.key) !== null && _childElement$key2 !== void 0 ? _childElement$key2 : "slot-".concat(index),
|
|
189
|
-
disabled: isDisabled,
|
|
190
|
-
'aria-disabled': isDisabled
|
|
191
|
-
});
|
|
192
|
-
if (childElement.type === _slot.LeftSlot) left.push(clonedChild);
|
|
193
|
-
if (childElement.type === _slot.RightSlot) right.push(clonedChild);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
return {
|
|
197
|
-
leftSlotElements: left,
|
|
198
|
-
rightSlotElements: right
|
|
199
|
-
};
|
|
200
|
-
}, [children, isDisabled]);
|
|
201
|
-
const {
|
|
202
|
-
optionItens
|
|
203
|
-
} = _react.default.useMemo(() => {
|
|
204
|
-
const itens = [];
|
|
205
|
-
_react.default.Children.map(children, (childElement, index) => {
|
|
206
|
-
if (/*#__PURE__*/_react.default.isValidElement(childElement)) {
|
|
207
|
-
var _childElement$key3;
|
|
208
|
-
const clonedChildItem = /*#__PURE__*/_react.default.cloneElement(childElement, {
|
|
209
|
-
key: (_childElement$key3 = childElement.key) !== null && _childElement$key3 !== void 0 ? _childElement$key3 : "option-list-".concat(index),
|
|
210
|
-
disabled: isDisabled
|
|
211
|
-
});
|
|
212
|
-
if (childElement.type === _options.Options) itens.push(clonedChildItem);
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
return {
|
|
216
|
-
optionItens: itens
|
|
217
|
-
};
|
|
218
|
-
}, [children, isDisabled]);
|
|
219
|
-
const hasLeftSlotElements = Boolean(leftSlotElements === null || leftSlotElements === void 0 ? void 0 : leftSlotElements.length);
|
|
220
|
-
const hasRightSlotElements = Boolean(rightSlotElements === null || rightSlotElements === void 0 ? void 0 : rightSlotElements.length);
|
|
221
|
-
const handleCloseListBox = () => {
|
|
222
|
-
setListBoxOpen(false);
|
|
223
|
-
setFilterValue('');
|
|
224
|
-
};
|
|
225
|
-
const handleOpenListBox = () => {
|
|
226
|
-
var _$toString;
|
|
227
|
-
const currentValue = !isMultipleSelect ? props === null || props === void 0 ? void 0 : props.value : _lodash.default.orderBy([...props.value], value => _lodash.default.toNumber(value), ['asc'])[0];
|
|
228
|
-
setActiveDescendant((_$toString = _lodash.default.toString(currentValue)) !== null && _$toString !== void 0 ? _$toString : undefined);
|
|
229
|
-
};
|
|
230
|
-
const handleChangeListBoxState = () => {
|
|
231
|
-
setListBoxOpen(prevState => {
|
|
232
|
-
if (prevState) {
|
|
233
|
-
setFilterValue('');
|
|
234
|
-
}
|
|
235
|
-
if (selectInputRef.current !== document.activeElement) {
|
|
236
|
-
var _selectInputRef$curre, _selectInputRef$curre2;
|
|
237
|
-
selectInputRef === null || selectInputRef === void 0 ? void 0 : (_selectInputRef$curre = selectInputRef.current) === null || _selectInputRef$curre === void 0 ? void 0 : (_selectInputRef$curre2 = _selectInputRef$curre.focus) === null || _selectInputRef$curre2 === void 0 ? void 0 : _selectInputRef$curre2.call(_selectInputRef$curre);
|
|
238
|
-
}
|
|
239
|
-
return !prevState;
|
|
240
|
-
});
|
|
241
|
-
};
|
|
242
|
-
const handleChangeLiSelected = liElement => {
|
|
243
|
-
liSelectedRef.current = liElement;
|
|
244
|
-
};
|
|
245
|
-
const handleOnChange = (value, inputLabel, addOrRemove) => {
|
|
246
|
-
let multipleValue = props === null || props === void 0 ? void 0 : props.value;
|
|
247
|
-
if (!addOrRemove) multipleValue = _lodash.default.union(props.value, [value]);
|
|
248
|
-
if (addOrRemove) multipleValue = _lodash.default.without(props.value, value);
|
|
249
|
-
const changedValue = !isMultipleSelect ? value : _lodash.default.orderBy(multipleValue, multiValue => _lodash.default.toNumber(multiValue), ['asc']);
|
|
250
|
-
const syntheticEvent = {
|
|
251
|
-
target: {
|
|
252
|
-
name,
|
|
253
|
-
value: changedValue
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(syntheticEvent);
|
|
257
|
-
if (!isMultipleSelect) {
|
|
258
|
-
setListBoxOpen(false);
|
|
259
|
-
setFilterValue('');
|
|
260
|
-
setInputValue(inputLabel !== null && inputLabel !== void 0 ? inputLabel : '');
|
|
261
|
-
if (document.activeElement === selectSearchInputRef.current) {
|
|
262
|
-
var _selectInputRef$curre3, _selectInputRef$curre4;
|
|
263
|
-
selectInputRef === null || selectInputRef === void 0 ? void 0 : (_selectInputRef$curre3 = selectInputRef.current) === null || _selectInputRef$curre3 === void 0 ? void 0 : (_selectInputRef$curre4 = _selectInputRef$curre3.focus) === null || _selectInputRef$curre4 === void 0 ? void 0 : _selectInputRef$curre4.call(_selectInputRef$curre3);
|
|
264
|
-
setListBoxOpen(false);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
const handleCheckMultiple = checkOrUncheckAll => {
|
|
269
|
-
const checkAll = Boolean(checkOrUncheckAll);
|
|
270
|
-
let allValues = [];
|
|
271
|
-
listOptionsMap.forEach((__, key) => allValues.push(key));
|
|
272
|
-
const value = checkAll ? allValues : [];
|
|
273
|
-
const syntheticEvent = {
|
|
274
|
-
target: {
|
|
275
|
-
name,
|
|
276
|
-
value
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(syntheticEvent);
|
|
280
|
-
};
|
|
281
|
-
const handleClearValue = () => {
|
|
282
|
-
const resetValue = !isMultipleSelect ? '' : [];
|
|
283
|
-
const syntheticEvent = {
|
|
284
|
-
target: {
|
|
285
|
-
name,
|
|
286
|
-
value: resetValue
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(syntheticEvent);
|
|
290
|
-
setListBoxOpen(false);
|
|
291
|
-
if (!isMultipleSelect) {
|
|
292
|
-
setFilterValue('');
|
|
293
|
-
setInputValue('');
|
|
294
|
-
}
|
|
295
|
-
if (isMultipleWithCheckboxes) {
|
|
296
|
-
setInputValue(multipleInputLabelEmpty);
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
const handleOnBlur = event => {
|
|
300
|
-
var _props$onBlur;
|
|
301
|
-
props === null || props === void 0 ? void 0 : (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 ? void 0 : _props$onBlur.call(props, event);
|
|
302
|
-
if (!event.relatedTarget || event.relatedTarget !== selectSearchInputRef.current) {
|
|
303
|
-
setListBoxOpen(false);
|
|
304
|
-
}
|
|
305
|
-
setFilterValue('');
|
|
306
|
-
};
|
|
307
|
-
const handleOnFocus = event => {
|
|
308
|
-
var _props$onFocus;
|
|
309
|
-
props === null || props === void 0 ? void 0 : (_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 ? void 0 : _props$onFocus.call(props, event);
|
|
310
|
-
if (openDropdownOnFocus) {
|
|
311
|
-
setListBoxOpen(true);
|
|
312
|
-
handleOpenListBox();
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
const handleOnChangeInput = event => {
|
|
316
|
-
setFilterValue(event.target.value);
|
|
317
|
-
setInputValue(event.target.value);
|
|
318
|
-
};
|
|
319
|
-
const handleOnPaste = event => {
|
|
320
|
-
if (undigitable || isMultipleWithCheckboxes) {
|
|
321
|
-
event.preventDefault();
|
|
322
|
-
} else {
|
|
323
|
-
var _props$onPaste;
|
|
324
|
-
(_props$onPaste = props.onPaste) === null || _props$onPaste === void 0 ? void 0 : _props$onPaste.call(props, event);
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
const handleOnBeforeInput = event => {
|
|
328
|
-
if (undigitable || isMultipleWithCheckboxes) {
|
|
329
|
-
event.preventDefault();
|
|
330
|
-
} else {
|
|
331
|
-
var _props$onBeforeInput;
|
|
332
|
-
(_props$onBeforeInput = props.onBeforeInput) === null || _props$onBeforeInput === void 0 ? void 0 : _props$onBeforeInput.call(props, event);
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
const handleOnSearch = event => {
|
|
336
|
-
if (externalSearch) {
|
|
337
|
-
onSearch === null || onSearch === void 0 ? void 0 : onSearch(event);
|
|
338
|
-
} else {
|
|
339
|
-
setFilterValue(event.target.value);
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
const handleOnKeyDown = event => {
|
|
343
|
-
var _props$onKeyDown;
|
|
344
|
-
props === null || props === void 0 ? void 0 : (_props$onKeyDown = props.onKeyDown) === null || _props$onKeyDown === void 0 ? void 0 : _props$onKeyDown.call(props, event);
|
|
345
|
-
const notUndigitableKeys = [_types.Keys.backspace, _types.Keys.delete];
|
|
346
|
-
if (undigitable && notUndigitableKeys.includes(event.key)) {
|
|
347
|
-
event.preventDefault();
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
const shouldOpenByTyping = (0, _helpers2.isTypingKey)(event) || event.key === _types.Keys.arrowDown;
|
|
351
|
-
if (shouldOpenByTyping && selectInputRef.current === document.activeElement) {
|
|
352
|
-
if (event.key === _types.Keys.arrowDown) {
|
|
353
|
-
event.preventDefault();
|
|
354
|
-
}
|
|
355
|
-
requestAnimationFrame(() => {
|
|
356
|
-
var _selectListBoxRef$cur, _ulListElement$queryS;
|
|
357
|
-
const ulListElement = (_selectListBoxRef$cur = selectListBoxRef.current) === null || _selectListBoxRef$cur === void 0 ? void 0 : _selectListBoxRef$cur.querySelector('ul[role="listbox"]');
|
|
358
|
-
const liElementsFiltered = (_ulListElement$queryS = ulListElement === null || ulListElement === void 0 ? void 0 : ulListElement.querySelectorAll('li[data-state-filtered="true"]')) !== null && _ulListElement$queryS !== void 0 ? _ulListElement$queryS : [];
|
|
359
|
-
if (!listBoxOpen && event.key === _types.Keys.arrowDown) {
|
|
360
|
-
var _$toString2;
|
|
361
|
-
const currentValue = !isMultipleSelect ? props === null || props === void 0 ? void 0 : props.value : _lodash.default.orderBy([...props.value], value => _lodash.default.toNumber(value), ['asc'])[0];
|
|
362
|
-
setActiveDescendant((_$toString2 = _lodash.default.toString(currentValue)) !== null && _$toString2 !== void 0 ? _$toString2 : undefined);
|
|
363
|
-
} else {
|
|
364
|
-
var _liElementsFiltered$, _liElementsFiltered$2;
|
|
365
|
-
setActiveDescendant((_liElementsFiltered$ = (_liElementsFiltered$2 = liElementsFiltered[0]) === null || _liElementsFiltered$2 === void 0 ? void 0 : _liElementsFiltered$2.id) !== null && _liElementsFiltered$ !== void 0 ? _liElementsFiltered$ : undefined);
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
if (!listBoxOpen) {
|
|
369
|
-
setListBoxOpen(true);
|
|
370
|
-
handleOpenListBox();
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
if (listBoxOpen && _helpers2.NAVIGATION_KEYS.includes(event.key)) {
|
|
374
|
-
event.preventDefault();
|
|
375
|
-
}
|
|
376
|
-
requestAnimationFrame(() => {
|
|
377
|
-
var _selectListBoxRef$cur2, _ulListElement$queryS2, _selectInputRef$curre5;
|
|
378
|
-
const ulListElement = (_selectListBoxRef$cur2 = selectListBoxRef.current) === null || _selectListBoxRef$cur2 === void 0 ? void 0 : _selectListBoxRef$cur2.querySelector('ul[role="listbox"]');
|
|
379
|
-
const liElementsFiltered = (_ulListElement$queryS2 = ulListElement === null || ulListElement === void 0 ? void 0 : ulListElement.querySelectorAll('li[data-state-filtered="true"]')) !== null && _ulListElement$queryS2 !== void 0 ? _ulListElement$queryS2 : [];
|
|
380
|
-
const currentElementIndex = Array.from(liElementsFiltered).findIndex(liElement => liElement.id === activeDescendant);
|
|
381
|
-
let nextElementIndex = currentElementIndex;
|
|
382
|
-
if (listBoxOpen) {
|
|
383
|
-
if (_helpers2.NAVIGATION_KEYS.includes(event.key)) {
|
|
384
|
-
switch (event.key) {
|
|
385
|
-
case _types.Keys.escape:
|
|
386
|
-
setListBoxOpen(false);
|
|
387
|
-
setFilterValue('');
|
|
388
|
-
(_selectInputRef$curre5 = selectInputRef.current) === null || _selectInputRef$curre5 === void 0 ? void 0 : _selectInputRef$curre5.focus();
|
|
389
|
-
if (event.target === selectSearchInputRef.current) {
|
|
390
|
-
setListBoxOpen(false);
|
|
391
|
-
}
|
|
392
|
-
break;
|
|
393
|
-
case _types.Keys.arrowDown:
|
|
394
|
-
nextElementIndex = Math.min(currentElementIndex + 1, liElementsFiltered.length - 1);
|
|
395
|
-
break;
|
|
396
|
-
case _types.Keys.arrowUp:
|
|
397
|
-
nextElementIndex = Math.max(currentElementIndex - 1, 0);
|
|
398
|
-
break;
|
|
399
|
-
case _types.Keys.enter:
|
|
400
|
-
if (activeDescendant) {
|
|
401
|
-
const selectedLIOption = liElementsFiltered[nextElementIndex];
|
|
402
|
-
if (selectedLIOption) {
|
|
403
|
-
selectedLIOption.click();
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
break;
|
|
407
|
-
default:
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
const nextLIOption = liElementsFiltered[nextElementIndex];
|
|
411
|
-
if (nextLIOption) {
|
|
412
|
-
var _nextLIOption$id;
|
|
413
|
-
setActiveDescendant((_nextLIOption$id = nextLIOption === null || nextLIOption === void 0 ? void 0 : nextLIOption.id) !== null && _nextLIOption$id !== void 0 ? _nextLIOption$id : '');
|
|
414
|
-
nextLIOption.scrollIntoView({
|
|
415
|
-
block: 'nearest'
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
} else return null;
|
|
420
|
-
});
|
|
421
|
-
};
|
|
422
|
-
const contextValues = _react.default.useMemo(() => ({
|
|
423
|
-
selectFieldId: SELECT_FIELD_CONTROLS_ID,
|
|
424
|
-
label: props.label,
|
|
425
|
-
striped,
|
|
426
|
-
listBoxOpen,
|
|
427
|
-
filterValue,
|
|
428
|
-
isDisabled,
|
|
429
|
-
liSelectedRef,
|
|
430
|
-
selectInputRef,
|
|
431
|
-
selectSearchInputRef,
|
|
432
|
-
handleOnSearch,
|
|
433
|
-
searchOnDropdown,
|
|
434
|
-
nameSelect: String(props.name),
|
|
435
|
-
valueSelect: props === null || props === void 0 ? void 0 : props.value,
|
|
436
|
-
activeDescendant,
|
|
437
|
-
handleOnChange,
|
|
438
|
-
handleOnKeyDown,
|
|
439
|
-
selectContainerRef,
|
|
440
|
-
handleCloseListBox,
|
|
441
|
-
notFoundFilterLabel,
|
|
442
|
-
handleChangeLiSelected,
|
|
443
|
-
isMultipleSelect,
|
|
444
|
-
isMultipleDefault,
|
|
445
|
-
isMultipleWithCheckboxes,
|
|
446
|
-
searchInputPlaceholder,
|
|
447
|
-
showClearButton,
|
|
448
|
-
dropdownAlignButton,
|
|
449
|
-
handleClearValue,
|
|
450
|
-
handleCheckMultiple,
|
|
451
|
-
handleChangeListBoxState,
|
|
452
|
-
optionItens
|
|
453
|
-
}), [striped, listBoxOpen, isDisabled, filterValue, props === null || props === void 0 ? void 0 : props.name, props === null || props === void 0 ? void 0 : props.value, activeDescendant, notFoundFilterLabel, searchOnDropdown, isMultipleSelect, showClearButton, isMultipleDefault, isMultipleWithCheckboxes, searchInputPlaceholder, dropdownAlignButton, optionItens]);
|
|
454
|
-
if (unvisible || hideContent) return null;
|
|
455
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
|
|
456
|
-
cols: gridLayout
|
|
457
|
-
}, /*#__PURE__*/_react.default.createElement(_context.SelectFieldContext.Provider, {
|
|
458
|
-
value: contextValues
|
|
459
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
460
|
-
ref: selectFieldRoot,
|
|
461
|
-
"data-testid": "test-select-field-root",
|
|
462
|
-
className: "select-field-root ".concat(customClassWrapper),
|
|
463
|
-
"data-state-error": hasValidationErrors,
|
|
464
|
-
"data-state-hint-position": hintPosition
|
|
465
|
-
}, hasLabel && /*#__PURE__*/_react.default.createElement("span", {
|
|
466
|
-
className: "root-label ".concat(customClassLabel),
|
|
467
|
-
"data-state-skeletonize": skeletonize
|
|
468
|
-
}, /*#__PURE__*/_react.default.createElement("label", {
|
|
469
|
-
"data-testid": "test-select-field-label",
|
|
470
|
-
className: "label",
|
|
471
|
-
title: label,
|
|
472
|
-
htmlFor: name,
|
|
473
|
-
"aria-disabled": isDisabled,
|
|
474
|
-
"aria-readonly": isReadOnly,
|
|
475
|
-
"data-state-input-required": props.required
|
|
476
|
-
}, label), hasHintMessages && hintPosition === 'onLabelRight' && !skeletonize && /*#__PURE__*/_react.default.createElement(_popover.default, {
|
|
477
|
-
customClass: "label-popover",
|
|
478
|
-
theme: themePopover,
|
|
479
|
-
align: popoverAlign,
|
|
480
|
-
iconColor: "#03bde2"
|
|
481
|
-
}, /*#__PURE__*/_react.default.createElement(_popover.PopoverText, {
|
|
482
|
-
text: (_props$hint2 = props === null || props === void 0 ? void 0 : props.hint) !== null && _props$hint2 !== void 0 ? _props$hint2 : ''
|
|
483
|
-
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
484
|
-
ref: selectContainerRef,
|
|
485
|
-
className: "container ".concat(customClassInputContainer),
|
|
486
|
-
"aria-expanded": listBoxOpen,
|
|
487
|
-
"data-state-skeletonize": skeletonize
|
|
488
|
-
}, hasLeftSlotElements && !skeletonize && leftSlotElements, /*#__PURE__*/_react.default.createElement("div", {
|
|
489
|
-
className: "input-root"
|
|
490
|
-
}, /*#__PURE__*/_react.default.createElement("input", _extends({}, rest, {
|
|
491
|
-
ref: (0, _helpers.mergeRefs)(ref, selectInputRef),
|
|
492
|
-
readOnly: props.readOnly || undigitable,
|
|
493
|
-
className: "input ".concat(customClass),
|
|
494
|
-
placeholder: rest.placeholder,
|
|
495
|
-
"data-state-error": hasValidationErrors,
|
|
496
|
-
"data-state-multiple": isMultipleSelect,
|
|
497
|
-
"data-state-read-only": isReadOnly,
|
|
498
|
-
"data-state-text-align": textAlign,
|
|
499
|
-
"data-state-undigitable": undigitable,
|
|
500
|
-
"data-state-skeletonize": skeletonize,
|
|
501
|
-
"data-state-multiple-with-checkboxes": isMultipleWithCheckboxes,
|
|
502
|
-
id: name,
|
|
503
|
-
type: "text",
|
|
504
|
-
role: "combobox",
|
|
505
|
-
multiple: false,
|
|
506
|
-
"data-testid": "test-select-field-input",
|
|
507
|
-
"aria-autocomplete": "list",
|
|
508
|
-
"aria-expanded": listBoxOpen,
|
|
509
|
-
"aria-controls": SELECT_FIELD_CONTROLS_ID,
|
|
510
|
-
"aria-activedescendant": activeDescendant,
|
|
511
|
-
tabIndex: !isReadOnly && !skeletonize ? 0 : -1,
|
|
512
|
-
value: inputValue,
|
|
513
|
-
onBlur: handleOnBlur,
|
|
514
|
-
onFocus: handleOnFocus,
|
|
515
|
-
onKeyDown: handleOnKeyDown,
|
|
516
|
-
onChange: handleOnChangeInput,
|
|
517
|
-
onPaste: handleOnPaste,
|
|
518
|
-
onBeforeInput: handleOnBeforeInput
|
|
519
|
-
})), isMultipleDefault && /*#__PURE__*/_react.default.createElement(_selections.Selections, {
|
|
520
|
-
isDisabled: isDisabled,
|
|
521
|
-
isReadOnly: isReadOnly,
|
|
522
|
-
listOfOptionsToSelect: listOptionsMap
|
|
523
|
-
})), hasRightSlotElements && !skeletonize && rightSlotElements, /*#__PURE__*/_react.default.createElement("div", {
|
|
524
|
-
className: "triggers",
|
|
525
|
-
"data-state-disabled": isDisabled,
|
|
526
|
-
"data-state-read-only": isReadOnly,
|
|
527
|
-
"data-state-skeletonize": skeletonize
|
|
528
|
-
}, /*#__PURE__*/_react.default.createElement(_triggers.Triggers, null)), listBoxOpen && !hideContent && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement(_listbox.ListBox, {
|
|
529
|
-
ref: selectListBoxRef
|
|
530
|
-
}, childrenItems), document.body)), hintPosition === 'below' && /*#__PURE__*/_react.default.createElement(_hint.default, {
|
|
531
|
-
customClass: "hint",
|
|
532
|
-
skeletonize: skeletonize,
|
|
533
|
-
description: props.hint,
|
|
534
|
-
disabled: isDisabled,
|
|
535
|
-
visible: hasHintMessages
|
|
536
|
-
}), hasValidationErrors && /*#__PURE__*/_react.default.createElement("span", {
|
|
537
|
-
"data-testid": "test-select-field-list-errors",
|
|
538
|
-
className: "error",
|
|
539
|
-
"data-state-skeletonize": skeletonize,
|
|
540
|
-
"aria-describedby": String(name).concat('-errors')
|
|
541
|
-
}, errors === null || errors === void 0 ? void 0 : errors.map((error, index) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
542
|
-
key: "".concat(index + 1, "-").concat(error)
|
|
543
|
-
}, error, "\xA0")))))), /*#__PURE__*/_react.default.createElement(_tooltip.Tooltip, {
|
|
544
|
-
targetRef: selectInputRef,
|
|
545
|
-
text: tooltip,
|
|
546
|
-
position: tooltipPosition,
|
|
547
|
-
width: tooltipWidth,
|
|
548
|
-
space: tooltipPosition === 'right' ? 64 : undefined
|
|
549
|
-
}));
|
|
66
|
+
const isReadOnly = Boolean(readOnly || onDenied.readOnly);
|
|
67
|
+
const isDisabled = Boolean(disabled || onDenied.disabled);
|
|
68
|
+
const inputProps = _objectSpread({
|
|
69
|
+
readOnly: isReadOnly,
|
|
70
|
+
disabled: isDisabled
|
|
71
|
+
}, props);
|
|
72
|
+
if (hideContent || unvisible) return null;
|
|
73
|
+
if (gridLayout) {
|
|
74
|
+
return /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
|
|
75
|
+
cols: gridLayout
|
|
76
|
+
}, /*#__PURE__*/_react.default.createElement(_base.InputBase, _extends({
|
|
77
|
+
ref: ref
|
|
78
|
+
}, inputProps)));
|
|
79
|
+
}
|
|
80
|
+
return /*#__PURE__*/_react.default.createElement(_base.InputBase, _extends({
|
|
81
|
+
ref: ref
|
|
82
|
+
}, inputProps));
|
|
550
83
|
});
|
|
551
84
|
Input.displayName = 'SelectFieldInput';
|
|
@@ -18,8 +18,13 @@ declare enum Keys {
|
|
|
18
18
|
delete = "Delete",
|
|
19
19
|
spaceBar = " "
|
|
20
20
|
}
|
|
21
|
-
type InputHTMLProps = Omit<React.
|
|
22
|
-
interface SelectFieldInputProps extends
|
|
21
|
+
type InputHTMLProps = Omit<React.ComponentPropsWithoutRef<'input'>, 'multiple' | 'type'>;
|
|
22
|
+
interface SelectFieldInputProps extends SelectFieldInputBaseProps {
|
|
23
|
+
gridLayout?: string;
|
|
24
|
+
permissionAttr?: PermissionAttr;
|
|
25
|
+
onDeniedActions?: OnDenied;
|
|
26
|
+
}
|
|
27
|
+
interface SelectFieldInputBaseProps extends InputHTMLProps, ITooltipCommonProps {
|
|
23
28
|
skeletonize?: boolean;
|
|
24
29
|
undigitable?: boolean;
|
|
25
30
|
externalSearch?: boolean;
|
|
@@ -31,7 +36,6 @@ interface SelectFieldInputProps extends InputHTMLProps, ITooltipCommonProps {
|
|
|
31
36
|
errors?: string[];
|
|
32
37
|
striped?: boolean;
|
|
33
38
|
hint?: string;
|
|
34
|
-
gridLayout?: string;
|
|
35
39
|
notFoundFilterLabel?: string;
|
|
36
40
|
customClass?: string;
|
|
37
41
|
customClassLabel?: string;
|
|
@@ -44,11 +48,9 @@ interface SelectFieldInputProps extends InputHTMLProps, ITooltipCommonProps {
|
|
|
44
48
|
hintPosition?: HintPosition;
|
|
45
49
|
themePopover?: ColorTheme;
|
|
46
50
|
popoverAlign?: Extract<Position, 'left' | 'right'>;
|
|
47
|
-
permissionAttr?: PermissionAttr;
|
|
48
|
-
onDeniedActions?: OnDenied;
|
|
49
51
|
dropdownAlignButton?: Extract<Position, 'left' | 'right'>;
|
|
50
52
|
onSearch?: (event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
51
53
|
multiple?: keyof typeof MultipleVariantEnum;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
export { Keys, MultipleVariantEnum, SelectFieldInputProps };
|
|
56
|
+
export { Keys, MultipleVariantEnum, SelectFieldInputBaseProps, SelectFieldInputProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { TextAlign } from '../../@types/Align.js';
|
|
3
|
+
import { ColorTheme } from '../../@types/ColorStyles.js';
|
|
4
|
+
import { HintPosition, Position } from '../../@types/Position.js';
|
|
5
|
+
import { ITooltipCommonProps } from '../../tooltip/types.js';
|
|
6
|
+
|
|
7
|
+
interface TextAreaFieldInputBaseProps extends React__default.ComponentPropsWithoutRef<'textarea'>, 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<TextAreaFieldInputBaseProps & React__default.RefAttributes<HTMLTextAreaElement>>;
|
|
25
|
+
|
|
26
|
+
export { InputBase, TextAreaFieldInputBaseProps };
|