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