@dxc-technology/halstack-react 0.0.0-31c6b1f → 0.0.0-324b670
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 +1 -10
- package/BackgroundColorContext.js +5 -22
- package/HalstackContext.d.ts +1235 -0
- package/HalstackContext.js +310 -0
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +116 -160
- package/accordion/Accordion.stories.tsx +103 -127
- package/accordion/Accordion.test.js +25 -41
- package/accordion/types.d.ts +5 -16
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +31 -98
- package/accordion-group/AccordionGroup.stories.tsx +94 -67
- package/accordion-group/AccordionGroup.test.js +52 -105
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +31 -0
- package/accordion-group/types.d.ts +11 -16
- package/alert/Alert.js +23 -59
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +29 -46
- package/alert/types.d.ts +5 -5
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +8 -19
- package/badge/types.d.ts +2 -1
- package/bleed/Bleed.js +14 -55
- package/bleed/Bleed.stories.tsx +95 -95
- package/bleed/types.d.ts +2 -2
- package/box/Box.d.ts +1 -1
- package/box/Box.js +30 -81
- package/box/Box.stories.tsx +38 -51
- package/box/Box.test.js +2 -7
- package/box/types.d.ts +3 -14
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +89 -0
- package/bulleted-list/BulletedList.stories.tsx +115 -0
- package/bulleted-list/types.d.ts +38 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +63 -115
- package/button/Button.stories.tsx +160 -90
- package/button/Button.test.js +18 -17
- package/button/types.d.ts +12 -8
- package/card/Card.d.ts +1 -1
- package/card/Card.js +64 -107
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +11 -22
- package/card/types.d.ts +6 -11
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +142 -181
- package/checkbox/Checkbox.stories.tsx +128 -94
- package/checkbox/Checkbox.test.js +160 -39
- package/checkbox/types.d.ts +11 -3
- package/chip/Chip.js +39 -79
- package/chip/Chip.stories.tsx +121 -26
- package/chip/Chip.test.js +16 -31
- package/chip/types.d.ts +4 -4
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +237 -0
- package/common/coreTokens.js +184 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +6 -12
- package/common/variables.d.ts +1381 -0
- package/common/variables.js +998 -1117
- package/container/Container.d.ts +4 -0
- package/container/Container.js +194 -0
- package/container/Container.stories.tsx +214 -0
- package/container/types.d.ts +74 -0
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +214 -0
- package/date-input/DateInput.js +153 -299
- package/date-input/DateInput.stories.tsx +203 -56
- package/date-input/DateInput.test.js +700 -371
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +115 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +58 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +100 -0
- package/date-input/types.d.ts +72 -15
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +73 -107
- package/dialog/Dialog.stories.tsx +320 -167
- package/dialog/Dialog.test.js +287 -20
- package/dialog/types.d.ts +18 -25
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +243 -300
- package/dropdown/Dropdown.stories.tsx +245 -56
- package/dropdown/Dropdown.test.js +575 -165
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +63 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +67 -0
- package/dropdown/types.d.ts +32 -14
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +246 -357
- package/file-input/FileInput.stories.tsx +123 -12
- package/file-input/FileInput.test.js +369 -367
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +50 -99
- package/file-input/types.d.ts +25 -8
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +57 -0
- package/flex/Flex.stories.tsx +112 -0
- package/flex/types.d.ts +97 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +57 -115
- package/footer/Footer.stories.tsx +41 -19
- package/footer/Footer.test.js +33 -57
- package/footer/Icons.d.ts +2 -2
- package/footer/Icons.js +3 -8
- package/footer/types.d.ts +21 -28
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +76 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +90 -170
- package/header/Header.stories.tsx +118 -39
- package/header/Header.test.js +13 -26
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +4 -9
- package/header/types.d.ts +5 -19
- package/heading/Heading.js +10 -32
- package/heading/Heading.test.js +71 -88
- package/heading/types.d.ts +7 -7
- package/image/Image.d.ts +4 -0
- package/image/Image.js +70 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/inset/Inset.js +14 -55
- package/inset/Inset.stories.tsx +37 -36
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +82 -166
- package/layout/ApplicationLayout.stories.tsx +85 -94
- package/layout/Icons.d.ts +8 -0
- package/layout/Icons.js +51 -48
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +13 -0
- package/layout/types.d.ts +19 -35
- package/link/Link.d.ts +3 -2
- package/link/Link.js +61 -95
- package/link/Link.stories.tsx +155 -53
- package/link/Link.test.js +25 -53
- package/link/types.d.ts +15 -31
- package/main.d.ts +11 -12
- package/main.js +58 -109
- package/nav-tabs/NavTabs.d.ts +8 -0
- package/nav-tabs/NavTabs.js +90 -0
- package/nav-tabs/NavTabs.stories.tsx +274 -0
- package/nav-tabs/NavTabs.test.js +75 -0
- package/nav-tabs/Tab.d.ts +4 -0
- package/nav-tabs/Tab.js +117 -0
- package/nav-tabs/types.d.ts +52 -0
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +26 -35
- package/number-input/NumberInput.stories.tsx +42 -26
- package/number-input/NumberInput.test.js +701 -377
- package/number-input/types.d.ts +12 -6
- package/package.json +44 -46
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +21 -47
- package/paginator/Paginator.js +34 -91
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +280 -211
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.d.ts +5 -0
- package/paragraph/Paragraph.js +22 -0
- package/paragraph/Paragraph.stories.tsx +27 -0
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +35 -0
- package/password-input/PasswordInput.js +57 -123
- package/password-input/PasswordInput.stories.tsx +1 -33
- package/password-input/PasswordInput.test.js +160 -143
- package/password-input/types.d.ts +9 -8
- package/progress-bar/ProgressBar.js +65 -91
- package/progress-bar/ProgressBar.stories.tsx +93 -0
- package/progress-bar/ProgressBar.test.js +72 -44
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.js +71 -41
- package/quick-nav/QuickNav.stories.tsx +146 -27
- package/quick-nav/types.d.ts +10 -10
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +59 -76
- package/radio-group/RadioGroup.js +71 -116
- package/radio-group/RadioGroup.stories.tsx +132 -18
- package/radio-group/RadioGroup.test.js +518 -457
- package/radio-group/types.d.ts +10 -10
- package/resultset-table/Icons.d.ts +7 -0
- package/resultset-table/Icons.js +47 -0
- package/resultset-table/ResultsetTable.js +159 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +50 -25
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +117 -118
- package/{resultsetTable → resultset-table}/types.d.ts +7 -7
- package/resultset-table/types.js +5 -0
- package/select/Icons.d.ts +7 -7
- package/select/Icons.js +1 -5
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +46 -51
- package/select/Option.js +20 -50
- package/select/Select.js +155 -228
- package/select/Select.stories.tsx +525 -136
- package/select/Select.test.js +1973 -1696
- package/select/types.d.ts +16 -20
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +47 -0
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +131 -71
- package/sidenav/Sidenav.stories.tsx +251 -151
- package/sidenav/Sidenav.test.js +26 -45
- package/sidenav/types.d.ts +52 -26
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +149 -181
- package/slider/Slider.test.js +185 -81
- package/slider/types.d.ts +7 -3
- package/spinner/Spinner.js +31 -75
- package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +53 -27
- package/spinner/Spinner.test.js +26 -35
- package/spinner/types.d.ts +3 -3
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +147 -125
- package/switch/Switch.stories.tsx +37 -60
- package/switch/Switch.test.js +138 -56
- package/switch/types.d.ts +7 -3
- package/table/Table.js +8 -30
- package/table/{Table.stories.jsx → Table.stories.tsx} +80 -1
- package/table/Table.test.js +3 -8
- package/table/types.d.ts +8 -8
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +113 -0
- package/tabs/Tabs.js +315 -141
- package/tabs/Tabs.stories.tsx +119 -11
- package/tabs/Tabs.test.js +223 -69
- package/tabs/types.d.ts +28 -18
- package/tag/Tag.js +29 -61
- package/tag/Tag.stories.tsx +14 -1
- package/tag/Tag.test.js +20 -31
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +56 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +67 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +84 -0
- package/text-input/TextInput.js +309 -527
- package/text-input/TextInput.stories.tsx +266 -275
- package/text-input/TextInput.test.js +1403 -1376
- package/text-input/types.d.ts +53 -14
- package/textarea/Textarea.js +79 -131
- package/textarea/Textarea.stories.tsx +174 -0
- package/textarea/Textarea.test.js +152 -183
- package/textarea/types.d.ts +10 -6
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +92 -106
- package/toggle-group/ToggleGroup.stories.tsx +49 -4
- package/toggle-group/ToggleGroup.test.js +69 -88
- package/toggle-group/types.d.ts +26 -17
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +23 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.d.ts +1133 -1
- package/useTheme.js +4 -11
- package/useTranslatedLabels.d.ts +85 -0
- package/useTranslatedLabels.js +14 -0
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +94 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +121 -0
- package/wizard/Wizard.js +51 -91
- package/wizard/Wizard.stories.tsx +40 -1
- package/wizard/Wizard.test.js +54 -81
- package/wizard/types.d.ts +7 -7
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
- package/card/ice-cream.jpg +0 -0
- package/common/RequiredComponent.js +0 -32
- 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/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/progress-bar/ProgressBar.stories.jsx +0 -58
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -173
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
- package/resultsetTable/ResultsetTable.js +0 -254
- 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/slider/Slider.stories.tsx +0 -177
- 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/textarea/Textarea.stories.jsx +0 -157
- /package/{list → bulleted-list}/types.js +0 -0
- /package/{radio → container}/types.js +0 -0
- /package/{resultsetTable → flex}/types.js +0 -0
- /package/{row → grid}/types.js +0 -0
- /package/{stack → image}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → nav-tabs/types.js} +0 -0
- /package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +0 -0
package/text-input/TextInput.js
CHANGED
|
@@ -1,90 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
-
|
|
16
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
13
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
|
-
|
|
22
14
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
23
|
-
|
|
24
|
-
var _variables = require("../common/variables
|
|
25
|
-
|
|
26
|
-
var
|
|
27
|
-
|
|
15
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
16
|
+
var _variables = require("../common/variables");
|
|
17
|
+
var _utils = require("../common/utils");
|
|
18
|
+
var _NumberInput = require("../number-input/NumberInput");
|
|
19
|
+
var _Suggestions = _interopRequireDefault(require("./Suggestions"));
|
|
20
|
+
var Popover = _interopRequireWildcard(require("@radix-ui/react-popover"));
|
|
21
|
+
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
28
22
|
var _uuid = require("uuid");
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
fill: "currentColor"
|
|
47
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
48
|
-
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"
|
|
49
|
-
})),
|
|
50
|
-
clear: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
51
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
52
|
-
width: "24",
|
|
53
|
-
height: "24",
|
|
54
|
-
viewBox: "0 0 24 24",
|
|
55
|
-
fill: "currentColor"
|
|
56
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
57
|
-
d: "M0 0h24v24H0V0z",
|
|
58
|
-
fill: "none"
|
|
59
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
60
|
-
d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
|
|
61
|
-
})),
|
|
62
|
-
increment: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
63
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
64
|
-
height: "24px",
|
|
65
|
-
viewBox: "0 0 24 24",
|
|
66
|
-
width: "24px",
|
|
67
|
-
fill: "currentColor"
|
|
68
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
69
|
-
d: "M0 0h24v24H0z",
|
|
70
|
-
fill: "none"
|
|
71
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
72
|
-
d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"
|
|
73
|
-
})),
|
|
74
|
-
decrement: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
75
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
76
|
-
height: "24px",
|
|
77
|
-
viewBox: "0 0 24 24",
|
|
78
|
-
width: "24px",
|
|
79
|
-
fill: "currentColor"
|
|
80
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
81
|
-
d: "M0 0h24v24H0z",
|
|
82
|
-
fill: "none"
|
|
83
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
84
|
-
d: "M19 13H5v-2h14v2z"
|
|
85
|
-
}))
|
|
23
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
24
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
25
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
26
|
+
var sizes = {
|
|
27
|
+
small: "240px",
|
|
28
|
+
medium: "360px",
|
|
29
|
+
large: "480px",
|
|
30
|
+
fillParent: "100%"
|
|
31
|
+
};
|
|
32
|
+
var AutosuggestWrapper = function AutosuggestWrapper(_ref) {
|
|
33
|
+
var condition = _ref.condition,
|
|
34
|
+
wrapper = _ref.wrapper,
|
|
35
|
+
children = _ref.children;
|
|
36
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, condition ? wrapper(children) : children);
|
|
37
|
+
};
|
|
38
|
+
var calculateWidth = function calculateWidth(margin, size) {
|
|
39
|
+
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
86
40
|
};
|
|
87
|
-
|
|
88
41
|
var makeCancelable = function makeCancelable(promise) {
|
|
89
42
|
var hasCanceled_ = false;
|
|
90
43
|
var wrappedPromise = new Promise(function (resolve, reject) {
|
|
@@ -105,341 +58,257 @@ var makeCancelable = function makeCancelable(promise) {
|
|
|
105
58
|
}
|
|
106
59
|
};
|
|
107
60
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return "This field is required. Please, enter a value.";
|
|
61
|
+
var hasSuggestions = function hasSuggestions(suggestions) {
|
|
62
|
+
return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
|
|
111
63
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return "Please match the format requested.";
|
|
64
|
+
var isRequired = function isRequired(value, optional) {
|
|
65
|
+
return value === "" && !optional;
|
|
115
66
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return new RegExp(pattern).test(value);
|
|
67
|
+
var isLengthIncorrect = function isLengthIncorrect(value, minLength, maxLength) {
|
|
68
|
+
return value != null && (value.length < minLength || value.length > maxLength);
|
|
119
69
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
var last = 0;
|
|
123
|
-
|
|
124
|
-
var reducer = function reducer(acc, current) {
|
|
125
|
-
var _current$options;
|
|
126
|
-
|
|
127
|
-
return acc + ((_current$options = current.options) === null || _current$options === void 0 ? void 0 : _current$options.length);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
if (filteredSuggestions.length > 0) filteredSuggestions[0].options ? last = filteredSuggestions.reduce(reducer, 0) - 1 : last = filteredSuggestions.length - 1;
|
|
131
|
-
return last;
|
|
70
|
+
var isNumberIncorrect = function isNumberIncorrect(value, minNumber, maxNumber) {
|
|
71
|
+
return value < minNumber || value > maxNumber;
|
|
132
72
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
73
|
+
var patternMismatch = function patternMismatch(pattern, value) {
|
|
74
|
+
return pattern != null && !new RegExp(pattern).test(value);
|
|
75
|
+
};
|
|
76
|
+
var useWidth = function useWidth(target) {
|
|
77
|
+
var _useState = (0, _react.useState)(0),
|
|
78
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
79
|
+
width = _useState2[0],
|
|
80
|
+
setWidth = _useState2[1];
|
|
81
|
+
(0, _react.useEffect)(function () {
|
|
82
|
+
if (target != null) {
|
|
83
|
+
setWidth(target.getBoundingClientRect().width);
|
|
84
|
+
var triggerObserver = new ResizeObserver(function (entries) {
|
|
85
|
+
var rect = entries[0].target.getBoundingClientRect();
|
|
86
|
+
setWidth(rect === null || rect === void 0 ? void 0 : rect.width);
|
|
87
|
+
});
|
|
88
|
+
triggerObserver.observe(target);
|
|
89
|
+
return function () {
|
|
90
|
+
triggerObserver.unobserve(target);
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}, [target]);
|
|
94
|
+
return width;
|
|
95
|
+
};
|
|
96
|
+
var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
97
|
+
var label = _ref2.label,
|
|
98
|
+
_ref2$name = _ref2.name,
|
|
99
|
+
name = _ref2$name === void 0 ? "" : _ref2$name,
|
|
100
|
+
_ref2$defaultValue = _ref2.defaultValue,
|
|
101
|
+
defaultValue = _ref2$defaultValue === void 0 ? "" : _ref2$defaultValue,
|
|
102
|
+
value = _ref2.value,
|
|
103
|
+
helperText = _ref2.helperText,
|
|
104
|
+
_ref2$placeholder = _ref2.placeholder,
|
|
105
|
+
placeholder = _ref2$placeholder === void 0 ? "" : _ref2$placeholder,
|
|
106
|
+
action = _ref2.action,
|
|
107
|
+
_ref2$clearable = _ref2.clearable,
|
|
108
|
+
clearable = _ref2$clearable === void 0 ? false : _ref2$clearable,
|
|
109
|
+
_ref2$disabled = _ref2.disabled,
|
|
110
|
+
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
111
|
+
_ref2$readOnly = _ref2.readOnly,
|
|
112
|
+
readOnly = _ref2$readOnly === void 0 ? false : _ref2$readOnly,
|
|
113
|
+
_ref2$optional = _ref2.optional,
|
|
114
|
+
optional = _ref2$optional === void 0 ? false : _ref2$optional,
|
|
115
|
+
_ref2$prefix = _ref2.prefix,
|
|
116
|
+
prefix = _ref2$prefix === void 0 ? "" : _ref2$prefix,
|
|
117
|
+
_ref2$suffix = _ref2.suffix,
|
|
118
|
+
suffix = _ref2$suffix === void 0 ? "" : _ref2$suffix,
|
|
119
|
+
onChange = _ref2.onChange,
|
|
120
|
+
onBlur = _ref2.onBlur,
|
|
121
|
+
error = _ref2.error,
|
|
122
|
+
suggestions = _ref2.suggestions,
|
|
123
|
+
pattern = _ref2.pattern,
|
|
124
|
+
minLength = _ref2.minLength,
|
|
125
|
+
maxLength = _ref2.maxLength,
|
|
126
|
+
_ref2$autocomplete = _ref2.autocomplete,
|
|
127
|
+
autocomplete = _ref2$autocomplete === void 0 ? "off" : _ref2$autocomplete,
|
|
128
|
+
margin = _ref2.margin,
|
|
129
|
+
_ref2$size = _ref2.size,
|
|
130
|
+
size = _ref2$size === void 0 ? "medium" : _ref2$size,
|
|
131
|
+
_ref2$tabIndex = _ref2.tabIndex,
|
|
132
|
+
tabIndex = _ref2$tabIndex === void 0 ? 0 : _ref2$tabIndex;
|
|
133
|
+
var _useState3 = (0, _react.useState)("input-".concat((0, _uuid.v4)())),
|
|
134
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
|
|
135
|
+
inputId = _useState4[0];
|
|
136
|
+
var autosuggestId = "suggestions-".concat(inputId);
|
|
137
|
+
var errorId = "error-".concat(inputId);
|
|
138
|
+
var _useState5 = (0, _react.useState)(defaultValue),
|
|
139
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
140
|
+
innerValue = _useState6[0],
|
|
141
|
+
setInnerValue = _useState6[1];
|
|
184
142
|
var _useState7 = (0, _react.useState)(false),
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
143
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
144
|
+
isOpen = _useState8[0],
|
|
145
|
+
changeIsOpen = _useState8[1];
|
|
189
146
|
var _useState9 = (0, _react.useState)(false),
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
147
|
+
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
148
|
+
isSearching = _useState10[0],
|
|
149
|
+
changeIsSearching = _useState10[1];
|
|
150
|
+
var _useState11 = (0, _react.useState)(false),
|
|
151
|
+
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
152
|
+
isAutosuggestError = _useState12[0],
|
|
153
|
+
changeIsAutosuggestError = _useState12[1];
|
|
154
|
+
var _useState13 = (0, _react.useState)([]),
|
|
155
|
+
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
156
|
+
filteredSuggestions = _useState14[0],
|
|
157
|
+
changeFilteredSuggestions = _useState14[1];
|
|
158
|
+
var _useState15 = (0, _react.useState)(-1),
|
|
159
|
+
_useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
|
|
160
|
+
visualFocusIndex = _useState16[0],
|
|
161
|
+
changeVisualFocusIndex = _useState16[1];
|
|
205
162
|
var inputRef = (0, _react.useRef)(null);
|
|
163
|
+
var inputContainerRef = (0, _react.useRef)(null);
|
|
206
164
|
var actionRef = (0, _react.useRef)(null);
|
|
165
|
+
var width = useWidth(inputContainerRef.current);
|
|
207
166
|
var colorsTheme = (0, _useTheme["default"])();
|
|
208
|
-
var
|
|
209
|
-
var
|
|
210
|
-
var errorId = "error-".concat(inputId);
|
|
211
|
-
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
|
-
|
|
167
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
168
|
+
var numberInputContext = (0, _react.useContext)(_NumberInput.NumberInputContext);
|
|
238
169
|
var getNumberErrorMessage = function getNumberErrorMessage(value) {
|
|
239
|
-
if (
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
var hasSuggestions = function hasSuggestions() {
|
|
243
|
-
return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
|
|
170
|
+
if (value < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) return translatedLabels.numberInput.valueGreaterThanOrEqualToErrorMessage(numberInputContext.minNumber);else if (value > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) return translatedLabels.numberInput.valueLessThanOrEqualToErrorMessage(numberInputContext.maxNumber);
|
|
244
171
|
};
|
|
245
|
-
|
|
246
172
|
var openSuggestions = function openSuggestions() {
|
|
247
|
-
hasSuggestions() && changeIsOpen(true);
|
|
173
|
+
hasSuggestions(suggestions) && changeIsOpen(true);
|
|
248
174
|
};
|
|
249
|
-
|
|
250
175
|
var closeSuggestions = function closeSuggestions() {
|
|
251
|
-
|
|
252
|
-
|
|
176
|
+
if (hasSuggestions(suggestions)) {
|
|
177
|
+
changeIsOpen(false);
|
|
178
|
+
changeVisualFocusIndex(-1);
|
|
179
|
+
}
|
|
253
180
|
};
|
|
254
|
-
|
|
255
181
|
var changeValue = function changeValue(newValue) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
if (
|
|
259
|
-
value:
|
|
260
|
-
error:
|
|
261
|
-
});else if (isLengthIncorrect(
|
|
262
|
-
value:
|
|
263
|
-
error:
|
|
264
|
-
});else if (
|
|
265
|
-
value:
|
|
266
|
-
error:
|
|
267
|
-
});else if (
|
|
268
|
-
value:
|
|
269
|
-
error: getNumberErrorMessage(newValue)
|
|
182
|
+
var formattedValue = typeof newValue === "number" ? newValue.toString() : newValue;
|
|
183
|
+
value !== null && value !== void 0 ? value : setInnerValue(formattedValue);
|
|
184
|
+
if (isRequired(formattedValue, optional)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
185
|
+
value: formattedValue,
|
|
186
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
187
|
+
});else if (isLengthIncorrect(formattedValue, minLength, maxLength)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
188
|
+
value: formattedValue,
|
|
189
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
190
|
+
});else if (patternMismatch(pattern, formattedValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
191
|
+
value: formattedValue,
|
|
192
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
193
|
+
});else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && isNumberIncorrect(Number(newValue), numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
194
|
+
value: formattedValue,
|
|
195
|
+
error: getNumberErrorMessage(Number(newValue))
|
|
270
196
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
271
|
-
value:
|
|
197
|
+
value: formattedValue
|
|
272
198
|
});
|
|
273
199
|
};
|
|
274
|
-
|
|
275
200
|
var handleInputContainerOnClick = function handleInputContainerOnClick() {
|
|
276
201
|
document.activeElement !== actionRef.current && inputRef.current.focus();
|
|
277
202
|
};
|
|
278
|
-
|
|
279
203
|
var handleInputContainerOnMouseDown = function handleInputContainerOnMouseDown(event) {
|
|
280
204
|
// Avoid input to lose the focus when the container is pressed
|
|
281
205
|
document.activeElement === inputRef.current && event.preventDefault();
|
|
282
206
|
};
|
|
283
|
-
|
|
284
|
-
var handleIOnChange = function handleIOnChange(event) {
|
|
207
|
+
var handleInputOnChange = function handleInputOnChange(event) {
|
|
285
208
|
openSuggestions();
|
|
286
209
|
changeValue(event.target.value);
|
|
287
210
|
};
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
211
|
+
var handleInputOnBlur = function handleInputOnBlur(event) {
|
|
212
|
+
closeSuggestions();
|
|
213
|
+
if (isRequired(event.target.value, optional)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
292
214
|
value: event.target.value,
|
|
293
|
-
error:
|
|
294
|
-
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
215
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
216
|
+
});else if (isLengthIncorrect(event.target.value, minLength, maxLength)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
295
217
|
value: event.target.value,
|
|
296
|
-
error:
|
|
297
|
-
});else if (
|
|
218
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
219
|
+
});else if (patternMismatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
298
220
|
value: event.target.value,
|
|
299
|
-
error:
|
|
300
|
-
});else if (
|
|
221
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
222
|
+
});else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && isNumberIncorrect(Number(event.target.value), numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
301
223
|
value: event.target.value,
|
|
302
|
-
error: getNumberErrorMessage(event.target.value)
|
|
224
|
+
error: getNumberErrorMessage(Number(event.target.value))
|
|
303
225
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
304
226
|
value: event.target.value
|
|
305
227
|
});
|
|
306
228
|
};
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
case
|
|
311
|
-
|
|
312
|
-
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
313
|
-
decrementNumber();
|
|
314
|
-
event.preventDefault();
|
|
315
|
-
} else {
|
|
316
|
-
event.preventDefault();
|
|
229
|
+
var handleInputOnKeyDown = function handleInputOnKeyDown(event) {
|
|
230
|
+
switch (event.key) {
|
|
231
|
+
case "Down":
|
|
232
|
+
case "ArrowDown":
|
|
233
|
+
event.preventDefault();
|
|
234
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") decrementNumber();else {
|
|
317
235
|
openSuggestions();
|
|
318
|
-
|
|
319
236
|
if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
|
|
320
|
-
|
|
237
|
+
changeVisualFocusIndex(function (visualFocusedSuggIndex) {
|
|
321
238
|
if (visualFocusedSuggIndex < filteredSuggestions.length - 1) return visualFocusedSuggIndex + 1;else if (visualFocusedSuggIndex === filteredSuggestions.length - 1) return 0;
|
|
322
239
|
});
|
|
323
240
|
}
|
|
324
241
|
}
|
|
325
|
-
|
|
326
242
|
break;
|
|
327
|
-
|
|
328
|
-
case
|
|
329
|
-
|
|
330
|
-
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
331
|
-
incrementNumber();
|
|
332
|
-
event.preventDefault();
|
|
333
|
-
} else {
|
|
334
|
-
event.preventDefault();
|
|
243
|
+
case "Up":
|
|
244
|
+
case "ArrowUp":
|
|
245
|
+
event.preventDefault();
|
|
246
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") incrementNumber();else {
|
|
335
247
|
openSuggestions();
|
|
336
|
-
|
|
337
248
|
if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
|
|
338
|
-
|
|
249
|
+
changeVisualFocusIndex(function (visualFocusedSuggIndex) {
|
|
339
250
|
if (visualFocusedSuggIndex === 0 || visualFocusedSuggIndex === -1) return filteredSuggestions.length > 0 ? filteredSuggestions.length - 1 : suggestions.length - 1;else return visualFocusedSuggIndex - 1;
|
|
340
251
|
});
|
|
341
252
|
}
|
|
342
253
|
}
|
|
343
|
-
|
|
344
254
|
break;
|
|
345
|
-
|
|
346
|
-
case
|
|
347
|
-
// Esc
|
|
255
|
+
case "Esc":
|
|
256
|
+
case "Escape":
|
|
348
257
|
event.preventDefault();
|
|
349
|
-
|
|
350
|
-
if (hasSuggestions()) {
|
|
258
|
+
if (hasSuggestions(suggestions)) {
|
|
351
259
|
changeValue("");
|
|
352
260
|
isOpen && closeSuggestions();
|
|
353
261
|
}
|
|
354
|
-
|
|
355
262
|
break;
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusedSuggIndex >= 0 && visualFocusedSuggIndex < filteredSuggestions.length;
|
|
361
|
-
validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusedSuggIndex]);
|
|
263
|
+
case "Enter":
|
|
264
|
+
if (hasSuggestions(suggestions) && !isSearching) {
|
|
265
|
+
var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusIndex >= 0 && visualFocusIndex < filteredSuggestions.length;
|
|
266
|
+
validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusIndex]);
|
|
362
267
|
isOpen && closeSuggestions();
|
|
363
268
|
}
|
|
364
|
-
|
|
365
269
|
break;
|
|
366
270
|
}
|
|
367
271
|
};
|
|
368
|
-
|
|
369
272
|
var handleClearActionOnClick = function handleClearActionOnClick() {
|
|
370
273
|
changeValue("");
|
|
371
274
|
inputRef.current.focus();
|
|
372
275
|
suggestions && closeSuggestions();
|
|
373
276
|
};
|
|
374
|
-
|
|
375
277
|
var handleDecrementActionOnClick = function handleDecrementActionOnClick() {
|
|
376
278
|
decrementNumber();
|
|
377
279
|
inputRef.current.focus();
|
|
378
280
|
};
|
|
379
|
-
|
|
380
281
|
var handleIncrementActionOnClick = function handleIncrementActionOnClick() {
|
|
381
282
|
incrementNumber();
|
|
382
283
|
inputRef.current.focus();
|
|
383
284
|
};
|
|
384
|
-
|
|
385
285
|
var setNumberProps = function setNumberProps(type, min, max, step) {
|
|
386
|
-
var _inputRef$
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
step && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 ? void 0 : _inputRef$current6.setAttribute("step", step));
|
|
286
|
+
var _inputRef$current, _inputRef$current2, _inputRef$current3, _inputRef$current4;
|
|
287
|
+
min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.setAttribute("min", min));
|
|
288
|
+
max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.setAttribute("max", max));
|
|
289
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("step", step);
|
|
290
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("type", type);
|
|
392
291
|
};
|
|
393
|
-
|
|
394
292
|
var decrementNumber = function decrementNumber() {
|
|
395
|
-
var
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
|
|
401
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && (parseInt(numberValue) === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || numberValue === "" || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber))) {
|
|
402
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);
|
|
403
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) >= (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue !== "") {
|
|
404
|
-
changeValue(parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
405
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue == "") {
|
|
406
|
-
changeValue(-(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
407
|
-
} else if (numberValue === "") {
|
|
408
|
-
changeValue(-1);
|
|
293
|
+
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
294
|
+
var numberValue = Number(currentValue);
|
|
295
|
+
var steppedValue = Math.round((numberValue - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
296
|
+
if (currentValue !== "") {
|
|
297
|
+
if (numberValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || steppedValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberValue);else if (numberValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else if (numberValue === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else changeValue(steppedValue);
|
|
409
298
|
} else {
|
|
410
|
-
changeValue(
|
|
299
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) >= 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) < 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(-numberInputContext.stepNumber);
|
|
411
300
|
}
|
|
412
301
|
};
|
|
413
|
-
|
|
414
302
|
var incrementNumber = function incrementNumber() {
|
|
415
|
-
var
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);
|
|
421
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && (parseInt(numberValue) === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber))) {
|
|
422
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
|
|
423
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) <= (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue !== "") {
|
|
424
|
-
changeValue(parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
425
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue == "") {
|
|
426
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber);
|
|
427
|
-
} else if (numberValue === "") {
|
|
428
|
-
changeValue(1);
|
|
303
|
+
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
304
|
+
var numberValue = Number(currentValue);
|
|
305
|
+
var steppedValue = Math.round((numberValue + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
306
|
+
if (currentValue !== "") {
|
|
307
|
+
if (numberValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || steppedValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberValue);else if (numberValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if (numberValue === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(steppedValue);
|
|
429
308
|
} else {
|
|
430
|
-
changeValue(
|
|
309
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) > 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) <= 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(numberInputContext.stepNumber);
|
|
431
310
|
}
|
|
432
311
|
};
|
|
433
|
-
|
|
434
|
-
(0, _react.useLayoutEffect)(function () {
|
|
435
|
-
var _suggestionsRef$curre, _visualFocusedOptionE;
|
|
436
|
-
|
|
437
|
-
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];
|
|
438
|
-
visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : (_visualFocusedOptionE = visualFocusedOptionEl.scrollIntoView) === null || _visualFocusedOptionE === void 0 ? void 0 : _visualFocusedOptionE.call(visualFocusedOptionEl, {
|
|
439
|
-
block: "nearest",
|
|
440
|
-
inline: "start"
|
|
441
|
-
});
|
|
442
|
-
}, [visualFocusedSuggIndex]);
|
|
443
312
|
(0, _react.useEffect)(function () {
|
|
444
313
|
if (typeof suggestions === "function") {
|
|
445
314
|
changeIsSearching(true);
|
|
@@ -463,182 +332,153 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
463
332
|
changeFilteredSuggestions(suggestions.filter(function (suggestion) {
|
|
464
333
|
return suggestion.toUpperCase().startsWith((value !== null && value !== void 0 ? value : innerValue).toUpperCase());
|
|
465
334
|
}));
|
|
466
|
-
|
|
335
|
+
changeVisualFocusIndex(-1);
|
|
467
336
|
}
|
|
468
|
-
|
|
469
|
-
(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
337
|
+
numberInputContext != null && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
470
338
|
}, [value, innerValue, suggestions, numberInputContext]);
|
|
471
|
-
|
|
472
|
-
var HighlightedSuggestion = function HighlightedSuggestion(_ref2) {
|
|
473
|
-
var suggestion = _ref2.suggestion,
|
|
474
|
-
index = _ref2.index;
|
|
475
|
-
var regEx = new RegExp(value !== null && value !== void 0 ? value : innerValue, "i");
|
|
476
|
-
var matchedWords = suggestion.match(regEx);
|
|
477
|
-
var noMatchedWords = suggestion.replace(regEx, "");
|
|
478
|
-
var isLastOption = index === lastOptionIndex;
|
|
479
|
-
return /*#__PURE__*/_react["default"].createElement(Suggestion, {
|
|
480
|
-
id: "suggestion-".concat(index),
|
|
481
|
-
onClick: function onClick() {
|
|
482
|
-
changeValue(suggestion);
|
|
483
|
-
closeSuggestions();
|
|
484
|
-
},
|
|
485
|
-
visualFocused: visualFocusedSuggIndex === index,
|
|
486
|
-
role: "option",
|
|
487
|
-
"aria-selected": visualFocusedSuggIndex === index && "true"
|
|
488
|
-
}, /*#__PURE__*/_react["default"].createElement(StyledSuggestion, {
|
|
489
|
-
last: isLastOption,
|
|
490
|
-
visualFocused: visualFocusedSuggIndex === index
|
|
491
|
-
}, typeof suggestions === "function" ? suggestion : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedWords), noMatchedWords)));
|
|
492
|
-
};
|
|
493
|
-
|
|
494
339
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
495
340
|
theme: colorsTheme.textInput
|
|
496
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
341
|
+
}, /*#__PURE__*/_react["default"].createElement(TextInputContainer, {
|
|
497
342
|
margin: margin,
|
|
498
|
-
|
|
499
|
-
|
|
343
|
+
size: size,
|
|
344
|
+
ref: ref
|
|
500
345
|
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
501
346
|
htmlFor: inputId,
|
|
502
347
|
disabled: disabled,
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
348
|
+
hasHelperText: helperText ? true : false
|
|
349
|
+
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
350
|
+
disabled: disabled
|
|
351
|
+
}, helperText), /*#__PURE__*/_react["default"].createElement(AutosuggestWrapper, {
|
|
352
|
+
condition: hasSuggestions(suggestions),
|
|
353
|
+
wrapper: function wrapper(children) {
|
|
354
|
+
return /*#__PURE__*/_react["default"].createElement(Popover.Root, {
|
|
355
|
+
open: isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError)
|
|
356
|
+
}, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
|
|
357
|
+
asChild: true,
|
|
358
|
+
"aria-controls": undefined
|
|
359
|
+
}, children), /*#__PURE__*/_react["default"].createElement(Popover.Portal, null, /*#__PURE__*/_react["default"].createElement(Popover.Content, {
|
|
360
|
+
sideOffset: 5,
|
|
361
|
+
style: {
|
|
362
|
+
zIndex: "2147483647"
|
|
363
|
+
},
|
|
364
|
+
onOpenAutoFocus: function onOpenAutoFocus(event) {
|
|
365
|
+
// Avoid select to lose focus when the list is opened
|
|
366
|
+
event.preventDefault();
|
|
367
|
+
},
|
|
368
|
+
onCloseAutoFocus: function onCloseAutoFocus(event) {
|
|
369
|
+
// Avoid select to lose focus when the list is closed
|
|
370
|
+
event.preventDefault();
|
|
371
|
+
}
|
|
372
|
+
}, /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
|
|
373
|
+
id: autosuggestId,
|
|
374
|
+
value: value !== null && value !== void 0 ? value : innerValue,
|
|
375
|
+
suggestions: filteredSuggestions,
|
|
376
|
+
visualFocusIndex: visualFocusIndex,
|
|
377
|
+
highlightedSuggestions: typeof suggestions !== "function",
|
|
378
|
+
searchHasErrors: isAutosuggestError,
|
|
379
|
+
isSearching: isSearching,
|
|
380
|
+
suggestionOnClick: function suggestionOnClick(suggestion) {
|
|
381
|
+
changeValue(suggestion);
|
|
382
|
+
closeSuggestions();
|
|
383
|
+
},
|
|
384
|
+
styles: {
|
|
385
|
+
width: width
|
|
386
|
+
}
|
|
387
|
+
}))));
|
|
388
|
+
}
|
|
389
|
+
}, /*#__PURE__*/_react["default"].createElement(InputContainer, {
|
|
390
|
+
error: error ? true : false,
|
|
510
391
|
disabled: disabled,
|
|
511
|
-
|
|
392
|
+
readOnly: readOnly,
|
|
512
393
|
onClick: handleInputContainerOnClick,
|
|
513
|
-
onMouseDown: handleInputContainerOnMouseDown
|
|
394
|
+
onMouseDown: handleInputContainerOnMouseDown,
|
|
395
|
+
ref: inputContainerRef
|
|
514
396
|
}, prefix && /*#__PURE__*/_react["default"].createElement(Prefix, {
|
|
515
|
-
disabled: disabled
|
|
516
|
-
backgroundType: backgroundType
|
|
397
|
+
disabled: disabled
|
|
517
398
|
}, prefix), /*#__PURE__*/_react["default"].createElement(Input, {
|
|
518
399
|
id: inputId,
|
|
519
400
|
name: name,
|
|
520
401
|
value: value !== null && value !== void 0 ? value : innerValue,
|
|
521
402
|
placeholder: placeholder,
|
|
522
|
-
onBlur:
|
|
523
|
-
onChange:
|
|
524
|
-
onFocus:
|
|
525
|
-
|
|
526
|
-
},
|
|
527
|
-
onKeyDown: handleIOnKeyDown,
|
|
403
|
+
onBlur: handleInputOnBlur,
|
|
404
|
+
onChange: handleInputOnChange,
|
|
405
|
+
onFocus: !readOnly ? openSuggestions : undefined,
|
|
406
|
+
onKeyDown: !readOnly ? handleInputOnKeyDown : undefined,
|
|
528
407
|
onMouseDown: function onMouseDown(event) {
|
|
529
408
|
event.stopPropagation();
|
|
530
409
|
},
|
|
531
410
|
disabled: disabled,
|
|
411
|
+
readOnly: readOnly,
|
|
532
412
|
ref: inputRef,
|
|
533
|
-
backgroundType: backgroundType,
|
|
534
413
|
pattern: pattern,
|
|
535
414
|
minLength: minLength,
|
|
536
415
|
maxLength: maxLength,
|
|
537
|
-
autoComplete: autocomplete,
|
|
416
|
+
autoComplete: autocomplete === "off" ? "nope" : autocomplete,
|
|
538
417
|
tabIndex: tabIndex,
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
"aria-
|
|
542
|
-
"aria-
|
|
543
|
-
"aria-expanded":
|
|
544
|
-
"aria-
|
|
545
|
-
"aria-
|
|
418
|
+
type: "text",
|
|
419
|
+
role: hasSuggestions(suggestions) ? "combobox" : undefined,
|
|
420
|
+
"aria-autocomplete": hasSuggestions(suggestions) ? "list" : undefined,
|
|
421
|
+
"aria-controls": hasSuggestions(suggestions) ? autosuggestId : undefined,
|
|
422
|
+
"aria-expanded": hasSuggestions(suggestions) ? isOpen : undefined,
|
|
423
|
+
"aria-haspopup": hasSuggestions(suggestions) ? "listbox" : undefined,
|
|
424
|
+
"aria-activedescendant": hasSuggestions(suggestions) && isOpen && visualFocusIndex !== -1 ? "suggestion-".concat(visualFocusIndex) : undefined,
|
|
425
|
+
"aria-invalid": error ? true : false,
|
|
546
426
|
"aria-errormessage": error ? errorId : undefined,
|
|
547
|
-
"aria-required":
|
|
427
|
+
"aria-required": !disabled && !optional
|
|
548
428
|
}), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
|
|
549
|
-
backgroundType: backgroundType,
|
|
550
429
|
"aria-label": "Error"
|
|
551
|
-
},
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
},
|
|
430
|
+
}, _Icons["default"].error), !disabled && !readOnly && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
431
|
+
"aria-label": translatedLabels.textInput.clearFieldActionTitle,
|
|
432
|
+
onClick: handleClearActionOnClick,
|
|
555
433
|
onMouseDown: function onMouseDown(event) {
|
|
556
434
|
event.stopPropagation();
|
|
557
435
|
},
|
|
558
|
-
backgroundType: backgroundType,
|
|
559
436
|
tabIndex: tabIndex,
|
|
560
|
-
title:
|
|
561
|
-
|
|
562
|
-
},
|
|
563
|
-
|
|
437
|
+
title: translatedLabels.textInput.clearFieldActionTitle,
|
|
438
|
+
type: "button"
|
|
439
|
+
}, _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, {
|
|
440
|
+
"aria-label": translatedLabels.numberInput.decrementValueTitle,
|
|
564
441
|
disabled: disabled,
|
|
565
|
-
onClick:
|
|
566
|
-
return handleDecrementActionOnClick();
|
|
567
|
-
},
|
|
442
|
+
onClick: !readOnly ? handleDecrementActionOnClick : undefined,
|
|
568
443
|
onMouseDown: function onMouseDown(event) {
|
|
569
444
|
event.stopPropagation();
|
|
570
445
|
},
|
|
571
|
-
backgroundType: backgroundType,
|
|
572
|
-
tabIndex: tabIndex,
|
|
573
|
-
title: "Decrement value",
|
|
574
|
-
"aria-label": "Decrement value"
|
|
575
|
-
}, textInputIcons.decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
576
446
|
ref: actionRef,
|
|
447
|
+
tabIndex: tabIndex,
|
|
448
|
+
title: translatedLabels.numberInput.decrementValueTitle,
|
|
449
|
+
type: "button"
|
|
450
|
+
}, _Icons["default"].decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
451
|
+
"aria-label": translatedLabels.numberInput.incrementValueTitle,
|
|
577
452
|
disabled: disabled,
|
|
578
|
-
onClick:
|
|
579
|
-
return handleIncrementActionOnClick();
|
|
580
|
-
},
|
|
453
|
+
onClick: !readOnly ? handleIncrementActionOnClick : undefined,
|
|
581
454
|
onMouseDown: function onMouseDown(event) {
|
|
582
455
|
event.stopPropagation();
|
|
583
456
|
},
|
|
584
|
-
backgroundType: backgroundType,
|
|
585
|
-
tabIndex: tabIndex,
|
|
586
|
-
title: "Increment value",
|
|
587
|
-
"aria-label": "Increment value"
|
|
588
|
-
}, textInputIcons.increment)) : action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
589
457
|
ref: actionRef,
|
|
458
|
+
tabIndex: tabIndex,
|
|
459
|
+
title: translatedLabels.numberInput.incrementValueTitle,
|
|
460
|
+
type: "button"
|
|
461
|
+
}, _Icons["default"].increment)), action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
462
|
+
"aria-label": action.title,
|
|
590
463
|
disabled: disabled,
|
|
591
|
-
onClick:
|
|
592
|
-
return action.onClick();
|
|
593
|
-
},
|
|
464
|
+
onClick: !readOnly ? action.onClick : undefined,
|
|
594
465
|
onMouseDown: function onMouseDown(event) {
|
|
595
466
|
event.stopPropagation();
|
|
596
467
|
},
|
|
468
|
+
ref: actionRef,
|
|
469
|
+
tabIndex: tabIndex,
|
|
597
470
|
title: action.title,
|
|
598
|
-
"
|
|
599
|
-
|
|
600
|
-
tabIndex: tabIndex
|
|
601
|
-
}, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement(ActionIcon, {
|
|
471
|
+
type: "button"
|
|
472
|
+
}, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
602
473
|
src: action.icon
|
|
603
474
|
}) : action.icon), suffix && /*#__PURE__*/_react["default"].createElement(Suffix, {
|
|
604
|
-
disabled: disabled
|
|
605
|
-
|
|
606
|
-
}, suffix), isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError) && /*#__PURE__*/_react["default"].createElement(Suggestions, {
|
|
607
|
-
id: autosuggestId,
|
|
608
|
-
isError: isAutosuggestError,
|
|
609
|
-
onMouseDown: function onMouseDown(event) {
|
|
610
|
-
event.preventDefault();
|
|
611
|
-
},
|
|
612
|
-
ref: suggestionsRef,
|
|
613
|
-
role: "listbox",
|
|
614
|
-
"aria-label": label
|
|
615
|
-
}, !isSearching && !isAutosuggestError && filteredSuggestions.length > 0 && filteredSuggestions.map(function (suggestion, index) {
|
|
616
|
-
return /*#__PURE__*/_react["default"].createElement(HighlightedSuggestion, {
|
|
617
|
-
key: "suggestion-".concat((0, _uuid.v4)()),
|
|
618
|
-
suggestion: suggestion,
|
|
619
|
-
index: index
|
|
620
|
-
});
|
|
621
|
-
}), isSearching && /*#__PURE__*/_react["default"].createElement(SuggestionsSystemMessage, null, "Searching..."), isAutosuggestError && /*#__PURE__*/_react["default"].createElement(SuggestionsError, null, /*#__PURE__*/_react["default"].createElement(SuggestionsErrorIcon, {
|
|
622
|
-
backgroundType: backgroundType
|
|
623
|
-
}, textInputIcons.error), "Error fetching data"))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
475
|
+
disabled: disabled
|
|
476
|
+
}, suffix))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
624
477
|
id: errorId,
|
|
625
|
-
backgroundType: backgroundType,
|
|
626
478
|
"aria-live": error ? "assertive" : "off"
|
|
627
479
|
}, error)));
|
|
628
480
|
});
|
|
629
|
-
|
|
630
|
-
var sizes = {
|
|
631
|
-
small: "240px",
|
|
632
|
-
medium: "360px",
|
|
633
|
-
large: "480px",
|
|
634
|
-
fillParent: "100%"
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
var calculateWidth = function calculateWidth(margin, size) {
|
|
638
|
-
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
639
|
-
};
|
|
640
|
-
|
|
641
|
-
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) {
|
|
481
|
+
var TextInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
642
482
|
return calculateWidth(props.margin, props.size);
|
|
643
483
|
}, function (props) {
|
|
644
484
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -651,9 +491,8 @@ var DxcInput = _styledComponents["default"].div(_templateObject || (_templateObj
|
|
|
651
491
|
}, function (props) {
|
|
652
492
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
653
493
|
});
|
|
654
|
-
|
|
655
494
|
var Label = _styledComponents["default"].label(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n ", "\n"])), function (props) {
|
|
656
|
-
return props.disabled ? props.
|
|
495
|
+
return props.disabled ? props.theme.disabledLabelFontColor : props.theme.labelFontColor;
|
|
657
496
|
}, function (props) {
|
|
658
497
|
return props.theme.fontFamily;
|
|
659
498
|
}, function (props) {
|
|
@@ -665,15 +504,13 @@ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObj
|
|
|
665
504
|
}, function (props) {
|
|
666
505
|
return props.theme.labelLineHeight;
|
|
667
506
|
}, function (props) {
|
|
668
|
-
return !props.
|
|
507
|
+
return !props.hasHelperText && "margin-bottom: 0.25rem";
|
|
669
508
|
});
|
|
670
|
-
|
|
671
509
|
var OptionalLabel = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: ", ";\n"])), function (props) {
|
|
672
510
|
return props.theme.optionalLabelFontWeight;
|
|
673
511
|
});
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledHelperTextFontColorOnDark : props.theme.disabledHelperTextFontColor : props.backgroundType === "dark" ? props.theme.helperTextFontColorOnDark : props.theme.helperTextFontColor;
|
|
512
|
+
var HelperText = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n margin-bottom: 0.25rem;\n"])), function (props) {
|
|
513
|
+
return props.disabled ? props.theme.disabledHelperTextFontColor : props.theme.helperTextFontColor;
|
|
677
514
|
}, function (props) {
|
|
678
515
|
return props.theme.fontFamily;
|
|
679
516
|
}, function (props) {
|
|
@@ -685,21 +522,17 @@ var HelperText = _styledComponents["default"].span(_templateObject4 || (_templat
|
|
|
685
522
|
}, function (props) {
|
|
686
523
|
return props.theme.helperTextLineHeight;
|
|
687
524
|
});
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
if (props.disabled) return props.backgroundType === "dark" ? "background-color: ".concat(props.theme.disabledContainerFillColorOnDark, ";") : "background-color: ".concat(props.theme.disabledContainerFillColor, ";");
|
|
525
|
+
var InputContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n position: relative;\n display: flex;\n align-items: center;\n height: calc(2.5rem - 2px);\n padding: 0 0.5rem;\n\n ", "\n box-shadow: 0 0 0 2px transparent;\n border-radius: 4px;\n border: 1px solid\n ", ";\n ", "\n\n ", ";\n"])), function (props) {
|
|
526
|
+
if (props.disabled) return "background-color: ".concat(props.theme.disabledContainerFillColor, ";");
|
|
691
527
|
}, function (props) {
|
|
692
|
-
if (props.disabled) return props.
|
|
528
|
+
if (props.disabled) return props.theme.disabledBorderColor;else if (props.readOnly) return props.theme.readOnlyBorderColor;else return props.theme.enabledBorderColor;
|
|
693
529
|
}, function (props) {
|
|
694
|
-
return props.error && !props.disabled && "border-color: transparent;\n box-shadow: 0 0 0 2px ".concat(props.
|
|
530
|
+
return props.error && !props.disabled && "border-color: transparent;\n box-shadow: 0 0 0 2px ".concat(props.theme.errorBorderColor, ";\n ");
|
|
695
531
|
}, function (props) {
|
|
696
|
-
return props.disabled
|
|
697
|
-
}, function (props) {
|
|
698
|
-
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 ");
|
|
532
|
+
return !props.disabled ? "\n &:hover {\n border-color: ".concat(props.error ? "transparent" : props.readOnly ? props.theme.hoverReadOnlyBorderColor : props.theme.hoverBorderColor, ";\n ").concat(props.error ? "box-shadow: 0 0 0 2px ".concat(props.theme.hoverErrorBorderColor, ";") : "", "\n }\n &:focus-within {\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(props.theme.focusBorderColor, ";\n }\n ") : "cursor: not-allowed;";
|
|
699
533
|
});
|
|
700
|
-
|
|
701
534
|
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) {
|
|
702
|
-
return props.disabled ? props.
|
|
535
|
+
return props.disabled ? props.theme.disabledValueFontColor : props.theme.valueFontColor;
|
|
703
536
|
}, function (props) {
|
|
704
537
|
return props.theme.fontFamily;
|
|
705
538
|
}, function (props) {
|
|
@@ -711,86 +544,35 @@ var Input = _styledComponents["default"].input(_templateObject6 || (_templateObj
|
|
|
711
544
|
}, function (props) {
|
|
712
545
|
return props.disabled && "cursor: not-allowed;";
|
|
713
546
|
}, function (props) {
|
|
714
|
-
return props.disabled ? props.
|
|
547
|
+
return props.disabled ? props.theme.disabledPlaceholderFontColor : props.theme.placeholderFontColor;
|
|
715
548
|
});
|
|
716
|
-
|
|
717
|
-
var ActionIcon = _styledComponents["default"].img(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n width: 16px;\n height: 16px;\n"])));
|
|
718
|
-
|
|
719
|
-
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) {
|
|
720
|
-
return props.theme.fontFamily;
|
|
721
|
-
}, function (props) {
|
|
549
|
+
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 color: ", ";\n\n ", "\n\n img, svg {\n width: 16px;\n height: 16px;\n }\n"])), function (props) {
|
|
722
550
|
return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
|
|
723
551
|
}, function (props) {
|
|
724
|
-
return props.disabled ? props.
|
|
552
|
+
return props.disabled ? props.theme.disabledActionBackgroundColor : props.theme.actionBackgroundColor;
|
|
725
553
|
}, function (props) {
|
|
726
|
-
return props.disabled ? props.
|
|
554
|
+
return props.disabled ? props.theme.disabledActionIconColor : props.theme.actionIconColor;
|
|
727
555
|
}, function (props) {
|
|
728
|
-
return !props.disabled && "\n &:focus
|
|
556
|
+
return !props.disabled && "\n &:focus, \n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ".concat(props.theme.focusActionBorderColor, ";\n color: ").concat(props.theme.focusActionIconColor, ";\n }\n &:hover {\n background-color: ").concat(props.theme.hoverActionBackgroundColor, ";\n color: ").concat(props.theme.hoverActionIconColor, ";\n }\n &:active {\n background-color: ").concat(props.theme.activeActionBackgroundColor, ";\n color: ").concat(props.theme.activeActionIconColor, ";\n }\n ");
|
|
729
557
|
});
|
|
730
|
-
|
|
731
|
-
var
|
|
732
|
-
var color = props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPrefixColorOnDark : props.theme.disabledPrefixColor : props.backgroundType === "dark" ? props.theme.prefixColorOnDark : props.theme.prefixColor;
|
|
558
|
+
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) {
|
|
559
|
+
var color = props.disabled ? props.theme.disabledPrefixColor : props.theme.prefixColor;
|
|
733
560
|
return "color: ".concat(color, "; border-right: 1px solid ").concat(color, ";");
|
|
734
561
|
}, function (props) {
|
|
735
562
|
return props.theme.fontFamily;
|
|
736
563
|
});
|
|
737
|
-
|
|
738
|
-
var
|
|
739
|
-
var color = props.disabled ? props.backgroundType === "dark" ? props.theme.disabledSuffixColorOnDark : props.theme.disabledSuffixColor : props.backgroundType === "dark" ? props.theme.suffixColorOnDark : props.theme.suffixColor;
|
|
564
|
+
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) {
|
|
565
|
+
var color = props.disabled ? props.theme.disabledSuffixColor : props.theme.suffixColor;
|
|
740
566
|
return "color: ".concat(color, "; border-left: 1px solid ").concat(color, ";");
|
|
741
567
|
}, function (props) {
|
|
742
568
|
return props.theme.fontFamily;
|
|
743
569
|
});
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
570
|
+
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) {
|
|
571
|
+
return props.theme.errorIconColor;
|
|
747
572
|
});
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
return props.backgroundType === "dark" ? props.theme.errorMessageColorOnDark : props.theme.errorMessageColor;
|
|
573
|
+
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) {
|
|
574
|
+
return props.theme.errorMessageColor;
|
|
751
575
|
}, function (props) {
|
|
752
576
|
return props.theme.fontFamily;
|
|
753
577
|
});
|
|
754
|
-
|
|
755
|
-
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) {
|
|
756
|
-
return props.isError ? props.theme.errorListDialogBackgroundColor : props.theme.listDialogBackgroundColor;
|
|
757
|
-
}, function (props) {
|
|
758
|
-
return props.isError ? props.theme.errorListDialogBorderColor : props.theme.listDialogBorderColor;
|
|
759
|
-
}, function (props) {
|
|
760
|
-
return props.theme.listOptionFontColor;
|
|
761
|
-
}, function (props) {
|
|
762
|
-
return props.theme.fontFamily;
|
|
763
|
-
}, function (props) {
|
|
764
|
-
return props.theme.listOptionFontSize;
|
|
765
|
-
}, function (props) {
|
|
766
|
-
return props.theme.listOptionFontStyle;
|
|
767
|
-
}, function (props) {
|
|
768
|
-
return props.theme.listOptionFontWeight;
|
|
769
|
-
});
|
|
770
|
-
|
|
771
|
-
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) {
|
|
772
|
-
return props.visualFocused ? props.theme.focusListOptionBorderColor : "transparent";
|
|
773
|
-
}, function (props) {
|
|
774
|
-
return props.theme.hoverListOptionBackgroundColor;
|
|
775
|
-
}, function (props) {
|
|
776
|
-
return props.theme.activeListOptionBackgroundColor;
|
|
777
|
-
});
|
|
778
|
-
|
|
779
|
-
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) {
|
|
780
|
-
return props.last || props.visualFocused ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
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) {
|
|
784
|
-
return props.theme.systemMessageFontColor;
|
|
785
|
-
});
|
|
786
|
-
|
|
787
|
-
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) {
|
|
788
|
-
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
789
|
-
});
|
|
790
|
-
|
|
791
|
-
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) {
|
|
792
|
-
return props.theme.errorListDialogFontColor;
|
|
793
|
-
});
|
|
794
|
-
|
|
795
|
-
var _default = DxcTextInput;
|
|
796
|
-
exports["default"] = _default;
|
|
578
|
+
var _default = exports["default"] = DxcTextInput;
|