@dxc-technology/halstack-react 0.0.0-bfdc357 → 0.0.0-c1c5f49
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/alert/types.d.ts +1 -1
- package/button/Button.d.ts +1 -1
- package/button/Button.js +4 -2
- package/button/types.d.ts +2 -2
- package/card/Card.stories.tsx +201 -0
- package/card/ice-cream.jpg +0 -0
- package/card/types.d.ts +4 -6
- package/checkbox/types.d.ts +1 -1
- package/common/variables.js +3 -2
- package/file-input/FileInput.js +22 -22
- package/file-input/FileItem.js +5 -3
- package/header/types.d.ts +4 -2
- package/heading/Heading.stories.tsx +53 -0
- 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/password-input/PasswordInput.js +4 -2
- package/password-input/types.d.ts +17 -10
- package/radio/types.d.ts +2 -2
- package/resultsetTable/ResultsetTable.d.ts +4 -0
- package/resultsetTable/ResultsetTable.js +3 -26
- package/resultsetTable/types.d.ts +67 -0
- package/resultsetTable/types.js +5 -0
- package/select/Select.js +1 -1
- package/sidenav/Sidenav.stories.tsx +165 -0
- package/slider/Slider.js +2 -2
- package/table/Table.js +1 -1
- package/tabs/Tabs.js +3 -1
- package/tabs/Tabs.stories.tsx +121 -0
- package/tabs/types.d.ts +2 -3
- package/text-input/TextInput.d.ts +4 -0
- package/text-input/TextInput.js +18 -57
- 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 +13 -14
- package/textarea/index.d.ts +18 -8
- package/toggle-group/ToggleGroup.d.ts +4 -0
- package/toggle-group/ToggleGroup.js +5 -31
- package/toggle-group/types.d.ts +84 -0
- package/toggle-group/types.js +5 -0
- package/resultsetTable/index.d.ts +0 -19
- package/text-input/index.d.ts +0 -135
- package/toggle-group/index.d.ts +0 -21
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"));
|
|
@@ -23,8 +21,6 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
23
21
|
|
|
24
22
|
var _useTheme = _interopRequireDefault(require("../useTheme.js"));
|
|
25
23
|
|
|
26
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
-
|
|
28
24
|
var _variables = require("../common/variables.js");
|
|
29
25
|
|
|
30
26
|
var _utils = require("../common/utils.js");
|
|
@@ -33,7 +29,7 @@ var _uuid = require("uuid");
|
|
|
33
29
|
|
|
34
30
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext.js"));
|
|
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
|
};
|
|
@@ -168,7 +160,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
168
160
|
error = _ref$error === void 0 ? "" : _ref$error,
|
|
169
161
|
suggestions = _ref.suggestions,
|
|
170
162
|
pattern = _ref.pattern,
|
|
171
|
-
|
|
163
|
+
minLength = _ref.minLength,
|
|
164
|
+
maxLength = _ref.maxLength,
|
|
172
165
|
_ref$autocomplete = _ref.autocomplete,
|
|
173
166
|
autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
|
|
174
167
|
margin = _ref.margin,
|
|
@@ -228,7 +221,11 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
228
221
|
};
|
|
229
222
|
|
|
230
223
|
var isLengthIncorrect = function isLengthIncorrect(value) {
|
|
231
|
-
return value &&
|
|
224
|
+
return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
var getLengthErrorMessage = function getLengthErrorMessage() {
|
|
228
|
+
return "Min length ".concat(minLength, ", max length ").concat(maxLength, ".");
|
|
232
229
|
};
|
|
233
230
|
|
|
234
231
|
var isNumberIncorrect = function isNumberIncorrect(value) {
|
|
@@ -266,7 +263,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
266
263
|
error: getNotOptionalErrorMessage()
|
|
267
264
|
});else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
268
265
|
value: changedValue,
|
|
269
|
-
error: getLengthErrorMessage(
|
|
266
|
+
error: getLengthErrorMessage()
|
|
270
267
|
});else if (newValue && pattern && !patternMatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
271
268
|
value: changedValue,
|
|
272
269
|
error: getPatternErrorMessage()
|
|
@@ -300,7 +297,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
300
297
|
error: getNotOptionalErrorMessage()
|
|
301
298
|
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
302
299
|
value: event.target.value,
|
|
303
|
-
error: getLengthErrorMessage(
|
|
300
|
+
error: getLengthErrorMessage()
|
|
304
301
|
});else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
305
302
|
value: event.target.value,
|
|
306
303
|
error: getPatternErrorMessage()
|
|
@@ -317,7 +314,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
317
314
|
switch (event.keyCode) {
|
|
318
315
|
case 40:
|
|
319
316
|
// Arrow Down
|
|
320
|
-
if (numberInputContext) {
|
|
317
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
321
318
|
decrementNumber();
|
|
322
319
|
event.preventDefault();
|
|
323
320
|
} else {
|
|
@@ -335,7 +332,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
335
332
|
|
|
336
333
|
case 38:
|
|
337
334
|
// Arrow Up
|
|
338
|
-
if (numberInputContext) {
|
|
335
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
339
336
|
incrementNumber();
|
|
340
337
|
event.preventDefault();
|
|
341
338
|
} else {
|
|
@@ -474,7 +471,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
474
471
|
changeVisualFocusedSuggIndex(-1);
|
|
475
472
|
}
|
|
476
473
|
|
|
477
|
-
numberInputContext && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
474
|
+
(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
478
475
|
}, [value, innerValue, suggestions, numberInputContext]);
|
|
479
476
|
|
|
480
477
|
var HighlightedSuggestion = function HighlightedSuggestion(_ref2) {
|
|
@@ -539,8 +536,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
539
536
|
ref: inputRef,
|
|
540
537
|
backgroundType: backgroundType,
|
|
541
538
|
pattern: pattern,
|
|
542
|
-
minLength:
|
|
543
|
-
maxLength:
|
|
539
|
+
minLength: minLength,
|
|
540
|
+
maxLength: maxLength,
|
|
544
541
|
autoComplete: autocomplete,
|
|
545
542
|
tabIndex: tabIndex,
|
|
546
543
|
role: isTextInputType() && hasSuggestions() ? "combobox" : "textbox",
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { userEvent, within, waitFor } from "@storybook/testing-library";
|
|
3
|
+
import { fireEvent } from "@testing-library/react";
|
|
4
|
+
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
5
|
+
import Title from "../../.storybook/components/Title";
|
|
6
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
7
|
+
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
8
|
+
import DxcTextInput from "./TextInput";
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: "Text input",
|
|
12
|
+
component: DxcTextInput,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const action = {
|
|
16
|
+
onClick: () => {},
|
|
17
|
+
icon: (
|
|
18
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
|
19
|
+
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
20
|
+
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" />
|
|
21
|
+
</svg>
|
|
22
|
+
),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const actionLargeIcon = {
|
|
26
|
+
onClick: () => {},
|
|
27
|
+
icon: (
|
|
28
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="currentColor">
|
|
29
|
+
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
30
|
+
<path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z" />
|
|
31
|
+
</svg>
|
|
32
|
+
),
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const country = ["Afghanistan"];
|
|
36
|
+
const countries = [
|
|
37
|
+
"Afghanistan",
|
|
38
|
+
"Albania",
|
|
39
|
+
"Algeria",
|
|
40
|
+
"Andorra Andorra Andorra Andorra Andorra Andorra Andorra Andorra",
|
|
41
|
+
"Angola",
|
|
42
|
+
"Antigua and Barbuda Antigua and Barbuda Antigua and Barbuda",
|
|
43
|
+
"Bahamas",
|
|
44
|
+
"Bahrain",
|
|
45
|
+
"Bangladesh",
|
|
46
|
+
"Barbados",
|
|
47
|
+
"Cabo Verde",
|
|
48
|
+
"Cambodia",
|
|
49
|
+
"Cameroon",
|
|
50
|
+
"Canada",
|
|
51
|
+
"Cayman Islands, The",
|
|
52
|
+
"Central African Republic",
|
|
53
|
+
"Chad",
|
|
54
|
+
"Democratic Republic of the Congo",
|
|
55
|
+
"Dominican Republic",
|
|
56
|
+
"Dominica",
|
|
57
|
+
"Denmark",
|
|
58
|
+
"Djibouti",
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
export const Chromatic = () => (
|
|
62
|
+
<>
|
|
63
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
64
|
+
<Title title="Hovered input" theme="light" level={4} />
|
|
65
|
+
<DxcTextInput label="Text input" />
|
|
66
|
+
</ExampleContainer>
|
|
67
|
+
<ExampleContainer pseudoState="pseudo-focus-within">
|
|
68
|
+
<Title title="Focused input" theme="light" level={4} />
|
|
69
|
+
<DxcTextInput label="Text input" />
|
|
70
|
+
</ExampleContainer>
|
|
71
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
72
|
+
<Title title="Hovered action" theme="light" level={4} />
|
|
73
|
+
<DxcTextInput label="Text input" value="Text" clearable />
|
|
74
|
+
</ExampleContainer>
|
|
75
|
+
<ExampleContainer>
|
|
76
|
+
<Title title="Without label" theme="light" level={4} />
|
|
77
|
+
<DxcTextInput />
|
|
78
|
+
</ExampleContainer>
|
|
79
|
+
<ExampleContainer>
|
|
80
|
+
<Title title="With label and placeholder" theme="light" level={4} />
|
|
81
|
+
<DxcTextInput label="Text input" placeholder="Placeholder" />
|
|
82
|
+
</ExampleContainer>
|
|
83
|
+
<ExampleContainer>
|
|
84
|
+
<Title title="Helper text, optional, and clearable" theme="light" level={4} />
|
|
85
|
+
<DxcTextInput label="Text input" clearable value="Text" helperText="Help message" optional />
|
|
86
|
+
</ExampleContainer>
|
|
87
|
+
<ExampleContainer>
|
|
88
|
+
<Title title="Clearable and large icon action" theme="light" level={4} />
|
|
89
|
+
<DxcTextInput
|
|
90
|
+
label="Text input"
|
|
91
|
+
value="Text text text text text text text text text text"
|
|
92
|
+
clearable
|
|
93
|
+
action={actionLargeIcon}
|
|
94
|
+
/>
|
|
95
|
+
</ExampleContainer>
|
|
96
|
+
<ExampleContainer>
|
|
97
|
+
<Title title="Prefix" theme="light" level={4} />
|
|
98
|
+
<DxcTextInput label="With prefix" prefix="+34" />
|
|
99
|
+
</ExampleContainer>
|
|
100
|
+
<ExampleContainer>
|
|
101
|
+
<Title title="Suffix and action" theme="light" level={4} />
|
|
102
|
+
<DxcTextInput label="With suffix" suffix="USD" action={action} />
|
|
103
|
+
</ExampleContainer>
|
|
104
|
+
<ExampleContainer>
|
|
105
|
+
<Title title="Invalid" theme="light" level={4} />
|
|
106
|
+
<DxcTextInput
|
|
107
|
+
label="Error text input"
|
|
108
|
+
helperText="Help message"
|
|
109
|
+
error="Error message."
|
|
110
|
+
value="Text"
|
|
111
|
+
clearable
|
|
112
|
+
optional
|
|
113
|
+
action={action}
|
|
114
|
+
/>
|
|
115
|
+
</ExampleContainer>
|
|
116
|
+
<ExampleContainer>
|
|
117
|
+
<Title title="Disabled and placeholder" theme="light" level={4} />
|
|
118
|
+
<DxcTextInput label="Disabled text input" disabled placeholder="Placeholder" />
|
|
119
|
+
</ExampleContainer>
|
|
120
|
+
<ExampleContainer>
|
|
121
|
+
<Title title="Disabled, helper text, optional, value and action" theme="light" level={4} />
|
|
122
|
+
<DxcTextInput
|
|
123
|
+
label="Disabled text input"
|
|
124
|
+
helperText="Help message"
|
|
125
|
+
disabled
|
|
126
|
+
optional
|
|
127
|
+
value="Text"
|
|
128
|
+
action={action}
|
|
129
|
+
/>
|
|
130
|
+
</ExampleContainer>
|
|
131
|
+
<ExampleContainer>
|
|
132
|
+
<Title title="Disabled with prefix and suffix" theme="light" level={4} />
|
|
133
|
+
<DxcTextInput
|
|
134
|
+
label="Disabled text input"
|
|
135
|
+
helperText="Help message"
|
|
136
|
+
disabled
|
|
137
|
+
optional
|
|
138
|
+
prefix="+34"
|
|
139
|
+
suffix="USD"
|
|
140
|
+
value="Text"
|
|
141
|
+
action={action}
|
|
142
|
+
/>
|
|
143
|
+
</ExampleContainer>
|
|
144
|
+
<BackgroundColorProvider color="#333333">
|
|
145
|
+
<DarkContainer>
|
|
146
|
+
<Title title="Dark" theme="dark" level={2} />
|
|
147
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
148
|
+
<Title title="Hovered" theme="dark" level={4} />
|
|
149
|
+
<DxcTextInput label="Text input" />
|
|
150
|
+
</ExampleContainer>
|
|
151
|
+
<ExampleContainer pseudoState="pseudo-focus-within">
|
|
152
|
+
<Title title="Focused" theme="dark" level={4} />
|
|
153
|
+
<DxcTextInput label="Text input" />
|
|
154
|
+
</ExampleContainer>
|
|
155
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
156
|
+
<Title title="Hovered action" theme="dark" level={4} />
|
|
157
|
+
<DxcTextInput label="Text input" value="Text" clearable />
|
|
158
|
+
</ExampleContainer>
|
|
159
|
+
<ExampleContainer>
|
|
160
|
+
<Title title="Helper text, placeholder, optional and action" theme="dark" level={4} />
|
|
161
|
+
<DxcTextInput
|
|
162
|
+
label="Text input"
|
|
163
|
+
helperText="Help message"
|
|
164
|
+
placeholder="Placeholder"
|
|
165
|
+
clearable
|
|
166
|
+
optional
|
|
167
|
+
action={action}
|
|
168
|
+
/>
|
|
169
|
+
</ExampleContainer>
|
|
170
|
+
<ExampleContainer>
|
|
171
|
+
<Title title="Helper text, clearable value, error and action" theme="dark" level={4} />
|
|
172
|
+
<DxcTextInput
|
|
173
|
+
label="Text input"
|
|
174
|
+
helperText="Help message"
|
|
175
|
+
error="Error message."
|
|
176
|
+
value="Text"
|
|
177
|
+
clearable
|
|
178
|
+
action={action}
|
|
179
|
+
/>
|
|
180
|
+
</ExampleContainer>
|
|
181
|
+
<ExampleContainer>
|
|
182
|
+
<Title title="Prefix and suffix" theme="dark" level={4} />
|
|
183
|
+
<DxcTextInput label="With prefix and suffix" prefix="+34" suffix="USD" />
|
|
184
|
+
</ExampleContainer>
|
|
185
|
+
<ExampleContainer>
|
|
186
|
+
<Title title="Disabled and placeholder" theme="dark" level={4} />
|
|
187
|
+
<DxcTextInput label="Disabled text input" disabled placeholder="Placeholder" />
|
|
188
|
+
</ExampleContainer>
|
|
189
|
+
<ExampleContainer>
|
|
190
|
+
<Title title="Disabled, helper text, optional, value and action" theme="dark" level={4} />
|
|
191
|
+
<DxcTextInput
|
|
192
|
+
label="Disabled text input"
|
|
193
|
+
helperText="Help message"
|
|
194
|
+
disabled
|
|
195
|
+
optional
|
|
196
|
+
value="Text"
|
|
197
|
+
action={action}
|
|
198
|
+
/>
|
|
199
|
+
</ExampleContainer>
|
|
200
|
+
<ExampleContainer>
|
|
201
|
+
<Title title="Disabled with prefix and suffix" theme="dark" level={4} />
|
|
202
|
+
<DxcTextInput
|
|
203
|
+
label="Disabled text input"
|
|
204
|
+
helperText="Help message"
|
|
205
|
+
disabled
|
|
206
|
+
optional
|
|
207
|
+
prefix="+34"
|
|
208
|
+
suffix="USD"
|
|
209
|
+
value="Text"
|
|
210
|
+
action={action}
|
|
211
|
+
/>
|
|
212
|
+
</ExampleContainer>
|
|
213
|
+
</DarkContainer>
|
|
214
|
+
</BackgroundColorProvider>
|
|
215
|
+
<Title title="Margins" theme="light" level={2} />
|
|
216
|
+
<ExampleContainer>
|
|
217
|
+
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
218
|
+
<DxcTextInput label="Xxsmall" margin="xxsmall" />
|
|
219
|
+
</ExampleContainer>
|
|
220
|
+
<ExampleContainer>
|
|
221
|
+
<Title title="Xsmall margin" theme="light" level={4} />
|
|
222
|
+
<DxcTextInput label="Xsmall" margin="xsmall" />
|
|
223
|
+
</ExampleContainer>
|
|
224
|
+
<ExampleContainer>
|
|
225
|
+
<Title title="Small margin" theme="light" level={4} />
|
|
226
|
+
<DxcTextInput label="Small" margin="small" />
|
|
227
|
+
</ExampleContainer>
|
|
228
|
+
<ExampleContainer>
|
|
229
|
+
<Title title="Medium margin" theme="light" level={4} />
|
|
230
|
+
<DxcTextInput label="Medium" margin="medium" />
|
|
231
|
+
</ExampleContainer>
|
|
232
|
+
<ExampleContainer>
|
|
233
|
+
<Title title="Large margin" theme="light" level={4} />
|
|
234
|
+
<DxcTextInput label="Large" margin="large" />
|
|
235
|
+
</ExampleContainer>
|
|
236
|
+
<ExampleContainer>
|
|
237
|
+
<Title title="Xlarge margin" theme="light" level={4} />
|
|
238
|
+
<DxcTextInput label="Xlarge" margin="xlarge" />
|
|
239
|
+
</ExampleContainer>
|
|
240
|
+
<ExampleContainer>
|
|
241
|
+
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
242
|
+
<DxcTextInput label="Xxlarge" margin="xxlarge" />
|
|
243
|
+
</ExampleContainer>
|
|
244
|
+
<Title title="Sizes" theme="light" level={2} />
|
|
245
|
+
<ExampleContainer>
|
|
246
|
+
<Title title="Small size" theme="light" level={4} />
|
|
247
|
+
<DxcTextInput label="Small" size="small" />
|
|
248
|
+
</ExampleContainer>
|
|
249
|
+
<ExampleContainer>
|
|
250
|
+
<Title title="Medium size" theme="light" level={4} />
|
|
251
|
+
<DxcTextInput label="Medium" size="medium" />
|
|
252
|
+
</ExampleContainer>
|
|
253
|
+
<ExampleContainer>
|
|
254
|
+
<Title title="Large size" theme="light" level={4} />
|
|
255
|
+
<DxcTextInput label="Large" size="large" />
|
|
256
|
+
</ExampleContainer>
|
|
257
|
+
<ExampleContainer>
|
|
258
|
+
<Title title="FillParent size" theme="light" level={4} />
|
|
259
|
+
<DxcTextInput label="FillParent" size="fillParent" />
|
|
260
|
+
</ExampleContainer>
|
|
261
|
+
</>
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
const FocusedActionTextInput = () => (
|
|
265
|
+
<ExampleContainer>
|
|
266
|
+
<Title title="Focused action" theme="light" level={4} />
|
|
267
|
+
<DxcTextInput label="Text input" action={action} clearable />
|
|
268
|
+
</ExampleContainer>
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
const ActivedActionTextInput = () => (
|
|
272
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
273
|
+
<Title title="Actived action" theme="light" level={4} />
|
|
274
|
+
<DxcTextInput label="Text input" action={action} clearable />
|
|
275
|
+
</ExampleContainer>
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
const ShowOptionsAutosuggest = () => (
|
|
279
|
+
<ExampleContainer expanded>
|
|
280
|
+
<Title title="Show options" theme="light" level={4} />
|
|
281
|
+
<DxcTextInput label="Text input" suggestions={countries} clearable />
|
|
282
|
+
</ExampleContainer>
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
const HoveredOptionAutosuggest = () => (
|
|
286
|
+
<ExampleContainer expanded pseudoState="pseudo-hover">
|
|
287
|
+
<Title title="Hovered option" theme="light" level={4} />
|
|
288
|
+
<DxcTextInput label="Text input" suggestions={country} clearable />
|
|
289
|
+
</ExampleContainer>
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
const FocusedOptionAutosuggest = () => (
|
|
293
|
+
<ExampleContainer expanded>
|
|
294
|
+
<Title title="Focused option" theme="light" level={4} />
|
|
295
|
+
<DxcTextInput label="Text input" suggestions={country} clearable />
|
|
296
|
+
</ExampleContainer>
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
const ActivedOptionAutosuggest = () => (
|
|
300
|
+
<ExampleContainer expanded pseudoState="pseudo-active">
|
|
301
|
+
<Title title="Actived option" theme="light" level={4} />
|
|
302
|
+
<DxcTextInput label="Text input" suggestions={country} clearable />
|
|
303
|
+
</ExampleContainer>
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
const FocusedActionTextInputOnDark = () => (
|
|
307
|
+
<BackgroundColorProvider color="#333333">
|
|
308
|
+
<DarkContainer>
|
|
309
|
+
<ExampleContainer>
|
|
310
|
+
<Title title="Focused action" theme="dark" level={4} />
|
|
311
|
+
<DxcTextInput label="Text input" action={action} clearable />
|
|
312
|
+
</ExampleContainer>
|
|
313
|
+
</DarkContainer>
|
|
314
|
+
</BackgroundColorProvider>
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
const ActivedActionTextInputOnDark = () => (
|
|
318
|
+
<BackgroundColorProvider color="#333333">
|
|
319
|
+
<DarkContainer>
|
|
320
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
321
|
+
<Title title="Actived action" theme="dark" level={4} />
|
|
322
|
+
<DxcTextInput label="Text input" action={action} clearable />
|
|
323
|
+
</ExampleContainer>
|
|
324
|
+
</DarkContainer>
|
|
325
|
+
</BackgroundColorProvider>
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
const ShowOptionsAutosuggestOnDark = () => (
|
|
329
|
+
<BackgroundColorProvider color="#333333">
|
|
330
|
+
<DarkContainer>
|
|
331
|
+
<ExampleContainer expanded>
|
|
332
|
+
<Title title="Show options" theme="dark" level={4} />
|
|
333
|
+
<DxcTextInput label="Text input" suggestions={countries} clearable />
|
|
334
|
+
</ExampleContainer>
|
|
335
|
+
</DarkContainer>
|
|
336
|
+
</BackgroundColorProvider>
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
const HoveredActionAutosuggestOnDark = () => (
|
|
340
|
+
<BackgroundColorProvider color="#333333">
|
|
341
|
+
<DarkContainer>
|
|
342
|
+
<ExampleContainer expanded pseudoState="pseudo-hover">
|
|
343
|
+
<Title title="Hovered option" theme="dark" level={4} />
|
|
344
|
+
<DxcTextInput label="Text input" suggestions={country} clearable />
|
|
345
|
+
</ExampleContainer>
|
|
346
|
+
</DarkContainer>
|
|
347
|
+
</BackgroundColorProvider>
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
const FocusedOptionAutosuggestOnDark = () => (
|
|
351
|
+
<BackgroundColorProvider color="#333333">
|
|
352
|
+
<DarkContainer>
|
|
353
|
+
<ExampleContainer expanded>
|
|
354
|
+
<Title title="Focused option" theme="dark" level={4} />
|
|
355
|
+
<DxcTextInput label="Text input" suggestions={country} clearable />
|
|
356
|
+
</ExampleContainer>
|
|
357
|
+
</DarkContainer>
|
|
358
|
+
</BackgroundColorProvider>
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
const ActivedOptionAutosuggestOnDark = () => (
|
|
362
|
+
<BackgroundColorProvider color="#333333">
|
|
363
|
+
<DarkContainer>
|
|
364
|
+
<ExampleContainer expanded pseudoState="pseudo-active">
|
|
365
|
+
<Title title="Actived option" theme="dark" level={4} />
|
|
366
|
+
<DxcTextInput label="Text input" suggestions={country} clearable />
|
|
367
|
+
</ExampleContainer>
|
|
368
|
+
</DarkContainer>
|
|
369
|
+
</BackgroundColorProvider>
|
|
370
|
+
);
|
|
371
|
+
|
|
372
|
+
export const FocusedAction = FocusedActionTextInput.bind({});
|
|
373
|
+
FocusedAction.play = async ({ canvasElement }) => {
|
|
374
|
+
const canvas = within(canvasElement);
|
|
375
|
+
const action = canvas.getByRole("button");
|
|
376
|
+
await action.focus();
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
export const ActivedAction = ActivedActionTextInput.bind({});
|
|
380
|
+
ActivedAction.play = async ({ canvasElement }) => {
|
|
381
|
+
const canvas = within(canvasElement);
|
|
382
|
+
const action = canvas.getByRole("button");
|
|
383
|
+
await userEvent.click(action);
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
export const ShowOptions = ShowOptionsAutosuggest.bind({});
|
|
387
|
+
ShowOptions.play = async ({ canvasElement }) => {
|
|
388
|
+
const canvas = within(canvasElement);
|
|
389
|
+
const autosuggest = canvas.getByRole("combobox");
|
|
390
|
+
await userEvent.click(autosuggest);
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
export const HoveredOption = HoveredOptionAutosuggest.bind({});
|
|
394
|
+
HoveredOption.play = async ({ canvasElement }) => {
|
|
395
|
+
const canvas = within(canvasElement);
|
|
396
|
+
const autosuggest = canvas.getByRole("combobox");
|
|
397
|
+
await userEvent.click(autosuggest);
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
export const FocusedOption = FocusedOptionAutosuggest.bind({});
|
|
401
|
+
FocusedOption.play = async ({ canvasElement }) => {
|
|
402
|
+
const canvas = within(canvasElement);
|
|
403
|
+
const autosuggest = canvas.getByRole("combobox");
|
|
404
|
+
await userEvent.click(autosuggest);
|
|
405
|
+
fireEvent.keyDown(autosuggest, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
export const ActivedOption = ActivedOptionAutosuggest.bind({});
|
|
409
|
+
ActivedOption.play = async ({ canvasElement }) => {
|
|
410
|
+
const canvas = within(canvasElement);
|
|
411
|
+
const autosuggest = canvas.getByRole("combobox");
|
|
412
|
+
await userEvent.click(autosuggest);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
export const FocusedActionOnDark = FocusedActionTextInputOnDark.bind({});
|
|
416
|
+
FocusedActionOnDark.play = async ({ canvasElement }) => {
|
|
417
|
+
const canvas = within(canvasElement);
|
|
418
|
+
const action = canvas.getByRole("button");
|
|
419
|
+
await action.focus();
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
export const ActivedActionOnDark = ActivedActionTextInputOnDark.bind({});
|
|
423
|
+
ActivedActionOnDark.play = async ({ canvasElement }) => {
|
|
424
|
+
const canvas = within(canvasElement);
|
|
425
|
+
const action = canvas.getByRole("button");
|
|
426
|
+
await userEvent.click(action);
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
export const ShowOptionsOnDark = ShowOptionsAutosuggestOnDark.bind({});
|
|
430
|
+
ShowOptionsOnDark.play = async ({ canvasElement }) => {
|
|
431
|
+
const canvas = within(canvasElement);
|
|
432
|
+
const autosuggest = canvas.getByRole("combobox");
|
|
433
|
+
await userEvent.click(autosuggest);
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
export const HoveredActionOnDark = HoveredActionAutosuggestOnDark.bind({});
|
|
437
|
+
HoveredActionOnDark.play = async ({ canvasElement }) => {
|
|
438
|
+
const canvas = within(canvasElement);
|
|
439
|
+
const autosuggest = canvas.getByRole("combobox");
|
|
440
|
+
await userEvent.click(autosuggest);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
export const FocusedOptionOnDark = FocusedOptionAutosuggestOnDark.bind({});
|
|
444
|
+
FocusedOptionOnDark.play = async ({ canvasElement }) => {
|
|
445
|
+
const canvas = within(canvasElement);
|
|
446
|
+
const autosuggest = canvas.getByRole("combobox");
|
|
447
|
+
await userEvent.click(autosuggest);
|
|
448
|
+
fireEvent.keyDown(autosuggest, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
export const ActivedOptionOnDark = ActivedOptionAutosuggestOnDark.bind({});
|
|
452
|
+
ActivedOptionOnDark.play = async ({ canvasElement }) => {
|
|
453
|
+
const canvas = within(canvasElement);
|
|
454
|
+
const autosuggest = canvas.getByRole("combobox");
|
|
455
|
+
await userEvent.click(autosuggest);
|
|
456
|
+
};
|