@dxc-technology/halstack-react 0.0.0-0e90110 → 0.0.0-0ea575c
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.js +0 -1
- package/HalstackContext.d.ts +12 -0
- package/HalstackContext.js +295 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +122 -135
- package/accordion/Accordion.stories.tsx +306 -0
- package/accordion/Accordion.test.js +71 -0
- package/accordion/types.d.ts +11 -11
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +15 -36
- package/accordion-group/AccordionGroup.stories.tsx +28 -2
- package/accordion-group/AccordionGroup.test.js +126 -0
- package/accordion-group/types.d.ts +16 -10
- package/alert/Alert.js +5 -2
- package/alert/Alert.test.js +92 -0
- package/badge/Badge.d.ts +4 -0
- package/badge/Badge.js +5 -3
- package/badge/types.d.ts +5 -0
- package/{radio → badge}/types.js +0 -0
- package/bleed/Bleed.d.ts +3 -0
- package/bleed/Bleed.js +51 -0
- package/bleed/Bleed.stories.tsx +341 -0
- package/bleed/types.d.ts +37 -0
- package/bleed/types.js +5 -0
- package/box/Box.js +23 -33
- package/box/Box.test.js +18 -0
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +123 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/bulleted-list/types.js +5 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +57 -80
- package/button/Button.stories.tsx +15 -8
- package/button/Button.test.js +35 -0
- package/button/types.d.ts +8 -12
- package/card/Card.js +24 -27
- package/card/Card.stories.tsx +1 -1
- package/card/Card.test.js +50 -0
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +102 -106
- package/checkbox/Checkbox.stories.tsx +124 -128
- package/checkbox/Checkbox.test.js +155 -0
- package/checkbox/types.d.ts +10 -6
- package/chip/Chip.d.ts +1 -1
- package/chip/Chip.js +16 -54
- package/chip/Chip.stories.tsx +6 -8
- package/chip/Chip.test.js +56 -0
- package/chip/types.d.ts +7 -15
- package/common/variables.js +289 -359
- package/date-input/DateInput.js +65 -54
- package/date-input/DateInput.stories.tsx +7 -7
- package/date-input/DateInput.test.js +479 -0
- package/date-input/types.d.ts +16 -9
- package/dialog/Dialog.js +48 -51
- package/dialog/Dialog.stories.tsx +57 -2
- package/dialog/Dialog.test.js +70 -0
- package/dialog/types.d.ts +2 -2
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +243 -273
- package/dropdown/Dropdown.stories.tsx +312 -0
- package/dropdown/Dropdown.test.js +591 -0
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +80 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +92 -0
- package/dropdown/types.d.ts +29 -18
- package/file-input/FileInput.d.ts +1 -1
- package/file-input/FileInput.js +152 -70
- package/file-input/FileInput.stories.tsx +507 -0
- package/file-input/FileInput.test.js +457 -0
- package/file-input/FileItem.js +9 -7
- package/file-input/types.d.ts +32 -7
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +57 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +21 -0
- package/flex/types.js +5 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +30 -111
- package/footer/{Footer.stories.jsx → Footer.stories.tsx} +5 -19
- package/footer/Footer.test.js +109 -0
- package/footer/Icons.d.ts +2 -0
- package/footer/Icons.js +4 -4
- package/footer/types.d.ts +5 -9
- package/header/Header.js +95 -114
- package/header/Header.stories.tsx +46 -36
- package/header/Header.test.js +79 -0
- package/header/Icons.d.ts +2 -0
- package/header/Icons.js +2 -2
- package/header/types.d.ts +2 -2
- package/heading/Heading.stories.tsx +3 -2
- package/heading/Heading.test.js +186 -0
- package/inset/Inset.d.ts +3 -0
- package/inset/Inset.js +51 -0
- package/inset/Inset.stories.tsx +229 -0
- package/inset/types.d.ts +37 -0
- package/inset/types.js +5 -0
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +71 -124
- package/layout/ApplicationLayout.stories.tsx +162 -0
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +13 -2
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +18 -33
- package/link/Link.d.ts +3 -2
- package/link/Link.js +60 -85
- package/link/Link.stories.tsx +99 -52
- package/link/Link.test.js +83 -0
- package/link/types.d.ts +9 -29
- package/main.d.ts +11 -11
- package/main.js +63 -57
- package/number-input/NumberInput.js +14 -24
- package/number-input/NumberInput.stories.tsx +5 -5
- package/number-input/NumberInput.test.js +506 -0
- package/number-input/types.d.ts +17 -10
- package/package.json +16 -12
- package/paginator/Paginator.js +17 -44
- package/paginator/Paginator.test.js +308 -0
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/PasswordInput.js +19 -17
- package/password-input/PasswordInput.stories.tsx +3 -3
- package/password-input/PasswordInput.test.js +180 -0
- package/password-input/types.d.ts +14 -11
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +57 -51
- package/progress-bar/ProgressBar.stories.jsx +13 -11
- package/progress-bar/ProgressBar.test.js +110 -0
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +115 -0
- package/quick-nav/QuickNav.stories.tsx +300 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio-group/Radio.d.ts +4 -0
- package/radio-group/Radio.js +156 -0
- package/radio-group/RadioGroup.d.ts +4 -0
- package/radio-group/RadioGroup.js +279 -0
- package/radio-group/RadioGroup.stories.tsx +101 -0
- package/radio-group/RadioGroup.test.js +665 -0
- package/radio-group/types.d.ts +114 -0
- package/radio-group/types.js +5 -0
- package/resultsetTable/ResultsetTable.js +5 -2
- package/resultsetTable/ResultsetTable.stories.tsx +275 -0
- package/resultsetTable/ResultsetTable.test.js +348 -0
- package/resultsetTable/types.d.ts +1 -1
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +93 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +198 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +110 -0
- package/select/Select.d.ts +4 -0
- package/select/Select.js +157 -379
- package/select/Select.stories.tsx +231 -176
- package/select/Select.test.js +2175 -0
- package/select/types.d.ts +210 -0
- package/select/types.js +5 -0
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +184 -52
- package/sidenav/Sidenav.stories.tsx +154 -139
- package/sidenav/Sidenav.test.js +44 -0
- package/sidenav/types.d.ts +50 -27
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +118 -93
- package/slider/Slider.stories.tsx +15 -9
- package/slider/Slider.test.js +250 -0
- package/slider/types.d.ts +6 -2
- package/spinner/Spinner.js +1 -1
- package/spinner/Spinner.stories.jsx +1 -0
- package/spinner/Spinner.test.js +64 -0
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +147 -65
- package/switch/Switch.stories.tsx +21 -43
- package/switch/Switch.test.js +225 -0
- package/switch/types.d.ts +9 -6
- package/table/Table.stories.jsx +2 -1
- package/table/Table.test.js +26 -0
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +135 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +364 -110
- package/tabs/Tabs.stories.tsx +81 -16
- package/tabs/Tabs.test.js +351 -0
- package/tabs/types.d.ts +39 -17
- package/tabs-nav/NavTabs.d.ts +8 -0
- package/tabs-nav/NavTabs.js +125 -0
- package/tabs-nav/NavTabs.stories.tsx +170 -0
- package/tabs-nav/NavTabs.test.js +82 -0
- package/tabs-nav/Tab.d.ts +4 -0
- package/tabs-nav/Tab.js +130 -0
- package/tabs-nav/types.d.ts +53 -0
- package/tabs-nav/types.js +5 -0
- package/tag/Tag.d.ts +1 -1
- package/tag/Tag.js +18 -28
- package/tag/Tag.stories.tsx +26 -29
- package/tag/Tag.test.js +60 -0
- package/tag/types.d.ts +23 -14
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +60 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +57 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +134 -0
- package/text-input/TextInput.js +154 -279
- package/text-input/TextInput.stories.tsx +218 -193
- package/text-input/TextInput.test.js +1713 -0
- package/text-input/types.d.ts +46 -13
- package/textarea/Textarea.d.ts +4 -0
- package/textarea/Textarea.js +32 -71
- package/textarea/Textarea.stories.jsx +37 -15
- package/textarea/Textarea.test.js +437 -0
- package/textarea/types.d.ts +137 -0
- package/textarea/types.js +5 -0
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +14 -16
- package/toggle-group/ToggleGroup.stories.tsx +27 -32
- package/toggle-group/ToggleGroup.test.js +156 -0
- package/toggle-group/types.d.ts +46 -25
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +131 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.js +2 -2
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +111 -57
- package/wizard/{Wizard.stories.jsx → Wizard.stories.tsx} +33 -24
- package/wizard/Wizard.test.js +141 -0
- package/wizard/types.d.ts +12 -11
- package/ThemeContext.d.ts +0 -15
- package/ThemeContext.js +0 -243
- package/V3Select/V3Select.js +0 -455
- package/V3Select/index.d.ts +0 -27
- package/V3Textarea/V3Textarea.js +0 -260
- package/V3Textarea/index.d.ts +0 -27
- package/date/Date.js +0 -373
- package/date/index.d.ts +0 -27
- package/input-text/Icons.js +0 -22
- package/input-text/InputText.js +0 -611
- package/input-text/index.d.ts +0 -36
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/types.d.ts +0 -54
- package/select/index.d.ts +0 -131
- package/textarea/index.d.ts +0 -127
- package/toggle/Toggle.js +0 -186
- package/toggle/index.d.ts +0 -21
- package/upload/Upload.js +0 -201
- package/upload/buttons-upload/ButtonsUpload.js +0 -111
- package/upload/buttons-upload/Icons.js +0 -40
- package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
- package/upload/dragAndDropArea/Icons.js +0 -39
- package/upload/file-upload/FileToUpload.js +0 -115
- package/upload/file-upload/Icons.js +0 -66
- package/upload/files-upload/FilesToUpload.js +0 -109
- package/upload/index.d.ts +0 -15
- package/upload/transaction/Icons.js +0 -160
- package/upload/transaction/Transaction.js +0 -104
- package/upload/transactions/Transactions.js +0 -94
- package/wizard/Icons.js +0 -65
package/text-input/TextInput.js
CHANGED
|
@@ -21,68 +21,39 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
21
21
|
|
|
22
22
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
23
23
|
|
|
24
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
25
|
+
|
|
24
26
|
var _variables = require("../common/variables.js");
|
|
25
27
|
|
|
26
28
|
var _utils = require("../common/utils.js");
|
|
27
29
|
|
|
28
|
-
var _uuid = require("uuid");
|
|
29
|
-
|
|
30
30
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
31
31
|
|
|
32
32
|
var _NumberInputContext = _interopRequireDefault(require("../number-input/NumberInputContext"));
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _Suggestions = _interopRequireDefault(require("./Suggestions"));
|
|
35
|
+
|
|
36
|
+
var Popover = _interopRequireWildcard(require("@radix-ui/react-popover"));
|
|
37
|
+
|
|
38
|
+
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
39
|
+
|
|
40
|
+
var _uuid = require("uuid");
|
|
41
|
+
|
|
42
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
|
|
35
43
|
|
|
36
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); }
|
|
37
45
|
|
|
38
46
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
47
|
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
})),
|
|
50
|
-
clear: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
51
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
52
|
-
width: "24",
|
|
53
|
-
height: "24",
|
|
54
|
-
viewBox: "0 0 24 24",
|
|
55
|
-
fill: "currentColor"
|
|
56
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
57
|
-
d: "M0 0h24v24H0V0z",
|
|
58
|
-
fill: "none"
|
|
59
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
60
|
-
d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
|
|
61
|
-
})),
|
|
62
|
-
increment: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
63
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
64
|
-
height: "24px",
|
|
65
|
-
viewBox: "0 0 24 24",
|
|
66
|
-
width: "24px",
|
|
67
|
-
fill: "currentColor"
|
|
68
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
69
|
-
d: "M0 0h24v24H0z",
|
|
70
|
-
fill: "none"
|
|
71
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
72
|
-
d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"
|
|
73
|
-
})),
|
|
74
|
-
decrement: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
75
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
76
|
-
height: "24px",
|
|
77
|
-
viewBox: "0 0 24 24",
|
|
78
|
-
width: "24px",
|
|
79
|
-
fill: "currentColor"
|
|
80
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
81
|
-
d: "M0 0h24v24H0z",
|
|
82
|
-
fill: "none"
|
|
83
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
84
|
-
d: "M19 13H5v-2h14v2z"
|
|
85
|
-
}))
|
|
48
|
+
var sizes = {
|
|
49
|
+
small: "240px",
|
|
50
|
+
medium: "360px",
|
|
51
|
+
large: "480px",
|
|
52
|
+
fillParent: "100%"
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
var calculateWidth = function calculateWidth(margin, size) {
|
|
56
|
+
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
86
57
|
};
|
|
87
58
|
|
|
88
59
|
var makeCancelable = function makeCancelable(promise) {
|
|
@@ -106,39 +77,18 @@ var makeCancelable = function makeCancelable(promise) {
|
|
|
106
77
|
};
|
|
107
78
|
};
|
|
108
79
|
|
|
109
|
-
var
|
|
110
|
-
return
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
var getPatternErrorMessage = function getPatternErrorMessage() {
|
|
114
|
-
return "Please match the format requested.";
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
var patternMatch = function patternMatch(pattern, value) {
|
|
118
|
-
return new RegExp(pattern).test(value);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
var getLastOptionIndex = function getLastOptionIndex(filteredSuggestions) {
|
|
122
|
-
var last = 0;
|
|
123
|
-
|
|
124
|
-
var reducer = function reducer(acc, current) {
|
|
125
|
-
var _current$options;
|
|
126
|
-
|
|
127
|
-
return acc + ((_current$options = current.options) === null || _current$options === void 0 ? void 0 : _current$options.length);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
if (filteredSuggestions.length > 0) filteredSuggestions[0].options ? last = filteredSuggestions.reduce(reducer, 0) - 1 : last = filteredSuggestions.length - 1;
|
|
131
|
-
return last;
|
|
80
|
+
var patternMissmatch = function patternMissmatch(pattern, value) {
|
|
81
|
+
return pattern && !new RegExp(pattern).test(value);
|
|
132
82
|
};
|
|
133
83
|
|
|
134
84
|
var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
135
|
-
var
|
|
136
|
-
label = _ref$label === void 0 ? "" : _ref$label,
|
|
85
|
+
var label = _ref.label,
|
|
137
86
|
_ref$name = _ref.name,
|
|
138
87
|
name = _ref$name === void 0 ? "" : _ref$name,
|
|
88
|
+
_ref$defaultValue = _ref.defaultValue,
|
|
89
|
+
defaultValue = _ref$defaultValue === void 0 ? "" : _ref$defaultValue,
|
|
139
90
|
value = _ref.value,
|
|
140
|
-
|
|
141
|
-
helperText = _ref$helperText === void 0 ? "" : _ref$helperText,
|
|
91
|
+
helperText = _ref.helperText,
|
|
142
92
|
_ref$placeholder = _ref.placeholder,
|
|
143
93
|
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
144
94
|
action = _ref.action,
|
|
@@ -154,8 +104,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
154
104
|
suffix = _ref$suffix === void 0 ? "" : _ref$suffix,
|
|
155
105
|
onChange = _ref.onChange,
|
|
156
106
|
onBlur = _ref.onBlur,
|
|
157
|
-
|
|
158
|
-
error = _ref$error === void 0 ? "" : _ref$error,
|
|
107
|
+
error = _ref.error,
|
|
159
108
|
suggestions = _ref.suggestions,
|
|
160
109
|
pattern = _ref.pattern,
|
|
161
110
|
minLength = _ref.minLength,
|
|
@@ -167,52 +116,48 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
167
116
|
size = _ref$size === void 0 ? "medium" : _ref$size,
|
|
168
117
|
_ref$tabIndex = _ref.tabIndex,
|
|
169
118
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
119
|
+
var id = (0, _react.useState)((0, _uuid.v4)());
|
|
120
|
+
var inputId = "input-".concat(id);
|
|
121
|
+
var autosuggestId = "suggestions-".concat(id);
|
|
122
|
+
var errorId = "error-".concat(id);
|
|
170
123
|
|
|
171
|
-
var _useState = (0, _react.useState)(
|
|
172
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState,
|
|
173
|
-
|
|
124
|
+
var _useState = (0, _react.useState)(defaultValue),
|
|
125
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
126
|
+
innerValue = _useState2[0],
|
|
127
|
+
setInnerValue = _useState2[1];
|
|
174
128
|
|
|
175
|
-
var _useState3 = (0, _react.useState)(
|
|
129
|
+
var _useState3 = (0, _react.useState)(false),
|
|
176
130
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
177
|
-
|
|
178
|
-
|
|
131
|
+
isOpen = _useState4[0],
|
|
132
|
+
changeIsOpen = _useState4[1];
|
|
179
133
|
|
|
180
134
|
var _useState5 = (0, _react.useState)(false),
|
|
181
135
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
182
|
-
|
|
183
|
-
|
|
136
|
+
isSearching = _useState6[0],
|
|
137
|
+
changeIsSearching = _useState6[1];
|
|
184
138
|
|
|
185
139
|
var _useState7 = (0, _react.useState)(false),
|
|
186
140
|
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
187
|
-
|
|
188
|
-
|
|
141
|
+
isAutosuggestError = _useState8[0],
|
|
142
|
+
changeIsAutosuggestError = _useState8[1];
|
|
189
143
|
|
|
190
|
-
var _useState9 = (0, _react.useState)(
|
|
144
|
+
var _useState9 = (0, _react.useState)([]),
|
|
191
145
|
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
192
|
-
|
|
193
|
-
|
|
146
|
+
filteredSuggestions = _useState10[0],
|
|
147
|
+
changeFilteredSuggestions = _useState10[1];
|
|
194
148
|
|
|
195
|
-
var _useState11 = (0, _react.useState)(
|
|
149
|
+
var _useState11 = (0, _react.useState)(-1),
|
|
196
150
|
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
var _useState13 = (0, _react.useState)(-1),
|
|
201
|
-
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
202
|
-
visualFocusedSuggIndex = _useState14[0],
|
|
203
|
-
changeVisualFocusedSuggIndex = _useState14[1];
|
|
151
|
+
visualFocusIndex = _useState12[0],
|
|
152
|
+
changeVisualFocusIndex = _useState12[1];
|
|
204
153
|
|
|
205
|
-
var
|
|
154
|
+
var inputContainerRef = (0, _react.useRef)(null);
|
|
206
155
|
var inputRef = (0, _react.useRef)(null);
|
|
207
156
|
var actionRef = (0, _react.useRef)(null);
|
|
208
157
|
var colorsTheme = (0, _useTheme["default"])();
|
|
158
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
209
159
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
210
|
-
var autosuggestId = "".concat(inputId, "-listBox");
|
|
211
|
-
var errorId = "error-message-".concat(inputId);
|
|
212
160
|
var numberInputContext = (0, _react.useContext)(_NumberInputContext["default"]);
|
|
213
|
-
var lastOptionIndex = (0, _react.useMemo)(function () {
|
|
214
|
-
return getLastOptionIndex(filteredSuggestions);
|
|
215
|
-
}, [filteredSuggestions]);
|
|
216
161
|
|
|
217
162
|
var isNotOptional = function isNotOptional(value) {
|
|
218
163
|
return value === "" && !optional;
|
|
@@ -222,10 +167,6 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
222
167
|
return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
|
|
223
168
|
};
|
|
224
169
|
|
|
225
|
-
var getLengthErrorMessage = function getLengthErrorMessage() {
|
|
226
|
-
return "Min length ".concat(minLength, ", max length ").concat(maxLength, ".");
|
|
227
|
-
};
|
|
228
|
-
|
|
229
170
|
var isNumberIncorrect = function isNumberIncorrect(value) {
|
|
230
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);
|
|
231
172
|
};
|
|
@@ -237,7 +178,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
237
178
|
};
|
|
238
179
|
|
|
239
180
|
var getNumberErrorMessage = function getNumberErrorMessage(value) {
|
|
240
|
-
if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && parseInt(value) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) return
|
|
181
|
+
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);
|
|
241
182
|
};
|
|
242
183
|
|
|
243
184
|
var hasSuggestions = function hasSuggestions() {
|
|
@@ -249,8 +190,10 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
249
190
|
};
|
|
250
191
|
|
|
251
192
|
var closeSuggestions = function closeSuggestions() {
|
|
252
|
-
|
|
253
|
-
|
|
193
|
+
if (hasSuggestions()) {
|
|
194
|
+
changeIsOpen(false);
|
|
195
|
+
changeVisualFocusIndex(-1);
|
|
196
|
+
}
|
|
254
197
|
};
|
|
255
198
|
|
|
256
199
|
var changeValue = function changeValue(newValue) {
|
|
@@ -258,19 +201,18 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
258
201
|
var changedValue = typeof newValue === "number" ? newValue.toString() : newValue;
|
|
259
202
|
if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
260
203
|
value: changedValue,
|
|
261
|
-
error:
|
|
204
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
262
205
|
});else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
263
206
|
value: changedValue,
|
|
264
|
-
error:
|
|
265
|
-
});else if (
|
|
207
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
208
|
+
});else if (patternMissmatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
266
209
|
value: changedValue,
|
|
267
|
-
error:
|
|
268
|
-
});else if (
|
|
210
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
211
|
+
});else if (isNumberIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
269
212
|
value: changedValue,
|
|
270
213
|
error: getNumberErrorMessage(newValue)
|
|
271
214
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
272
|
-
value: changedValue
|
|
273
|
-
error: null
|
|
215
|
+
value: changedValue
|
|
274
216
|
});
|
|
275
217
|
};
|
|
276
218
|
|
|
@@ -289,38 +231,37 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
289
231
|
};
|
|
290
232
|
|
|
291
233
|
var handleIOnBlur = function handleIOnBlur(event) {
|
|
292
|
-
|
|
234
|
+
closeSuggestions();
|
|
293
235
|
if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
294
236
|
value: event.target.value,
|
|
295
|
-
error:
|
|
237
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
296
238
|
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
297
239
|
value: event.target.value,
|
|
298
|
-
error:
|
|
299
|
-
});else if (
|
|
240
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
241
|
+
});else if (patternMissmatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
300
242
|
value: event.target.value,
|
|
301
|
-
error:
|
|
302
|
-
});else if (
|
|
243
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
244
|
+
});else if (isNumberIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
303
245
|
value: event.target.value,
|
|
304
246
|
error: getNumberErrorMessage(event.target.value)
|
|
305
247
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
306
|
-
value: event.target.value
|
|
307
|
-
error: null
|
|
248
|
+
value: event.target.value
|
|
308
249
|
});
|
|
309
250
|
};
|
|
310
251
|
|
|
311
252
|
var handleIOnKeyDown = function handleIOnKeyDown(event) {
|
|
312
|
-
switch (event.
|
|
313
|
-
case
|
|
314
|
-
|
|
253
|
+
switch (event.key) {
|
|
254
|
+
case "Down":
|
|
255
|
+
case "ArrowDown":
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
|
|
315
258
|
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
316
259
|
decrementNumber();
|
|
317
|
-
event.preventDefault();
|
|
318
260
|
} else {
|
|
319
|
-
event.preventDefault();
|
|
320
261
|
openSuggestions();
|
|
321
262
|
|
|
322
263
|
if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
|
|
323
|
-
|
|
264
|
+
changeVisualFocusIndex(function (visualFocusedSuggIndex) {
|
|
324
265
|
if (visualFocusedSuggIndex < filteredSuggestions.length - 1) return visualFocusedSuggIndex + 1;else if (visualFocusedSuggIndex === filteredSuggestions.length - 1) return 0;
|
|
325
266
|
});
|
|
326
267
|
}
|
|
@@ -328,17 +269,17 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
328
269
|
|
|
329
270
|
break;
|
|
330
271
|
|
|
331
|
-
case
|
|
332
|
-
|
|
272
|
+
case "Up":
|
|
273
|
+
case "ArrowUp":
|
|
274
|
+
event.preventDefault();
|
|
275
|
+
|
|
333
276
|
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
334
277
|
incrementNumber();
|
|
335
|
-
event.preventDefault();
|
|
336
278
|
} else {
|
|
337
|
-
event.preventDefault();
|
|
338
279
|
openSuggestions();
|
|
339
280
|
|
|
340
281
|
if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
|
|
341
|
-
|
|
282
|
+
changeVisualFocusIndex(function (visualFocusedSuggIndex) {
|
|
342
283
|
if (visualFocusedSuggIndex === 0 || visualFocusedSuggIndex === -1) return filteredSuggestions.length > 0 ? filteredSuggestions.length - 1 : suggestions.length - 1;else return visualFocusedSuggIndex - 1;
|
|
343
284
|
});
|
|
344
285
|
}
|
|
@@ -346,8 +287,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
346
287
|
|
|
347
288
|
break;
|
|
348
289
|
|
|
349
|
-
case
|
|
350
|
-
|
|
290
|
+
case "Esc":
|
|
291
|
+
case "Escape":
|
|
351
292
|
event.preventDefault();
|
|
352
293
|
|
|
353
294
|
if (hasSuggestions()) {
|
|
@@ -357,11 +298,10 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
357
298
|
|
|
358
299
|
break;
|
|
359
300
|
|
|
360
|
-
case
|
|
361
|
-
// Enter
|
|
301
|
+
case "Enter":
|
|
362
302
|
if (hasSuggestions() && !isSearching) {
|
|
363
|
-
var validFocusedSuggestion = filteredSuggestions.length > 0 &&
|
|
364
|
-
validFocusedSuggestion && changeValue(filteredSuggestions[
|
|
303
|
+
var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusIndex >= 0 && visualFocusIndex < filteredSuggestions.length;
|
|
304
|
+
validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusIndex]);
|
|
365
305
|
isOpen && closeSuggestions();
|
|
366
306
|
}
|
|
367
307
|
|
|
@@ -434,15 +374,12 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
434
374
|
}
|
|
435
375
|
};
|
|
436
376
|
|
|
437
|
-
(0, _react.
|
|
438
|
-
var
|
|
377
|
+
var getTextInputWidth = (0, _react.useCallback)(function () {
|
|
378
|
+
var _inputContainerRef$cu;
|
|
439
379
|
|
|
440
|
-
var
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
inline: "start"
|
|
444
|
-
});
|
|
445
|
-
}, [visualFocusedSuggIndex]);
|
|
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
|
+
}, []);
|
|
446
383
|
(0, _react.useEffect)(function () {
|
|
447
384
|
if (typeof suggestions === "function") {
|
|
448
385
|
changeIsSearching(true);
|
|
@@ -466,53 +403,36 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
466
403
|
changeFilteredSuggestions(suggestions.filter(function (suggestion) {
|
|
467
404
|
return suggestion.toUpperCase().startsWith((value !== null && value !== void 0 ? value : innerValue).toUpperCase());
|
|
468
405
|
}));
|
|
469
|
-
|
|
406
|
+
changeVisualFocusIndex(-1);
|
|
470
407
|
}
|
|
471
408
|
|
|
472
409
|
(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
473
410
|
}, [value, innerValue, suggestions, numberInputContext]);
|
|
474
|
-
|
|
475
|
-
var HighlightedSuggestion = function HighlightedSuggestion(_ref2) {
|
|
476
|
-
var suggestion = _ref2.suggestion,
|
|
477
|
-
index = _ref2.index;
|
|
478
|
-
var regEx = new RegExp(value !== null && value !== void 0 ? value : innerValue, "i");
|
|
479
|
-
var matchedWords = suggestion.match(regEx);
|
|
480
|
-
var noMatchedWords = suggestion.replace(regEx, "");
|
|
481
|
-
var isLastOption = index === lastOptionIndex;
|
|
482
|
-
return /*#__PURE__*/_react["default"].createElement(Suggestion, {
|
|
483
|
-
id: "suggestion-".concat(index),
|
|
484
|
-
onClick: function onClick() {
|
|
485
|
-
changeValue(suggestion);
|
|
486
|
-
closeSuggestions();
|
|
487
|
-
},
|
|
488
|
-
visualFocused: visualFocusedSuggIndex === index,
|
|
489
|
-
role: "option",
|
|
490
|
-
"aria-selected": visualFocusedSuggIndex === index && "true"
|
|
491
|
-
}, /*#__PURE__*/_react["default"].createElement(StyledSuggestion, {
|
|
492
|
-
last: isLastOption,
|
|
493
|
-
visualFocused: visualFocusedSuggIndex === index
|
|
494
|
-
}, typeof suggestions === "function" ? suggestion : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedWords), noMatchedWords)));
|
|
495
|
-
};
|
|
496
|
-
|
|
497
411
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
498
412
|
theme: colorsTheme.textInput
|
|
499
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
413
|
+
}, /*#__PURE__*/_react["default"].createElement(TextInputContainer, {
|
|
500
414
|
margin: margin,
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}, /*#__PURE__*/_react["default"].createElement(Label, {
|
|
415
|
+
size: size,
|
|
416
|
+
ref: ref
|
|
417
|
+
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
504
418
|
htmlFor: inputId,
|
|
505
419
|
disabled: disabled,
|
|
506
|
-
backgroundType: backgroundType
|
|
507
|
-
|
|
420
|
+
backgroundType: backgroundType,
|
|
421
|
+
hasHelperText: helperText ? true : false
|
|
422
|
+
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
508
423
|
disabled: disabled,
|
|
509
424
|
backgroundType: backgroundType
|
|
510
|
-
}, helperText), /*#__PURE__*/_react["default"].createElement(
|
|
511
|
-
|
|
425
|
+
}, helperText), /*#__PURE__*/_react["default"].createElement(Popover.Root, {
|
|
426
|
+
open: isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError)
|
|
427
|
+
}, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
|
|
428
|
+
asChild: true
|
|
429
|
+
}, /*#__PURE__*/_react["default"].createElement(InputContainer, {
|
|
430
|
+
error: error ? true : false,
|
|
512
431
|
disabled: disabled,
|
|
513
432
|
backgroundType: backgroundType,
|
|
514
433
|
onClick: handleInputContainerOnClick,
|
|
515
|
-
onMouseDown: handleInputContainerOnMouseDown
|
|
434
|
+
onMouseDown: handleInputContainerOnMouseDown,
|
|
435
|
+
ref: inputContainerRef
|
|
516
436
|
}, prefix && /*#__PURE__*/_react["default"].createElement(Prefix, {
|
|
517
437
|
disabled: disabled,
|
|
518
438
|
backgroundType: backgroundType
|
|
@@ -523,9 +443,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
523
443
|
placeholder: placeholder,
|
|
524
444
|
onBlur: handleIOnBlur,
|
|
525
445
|
onChange: handleIOnChange,
|
|
526
|
-
onFocus:
|
|
527
|
-
openSuggestions();
|
|
528
|
-
},
|
|
446
|
+
onFocus: openSuggestions,
|
|
529
447
|
onKeyDown: handleIOnKeyDown,
|
|
530
448
|
onMouseDown: function onMouseDown(event) {
|
|
531
449
|
event.stopPropagation();
|
|
@@ -536,29 +454,30 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
536
454
|
pattern: pattern,
|
|
537
455
|
minLength: minLength,
|
|
538
456
|
maxLength: maxLength,
|
|
539
|
-
autoComplete: autocomplete,
|
|
457
|
+
autoComplete: autocomplete === "off" ? "nope" : autocomplete,
|
|
540
458
|
tabIndex: tabIndex,
|
|
541
459
|
role: isTextInputType() && hasSuggestions() ? "combobox" : "textbox",
|
|
542
460
|
"aria-autocomplete": isTextInputType() && hasSuggestions() ? "list" : undefined,
|
|
543
461
|
"aria-controls": isTextInputType() && hasSuggestions() ? autosuggestId : undefined,
|
|
544
|
-
"aria-
|
|
545
|
-
"aria-
|
|
546
|
-
"aria-
|
|
547
|
-
"aria-
|
|
548
|
-
"aria-
|
|
462
|
+
"aria-disabled": disabled,
|
|
463
|
+
"aria-expanded": isTextInputType() && hasSuggestions() ? isOpen : undefined,
|
|
464
|
+
"aria-activedescendant": isTextInputType() && hasSuggestions() && isOpen && visualFocusIndex !== -1 ? "suggestion-".concat(visualFocusIndex) : undefined,
|
|
465
|
+
"aria-invalid": error ? true : false,
|
|
466
|
+
"aria-errormessage": error ? errorId : undefined,
|
|
467
|
+
"aria-required": optional ? false : true
|
|
549
468
|
}), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
|
|
550
469
|
backgroundType: backgroundType,
|
|
551
470
|
"aria-label": "Error"
|
|
552
|
-
},
|
|
471
|
+
}, _Icons["default"].error), !disabled && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
553
472
|
onClick: handleClearActionOnClick,
|
|
554
473
|
onMouseDown: function onMouseDown(event) {
|
|
555
474
|
event.stopPropagation();
|
|
556
475
|
},
|
|
557
476
|
backgroundType: backgroundType,
|
|
558
477
|
tabIndex: tabIndex,
|
|
559
|
-
title:
|
|
560
|
-
"aria-label":
|
|
561
|
-
},
|
|
478
|
+
title: translatedLabels.textInput.clearFieldActionTitle,
|
|
479
|
+
"aria-label": translatedLabels.textInput.clearFieldActionTitle
|
|
480
|
+
}, _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, {
|
|
562
481
|
ref: actionRef,
|
|
563
482
|
disabled: disabled,
|
|
564
483
|
onClick: handleDecrementActionOnClick,
|
|
@@ -567,9 +486,9 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
567
486
|
},
|
|
568
487
|
backgroundType: backgroundType,
|
|
569
488
|
tabIndex: tabIndex,
|
|
570
|
-
title:
|
|
571
|
-
"aria-label":
|
|
572
|
-
},
|
|
489
|
+
title: translatedLabels.numberInput.decrementValueTitle,
|
|
490
|
+
"aria-label": translatedLabels.numberInput.decrementValueTitle
|
|
491
|
+
}, _Icons["default"].decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
573
492
|
ref: actionRef,
|
|
574
493
|
disabled: disabled,
|
|
575
494
|
onClick: handleIncrementActionOnClick,
|
|
@@ -578,9 +497,9 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
578
497
|
},
|
|
579
498
|
backgroundType: backgroundType,
|
|
580
499
|
tabIndex: tabIndex,
|
|
581
|
-
title:
|
|
582
|
-
"aria-label":
|
|
583
|
-
},
|
|
500
|
+
title: translatedLabels.numberInput.incrementValueTitle,
|
|
501
|
+
"aria-label": translatedLabels.numberInput.incrementValueTitle
|
|
502
|
+
}, _Icons["default"].increment)), action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
584
503
|
ref: actionRef,
|
|
585
504
|
disabled: disabled,
|
|
586
505
|
onClick: action.onClick,
|
|
@@ -596,41 +515,37 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
596
515
|
}) : action.icon), suffix && /*#__PURE__*/_react["default"].createElement(Suffix, {
|
|
597
516
|
disabled: disabled,
|
|
598
517
|
backgroundType: backgroundType
|
|
599
|
-
}, suffix),
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
518
|
+
}, suffix))), /*#__PURE__*/_react["default"].createElement(Popover.Content, {
|
|
519
|
+
sideOffset: 4,
|
|
520
|
+
onOpenAutoFocus: function onOpenAutoFocus(event) {
|
|
521
|
+
// Avoid select to lose focus when the list is opened
|
|
603
522
|
event.preventDefault();
|
|
604
523
|
},
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
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, {
|
|
617
542
|
id: errorId,
|
|
618
|
-
backgroundType: backgroundType
|
|
543
|
+
backgroundType: backgroundType,
|
|
544
|
+
"aria-live": error ? "assertive" : "off"
|
|
619
545
|
}, error)));
|
|
620
546
|
});
|
|
621
547
|
|
|
622
|
-
var
|
|
623
|
-
small: "240px",
|
|
624
|
-
medium: "360px",
|
|
625
|
-
large: "480px",
|
|
626
|
-
fillParent: "100%"
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
var calculateWidth = function calculateWidth(margin, size) {
|
|
630
|
-
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
631
|
-
};
|
|
632
|
-
|
|
633
|
-
var DxcInput = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
548
|
+
var TextInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
634
549
|
return calculateWidth(props.margin, props.size);
|
|
635
550
|
}, function (props) {
|
|
636
551
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -644,7 +559,7 @@ var DxcInput = _styledComponents["default"].div(_templateObject || (_templateObj
|
|
|
644
559
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
645
560
|
});
|
|
646
561
|
|
|
647
|
-
var Label = _styledComponents["default"].label(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
|
|
562
|
+
var Label = _styledComponents["default"].label(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n ", "\n"])), function (props) {
|
|
648
563
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledLabelFontColorOnDark : props.theme.disabledLabelFontColor : props.backgroundType === "dark" ? props.theme.labelFontColorOnDark : props.theme.labelFontColor;
|
|
649
564
|
}, function (props) {
|
|
650
565
|
return props.theme.fontFamily;
|
|
@@ -656,13 +571,15 @@ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObj
|
|
|
656
571
|
return props.theme.labelFontWeight;
|
|
657
572
|
}, function (props) {
|
|
658
573
|
return props.theme.labelLineHeight;
|
|
574
|
+
}, function (props) {
|
|
575
|
+
return !props.hasHelperText && "margin-bottom: 0.25rem";
|
|
659
576
|
});
|
|
660
577
|
|
|
661
578
|
var OptionalLabel = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: ", ";\n"])), function (props) {
|
|
662
579
|
return props.theme.optionalLabelFontWeight;
|
|
663
580
|
});
|
|
664
581
|
|
|
665
|
-
var HelperText = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
|
|
582
|
+
var HelperText = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n margin-bottom: 0.25rem;\n"])), function (props) {
|
|
666
583
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledHelperTextFontColorOnDark : props.theme.disabledHelperTextFontColor : props.backgroundType === "dark" ? props.theme.helperTextFontColorOnDark : props.theme.helperTextFontColor;
|
|
667
584
|
}, function (props) {
|
|
668
585
|
return props.theme.fontFamily;
|
|
@@ -676,9 +593,7 @@ var HelperText = _styledComponents["default"].span(_templateObject4 || (_templat
|
|
|
676
593
|
return props.theme.helperTextLineHeight;
|
|
677
594
|
});
|
|
678
595
|
|
|
679
|
-
var InputContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n position: relative;\n align-items: center;\n height: calc(2.5rem - 2px);\n
|
|
680
|
-
return "".concat(props.theme.inputMarginTop, " 0 ").concat(props.theme.inputMarginBottom, " 0");
|
|
681
|
-
}, function (props) {
|
|
596
|
+
var InputContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n position: relative;\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 ", ";\n"])), function (props) {
|
|
682
597
|
if (props.disabled) return props.backgroundType === "dark" ? "background-color: ".concat(props.theme.disabledContainerFillColorOnDark, ";") : "background-color: ".concat(props.theme.disabledContainerFillColor, ";");
|
|
683
598
|
}, function (props) {
|
|
684
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;
|
|
@@ -738,51 +653,11 @@ var ErrorIcon = _styledComponents["default"].span(_templateObject11 || (_templat
|
|
|
738
653
|
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
739
654
|
});
|
|
740
655
|
|
|
741
|
-
var Error = _styledComponents["default"].span(_templateObject12 || (_templateObject12 = (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"])), function (props) {
|
|
656
|
+
var Error = _styledComponents["default"].span(_templateObject12 || (_templateObject12 = (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) {
|
|
742
657
|
return props.backgroundType === "dark" ? props.theme.errorMessageColorOnDark : props.theme.errorMessageColor;
|
|
743
658
|
}, function (props) {
|
|
744
659
|
return props.theme.fontFamily;
|
|
745
660
|
});
|
|
746
661
|
|
|
747
|
-
var Suggestions = _styledComponents["default"].ul(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["\n position: absolute;\n z-index: 1;\n max-height: 304px;\n overflow-y: auto;\n top: calc(100% + 4px);\n left: 0;\n margin: 0;\n padding: 0.25rem 0;\n width: 100%;\n background-color: ", ";\n border: 1px solid\n ", ";\n border-radius: 0.25rem;\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n cursor: default;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
748
|
-
return props.isError ? props.theme.errorListDialogBackgroundColor : props.theme.listDialogBackgroundColor;
|
|
749
|
-
}, function (props) {
|
|
750
|
-
return props.isError ? props.theme.errorListDialogBorderColor : props.theme.listDialogBorderColor;
|
|
751
|
-
}, function (props) {
|
|
752
|
-
return props.theme.listOptionFontColor;
|
|
753
|
-
}, function (props) {
|
|
754
|
-
return props.theme.fontFamily;
|
|
755
|
-
}, function (props) {
|
|
756
|
-
return props.theme.listOptionFontSize;
|
|
757
|
-
}, function (props) {
|
|
758
|
-
return props.theme.listOptionFontStyle;
|
|
759
|
-
}, function (props) {
|
|
760
|
-
return props.theme.listOptionFontWeight;
|
|
761
|
-
});
|
|
762
|
-
|
|
763
|
-
var Suggestion = _styledComponents["default"].li(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0 0.5rem;\n line-height: 1.715em;\n cursor: pointer;\n\n box-shadow: inset 0 0 0 2px\n ", ";\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n }\n"])), function (props) {
|
|
764
|
-
return props.visualFocused ? props.theme.focusListOptionBorderColor : "transparent";
|
|
765
|
-
}, function (props) {
|
|
766
|
-
return props.theme.hoverListOptionBackgroundColor;
|
|
767
|
-
}, function (props) {
|
|
768
|
-
return props.theme.activeListOptionBackgroundColor;
|
|
769
|
-
});
|
|
770
|
-
|
|
771
|
-
var StyledSuggestion = _styledComponents["default"].span(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n padding: 0.25rem 0.5rem 0.188rem 0.5rem;\n ", ";\n"])), function (props) {
|
|
772
|
-
return props.last || props.visualFocused ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
var SuggestionsSystemMessage = _styledComponents["default"].span(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.25rem 1rem;\n color: ", ";\n line-height: 1.715em;\n"])), function (props) {
|
|
776
|
-
return props.theme.systemMessageFontColor;
|
|
777
|
-
});
|
|
778
|
-
|
|
779
|
-
var SuggestionsErrorIcon = _styledComponents["default"].span(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n margin-right: 0.5rem;\n height: 18px;\n width: 18px;\n color: ", ";\n"])), function (props) {
|
|
780
|
-
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
var SuggestionsError = _styledComponents["default"].span(_templateObject18 || (_templateObject18 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.25rem 1rem;\n align-items: center;\n line-height: 1.715em;\n color: ", ";\n"])), function (props) {
|
|
784
|
-
return props.theme.errorListDialogFontColor;
|
|
785
|
-
});
|
|
786
|
-
|
|
787
662
|
var _default = DxcTextInput;
|
|
788
663
|
exports["default"] = _default;
|