@dxc-technology/halstack-react 6.2.2 → 7.0.0
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/accordion/types.d.ts +1 -0
- package/accordion-group/types.d.ts +1 -0
- package/box/types.d.ts +1 -0
- package/card/types.d.ts +1 -0
- package/common/variables.js +5 -5
- package/dialog/types.d.ts +1 -0
- package/dropdown/Dropdown.js +3 -2
- package/dropdown/Dropdown.test.js +1 -2
- package/file-input/FileInput.js +13 -5
- package/file-input/FileInput.test.js +41 -0
- package/flex/Flex.d.ts +1 -1
- package/flex/Flex.js +31 -19
- package/flex/types.d.ts +14 -3
- package/footer/types.d.ts +1 -0
- package/header/types.d.ts +1 -0
- package/number-input/NumberInput.test.js +38 -1
- package/package.json +1 -1
- package/paginator/Paginator.js +2 -2
- package/paginator/Paginator.test.js +1 -1
- package/password-input/PasswordInput.test.js +13 -12
- package/quick-nav/QuickNav.js +11 -12
- package/quick-nav/QuickNav.stories.tsx +97 -19
- package/radio-group/RadioGroup.js +9 -5
- package/radio-group/RadioGroup.test.js +116 -59
- package/resultsetTable/ResultsetTable.js +1 -3
- package/select/Select.js +3 -1
- package/select/Select.test.js +267 -209
- package/table/Table.js +1 -1
- package/text-input/TextInput.js +165 -151
- package/text-input/TextInput.test.js +140 -82
- package/text-input/types.d.ts +5 -0
package/table/Table.js
CHANGED
|
@@ -66,7 +66,7 @@ var DxcTableContainer = _styledComponents["default"].div(_templateObject || (_te
|
|
|
66
66
|
return props.theme.scrollBarTrackColor;
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
var DxcTableContent = _styledComponents["default"].table(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n border-collapse: collapse;\n width: 100%;\n\n & tr {\n border-bottom: ", ";\n }\n & td {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th:first-child {\n border-top-left-radius: ", ";\n }\n & th:last-child {\n border-top-right-radius: ", ";\n }\n"])), function (props) {
|
|
69
|
+
var DxcTableContent = _styledComponents["default"].table(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n border-collapse: collapse;\n width: 100%;\n\n & tr {\n border-bottom: ", ";\n height: 60px;\n }\n & td {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th:first-child {\n border-top-left-radius: ", ";\n }\n & th:last-child {\n border-top-right-radius: ", ";\n }\n & td:last-child {\n padding-right: 40px;\n }\n"])), function (props) {
|
|
70
70
|
return "".concat(props.theme.rowSeparatorThickness, " ").concat(props.theme.rowSeparatorStyle, " ").concat(props.theme.rowSeparatorColor);
|
|
71
71
|
}, function (props) {
|
|
72
72
|
return props.theme.dataBackgroundColor;
|
package/text-input/TextInput.js
CHANGED
|
@@ -52,6 +52,13 @@ var sizes = {
|
|
|
52
52
|
fillParent: "100%"
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
+
var AutosuggestWrapper = function AutosuggestWrapper(_ref) {
|
|
56
|
+
var condition = _ref.condition,
|
|
57
|
+
wrapper = _ref.wrapper,
|
|
58
|
+
children = _ref.children;
|
|
59
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, condition ? wrapper(children) : children);
|
|
60
|
+
};
|
|
61
|
+
|
|
55
62
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
56
63
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
57
64
|
};
|
|
@@ -77,81 +84,99 @@ var makeCancelable = function makeCancelable(promise) {
|
|
|
77
84
|
};
|
|
78
85
|
};
|
|
79
86
|
|
|
87
|
+
var hasSuggestions = function hasSuggestions(suggestions) {
|
|
88
|
+
return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
var isNotOptional = function isNotOptional(value, optional) {
|
|
92
|
+
return value === "" && !optional;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
var isLengthIncorrect = function isLengthIncorrect(value, minLength, maxLength) {
|
|
96
|
+
return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
var isNumberIncorrect = function isNumberIncorrect(value, minNumber, maxNumber) {
|
|
100
|
+
return minNumber && parseInt(value) < minNumber || maxNumber && parseInt(value) > maxNumber;
|
|
101
|
+
};
|
|
102
|
+
|
|
80
103
|
var patternMissmatch = function patternMissmatch(pattern, value) {
|
|
81
104
|
return pattern && !new RegExp(pattern).test(value);
|
|
82
105
|
};
|
|
83
106
|
|
|
84
|
-
var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
85
|
-
var label =
|
|
86
|
-
|
|
87
|
-
name =
|
|
88
|
-
|
|
89
|
-
defaultValue =
|
|
90
|
-
value =
|
|
91
|
-
helperText =
|
|
92
|
-
|
|
93
|
-
placeholder =
|
|
94
|
-
action =
|
|
95
|
-
|
|
96
|
-
clearable =
|
|
97
|
-
|
|
98
|
-
disabled =
|
|
99
|
-
|
|
100
|
-
optional =
|
|
101
|
-
|
|
102
|
-
prefix =
|
|
103
|
-
|
|
104
|
-
suffix =
|
|
105
|
-
onChange =
|
|
106
|
-
onBlur =
|
|
107
|
-
error =
|
|
108
|
-
suggestions =
|
|
109
|
-
pattern =
|
|
110
|
-
minLength =
|
|
111
|
-
maxLength =
|
|
112
|
-
|
|
113
|
-
autocomplete =
|
|
114
|
-
margin =
|
|
115
|
-
|
|
116
|
-
size =
|
|
117
|
-
|
|
118
|
-
tabIndex =
|
|
119
|
-
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
var
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
var _useState3 = (0, _react.useState)(false),
|
|
107
|
+
var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
108
|
+
var label = _ref2.label,
|
|
109
|
+
_ref2$name = _ref2.name,
|
|
110
|
+
name = _ref2$name === void 0 ? "" : _ref2$name,
|
|
111
|
+
_ref2$defaultValue = _ref2.defaultValue,
|
|
112
|
+
defaultValue = _ref2$defaultValue === void 0 ? "" : _ref2$defaultValue,
|
|
113
|
+
value = _ref2.value,
|
|
114
|
+
helperText = _ref2.helperText,
|
|
115
|
+
_ref2$placeholder = _ref2.placeholder,
|
|
116
|
+
placeholder = _ref2$placeholder === void 0 ? "" : _ref2$placeholder,
|
|
117
|
+
action = _ref2.action,
|
|
118
|
+
_ref2$clearable = _ref2.clearable,
|
|
119
|
+
clearable = _ref2$clearable === void 0 ? false : _ref2$clearable,
|
|
120
|
+
_ref2$disabled = _ref2.disabled,
|
|
121
|
+
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
122
|
+
_ref2$optional = _ref2.optional,
|
|
123
|
+
optional = _ref2$optional === void 0 ? false : _ref2$optional,
|
|
124
|
+
_ref2$prefix = _ref2.prefix,
|
|
125
|
+
prefix = _ref2$prefix === void 0 ? "" : _ref2$prefix,
|
|
126
|
+
_ref2$suffix = _ref2.suffix,
|
|
127
|
+
suffix = _ref2$suffix === void 0 ? "" : _ref2$suffix,
|
|
128
|
+
onChange = _ref2.onChange,
|
|
129
|
+
onBlur = _ref2.onBlur,
|
|
130
|
+
error = _ref2.error,
|
|
131
|
+
suggestions = _ref2.suggestions,
|
|
132
|
+
pattern = _ref2.pattern,
|
|
133
|
+
minLength = _ref2.minLength,
|
|
134
|
+
maxLength = _ref2.maxLength,
|
|
135
|
+
_ref2$autocomplete = _ref2.autocomplete,
|
|
136
|
+
autocomplete = _ref2$autocomplete === void 0 ? "off" : _ref2$autocomplete,
|
|
137
|
+
margin = _ref2.margin,
|
|
138
|
+
_ref2$size = _ref2.size,
|
|
139
|
+
size = _ref2$size === void 0 ? "medium" : _ref2$size,
|
|
140
|
+
_ref2$tabIndex = _ref2.tabIndex,
|
|
141
|
+
tabIndex = _ref2$tabIndex === void 0 ? 0 : _ref2$tabIndex;
|
|
142
|
+
|
|
143
|
+
var _useState = (0, _react.useState)("input-".concat((0, _uuid.v4)())),
|
|
144
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
145
|
+
inputId = _useState2[0];
|
|
146
|
+
|
|
147
|
+
var autosuggestId = "suggestions-".concat(inputId);
|
|
148
|
+
var errorId = "error-".concat(inputId);
|
|
149
|
+
|
|
150
|
+
var _useState3 = (0, _react.useState)(defaultValue),
|
|
130
151
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
131
|
-
|
|
132
|
-
|
|
152
|
+
innerValue = _useState4[0],
|
|
153
|
+
setInnerValue = _useState4[1];
|
|
133
154
|
|
|
134
155
|
var _useState5 = (0, _react.useState)(false),
|
|
135
156
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
136
|
-
|
|
137
|
-
|
|
157
|
+
isOpen = _useState6[0],
|
|
158
|
+
changeIsOpen = _useState6[1];
|
|
138
159
|
|
|
139
160
|
var _useState7 = (0, _react.useState)(false),
|
|
140
161
|
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
141
|
-
|
|
142
|
-
|
|
162
|
+
isSearching = _useState8[0],
|
|
163
|
+
changeIsSearching = _useState8[1];
|
|
143
164
|
|
|
144
|
-
var _useState9 = (0, _react.useState)(
|
|
165
|
+
var _useState9 = (0, _react.useState)(false),
|
|
145
166
|
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
146
|
-
|
|
147
|
-
|
|
167
|
+
isAutosuggestError = _useState10[0],
|
|
168
|
+
changeIsAutosuggestError = _useState10[1];
|
|
148
169
|
|
|
149
|
-
var _useState11 = (0, _react.useState)(
|
|
170
|
+
var _useState11 = (0, _react.useState)([]),
|
|
150
171
|
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
151
|
-
|
|
152
|
-
|
|
172
|
+
filteredSuggestions = _useState12[0],
|
|
173
|
+
changeFilteredSuggestions = _useState12[1];
|
|
174
|
+
|
|
175
|
+
var _useState13 = (0, _react.useState)(-1),
|
|
176
|
+
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
177
|
+
visualFocusIndex = _useState14[0],
|
|
178
|
+
changeVisualFocusIndex = _useState14[1];
|
|
153
179
|
|
|
154
|
-
var inputContainerRef = (0, _react.useRef)(null);
|
|
155
180
|
var inputRef = (0, _react.useRef)(null);
|
|
156
181
|
var actionRef = (0, _react.useRef)(null);
|
|
157
182
|
var colorsTheme = (0, _useTheme["default"])();
|
|
@@ -159,38 +184,23 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
159
184
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
160
185
|
var numberInputContext = (0, _react.useContext)(_NumberInputContext["default"]);
|
|
161
186
|
|
|
162
|
-
var isNotOptional = function isNotOptional(value) {
|
|
163
|
-
return value === "" && !optional;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
var isLengthIncorrect = function isLengthIncorrect(value) {
|
|
167
|
-
return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
var isNumberIncorrect = function isNumberIncorrect(value) {
|
|
171
|
-
return (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) && parseInt(value) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) && parseInt(value) > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
var isTextInputType = function isTextInputType() {
|
|
175
|
-
var _inputRef$current, _inputRef$current2;
|
|
176
|
-
|
|
177
|
-
return !(inputRef !== null && inputRef !== void 0 && (_inputRef$current = inputRef.current) !== null && _inputRef$current !== void 0 && _inputRef$current.getAttribute("type")) || (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.getAttribute("type")) === "text";
|
|
178
|
-
};
|
|
179
|
-
|
|
180
187
|
var getNumberErrorMessage = function getNumberErrorMessage(value) {
|
|
181
188
|
if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && parseInt(value) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) return translatedLabels.numberInput.valueGreaterThanOrEqualToErrorMessage(numberInputContext.minNumber);else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && parseInt(value) > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) return translatedLabels.numberInput.valueLessThanOrEqualToErrorMessage(numberInputContext.maxNumber);
|
|
182
189
|
};
|
|
183
190
|
|
|
184
|
-
var
|
|
185
|
-
|
|
186
|
-
|
|
191
|
+
var getTextInputWidth = (0, _react.useCallback)(function () {
|
|
192
|
+
var _inputRef$current, _inputRef$current$par;
|
|
193
|
+
|
|
194
|
+
var rect = inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : (_inputRef$current$par = _inputRef$current.parentElement) === null || _inputRef$current$par === void 0 ? void 0 : _inputRef$current$par.getBoundingClientRect();
|
|
195
|
+
return rect === null || rect === void 0 ? void 0 : rect.width;
|
|
196
|
+
}, []);
|
|
187
197
|
|
|
188
198
|
var openSuggestions = function openSuggestions() {
|
|
189
|
-
hasSuggestions() && changeIsOpen(true);
|
|
199
|
+
hasSuggestions(suggestions) && changeIsOpen(true);
|
|
190
200
|
};
|
|
191
201
|
|
|
192
202
|
var closeSuggestions = function closeSuggestions() {
|
|
193
|
-
if (hasSuggestions()) {
|
|
203
|
+
if (hasSuggestions(suggestions)) {
|
|
194
204
|
changeIsOpen(false);
|
|
195
205
|
changeVisualFocusIndex(-1);
|
|
196
206
|
}
|
|
@@ -199,16 +209,16 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
199
209
|
var changeValue = function changeValue(newValue) {
|
|
200
210
|
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
201
211
|
var changedValue = typeof newValue === "number" ? newValue.toString() : newValue;
|
|
202
|
-
if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
212
|
+
if (isNotOptional(newValue, optional)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
203
213
|
value: changedValue,
|
|
204
214
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
205
|
-
});else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
215
|
+
});else if (isLengthIncorrect(newValue, minLength, maxLength)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
206
216
|
value: changedValue,
|
|
207
217
|
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
208
218
|
});else if (patternMissmatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
209
219
|
value: changedValue,
|
|
210
220
|
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
211
|
-
});else if (isNumberIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
221
|
+
});else if (isNumberIncorrect(newValue, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
212
222
|
value: changedValue,
|
|
213
223
|
error: getNumberErrorMessage(newValue)
|
|
214
224
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
@@ -225,23 +235,23 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
225
235
|
document.activeElement === inputRef.current && event.preventDefault();
|
|
226
236
|
};
|
|
227
237
|
|
|
228
|
-
var
|
|
238
|
+
var handleInputOnChange = function handleInputOnChange(event) {
|
|
229
239
|
openSuggestions();
|
|
230
240
|
changeValue(event.target.value);
|
|
231
241
|
};
|
|
232
242
|
|
|
233
|
-
var
|
|
243
|
+
var handleInputOnBlur = function handleInputOnBlur(event) {
|
|
234
244
|
closeSuggestions();
|
|
235
|
-
if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
245
|
+
if (isNotOptional(event.target.value, optional)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
236
246
|
value: event.target.value,
|
|
237
247
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
238
|
-
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
248
|
+
});else if (isLengthIncorrect(event.target.value, minLength, maxLength)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
239
249
|
value: event.target.value,
|
|
240
250
|
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
241
251
|
});else if (patternMissmatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
242
252
|
value: event.target.value,
|
|
243
253
|
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
244
|
-
});else if (isNumberIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
254
|
+
});else if (isNumberIncorrect(event.target.value, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
245
255
|
value: event.target.value,
|
|
246
256
|
error: getNumberErrorMessage(event.target.value)
|
|
247
257
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
@@ -249,7 +259,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
249
259
|
});
|
|
250
260
|
};
|
|
251
261
|
|
|
252
|
-
var
|
|
262
|
+
var handleInputOnKeyDown = function handleInputOnKeyDown(event) {
|
|
253
263
|
switch (event.key) {
|
|
254
264
|
case "Down":
|
|
255
265
|
case "ArrowDown":
|
|
@@ -291,7 +301,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
291
301
|
case "Escape":
|
|
292
302
|
event.preventDefault();
|
|
293
303
|
|
|
294
|
-
if (hasSuggestions()) {
|
|
304
|
+
if (hasSuggestions(suggestions)) {
|
|
295
305
|
changeValue("");
|
|
296
306
|
isOpen && closeSuggestions();
|
|
297
307
|
}
|
|
@@ -299,7 +309,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
299
309
|
break;
|
|
300
310
|
|
|
301
311
|
case "Enter":
|
|
302
|
-
if (hasSuggestions() && !isSearching) {
|
|
312
|
+
if (hasSuggestions(suggestions) && !isSearching) {
|
|
303
313
|
var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusIndex >= 0 && visualFocusIndex < filteredSuggestions.length;
|
|
304
314
|
validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusIndex]);
|
|
305
315
|
isOpen && closeSuggestions();
|
|
@@ -326,12 +336,12 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
326
336
|
};
|
|
327
337
|
|
|
328
338
|
var setNumberProps = function setNumberProps(type, min, max, step) {
|
|
329
|
-
var _inputRef$
|
|
339
|
+
var _inputRef$current2, _inputRef$current3, _inputRef$current4, _inputRef$current5;
|
|
330
340
|
|
|
331
|
-
type && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$
|
|
332
|
-
min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$
|
|
333
|
-
max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$
|
|
334
|
-
step && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$
|
|
341
|
+
type && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.setAttribute("type", type));
|
|
342
|
+
min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("min", min));
|
|
343
|
+
max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("max", max));
|
|
344
|
+
step && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.setAttribute("step", step));
|
|
335
345
|
};
|
|
336
346
|
|
|
337
347
|
var decrementNumber = function decrementNumber() {
|
|
@@ -374,12 +384,6 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
374
384
|
}
|
|
375
385
|
};
|
|
376
386
|
|
|
377
|
-
var getTextInputWidth = (0, _react.useCallback)(function () {
|
|
378
|
-
var _inputContainerRef$cu;
|
|
379
|
-
|
|
380
|
-
var rect = inputContainerRef === null || inputContainerRef === void 0 ? void 0 : (_inputContainerRef$cu = inputContainerRef.current) === null || _inputContainerRef$cu === void 0 ? void 0 : _inputContainerRef$cu.getBoundingClientRect();
|
|
381
|
-
return rect === null || rect === void 0 ? void 0 : rect.width;
|
|
382
|
-
}, []);
|
|
383
387
|
(0, _react.useEffect)(function () {
|
|
384
388
|
if (typeof suggestions === "function") {
|
|
385
389
|
changeIsSearching(true);
|
|
@@ -422,29 +426,57 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
422
426
|
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
423
427
|
disabled: disabled,
|
|
424
428
|
backgroundType: backgroundType
|
|
425
|
-
}, helperText), /*#__PURE__*/_react["default"].createElement(
|
|
426
|
-
open: isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError)
|
|
427
|
-
}, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
|
|
428
|
-
asChild: true
|
|
429
|
-
}, /*#__PURE__*/_react["default"].createElement(InputContainer, {
|
|
429
|
+
}, helperText), /*#__PURE__*/_react["default"].createElement(InputContainer, {
|
|
430
430
|
error: error ? true : false,
|
|
431
431
|
disabled: disabled,
|
|
432
432
|
backgroundType: backgroundType,
|
|
433
433
|
onClick: handleInputContainerOnClick,
|
|
434
|
-
onMouseDown: handleInputContainerOnMouseDown
|
|
435
|
-
ref: inputContainerRef
|
|
434
|
+
onMouseDown: handleInputContainerOnMouseDown
|
|
436
435
|
}, prefix && /*#__PURE__*/_react["default"].createElement(Prefix, {
|
|
437
436
|
disabled: disabled,
|
|
438
437
|
backgroundType: backgroundType
|
|
439
|
-
}, prefix), /*#__PURE__*/_react["default"].createElement(
|
|
438
|
+
}, prefix), /*#__PURE__*/_react["default"].createElement(AutosuggestWrapper, {
|
|
439
|
+
condition: hasSuggestions(suggestions),
|
|
440
|
+
wrapper: function wrapper(children) {
|
|
441
|
+
return /*#__PURE__*/_react["default"].createElement(Popover.Root, {
|
|
442
|
+
open: isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError)
|
|
443
|
+
}, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
|
|
444
|
+
asChild: true,
|
|
445
|
+
"aria-controls": undefined
|
|
446
|
+
}, children), /*#__PURE__*/_react["default"].createElement(Popover.Content, {
|
|
447
|
+
sideOffset: 5,
|
|
448
|
+
onOpenAutoFocus: function onOpenAutoFocus(event) {
|
|
449
|
+
// Avoid select to lose focus when the list is opened
|
|
450
|
+
event.preventDefault();
|
|
451
|
+
},
|
|
452
|
+
onCloseAutoFocus: function onCloseAutoFocus(event) {
|
|
453
|
+
// Avoid select to lose focus when the list is closed
|
|
454
|
+
event.preventDefault();
|
|
455
|
+
}
|
|
456
|
+
}, /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
|
|
457
|
+
id: autosuggestId,
|
|
458
|
+
value: value !== null && value !== void 0 ? value : innerValue,
|
|
459
|
+
suggestions: filteredSuggestions,
|
|
460
|
+
visualFocusIndex: visualFocusIndex,
|
|
461
|
+
highlightedSuggestions: typeof suggestions !== "function",
|
|
462
|
+
searchHasErrors: isAutosuggestError,
|
|
463
|
+
isSearching: isSearching,
|
|
464
|
+
suggestionOnClick: function suggestionOnClick(suggestion) {
|
|
465
|
+
changeValue(suggestion);
|
|
466
|
+
closeSuggestions();
|
|
467
|
+
},
|
|
468
|
+
getTextInputWidth: getTextInputWidth
|
|
469
|
+
})));
|
|
470
|
+
}
|
|
471
|
+
}, /*#__PURE__*/_react["default"].createElement(Input, {
|
|
440
472
|
id: inputId,
|
|
441
473
|
name: name,
|
|
442
474
|
value: value !== null && value !== void 0 ? value : innerValue,
|
|
443
475
|
placeholder: placeholder,
|
|
444
|
-
onBlur:
|
|
445
|
-
onChange:
|
|
476
|
+
onBlur: handleInputOnBlur,
|
|
477
|
+
onChange: handleInputOnChange,
|
|
446
478
|
onFocus: openSuggestions,
|
|
447
|
-
onKeyDown:
|
|
479
|
+
onKeyDown: handleInputOnKeyDown,
|
|
448
480
|
onMouseDown: function onMouseDown(event) {
|
|
449
481
|
event.stopPropagation();
|
|
450
482
|
},
|
|
@@ -456,16 +488,17 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
456
488
|
maxLength: maxLength,
|
|
457
489
|
autoComplete: autocomplete === "off" ? "nope" : autocomplete,
|
|
458
490
|
tabIndex: tabIndex,
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
"aria-
|
|
462
|
-
"aria-
|
|
463
|
-
"aria-expanded":
|
|
464
|
-
"aria-
|
|
491
|
+
type: "text",
|
|
492
|
+
role: hasSuggestions(suggestions) ? "combobox" : undefined,
|
|
493
|
+
"aria-autocomplete": hasSuggestions(suggestions) ? "list" : undefined,
|
|
494
|
+
"aria-controls": hasSuggestions(suggestions) ? autosuggestId : undefined,
|
|
495
|
+
"aria-expanded": hasSuggestions(suggestions) ? isOpen : undefined,
|
|
496
|
+
"aria-haspopup": hasSuggestions(suggestions) ? "listbox" : undefined,
|
|
497
|
+
"aria-activedescendant": hasSuggestions(suggestions) && isOpen && visualFocusIndex !== -1 ? "suggestion-".concat(visualFocusIndex) : undefined,
|
|
465
498
|
"aria-invalid": error ? true : false,
|
|
466
499
|
"aria-errormessage": error ? errorId : undefined,
|
|
467
500
|
"aria-required": optional ? false : true
|
|
468
|
-
}), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
|
|
501
|
+
})), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
|
|
469
502
|
backgroundType: backgroundType,
|
|
470
503
|
"aria-label": "Error"
|
|
471
504
|
}, _Icons["default"].error), !disabled && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
@@ -476,7 +509,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
476
509
|
backgroundType: backgroundType,
|
|
477
510
|
tabIndex: tabIndex,
|
|
478
511
|
title: translatedLabels.textInput.clearFieldActionTitle,
|
|
479
|
-
"aria-label": translatedLabels.textInput.clearFieldActionTitle
|
|
512
|
+
"aria-label": translatedLabels.textInput.clearFieldActionTitle,
|
|
513
|
+
type: "button"
|
|
480
514
|
}, _Icons["default"].clear), (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(Action, {
|
|
481
515
|
ref: actionRef,
|
|
482
516
|
disabled: disabled,
|
|
@@ -487,7 +521,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
487
521
|
backgroundType: backgroundType,
|
|
488
522
|
tabIndex: tabIndex,
|
|
489
523
|
title: translatedLabels.numberInput.decrementValueTitle,
|
|
490
|
-
"aria-label": translatedLabels.numberInput.decrementValueTitle
|
|
524
|
+
"aria-label": translatedLabels.numberInput.decrementValueTitle,
|
|
525
|
+
type: "button"
|
|
491
526
|
}, _Icons["default"].decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
492
527
|
ref: actionRef,
|
|
493
528
|
disabled: disabled,
|
|
@@ -498,7 +533,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
498
533
|
backgroundType: backgroundType,
|
|
499
534
|
tabIndex: tabIndex,
|
|
500
535
|
title: translatedLabels.numberInput.incrementValueTitle,
|
|
501
|
-
"aria-label": translatedLabels.numberInput.incrementValueTitle
|
|
536
|
+
"aria-label": translatedLabels.numberInput.incrementValueTitle,
|
|
537
|
+
type: "button"
|
|
502
538
|
}, _Icons["default"].increment)), action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
503
539
|
ref: actionRef,
|
|
504
540
|
disabled: disabled,
|
|
@@ -509,36 +545,14 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
509
545
|
title: action.title,
|
|
510
546
|
"aria-label": action.title,
|
|
511
547
|
backgroundType: backgroundType,
|
|
512
|
-
tabIndex: tabIndex
|
|
548
|
+
tabIndex: tabIndex,
|
|
549
|
+
type: "button"
|
|
513
550
|
}, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement(ActionIcon, {
|
|
514
551
|
src: action.icon
|
|
515
552
|
}) : action.icon), suffix && /*#__PURE__*/_react["default"].createElement(Suffix, {
|
|
516
553
|
disabled: disabled,
|
|
517
554
|
backgroundType: backgroundType
|
|
518
|
-
}, suffix))
|
|
519
|
-
sideOffset: 4,
|
|
520
|
-
onOpenAutoFocus: function onOpenAutoFocus(event) {
|
|
521
|
-
// Avoid select to lose focus when the list is opened
|
|
522
|
-
event.preventDefault();
|
|
523
|
-
},
|
|
524
|
-
onCloseAutoFocus: function onCloseAutoFocus(event) {
|
|
525
|
-
// Avoid select to lose focus when the list is closed
|
|
526
|
-
event.preventDefault();
|
|
527
|
-
}
|
|
528
|
-
}, /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
|
|
529
|
-
id: autosuggestId,
|
|
530
|
-
value: value !== null && value !== void 0 ? value : innerValue,
|
|
531
|
-
suggestions: filteredSuggestions,
|
|
532
|
-
visualFocusIndex: visualFocusIndex,
|
|
533
|
-
highlightedSuggestions: typeof suggestions !== "function",
|
|
534
|
-
searchHasErrors: isAutosuggestError,
|
|
535
|
-
isSearching: isSearching,
|
|
536
|
-
suggestionOnClick: function suggestionOnClick(suggestion) {
|
|
537
|
-
changeValue(suggestion);
|
|
538
|
-
closeSuggestions();
|
|
539
|
-
},
|
|
540
|
-
getTextInputWidth: getTextInputWidth
|
|
541
|
-
}))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
555
|
+
}, suffix)), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
542
556
|
id: errorId,
|
|
543
557
|
backgroundType: backgroundType,
|
|
544
558
|
"aria-live": error ? "assertive" : "off"
|
|
@@ -602,7 +616,7 @@ var InputContainer = _styledComponents["default"].div(_templateObject5 || (_temp
|
|
|
602
616
|
}, function (props) {
|
|
603
617
|
return props.disabled && "cursor: not-allowed;";
|
|
604
618
|
}, function (props) {
|
|
605
|
-
return !props.disabled && "\n &:hover {\n border-color: ".concat(props.error ? "transparent" : props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor, ";\n ").concat(props.error
|
|
619
|
+
return !props.disabled && "\n &:hover {\n border-color: ".concat(props.error ? "transparent" : props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor, ";\n ").concat(props.error ? "box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.hoverErrorBorderColorOnDark : props.theme.hoverErrorBorderColor, ";") : "", "\n }\n &:focus-within {\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n ");
|
|
606
620
|
});
|
|
607
621
|
|
|
608
622
|
var Input = _styledComponents["default"].input(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n height: calc(2.5rem - 2px);\n width: 100%;\n background: none;\n border: none;\n outline: none;\n padding: 0 0.5rem;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.5em;\n ", "\n\n ::placeholder {\n color: ", ";\n }\n"])), function (props) {
|