@dxc-technology/halstack-react 0.0.0-49006fa → 0.0.0-49081f0
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/HalstackContext.d.ts +12 -0
- package/HalstackContext.js +295 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +121 -123
- package/accordion/Accordion.stories.tsx +13 -14
- package/accordion/Accordion.test.js +25 -11
- package/accordion/types.d.ts +9 -4
- 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 +30 -37
- package/accordion-group/types.d.ts +14 -3
- package/alert/Alert.js +5 -2
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +5 -3
- package/badge/types.d.ts +1 -0
- package/bleed/Bleed.js +1 -34
- package/bleed/Bleed.stories.tsx +94 -95
- package/bleed/types.d.ts +1 -1
- package/box/Box.js +23 -33
- package/box/types.d.ts +1 -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/{list → bulleted-list}/types.js +0 -0
- package/button/Button.js +53 -68
- package/button/Button.stories.tsx +9 -0
- package/button/types.d.ts +7 -7
- package/card/Card.js +24 -27
- package/card/types.d.ts +1 -0
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +99 -97
- package/checkbox/Checkbox.stories.tsx +124 -128
- package/checkbox/Checkbox.test.js +93 -16
- package/checkbox/types.d.ts +5 -5
- package/chip/types.d.ts +1 -1
- package/common/variables.js +236 -100
- package/date-input/DateInput.js +41 -23
- package/date-input/DateInput.test.js +9 -22
- package/date-input/types.d.ts +12 -9
- package/dialog/Dialog.js +46 -50
- package/dialog/Dialog.stories.tsx +57 -2
- package/dialog/Dialog.test.js +34 -4
- package/dialog/types.d.ts +3 -2
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +244 -251
- package/dropdown/Dropdown.stories.tsx +126 -63
- package/dropdown/Dropdown.test.js +509 -108
- 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 +25 -5
- package/file-input/FileInput.js +174 -193
- package/file-input/FileInput.stories.tsx +38 -6
- package/file-input/FileInput.test.js +41 -0
- package/file-input/FileItem.d.ts +4 -4
- package/file-input/FileItem.js +29 -39
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +69 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +32 -0
- package/{radio → flex}/types.js +0 -0
- package/footer/Footer.js +15 -88
- package/footer/Footer.stories.tsx +8 -1
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +2 -1
- package/header/Header.js +95 -114
- package/header/Header.stories.tsx +46 -36
- package/header/Header.test.js +18 -2
- package/header/Icons.js +2 -2
- package/header/types.d.ts +3 -2
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +36 -36
- package/inset/types.d.ts +25 -1
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +71 -131
- package/layout/ApplicationLayout.stories.tsx +84 -93
- 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 +57 -74
- package/link/Link.stories.tsx +95 -53
- package/link/Link.test.js +7 -15
- package/link/types.d.ts +7 -23
- package/main.d.ts +8 -10
- package/main.js +46 -56
- package/number-input/NumberInput.test.js +40 -5
- package/number-input/types.d.ts +13 -10
- package/package.json +14 -12
- package/paginator/Paginator.js +17 -38
- package/paginator/Paginator.test.js +43 -1
- 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 +7 -4
- package/password-input/PasswordInput.test.js +16 -18
- 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 +67 -22
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +117 -0
- package/quick-nav/QuickNav.stories.tsx +342 -0
- package/quick-nav/types.d.ts +21 -0
- package/{row → quick-nav}/types.js +0 -0
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +43 -28
- package/radio-group/RadioGroup.js +30 -27
- package/radio-group/RadioGroup.stories.tsx +1 -0
- package/radio-group/RadioGroup.test.js +123 -96
- package/radio-group/types.d.ts +2 -2
- package/resultsetTable/ResultsetTable.js +1 -3
- package/resultsetTable/ResultsetTable.test.js +42 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +198 -0
- package/select/Option.js +1 -1
- package/select/Select.js +104 -199
- package/select/Select.stories.tsx +145 -100
- package/select/Select.test.js +503 -286
- package/select/types.d.ts +31 -12
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +184 -52
- package/sidenav/Sidenav.stories.tsx +154 -156
- package/sidenav/Sidenav.test.js +25 -37
- 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 +142 -21
- package/slider/types.d.ts +6 -2
- package/spinner/Spinner.js +1 -1
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +133 -64
- package/switch/Switch.stories.tsx +16 -38
- package/switch/Switch.test.js +144 -17
- package/switch/types.d.ts +5 -6
- package/table/Table.js +1 -1
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +135 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +362 -108
- package/tabs/Tabs.stories.tsx +74 -8
- package/tabs/Tabs.test.js +241 -13
- package/tabs/types.d.ts +19 -5
- 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/{stack → tabs-nav}/types.js +0 -0
- package/tag/Tag.js +6 -9
- package/tag/types.d.ts +1 -1
- 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 +213 -334
- package/text-input/TextInput.stories.tsx +189 -182
- package/text-input/TextInput.test.js +244 -198
- package/text-input/types.d.ts +46 -12
- package/textarea/Textarea.js +10 -19
- package/textarea/types.d.ts +10 -7
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +5 -4
- package/toggle-group/ToggleGroup.stories.tsx +4 -4
- package/toggle-group/ToggleGroup.test.js +35 -4
- package/toggle-group/types.d.ts +9 -1
- 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.js +43 -44
- package/wizard/Wizard.stories.tsx +20 -1
- package/wizard/types.d.ts +5 -4
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
- package/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/list/types.d.ts +0 -7
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
- package/row/Row.d.ts +0 -3
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -237
- package/row/types.d.ts +0 -28
- package/stack/Stack.d.ts +0 -3
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -164
- package/stack/types.d.ts +0 -24
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
package/text-input/TextInput.js
CHANGED
|
@@ -21,68 +21,46 @@ 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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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 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
|
+
|
|
62
|
+
var calculateWidth = function calculateWidth(margin, size) {
|
|
63
|
+
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
86
64
|
};
|
|
87
65
|
|
|
88
66
|
var makeCancelable = function makeCancelable(promise) {
|
|
@@ -106,71 +84,69 @@ var makeCancelable = function makeCancelable(promise) {
|
|
|
106
84
|
};
|
|
107
85
|
};
|
|
108
86
|
|
|
109
|
-
var
|
|
110
|
-
return "
|
|
87
|
+
var hasSuggestions = function hasSuggestions(suggestions) {
|
|
88
|
+
return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
|
|
111
89
|
};
|
|
112
90
|
|
|
113
|
-
var
|
|
114
|
-
return
|
|
91
|
+
var isNotOptional = function isNotOptional(value, optional) {
|
|
92
|
+
return value === "" && !optional;
|
|
115
93
|
};
|
|
116
94
|
|
|
117
|
-
var
|
|
118
|
-
return
|
|
95
|
+
var isLengthIncorrect = function isLengthIncorrect(value, minLength, maxLength) {
|
|
96
|
+
return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
|
|
119
97
|
};
|
|
120
98
|
|
|
121
|
-
var
|
|
122
|
-
|
|
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
|
-
};
|
|
99
|
+
var isNumberIncorrect = function isNumberIncorrect(value, minNumber, maxNumber) {
|
|
100
|
+
return minNumber && parseInt(value) < minNumber || maxNumber && parseInt(value) > maxNumber;
|
|
101
|
+
};
|
|
129
102
|
|
|
130
|
-
|
|
131
|
-
return
|
|
103
|
+
var patternMissmatch = function patternMissmatch(pattern, value) {
|
|
104
|
+
return pattern && !new RegExp(pattern).test(value);
|
|
132
105
|
};
|
|
133
106
|
|
|
134
|
-
var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
135
|
-
var label =
|
|
136
|
-
|
|
137
|
-
name =
|
|
138
|
-
|
|
139
|
-
defaultValue =
|
|
140
|
-
value =
|
|
141
|
-
helperText =
|
|
142
|
-
|
|
143
|
-
placeholder =
|
|
144
|
-
action =
|
|
145
|
-
|
|
146
|
-
clearable =
|
|
147
|
-
|
|
148
|
-
disabled =
|
|
149
|
-
|
|
150
|
-
optional =
|
|
151
|
-
|
|
152
|
-
prefix =
|
|
153
|
-
|
|
154
|
-
suffix =
|
|
155
|
-
onChange =
|
|
156
|
-
onBlur =
|
|
157
|
-
error =
|
|
158
|
-
suggestions =
|
|
159
|
-
pattern =
|
|
160
|
-
minLength =
|
|
161
|
-
maxLength =
|
|
162
|
-
|
|
163
|
-
autocomplete =
|
|
164
|
-
margin =
|
|
165
|
-
|
|
166
|
-
size =
|
|
167
|
-
|
|
168
|
-
tabIndex =
|
|
107
|
+
var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
108
|
+
var label = _ref2.label,
|
|
109
|
+
_ref2$name = _ref2.name,
|
|
110
|
+
name = _ref2$name === void 0 ? "" : _ref2$name,
|
|
111
|
+
_ref2$defaultValue = _ref2.defaultValue,
|
|
112
|
+
defaultValue = _ref2$defaultValue === void 0 ? "" : _ref2$defaultValue,
|
|
113
|
+
value = _ref2.value,
|
|
114
|
+
helperText = _ref2.helperText,
|
|
115
|
+
_ref2$placeholder = _ref2.placeholder,
|
|
116
|
+
placeholder = _ref2$placeholder === void 0 ? "" : _ref2$placeholder,
|
|
117
|
+
action = _ref2.action,
|
|
118
|
+
_ref2$clearable = _ref2.clearable,
|
|
119
|
+
clearable = _ref2$clearable === void 0 ? false : _ref2$clearable,
|
|
120
|
+
_ref2$disabled = _ref2.disabled,
|
|
121
|
+
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
122
|
+
_ref2$optional = _ref2.optional,
|
|
123
|
+
optional = _ref2$optional === void 0 ? false : _ref2$optional,
|
|
124
|
+
_ref2$prefix = _ref2.prefix,
|
|
125
|
+
prefix = _ref2$prefix === void 0 ? "" : _ref2$prefix,
|
|
126
|
+
_ref2$suffix = _ref2.suffix,
|
|
127
|
+
suffix = _ref2$suffix === void 0 ? "" : _ref2$suffix,
|
|
128
|
+
onChange = _ref2.onChange,
|
|
129
|
+
onBlur = _ref2.onBlur,
|
|
130
|
+
error = _ref2.error,
|
|
131
|
+
suggestions = _ref2.suggestions,
|
|
132
|
+
pattern = _ref2.pattern,
|
|
133
|
+
minLength = _ref2.minLength,
|
|
134
|
+
maxLength = _ref2.maxLength,
|
|
135
|
+
_ref2$autocomplete = _ref2.autocomplete,
|
|
136
|
+
autocomplete = _ref2$autocomplete === void 0 ? "off" : _ref2$autocomplete,
|
|
137
|
+
margin = _ref2.margin,
|
|
138
|
+
_ref2$size = _ref2.size,
|
|
139
|
+
size = _ref2$size === void 0 ? "medium" : _ref2$size,
|
|
140
|
+
_ref2$tabIndex = _ref2.tabIndex,
|
|
141
|
+
tabIndex = _ref2$tabIndex === void 0 ? 0 : _ref2$tabIndex;
|
|
169
142
|
|
|
170
143
|
var _useState = (0, _react.useState)("input-".concat((0, _uuid.v4)())),
|
|
171
144
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
172
145
|
inputId = _useState2[0];
|
|
173
146
|
|
|
147
|
+
var autosuggestId = "suggestions-".concat(inputId);
|
|
148
|
+
var errorId = "error-".concat(inputId);
|
|
149
|
+
|
|
174
150
|
var _useState3 = (0, _react.useState)(defaultValue),
|
|
175
151
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
176
152
|
innerValue = _useState4[0],
|
|
@@ -198,78 +174,55 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
198
174
|
|
|
199
175
|
var _useState13 = (0, _react.useState)(-1),
|
|
200
176
|
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
201
|
-
|
|
202
|
-
|
|
177
|
+
visualFocusIndex = _useState14[0],
|
|
178
|
+
changeVisualFocusIndex = _useState14[1];
|
|
203
179
|
|
|
204
|
-
var suggestionsRef = (0, _react.useRef)(null);
|
|
205
180
|
var inputRef = (0, _react.useRef)(null);
|
|
206
181
|
var actionRef = (0, _react.useRef)(null);
|
|
207
182
|
var colorsTheme = (0, _useTheme["default"])();
|
|
183
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
208
184
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
209
|
-
var autosuggestId = "".concat(inputId, "-listBox");
|
|
210
|
-
var errorId = "error-".concat(inputId);
|
|
211
185
|
var numberInputContext = (0, _react.useContext)(_NumberInputContext["default"]);
|
|
212
|
-
var lastOptionIndex = (0, _react.useMemo)(function () {
|
|
213
|
-
return getLastOptionIndex(filteredSuggestions);
|
|
214
|
-
}, [filteredSuggestions]);
|
|
215
|
-
|
|
216
|
-
var isNotOptional = function isNotOptional(value) {
|
|
217
|
-
return value === "" && !optional;
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
var isLengthIncorrect = function isLengthIncorrect(value) {
|
|
221
|
-
return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
var getLengthErrorMessage = function getLengthErrorMessage() {
|
|
225
|
-
return "Min length ".concat(minLength, ", max length ").concat(maxLength, ".");
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
var isNumberIncorrect = function isNumberIncorrect(value) {
|
|
229
|
-
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);
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
var isTextInputType = function isTextInputType() {
|
|
233
|
-
var _inputRef$current, _inputRef$current2;
|
|
234
|
-
|
|
235
|
-
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";
|
|
236
|
-
};
|
|
237
186
|
|
|
238
187
|
var getNumberErrorMessage = function getNumberErrorMessage(value) {
|
|
239
|
-
if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && parseInt(value) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) return
|
|
188
|
+
if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && parseInt(value) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) return translatedLabels.numberInput.valueGreaterThanOrEqualToErrorMessage(numberInputContext.minNumber);else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && parseInt(value) > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) return translatedLabels.numberInput.valueLessThanOrEqualToErrorMessage(numberInputContext.maxNumber);
|
|
240
189
|
};
|
|
241
190
|
|
|
242
|
-
var
|
|
243
|
-
|
|
244
|
-
|
|
191
|
+
var getTextInputWidth = (0, _react.useCallback)(function () {
|
|
192
|
+
var _inputRef$current, _inputRef$current$par;
|
|
193
|
+
|
|
194
|
+
var rect = inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : (_inputRef$current$par = _inputRef$current.parentElement) === null || _inputRef$current$par === void 0 ? void 0 : _inputRef$current$par.getBoundingClientRect();
|
|
195
|
+
return rect === null || rect === void 0 ? void 0 : rect.width;
|
|
196
|
+
}, []);
|
|
245
197
|
|
|
246
198
|
var openSuggestions = function openSuggestions() {
|
|
247
|
-
hasSuggestions() && changeIsOpen(true);
|
|
199
|
+
hasSuggestions(suggestions) && changeIsOpen(true);
|
|
248
200
|
};
|
|
249
201
|
|
|
250
202
|
var closeSuggestions = function closeSuggestions() {
|
|
251
|
-
|
|
252
|
-
|
|
203
|
+
if (hasSuggestions(suggestions)) {
|
|
204
|
+
changeIsOpen(false);
|
|
205
|
+
changeVisualFocusIndex(-1);
|
|
206
|
+
}
|
|
253
207
|
};
|
|
254
208
|
|
|
255
209
|
var changeValue = function changeValue(newValue) {
|
|
256
210
|
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
257
211
|
var changedValue = typeof newValue === "number" ? newValue.toString() : newValue;
|
|
258
|
-
if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
212
|
+
if (isNotOptional(newValue, optional)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
259
213
|
value: changedValue,
|
|
260
|
-
error:
|
|
261
|
-
});else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
214
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
215
|
+
});else if (isLengthIncorrect(newValue, minLength, maxLength)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
262
216
|
value: changedValue,
|
|
263
|
-
error:
|
|
264
|
-
});else if (
|
|
217
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
218
|
+
});else if (patternMissmatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
265
219
|
value: changedValue,
|
|
266
|
-
error:
|
|
267
|
-
});else if (newValue
|
|
220
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
221
|
+
});else if (isNumberIncorrect(newValue, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
268
222
|
value: changedValue,
|
|
269
223
|
error: getNumberErrorMessage(newValue)
|
|
270
224
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
271
|
-
value: changedValue
|
|
272
|
-
error: null
|
|
225
|
+
value: changedValue
|
|
273
226
|
});
|
|
274
227
|
};
|
|
275
228
|
|
|
@@ -282,44 +235,43 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
282
235
|
document.activeElement === inputRef.current && event.preventDefault();
|
|
283
236
|
};
|
|
284
237
|
|
|
285
|
-
var
|
|
238
|
+
var handleInputOnChange = function handleInputOnChange(event) {
|
|
286
239
|
openSuggestions();
|
|
287
240
|
changeValue(event.target.value);
|
|
288
241
|
};
|
|
289
242
|
|
|
290
|
-
var
|
|
291
|
-
|
|
292
|
-
if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
243
|
+
var handleInputOnBlur = function handleInputOnBlur(event) {
|
|
244
|
+
closeSuggestions();
|
|
245
|
+
if (isNotOptional(event.target.value, optional)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
293
246
|
value: event.target.value,
|
|
294
|
-
error:
|
|
295
|
-
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
247
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
248
|
+
});else if (isLengthIncorrect(event.target.value, minLength, maxLength)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
296
249
|
value: event.target.value,
|
|
297
|
-
error:
|
|
298
|
-
});else if (
|
|
250
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
251
|
+
});else if (patternMissmatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
299
252
|
value: event.target.value,
|
|
300
|
-
error:
|
|
301
|
-
});else if (event.target.value
|
|
253
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
254
|
+
});else if (isNumberIncorrect(event.target.value, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
302
255
|
value: event.target.value,
|
|
303
256
|
error: getNumberErrorMessage(event.target.value)
|
|
304
257
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
305
|
-
value: event.target.value
|
|
306
|
-
error: null
|
|
258
|
+
value: event.target.value
|
|
307
259
|
});
|
|
308
260
|
};
|
|
309
261
|
|
|
310
|
-
var
|
|
311
|
-
switch (event.
|
|
312
|
-
case
|
|
313
|
-
|
|
262
|
+
var handleInputOnKeyDown = function handleInputOnKeyDown(event) {
|
|
263
|
+
switch (event.key) {
|
|
264
|
+
case "Down":
|
|
265
|
+
case "ArrowDown":
|
|
266
|
+
event.preventDefault();
|
|
267
|
+
|
|
314
268
|
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
315
269
|
decrementNumber();
|
|
316
|
-
event.preventDefault();
|
|
317
270
|
} else {
|
|
318
|
-
event.preventDefault();
|
|
319
271
|
openSuggestions();
|
|
320
272
|
|
|
321
273
|
if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
|
|
322
|
-
|
|
274
|
+
changeVisualFocusIndex(function (visualFocusedSuggIndex) {
|
|
323
275
|
if (visualFocusedSuggIndex < filteredSuggestions.length - 1) return visualFocusedSuggIndex + 1;else if (visualFocusedSuggIndex === filteredSuggestions.length - 1) return 0;
|
|
324
276
|
});
|
|
325
277
|
}
|
|
@@ -327,17 +279,17 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
327
279
|
|
|
328
280
|
break;
|
|
329
281
|
|
|
330
|
-
case
|
|
331
|
-
|
|
282
|
+
case "Up":
|
|
283
|
+
case "ArrowUp":
|
|
284
|
+
event.preventDefault();
|
|
285
|
+
|
|
332
286
|
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
333
287
|
incrementNumber();
|
|
334
|
-
event.preventDefault();
|
|
335
288
|
} else {
|
|
336
|
-
event.preventDefault();
|
|
337
289
|
openSuggestions();
|
|
338
290
|
|
|
339
291
|
if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
|
|
340
|
-
|
|
292
|
+
changeVisualFocusIndex(function (visualFocusedSuggIndex) {
|
|
341
293
|
if (visualFocusedSuggIndex === 0 || visualFocusedSuggIndex === -1) return filteredSuggestions.length > 0 ? filteredSuggestions.length - 1 : suggestions.length - 1;else return visualFocusedSuggIndex - 1;
|
|
342
294
|
});
|
|
343
295
|
}
|
|
@@ -345,22 +297,21 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
345
297
|
|
|
346
298
|
break;
|
|
347
299
|
|
|
348
|
-
case
|
|
349
|
-
|
|
300
|
+
case "Esc":
|
|
301
|
+
case "Escape":
|
|
350
302
|
event.preventDefault();
|
|
351
303
|
|
|
352
|
-
if (hasSuggestions()) {
|
|
304
|
+
if (hasSuggestions(suggestions)) {
|
|
353
305
|
changeValue("");
|
|
354
306
|
isOpen && closeSuggestions();
|
|
355
307
|
}
|
|
356
308
|
|
|
357
309
|
break;
|
|
358
310
|
|
|
359
|
-
case
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusedSuggIndex]);
|
|
311
|
+
case "Enter":
|
|
312
|
+
if (hasSuggestions(suggestions) && !isSearching) {
|
|
313
|
+
var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusIndex >= 0 && visualFocusIndex < filteredSuggestions.length;
|
|
314
|
+
validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusIndex]);
|
|
364
315
|
isOpen && closeSuggestions();
|
|
365
316
|
}
|
|
366
317
|
|
|
@@ -385,12 +336,12 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
385
336
|
};
|
|
386
337
|
|
|
387
338
|
var setNumberProps = function setNumberProps(type, min, max, step) {
|
|
388
|
-
var _inputRef$
|
|
339
|
+
var _inputRef$current2, _inputRef$current3, _inputRef$current4, _inputRef$current5;
|
|
389
340
|
|
|
390
|
-
type && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$
|
|
391
|
-
min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$
|
|
392
|
-
max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$
|
|
393
|
-
step && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$
|
|
341
|
+
type && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.setAttribute("type", type));
|
|
342
|
+
min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("min", min));
|
|
343
|
+
max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("max", max));
|
|
344
|
+
step && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.setAttribute("step", step));
|
|
394
345
|
};
|
|
395
346
|
|
|
396
347
|
var decrementNumber = function decrementNumber() {
|
|
@@ -433,15 +384,6 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
433
384
|
}
|
|
434
385
|
};
|
|
435
386
|
|
|
436
|
-
(0, _react.useLayoutEffect)(function () {
|
|
437
|
-
var _suggestionsRef$curre, _visualFocusedOptionE;
|
|
438
|
-
|
|
439
|
-
var visualFocusedOptionEl = suggestionsRef === null || suggestionsRef === void 0 ? void 0 : (_suggestionsRef$curre = suggestionsRef.current) === null || _suggestionsRef$curre === void 0 ? void 0 : _suggestionsRef$curre.querySelectorAll("[role='option']")[visualFocusedSuggIndex];
|
|
440
|
-
visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : (_visualFocusedOptionE = visualFocusedOptionEl.scrollIntoView) === null || _visualFocusedOptionE === void 0 ? void 0 : _visualFocusedOptionE.call(visualFocusedOptionEl, {
|
|
441
|
-
block: "nearest",
|
|
442
|
-
inline: "start"
|
|
443
|
-
});
|
|
444
|
-
}, [visualFocusedSuggIndex]);
|
|
445
387
|
(0, _react.useEffect)(function () {
|
|
446
388
|
if (typeof suggestions === "function") {
|
|
447
389
|
changeIsSearching(true);
|
|
@@ -465,50 +407,27 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
465
407
|
changeFilteredSuggestions(suggestions.filter(function (suggestion) {
|
|
466
408
|
return suggestion.toUpperCase().startsWith((value !== null && value !== void 0 ? value : innerValue).toUpperCase());
|
|
467
409
|
}));
|
|
468
|
-
|
|
410
|
+
changeVisualFocusIndex(-1);
|
|
469
411
|
}
|
|
470
412
|
|
|
471
413
|
(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
472
414
|
}, [value, innerValue, suggestions, numberInputContext]);
|
|
473
|
-
|
|
474
|
-
var HighlightedSuggestion = function HighlightedSuggestion(_ref2) {
|
|
475
|
-
var suggestion = _ref2.suggestion,
|
|
476
|
-
index = _ref2.index;
|
|
477
|
-
var regEx = new RegExp(value !== null && value !== void 0 ? value : innerValue, "i");
|
|
478
|
-
var matchedWords = suggestion.match(regEx);
|
|
479
|
-
var noMatchedWords = suggestion.replace(regEx, "");
|
|
480
|
-
var isLastOption = index === lastOptionIndex;
|
|
481
|
-
return /*#__PURE__*/_react["default"].createElement(Suggestion, {
|
|
482
|
-
id: "suggestion-".concat(index),
|
|
483
|
-
onClick: function onClick() {
|
|
484
|
-
changeValue(suggestion);
|
|
485
|
-
closeSuggestions();
|
|
486
|
-
},
|
|
487
|
-
visualFocused: visualFocusedSuggIndex === index,
|
|
488
|
-
role: "option",
|
|
489
|
-
"aria-selected": visualFocusedSuggIndex === index && "true"
|
|
490
|
-
}, /*#__PURE__*/_react["default"].createElement(StyledSuggestion, {
|
|
491
|
-
last: isLastOption,
|
|
492
|
-
visualFocused: visualFocusedSuggIndex === index
|
|
493
|
-
}, typeof suggestions === "function" ? suggestion : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedWords), noMatchedWords)));
|
|
494
|
-
};
|
|
495
|
-
|
|
496
415
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
497
416
|
theme: colorsTheme.textInput
|
|
498
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
417
|
+
}, /*#__PURE__*/_react["default"].createElement(TextInputContainer, {
|
|
499
418
|
margin: margin,
|
|
500
|
-
|
|
501
|
-
|
|
419
|
+
size: size,
|
|
420
|
+
ref: ref
|
|
502
421
|
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
503
422
|
htmlFor: inputId,
|
|
504
423
|
disabled: disabled,
|
|
505
424
|
backgroundType: backgroundType,
|
|
506
|
-
helperText:
|
|
507
|
-
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null,
|
|
425
|
+
hasHelperText: helperText ? true : false
|
|
426
|
+
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
508
427
|
disabled: disabled,
|
|
509
428
|
backgroundType: backgroundType
|
|
510
429
|
}, helperText), /*#__PURE__*/_react["default"].createElement(InputContainer, {
|
|
511
|
-
error: error,
|
|
430
|
+
error: error ? true : false,
|
|
512
431
|
disabled: disabled,
|
|
513
432
|
backgroundType: backgroundType,
|
|
514
433
|
onClick: handleInputContainerOnClick,
|
|
@@ -516,17 +435,48 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
516
435
|
}, prefix && /*#__PURE__*/_react["default"].createElement(Prefix, {
|
|
517
436
|
disabled: disabled,
|
|
518
437
|
backgroundType: backgroundType
|
|
519
|
-
}, prefix), /*#__PURE__*/_react["default"].createElement(
|
|
438
|
+
}, prefix), /*#__PURE__*/_react["default"].createElement(AutosuggestWrapper, {
|
|
439
|
+
condition: hasSuggestions(suggestions),
|
|
440
|
+
wrapper: function wrapper(children) {
|
|
441
|
+
return /*#__PURE__*/_react["default"].createElement(Popover.Root, {
|
|
442
|
+
open: isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError)
|
|
443
|
+
}, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
|
|
444
|
+
asChild: true,
|
|
445
|
+
"aria-controls": undefined
|
|
446
|
+
}, children), /*#__PURE__*/_react["default"].createElement(Popover.Content, {
|
|
447
|
+
sideOffset: 5,
|
|
448
|
+
onOpenAutoFocus: function onOpenAutoFocus(event) {
|
|
449
|
+
// Avoid select to lose focus when the list is opened
|
|
450
|
+
event.preventDefault();
|
|
451
|
+
},
|
|
452
|
+
onCloseAutoFocus: function onCloseAutoFocus(event) {
|
|
453
|
+
// Avoid select to lose focus when the list is closed
|
|
454
|
+
event.preventDefault();
|
|
455
|
+
}
|
|
456
|
+
}, /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
|
|
457
|
+
id: autosuggestId,
|
|
458
|
+
value: value !== null && value !== void 0 ? value : innerValue,
|
|
459
|
+
suggestions: filteredSuggestions,
|
|
460
|
+
visualFocusIndex: visualFocusIndex,
|
|
461
|
+
highlightedSuggestions: typeof suggestions !== "function",
|
|
462
|
+
searchHasErrors: isAutosuggestError,
|
|
463
|
+
isSearching: isSearching,
|
|
464
|
+
suggestionOnClick: function suggestionOnClick(suggestion) {
|
|
465
|
+
changeValue(suggestion);
|
|
466
|
+
closeSuggestions();
|
|
467
|
+
},
|
|
468
|
+
getTextInputWidth: getTextInputWidth
|
|
469
|
+
})));
|
|
470
|
+
}
|
|
471
|
+
}, /*#__PURE__*/_react["default"].createElement(Input, {
|
|
520
472
|
id: inputId,
|
|
521
473
|
name: name,
|
|
522
474
|
value: value !== null && value !== void 0 ? value : innerValue,
|
|
523
475
|
placeholder: placeholder,
|
|
524
|
-
onBlur:
|
|
525
|
-
onChange:
|
|
526
|
-
onFocus:
|
|
527
|
-
|
|
528
|
-
},
|
|
529
|
-
onKeyDown: handleIOnKeyDown,
|
|
476
|
+
onBlur: handleInputOnBlur,
|
|
477
|
+
onChange: handleInputOnChange,
|
|
478
|
+
onFocus: openSuggestions,
|
|
479
|
+
onKeyDown: handleInputOnKeyDown,
|
|
530
480
|
onMouseDown: function onMouseDown(event) {
|
|
531
481
|
event.stopPropagation();
|
|
532
482
|
},
|
|
@@ -536,111 +486,80 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
536
486
|
pattern: pattern,
|
|
537
487
|
minLength: minLength,
|
|
538
488
|
maxLength: maxLength,
|
|
539
|
-
autoComplete: autocomplete,
|
|
489
|
+
autoComplete: autocomplete === "off" ? "nope" : autocomplete,
|
|
540
490
|
tabIndex: tabIndex,
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
"aria-
|
|
544
|
-
"aria-
|
|
545
|
-
"aria-expanded":
|
|
546
|
-
"aria-
|
|
547
|
-
"aria-
|
|
491
|
+
type: "text",
|
|
492
|
+
role: hasSuggestions(suggestions) ? "combobox" : undefined,
|
|
493
|
+
"aria-autocomplete": hasSuggestions(suggestions) ? "list" : undefined,
|
|
494
|
+
"aria-controls": hasSuggestions(suggestions) ? autosuggestId : undefined,
|
|
495
|
+
"aria-expanded": hasSuggestions(suggestions) ? isOpen : undefined,
|
|
496
|
+
"aria-haspopup": hasSuggestions(suggestions) ? "listbox" : undefined,
|
|
497
|
+
"aria-activedescendant": hasSuggestions(suggestions) && isOpen && visualFocusIndex !== -1 ? "suggestion-".concat(visualFocusIndex) : undefined,
|
|
498
|
+
"aria-invalid": error ? true : false,
|
|
548
499
|
"aria-errormessage": error ? errorId : undefined,
|
|
549
|
-
"aria-required": optional ?
|
|
550
|
-
}), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
|
|
500
|
+
"aria-required": optional ? false : true
|
|
501
|
+
})), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
|
|
551
502
|
backgroundType: backgroundType,
|
|
552
503
|
"aria-label": "Error"
|
|
553
|
-
},
|
|
554
|
-
onClick:
|
|
555
|
-
return handleClearActionOnClick();
|
|
556
|
-
},
|
|
504
|
+
}, _Icons["default"].error), !disabled && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
505
|
+
onClick: handleClearActionOnClick,
|
|
557
506
|
onMouseDown: function onMouseDown(event) {
|
|
558
507
|
event.stopPropagation();
|
|
559
508
|
},
|
|
560
509
|
backgroundType: backgroundType,
|
|
561
510
|
tabIndex: tabIndex,
|
|
562
|
-
title:
|
|
563
|
-
"aria-label":
|
|
564
|
-
|
|
511
|
+
title: translatedLabels.textInput.clearFieldActionTitle,
|
|
512
|
+
"aria-label": translatedLabels.textInput.clearFieldActionTitle,
|
|
513
|
+
type: "button"
|
|
514
|
+
}, _Icons["default"].clear), (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(Action, {
|
|
565
515
|
ref: actionRef,
|
|
566
516
|
disabled: disabled,
|
|
567
|
-
onClick:
|
|
568
|
-
return handleDecrementActionOnClick();
|
|
569
|
-
},
|
|
517
|
+
onClick: handleDecrementActionOnClick,
|
|
570
518
|
onMouseDown: function onMouseDown(event) {
|
|
571
519
|
event.stopPropagation();
|
|
572
520
|
},
|
|
573
521
|
backgroundType: backgroundType,
|
|
574
522
|
tabIndex: tabIndex,
|
|
575
|
-
title:
|
|
576
|
-
"aria-label":
|
|
577
|
-
|
|
523
|
+
title: translatedLabels.numberInput.decrementValueTitle,
|
|
524
|
+
"aria-label": translatedLabels.numberInput.decrementValueTitle,
|
|
525
|
+
type: "button"
|
|
526
|
+
}, _Icons["default"].decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
578
527
|
ref: actionRef,
|
|
579
528
|
disabled: disabled,
|
|
580
|
-
onClick:
|
|
581
|
-
return handleIncrementActionOnClick();
|
|
582
|
-
},
|
|
529
|
+
onClick: handleIncrementActionOnClick,
|
|
583
530
|
onMouseDown: function onMouseDown(event) {
|
|
584
531
|
event.stopPropagation();
|
|
585
532
|
},
|
|
586
533
|
backgroundType: backgroundType,
|
|
587
534
|
tabIndex: tabIndex,
|
|
588
|
-
title:
|
|
589
|
-
"aria-label":
|
|
590
|
-
|
|
535
|
+
title: translatedLabels.numberInput.incrementValueTitle,
|
|
536
|
+
"aria-label": translatedLabels.numberInput.incrementValueTitle,
|
|
537
|
+
type: "button"
|
|
538
|
+
}, _Icons["default"].increment)), action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
591
539
|
ref: actionRef,
|
|
592
540
|
disabled: disabled,
|
|
593
|
-
onClick:
|
|
594
|
-
return action.onClick();
|
|
595
|
-
},
|
|
541
|
+
onClick: action.onClick,
|
|
596
542
|
onMouseDown: function onMouseDown(event) {
|
|
597
543
|
event.stopPropagation();
|
|
598
544
|
},
|
|
599
545
|
title: action.title,
|
|
600
546
|
"aria-label": action.title,
|
|
601
547
|
backgroundType: backgroundType,
|
|
602
|
-
tabIndex: tabIndex
|
|
548
|
+
tabIndex: tabIndex,
|
|
549
|
+
type: "button"
|
|
603
550
|
}, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement(ActionIcon, {
|
|
604
551
|
src: action.icon
|
|
605
552
|
}) : action.icon), suffix && /*#__PURE__*/_react["default"].createElement(Suffix, {
|
|
606
553
|
disabled: disabled,
|
|
607
554
|
backgroundType: backgroundType
|
|
608
|
-
}, suffix),
|
|
609
|
-
id: autosuggestId,
|
|
610
|
-
isError: isAutosuggestError,
|
|
611
|
-
onMouseDown: function onMouseDown(event) {
|
|
612
|
-
event.preventDefault();
|
|
613
|
-
},
|
|
614
|
-
ref: suggestionsRef,
|
|
615
|
-
role: "listbox",
|
|
616
|
-
"aria-label": label
|
|
617
|
-
}, !isSearching && !isAutosuggestError && filteredSuggestions.length > 0 && filteredSuggestions.map(function (suggestion, index) {
|
|
618
|
-
return /*#__PURE__*/_react["default"].createElement(HighlightedSuggestion, {
|
|
619
|
-
key: "suggestion-".concat((0, _uuid.v4)()),
|
|
620
|
-
suggestion: suggestion,
|
|
621
|
-
index: index
|
|
622
|
-
});
|
|
623
|
-
}), isSearching && /*#__PURE__*/_react["default"].createElement(SuggestionsSystemMessage, null, "Searching..."), isAutosuggestError && /*#__PURE__*/_react["default"].createElement(SuggestionsError, null, /*#__PURE__*/_react["default"].createElement(SuggestionsErrorIcon, {
|
|
624
|
-
backgroundType: backgroundType
|
|
625
|
-
}, textInputIcons.error), "Error fetching data"))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
555
|
+
}, suffix)), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
626
556
|
id: errorId,
|
|
627
557
|
backgroundType: backgroundType,
|
|
628
558
|
"aria-live": error ? "assertive" : "off"
|
|
629
559
|
}, error)));
|
|
630
560
|
});
|
|
631
561
|
|
|
632
|
-
var
|
|
633
|
-
small: "240px",
|
|
634
|
-
medium: "360px",
|
|
635
|
-
large: "480px",
|
|
636
|
-
fillParent: "100%"
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
var calculateWidth = function calculateWidth(margin, size) {
|
|
640
|
-
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
641
|
-
};
|
|
642
|
-
|
|
643
|
-
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) {
|
|
562
|
+
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) {
|
|
644
563
|
return calculateWidth(props.margin, props.size);
|
|
645
564
|
}, function (props) {
|
|
646
565
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -667,7 +586,7 @@ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObj
|
|
|
667
586
|
}, function (props) {
|
|
668
587
|
return props.theme.labelLineHeight;
|
|
669
588
|
}, function (props) {
|
|
670
|
-
return !props.
|
|
589
|
+
return !props.hasHelperText && "margin-bottom: 0.25rem";
|
|
671
590
|
});
|
|
672
591
|
|
|
673
592
|
var OptionalLabel = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: ", ";\n"])), function (props) {
|
|
@@ -697,7 +616,7 @@ var InputContainer = _styledComponents["default"].div(_templateObject5 || (_temp
|
|
|
697
616
|
}, function (props) {
|
|
698
617
|
return props.disabled && "cursor: not-allowed;";
|
|
699
618
|
}, function (props) {
|
|
700
|
-
return !props.disabled && "\n &:hover {\n border-color: ".concat(props.error ? "transparent" : props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor, ";\n ").concat(props.error
|
|
619
|
+
return !props.disabled && "\n &:hover {\n border-color: ".concat(props.error ? "transparent" : props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor, ";\n ").concat(props.error ? "box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.hoverErrorBorderColorOnDark : props.theme.hoverErrorBorderColor, ";") : "", "\n }\n &:focus-within {\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n ");
|
|
701
620
|
});
|
|
702
621
|
|
|
703
622
|
var Input = _styledComponents["default"].input(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n height: calc(2.5rem - 2px);\n width: 100%;\n background: none;\n border: none;\n outline: none;\n padding: 0 0.5rem;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.5em;\n ", "\n\n ::placeholder {\n color: ", ";\n }\n"])), function (props) {
|
|
@@ -754,45 +673,5 @@ var Error = _styledComponents["default"].span(_templateObject12 || (_templateObj
|
|
|
754
673
|
return props.theme.fontFamily;
|
|
755
674
|
});
|
|
756
675
|
|
|
757
|
-
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) {
|
|
758
|
-
return props.isError ? props.theme.errorListDialogBackgroundColor : props.theme.listDialogBackgroundColor;
|
|
759
|
-
}, function (props) {
|
|
760
|
-
return props.isError ? props.theme.errorListDialogBorderColor : props.theme.listDialogBorderColor;
|
|
761
|
-
}, function (props) {
|
|
762
|
-
return props.theme.listOptionFontColor;
|
|
763
|
-
}, function (props) {
|
|
764
|
-
return props.theme.fontFamily;
|
|
765
|
-
}, function (props) {
|
|
766
|
-
return props.theme.listOptionFontSize;
|
|
767
|
-
}, function (props) {
|
|
768
|
-
return props.theme.listOptionFontStyle;
|
|
769
|
-
}, function (props) {
|
|
770
|
-
return props.theme.listOptionFontWeight;
|
|
771
|
-
});
|
|
772
|
-
|
|
773
|
-
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) {
|
|
774
|
-
return props.visualFocused ? props.theme.focusListOptionBorderColor : "transparent";
|
|
775
|
-
}, function (props) {
|
|
776
|
-
return props.theme.hoverListOptionBackgroundColor;
|
|
777
|
-
}, function (props) {
|
|
778
|
-
return props.theme.activeListOptionBackgroundColor;
|
|
779
|
-
});
|
|
780
|
-
|
|
781
|
-
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) {
|
|
782
|
-
return props.last || props.visualFocused ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
|
|
783
|
-
});
|
|
784
|
-
|
|
785
|
-
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) {
|
|
786
|
-
return props.theme.systemMessageFontColor;
|
|
787
|
-
});
|
|
788
|
-
|
|
789
|
-
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) {
|
|
790
|
-
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
791
|
-
});
|
|
792
|
-
|
|
793
|
-
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) {
|
|
794
|
-
return props.theme.errorListDialogFontColor;
|
|
795
|
-
});
|
|
796
|
-
|
|
797
676
|
var _default = DxcTextInput;
|
|
798
677
|
exports["default"] = _default;
|