@dxc-technology/halstack-react 0.0.0-d3554d7 → 0.0.0-d3ac293
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 +1336 -0
- package/HalstackContext.js +335 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +118 -126
- package/accordion/Accordion.stories.tsx +115 -27
- package/accordion/Accordion.test.js +26 -12
- package/accordion/types.d.ts +9 -4
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +17 -38
- package/accordion-group/AccordionGroup.stories.tsx +28 -2
- package/accordion-group/AccordionGroup.test.js +31 -38
- package/accordion-group/types.d.ts +14 -3
- package/alert/Alert.js +7 -4
- 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 +94 -95
- package/bleed/types.d.ts +25 -1
- package/box/Box.js +25 -37
- package/box/Box.stories.tsx +15 -0
- package/box/Box.test.js +1 -1
- package/box/types.d.ts +1 -0
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +123 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/button/Button.js +52 -69
- package/button/Button.stories.tsx +159 -8
- package/button/Button.test.js +1 -1
- package/button/types.d.ts +7 -7
- package/card/Card.js +25 -28
- package/card/Card.test.js +1 -1
- package/card/types.d.ts +1 -0
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +107 -110
- package/checkbox/Checkbox.stories.tsx +198 -130
- package/checkbox/Checkbox.test.js +101 -11
- package/checkbox/types.d.ts +13 -5
- package/chip/Chip.js +18 -24
- package/chip/Chip.stories.tsx +96 -9
- package/chip/Chip.test.js +3 -5
- package/chip/types.d.ts +1 -1
- package/common/utils.d.ts +1 -0
- package/common/utils.js +4 -4
- package/common/variables.d.ts +1625 -0
- package/common/variables.js +483 -352
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.js +169 -258
- package/date-input/DateInput.stories.tsx +199 -33
- package/date-input/DateInput.test.js +521 -155
- 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 +67 -9
- package/dialog/Dialog.js +76 -93
- package/dialog/Dialog.stories.tsx +230 -123
- package/dialog/Dialog.test.js +334 -5
- package/dialog/types.d.ts +3 -2
- 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 +70 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +81 -0
- package/dropdown/types.d.ts +25 -5
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +181 -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 +17 -0
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +69 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +32 -0
- package/footer/Footer.js +16 -89
- package/footer/Footer.stories.tsx +99 -1
- package/footer/Footer.test.js +14 -26
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +2 -1
- package/header/Header.js +108 -129
- package/header/Header.stories.tsx +189 -36
- package/header/Header.test.js +20 -4
- package/header/Icons.js +2 -2
- package/header/types.d.ts +3 -2
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.js +1 -1
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +36 -36
- package/inset/types.d.ts +25 -1
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +72 -132
- package/layout/ApplicationLayout.stories.tsx +84 -93
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +13 -2
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +18 -33
- package/link/Link.d.ts +3 -2
- package/link/Link.js +59 -76
- package/link/Link.stories.tsx +155 -53
- package/link/Link.test.js +9 -19
- package/link/types.d.ts +7 -23
- package/main.d.ts +8 -10
- package/main.js +46 -56
- package/nav-tabs/NavTabs.d.ts +8 -0
- package/nav-tabs/NavTabs.js +125 -0
- package/nav-tabs/NavTabs.stories.tsx +260 -0
- package/nav-tabs/NavTabs.test.js +82 -0
- package/nav-tabs/Tab.d.ts +4 -0
- package/nav-tabs/Tab.js +150 -0
- package/nav-tabs/types.d.ts +53 -0
- package/number-input/NumberInput.js +11 -18
- package/number-input/NumberInput.stories.tsx +5 -5
- package/number-input/NumberInput.test.js +46 -12
- package/number-input/types.d.ts +17 -10
- package/package.json +20 -23
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +19 -46
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +78 -39
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/PasswordInput.js +7 -4
- package/password-input/PasswordInput.test.js +17 -19
- package/password-input/types.d.ts +14 -11
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +61 -55
- package/progress-bar/ProgressBar.stories.jsx +47 -12
- package/progress-bar/ProgressBar.test.js +68 -23
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +117 -0
- package/quick-nav/QuickNav.stories.tsx +356 -0
- package/quick-nav/types.d.ts +21 -0
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +43 -28
- package/radio-group/RadioGroup.js +32 -28
- package/radio-group/RadioGroup.stories.tsx +135 -17
- package/radio-group/RadioGroup.test.js +145 -117
- package/radio-group/types.d.ts +79 -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 +2 -2
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +93 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +169 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +97 -0
- package/select/Select.js +179 -384
- package/select/Select.stories.tsx +531 -142
- package/select/Select.test.js +652 -324
- package/select/types.d.ts +53 -13
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +183 -53
- package/sidenav/Sidenav.stories.tsx +249 -149
- package/sidenav/Sidenav.test.js +25 -37
- package/sidenav/types.d.ts +50 -27
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +124 -98
- package/slider/Slider.stories.tsx +72 -9
- package/slider/Slider.test.js +143 -22
- package/slider/types.d.ts +10 -2
- package/spinner/Spinner.js +4 -4
- package/spinner/Spinner.stories.jsx +27 -1
- package/spinner/Spinner.test.js +1 -1
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +152 -69
- package/switch/Switch.stories.tsx +53 -42
- package/switch/Switch.test.js +156 -4
- package/switch/types.d.ts +12 -4
- 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 +133 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +363 -109
- package/tabs/Tabs.stories.tsx +119 -13
- package/tabs/Tabs.test.js +241 -14
- package/tabs/types.d.ts +19 -5
- package/tag/Tag.js +17 -22
- package/tag/Tag.stories.tsx +25 -8
- 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 +221 -344
- package/text-input/TextInput.stories.tsx +290 -195
- package/text-input/TextInput.test.js +763 -731
- package/text-input/types.d.ts +50 -12
- package/textarea/Textarea.js +17 -26
- package/textarea/Textarea.stories.jsx +65 -6
- package/textarea/Textarea.test.js +38 -37
- package/textarea/types.d.ts +18 -11
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +6 -5
- package/toggle-group/ToggleGroup.stories.tsx +46 -4
- package/toggle-group/ToggleGroup.test.js +36 -5
- package/toggle-group/types.d.ts +9 -1
- 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 +1234 -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 +139 -0
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +59 -55
- package/wizard/Wizard.stories.tsx +48 -19
- package/wizard/Wizard.test.js +37 -24
- package/wizard/types.d.ts +10 -5
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
- 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/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 -10
- 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 -9
- 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 → nav-tabs}/types.js +0 -0
- /package/{stack → quick-nav}/types.js +0 -0
package/text-input/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare type Margin = {
|
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
declare type SVG = React.
|
|
9
|
+
declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
10
|
declare type Action = {
|
|
11
11
|
/**
|
|
12
12
|
* This function will be called when the user clicks the action.
|
|
@@ -30,6 +30,10 @@ declare type Props = {
|
|
|
30
30
|
* Name attribute of the input element.
|
|
31
31
|
*/
|
|
32
32
|
name?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Initial value of the input, only when it is uncontrolled.
|
|
35
|
+
*/
|
|
36
|
+
defaultValue?: string;
|
|
33
37
|
/**
|
|
34
38
|
* Value of the input. If undefined, the component will be uncontrolled and the value will be managed internally by the component.
|
|
35
39
|
*/
|
|
@@ -74,26 +78,29 @@ declare type Props = {
|
|
|
74
78
|
* This function will be called when the user types within the input
|
|
75
79
|
* element of the component. An object including the current value and
|
|
76
80
|
* the error (if the value entered is not valid) will be passed to this
|
|
77
|
-
* function. If there is no error, error will be
|
|
81
|
+
* function. If there is no error, error will not be defined.
|
|
78
82
|
*/
|
|
79
83
|
onChange?: (val: {
|
|
80
84
|
value: string;
|
|
81
|
-
error
|
|
85
|
+
error?: string;
|
|
82
86
|
}) => void;
|
|
83
87
|
/**
|
|
84
88
|
* This function will be called when the input element loses the focus.
|
|
85
89
|
* An object including the input value and the error (if the value
|
|
86
90
|
* entered is not valid) will be passed to this function. If there is no error,
|
|
87
|
-
* error will be
|
|
91
|
+
* error will not be defined.
|
|
88
92
|
*/
|
|
89
93
|
onBlur?: (val: {
|
|
90
94
|
value: string;
|
|
91
|
-
error
|
|
95
|
+
error?: string;
|
|
92
96
|
}) => void;
|
|
93
97
|
/**
|
|
94
|
-
* If it is defined
|
|
95
|
-
* the error below the input component. If
|
|
96
|
-
*
|
|
98
|
+
* If it is a defined value and also a truthy string, the component will
|
|
99
|
+
* change its appearance, showing the error below the input component. If
|
|
100
|
+
* the defined value is an empty string, it will reserve a space below
|
|
101
|
+
* the component for a future error, but it would not change its look. In
|
|
102
|
+
* case of being undefined or null, both the appearance and the space for
|
|
103
|
+
* the error message would not be modified.
|
|
97
104
|
*/
|
|
98
105
|
error?: string;
|
|
99
106
|
/**
|
|
@@ -110,7 +117,7 @@ declare type Props = {
|
|
|
110
117
|
* pattern, the onBlur and onChange functions will be called with the
|
|
111
118
|
* current value and an internal error informing that this value does not
|
|
112
119
|
* match the pattern. If the pattern is met, the error parameter of both
|
|
113
|
-
* events will be
|
|
120
|
+
* events will not be defined.
|
|
114
121
|
*/
|
|
115
122
|
pattern?: string;
|
|
116
123
|
/**
|
|
@@ -120,7 +127,7 @@ declare type Props = {
|
|
|
120
127
|
* comply the minimum length, the onBlur and onChange functions will be called
|
|
121
128
|
* with the current value and an internal error informing that the value
|
|
122
129
|
* length does not comply the specified range. If a valid length is
|
|
123
|
-
* reached, the error parameter of both events will be
|
|
130
|
+
* reached, the error parameter of both events will not be defined.
|
|
124
131
|
*/
|
|
125
132
|
minLength?: number;
|
|
126
133
|
/**
|
|
@@ -130,7 +137,7 @@ declare type Props = {
|
|
|
130
137
|
* comply the maximum length, the onBlur and onChange functions will be called
|
|
131
138
|
* with the current value and an internal error informing that the value
|
|
132
139
|
* length does not comply the specified range. If a valid length is
|
|
133
|
-
* reached, the error parameter of both events will be
|
|
140
|
+
* reached, the error parameter of both events will not be defined.
|
|
134
141
|
*/
|
|
135
142
|
maxLength?: number;
|
|
136
143
|
/**
|
|
@@ -144,7 +151,7 @@ declare type Props = {
|
|
|
144
151
|
*/
|
|
145
152
|
margin?: Space | Margin;
|
|
146
153
|
/**
|
|
147
|
-
* Size of the component
|
|
154
|
+
* Size of the component.
|
|
148
155
|
*/
|
|
149
156
|
size?: "small" | "medium" | "large" | "fillParent";
|
|
150
157
|
/**
|
|
@@ -152,8 +159,39 @@ declare type Props = {
|
|
|
152
159
|
*/
|
|
153
160
|
tabIndex?: number;
|
|
154
161
|
};
|
|
162
|
+
/**
|
|
163
|
+
* List of suggestions of an Text Input component.
|
|
164
|
+
*/
|
|
165
|
+
export declare type SuggestionsProps = {
|
|
166
|
+
id: string;
|
|
167
|
+
value: string;
|
|
168
|
+
suggestions: string[];
|
|
169
|
+
visualFocusIndex: number;
|
|
170
|
+
highlightedSuggestions: boolean;
|
|
171
|
+
searchHasErrors: boolean;
|
|
172
|
+
isSearching: boolean;
|
|
173
|
+
suggestionOnClick: (suggestion: string) => void;
|
|
174
|
+
getTextInputWidth: () => number;
|
|
175
|
+
};
|
|
155
176
|
/**
|
|
156
177
|
* Reference to the component.
|
|
157
178
|
*/
|
|
158
179
|
export declare type RefType = HTMLDivElement;
|
|
180
|
+
/**
|
|
181
|
+
* Single suggestion of an Text Input component.
|
|
182
|
+
*/
|
|
183
|
+
export declare type SuggestionProps = {
|
|
184
|
+
id: string;
|
|
185
|
+
value: string;
|
|
186
|
+
onClick: (suggestion: string) => void;
|
|
187
|
+
suggestion: string;
|
|
188
|
+
isLast: boolean;
|
|
189
|
+
visuallyFocused: boolean;
|
|
190
|
+
highlighted: boolean;
|
|
191
|
+
};
|
|
192
|
+
export declare type AutosuggestWrapperProps = {
|
|
193
|
+
condition: boolean;
|
|
194
|
+
wrapper: (children: React.ReactNode) => JSX.Element;
|
|
195
|
+
children: React.ReactNode;
|
|
196
|
+
};
|
|
159
197
|
export default Props;
|
package/textarea/Textarea.js
CHANGED
|
@@ -19,11 +19,13 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
19
19
|
|
|
20
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
21
|
|
|
22
|
-
var _utils = require("../common/utils
|
|
22
|
+
var _utils = require("../common/utils");
|
|
23
23
|
|
|
24
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
27
|
+
|
|
28
|
+
var _variables = require("../common/variables");
|
|
27
29
|
|
|
28
30
|
var _uuid = require("uuid");
|
|
29
31
|
|
|
@@ -35,14 +37,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
35
37
|
|
|
36
38
|
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; }
|
|
37
39
|
|
|
38
|
-
var getNotOptionalErrorMessage = function getNotOptionalErrorMessage() {
|
|
39
|
-
return "This field is required. Please, enter a value.";
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
var getPatternErrorMessage = function getPatternErrorMessage() {
|
|
43
|
-
return "Please match the format requested.";
|
|
44
|
-
};
|
|
45
|
-
|
|
46
40
|
var patternMatch = function patternMatch(pattern, value) {
|
|
47
41
|
return new RegExp(pattern).test(value);
|
|
48
42
|
};
|
|
@@ -51,6 +45,8 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
51
45
|
var label = _ref.label,
|
|
52
46
|
_ref$name = _ref.name,
|
|
53
47
|
name = _ref$name === void 0 ? "" : _ref$name,
|
|
48
|
+
_ref$defaultValue = _ref.defaultValue,
|
|
49
|
+
defaultValue = _ref$defaultValue === void 0 ? "" : _ref$defaultValue,
|
|
54
50
|
value = _ref.value,
|
|
55
51
|
helperText = _ref.helperText,
|
|
56
52
|
_ref$placeholder = _ref.placeholder,
|
|
@@ -77,7 +73,7 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
77
73
|
_ref$tabIndex = _ref.tabIndex,
|
|
78
74
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
79
75
|
|
|
80
|
-
var _useState = (0, _react.useState)(
|
|
76
|
+
var _useState = (0, _react.useState)(defaultValue),
|
|
81
77
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
82
78
|
innerValue = _useState2[0],
|
|
83
79
|
setInnerValue = _useState2[1];
|
|
@@ -88,13 +84,10 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
88
84
|
|
|
89
85
|
var colorsTheme = (0, _useTheme["default"])();
|
|
90
86
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
87
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
91
88
|
var textareaRef = (0, _react.useRef)(null);
|
|
92
89
|
var errorId = "error-".concat(textareaId);
|
|
93
90
|
|
|
94
|
-
var getLengthErrorMessage = function getLengthErrorMessage() {
|
|
95
|
-
return "Min length ".concat(minLength, ", max length ").concat(maxLength, ".");
|
|
96
|
-
};
|
|
97
|
-
|
|
98
91
|
var isNotOptional = function isNotOptional(value) {
|
|
99
92
|
return value === "" && !optional;
|
|
100
93
|
};
|
|
@@ -107,32 +100,30 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
107
100
|
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
108
101
|
if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
109
102
|
value: newValue,
|
|
110
|
-
error:
|
|
103
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
111
104
|
});else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
112
105
|
value: newValue,
|
|
113
|
-
error:
|
|
106
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
114
107
|
});else if (newValue && pattern && !patternMatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
115
108
|
value: newValue,
|
|
116
|
-
error:
|
|
109
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
117
110
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
118
|
-
value: newValue
|
|
119
|
-
error: null
|
|
111
|
+
value: newValue
|
|
120
112
|
});
|
|
121
113
|
};
|
|
122
114
|
|
|
123
115
|
var handleTOnBlur = function handleTOnBlur(event) {
|
|
124
116
|
if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
125
117
|
value: event.target.value,
|
|
126
|
-
error:
|
|
118
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
127
119
|
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
128
120
|
value: event.target.value,
|
|
129
|
-
error:
|
|
121
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
130
122
|
});else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
131
123
|
value: event.target.value,
|
|
132
|
-
error:
|
|
124
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
133
125
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
134
|
-
value: event.target.value
|
|
135
|
-
error: null
|
|
126
|
+
value: event.target.value
|
|
136
127
|
});
|
|
137
128
|
};
|
|
138
129
|
|
|
@@ -160,7 +151,7 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
160
151
|
disabled: disabled,
|
|
161
152
|
backgroundType: backgroundType,
|
|
162
153
|
helperText: helperText
|
|
163
|
-
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null,
|
|
154
|
+
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
164
155
|
disabled: disabled,
|
|
165
156
|
backgroundType: backgroundType
|
|
166
157
|
}, helperText), /*#__PURE__*/_react["default"].createElement(Textarea, {
|
|
@@ -4,12 +4,20 @@ import Title from "../../.storybook/components/Title";
|
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
5
|
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
6
6
|
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
7
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
title: "Textarea",
|
|
10
11
|
component: DxcTextarea,
|
|
11
12
|
};
|
|
12
13
|
|
|
14
|
+
const opinionatedTheme = {
|
|
15
|
+
textarea: {
|
|
16
|
+
fontColor: "#000000",
|
|
17
|
+
hoverBorderColor: "#a46ede",
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
13
21
|
export const Chromatic = () => (
|
|
14
22
|
<>
|
|
15
23
|
<>
|
|
@@ -33,7 +41,7 @@ export const Chromatic = () => (
|
|
|
33
41
|
</ExampleContainer>
|
|
34
42
|
<ExampleContainer>
|
|
35
43
|
<Title title="Disabled with value" theme="light" level={4} />
|
|
36
|
-
<DxcTextarea label="Disabled"
|
|
44
|
+
<DxcTextarea label="Disabled" defaultValue="Example text" disabled />
|
|
37
45
|
</ExampleContainer>
|
|
38
46
|
<ExampleContainer>
|
|
39
47
|
<Title title="With error" theme="light" level={4} />
|
|
@@ -55,7 +63,7 @@ export const Chromatic = () => (
|
|
|
55
63
|
</ExampleContainer>
|
|
56
64
|
<ExampleContainer>
|
|
57
65
|
<Title title="Helper text and optional with value" theme="light" level={4} />
|
|
58
|
-
<DxcTextarea label="Helper & optional"
|
|
66
|
+
<DxcTextarea label="Helper & optional" defaultValue="Some text" helperText="Sample text" optional />
|
|
59
67
|
</ExampleContainer>
|
|
60
68
|
<ExampleContainer>
|
|
61
69
|
<Title title="Resizable" theme="light" level={4} />
|
|
@@ -66,7 +74,7 @@ export const Chromatic = () => (
|
|
|
66
74
|
<DxcTextarea
|
|
67
75
|
label="Manual vertical grow"
|
|
68
76
|
verticalGrow="manual"
|
|
69
|
-
|
|
77
|
+
defaultValue="Long textttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt"
|
|
70
78
|
/>
|
|
71
79
|
</ExampleContainer>
|
|
72
80
|
</>
|
|
@@ -74,7 +82,7 @@ export const Chromatic = () => (
|
|
|
74
82
|
<DarkContainer>
|
|
75
83
|
<ExampleContainer>
|
|
76
84
|
<Title title="Helper text and optional with value" theme="dark" level={4} />
|
|
77
|
-
<DxcTextarea label="Helper & optional"
|
|
85
|
+
<DxcTextarea label="Helper & optional" defaultValue="Some text" helperText="Sample text" optional />
|
|
78
86
|
</ExampleContainer>
|
|
79
87
|
<ExampleContainer>
|
|
80
88
|
<Title title="Disabled" theme="dark" level={4} />
|
|
@@ -88,7 +96,7 @@ export const Chromatic = () => (
|
|
|
88
96
|
</ExampleContainer>
|
|
89
97
|
<ExampleContainer>
|
|
90
98
|
<Title title="Disabled with value" theme="dark" level={4} />
|
|
91
|
-
<DxcTextarea label="Disabled"
|
|
99
|
+
<DxcTextarea label="Disabled" defaultValue="Example text" disabled />
|
|
92
100
|
</ExampleContainer>
|
|
93
101
|
<ExampleContainer>
|
|
94
102
|
<Title title="With error" theme="dark" level={4} />
|
|
@@ -151,7 +159,58 @@ export const Chromatic = () => (
|
|
|
151
159
|
<ExampleContainer>
|
|
152
160
|
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
153
161
|
<DxcTextarea label="Xxlarge" margin="xxlarge" />
|
|
154
|
-
|
|
162
|
+
</ExampleContainer>
|
|
163
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
164
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
165
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
166
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
167
|
+
<DxcTextarea label="Hovered" helperText="Sample text" placeholder="Placeholder" />
|
|
168
|
+
</HalstackProvider>
|
|
169
|
+
</ExampleContainer>
|
|
170
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
171
|
+
<Title title="Focused" theme="light" level={4} />
|
|
172
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
173
|
+
<DxcTextarea label="Focused" helperText="Sample text" />
|
|
174
|
+
</HalstackProvider>
|
|
175
|
+
</ExampleContainer>
|
|
176
|
+
<ExampleContainer>
|
|
177
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
178
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
179
|
+
<DxcTextarea
|
|
180
|
+
label="Disabled"
|
|
181
|
+
optional
|
|
182
|
+
helperText="Sample text"
|
|
183
|
+
placeholder="Enter your text here..."
|
|
184
|
+
disabled
|
|
185
|
+
/>
|
|
186
|
+
</HalstackProvider>
|
|
187
|
+
</ExampleContainer>
|
|
188
|
+
<ExampleContainer>
|
|
189
|
+
<Title title="Disabled with value" theme="light" level={4} />
|
|
190
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
191
|
+
<DxcTextarea label="Disabled" helperText="Sample text" defaultValue="Example text" disabled />
|
|
192
|
+
</HalstackProvider>
|
|
193
|
+
</ExampleContainer>
|
|
194
|
+
<ExampleContainer>
|
|
195
|
+
<Title title="With error" theme="light" level={4} />
|
|
196
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
197
|
+
<DxcTextarea
|
|
198
|
+
label="Textarea with error"
|
|
199
|
+
helperText="Helper text"
|
|
200
|
+
placeholder="Enter your text here..."
|
|
201
|
+
error="Error message."
|
|
202
|
+
/>
|
|
203
|
+
</HalstackProvider>
|
|
204
|
+
</ExampleContainer>
|
|
205
|
+
<ExampleContainer>
|
|
206
|
+
<Title title="Grow manual" theme="light" level={4} />{" "}
|
|
207
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
208
|
+
<DxcTextarea
|
|
209
|
+
label="Manual vertical grow"
|
|
210
|
+
verticalGrow="manual"
|
|
211
|
+
defaultValue="Long textttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt"
|
|
212
|
+
/>
|
|
213
|
+
</HalstackProvider>
|
|
155
214
|
</ExampleContainer>
|
|
156
215
|
</>
|
|
157
216
|
);
|
|
@@ -8,7 +8,7 @@ var _react2 = require("@testing-library/react");
|
|
|
8
8
|
|
|
9
9
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
10
10
|
|
|
11
|
-
var _Textarea = _interopRequireDefault(require("./Textarea"));
|
|
11
|
+
var _Textarea = _interopRequireDefault(require("./Textarea.tsx"));
|
|
12
12
|
|
|
13
13
|
describe("Textarea component tests", function () {
|
|
14
14
|
test("Renders with correct label", function () {
|
|
@@ -90,15 +90,26 @@ describe("Textarea component tests", function () {
|
|
|
90
90
|
expect(textarea.getAttribute("aria-describedBy")).toBeNull();
|
|
91
91
|
expect(textarea.getAttribute("aria-required")).toBe("true");
|
|
92
92
|
});
|
|
93
|
+
test("Renders with correct initial value", function () {
|
|
94
|
+
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
95
|
+
label: "Example label",
|
|
96
|
+
placeholder: "Placeholder",
|
|
97
|
+
defaultValue: "Example text"
|
|
98
|
+
})),
|
|
99
|
+
getByLabelText = _render8.getByLabelText;
|
|
100
|
+
|
|
101
|
+
var textarea = getByLabelText("Example label");
|
|
102
|
+
expect(textarea.value).toBe("Example text");
|
|
103
|
+
});
|
|
93
104
|
test("Disabled textarea renders with correct aria and can not be modified", function () {
|
|
94
105
|
var onChange = jest.fn();
|
|
95
106
|
|
|
96
|
-
var
|
|
107
|
+
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
97
108
|
label: "Example label",
|
|
98
109
|
onChange: onChange,
|
|
99
110
|
disabled: true
|
|
100
111
|
})),
|
|
101
|
-
getByLabelText =
|
|
112
|
+
getByLabelText = _render9.getByLabelText;
|
|
102
113
|
|
|
103
114
|
var textarea = getByLabelText("Example label");
|
|
104
115
|
expect(textarea.getAttribute("aria-disabled")).toBe("true");
|
|
@@ -111,13 +122,13 @@ describe("Textarea component tests", function () {
|
|
|
111
122
|
var onChange = jest.fn();
|
|
112
123
|
var onBlur = jest.fn();
|
|
113
124
|
|
|
114
|
-
var
|
|
125
|
+
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
115
126
|
label: "Example label",
|
|
116
127
|
placeholder: "Placeholder",
|
|
117
128
|
onChange: onChange,
|
|
118
129
|
onBlur: onBlur
|
|
119
130
|
})),
|
|
120
|
-
getByLabelText =
|
|
131
|
+
getByLabelText = _render10.getByLabelText;
|
|
121
132
|
|
|
122
133
|
var textarea = getByLabelText("Example label");
|
|
123
134
|
|
|
@@ -141,19 +152,18 @@ describe("Textarea component tests", function () {
|
|
|
141
152
|
|
|
142
153
|
expect(onBlur).toHaveBeenCalled();
|
|
143
154
|
expect(onBlur).toHaveBeenCalledWith({
|
|
144
|
-
value: "Test"
|
|
145
|
-
error: null
|
|
155
|
+
value: "Test"
|
|
146
156
|
});
|
|
147
157
|
});
|
|
148
158
|
test("Not optional constraint (onChange)", function () {
|
|
149
159
|
var onChange = jest.fn();
|
|
150
160
|
|
|
151
|
-
var
|
|
161
|
+
var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
152
162
|
label: "Example label",
|
|
153
163
|
placeholder: "Placeholder",
|
|
154
164
|
onChange: onChange
|
|
155
165
|
})),
|
|
156
|
-
getByLabelText =
|
|
166
|
+
getByLabelText = _render11.getByLabelText;
|
|
157
167
|
|
|
158
168
|
var textarea = getByLabelText("Example label");
|
|
159
169
|
|
|
@@ -167,8 +177,7 @@ describe("Textarea component tests", function () {
|
|
|
167
177
|
|
|
168
178
|
expect(onChange).toHaveBeenCalled();
|
|
169
179
|
expect(onChange).toHaveBeenCalledWith({
|
|
170
|
-
value: "Test"
|
|
171
|
-
error: null
|
|
180
|
+
value: "Test"
|
|
172
181
|
});
|
|
173
182
|
|
|
174
183
|
_userEvent["default"].clear(textarea);
|
|
@@ -183,7 +192,7 @@ describe("Textarea component tests", function () {
|
|
|
183
192
|
var onChange = jest.fn();
|
|
184
193
|
var onBlur = jest.fn();
|
|
185
194
|
|
|
186
|
-
var
|
|
195
|
+
var _render12 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
187
196
|
label: "Example label",
|
|
188
197
|
placeholder: "Placeholder",
|
|
189
198
|
onChange: onChange,
|
|
@@ -194,7 +203,7 @@ describe("Textarea component tests", function () {
|
|
|
194
203
|
},
|
|
195
204
|
pattern: "^.*(?=.*[a-zA-Z])(?=.*\\d)(?=.*[!&$%&? \"]).*$"
|
|
196
205
|
})),
|
|
197
|
-
getByLabelText =
|
|
206
|
+
getByLabelText = _render12.getByLabelText;
|
|
198
207
|
|
|
199
208
|
var textarea = getByLabelText("Example label");
|
|
200
209
|
|
|
@@ -228,23 +237,21 @@ describe("Textarea component tests", function () {
|
|
|
228
237
|
|
|
229
238
|
expect(onChange).toHaveBeenCalled();
|
|
230
239
|
expect(onChange).toHaveBeenCalledWith({
|
|
231
|
-
value: "pattern4&"
|
|
232
|
-
error: null
|
|
240
|
+
value: "pattern4&"
|
|
233
241
|
});
|
|
234
242
|
|
|
235
243
|
_react2.fireEvent.blur(textarea);
|
|
236
244
|
|
|
237
245
|
expect(onBlur).toHaveBeenCalled();
|
|
238
246
|
expect(onBlur).toHaveBeenCalledWith({
|
|
239
|
-
value: "pattern4&"
|
|
240
|
-
error: null
|
|
247
|
+
value: "pattern4&"
|
|
241
248
|
});
|
|
242
249
|
});
|
|
243
250
|
test("Length constraint", function () {
|
|
244
251
|
var onChange = jest.fn();
|
|
245
252
|
var onBlur = jest.fn();
|
|
246
253
|
|
|
247
|
-
var
|
|
254
|
+
var _render13 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
248
255
|
label: "Example label",
|
|
249
256
|
placeholder: "Placeholder",
|
|
250
257
|
onChange: onChange,
|
|
@@ -256,7 +263,7 @@ describe("Textarea component tests", function () {
|
|
|
256
263
|
minLength: 5,
|
|
257
264
|
maxLength: 10
|
|
258
265
|
})),
|
|
259
|
-
getByLabelText =
|
|
266
|
+
getByLabelText = _render13.getByLabelText;
|
|
260
267
|
|
|
261
268
|
var textarea = getByLabelText("Example label");
|
|
262
269
|
|
|
@@ -290,23 +297,21 @@ describe("Textarea component tests", function () {
|
|
|
290
297
|
|
|
291
298
|
expect(onChange).toHaveBeenCalled();
|
|
292
299
|
expect(onChange).toHaveBeenCalledWith({
|
|
293
|
-
value: "length"
|
|
294
|
-
error: null
|
|
300
|
+
value: "length"
|
|
295
301
|
});
|
|
296
302
|
|
|
297
303
|
_react2.fireEvent.blur(textarea);
|
|
298
304
|
|
|
299
305
|
expect(onBlur).toHaveBeenCalled();
|
|
300
306
|
expect(onBlur).toHaveBeenCalledWith({
|
|
301
|
-
value: "length"
|
|
302
|
-
error: null
|
|
307
|
+
value: "length"
|
|
303
308
|
});
|
|
304
309
|
});
|
|
305
310
|
test("Pattern and length constraints", function () {
|
|
306
311
|
var onChange = jest.fn();
|
|
307
312
|
var onBlur = jest.fn();
|
|
308
313
|
|
|
309
|
-
var
|
|
314
|
+
var _render14 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
310
315
|
label: "Example label",
|
|
311
316
|
placeholder: "Placeholder",
|
|
312
317
|
onChange: onChange,
|
|
@@ -319,7 +324,7 @@ describe("Textarea component tests", function () {
|
|
|
319
324
|
minLength: 5,
|
|
320
325
|
maxLength: 10
|
|
321
326
|
})),
|
|
322
|
-
getByLabelText =
|
|
327
|
+
getByLabelText = _render14.getByLabelText;
|
|
323
328
|
|
|
324
329
|
var textarea = getByLabelText("Example label");
|
|
325
330
|
|
|
@@ -371,26 +376,24 @@ describe("Textarea component tests", function () {
|
|
|
371
376
|
|
|
372
377
|
expect(onChange).toHaveBeenCalled();
|
|
373
378
|
expect(onChange).toHaveBeenCalledWith({
|
|
374
|
-
value: "tests4&"
|
|
375
|
-
error: null
|
|
379
|
+
value: "tests4&"
|
|
376
380
|
});
|
|
377
381
|
|
|
378
382
|
_react2.fireEvent.blur(textarea);
|
|
379
383
|
|
|
380
384
|
expect(onBlur).toHaveBeenCalled();
|
|
381
385
|
expect(onBlur).toHaveBeenCalledWith({
|
|
382
|
-
value: "tests4&"
|
|
383
|
-
error: null
|
|
386
|
+
value: "tests4&"
|
|
384
387
|
});
|
|
385
388
|
});
|
|
386
389
|
test("onBlur function is called correctly", function () {
|
|
387
390
|
var onBlur = jest.fn();
|
|
388
391
|
|
|
389
|
-
var
|
|
392
|
+
var _render15 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
390
393
|
label: "Example label",
|
|
391
394
|
onBlur: onBlur
|
|
392
395
|
})),
|
|
393
|
-
getByLabelText =
|
|
396
|
+
getByLabelText = _render15.getByLabelText;
|
|
394
397
|
|
|
395
398
|
var textarea = getByLabelText("Example label");
|
|
396
399
|
|
|
@@ -404,19 +407,18 @@ describe("Textarea component tests", function () {
|
|
|
404
407
|
|
|
405
408
|
expect(onBlur).toHaveBeenCalled();
|
|
406
409
|
expect(onBlur).toHaveBeenCalledWith({
|
|
407
|
-
value: "Blur test"
|
|
408
|
-
error: null
|
|
410
|
+
value: "Blur test"
|
|
409
411
|
});
|
|
410
412
|
});
|
|
411
413
|
test("onChange function is called correctly", function () {
|
|
412
414
|
var onChange = jest.fn();
|
|
413
415
|
|
|
414
|
-
var
|
|
416
|
+
var _render16 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
415
417
|
label: "Example label",
|
|
416
418
|
value: "Test value",
|
|
417
419
|
onChange: onChange
|
|
418
420
|
})),
|
|
419
|
-
getByLabelText =
|
|
421
|
+
getByLabelText = _render16.getByLabelText;
|
|
420
422
|
|
|
421
423
|
var textarea = getByLabelText("Example label");
|
|
422
424
|
|
|
@@ -428,8 +430,7 @@ describe("Textarea component tests", function () {
|
|
|
428
430
|
|
|
429
431
|
expect(onChange).toHaveBeenCalled();
|
|
430
432
|
expect(onChange).toHaveBeenCalledWith({
|
|
431
|
-
value: "Controlled test"
|
|
432
|
-
error: null
|
|
433
|
+
value: "Controlled test"
|
|
433
434
|
});
|
|
434
435
|
expect(textarea.value).toBe("Test value");
|
|
435
436
|
});
|