@dxc-technology/halstack-react 0.0.0-7550efd → 0.0.0-757bc34
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 +3 -3
- package/BackgroundColorContext.js +6 -18
- package/HalstackContext.d.ts +1347 -6
- package/HalstackContext.js +125 -110
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +116 -157
- package/accordion/Accordion.stories.tsx +101 -125
- 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 +30 -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 +19 -55
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +29 -46
- package/alert/types.d.ts +5 -5
- package/badge/Badge.js +4 -17
- package/badge/types.d.ts +1 -1
- package/bleed/Bleed.js +13 -21
- package/bleed/Bleed.stories.tsx +1 -0
- package/bleed/types.d.ts +2 -2
- package/box/Box.d.ts +1 -1
- package/box/Box.js +18 -56
- 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.js +11 -35
- package/bulleted-list/BulletedList.stories.tsx +8 -92
- package/bulleted-list/types.d.ts +32 -5
- package/button/Button.d.ts +1 -1
- package/button/Button.js +65 -100
- package/button/Button.stories.tsx +152 -91
- package/button/Button.test.js +18 -17
- package/button/types.d.ts +8 -4
- package/card/Card.d.ts +1 -1
- package/card/Card.js +48 -89
- 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 +141 -178
- 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 +1499 -0
- package/common/variables.js +1008 -1145
- package/container/Container.d.ts +4 -0
- package/container/Container.js +198 -0
- package/container/Container.stories.tsx +229 -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 +150 -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 +61 -116
- package/dialog/Dialog.stories.tsx +320 -166
- package/dialog/Dialog.test.js +269 -32
- package/dialog/types.d.ts +18 -25
- package/dropdown/Dropdown.js +72 -125
- package/dropdown/Dropdown.stories.tsx +210 -84
- package/dropdown/Dropdown.test.js +410 -402
- package/dropdown/DropdownMenu.js +20 -37
- package/dropdown/DropdownMenuItem.js +10 -35
- package/dropdown/types.d.ts +17 -19
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +241 -355
- 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 +45 -96
- package/file-input/types.d.ts +25 -8
- package/flex/Flex.d.ts +1 -1
- package/flex/Flex.js +40 -40
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +84 -8
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +53 -104
- 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 +2 -7
- 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 +41 -116
- 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 +2 -7
- 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 +13 -21
- package/inset/Inset.stories.tsx +2 -1
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +5 -5
- package/layout/ApplicationLayout.js +29 -66
- package/layout/ApplicationLayout.stories.tsx +1 -1
- package/layout/Icons.d.ts +8 -5
- package/layout/Icons.js +51 -59
- package/layout/SidenavContext.d.ts +1 -1
- package/layout/SidenavContext.js +3 -9
- package/layout/types.d.ts +5 -6
- package/link/Link.js +25 -46
- package/link/Link.stories.tsx +60 -0
- package/link/Link.test.js +24 -44
- package/link/types.d.ts +14 -14
- package/main.d.ts +6 -3
- package/main.js +25 -51
- package/{tabs-nav → nav-tabs}/NavTabs.d.ts +2 -2
- package/{tabs-nav → nav-tabs}/NavTabs.js +17 -52
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +111 -7
- package/{tabs-nav → nav-tabs}/NavTabs.test.js +37 -44
- package/nav-tabs/Tab.js +117 -0
- package/{tabs-nav → nav-tabs}/types.d.ts +14 -15
- package/nav-tabs/types.js +5 -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 +11 -5
- package/package.json +37 -40
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +21 -47
- package/paginator/Paginator.js +22 -55
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +253 -226
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +6 -17
- package/paragraph/Paragraph.stories.tsx +0 -17
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +35 -0
- package/password-input/PasswordInput.js +57 -126
- package/password-input/PasswordInput.stories.tsx +1 -32
- package/password-input/PasswordInput.test.js +160 -142
- package/password-input/types.d.ts +8 -7
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +21 -47
- package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +36 -3
- package/progress-bar/ProgressBar.test.js +36 -53
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.js +15 -39
- package/quick-nav/QuickNav.stories.tsx +112 -20
- 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 +59 -105
- 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 +101 -144
- 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 +17 -73
- package/select/Option.js +20 -50
- package/select/Select.js +95 -156
- package/select/Select.stories.tsx +497 -153
- package/select/Select.test.js +1934 -1775
- package/select/types.d.ts +16 -17
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +47 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +80 -149
- package/sidenav/Sidenav.stories.tsx +165 -63
- package/sidenav/Sidenav.test.js +3 -10
- package/sidenav/types.d.ts +31 -28
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +57 -96
- package/slider/Slider.test.js +108 -104
- package/slider/types.d.ts +7 -3
- package/spinner/Spinner.js +27 -63
- 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 +3 -3
- package/switch/Switch.js +112 -144
- package/switch/Switch.stories.tsx +33 -34
- package/switch/Switch.test.js +70 -102
- package/switch/types.d.ts +8 -3
- package/table/Table.js +7 -26
- 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.js +22 -44
- package/tabs/Tabs.js +59 -141
- package/tabs/Tabs.stories.tsx +45 -5
- package/tabs/Tabs.test.js +66 -123
- package/tabs/types.d.ts +19 -19
- 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.js +40 -28
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +89 -0
- package/text-input/TextInput.js +272 -441
- package/text-input/TextInput.stories.tsx +266 -274
- package/text-input/TextInput.test.js +1402 -1375
- package/text-input/types.d.ts +43 -16
- package/textarea/Textarea.js +63 -100
- package/textarea/Textarea.stories.tsx +175 -0
- package/textarea/Textarea.test.js +152 -183
- package/textarea/types.d.ts +9 -5
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +95 -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 +2 -2
- package/typography/Typography.js +15 -123
- package/typography/Typography.stories.tsx +1 -1
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +1251 -1
- package/useTheme.js +2 -9
- package/useTranslatedLabels.d.ts +84 -1
- package/useTranslatedLabels.js +1 -7
- 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 +16 -51
- package/wizard/Wizard.stories.tsx +20 -0
- package/wizard/Wizard.test.js +54 -81
- package/wizard/types.d.ts +8 -9
- package/card/ice-cream.jpg +0 -0
- package/common/RequiredComponent.js +0 -32
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/resultsetTable/ResultsetTable.js +0 -254
- package/slider/Slider.stories.tsx +0 -183
- package/tabs-nav/Tab.js +0 -130
- package/textarea/Textarea.stories.jsx +0 -157
- /package/{resultsetTable → container}/types.js +0 -0
- /package/{tabs-nav → grid}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → image/types.js} +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
- /package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +0 -0
package/text-input/TextInput.js
CHANGED
|
@@ -1,94 +1,44 @@
|
|
|
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
15
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
25
|
-
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
var _utils = require("../common/utils.js");
|
|
29
|
-
|
|
30
|
-
var _uuid = require("uuid");
|
|
31
|
-
|
|
16
|
+
var _variables = require("../common/variables");
|
|
17
|
+
var _utils = require("../common/utils");
|
|
32
18
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
56
|
-
width: "24",
|
|
57
|
-
height: "24",
|
|
58
|
-
viewBox: "0 0 24 24",
|
|
59
|
-
fill: "currentColor"
|
|
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
|
-
}))
|
|
19
|
+
var _NumberInput = require("../number-input/NumberInput");
|
|
20
|
+
var _Suggestions = _interopRequireDefault(require("./Suggestions"));
|
|
21
|
+
var Popover = _interopRequireWildcard(require("@radix-ui/react-popover"));
|
|
22
|
+
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
23
|
+
var _uuid = require("uuid");
|
|
24
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
25
|
+
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); }
|
|
26
|
+
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; }
|
|
27
|
+
var sizes = {
|
|
28
|
+
small: "240px",
|
|
29
|
+
medium: "360px",
|
|
30
|
+
large: "480px",
|
|
31
|
+
fillParent: "100%"
|
|
32
|
+
};
|
|
33
|
+
var AutosuggestWrapper = function AutosuggestWrapper(_ref) {
|
|
34
|
+
var condition = _ref.condition,
|
|
35
|
+
wrapper = _ref.wrapper,
|
|
36
|
+
children = _ref.children;
|
|
37
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, condition ? wrapper(children) : children);
|
|
38
|
+
};
|
|
39
|
+
var calculateWidth = function calculateWidth(margin, size) {
|
|
40
|
+
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
90
41
|
};
|
|
91
|
-
|
|
92
42
|
var makeCancelable = function makeCancelable(promise) {
|
|
93
43
|
var hasCanceled_ = false;
|
|
94
44
|
var wrappedPromise = new Promise(function (resolve, reject) {
|
|
@@ -109,329 +59,258 @@ var makeCancelable = function makeCancelable(promise) {
|
|
|
109
59
|
}
|
|
110
60
|
};
|
|
111
61
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return new RegExp(pattern).test(value);
|
|
62
|
+
var hasSuggestions = function hasSuggestions(suggestions) {
|
|
63
|
+
return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
|
|
115
64
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
var last = 0;
|
|
119
|
-
|
|
120
|
-
var reducer = function reducer(acc, current) {
|
|
121
|
-
var _current$options;
|
|
122
|
-
|
|
123
|
-
return acc + ((_current$options = current.options) === null || _current$options === void 0 ? void 0 : _current$options.length);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
if (filteredSuggestions.length > 0) filteredSuggestions[0].options ? last = filteredSuggestions.reduce(reducer, 0) - 1 : last = filteredSuggestions.length - 1;
|
|
127
|
-
return last;
|
|
65
|
+
var isRequired = function isRequired(value, optional) {
|
|
66
|
+
return value === "" && !optional;
|
|
128
67
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
68
|
+
var isLengthIncorrect = function isLengthIncorrect(value, minLength, maxLength) {
|
|
69
|
+
return value != null && (value.length < minLength || value.length > maxLength);
|
|
70
|
+
};
|
|
71
|
+
var isNumberIncorrect = function isNumberIncorrect(value, minNumber, maxNumber) {
|
|
72
|
+
return value < minNumber || value > maxNumber;
|
|
73
|
+
};
|
|
74
|
+
var patternMismatch = function patternMismatch(pattern, value) {
|
|
75
|
+
return pattern != null && !new RegExp(pattern).test(value);
|
|
76
|
+
};
|
|
77
|
+
var useWidth = function useWidth(target) {
|
|
78
|
+
var _useState = (0, _react.useState)(0),
|
|
79
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
80
|
+
width = _useState2[0],
|
|
81
|
+
setWidth = _useState2[1];
|
|
82
|
+
(0, _react.useEffect)(function () {
|
|
83
|
+
if (target != null) {
|
|
84
|
+
setWidth(target.getBoundingClientRect().width);
|
|
85
|
+
var triggerObserver = new ResizeObserver(function (entries) {
|
|
86
|
+
var rect = entries[0].target.getBoundingClientRect();
|
|
87
|
+
setWidth(rect === null || rect === void 0 ? void 0 : rect.width);
|
|
88
|
+
});
|
|
89
|
+
triggerObserver.observe(target);
|
|
90
|
+
return function () {
|
|
91
|
+
triggerObserver.unobserve(target);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}, [target]);
|
|
95
|
+
return width;
|
|
96
|
+
};
|
|
97
|
+
var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
98
|
+
var label = _ref2.label,
|
|
99
|
+
_ref2$name = _ref2.name,
|
|
100
|
+
name = _ref2$name === void 0 ? "" : _ref2$name,
|
|
101
|
+
_ref2$defaultValue = _ref2.defaultValue,
|
|
102
|
+
defaultValue = _ref2$defaultValue === void 0 ? "" : _ref2$defaultValue,
|
|
103
|
+
value = _ref2.value,
|
|
104
|
+
helperText = _ref2.helperText,
|
|
105
|
+
_ref2$placeholder = _ref2.placeholder,
|
|
106
|
+
placeholder = _ref2$placeholder === void 0 ? "" : _ref2$placeholder,
|
|
107
|
+
action = _ref2.action,
|
|
108
|
+
_ref2$clearable = _ref2.clearable,
|
|
109
|
+
clearable = _ref2$clearable === void 0 ? false : _ref2$clearable,
|
|
110
|
+
_ref2$disabled = _ref2.disabled,
|
|
111
|
+
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
112
|
+
_ref2$readOnly = _ref2.readOnly,
|
|
113
|
+
readOnly = _ref2$readOnly === void 0 ? false : _ref2$readOnly,
|
|
114
|
+
_ref2$optional = _ref2.optional,
|
|
115
|
+
optional = _ref2$optional === void 0 ? false : _ref2$optional,
|
|
116
|
+
_ref2$prefix = _ref2.prefix,
|
|
117
|
+
prefix = _ref2$prefix === void 0 ? "" : _ref2$prefix,
|
|
118
|
+
_ref2$suffix = _ref2.suffix,
|
|
119
|
+
suffix = _ref2$suffix === void 0 ? "" : _ref2$suffix,
|
|
120
|
+
onChange = _ref2.onChange,
|
|
121
|
+
onBlur = _ref2.onBlur,
|
|
122
|
+
error = _ref2.error,
|
|
123
|
+
suggestions = _ref2.suggestions,
|
|
124
|
+
pattern = _ref2.pattern,
|
|
125
|
+
minLength = _ref2.minLength,
|
|
126
|
+
maxLength = _ref2.maxLength,
|
|
127
|
+
_ref2$autocomplete = _ref2.autocomplete,
|
|
128
|
+
autocomplete = _ref2$autocomplete === void 0 ? "off" : _ref2$autocomplete,
|
|
129
|
+
margin = _ref2.margin,
|
|
130
|
+
_ref2$size = _ref2.size,
|
|
131
|
+
size = _ref2$size === void 0 ? "medium" : _ref2$size,
|
|
132
|
+
_ref2$tabIndex = _ref2.tabIndex,
|
|
133
|
+
tabIndex = _ref2$tabIndex === void 0 ? 0 : _ref2$tabIndex;
|
|
134
|
+
var _useState3 = (0, _react.useState)("input-".concat((0, _uuid.v4)())),
|
|
135
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
|
|
136
|
+
inputId = _useState4[0];
|
|
137
|
+
var autosuggestId = "suggestions-".concat(inputId);
|
|
138
|
+
var errorId = "error-".concat(inputId);
|
|
139
|
+
var _useState5 = (0, _react.useState)(defaultValue),
|
|
140
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
141
|
+
innerValue = _useState6[0],
|
|
142
|
+
setInnerValue = _useState6[1];
|
|
180
143
|
var _useState7 = (0, _react.useState)(false),
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
144
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
145
|
+
isOpen = _useState8[0],
|
|
146
|
+
changeIsOpen = _useState8[1];
|
|
185
147
|
var _useState9 = (0, _react.useState)(false),
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
148
|
+
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
149
|
+
isSearching = _useState10[0],
|
|
150
|
+
changeIsSearching = _useState10[1];
|
|
151
|
+
var _useState11 = (0, _react.useState)(false),
|
|
152
|
+
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
153
|
+
isAutosuggestError = _useState12[0],
|
|
154
|
+
changeIsAutosuggestError = _useState12[1];
|
|
155
|
+
var _useState13 = (0, _react.useState)([]),
|
|
156
|
+
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
157
|
+
filteredSuggestions = _useState14[0],
|
|
158
|
+
changeFilteredSuggestions = _useState14[1];
|
|
159
|
+
var _useState15 = (0, _react.useState)(-1),
|
|
160
|
+
_useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
|
|
161
|
+
visualFocusIndex = _useState16[0],
|
|
162
|
+
changeVisualFocusIndex = _useState16[1];
|
|
201
163
|
var inputRef = (0, _react.useRef)(null);
|
|
164
|
+
var inputContainerRef = (0, _react.useRef)(null);
|
|
202
165
|
var actionRef = (0, _react.useRef)(null);
|
|
166
|
+
var width = useWidth(inputContainerRef.current);
|
|
203
167
|
var colorsTheme = (0, _useTheme["default"])();
|
|
204
168
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
205
169
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
206
|
-
var
|
|
207
|
-
var errorId = "error-".concat(inputId);
|
|
208
|
-
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
|
-
|
|
170
|
+
var numberInputContext = (0, _react.useContext)(_NumberInput.NumberInputContext);
|
|
231
171
|
var getNumberErrorMessage = function getNumberErrorMessage(value) {
|
|
232
|
-
if (
|
|
172
|
+
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);
|
|
233
173
|
};
|
|
234
|
-
|
|
235
|
-
var hasSuggestions = function hasSuggestions() {
|
|
236
|
-
return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
|
|
237
|
-
};
|
|
238
|
-
|
|
239
174
|
var openSuggestions = function openSuggestions() {
|
|
240
|
-
hasSuggestions() && changeIsOpen(true);
|
|
175
|
+
hasSuggestions(suggestions) && changeIsOpen(true);
|
|
241
176
|
};
|
|
242
|
-
|
|
243
177
|
var closeSuggestions = function closeSuggestions() {
|
|
244
|
-
|
|
245
|
-
|
|
178
|
+
if (hasSuggestions(suggestions)) {
|
|
179
|
+
changeIsOpen(false);
|
|
180
|
+
changeVisualFocusIndex(-1);
|
|
181
|
+
}
|
|
246
182
|
};
|
|
247
|
-
|
|
248
183
|
var changeValue = function changeValue(newValue) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (
|
|
252
|
-
value:
|
|
184
|
+
var formattedValue = typeof newValue === "number" ? newValue.toString() : newValue;
|
|
185
|
+
value !== null && value !== void 0 ? value : setInnerValue(formattedValue);
|
|
186
|
+
if (isRequired(formattedValue, optional)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
187
|
+
value: formattedValue,
|
|
253
188
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
254
|
-
});else if (isLengthIncorrect(
|
|
255
|
-
value:
|
|
189
|
+
});else if (isLengthIncorrect(formattedValue, minLength, maxLength)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
190
|
+
value: formattedValue,
|
|
256
191
|
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
257
|
-
});else if (
|
|
258
|
-
value:
|
|
192
|
+
});else if (patternMismatch(pattern, formattedValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
193
|
+
value: formattedValue,
|
|
259
194
|
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
260
|
-
});else if (
|
|
261
|
-
value:
|
|
262
|
-
error: getNumberErrorMessage(newValue)
|
|
195
|
+
});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({
|
|
196
|
+
value: formattedValue,
|
|
197
|
+
error: getNumberErrorMessage(Number(newValue))
|
|
263
198
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
264
|
-
value:
|
|
199
|
+
value: formattedValue
|
|
265
200
|
});
|
|
266
201
|
};
|
|
267
|
-
|
|
268
202
|
var handleInputContainerOnClick = function handleInputContainerOnClick() {
|
|
269
203
|
document.activeElement !== actionRef.current && inputRef.current.focus();
|
|
270
204
|
};
|
|
271
|
-
|
|
272
205
|
var handleInputContainerOnMouseDown = function handleInputContainerOnMouseDown(event) {
|
|
273
206
|
// Avoid input to lose the focus when the container is pressed
|
|
274
207
|
document.activeElement === inputRef.current && event.preventDefault();
|
|
275
208
|
};
|
|
276
|
-
|
|
277
|
-
var handleIOnChange = function handleIOnChange(event) {
|
|
209
|
+
var handleInputOnChange = function handleInputOnChange(event) {
|
|
278
210
|
openSuggestions();
|
|
279
211
|
changeValue(event.target.value);
|
|
280
212
|
};
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
213
|
+
var handleInputOnBlur = function handleInputOnBlur(event) {
|
|
214
|
+
closeSuggestions();
|
|
215
|
+
if (isRequired(event.target.value, optional)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
285
216
|
value: event.target.value,
|
|
286
217
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
287
|
-
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
218
|
+
});else if (isLengthIncorrect(event.target.value, minLength, maxLength)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
288
219
|
value: event.target.value,
|
|
289
220
|
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
290
|
-
});else if (
|
|
221
|
+
});else if (patternMismatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
291
222
|
value: event.target.value,
|
|
292
223
|
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
293
|
-
});else if (
|
|
224
|
+
});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({
|
|
294
225
|
value: event.target.value,
|
|
295
|
-
error: getNumberErrorMessage(event.target.value)
|
|
226
|
+
error: getNumberErrorMessage(Number(event.target.value))
|
|
296
227
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
297
228
|
value: event.target.value
|
|
298
229
|
});
|
|
299
230
|
};
|
|
300
|
-
|
|
301
|
-
var handleIOnKeyDown = function handleIOnKeyDown(event) {
|
|
231
|
+
var handleInputOnKeyDown = function handleInputOnKeyDown(event) {
|
|
302
232
|
switch (event.key) {
|
|
303
233
|
case "Down":
|
|
304
234
|
case "ArrowDown":
|
|
305
235
|
event.preventDefault();
|
|
306
|
-
|
|
307
|
-
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
308
|
-
decrementNumber();
|
|
309
|
-
} else {
|
|
236
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") decrementNumber();else {
|
|
310
237
|
openSuggestions();
|
|
311
|
-
|
|
312
238
|
if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
|
|
313
|
-
|
|
239
|
+
changeVisualFocusIndex(function (visualFocusedSuggIndex) {
|
|
314
240
|
if (visualFocusedSuggIndex < filteredSuggestions.length - 1) return visualFocusedSuggIndex + 1;else if (visualFocusedSuggIndex === filteredSuggestions.length - 1) return 0;
|
|
315
241
|
});
|
|
316
242
|
}
|
|
317
243
|
}
|
|
318
|
-
|
|
319
244
|
break;
|
|
320
|
-
|
|
321
245
|
case "Up":
|
|
322
246
|
case "ArrowUp":
|
|
323
247
|
event.preventDefault();
|
|
324
|
-
|
|
325
|
-
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
326
|
-
incrementNumber();
|
|
327
|
-
} else {
|
|
248
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") incrementNumber();else {
|
|
328
249
|
openSuggestions();
|
|
329
|
-
|
|
330
250
|
if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
|
|
331
|
-
|
|
251
|
+
changeVisualFocusIndex(function (visualFocusedSuggIndex) {
|
|
332
252
|
if (visualFocusedSuggIndex === 0 || visualFocusedSuggIndex === -1) return filteredSuggestions.length > 0 ? filteredSuggestions.length - 1 : suggestions.length - 1;else return visualFocusedSuggIndex - 1;
|
|
333
253
|
});
|
|
334
254
|
}
|
|
335
255
|
}
|
|
336
|
-
|
|
337
256
|
break;
|
|
338
|
-
|
|
339
257
|
case "Esc":
|
|
340
258
|
case "Escape":
|
|
341
259
|
event.preventDefault();
|
|
342
|
-
|
|
343
|
-
if (hasSuggestions()) {
|
|
260
|
+
if (hasSuggestions(suggestions)) {
|
|
344
261
|
changeValue("");
|
|
345
262
|
isOpen && closeSuggestions();
|
|
346
263
|
}
|
|
347
|
-
|
|
348
264
|
break;
|
|
349
|
-
|
|
350
265
|
case "Enter":
|
|
351
|
-
if (hasSuggestions() && !isSearching) {
|
|
352
|
-
var validFocusedSuggestion = filteredSuggestions.length > 0 &&
|
|
353
|
-
validFocusedSuggestion && changeValue(filteredSuggestions[
|
|
266
|
+
if (hasSuggestions(suggestions) && !isSearching) {
|
|
267
|
+
var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusIndex >= 0 && visualFocusIndex < filteredSuggestions.length;
|
|
268
|
+
validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusIndex]);
|
|
354
269
|
isOpen && closeSuggestions();
|
|
355
270
|
}
|
|
356
|
-
|
|
357
271
|
break;
|
|
358
272
|
}
|
|
359
273
|
};
|
|
360
|
-
|
|
361
274
|
var handleClearActionOnClick = function handleClearActionOnClick() {
|
|
362
275
|
changeValue("");
|
|
363
276
|
inputRef.current.focus();
|
|
364
277
|
suggestions && closeSuggestions();
|
|
365
278
|
};
|
|
366
|
-
|
|
367
279
|
var handleDecrementActionOnClick = function handleDecrementActionOnClick() {
|
|
368
280
|
decrementNumber();
|
|
369
281
|
inputRef.current.focus();
|
|
370
282
|
};
|
|
371
|
-
|
|
372
283
|
var handleIncrementActionOnClick = function handleIncrementActionOnClick() {
|
|
373
284
|
incrementNumber();
|
|
374
285
|
inputRef.current.focus();
|
|
375
286
|
};
|
|
376
|
-
|
|
377
287
|
var setNumberProps = function setNumberProps(type, min, max, step) {
|
|
378
|
-
var _inputRef$
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
step && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 ? void 0 : _inputRef$current6.setAttribute("step", step));
|
|
288
|
+
var _inputRef$current, _inputRef$current2, _inputRef$current3, _inputRef$current4;
|
|
289
|
+
min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.setAttribute("min", min));
|
|
290
|
+
max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.setAttribute("max", max));
|
|
291
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("step", step);
|
|
292
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("type", type);
|
|
384
293
|
};
|
|
385
|
-
|
|
386
294
|
var decrementNumber = function decrementNumber() {
|
|
387
|
-
var
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
|
|
393
|
-
} 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))) {
|
|
394
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);
|
|
395
|
-
} 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 !== "") {
|
|
396
|
-
changeValue(parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
397
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue == "") {
|
|
398
|
-
changeValue(-(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
399
|
-
} else if (numberValue === "") {
|
|
400
|
-
changeValue(-1);
|
|
295
|
+
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
296
|
+
var numberValue = Number(currentValue);
|
|
297
|
+
var steppedValue = Math.round((numberValue - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
298
|
+
if (currentValue !== "") {
|
|
299
|
+
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);
|
|
401
300
|
} else {
|
|
402
|
-
changeValue(
|
|
301
|
+
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);
|
|
403
302
|
}
|
|
404
303
|
};
|
|
405
|
-
|
|
406
304
|
var incrementNumber = function incrementNumber() {
|
|
407
|
-
var
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);
|
|
413
|
-
} 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))) {
|
|
414
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
|
|
415
|
-
} 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 !== "") {
|
|
416
|
-
changeValue(parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
417
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue == "") {
|
|
418
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber);
|
|
419
|
-
} else if (numberValue === "") {
|
|
420
|
-
changeValue(1);
|
|
305
|
+
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
306
|
+
var numberValue = Number(currentValue);
|
|
307
|
+
var steppedValue = Math.round((numberValue + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
308
|
+
if (currentValue !== "") {
|
|
309
|
+
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);
|
|
421
310
|
} else {
|
|
422
|
-
changeValue(
|
|
311
|
+
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);
|
|
423
312
|
}
|
|
424
313
|
};
|
|
425
|
-
|
|
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
314
|
(0, _react.useEffect)(function () {
|
|
436
315
|
if (typeof suggestions === "function") {
|
|
437
316
|
changeIsSearching(true);
|
|
@@ -455,10 +334,9 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
455
334
|
changeFilteredSuggestions(suggestions.filter(function (suggestion) {
|
|
456
335
|
return suggestion.toUpperCase().startsWith((value !== null && value !== void 0 ? value : innerValue).toUpperCase());
|
|
457
336
|
}));
|
|
458
|
-
|
|
337
|
+
changeVisualFocusIndex(-1);
|
|
459
338
|
}
|
|
460
|
-
|
|
461
|
-
(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
339
|
+
numberInputContext != null && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
462
340
|
}, [value, innerValue, suggestions, numberInputContext]);
|
|
463
341
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
464
342
|
theme: colorsTheme.textInput
|
|
@@ -474,12 +352,52 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
474
352
|
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
475
353
|
disabled: disabled,
|
|
476
354
|
backgroundType: backgroundType
|
|
477
|
-
}, helperText), /*#__PURE__*/_react["default"].createElement(
|
|
355
|
+
}, helperText), /*#__PURE__*/_react["default"].createElement(AutosuggestWrapper, {
|
|
356
|
+
condition: hasSuggestions(suggestions),
|
|
357
|
+
wrapper: function wrapper(children) {
|
|
358
|
+
return /*#__PURE__*/_react["default"].createElement(Popover.Root, {
|
|
359
|
+
open: isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError)
|
|
360
|
+
}, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
|
|
361
|
+
asChild: true,
|
|
362
|
+
"aria-controls": undefined
|
|
363
|
+
}, children), /*#__PURE__*/_react["default"].createElement(Popover.Portal, null, /*#__PURE__*/_react["default"].createElement(Popover.Content, {
|
|
364
|
+
sideOffset: 5,
|
|
365
|
+
style: {
|
|
366
|
+
zIndex: "2147483647"
|
|
367
|
+
},
|
|
368
|
+
onOpenAutoFocus: function onOpenAutoFocus(event) {
|
|
369
|
+
// Avoid select to lose focus when the list is opened
|
|
370
|
+
event.preventDefault();
|
|
371
|
+
},
|
|
372
|
+
onCloseAutoFocus: function onCloseAutoFocus(event) {
|
|
373
|
+
// Avoid select to lose focus when the list is closed
|
|
374
|
+
event.preventDefault();
|
|
375
|
+
}
|
|
376
|
+
}, /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
|
|
377
|
+
id: autosuggestId,
|
|
378
|
+
value: value !== null && value !== void 0 ? value : innerValue,
|
|
379
|
+
suggestions: filteredSuggestions,
|
|
380
|
+
visualFocusIndex: visualFocusIndex,
|
|
381
|
+
highlightedSuggestions: typeof suggestions !== "function",
|
|
382
|
+
searchHasErrors: isAutosuggestError,
|
|
383
|
+
isSearching: isSearching,
|
|
384
|
+
suggestionOnClick: function suggestionOnClick(suggestion) {
|
|
385
|
+
changeValue(suggestion);
|
|
386
|
+
closeSuggestions();
|
|
387
|
+
},
|
|
388
|
+
styles: {
|
|
389
|
+
width: width
|
|
390
|
+
}
|
|
391
|
+
}))));
|
|
392
|
+
}
|
|
393
|
+
}, /*#__PURE__*/_react["default"].createElement(InputContainer, {
|
|
478
394
|
error: error ? true : false,
|
|
479
395
|
disabled: disabled,
|
|
396
|
+
readOnly: readOnly,
|
|
480
397
|
backgroundType: backgroundType,
|
|
481
398
|
onClick: handleInputContainerOnClick,
|
|
482
|
-
onMouseDown: handleInputContainerOnMouseDown
|
|
399
|
+
onMouseDown: handleInputContainerOnMouseDown,
|
|
400
|
+
ref: inputContainerRef
|
|
483
401
|
}, prefix && /*#__PURE__*/_react["default"].createElement(Prefix, {
|
|
484
402
|
disabled: disabled,
|
|
485
403
|
backgroundType: backgroundType
|
|
@@ -488,134 +406,93 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
488
406
|
name: name,
|
|
489
407
|
value: value !== null && value !== void 0 ? value : innerValue,
|
|
490
408
|
placeholder: placeholder,
|
|
491
|
-
onBlur:
|
|
492
|
-
onChange:
|
|
493
|
-
onFocus:
|
|
494
|
-
|
|
495
|
-
},
|
|
496
|
-
onKeyDown: handleIOnKeyDown,
|
|
409
|
+
onBlur: handleInputOnBlur,
|
|
410
|
+
onChange: handleInputOnChange,
|
|
411
|
+
onFocus: !readOnly ? openSuggestions : undefined,
|
|
412
|
+
onKeyDown: !readOnly ? handleInputOnKeyDown : undefined,
|
|
497
413
|
onMouseDown: function onMouseDown(event) {
|
|
498
414
|
event.stopPropagation();
|
|
499
415
|
},
|
|
500
416
|
disabled: disabled,
|
|
417
|
+
readOnly: readOnly,
|
|
501
418
|
ref: inputRef,
|
|
502
419
|
backgroundType: backgroundType,
|
|
503
420
|
pattern: pattern,
|
|
504
421
|
minLength: minLength,
|
|
505
422
|
maxLength: maxLength,
|
|
506
|
-
autoComplete: autocomplete,
|
|
423
|
+
autoComplete: autocomplete === "off" ? "nope" : autocomplete,
|
|
507
424
|
tabIndex: tabIndex,
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
"aria-
|
|
511
|
-
"aria-
|
|
512
|
-
"aria-expanded":
|
|
513
|
-
"aria-
|
|
514
|
-
"aria-
|
|
425
|
+
type: "text",
|
|
426
|
+
role: hasSuggestions(suggestions) ? "combobox" : undefined,
|
|
427
|
+
"aria-autocomplete": hasSuggestions(suggestions) ? "list" : undefined,
|
|
428
|
+
"aria-controls": hasSuggestions(suggestions) ? autosuggestId : undefined,
|
|
429
|
+
"aria-expanded": hasSuggestions(suggestions) ? isOpen : undefined,
|
|
430
|
+
"aria-haspopup": hasSuggestions(suggestions) ? "listbox" : undefined,
|
|
431
|
+
"aria-activedescendant": hasSuggestions(suggestions) && isOpen && visualFocusIndex !== -1 ? "suggestion-".concat(visualFocusIndex) : undefined,
|
|
432
|
+
"aria-invalid": error ? true : false,
|
|
515
433
|
"aria-errormessage": error ? errorId : undefined,
|
|
516
|
-
"aria-required":
|
|
434
|
+
"aria-required": !disabled && !optional
|
|
517
435
|
}), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
|
|
518
436
|
backgroundType: backgroundType,
|
|
519
437
|
"aria-label": "Error"
|
|
520
|
-
},
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
},
|
|
438
|
+
}, _Icons["default"].error), !disabled && !readOnly && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
439
|
+
"aria-label": translatedLabels.textInput.clearFieldActionTitle,
|
|
440
|
+
onClick: handleClearActionOnClick,
|
|
524
441
|
onMouseDown: function onMouseDown(event) {
|
|
525
442
|
event.stopPropagation();
|
|
526
443
|
},
|
|
527
|
-
backgroundType: backgroundType,
|
|
528
444
|
tabIndex: tabIndex,
|
|
529
445
|
title: translatedLabels.textInput.clearFieldActionTitle,
|
|
530
|
-
"
|
|
531
|
-
|
|
532
|
-
|
|
446
|
+
type: "button",
|
|
447
|
+
backgroundType: backgroundType
|
|
448
|
+
}, _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, {
|
|
449
|
+
"aria-label": translatedLabels.numberInput.decrementValueTitle,
|
|
533
450
|
disabled: disabled,
|
|
534
|
-
onClick:
|
|
535
|
-
return handleDecrementActionOnClick();
|
|
536
|
-
},
|
|
451
|
+
onClick: !readOnly ? handleDecrementActionOnClick : undefined,
|
|
537
452
|
onMouseDown: function onMouseDown(event) {
|
|
538
453
|
event.stopPropagation();
|
|
539
454
|
},
|
|
540
|
-
|
|
455
|
+
ref: actionRef,
|
|
541
456
|
tabIndex: tabIndex,
|
|
542
457
|
title: translatedLabels.numberInput.decrementValueTitle,
|
|
543
|
-
"
|
|
544
|
-
|
|
545
|
-
|
|
458
|
+
type: "button",
|
|
459
|
+
backgroundType: backgroundType
|
|
460
|
+
}, _Icons["default"].decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
461
|
+
"aria-label": translatedLabels.numberInput.incrementValueTitle,
|
|
546
462
|
disabled: disabled,
|
|
547
|
-
onClick:
|
|
548
|
-
return handleIncrementActionOnClick();
|
|
549
|
-
},
|
|
463
|
+
onClick: !readOnly ? handleIncrementActionOnClick : undefined,
|
|
550
464
|
onMouseDown: function onMouseDown(event) {
|
|
551
465
|
event.stopPropagation();
|
|
552
466
|
},
|
|
553
|
-
|
|
467
|
+
ref: actionRef,
|
|
554
468
|
tabIndex: tabIndex,
|
|
555
469
|
title: translatedLabels.numberInput.incrementValueTitle,
|
|
556
|
-
"
|
|
557
|
-
|
|
558
|
-
|
|
470
|
+
type: "button",
|
|
471
|
+
backgroundType: backgroundType
|
|
472
|
+
}, _Icons["default"].increment)), action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
473
|
+
"aria-label": action.title,
|
|
559
474
|
disabled: disabled,
|
|
560
|
-
onClick:
|
|
561
|
-
return action.onClick();
|
|
562
|
-
},
|
|
475
|
+
onClick: !readOnly ? action.onClick : undefined,
|
|
563
476
|
onMouseDown: function onMouseDown(event) {
|
|
564
477
|
event.stopPropagation();
|
|
565
478
|
},
|
|
479
|
+
ref: actionRef,
|
|
480
|
+
tabIndex: tabIndex,
|
|
566
481
|
title: action.title,
|
|
567
|
-
"
|
|
568
|
-
backgroundType: backgroundType
|
|
569
|
-
|
|
570
|
-
}, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement(ActionIcon, {
|
|
482
|
+
type: "button",
|
|
483
|
+
backgroundType: backgroundType
|
|
484
|
+
}, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
571
485
|
src: action.icon
|
|
572
486
|
}) : action.icon), suffix && /*#__PURE__*/_react["default"].createElement(Suffix, {
|
|
573
487
|
disabled: disabled,
|
|
574
488
|
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, {
|
|
489
|
+
}, suffix))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
601
490
|
id: errorId,
|
|
602
491
|
backgroundType: backgroundType,
|
|
603
492
|
"aria-live": error ? "assertive" : "off"
|
|
604
493
|
}, error)));
|
|
605
494
|
});
|
|
606
|
-
|
|
607
|
-
var sizes = {
|
|
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) {
|
|
495
|
+
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) {
|
|
619
496
|
return calculateWidth(props.margin, props.size);
|
|
620
497
|
}, function (props) {
|
|
621
498
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -628,7 +505,6 @@ var TextInputContainer = _styledComponents["default"].div(_templateObject || (_t
|
|
|
628
505
|
}, function (props) {
|
|
629
506
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
630
507
|
});
|
|
631
|
-
|
|
632
508
|
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) {
|
|
633
509
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledLabelFontColorOnDark : props.theme.disabledLabelFontColor : props.backgroundType === "dark" ? props.theme.labelFontColorOnDark : props.theme.labelFontColor;
|
|
634
510
|
}, function (props) {
|
|
@@ -644,11 +520,9 @@ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObj
|
|
|
644
520
|
}, function (props) {
|
|
645
521
|
return !props.hasHelperText && "margin-bottom: 0.25rem";
|
|
646
522
|
});
|
|
647
|
-
|
|
648
523
|
var OptionalLabel = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: ", ";\n"])), function (props) {
|
|
649
524
|
return props.theme.optionalLabelFontWeight;
|
|
650
525
|
});
|
|
651
|
-
|
|
652
526
|
var HelperText = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n margin-bottom: 0.25rem;\n"])), function (props) {
|
|
653
527
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledHelperTextFontColorOnDark : props.theme.disabledHelperTextFontColor : props.backgroundType === "dark" ? props.theme.helperTextFontColorOnDark : props.theme.helperTextFontColor;
|
|
654
528
|
}, function (props) {
|
|
@@ -662,19 +536,15 @@ var HelperText = _styledComponents["default"].span(_templateObject4 || (_templat
|
|
|
662
536
|
}, function (props) {
|
|
663
537
|
return props.theme.helperTextLineHeight;
|
|
664
538
|
});
|
|
665
|
-
|
|
666
|
-
var InputContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n position: relative;\n align-items: center;\n height: calc(2.5rem - 2px);\n padding: 0 0.5rem;\n\n ", "\n box-shadow: 0 0 0 2px transparent;\n border-radius: 4px;\n border: 1px solid\n ", ";\n ", "\n ", ";\n\n ", ";\n"])), function (props) {
|
|
539
|
+
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) {
|
|
667
540
|
if (props.disabled) return props.backgroundType === "dark" ? "background-color: ".concat(props.theme.disabledContainerFillColorOnDark, ";") : "background-color: ".concat(props.theme.disabledContainerFillColor, ";");
|
|
668
541
|
}, function (props) {
|
|
669
|
-
if (props.disabled) return props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;else return props.backgroundType === "dark" ? props.theme.enabledBorderColorOnDark : props.theme.enabledBorderColor;
|
|
542
|
+
if (props.disabled) return props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;else if (props.readOnly) return props.theme.readOnlyBorderColor;else return props.backgroundType === "dark" ? props.theme.enabledBorderColorOnDark : props.theme.enabledBorderColor;
|
|
670
543
|
}, function (props) {
|
|
671
544
|
return props.error && !props.disabled && "border-color: transparent;\n box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.errorBorderColorOnDark : props.theme.errorBorderColor, ";\n ");
|
|
672
545
|
}, function (props) {
|
|
673
|
-
return props.disabled
|
|
674
|
-
}, 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 && "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 ");
|
|
546
|
+
return !props.disabled ? "\n &:hover {\n border-color: ".concat(props.error ? "transparent" : props.readOnly ? props.theme.hoverReadOnlyBorderColor : props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor, ";\n ").concat(props.error ? "box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.hoverErrorBorderColorOnDark : props.theme.hoverErrorBorderColor, ";") : "", "\n }\n &:focus-within {\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n ") : "cursor: not-allowed;";
|
|
676
547
|
});
|
|
677
|
-
|
|
678
548
|
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) {
|
|
679
549
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledValueFontColorOnDark : props.theme.disabledValueFontColor : props.backgroundType === "dark" ? props.theme.valueFontColorOnDark : props.theme.valueFontColor;
|
|
680
550
|
}, function (props) {
|
|
@@ -690,72 +560,33 @@ var Input = _styledComponents["default"].input(_templateObject6 || (_templateObj
|
|
|
690
560
|
}, function (props) {
|
|
691
561
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPlaceholderFontColorOnDark : props.theme.disabledPlaceholderFontColor : props.backgroundType === "dark" ? props.theme.placeholderFontColorOnDark : props.theme.placeholderFontColor;
|
|
692
562
|
});
|
|
693
|
-
|
|
694
|
-
var ActionIcon = _styledComponents["default"].img(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n width: 16px;\n height: 16px;\n"])));
|
|
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) {
|
|
563
|
+
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
564
|
return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
|
|
700
565
|
}, function (props) {
|
|
701
566
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledActionBackgroundColorOnDark : props.theme.disabledActionBackgroundColor : props.backgroundType === "dark" ? props.theme.actionBackgroundColorOnDark : props.theme.actionBackgroundColor;
|
|
702
567
|
}, function (props) {
|
|
703
568
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledActionIconColorOnDark : props.theme.disabledActionIconColor : props.backgroundType === "dark" ? props.theme.actionIconColorOnDark : props.theme.actionIconColor;
|
|
704
569
|
}, function (props) {
|
|
705
|
-
return !props.disabled && "\n &:focus
|
|
570
|
+
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
571
|
});
|
|
707
|
-
|
|
708
|
-
var Prefix = _styledComponents["default"].span(_templateObject9 || (_templateObject9 = (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) {
|
|
572
|
+
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
573
|
var color = props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPrefixColorOnDark : props.theme.disabledPrefixColor : props.backgroundType === "dark" ? props.theme.prefixColorOnDark : props.theme.prefixColor;
|
|
710
574
|
return "color: ".concat(color, "; border-right: 1px solid ").concat(color, ";");
|
|
711
575
|
}, function (props) {
|
|
712
576
|
return props.theme.fontFamily;
|
|
713
577
|
});
|
|
714
|
-
|
|
715
|
-
var Suffix = _styledComponents["default"].span(_templateObject10 || (_templateObject10 = (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) {
|
|
578
|
+
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
579
|
var color = props.disabled ? props.backgroundType === "dark" ? props.theme.disabledSuffixColorOnDark : props.theme.disabledSuffixColor : props.backgroundType === "dark" ? props.theme.suffixColorOnDark : props.theme.suffixColor;
|
|
717
580
|
return "color: ".concat(color, "; border-left: 1px solid ").concat(color, ";");
|
|
718
581
|
}, function (props) {
|
|
719
582
|
return props.theme.fontFamily;
|
|
720
583
|
});
|
|
721
|
-
|
|
722
|
-
var ErrorIcon = _styledComponents["default"].span(_templateObject11 || (_templateObject11 = (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) {
|
|
584
|
+
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
585
|
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
724
586
|
});
|
|
725
|
-
|
|
726
|
-
var Error = _styledComponents["default"].span(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 1.5em;\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n line-height: 1.5em;\n margin-top: 0.25rem;\n"])), function (props) {
|
|
587
|
+
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
588
|
return props.backgroundType === "dark" ? props.theme.errorMessageColorOnDark : props.theme.errorMessageColor;
|
|
728
589
|
}, function (props) {
|
|
729
590
|
return props.theme.fontFamily;
|
|
730
591
|
});
|
|
731
|
-
|
|
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
|
-
var _default = DxcTextInput;
|
|
761
|
-
exports["default"] = _default;
|
|
592
|
+
var _default = exports["default"] = DxcTextInput;
|