@dxc-technology/halstack-react 0.0.0-e884f9f → 0.0.0-e9cf865
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 +10 -0
- package/BackgroundColorContext.js +1 -3
- package/ThemeContext.d.ts +15 -0
- package/ThemeContext.js +5 -8
- package/V3Select/V3Select.js +2 -2
- package/V3Textarea/V3Textarea.js +2 -2
- package/accordion/Accordion.js +2 -2
- package/accordion-group/AccordionGroup.js +2 -2
- package/accordion-group/AccordionGroup.stories.tsx +225 -0
- package/alert/Alert.js +2 -2
- package/badge/Badge.js +1 -1
- package/box/Box.js +2 -2
- package/button/Button.d.ts +1 -1
- package/button/Button.js +6 -4
- package/button/types.d.ts +2 -2
- package/card/Card.js +1 -1
- package/checkbox/Checkbox.js +2 -2
- package/chip/Chip.d.ts +4 -0
- package/chip/Chip.js +1 -23
- package/chip/types.d.ts +53 -0
- package/chip/types.js +5 -0
- package/common/variables.js +19 -22
- package/date/Date.js +1 -1
- package/date-input/DateInput.js +4 -7
- package/dialog/Dialog.js +2 -2
- package/dropdown/Dropdown.js +1 -1
- package/dropdown/types.d.ts +1 -1
- package/file-input/FileInput.d.ts +1 -1
- package/file-input/FileInput.js +58 -48
- package/file-input/FileItem.js +8 -6
- package/file-input/types.d.ts +32 -7
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +11 -17
- package/footer/{Footer.stories.jsx → Footer.stories.tsx} +1 -22
- package/footer/Icons.d.ts +2 -0
- package/footer/Icons.js +3 -3
- package/footer/types.d.ts +21 -17
- package/header/Header.js +2 -2
- package/header/Icons.d.ts +2 -0
- package/heading/Heading.js +1 -1
- package/input-text/InputText.js +2 -2
- package/layout/ApplicationLayout.d.ts +10 -0
- package/layout/ApplicationLayout.js +8 -18
- package/layout/ApplicationLayout.stories.tsx +171 -0
- package/layout/types.d.ts +57 -0
- package/layout/types.js +5 -0
- package/link/Link.js +1 -1
- package/list/List.d.ts +7 -0
- package/list/List.js +37 -0
- package/list/List.stories.tsx +70 -0
- package/main.d.ts +7 -3
- package/main.js +34 -2
- package/number-input/NumberInput.js +3 -6
- package/number-input/NumberInputContext.d.ts +4 -0
- package/number-input/NumberInputContext.js +5 -2
- package/number-input/numberInputContextTypes.d.ts +19 -0
- package/number-input/numberInputContextTypes.js +5 -0
- package/package.json +1 -1
- package/paginator/Paginator.js +2 -8
- package/password-input/PasswordInput.js +19 -18
- package/password-input/types.d.ts +17 -10
- package/progress-bar/ProgressBar.js +2 -2
- package/radio/Radio.js +2 -2
- package/resultsetTable/ResultsetTable.d.ts +4 -0
- package/resultsetTable/ResultsetTable.js +4 -27
- package/resultsetTable/types.d.ts +67 -0
- package/resultsetTable/types.js +5 -0
- package/row/Row.d.ts +11 -0
- package/row/Row.js +124 -0
- package/row/Row.stories.tsx +223 -0
- package/select/Select.js +15 -17
- package/sidenav/Sidenav.js +2 -2
- package/slider/Slider.js +4 -4
- package/spinner/Spinner.js +2 -2
- package/stack/Stack.d.ts +10 -0
- package/stack/Stack.js +94 -0
- package/stack/Stack.stories.tsx +150 -0
- package/switch/Switch.js +2 -2
- package/table/Table.js +3 -3
- package/tabs/Tabs.js +1 -1
- package/tabs/Tabs.stories.tsx +121 -0
- package/tabs/types.d.ts +1 -1
- package/tag/Tag.js +1 -1
- package/text/Text.d.ts +7 -0
- package/text/Text.js +30 -0
- package/text/Text.stories.tsx +19 -0
- package/text-input/TextInput.d.ts +4 -0
- package/text-input/TextInput.js +42 -81
- package/text-input/TextInput.stories.tsx +456 -0
- package/text-input/types.d.ts +159 -0
- package/text-input/types.js +5 -0
- package/textarea/Textarea.js +29 -32
- package/textarea/index.d.ts +18 -8
- package/toggle/Toggle.js +1 -1
- package/toggle-group/ToggleGroup.d.ts +4 -0
- package/toggle-group/ToggleGroup.js +8 -34
- package/toggle-group/types.d.ts +84 -0
- package/toggle-group/types.js +5 -0
- package/upload/buttons-upload/ButtonsUpload.js +2 -2
- package/upload/dragAndDropArea/DragAndDropArea.js +2 -2
- package/upload/file-upload/FileToUpload.js +1 -1
- package/upload/files-upload/FilesToUpload.js +1 -1
- package/upload/transaction/Transaction.js +2 -2
- package/upload/transactions/Transactions.js +1 -1
- package/useTheme.d.ts +2 -0
- package/useTheme.js +1 -1
- package/wizard/Wizard.js +2 -2
- package/wizard/types.d.ts +1 -1
- package/chip/index.d.ts +0 -22
- package/resultsetTable/index.d.ts +0 -19
- package/text-input/index.d.ts +0 -135
- package/toggle-group/index.d.ts +0 -21
package/table/Table.js
CHANGED
|
@@ -21,9 +21,9 @@ var _variables = require("../common/variables.js");
|
|
|
21
21
|
|
|
22
22
|
var _utils = require("../common/utils.js");
|
|
23
23
|
|
|
24
|
-
var _useTheme = _interopRequireDefault(require("../useTheme
|
|
24
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
26
|
-
var _BackgroundColorContext = require("../BackgroundColorContext
|
|
26
|
+
var _BackgroundColorContext = require("../BackgroundColorContext");
|
|
27
27
|
|
|
28
28
|
var _templateObject, _templateObject2;
|
|
29
29
|
|
|
@@ -48,7 +48,7 @@ var calculateWidth = function calculateWidth(margin) {
|
|
|
48
48
|
return "calc(100% - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
var DxcTableContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n overflow:
|
|
51
|
+
var DxcTableContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n overflow: auto;\n &::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n }\n &::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 6px;\n }\n &::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 6px;\n }\n"])), function (props) {
|
|
52
52
|
return calculateWidth(props.margin);
|
|
53
53
|
}, function (props) {
|
|
54
54
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
package/tabs/Tabs.js
CHANGED
|
@@ -27,7 +27,7 @@ var _variables = require("../common/variables.js");
|
|
|
27
27
|
|
|
28
28
|
var _Badge = _interopRequireDefault(require("../badge/Badge"));
|
|
29
29
|
|
|
30
|
-
var _useTheme = _interopRequireDefault(require("../useTheme
|
|
30
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
31
31
|
|
|
32
32
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
33
33
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
3
|
+
import DxcTabs from "./Tabs";
|
|
4
|
+
import Title from "../../.storybook/components/Title";
|
|
5
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Tabs",
|
|
9
|
+
component: DxcTabs,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const iconSVG = () => {
|
|
13
|
+
return (
|
|
14
|
+
<svg viewBox="0 0 24 24" fill="currentColor">
|
|
15
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
16
|
+
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const tabs: any = [
|
|
22
|
+
{
|
|
23
|
+
label: "Tab 1",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: "Tab 2",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: "Tab 3",
|
|
30
|
+
isDisabled: true,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: "Tab 4",
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const tabsNotification = tabs.map((tab, index) => ({
|
|
38
|
+
...tab,
|
|
39
|
+
notificationNumber: (index === 0 && true) || (index === 1 && 5) || (index === 2 && 200),
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
const tabsIcon = tabs.map((tab) => ({ ...tab, icon: iconSVG }));
|
|
43
|
+
|
|
44
|
+
const tabsNotificationIcon = tabsNotification.map((tab) => ({ ...tab, icon: iconSVG }));
|
|
45
|
+
|
|
46
|
+
export const Chromatic = () => (
|
|
47
|
+
<>
|
|
48
|
+
<ExampleContainer>
|
|
49
|
+
<Title title="Only label" theme="light" level={4} />
|
|
50
|
+
<DxcTabs tabs={tabs} />
|
|
51
|
+
</ExampleContainer>
|
|
52
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
53
|
+
<Title title="Hovered tabs" theme="light" level={4} />
|
|
54
|
+
<DxcTabs tabs={tabs} />
|
|
55
|
+
</ExampleContainer>
|
|
56
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
57
|
+
<Title title="Focused tabs" theme="light" level={4} />
|
|
58
|
+
<DxcTabs tabs={tabs} />
|
|
59
|
+
</ExampleContainer>
|
|
60
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
61
|
+
<Title title="Actived tabs" theme="light" level={4} />
|
|
62
|
+
<DxcTabs tabs={tabs} />
|
|
63
|
+
</ExampleContainer>
|
|
64
|
+
<ExampleContainer>
|
|
65
|
+
<Title title="With notification number" theme="light" level={4} />
|
|
66
|
+
<DxcTabs tabs={tabsNotification} />
|
|
67
|
+
</ExampleContainer>
|
|
68
|
+
<ExampleContainer>
|
|
69
|
+
<Title title="With icon position top" theme="light" level={4} />
|
|
70
|
+
<DxcTabs tabs={tabsIcon} />
|
|
71
|
+
</ExampleContainer>
|
|
72
|
+
<ExampleContainer>
|
|
73
|
+
<Title title="With icon position left" theme="light" level={4} />
|
|
74
|
+
<DxcTabs tabs={tabsIcon} iconPosition="left" />
|
|
75
|
+
</ExampleContainer>
|
|
76
|
+
<ExampleContainer>
|
|
77
|
+
<Title title="With icon and notification number" theme="light" level={4} />
|
|
78
|
+
<DxcTabs tabs={tabsNotificationIcon} />
|
|
79
|
+
</ExampleContainer>
|
|
80
|
+
<ExampleContainer>
|
|
81
|
+
<Title title="With icon on the left and notification number" theme="light" level={4} />
|
|
82
|
+
<DxcTabs tabs={tabsNotificationIcon} iconPosition="left" />
|
|
83
|
+
</ExampleContainer>
|
|
84
|
+
<ExampleContainer>
|
|
85
|
+
<Title title="Scrollable" theme="light" level={4} />
|
|
86
|
+
<div style={{ width: "400px" }}>
|
|
87
|
+
<DxcTabs tabs={tabsNotificationIcon} iconPosition="left" activeTabIndex={1} />
|
|
88
|
+
</div>
|
|
89
|
+
</ExampleContainer>
|
|
90
|
+
|
|
91
|
+
<Title title="Margins" theme="light" level={2} />
|
|
92
|
+
<ExampleContainer>
|
|
93
|
+
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
94
|
+
<DxcTabs tabs={tabs} margin="xxsmall" />
|
|
95
|
+
</ExampleContainer>
|
|
96
|
+
<ExampleContainer>
|
|
97
|
+
<Title title="Xsmall margin" theme="light" level={4} />
|
|
98
|
+
<DxcTabs tabs={tabs} margin="xsmall" />
|
|
99
|
+
</ExampleContainer>
|
|
100
|
+
<ExampleContainer>
|
|
101
|
+
<Title title="Small margin" theme="light" level={4} />
|
|
102
|
+
<DxcTabs tabs={tabs} margin="small" />
|
|
103
|
+
</ExampleContainer>
|
|
104
|
+
<ExampleContainer>
|
|
105
|
+
<Title title="Medium margin" theme="light" level={4} />
|
|
106
|
+
<DxcTabs tabs={tabs} margin="medium" />
|
|
107
|
+
</ExampleContainer>
|
|
108
|
+
<ExampleContainer>
|
|
109
|
+
<Title title="Large margin" theme="light" level={4} />
|
|
110
|
+
<DxcTabs tabs={tabs} margin="large" />
|
|
111
|
+
</ExampleContainer>
|
|
112
|
+
<ExampleContainer>
|
|
113
|
+
<Title title="Xlarge margin" theme="light" level={4} />
|
|
114
|
+
<DxcTabs tabs={tabs} margin="xlarge" />
|
|
115
|
+
</ExampleContainer>
|
|
116
|
+
<ExampleContainer>
|
|
117
|
+
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
118
|
+
<DxcTabs tabs={tabs} margin="xxlarge" />
|
|
119
|
+
</ExampleContainer>
|
|
120
|
+
</>
|
|
121
|
+
);
|
package/tabs/types.d.ts
CHANGED
package/tag/Tag.js
CHANGED
|
@@ -21,7 +21,7 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
21
21
|
|
|
22
22
|
var _variables = require("../common/variables.js");
|
|
23
23
|
|
|
24
|
-
var _useTheme = _interopRequireDefault(require("../useTheme
|
|
24
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
26
26
|
var _utils = require("../common/utils.js");
|
|
27
27
|
|
package/text/Text.d.ts
ADDED
package/text/Text.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _templateObject;
|
|
17
|
+
|
|
18
|
+
function Text(_ref) {
|
|
19
|
+
var _ref$as = _ref.as,
|
|
20
|
+
as = _ref$as === void 0 ? "span" : _ref$as,
|
|
21
|
+
children = _ref.children;
|
|
22
|
+
return /*#__PURE__*/_react["default"].createElement(StyledText, {
|
|
23
|
+
as: as
|
|
24
|
+
}, children);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var StyledText = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n margin: 0px;\n font-family: Open Sans, sans-serif;\n"])));
|
|
28
|
+
|
|
29
|
+
var _default = Text;
|
|
30
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Title from "../../.storybook/components/Title";
|
|
3
|
+
import DxcText from "./Text";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "Text",
|
|
7
|
+
component: DxcText,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const Chromatic = () => (
|
|
11
|
+
<>
|
|
12
|
+
<Title title="Two texts as span" theme="light" level={4} />
|
|
13
|
+
<DxcText>Text 1.</DxcText>
|
|
14
|
+
<DxcText>Text 2.</DxcText>
|
|
15
|
+
<Title title="Two texts as p" theme="light" level={4} />
|
|
16
|
+
<DxcText as="p">Text 1.</DxcText>
|
|
17
|
+
<DxcText as="p">Text 2.</DxcText>
|
|
18
|
+
</>
|
|
19
|
+
);
|
package/text-input/TextInput.js
CHANGED
|
@@ -9,8 +9,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
|
|
14
12
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
15
13
|
|
|
16
14
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
@@ -21,9 +19,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
21
19
|
|
|
22
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
23
21
|
|
|
24
|
-
var _useTheme = _interopRequireDefault(require("../useTheme
|
|
25
|
-
|
|
26
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
22
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
27
23
|
|
|
28
24
|
var _variables = require("../common/variables.js");
|
|
29
25
|
|
|
@@ -31,9 +27,9 @@ var _utils = require("../common/utils.js");
|
|
|
31
27
|
|
|
32
28
|
var _uuid = require("uuid");
|
|
33
29
|
|
|
34
|
-
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext
|
|
30
|
+
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
35
31
|
|
|
36
|
-
var _NumberInputContext = _interopRequireDefault(require("../number-input/NumberInputContext
|
|
32
|
+
var _NumberInputContext = _interopRequireDefault(require("../number-input/NumberInputContext"));
|
|
37
33
|
|
|
38
34
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
|
|
39
35
|
|
|
@@ -114,10 +110,6 @@ var getNotOptionalErrorMessage = function getNotOptionalErrorMessage() {
|
|
|
114
110
|
return "This field is required. Please, enter a value.";
|
|
115
111
|
};
|
|
116
112
|
|
|
117
|
-
var getLengthErrorMessage = function getLengthErrorMessage(length) {
|
|
118
|
-
return "Min length ".concat(length.min, ", max length ").concat(length.max, ".");
|
|
119
|
-
};
|
|
120
|
-
|
|
121
113
|
var getPatternErrorMessage = function getPatternErrorMessage() {
|
|
122
114
|
return "Please match the format requested.";
|
|
123
115
|
};
|
|
@@ -140,15 +132,11 @@ var getLastOptionIndex = function getLastOptionIndex(filteredSuggestions) {
|
|
|
140
132
|
};
|
|
141
133
|
|
|
142
134
|
var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
143
|
-
var
|
|
144
|
-
|
|
145
|
-
var _ref$label = _ref.label,
|
|
146
|
-
label = _ref$label === void 0 ? "" : _ref$label,
|
|
135
|
+
var label = _ref.label,
|
|
147
136
|
_ref$name = _ref.name,
|
|
148
137
|
name = _ref$name === void 0 ? "" : _ref$name,
|
|
149
138
|
value = _ref.value,
|
|
150
|
-
|
|
151
|
-
helperText = _ref$helperText === void 0 ? "" : _ref$helperText,
|
|
139
|
+
helperText = _ref.helperText,
|
|
152
140
|
_ref$placeholder = _ref.placeholder,
|
|
153
141
|
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
154
142
|
action = _ref.action,
|
|
@@ -164,11 +152,11 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
164
152
|
suffix = _ref$suffix === void 0 ? "" : _ref$suffix,
|
|
165
153
|
onChange = _ref.onChange,
|
|
166
154
|
onBlur = _ref.onBlur,
|
|
167
|
-
|
|
168
|
-
error = _ref$error === void 0 ? "" : _ref$error,
|
|
155
|
+
error = _ref.error,
|
|
169
156
|
suggestions = _ref.suggestions,
|
|
170
157
|
pattern = _ref.pattern,
|
|
171
|
-
|
|
158
|
+
minLength = _ref.minLength,
|
|
159
|
+
maxLength = _ref.maxLength,
|
|
172
160
|
_ref$autocomplete = _ref.autocomplete,
|
|
173
161
|
autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
|
|
174
162
|
margin = _ref.margin,
|
|
@@ -228,7 +216,11 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
228
216
|
};
|
|
229
217
|
|
|
230
218
|
var isLengthIncorrect = function isLengthIncorrect(value) {
|
|
231
|
-
return value &&
|
|
219
|
+
return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
var getLengthErrorMessage = function getLengthErrorMessage() {
|
|
223
|
+
return "Min length ".concat(minLength, ", max length ").concat(maxLength, ".");
|
|
232
224
|
};
|
|
233
225
|
|
|
234
226
|
var isNumberIncorrect = function isNumberIncorrect(value) {
|
|
@@ -266,7 +258,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
266
258
|
error: getNotOptionalErrorMessage()
|
|
267
259
|
});else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
268
260
|
value: changedValue,
|
|
269
|
-
error: getLengthErrorMessage(
|
|
261
|
+
error: getLengthErrorMessage()
|
|
270
262
|
});else if (newValue && pattern && !patternMatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
271
263
|
value: changedValue,
|
|
272
264
|
error: getPatternErrorMessage()
|
|
@@ -300,7 +292,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
300
292
|
error: getNotOptionalErrorMessage()
|
|
301
293
|
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
302
294
|
value: event.target.value,
|
|
303
|
-
error: getLengthErrorMessage(
|
|
295
|
+
error: getLengthErrorMessage()
|
|
304
296
|
});else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
305
297
|
value: event.target.value,
|
|
306
298
|
error: getPatternErrorMessage()
|
|
@@ -317,7 +309,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
317
309
|
switch (event.keyCode) {
|
|
318
310
|
case 40:
|
|
319
311
|
// Arrow Down
|
|
320
|
-
if (numberInputContext) {
|
|
312
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
321
313
|
decrementNumber();
|
|
322
314
|
event.preventDefault();
|
|
323
315
|
} else {
|
|
@@ -335,7 +327,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
335
327
|
|
|
336
328
|
case 38:
|
|
337
329
|
// Arrow Up
|
|
338
|
-
if (numberInputContext) {
|
|
330
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
339
331
|
incrementNumber();
|
|
340
332
|
event.preventDefault();
|
|
341
333
|
} else {
|
|
@@ -474,7 +466,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
474
466
|
changeVisualFocusedSuggIndex(-1);
|
|
475
467
|
}
|
|
476
468
|
|
|
477
|
-
numberInputContext && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
469
|
+
(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
478
470
|
}, [value, innerValue, suggestions, numberInputContext]);
|
|
479
471
|
|
|
480
472
|
var HighlightedSuggestion = function HighlightedSuggestion(_ref2) {
|
|
@@ -505,11 +497,12 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
505
497
|
margin: margin,
|
|
506
498
|
ref: ref,
|
|
507
499
|
size: size
|
|
508
|
-
}, /*#__PURE__*/_react["default"].createElement(Label, {
|
|
500
|
+
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
509
501
|
htmlFor: inputId,
|
|
510
502
|
disabled: disabled,
|
|
511
|
-
backgroundType: backgroundType
|
|
512
|
-
|
|
503
|
+
backgroundType: backgroundType,
|
|
504
|
+
helperText: helperText
|
|
505
|
+
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, "(Optional)")), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
513
506
|
disabled: disabled,
|
|
514
507
|
backgroundType: backgroundType
|
|
515
508
|
}, helperText), /*#__PURE__*/_react["default"].createElement(InputContainer, {
|
|
@@ -539,8 +532,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
539
532
|
ref: inputRef,
|
|
540
533
|
backgroundType: backgroundType,
|
|
541
534
|
pattern: pattern,
|
|
542
|
-
minLength:
|
|
543
|
-
maxLength:
|
|
535
|
+
minLength: minLength,
|
|
536
|
+
maxLength: maxLength,
|
|
544
537
|
autoComplete: autocomplete,
|
|
545
538
|
tabIndex: tabIndex,
|
|
546
539
|
role: isTextInputType() && hasSuggestions() ? "combobox" : "textbox",
|
|
@@ -561,7 +554,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
561
554
|
},
|
|
562
555
|
backgroundType: backgroundType,
|
|
563
556
|
tabIndex: tabIndex,
|
|
564
|
-
|
|
557
|
+
title: "Clear field",
|
|
558
|
+
"aria-label": "Clear field"
|
|
565
559
|
}, textInputIcons.clear), (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(Action, {
|
|
566
560
|
ref: actionRef,
|
|
567
561
|
disabled: disabled,
|
|
@@ -571,7 +565,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
571
565
|
},
|
|
572
566
|
backgroundType: backgroundType,
|
|
573
567
|
tabIndex: tabIndex,
|
|
574
|
-
|
|
568
|
+
title: "Decrement value",
|
|
569
|
+
"aria-label": "Decrement value"
|
|
575
570
|
}, textInputIcons.decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
576
571
|
ref: actionRef,
|
|
577
572
|
disabled: disabled,
|
|
@@ -581,7 +576,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
581
576
|
},
|
|
582
577
|
backgroundType: backgroundType,
|
|
583
578
|
tabIndex: tabIndex,
|
|
584
|
-
|
|
579
|
+
title: "Increment value",
|
|
580
|
+
"aria-label": "Increment value"
|
|
585
581
|
}, textInputIcons.increment)) : action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
586
582
|
ref: actionRef,
|
|
587
583
|
disabled: disabled,
|
|
@@ -589,7 +585,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
589
585
|
onMouseDown: function onMouseDown(event) {
|
|
590
586
|
event.stopPropagation();
|
|
591
587
|
},
|
|
592
|
-
title:
|
|
588
|
+
title: action.title,
|
|
589
|
+
"aria-label": action.title,
|
|
593
590
|
backgroundType: backgroundType,
|
|
594
591
|
tabIndex: tabIndex
|
|
595
592
|
}, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement(ActionIcon, {
|
|
@@ -614,7 +611,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
614
611
|
});
|
|
615
612
|
}), isSearching && /*#__PURE__*/_react["default"].createElement(SuggestionsSystemMessage, null, "Searching..."), isAutosuggestError && /*#__PURE__*/_react["default"].createElement(SuggestionsError, null, /*#__PURE__*/_react["default"].createElement(SuggestionsErrorIcon, {
|
|
616
613
|
backgroundType: backgroundType
|
|
617
|
-
}, textInputIcons.error), "Error fetching data"))), !disabled && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
614
|
+
}, textInputIcons.error), "Error fetching data"))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
618
615
|
id: errorId,
|
|
619
616
|
backgroundType: backgroundType
|
|
620
617
|
}, error)));
|
|
@@ -645,7 +642,7 @@ var DxcInput = _styledComponents["default"].div(_templateObject || (_templateObj
|
|
|
645
642
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
646
643
|
});
|
|
647
644
|
|
|
648
|
-
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"])), function (props) {
|
|
645
|
+
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) {
|
|
649
646
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledLabelFontColorOnDark : props.theme.disabledLabelFontColor : props.backgroundType === "dark" ? props.theme.labelFontColorOnDark : props.theme.labelFontColor;
|
|
650
647
|
}, function (props) {
|
|
651
648
|
return props.theme.fontFamily;
|
|
@@ -657,13 +654,15 @@ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObj
|
|
|
657
654
|
return props.theme.labelFontWeight;
|
|
658
655
|
}, function (props) {
|
|
659
656
|
return props.theme.labelLineHeight;
|
|
657
|
+
}, function (props) {
|
|
658
|
+
return !props.helperText && "margin-bottom: 0.25rem";
|
|
660
659
|
});
|
|
661
660
|
|
|
662
661
|
var OptionalLabel = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: ", ";\n"])), function (props) {
|
|
663
662
|
return props.theme.optionalLabelFontWeight;
|
|
664
663
|
});
|
|
665
664
|
|
|
666
|
-
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"])), function (props) {
|
|
665
|
+
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) {
|
|
667
666
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledHelperTextFontColorOnDark : props.theme.disabledHelperTextFontColor : props.backgroundType === "dark" ? props.theme.helperTextFontColorOnDark : props.theme.helperTextFontColor;
|
|
668
667
|
}, function (props) {
|
|
669
668
|
return props.theme.fontFamily;
|
|
@@ -677,9 +676,7 @@ var HelperText = _styledComponents["default"].span(_templateObject4 || (_templat
|
|
|
677
676
|
return props.theme.helperTextLineHeight;
|
|
678
677
|
});
|
|
679
678
|
|
|
680
|
-
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
|
|
681
|
-
return "".concat(props.theme.inputMarginTop, " 0 ").concat(props.theme.inputMarginBottom, " 0");
|
|
682
|
-
}, function (props) {
|
|
679
|
+
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) {
|
|
683
680
|
if (props.disabled) return props.backgroundType === "dark" ? "background-color: ".concat(props.theme.disabledContainerFillColorOnDark, ";") : "background-color: ".concat(props.theme.disabledContainerFillColor, ";");
|
|
684
681
|
}, function (props) {
|
|
685
682
|
if (props.disabled) return props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;else return props.backgroundType === "dark" ? props.theme.enabledBorderColorOnDark : props.theme.enabledBorderColor;
|
|
@@ -691,7 +688,7 @@ var InputContainer = _styledComponents["default"].div(_templateObject5 || (_temp
|
|
|
691
688
|
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 ");
|
|
692
689
|
});
|
|
693
690
|
|
|
694
|
-
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\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.5em;\n ", "\n\n ::placeholder {\n color: ", ";\n }\n"])), function (props) {
|
|
691
|
+
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) {
|
|
695
692
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledValueFontColorOnDark : props.theme.disabledValueFontColor : props.backgroundType === "dark" ? props.theme.valueFontColorOnDark : props.theme.valueFontColor;
|
|
696
693
|
}, function (props) {
|
|
697
694
|
return props.theme.fontFamily;
|
|
@@ -739,7 +736,7 @@ var ErrorIcon = _styledComponents["default"].span(_templateObject11 || (_templat
|
|
|
739
736
|
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
740
737
|
});
|
|
741
738
|
|
|
742
|
-
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"])), function (props) {
|
|
739
|
+
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) {
|
|
743
740
|
return props.backgroundType === "dark" ? props.theme.errorMessageColorOnDark : props.theme.errorMessageColor;
|
|
744
741
|
}, function (props) {
|
|
745
742
|
return props.theme.fontFamily;
|
|
@@ -761,7 +758,7 @@ var Suggestions = _styledComponents["default"].ul(_templateObject13 || (_templat
|
|
|
761
758
|
return props.theme.listOptionFontWeight;
|
|
762
759
|
});
|
|
763
760
|
|
|
764
|
-
var Suggestion = _styledComponents["default"].li(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\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) {
|
|
761
|
+
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) {
|
|
765
762
|
return props.visualFocused ? props.theme.focusListOptionBorderColor : "transparent";
|
|
766
763
|
}, function (props) {
|
|
767
764
|
return props.theme.hoverListOptionBackgroundColor;
|
|
@@ -769,7 +766,7 @@ var Suggestion = _styledComponents["default"].li(_templateObject14 || (_template
|
|
|
769
766
|
return props.theme.activeListOptionBackgroundColor;
|
|
770
767
|
});
|
|
771
768
|
|
|
772
|
-
var StyledSuggestion = _styledComponents["default"].span(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
769
|
+
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) {
|
|
773
770
|
return props.last || props.visualFocused ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
|
|
774
771
|
});
|
|
775
772
|
|
|
@@ -785,41 +782,5 @@ var SuggestionsError = _styledComponents["default"].span(_templateObject18 || (_
|
|
|
785
782
|
return props.theme.errorListDialogFontColor;
|
|
786
783
|
});
|
|
787
784
|
|
|
788
|
-
DxcTextInput.propTypes = {
|
|
789
|
-
label: _propTypes["default"].string,
|
|
790
|
-
name: _propTypes["default"].string,
|
|
791
|
-
value: _propTypes["default"].string,
|
|
792
|
-
helperText: _propTypes["default"].string,
|
|
793
|
-
placeholder: _propTypes["default"].string,
|
|
794
|
-
action: _propTypes["default"].shape({
|
|
795
|
-
onClick: _propTypes["default"].func.isRequired,
|
|
796
|
-
icon: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
797
|
-
type: _propTypes["default"].oneOf(["svg"])
|
|
798
|
-
}), _propTypes["default"].string]).isRequired
|
|
799
|
-
}),
|
|
800
|
-
clearable: _propTypes["default"].bool,
|
|
801
|
-
disabled: _propTypes["default"].bool,
|
|
802
|
-
optional: _propTypes["default"].bool,
|
|
803
|
-
prefix: _propTypes["default"].string,
|
|
804
|
-
suffix: _propTypes["default"].string,
|
|
805
|
-
onChange: _propTypes["default"].func,
|
|
806
|
-
onBlur: _propTypes["default"].func,
|
|
807
|
-
error: _propTypes["default"].string,
|
|
808
|
-
autocomplete: _propTypes["default"].string,
|
|
809
|
-
margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
810
|
-
top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
811
|
-
bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
812
|
-
left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
813
|
-
right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
|
|
814
|
-
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
|
|
815
|
-
size: _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(sizes))),
|
|
816
|
-
suggestions: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].array]),
|
|
817
|
-
pattern: _propTypes["default"].string,
|
|
818
|
-
length: _propTypes["default"].shape({
|
|
819
|
-
min: _propTypes["default"].number,
|
|
820
|
-
max: _propTypes["default"].number
|
|
821
|
-
}),
|
|
822
|
-
tabIndex: _propTypes["default"].number
|
|
823
|
-
};
|
|
824
785
|
var _default = DxcTextInput;
|
|
825
786
|
exports["default"] = _default;
|