@dxc-technology/halstack-react 0.0.0-74ba970 → 0.0.0-752ca0a
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/BackgroundColorContext.d.ts +2 -2
- package/BackgroundColorContext.js +1 -1
- package/HalstackContext.d.ts +1349 -5
- package/HalstackContext.js +117 -77
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +14 -37
- package/accordion/Accordion.stories.tsx +104 -113
- package/accordion/Accordion.test.js +1 -1
- package/accordion/types.d.ts +2 -13
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +23 -44
- package/accordion-group/AccordionGroup.stories.tsx +77 -76
- package/accordion-group/AccordionGroup.test.js +7 -17
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +2 -13
- package/alert/Alert.js +4 -8
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +1 -1
- package/bleed/Bleed.stories.tsx +1 -0
- package/box/Box.d.ts +1 -1
- package/box/Box.js +7 -26
- package/box/Box.stories.tsx +38 -51
- package/box/Box.test.js +1 -1
- package/box/types.d.ts +0 -11
- package/bulleted-list/BulletedList.js +4 -2
- package/bulleted-list/BulletedList.stories.tsx +7 -1
- package/bulleted-list/types.d.ts +31 -4
- package/button/Button.d.ts +1 -1
- package/button/Button.js +48 -60
- package/button/Button.stories.tsx +151 -9
- package/button/Button.test.js +12 -1
- package/button/types.d.ts +7 -3
- package/card/Card.d.ts +1 -1
- package/card/Card.js +27 -45
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +1 -1
- package/card/types.d.ts +1 -6
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +71 -51
- package/checkbox/Checkbox.stories.tsx +146 -58
- package/checkbox/Checkbox.test.js +84 -11
- package/checkbox/types.d.ts +10 -2
- package/chip/Chip.js +28 -49
- package/chip/Chip.stories.tsx +121 -26
- package/chip/Chip.test.js +3 -5
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +4 -4
- package/common/variables.d.ts +1499 -0
- package/common/variables.js +1004 -1134
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.js +138 -239
- package/date-input/DateInput.stories.tsx +209 -33
- package/date-input/DateInput.test.js +519 -149
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +146 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +75 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +126 -0
- package/date-input/types.d.ts +55 -0
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +54 -85
- package/dialog/Dialog.stories.tsx +154 -170
- package/dialog/Dialog.test.js +302 -3
- package/dialog/types.d.ts +0 -12
- package/dropdown/Dropdown.js +40 -39
- package/dropdown/Dropdown.stories.tsx +210 -84
- package/dropdown/Dropdown.test.js +21 -26
- package/dropdown/DropdownMenu.js +12 -18
- package/dropdown/DropdownMenuItem.js +4 -17
- package/dropdown/types.d.ts +3 -3
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +174 -220
- package/file-input/FileInput.stories.tsx +122 -11
- package/file-input/FileInput.test.js +14 -14
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +39 -63
- package/file-input/types.d.ts +18 -1
- package/flex/Flex.d.ts +1 -1
- package/flex/Flex.js +33 -19
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +83 -7
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +44 -64
- package/footer/Footer.stories.tsx +36 -21
- package/footer/Footer.test.js +16 -26
- package/footer/types.d.ts +10 -11
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +20 -49
- package/header/Header.stories.tsx +115 -36
- package/header/Header.test.js +2 -2
- package/header/types.d.ts +1 -14
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.js +1 -1
- package/image/Image.d.ts +4 -0
- package/image/Image.js +85 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/inset/Inset.stories.tsx +2 -1
- package/layout/ApplicationLayout.d.ts +5 -5
- package/layout/ApplicationLayout.js +15 -12
- package/layout/ApplicationLayout.stories.tsx +1 -1
- package/layout/Icons.d.ts +7 -4
- package/layout/Icons.js +52 -56
- package/layout/types.d.ts +2 -3
- package/link/Link.js +4 -4
- package/link/Link.stories.tsx +60 -0
- package/link/Link.test.js +2 -4
- package/link/types.d.ts +2 -2
- package/main.d.ts +4 -2
- package/main.js +17 -1
- package/{tabs-nav → nav-tabs}/NavTabs.d.ts +2 -2
- package/{tabs-nav → nav-tabs}/NavTabs.js +8 -11
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +110 -6
- package/{tabs-nav → nav-tabs}/NavTabs.test.js +1 -1
- package/{tabs-nav → nav-tabs}/Tab.js +48 -32
- package/{tabs-nav → nav-tabs}/types.d.ts +8 -9
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +6 -4
- package/number-input/NumberInput.test.js +317 -98
- package/package.json +9 -14
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +8 -16
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +58 -48
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +5 -5
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +39 -0
- package/password-input/PasswordInput.js +35 -82
- package/password-input/PasswordInput.stories.tsx +1 -0
- package/password-input/PasswordInput.test.js +34 -40
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +5 -5
- package/progress-bar/ProgressBar.stories.jsx +35 -2
- package/progress-bar/ProgressBar.test.js +1 -1
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.js +11 -12
- package/quick-nav/QuickNav.stories.tsx +111 -19
- package/radio-group/Radio.js +10 -10
- package/radio-group/RadioGroup.js +15 -13
- package/radio-group/RadioGroup.stories.tsx +131 -18
- package/radio-group/RadioGroup.test.js +117 -60
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.js +49 -108
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +41 -64
- package/resultsetTable/types.d.ts +1 -1
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +5 -34
- package/select/Option.js +11 -24
- package/select/Select.js +59 -36
- package/select/Select.stories.tsx +497 -153
- package/select/Select.test.js +345 -292
- package/select/types.d.ts +2 -2
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +66 -96
- package/sidenav/Sidenav.stories.tsx +165 -63
- package/sidenav/types.d.ts +21 -18
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +17 -14
- package/slider/Slider.stories.tsx +57 -0
- package/slider/Slider.test.js +1 -1
- package/slider/types.d.ts +6 -2
- package/spinner/Spinner.js +17 -23
- package/spinner/Spinner.stories.jsx +53 -27
- package/spinner/Spinner.test.js +1 -1
- package/switch/Switch.d.ts +3 -3
- package/switch/Switch.js +7 -6
- package/switch/Switch.stories.tsx +33 -0
- package/switch/Switch.test.js +1 -1
- package/switch/types.d.ts +8 -3
- package/table/Table.js +3 -3
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +2 -2
- package/tabs/Tab.js +12 -15
- package/tabs/Tabs.js +11 -17
- package/tabs/Tabs.stories.tsx +45 -5
- package/tabs/Tabs.test.js +4 -5
- package/tabs/types.d.ts +2 -2
- package/tag/Tag.js +7 -9
- package/tag/Tag.stories.tsx +14 -1
- package/tag/Tag.test.js +1 -1
- package/text-input/Suggestion.js +34 -7
- package/text-input/TextInput.js +224 -228
- package/text-input/TextInput.stories.tsx +132 -5
- package/text-input/TextInput.test.js +757 -658
- package/text-input/types.d.ts +9 -0
- package/textarea/Textarea.js +27 -26
- package/textarea/Textarea.stories.jsx +68 -1
- package/textarea/Textarea.test.js +61 -19
- package/textarea/types.d.ts +4 -0
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +85 -59
- package/toggle-group/ToggleGroup.stories.tsx +48 -3
- package/toggle-group/ToggleGroup.test.js +38 -24
- package/toggle-group/types.d.ts +22 -13
- package/typography/Typography.d.ts +2 -2
- package/typography/Typography.js +14 -113
- package/typography/Typography.stories.tsx +1 -1
- package/useTheme.d.ts +1251 -1
- package/useTheme.js +1 -1
- package/useTranslatedLabels.d.ts +84 -1
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +108 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +138 -0
- package/wizard/Wizard.js +2 -2
- package/wizard/Wizard.stories.tsx +20 -0
- package/wizard/Wizard.test.js +1 -1
- package/wizard/types.d.ts +5 -6
- package/card/ice-cream.jpg +0 -0
- package/common/RequiredComponent.js +0 -32
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- /package/{tabs-nav → grid}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → image/types.js} +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
package/text-input/TextInput.js
CHANGED
|
@@ -23,13 +23,13 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
|
23
23
|
|
|
24
24
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
25
25
|
|
|
26
|
-
var _variables = require("../common/variables
|
|
26
|
+
var _variables = require("../common/variables");
|
|
27
27
|
|
|
28
|
-
var _utils = require("../common/utils
|
|
28
|
+
var _utils = require("../common/utils");
|
|
29
29
|
|
|
30
30
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _NumberInput = require("../number-input/NumberInput");
|
|
33
33
|
|
|
34
34
|
var _Suggestions = _interopRequireDefault(require("./Suggestions"));
|
|
35
35
|
|
|
@@ -39,7 +39,7 @@ var _Icons = _interopRequireDefault(require("./Icons"));
|
|
|
39
39
|
|
|
40
40
|
var _uuid = require("uuid");
|
|
41
41
|
|
|
42
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11
|
|
42
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
43
43
|
|
|
44
44
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
45
|
|
|
@@ -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,142 +84,147 @@ var makeCancelable = function makeCancelable(promise) {
|
|
|
77
84
|
};
|
|
78
85
|
};
|
|
79
86
|
|
|
80
|
-
var
|
|
81
|
-
return
|
|
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 isRequired = function isRequired(value, optional) {
|
|
92
|
+
return value === "" && !optional;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
var isLengthIncorrect = function isLengthIncorrect(value, minLength, maxLength) {
|
|
96
|
+
return value != null && (value.length < minLength || value.length > maxLength);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
var isNumberIncorrect = function isNumberIncorrect(value, minNumber, maxNumber) {
|
|
100
|
+
return value < minNumber || value > maxNumber;
|
|
82
101
|
};
|
|
83
102
|
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
103
|
+
var patternMismatch = function patternMismatch(pattern, value) {
|
|
104
|
+
return pattern != null && !new RegExp(pattern).test(value);
|
|
105
|
+
};
|
|
106
|
+
|
|
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$readOnly = _ref2.readOnly,
|
|
123
|
+
readOnly = _ref2$readOnly === void 0 ? false : _ref2$readOnly,
|
|
124
|
+
_ref2$optional = _ref2.optional,
|
|
125
|
+
optional = _ref2$optional === void 0 ? false : _ref2$optional,
|
|
126
|
+
_ref2$prefix = _ref2.prefix,
|
|
127
|
+
prefix = _ref2$prefix === void 0 ? "" : _ref2$prefix,
|
|
128
|
+
_ref2$suffix = _ref2.suffix,
|
|
129
|
+
suffix = _ref2$suffix === void 0 ? "" : _ref2$suffix,
|
|
130
|
+
onChange = _ref2.onChange,
|
|
131
|
+
onBlur = _ref2.onBlur,
|
|
132
|
+
error = _ref2.error,
|
|
133
|
+
suggestions = _ref2.suggestions,
|
|
134
|
+
pattern = _ref2.pattern,
|
|
135
|
+
minLength = _ref2.minLength,
|
|
136
|
+
maxLength = _ref2.maxLength,
|
|
137
|
+
_ref2$autocomplete = _ref2.autocomplete,
|
|
138
|
+
autocomplete = _ref2$autocomplete === void 0 ? "off" : _ref2$autocomplete,
|
|
139
|
+
margin = _ref2.margin,
|
|
140
|
+
_ref2$size = _ref2.size,
|
|
141
|
+
size = _ref2$size === void 0 ? "medium" : _ref2$size,
|
|
142
|
+
_ref2$tabIndex = _ref2.tabIndex,
|
|
143
|
+
tabIndex = _ref2$tabIndex === void 0 ? 0 : _ref2$tabIndex;
|
|
144
|
+
|
|
145
|
+
var _useState = (0, _react.useState)("input-".concat((0, _uuid.v4)())),
|
|
146
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
147
|
+
inputId = _useState2[0];
|
|
148
|
+
|
|
149
|
+
var autosuggestId = "suggestions-".concat(inputId);
|
|
150
|
+
var errorId = "error-".concat(inputId);
|
|
151
|
+
|
|
152
|
+
var _useState3 = (0, _react.useState)(defaultValue),
|
|
130
153
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
131
|
-
|
|
132
|
-
|
|
154
|
+
innerValue = _useState4[0],
|
|
155
|
+
setInnerValue = _useState4[1];
|
|
133
156
|
|
|
134
157
|
var _useState5 = (0, _react.useState)(false),
|
|
135
158
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
136
|
-
|
|
137
|
-
|
|
159
|
+
isOpen = _useState6[0],
|
|
160
|
+
changeIsOpen = _useState6[1];
|
|
138
161
|
|
|
139
162
|
var _useState7 = (0, _react.useState)(false),
|
|
140
163
|
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
141
|
-
|
|
142
|
-
|
|
164
|
+
isSearching = _useState8[0],
|
|
165
|
+
changeIsSearching = _useState8[1];
|
|
143
166
|
|
|
144
|
-
var _useState9 = (0, _react.useState)(
|
|
167
|
+
var _useState9 = (0, _react.useState)(false),
|
|
145
168
|
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
146
|
-
|
|
147
|
-
|
|
169
|
+
isAutosuggestError = _useState10[0],
|
|
170
|
+
changeIsAutosuggestError = _useState10[1];
|
|
148
171
|
|
|
149
|
-
var _useState11 = (0, _react.useState)(
|
|
172
|
+
var _useState11 = (0, _react.useState)([]),
|
|
150
173
|
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
151
|
-
|
|
152
|
-
|
|
174
|
+
filteredSuggestions = _useState12[0],
|
|
175
|
+
changeFilteredSuggestions = _useState12[1];
|
|
176
|
+
|
|
177
|
+
var _useState13 = (0, _react.useState)(-1),
|
|
178
|
+
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
179
|
+
visualFocusIndex = _useState14[0],
|
|
180
|
+
changeVisualFocusIndex = _useState14[1];
|
|
153
181
|
|
|
154
|
-
var inputContainerRef = (0, _react.useRef)(null);
|
|
155
182
|
var inputRef = (0, _react.useRef)(null);
|
|
156
183
|
var actionRef = (0, _react.useRef)(null);
|
|
157
184
|
var colorsTheme = (0, _useTheme["default"])();
|
|
158
185
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
159
186
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
160
|
-
var numberInputContext = (0, _react.useContext)(
|
|
161
|
-
|
|
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
|
-
};
|
|
187
|
+
var numberInputContext = (0, _react.useContext)(_NumberInput.NumberInputContext);
|
|
179
188
|
|
|
180
189
|
var getNumberErrorMessage = function getNumberErrorMessage(value) {
|
|
181
|
-
if (
|
|
190
|
+
if (value < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) return translatedLabels.numberInput.valueGreaterThanOrEqualToErrorMessage(numberInputContext.minNumber);else if (value > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) return translatedLabels.numberInput.valueLessThanOrEqualToErrorMessage(numberInputContext.maxNumber);
|
|
182
191
|
};
|
|
183
192
|
|
|
184
|
-
var
|
|
185
|
-
|
|
186
|
-
|
|
193
|
+
var getTextInputWidth = (0, _react.useCallback)(function () {
|
|
194
|
+
var _inputRef$current, _inputRef$current$par;
|
|
195
|
+
|
|
196
|
+
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();
|
|
197
|
+
return rect === null || rect === void 0 ? void 0 : rect.width;
|
|
198
|
+
}, []);
|
|
187
199
|
|
|
188
200
|
var openSuggestions = function openSuggestions() {
|
|
189
|
-
hasSuggestions() && changeIsOpen(true);
|
|
201
|
+
hasSuggestions(suggestions) && changeIsOpen(true);
|
|
190
202
|
};
|
|
191
203
|
|
|
192
204
|
var closeSuggestions = function closeSuggestions() {
|
|
193
|
-
if (hasSuggestions()) {
|
|
205
|
+
if (hasSuggestions(suggestions)) {
|
|
194
206
|
changeIsOpen(false);
|
|
195
207
|
changeVisualFocusIndex(-1);
|
|
196
208
|
}
|
|
197
209
|
};
|
|
198
210
|
|
|
199
211
|
var changeValue = function changeValue(newValue) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (
|
|
203
|
-
value:
|
|
212
|
+
var formattedValue = typeof newValue === "number" ? newValue.toString() : newValue;
|
|
213
|
+
value !== null && value !== void 0 ? value : setInnerValue(formattedValue);
|
|
214
|
+
if (isRequired(formattedValue, optional)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
215
|
+
value: formattedValue,
|
|
204
216
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
205
|
-
});else if (isLengthIncorrect(
|
|
206
|
-
value:
|
|
217
|
+
});else if (isLengthIncorrect(formattedValue, minLength, maxLength)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
218
|
+
value: formattedValue,
|
|
207
219
|
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
208
|
-
});else if (
|
|
209
|
-
value:
|
|
220
|
+
});else if (patternMismatch(pattern, formattedValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
221
|
+
value: formattedValue,
|
|
210
222
|
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
211
|
-
});else if (isNumberIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
212
|
-
value:
|
|
213
|
-
error: getNumberErrorMessage(newValue)
|
|
223
|
+
});else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && isNumberIncorrect(Number(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({
|
|
224
|
+
value: formattedValue,
|
|
225
|
+
error: getNumberErrorMessage(Number(newValue))
|
|
214
226
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
215
|
-
value:
|
|
227
|
+
value: formattedValue
|
|
216
228
|
});
|
|
217
229
|
};
|
|
218
230
|
|
|
@@ -225,31 +237,31 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
225
237
|
document.activeElement === inputRef.current && event.preventDefault();
|
|
226
238
|
};
|
|
227
239
|
|
|
228
|
-
var
|
|
240
|
+
var handleInputOnChange = function handleInputOnChange(event) {
|
|
229
241
|
openSuggestions();
|
|
230
242
|
changeValue(event.target.value);
|
|
231
243
|
};
|
|
232
244
|
|
|
233
|
-
var
|
|
245
|
+
var handleInputOnBlur = function handleInputOnBlur(event) {
|
|
234
246
|
closeSuggestions();
|
|
235
|
-
if (
|
|
247
|
+
if (isRequired(event.target.value, optional)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
236
248
|
value: event.target.value,
|
|
237
249
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
238
|
-
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
250
|
+
});else if (isLengthIncorrect(event.target.value, minLength, maxLength)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
239
251
|
value: event.target.value,
|
|
240
252
|
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
241
|
-
});else if (
|
|
253
|
+
});else if (patternMismatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
242
254
|
value: event.target.value,
|
|
243
255
|
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
244
|
-
});else if (isNumberIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
256
|
+
});else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && isNumberIncorrect(Number(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
257
|
value: event.target.value,
|
|
246
|
-
error: getNumberErrorMessage(event.target.value)
|
|
258
|
+
error: getNumberErrorMessage(Number(event.target.value))
|
|
247
259
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
248
260
|
value: event.target.value
|
|
249
261
|
});
|
|
250
262
|
};
|
|
251
263
|
|
|
252
|
-
var
|
|
264
|
+
var handleInputOnKeyDown = function handleInputOnKeyDown(event) {
|
|
253
265
|
switch (event.key) {
|
|
254
266
|
case "Down":
|
|
255
267
|
case "ArrowDown":
|
|
@@ -291,7 +303,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
291
303
|
case "Escape":
|
|
292
304
|
event.preventDefault();
|
|
293
305
|
|
|
294
|
-
if (hasSuggestions()) {
|
|
306
|
+
if (hasSuggestions(suggestions)) {
|
|
295
307
|
changeValue("");
|
|
296
308
|
isOpen && closeSuggestions();
|
|
297
309
|
}
|
|
@@ -299,7 +311,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
299
311
|
break;
|
|
300
312
|
|
|
301
313
|
case "Enter":
|
|
302
|
-
if (hasSuggestions() && !isSearching) {
|
|
314
|
+
if (hasSuggestions(suggestions) && !isSearching) {
|
|
303
315
|
var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusIndex >= 0 && visualFocusIndex < filteredSuggestions.length;
|
|
304
316
|
validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusIndex]);
|
|
305
317
|
isOpen && closeSuggestions();
|
|
@@ -326,60 +338,38 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
326
338
|
};
|
|
327
339
|
|
|
328
340
|
var setNumberProps = function setNumberProps(type, min, max, step) {
|
|
329
|
-
var _inputRef$
|
|
341
|
+
var _inputRef$current2, _inputRef$current3, _inputRef$current4, _inputRef$current5;
|
|
330
342
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
343
|
+
min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.setAttribute("min", min));
|
|
344
|
+
max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("max", max));
|
|
345
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("step", step);
|
|
346
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.setAttribute("type", type);
|
|
335
347
|
};
|
|
336
348
|
|
|
337
349
|
var decrementNumber = function decrementNumber() {
|
|
338
|
-
var
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
|
|
344
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && (parseInt(numberValue) === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || numberValue === "" || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber))) {
|
|
345
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);
|
|
346
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) >= (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue !== "") {
|
|
347
|
-
changeValue(parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
348
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue == "") {
|
|
349
|
-
changeValue(-(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
350
|
-
} else if (numberValue === "") {
|
|
351
|
-
changeValue(-1);
|
|
350
|
+
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
351
|
+
var numberValue = Number(currentValue);
|
|
352
|
+
var steppedValue = Math.round((numberValue - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
353
|
+
|
|
354
|
+
if (currentValue !== "") {
|
|
355
|
+
if (numberValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || steppedValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberValue);else if (numberValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else if (numberValue === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else changeValue(steppedValue);
|
|
352
356
|
} else {
|
|
353
|
-
changeValue(
|
|
357
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) >= 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) < 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(-numberInputContext.stepNumber);
|
|
354
358
|
}
|
|
355
359
|
};
|
|
356
360
|
|
|
357
361
|
var incrementNumber = function incrementNumber() {
|
|
358
|
-
var
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);
|
|
364
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && (parseInt(numberValue) === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber))) {
|
|
365
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
|
|
366
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) <= (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue !== "") {
|
|
367
|
-
changeValue(parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
368
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue == "") {
|
|
369
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber);
|
|
370
|
-
} else if (numberValue === "") {
|
|
371
|
-
changeValue(1);
|
|
362
|
+
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
363
|
+
var numberValue = Number(currentValue);
|
|
364
|
+
var steppedValue = Math.round((numberValue + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
365
|
+
|
|
366
|
+
if (currentValue !== "") {
|
|
367
|
+
if (numberValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || steppedValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberValue);else if (numberValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if (numberValue === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(steppedValue);
|
|
372
368
|
} else {
|
|
373
|
-
changeValue(
|
|
369
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) > 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) <= 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(numberInputContext.stepNumber);
|
|
374
370
|
}
|
|
375
371
|
};
|
|
376
372
|
|
|
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
373
|
(0, _react.useEffect)(function () {
|
|
384
374
|
if (typeof suggestions === "function") {
|
|
385
375
|
changeIsSearching(true);
|
|
@@ -406,7 +396,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
406
396
|
changeVisualFocusIndex(-1);
|
|
407
397
|
}
|
|
408
398
|
|
|
409
|
-
|
|
399
|
+
numberInputContext != null && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
410
400
|
}, [value, innerValue, suggestions, numberInputContext]);
|
|
411
401
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
412
402
|
theme: colorsTheme.textInput
|
|
@@ -422,33 +412,63 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
422
412
|
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
423
413
|
disabled: disabled,
|
|
424
414
|
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, {
|
|
415
|
+
}, helperText), /*#__PURE__*/_react["default"].createElement(InputContainer, {
|
|
430
416
|
error: error ? true : false,
|
|
431
417
|
disabled: disabled,
|
|
418
|
+
readOnly: readOnly,
|
|
432
419
|
backgroundType: backgroundType,
|
|
433
420
|
onClick: handleInputContainerOnClick,
|
|
434
|
-
onMouseDown: handleInputContainerOnMouseDown
|
|
435
|
-
ref: inputContainerRef
|
|
421
|
+
onMouseDown: handleInputContainerOnMouseDown
|
|
436
422
|
}, prefix && /*#__PURE__*/_react["default"].createElement(Prefix, {
|
|
437
423
|
disabled: disabled,
|
|
438
424
|
backgroundType: backgroundType
|
|
439
|
-
}, prefix), /*#__PURE__*/_react["default"].createElement(
|
|
425
|
+
}, prefix), /*#__PURE__*/_react["default"].createElement(AutosuggestWrapper, {
|
|
426
|
+
condition: hasSuggestions(suggestions),
|
|
427
|
+
wrapper: function wrapper(children) {
|
|
428
|
+
return /*#__PURE__*/_react["default"].createElement(Popover.Root, {
|
|
429
|
+
open: isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError)
|
|
430
|
+
}, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
|
|
431
|
+
asChild: true,
|
|
432
|
+
"aria-controls": undefined
|
|
433
|
+
}, children), /*#__PURE__*/_react["default"].createElement(Popover.Content, {
|
|
434
|
+
sideOffset: 5,
|
|
435
|
+
onOpenAutoFocus: function onOpenAutoFocus(event) {
|
|
436
|
+
// Avoid select to lose focus when the list is opened
|
|
437
|
+
event.preventDefault();
|
|
438
|
+
},
|
|
439
|
+
onCloseAutoFocus: function onCloseAutoFocus(event) {
|
|
440
|
+
// Avoid select to lose focus when the list is closed
|
|
441
|
+
event.preventDefault();
|
|
442
|
+
}
|
|
443
|
+
}, /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
|
|
444
|
+
id: autosuggestId,
|
|
445
|
+
value: value !== null && value !== void 0 ? value : innerValue,
|
|
446
|
+
suggestions: filteredSuggestions,
|
|
447
|
+
visualFocusIndex: visualFocusIndex,
|
|
448
|
+
highlightedSuggestions: typeof suggestions !== "function",
|
|
449
|
+
searchHasErrors: isAutosuggestError,
|
|
450
|
+
isSearching: isSearching,
|
|
451
|
+
suggestionOnClick: function suggestionOnClick(suggestion) {
|
|
452
|
+
changeValue(suggestion);
|
|
453
|
+
closeSuggestions();
|
|
454
|
+
},
|
|
455
|
+
getTextInputWidth: getTextInputWidth
|
|
456
|
+
})));
|
|
457
|
+
}
|
|
458
|
+
}, /*#__PURE__*/_react["default"].createElement(Input, {
|
|
440
459
|
id: inputId,
|
|
441
460
|
name: name,
|
|
442
461
|
value: value !== null && value !== void 0 ? value : innerValue,
|
|
443
462
|
placeholder: placeholder,
|
|
444
|
-
onBlur:
|
|
445
|
-
onChange:
|
|
463
|
+
onBlur: handleInputOnBlur,
|
|
464
|
+
onChange: handleInputOnChange,
|
|
446
465
|
onFocus: openSuggestions,
|
|
447
|
-
onKeyDown:
|
|
466
|
+
onKeyDown: handleInputOnKeyDown,
|
|
448
467
|
onMouseDown: function onMouseDown(event) {
|
|
449
468
|
event.stopPropagation();
|
|
450
469
|
},
|
|
451
470
|
disabled: disabled,
|
|
471
|
+
readOnly: readOnly,
|
|
452
472
|
ref: inputRef,
|
|
453
473
|
backgroundType: backgroundType,
|
|
454
474
|
pattern: pattern,
|
|
@@ -456,96 +476,78 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
456
476
|
maxLength: maxLength,
|
|
457
477
|
autoComplete: autocomplete === "off" ? "nope" : autocomplete,
|
|
458
478
|
tabIndex: tabIndex,
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
"aria-
|
|
462
|
-
"aria-
|
|
463
|
-
"aria-expanded":
|
|
464
|
-
"aria-
|
|
479
|
+
type: "text",
|
|
480
|
+
role: hasSuggestions(suggestions) ? "combobox" : undefined,
|
|
481
|
+
"aria-autocomplete": hasSuggestions(suggestions) ? "list" : undefined,
|
|
482
|
+
"aria-controls": hasSuggestions(suggestions) ? autosuggestId : undefined,
|
|
483
|
+
"aria-expanded": hasSuggestions(suggestions) ? isOpen : undefined,
|
|
484
|
+
"aria-haspopup": hasSuggestions(suggestions) ? "listbox" : undefined,
|
|
485
|
+
"aria-activedescendant": hasSuggestions(suggestions) && isOpen && visualFocusIndex !== -1 ? "suggestion-".concat(visualFocusIndex) : undefined,
|
|
465
486
|
"aria-invalid": error ? true : false,
|
|
466
487
|
"aria-errormessage": error ? errorId : undefined,
|
|
467
|
-
"aria-required":
|
|
468
|
-
}), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
|
|
488
|
+
"aria-required": !disabled && !optional
|
|
489
|
+
})), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
|
|
469
490
|
backgroundType: backgroundType,
|
|
470
491
|
"aria-label": "Error"
|
|
471
|
-
}, _Icons["default"].error), !disabled && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
492
|
+
}, _Icons["default"].error), !disabled && !readOnly && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
493
|
+
"aria-label": translatedLabels.textInput.clearFieldActionTitle,
|
|
472
494
|
onClick: handleClearActionOnClick,
|
|
473
495
|
onMouseDown: function onMouseDown(event) {
|
|
474
496
|
event.stopPropagation();
|
|
475
497
|
},
|
|
476
|
-
backgroundType: backgroundType,
|
|
477
498
|
tabIndex: tabIndex,
|
|
478
499
|
title: translatedLabels.textInput.clearFieldActionTitle,
|
|
479
|
-
"
|
|
500
|
+
type: "button",
|
|
501
|
+
backgroundType: backgroundType
|
|
480
502
|
}, _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
|
-
|
|
503
|
+
"aria-label": translatedLabels.numberInput.decrementValueTitle,
|
|
482
504
|
disabled: disabled,
|
|
483
505
|
onClick: handleDecrementActionOnClick,
|
|
484
506
|
onMouseDown: function onMouseDown(event) {
|
|
485
507
|
event.stopPropagation();
|
|
486
508
|
},
|
|
487
|
-
|
|
509
|
+
ref: actionRef,
|
|
488
510
|
tabIndex: tabIndex,
|
|
489
511
|
title: translatedLabels.numberInput.decrementValueTitle,
|
|
490
|
-
"
|
|
512
|
+
type: "button",
|
|
513
|
+
backgroundType: backgroundType
|
|
491
514
|
}, _Icons["default"].decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
492
|
-
|
|
515
|
+
"aria-label": translatedLabels.numberInput.incrementValueTitle,
|
|
493
516
|
disabled: disabled,
|
|
494
517
|
onClick: handleIncrementActionOnClick,
|
|
495
518
|
onMouseDown: function onMouseDown(event) {
|
|
496
519
|
event.stopPropagation();
|
|
497
520
|
},
|
|
498
|
-
|
|
521
|
+
ref: actionRef,
|
|
499
522
|
tabIndex: tabIndex,
|
|
500
523
|
title: translatedLabels.numberInput.incrementValueTitle,
|
|
501
|
-
"
|
|
524
|
+
type: "button",
|
|
525
|
+
backgroundType: backgroundType
|
|
502
526
|
}, _Icons["default"].increment)), action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
503
|
-
|
|
527
|
+
"aria-label": action.title,
|
|
504
528
|
disabled: disabled,
|
|
505
|
-
onClick: action.onClick,
|
|
529
|
+
onClick: !readOnly ? action.onClick : undefined,
|
|
506
530
|
onMouseDown: function onMouseDown(event) {
|
|
507
531
|
event.stopPropagation();
|
|
508
532
|
},
|
|
533
|
+
ref: actionRef,
|
|
534
|
+
tabIndex: tabIndex,
|
|
509
535
|
title: action.title,
|
|
510
|
-
"
|
|
511
|
-
backgroundType: backgroundType
|
|
512
|
-
|
|
513
|
-
}, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement(ActionIcon, {
|
|
536
|
+
type: "button",
|
|
537
|
+
backgroundType: backgroundType
|
|
538
|
+
}, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
514
539
|
src: action.icon
|
|
515
540
|
}) : action.icon), suffix && /*#__PURE__*/_react["default"].createElement(Suffix, {
|
|
516
541
|
disabled: disabled,
|
|
517
542
|
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, {
|
|
543
|
+
}, suffix)), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
542
544
|
id: errorId,
|
|
543
545
|
backgroundType: backgroundType,
|
|
544
546
|
"aria-live": error ? "assertive" : "off"
|
|
545
547
|
}, error)));
|
|
546
548
|
});
|
|
547
549
|
|
|
548
|
-
var TextInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n
|
|
550
|
+
var TextInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
549
551
|
return calculateWidth(props.margin, props.size);
|
|
550
552
|
}, function (props) {
|
|
551
553
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -593,16 +595,14 @@ var HelperText = _styledComponents["default"].span(_templateObject4 || (_templat
|
|
|
593
595
|
return props.theme.helperTextLineHeight;
|
|
594
596
|
});
|
|
595
597
|
|
|
596
|
-
var InputContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
598
|
+
var InputContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n position: relative;\n display: flex;\n align-items: center;\n height: calc(2.5rem - 2px);\n padding: 0 0.5rem;\n\n ", "\n box-shadow: 0 0 0 2px transparent;\n border-radius: 4px;\n border: 1px solid\n ", ";\n ", "\n\n ", ";\n"])), function (props) {
|
|
597
599
|
if (props.disabled) return props.backgroundType === "dark" ? "background-color: ".concat(props.theme.disabledContainerFillColorOnDark, ";") : "background-color: ".concat(props.theme.disabledContainerFillColor, ";");
|
|
598
600
|
}, function (props) {
|
|
599
|
-
if (props.disabled) return props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;else return props.backgroundType === "dark" ? props.theme.enabledBorderColorOnDark : props.theme.enabledBorderColor;
|
|
601
|
+
if (props.disabled) return props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;else if (props.readOnly) return props.theme.readOnlyBorderColor;else return props.backgroundType === "dark" ? props.theme.enabledBorderColorOnDark : props.theme.enabledBorderColor;
|
|
600
602
|
}, function (props) {
|
|
601
603
|
return props.error && !props.disabled && "border-color: transparent;\n box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.errorBorderColorOnDark : props.theme.errorBorderColor, ";\n ");
|
|
602
604
|
}, function (props) {
|
|
603
|
-
return props.disabled
|
|
604
|
-
}, 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 && "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 ");
|
|
605
|
+
return !props.disabled ? "\n &:hover {\n border-color: ".concat(props.error ? "transparent" : props.readOnly ? props.theme.hoverReadOnlyBorderColor : 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 ") : "cursor: not-allowed;";
|
|
606
606
|
});
|
|
607
607
|
|
|
608
608
|
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) {
|
|
@@ -621,39 +621,35 @@ var Input = _styledComponents["default"].input(_templateObject6 || (_templateObj
|
|
|
621
621
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPlaceholderFontColorOnDark : props.theme.disabledPlaceholderFontColor : props.backgroundType === "dark" ? props.theme.placeholderFontColorOnDark : props.theme.placeholderFontColor;
|
|
622
622
|
});
|
|
623
623
|
|
|
624
|
-
var
|
|
625
|
-
|
|
626
|
-
var Action = _styledComponents["default"].button(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n font-size: 1rem;\n font-family: ", ";\n border: 1px solid transparent;\n border-radius: 2px;\n padding: 3px;\n margin-left: 0.25rem;\n ", "\n\n box-shadow: 0 0 0 2px transparent;\n background-color: ", ";\n\n color: ", ";\n\n ", "\n\n svg {\n line-height: 18px;\n }\n"])), function (props) {
|
|
627
|
-
return props.theme.fontFamily;
|
|
628
|
-
}, function (props) {
|
|
624
|
+
var Action = _styledComponents["default"].button(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n border: 1px solid transparent;\n border-radius: 2px;\n width: 24px;\n height: 24px;\n padding: 3px;\n margin-left: 0.25rem;\n ", "\n\n box-shadow: 0 0 0 2px transparent;\n background-color: ", ";\n\n color: ", ";\n\n ", "\n\n img, svg {\n width: 16px;\n height: 16px;\n }\n"])), function (props) {
|
|
629
625
|
return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
|
|
630
626
|
}, function (props) {
|
|
631
627
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledActionBackgroundColorOnDark : props.theme.disabledActionBackgroundColor : props.backgroundType === "dark" ? props.theme.actionBackgroundColorOnDark : props.theme.actionBackgroundColor;
|
|
632
628
|
}, function (props) {
|
|
633
629
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledActionIconColorOnDark : props.theme.disabledActionIconColor : props.backgroundType === "dark" ? props.theme.actionIconColorOnDark : props.theme.actionIconColor;
|
|
634
630
|
}, function (props) {
|
|
635
|
-
return !props.disabled && "\n &:focus
|
|
631
|
+
return !props.disabled && "\n &:focus, \n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.focusActionBorderColorOnDark : props.theme.focusActionBorderColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.focusActionIconColorOnDark : props.theme.focusActionIconColor, ";\n }\n &:hover {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionBackgroundColorOnDark : props.theme.hoverActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionIconColorOnDark : props.theme.hoverActionIconColor, ";\n }\n &:active {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionBackgroundColorOnDark : props.theme.activeActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionIconColorOnDark : props.theme.activeActionIconColor, ";\n }\n ");
|
|
636
632
|
});
|
|
637
633
|
|
|
638
|
-
var Prefix = _styledComponents["default"].span(
|
|
634
|
+
var Prefix = _styledComponents["default"].span(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n height: 1.5rem;\n line-height: 1.5rem;\n margin-left: 0.25rem;\n padding: 0 0.5rem 0 0;\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"])), function (props) {
|
|
639
635
|
var color = props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPrefixColorOnDark : props.theme.disabledPrefixColor : props.backgroundType === "dark" ? props.theme.prefixColorOnDark : props.theme.prefixColor;
|
|
640
636
|
return "color: ".concat(color, "; border-right: 1px solid ").concat(color, ";");
|
|
641
637
|
}, function (props) {
|
|
642
638
|
return props.theme.fontFamily;
|
|
643
639
|
});
|
|
644
640
|
|
|
645
|
-
var Suffix = _styledComponents["default"].span(
|
|
641
|
+
var Suffix = _styledComponents["default"].span(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n height: 1.5rem;\n line-height: 1.5rem;\n margin: 0 0.25rem;\n padding: 0 0 0 0.5rem;\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"])), function (props) {
|
|
646
642
|
var color = props.disabled ? props.backgroundType === "dark" ? props.theme.disabledSuffixColorOnDark : props.theme.disabledSuffixColor : props.backgroundType === "dark" ? props.theme.suffixColorOnDark : props.theme.suffixColor;
|
|
647
643
|
return "color: ".concat(color, "; border-left: 1px solid ").concat(color, ";");
|
|
648
644
|
}, function (props) {
|
|
649
645
|
return props.theme.fontFamily;
|
|
650
646
|
});
|
|
651
647
|
|
|
652
|
-
var ErrorIcon = _styledComponents["default"].span(
|
|
648
|
+
var ErrorIcon = _styledComponents["default"].span(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n padding: 3px;\n height: 18px;\n width: 18px;\n margin-left: 0.25rem;\n color: ", ";\n\n svg {\n line-height: 18px;\n font-size: 1.25rem;\n }\n"])), function (props) {
|
|
653
649
|
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
654
650
|
});
|
|
655
651
|
|
|
656
|
-
var Error = _styledComponents["default"].span(
|
|
652
|
+
var Error = _styledComponents["default"].span(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 1.5em;\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n line-height: 1.5em;\n margin-top: 0.25rem;\n"])), function (props) {
|
|
657
653
|
return props.backgroundType === "dark" ? props.theme.errorMessageColorOnDark : props.theme.errorMessageColor;
|
|
658
654
|
}, function (props) {
|
|
659
655
|
return props.theme.fontFamily;
|