@dxc-technology/halstack-react 0.0.0-ecc45e2 → 0.0.0-ede733c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BackgroundColorContext.d.ts +2 -2
- package/BackgroundColorContext.js +1 -1
- package/HalstackContext.d.ts +1329 -5
- package/HalstackContext.js +117 -77
- package/accordion/Accordion.js +118 -110
- package/accordion/Accordion.stories.tsx +103 -15
- package/accordion/Accordion.test.js +10 -11
- package/accordion/types.d.ts +1 -0
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +24 -65
- package/accordion-group/AccordionGroup.stories.tsx +27 -1
- package/accordion-group/AccordionGroup.test.js +21 -46
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +7 -0
- package/alert/Alert.js +5 -9
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +1 -1
- package/bleed/Bleed.stories.tsx +1 -0
- package/box/Box.js +4 -6
- package/box/Box.stories.tsx +15 -0
- package/box/Box.test.js +1 -1
- package/box/types.d.ts +1 -0
- package/bulleted-list/BulletedList.js +4 -2
- package/bulleted-list/BulletedList.stories.tsx +7 -1
- package/bulleted-list/types.d.ts +31 -4
- package/button/Button.js +13 -16
- package/button/Button.stories.tsx +151 -9
- package/button/Button.test.js +1 -1
- package/button/types.d.ts +3 -3
- package/card/Card.js +12 -13
- package/card/Card.stories.tsx +12 -13
- package/card/Card.test.js +1 -1
- package/card/types.d.ts +1 -0
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +94 -101
- package/checkbox/Checkbox.stories.tsx +131 -59
- package/checkbox/Checkbox.test.js +94 -17
- package/checkbox/types.d.ts +4 -0
- package/chip/Chip.js +28 -49
- package/chip/Chip.stories.tsx +121 -26
- package/chip/Chip.test.js +3 -5
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +4 -4
- package/common/variables.d.ts +1482 -0
- package/common/variables.js +994 -1137
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.js +134 -237
- package/date-input/DateInput.stories.tsx +199 -33
- package/date-input/DateInput.test.js +494 -138
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +146 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +75 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +126 -0
- package/date-input/types.d.ts +51 -0
- package/dialog/Dialog.js +60 -73
- package/dialog/Dialog.stories.tsx +229 -121
- package/dialog/Dialog.test.js +302 -3
- package/dialog/types.d.ts +3 -2
- package/dropdown/Dropdown.js +43 -42
- package/dropdown/Dropdown.stories.tsx +210 -84
- package/dropdown/Dropdown.test.js +22 -27
- package/dropdown/DropdownMenu.js +12 -18
- package/dropdown/DropdownMenuItem.js +5 -18
- package/dropdown/types.d.ts +3 -3
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +174 -220
- package/file-input/FileInput.stories.tsx +122 -11
- package/file-input/FileInput.test.js +14 -14
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +39 -63
- package/file-input/types.d.ts +17 -0
- package/flex/Flex.d.ts +1 -1
- package/flex/Flex.js +33 -19
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +83 -7
- package/footer/Footer.js +6 -8
- package/footer/Footer.stories.tsx +99 -1
- package/footer/Footer.test.js +14 -26
- package/footer/types.d.ts +1 -0
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +3 -2
- package/header/Header.js +21 -23
- package/header/Header.stories.tsx +152 -9
- package/header/Header.test.js +2 -2
- package/header/types.d.ts +3 -2
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.js +1 -1
- package/inset/Inset.stories.tsx +2 -1
- package/layout/ApplicationLayout.d.ts +3 -3
- package/layout/ApplicationLayout.js +1 -1
- package/layout/ApplicationLayout.stories.tsx +1 -0
- package/layout/types.d.ts +2 -3
- package/link/Link.js +4 -4
- package/link/Link.stories.tsx +60 -0
- package/link/Link.test.js +2 -4
- package/link/types.d.ts +2 -2
- package/main.d.ts +3 -2
- package/main.js +9 -1
- package/{tabs-nav → nav-tabs}/NavTabs.js +1 -1
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +96 -6
- package/{tabs-nav → nav-tabs}/NavTabs.test.js +1 -1
- package/{tabs-nav → nav-tabs}/Tab.js +38 -18
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.test.js +44 -8
- package/package.json +15 -20
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +7 -15
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +45 -48
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +5 -5
- package/password-input/PasswordInput.test.js +14 -13
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +5 -5
- package/progress-bar/ProgressBar.stories.jsx +35 -2
- package/progress-bar/ProgressBar.test.js +1 -1
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.js +11 -12
- package/quick-nav/QuickNav.stories.tsx +111 -19
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +43 -28
- package/radio-group/RadioGroup.js +15 -13
- package/radio-group/RadioGroup.stories.tsx +132 -18
- package/radio-group/RadioGroup.test.js +124 -97
- package/radio-group/types.d.ts +2 -2
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.js +49 -108
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +41 -64
- package/resultsetTable/types.d.ts +1 -1
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +5 -35
- package/select/Option.js +11 -24
- package/select/Select.js +59 -36
- package/select/Select.stories.tsx +494 -150
- package/select/Select.test.js +341 -288
- package/select/types.d.ts +2 -2
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +66 -96
- package/sidenav/Sidenav.stories.tsx +165 -63
- package/sidenav/types.d.ts +21 -18
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +119 -95
- package/slider/Slider.stories.tsx +64 -1
- package/slider/Slider.test.js +88 -25
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +17 -23
- package/spinner/Spinner.stories.jsx +53 -27
- package/spinner/Spinner.test.js +1 -1
- package/switch/Switch.d.ts +3 -3
- package/switch/Switch.js +96 -85
- package/switch/Switch.stories.tsx +33 -0
- package/switch/Switch.test.js +27 -14
- package/switch/types.d.ts +8 -3
- package/table/Table.js +3 -3
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +2 -2
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +132 -0
- package/tabs/Tabs.js +358 -108
- package/tabs/Tabs.stories.tsx +119 -5
- package/tabs/Tabs.test.js +220 -10
- package/tabs/types.d.ts +12 -2
- package/tag/Tag.js +8 -10
- package/tag/Tag.stories.tsx +14 -1
- package/tag/Tag.test.js +1 -1
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +60 -0
- package/text-input/Suggestion.js +40 -11
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +134 -0
- package/text-input/TextInput.js +189 -277
- package/text-input/TextInput.stories.tsx +280 -184
- package/text-input/TextInput.test.js +736 -725
- package/text-input/types.d.ts +21 -2
- package/textarea/Textarea.js +3 -4
- package/textarea/Textarea.stories.jsx +60 -1
- package/textarea/Textarea.test.js +2 -4
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +7 -4
- package/toggle-group/ToggleGroup.stories.tsx +42 -0
- package/toggle-group/ToggleGroup.test.js +1 -1
- package/toggle-group/types.d.ts +1 -1
- package/typography/Typography.d.ts +2 -2
- package/typography/Typography.js +14 -113
- package/typography/Typography.stories.tsx +1 -1
- package/useTheme.d.ts +1234 -1
- package/useTheme.js +1 -1
- package/useTranslatedLabels.d.ts +84 -1
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +108 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +138 -0
- package/wizard/Wizard.js +2 -2
- package/wizard/Wizard.stories.tsx +20 -0
- package/wizard/Wizard.test.js +1 -1
- package/wizard/types.d.ts +5 -6
- package/common/RequiredComponent.js +0 -32
- /package/{tabs-nav → grid}/types.js +0 -0
- /package/{tabs-nav → nav-tabs}/NavTabs.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/types.d.ts +0 -0
package/text-input/TextInput.js
CHANGED
|
@@ -23,70 +23,44 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
|
23
23
|
|
|
24
24
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
25
25
|
|
|
26
|
-
var _variables = require("../common/variables
|
|
26
|
+
var _variables = require("../common/variables");
|
|
27
27
|
|
|
28
|
-
var _utils = require("../common/utils
|
|
29
|
-
|
|
30
|
-
var _uuid = require("uuid");
|
|
28
|
+
var _utils = require("../common/utils");
|
|
31
29
|
|
|
32
30
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
33
31
|
|
|
34
32
|
var _NumberInputContext = _interopRequireDefault(require("../number-input/NumberInputContext"));
|
|
35
33
|
|
|
36
|
-
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");
|
|
37
41
|
|
|
38
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11
|
|
42
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
39
43
|
|
|
40
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); }
|
|
41
45
|
|
|
42
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; }
|
|
43
47
|
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
61
|
-
d: "M0 0h24v24H0V0z",
|
|
62
|
-
fill: "none"
|
|
63
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
64
|
-
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"
|
|
65
|
-
})),
|
|
66
|
-
increment: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
67
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
68
|
-
height: "24px",
|
|
69
|
-
viewBox: "0 0 24 24",
|
|
70
|
-
width: "24px",
|
|
71
|
-
fill: "currentColor"
|
|
72
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
73
|
-
d: "M0 0h24v24H0z",
|
|
74
|
-
fill: "none"
|
|
75
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
76
|
-
d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"
|
|
77
|
-
})),
|
|
78
|
-
decrement: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
79
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
80
|
-
height: "24px",
|
|
81
|
-
viewBox: "0 0 24 24",
|
|
82
|
-
width: "24px",
|
|
83
|
-
fill: "currentColor"
|
|
84
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
85
|
-
d: "M0 0h24v24H0z",
|
|
86
|
-
fill: "none"
|
|
87
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
88
|
-
d: "M19 13H5v-2h14v2z"
|
|
89
|
-
}))
|
|
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];
|
|
90
64
|
};
|
|
91
65
|
|
|
92
66
|
var makeCancelable = function makeCancelable(promise) {
|
|
@@ -110,63 +84,69 @@ var makeCancelable = function makeCancelable(promise) {
|
|
|
110
84
|
};
|
|
111
85
|
};
|
|
112
86
|
|
|
113
|
-
var
|
|
114
|
-
return
|
|
87
|
+
var hasSuggestions = function hasSuggestions(suggestions) {
|
|
88
|
+
return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
|
|
115
89
|
};
|
|
116
90
|
|
|
117
|
-
var
|
|
118
|
-
|
|
91
|
+
var isNotOptional = function isNotOptional(value, optional) {
|
|
92
|
+
return value === "" && !optional;
|
|
93
|
+
};
|
|
119
94
|
|
|
120
|
-
|
|
121
|
-
|
|
95
|
+
var isLengthIncorrect = function isLengthIncorrect(value, minLength, maxLength) {
|
|
96
|
+
return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
|
|
97
|
+
};
|
|
122
98
|
|
|
123
|
-
|
|
124
|
-
|
|
99
|
+
var isNumberIncorrect = function isNumberIncorrect(value, minNumber, maxNumber) {
|
|
100
|
+
return minNumber && parseInt(value) < minNumber || maxNumber && parseInt(value) > maxNumber;
|
|
101
|
+
};
|
|
125
102
|
|
|
126
|
-
|
|
127
|
-
return
|
|
103
|
+
var patternMissmatch = function patternMissmatch(pattern, value) {
|
|
104
|
+
return pattern && !new RegExp(pattern).test(value);
|
|
128
105
|
};
|
|
129
106
|
|
|
130
|
-
var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
131
|
-
var label =
|
|
132
|
-
|
|
133
|
-
name =
|
|
134
|
-
|
|
135
|
-
defaultValue =
|
|
136
|
-
value =
|
|
137
|
-
helperText =
|
|
138
|
-
|
|
139
|
-
placeholder =
|
|
140
|
-
action =
|
|
141
|
-
|
|
142
|
-
clearable =
|
|
143
|
-
|
|
144
|
-
disabled =
|
|
145
|
-
|
|
146
|
-
optional =
|
|
147
|
-
|
|
148
|
-
prefix =
|
|
149
|
-
|
|
150
|
-
suffix =
|
|
151
|
-
onChange =
|
|
152
|
-
onBlur =
|
|
153
|
-
error =
|
|
154
|
-
suggestions =
|
|
155
|
-
pattern =
|
|
156
|
-
minLength =
|
|
157
|
-
maxLength =
|
|
158
|
-
|
|
159
|
-
autocomplete =
|
|
160
|
-
margin =
|
|
161
|
-
|
|
162
|
-
size =
|
|
163
|
-
|
|
164
|
-
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;
|
|
165
142
|
|
|
166
143
|
var _useState = (0, _react.useState)("input-".concat((0, _uuid.v4)())),
|
|
167
144
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
168
145
|
inputId = _useState2[0];
|
|
169
146
|
|
|
147
|
+
var autosuggestId = "suggestions-".concat(inputId);
|
|
148
|
+
var errorId = "error-".concat(inputId);
|
|
149
|
+
|
|
170
150
|
var _useState3 = (0, _react.useState)(defaultValue),
|
|
171
151
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
172
152
|
innerValue = _useState4[0],
|
|
@@ -194,70 +174,51 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
194
174
|
|
|
195
175
|
var _useState13 = (0, _react.useState)(-1),
|
|
196
176
|
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
197
|
-
|
|
198
|
-
|
|
177
|
+
visualFocusIndex = _useState14[0],
|
|
178
|
+
changeVisualFocusIndex = _useState14[1];
|
|
199
179
|
|
|
200
|
-
var suggestionsRef = (0, _react.useRef)(null);
|
|
201
180
|
var inputRef = (0, _react.useRef)(null);
|
|
202
181
|
var actionRef = (0, _react.useRef)(null);
|
|
203
182
|
var colorsTheme = (0, _useTheme["default"])();
|
|
204
183
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
205
184
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
206
|
-
var autosuggestId = "".concat(inputId, "-listBox");
|
|
207
|
-
var errorId = "error-".concat(inputId);
|
|
208
185
|
var numberInputContext = (0, _react.useContext)(_NumberInputContext["default"]);
|
|
209
|
-
var lastOptionIndex = (0, _react.useMemo)(function () {
|
|
210
|
-
return getLastOptionIndex(filteredSuggestions);
|
|
211
|
-
}, [filteredSuggestions]);
|
|
212
|
-
|
|
213
|
-
var isNotOptional = function isNotOptional(value) {
|
|
214
|
-
return value === "" && !optional;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
var isLengthIncorrect = function isLengthIncorrect(value) {
|
|
218
|
-
return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
var isNumberIncorrect = function isNumberIncorrect(value) {
|
|
222
|
-
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);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
var isTextInputType = function isTextInputType() {
|
|
226
|
-
var _inputRef$current, _inputRef$current2;
|
|
227
|
-
|
|
228
|
-
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";
|
|
229
|
-
};
|
|
230
186
|
|
|
231
187
|
var getNumberErrorMessage = function getNumberErrorMessage(value) {
|
|
232
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);
|
|
233
189
|
};
|
|
234
190
|
|
|
235
|
-
var
|
|
236
|
-
|
|
237
|
-
|
|
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
|
+
}, []);
|
|
238
197
|
|
|
239
198
|
var openSuggestions = function openSuggestions() {
|
|
240
|
-
hasSuggestions() && changeIsOpen(true);
|
|
199
|
+
hasSuggestions(suggestions) && changeIsOpen(true);
|
|
241
200
|
};
|
|
242
201
|
|
|
243
202
|
var closeSuggestions = function closeSuggestions() {
|
|
244
|
-
|
|
245
|
-
|
|
203
|
+
if (hasSuggestions(suggestions)) {
|
|
204
|
+
changeIsOpen(false);
|
|
205
|
+
changeVisualFocusIndex(-1);
|
|
206
|
+
}
|
|
246
207
|
};
|
|
247
208
|
|
|
248
209
|
var changeValue = function changeValue(newValue) {
|
|
249
210
|
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
250
211
|
var changedValue = typeof newValue === "number" ? newValue.toString() : newValue;
|
|
251
|
-
if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
212
|
+
if (isNotOptional(newValue, optional)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
252
213
|
value: changedValue,
|
|
253
214
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
254
|
-
});else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
215
|
+
});else if (isLengthIncorrect(newValue, minLength, maxLength)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
255
216
|
value: changedValue,
|
|
256
217
|
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
257
|
-
});else if (
|
|
218
|
+
});else if (patternMissmatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
258
219
|
value: changedValue,
|
|
259
220
|
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
260
|
-
});else if (newValue
|
|
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({
|
|
261
222
|
value: changedValue,
|
|
262
223
|
error: getNumberErrorMessage(newValue)
|
|
263
224
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
@@ -274,23 +235,23 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
274
235
|
document.activeElement === inputRef.current && event.preventDefault();
|
|
275
236
|
};
|
|
276
237
|
|
|
277
|
-
var
|
|
238
|
+
var handleInputOnChange = function handleInputOnChange(event) {
|
|
278
239
|
openSuggestions();
|
|
279
240
|
changeValue(event.target.value);
|
|
280
241
|
};
|
|
281
242
|
|
|
282
|
-
var
|
|
283
|
-
|
|
284
|
-
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({
|
|
285
246
|
value: event.target.value,
|
|
286
247
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
287
|
-
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
248
|
+
});else if (isLengthIncorrect(event.target.value, minLength, maxLength)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
288
249
|
value: event.target.value,
|
|
289
250
|
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
290
|
-
});else if (
|
|
251
|
+
});else if (patternMissmatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
291
252
|
value: event.target.value,
|
|
292
253
|
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
293
|
-
});else if (event.target.value
|
|
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({
|
|
294
255
|
value: event.target.value,
|
|
295
256
|
error: getNumberErrorMessage(event.target.value)
|
|
296
257
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
@@ -298,7 +259,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
298
259
|
});
|
|
299
260
|
};
|
|
300
261
|
|
|
301
|
-
var
|
|
262
|
+
var handleInputOnKeyDown = function handleInputOnKeyDown(event) {
|
|
302
263
|
switch (event.key) {
|
|
303
264
|
case "Down":
|
|
304
265
|
case "ArrowDown":
|
|
@@ -310,7 +271,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
310
271
|
openSuggestions();
|
|
311
272
|
|
|
312
273
|
if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
|
|
313
|
-
|
|
274
|
+
changeVisualFocusIndex(function (visualFocusedSuggIndex) {
|
|
314
275
|
if (visualFocusedSuggIndex < filteredSuggestions.length - 1) return visualFocusedSuggIndex + 1;else if (visualFocusedSuggIndex === filteredSuggestions.length - 1) return 0;
|
|
315
276
|
});
|
|
316
277
|
}
|
|
@@ -328,7 +289,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
328
289
|
openSuggestions();
|
|
329
290
|
|
|
330
291
|
if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
|
|
331
|
-
|
|
292
|
+
changeVisualFocusIndex(function (visualFocusedSuggIndex) {
|
|
332
293
|
if (visualFocusedSuggIndex === 0 || visualFocusedSuggIndex === -1) return filteredSuggestions.length > 0 ? filteredSuggestions.length - 1 : suggestions.length - 1;else return visualFocusedSuggIndex - 1;
|
|
333
294
|
});
|
|
334
295
|
}
|
|
@@ -340,7 +301,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
340
301
|
case "Escape":
|
|
341
302
|
event.preventDefault();
|
|
342
303
|
|
|
343
|
-
if (hasSuggestions()) {
|
|
304
|
+
if (hasSuggestions(suggestions)) {
|
|
344
305
|
changeValue("");
|
|
345
306
|
isOpen && closeSuggestions();
|
|
346
307
|
}
|
|
@@ -348,9 +309,9 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
348
309
|
break;
|
|
349
310
|
|
|
350
311
|
case "Enter":
|
|
351
|
-
if (hasSuggestions() && !isSearching) {
|
|
352
|
-
var validFocusedSuggestion = filteredSuggestions.length > 0 &&
|
|
353
|
-
validFocusedSuggestion && changeValue(filteredSuggestions[
|
|
312
|
+
if (hasSuggestions(suggestions) && !isSearching) {
|
|
313
|
+
var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusIndex >= 0 && visualFocusIndex < filteredSuggestions.length;
|
|
314
|
+
validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusIndex]);
|
|
354
315
|
isOpen && closeSuggestions();
|
|
355
316
|
}
|
|
356
317
|
|
|
@@ -375,12 +336,12 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
375
336
|
};
|
|
376
337
|
|
|
377
338
|
var setNumberProps = function setNumberProps(type, min, max, step) {
|
|
378
|
-
var _inputRef$
|
|
339
|
+
var _inputRef$current2, _inputRef$current3, _inputRef$current4, _inputRef$current5;
|
|
379
340
|
|
|
380
|
-
type && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$
|
|
381
|
-
min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$
|
|
382
|
-
max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$
|
|
383
|
-
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));
|
|
384
345
|
};
|
|
385
346
|
|
|
386
347
|
var decrementNumber = function decrementNumber() {
|
|
@@ -423,15 +384,6 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
423
384
|
}
|
|
424
385
|
};
|
|
425
386
|
|
|
426
|
-
(0, _react.useLayoutEffect)(function () {
|
|
427
|
-
var _suggestionsRef$curre, _visualFocusedOptionE;
|
|
428
|
-
|
|
429
|
-
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];
|
|
430
|
-
visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : (_visualFocusedOptionE = visualFocusedOptionEl.scrollIntoView) === null || _visualFocusedOptionE === void 0 ? void 0 : _visualFocusedOptionE.call(visualFocusedOptionEl, {
|
|
431
|
-
block: "nearest",
|
|
432
|
-
inline: "start"
|
|
433
|
-
});
|
|
434
|
-
}, [visualFocusedSuggIndex]);
|
|
435
387
|
(0, _react.useEffect)(function () {
|
|
436
388
|
if (typeof suggestions === "function") {
|
|
437
389
|
changeIsSearching(true);
|
|
@@ -455,7 +407,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
455
407
|
changeFilteredSuggestions(suggestions.filter(function (suggestion) {
|
|
456
408
|
return suggestion.toUpperCase().startsWith((value !== null && value !== void 0 ? value : innerValue).toUpperCase());
|
|
457
409
|
}));
|
|
458
|
-
|
|
410
|
+
changeVisualFocusIndex(-1);
|
|
459
411
|
}
|
|
460
412
|
|
|
461
413
|
(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
@@ -483,17 +435,48 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
483
435
|
}, prefix && /*#__PURE__*/_react["default"].createElement(Prefix, {
|
|
484
436
|
disabled: disabled,
|
|
485
437
|
backgroundType: backgroundType
|
|
486
|
-
}, 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, {
|
|
487
472
|
id: inputId,
|
|
488
473
|
name: name,
|
|
489
474
|
value: value !== null && value !== void 0 ? value : innerValue,
|
|
490
475
|
placeholder: placeholder,
|
|
491
|
-
onBlur:
|
|
492
|
-
onChange:
|
|
493
|
-
onFocus:
|
|
494
|
-
|
|
495
|
-
},
|
|
496
|
-
onKeyDown: handleIOnKeyDown,
|
|
476
|
+
onBlur: handleInputOnBlur,
|
|
477
|
+
onChange: handleInputOnChange,
|
|
478
|
+
onFocus: openSuggestions,
|
|
479
|
+
onKeyDown: handleInputOnKeyDown,
|
|
497
480
|
onMouseDown: function onMouseDown(event) {
|
|
498
481
|
event.stopPropagation();
|
|
499
482
|
},
|
|
@@ -503,119 +486,80 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
503
486
|
pattern: pattern,
|
|
504
487
|
minLength: minLength,
|
|
505
488
|
maxLength: maxLength,
|
|
506
|
-
autoComplete: autocomplete,
|
|
489
|
+
autoComplete: autocomplete === "off" ? "nope" : autocomplete,
|
|
507
490
|
tabIndex: tabIndex,
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
"aria-
|
|
511
|
-
"aria-
|
|
512
|
-
"aria-expanded":
|
|
513
|
-
"aria-
|
|
514
|
-
"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,
|
|
515
499
|
"aria-errormessage": error ? errorId : undefined,
|
|
516
|
-
"aria-required": optional ?
|
|
517
|
-
}), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
|
|
500
|
+
"aria-required": optional ? false : true
|
|
501
|
+
})), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
|
|
518
502
|
backgroundType: backgroundType,
|
|
519
503
|
"aria-label": "Error"
|
|
520
|
-
},
|
|
521
|
-
onClick:
|
|
522
|
-
return handleClearActionOnClick();
|
|
523
|
-
},
|
|
504
|
+
}, _Icons["default"].error), !disabled && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
505
|
+
onClick: handleClearActionOnClick,
|
|
524
506
|
onMouseDown: function onMouseDown(event) {
|
|
525
507
|
event.stopPropagation();
|
|
526
508
|
},
|
|
527
509
|
backgroundType: backgroundType,
|
|
528
510
|
tabIndex: tabIndex,
|
|
529
511
|
title: translatedLabels.textInput.clearFieldActionTitle,
|
|
530
|
-
"aria-label": translatedLabels.textInput.clearFieldActionTitle
|
|
531
|
-
|
|
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, {
|
|
532
515
|
ref: actionRef,
|
|
533
516
|
disabled: disabled,
|
|
534
|
-
onClick:
|
|
535
|
-
return handleDecrementActionOnClick();
|
|
536
|
-
},
|
|
517
|
+
onClick: handleDecrementActionOnClick,
|
|
537
518
|
onMouseDown: function onMouseDown(event) {
|
|
538
519
|
event.stopPropagation();
|
|
539
520
|
},
|
|
540
521
|
backgroundType: backgroundType,
|
|
541
522
|
tabIndex: tabIndex,
|
|
542
523
|
title: translatedLabels.numberInput.decrementValueTitle,
|
|
543
|
-
"aria-label": translatedLabels.numberInput.decrementValueTitle
|
|
544
|
-
|
|
524
|
+
"aria-label": translatedLabels.numberInput.decrementValueTitle,
|
|
525
|
+
type: "button"
|
|
526
|
+
}, _Icons["default"].decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
545
527
|
ref: actionRef,
|
|
546
528
|
disabled: disabled,
|
|
547
|
-
onClick:
|
|
548
|
-
return handleIncrementActionOnClick();
|
|
549
|
-
},
|
|
529
|
+
onClick: handleIncrementActionOnClick,
|
|
550
530
|
onMouseDown: function onMouseDown(event) {
|
|
551
531
|
event.stopPropagation();
|
|
552
532
|
},
|
|
553
533
|
backgroundType: backgroundType,
|
|
554
534
|
tabIndex: tabIndex,
|
|
555
535
|
title: translatedLabels.numberInput.incrementValueTitle,
|
|
556
|
-
"aria-label": translatedLabels.numberInput.incrementValueTitle
|
|
557
|
-
|
|
536
|
+
"aria-label": translatedLabels.numberInput.incrementValueTitle,
|
|
537
|
+
type: "button"
|
|
538
|
+
}, _Icons["default"].increment)), action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
558
539
|
ref: actionRef,
|
|
559
540
|
disabled: disabled,
|
|
560
|
-
onClick:
|
|
561
|
-
return action.onClick();
|
|
562
|
-
},
|
|
541
|
+
onClick: action.onClick,
|
|
563
542
|
onMouseDown: function onMouseDown(event) {
|
|
564
543
|
event.stopPropagation();
|
|
565
544
|
},
|
|
566
545
|
title: action.title,
|
|
567
546
|
"aria-label": action.title,
|
|
568
547
|
backgroundType: backgroundType,
|
|
569
|
-
tabIndex: tabIndex
|
|
570
|
-
|
|
548
|
+
tabIndex: tabIndex,
|
|
549
|
+
type: "button"
|
|
550
|
+
}, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
571
551
|
src: action.icon
|
|
572
552
|
}) : action.icon), suffix && /*#__PURE__*/_react["default"].createElement(Suffix, {
|
|
573
553
|
disabled: disabled,
|
|
574
554
|
backgroundType: backgroundType
|
|
575
|
-
}, suffix),
|
|
576
|
-
id: autosuggestId,
|
|
577
|
-
error: isAutosuggestError ? true : false,
|
|
578
|
-
onMouseDown: function onMouseDown(event) {
|
|
579
|
-
event.preventDefault();
|
|
580
|
-
},
|
|
581
|
-
ref: suggestionsRef,
|
|
582
|
-
role: "listbox",
|
|
583
|
-
"aria-label": label
|
|
584
|
-
}, !isSearching && !isAutosuggestError && filteredSuggestions.length > 0 && filteredSuggestions.map(function (suggestion, index) {
|
|
585
|
-
return /*#__PURE__*/_react["default"].createElement(_Suggestion["default"], {
|
|
586
|
-
key: "suggestion-".concat(index),
|
|
587
|
-
id: "suggestion-".concat(index),
|
|
588
|
-
value: value !== null && value !== void 0 ? value : innerValue,
|
|
589
|
-
onClick: function onClick() {
|
|
590
|
-
changeValue(suggestion);
|
|
591
|
-
closeSuggestions();
|
|
592
|
-
},
|
|
593
|
-
suggestion: suggestion,
|
|
594
|
-
isLast: index === lastOptionIndex,
|
|
595
|
-
visuallyFocused: visualFocusedSuggIndex === index,
|
|
596
|
-
highlighted: typeof suggestions === "function"
|
|
597
|
-
});
|
|
598
|
-
}), isSearching && /*#__PURE__*/_react["default"].createElement(SuggestionsSystemMessage, null, translatedLabels.textInput.searchingMessage), isAutosuggestError && /*#__PURE__*/_react["default"].createElement(SuggestionsError, null, /*#__PURE__*/_react["default"].createElement(SuggestionsErrorIcon, {
|
|
599
|
-
backgroundType: backgroundType
|
|
600
|
-
}, textInputIcons.error), translatedLabels.textInput.fetchingDataErrorMessage))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
555
|
+
}, suffix)), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
601
556
|
id: errorId,
|
|
602
557
|
backgroundType: backgroundType,
|
|
603
558
|
"aria-live": error ? "assertive" : "off"
|
|
604
559
|
}, error)));
|
|
605
560
|
});
|
|
606
561
|
|
|
607
|
-
var
|
|
608
|
-
small: "240px",
|
|
609
|
-
medium: "360px",
|
|
610
|
-
large: "480px",
|
|
611
|
-
fillParent: "100%"
|
|
612
|
-
};
|
|
613
|
-
|
|
614
|
-
var calculateWidth = function calculateWidth(margin, size) {
|
|
615
|
-
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
616
|
-
};
|
|
617
|
-
|
|
618
|
-
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) {
|
|
562
|
+
var TextInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
619
563
|
return calculateWidth(props.margin, props.size);
|
|
620
564
|
}, function (props) {
|
|
621
565
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -672,7 +616,7 @@ var InputContainer = _styledComponents["default"].div(_templateObject5 || (_temp
|
|
|
672
616
|
}, function (props) {
|
|
673
617
|
return props.disabled && "cursor: not-allowed;";
|
|
674
618
|
}, function (props) {
|
|
675
|
-
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 ");
|
|
676
620
|
});
|
|
677
621
|
|
|
678
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) {
|
|
@@ -691,71 +635,39 @@ var Input = _styledComponents["default"].input(_templateObject6 || (_templateObj
|
|
|
691
635
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPlaceholderFontColorOnDark : props.theme.disabledPlaceholderFontColor : props.backgroundType === "dark" ? props.theme.placeholderFontColorOnDark : props.theme.placeholderFontColor;
|
|
692
636
|
});
|
|
693
637
|
|
|
694
|
-
var
|
|
695
|
-
|
|
696
|
-
var Action = _styledComponents["default"].button(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n font-size: 1rem;\n font-family: ", ";\n border: 1px solid transparent;\n border-radius: 2px;\n padding: 3px;\n margin-left: 0.25rem;\n ", "\n\n box-shadow: 0 0 0 2px transparent;\n background-color: ", ";\n\n color: ", ";\n\n ", "\n\n svg {\n line-height: 18px;\n }\n"])), function (props) {
|
|
697
|
-
return props.theme.fontFamily;
|
|
698
|
-
}, function (props) {
|
|
638
|
+
var Action = _styledComponents["default"].button(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n border: 1px solid transparent;\n border-radius: 2px;\n width: 24px;\n height: 24px;\n padding: 3px;\n margin-left: 0.25rem;\n ", "\n\n box-shadow: 0 0 0 2px transparent;\n background-color: ", ";\n\n color: ", ";\n\n ", "\n\n img, svg {\n width: 16px;\n height: 16px;\n }\n"])), function (props) {
|
|
699
639
|
return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
|
|
700
640
|
}, function (props) {
|
|
701
641
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledActionBackgroundColorOnDark : props.theme.disabledActionBackgroundColor : props.backgroundType === "dark" ? props.theme.actionBackgroundColorOnDark : props.theme.actionBackgroundColor;
|
|
702
642
|
}, function (props) {
|
|
703
643
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledActionIconColorOnDark : props.theme.disabledActionIconColor : props.backgroundType === "dark" ? props.theme.actionIconColorOnDark : props.theme.actionIconColor;
|
|
704
644
|
}, function (props) {
|
|
705
|
-
return !props.disabled && "\n &:focus
|
|
645
|
+
return !props.disabled && "\n &:focus, \n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.focusActionBorderColorOnDark : props.theme.focusActionBorderColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.focusActionIconColorOnDark : props.theme.focusActionIconColor, ";\n }\n &:hover {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionBackgroundColorOnDark : props.theme.hoverActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionIconColorOnDark : props.theme.hoverActionIconColor, ";\n }\n &:active {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionBackgroundColorOnDark : props.theme.activeActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionIconColorOnDark : props.theme.activeActionIconColor, ";\n }\n ");
|
|
706
646
|
});
|
|
707
647
|
|
|
708
|
-
var Prefix = _styledComponents["default"].span(
|
|
648
|
+
var Prefix = _styledComponents["default"].span(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n height: 1.5rem;\n line-height: 1.5rem;\n margin-left: 0.25rem;\n padding: 0 0.5rem 0 0;\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"])), function (props) {
|
|
709
649
|
var color = props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPrefixColorOnDark : props.theme.disabledPrefixColor : props.backgroundType === "dark" ? props.theme.prefixColorOnDark : props.theme.prefixColor;
|
|
710
650
|
return "color: ".concat(color, "; border-right: 1px solid ").concat(color, ";");
|
|
711
651
|
}, function (props) {
|
|
712
652
|
return props.theme.fontFamily;
|
|
713
653
|
});
|
|
714
654
|
|
|
715
|
-
var Suffix = _styledComponents["default"].span(
|
|
655
|
+
var Suffix = _styledComponents["default"].span(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n height: 1.5rem;\n line-height: 1.5rem;\n margin: 0 0.25rem;\n padding: 0 0 0 0.5rem;\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"])), function (props) {
|
|
716
656
|
var color = props.disabled ? props.backgroundType === "dark" ? props.theme.disabledSuffixColorOnDark : props.theme.disabledSuffixColor : props.backgroundType === "dark" ? props.theme.suffixColorOnDark : props.theme.suffixColor;
|
|
717
657
|
return "color: ".concat(color, "; border-left: 1px solid ").concat(color, ";");
|
|
718
658
|
}, function (props) {
|
|
719
659
|
return props.theme.fontFamily;
|
|
720
660
|
});
|
|
721
661
|
|
|
722
|
-
var ErrorIcon = _styledComponents["default"].span(
|
|
662
|
+
var ErrorIcon = _styledComponents["default"].span(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n padding: 3px;\n height: 18px;\n width: 18px;\n margin-left: 0.25rem;\n color: ", ";\n\n svg {\n line-height: 18px;\n font-size: 1.25rem;\n }\n"])), function (props) {
|
|
723
663
|
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
724
664
|
});
|
|
725
665
|
|
|
726
|
-
var Error = _styledComponents["default"].span(
|
|
666
|
+
var Error = _styledComponents["default"].span(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 1.5em;\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n line-height: 1.5em;\n margin-top: 0.25rem;\n"])), function (props) {
|
|
727
667
|
return props.backgroundType === "dark" ? props.theme.errorMessageColorOnDark : props.theme.errorMessageColor;
|
|
728
668
|
}, function (props) {
|
|
729
669
|
return props.theme.fontFamily;
|
|
730
670
|
});
|
|
731
671
|
|
|
732
|
-
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) {
|
|
733
|
-
return props.error ? props.theme.errorListDialogBackgroundColor : props.theme.listDialogBackgroundColor;
|
|
734
|
-
}, function (props) {
|
|
735
|
-
return props.error ? props.theme.errorListDialogBorderColor : props.theme.listDialogBorderColor;
|
|
736
|
-
}, function (props) {
|
|
737
|
-
return props.theme.listOptionFontColor;
|
|
738
|
-
}, function (props) {
|
|
739
|
-
return props.theme.fontFamily;
|
|
740
|
-
}, function (props) {
|
|
741
|
-
return props.theme.listOptionFontSize;
|
|
742
|
-
}, function (props) {
|
|
743
|
-
return props.theme.listOptionFontStyle;
|
|
744
|
-
}, function (props) {
|
|
745
|
-
return props.theme.listOptionFontWeight;
|
|
746
|
-
});
|
|
747
|
-
|
|
748
|
-
var SuggestionsSystemMessage = _styledComponents["default"].span(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.25rem 1rem;\n color: ", ";\n line-height: 1.715em;\n"])), function (props) {
|
|
749
|
-
return props.theme.systemMessageFontColor;
|
|
750
|
-
});
|
|
751
|
-
|
|
752
|
-
var SuggestionsErrorIcon = _styledComponents["default"].span(_templateObject15 || (_templateObject15 = (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) {
|
|
753
|
-
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
754
|
-
});
|
|
755
|
-
|
|
756
|
-
var SuggestionsError = _styledComponents["default"].span(_templateObject16 || (_templateObject16 = (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) {
|
|
757
|
-
return props.theme.errorListDialogFontColor;
|
|
758
|
-
});
|
|
759
|
-
|
|
760
672
|
var _default = DxcTextInput;
|
|
761
673
|
exports["default"] = _default;
|