@dxc-technology/halstack-react 0.0.0-90f64ff → 0.0.0-9427b76

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.
Files changed (38) hide show
  1. package/dist/ThemeContext.js +66 -58
  2. package/dist/alert/Alert.js +1 -1
  3. package/dist/alert/index.d.ts +51 -0
  4. package/dist/common/variables.js +141 -58
  5. package/dist/date/Date.js +4 -6
  6. package/dist/file-input/FileInput.js +641 -0
  7. package/dist/file-input/FileItem.js +280 -0
  8. package/dist/file-input/index.d.ts +81 -0
  9. package/dist/layout/ApplicationLayout.js +1 -1
  10. package/dist/link/Link.js +4 -8
  11. package/dist/main.d.ts +7 -0
  12. package/dist/main.js +8 -0
  13. package/dist/new-date/NewDate.js +64 -67
  14. package/dist/new-date/index.d.ts +95 -0
  15. package/dist/new-input-text/NewInputText.js +160 -157
  16. package/dist/new-input-text/index.d.ts +135 -0
  17. package/dist/new-textarea/NewTextarea.js +53 -37
  18. package/dist/new-textarea/index.d.ts +117 -0
  19. package/dist/number/Number.js +1 -3
  20. package/dist/number/index.d.ts +113 -0
  21. package/dist/password/Password.js +3 -3
  22. package/dist/password/index.d.ts +94 -0
  23. package/dist/progress-bar/ProgressBar.js +1 -1
  24. package/dist/select/Select.js +122 -158
  25. package/dist/sidenav/Sidenav.js +6 -4
  26. package/dist/tag/Tag.js +26 -32
  27. package/package.json +2 -1
  28. package/test/FileInput.test.js +201 -0
  29. package/test/NewDate.test.js +41 -12
  30. package/test/NewInputText.test.js +104 -187
  31. package/test/NewTextarea.test.js +95 -101
  32. package/test/Number.test.js +44 -28
  33. package/test/Paginator.test.js +1 -1
  34. package/test/Password.test.js +15 -8
  35. package/test/ResultsetTable.test.js +1 -2
  36. package/test/Select.test.js +40 -17
  37. package/dist/select/Select.stories.js +0 -235
  38. package/dist/select/readme.md +0 -72
@@ -0,0 +1,135 @@
1
+ type Size = "small" | "medium" | "large" | "fillParent";
2
+ type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ type Margin = {
4
+ top?: Space;
5
+ bottom?: Space;
6
+ left?: Space;
7
+ right?: Space;
8
+ };
9
+ type SVG = string | (HTMLElement & SVGElement);
10
+ type Action = {
11
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
12
+ icon: SVG;
13
+ };
14
+
15
+ type Props = {
16
+ /**
17
+ * Text to be placed above the input. This label will be used as the aria-label attribute of the list of suggestions.
18
+ */
19
+ label?: string;
20
+ /**
21
+ * Name attribute of the input element.
22
+ */
23
+ name?: string;
24
+ /**
25
+ * Value of the input. If undefined, the component will be uncontrolled and the value will be managed internally by the component.
26
+ */
27
+ value?: string;
28
+ /**
29
+ * Helper text to be placed above the input.
30
+ */
31
+ helperText?: string;
32
+ /**
33
+ * Text to be put as placeholder of the input.
34
+ */
35
+ placeholder?: string;
36
+ /**
37
+ * Action to be shown in the input. This is an object composed of an onClick function and an icon,
38
+ * being the latter either an inline svg or a URL to the image.
39
+ */
40
+ action?: Action;
41
+ /**
42
+ * If true, the input will have an action to clear the entered value.
43
+ */
44
+ clearable?: boolean;
45
+ /**
46
+ * If true, the component will be disabled.
47
+ */
48
+ disabled?: boolean;
49
+ /**
50
+ * If true, the input will be optional, showing '(Optional)'
51
+ * next to the label. Otherwise, the field will be considered required and an error will be
52
+ * passed as a parameter to the OnBlur and onChange functions when it has
53
+ * not been filled.
54
+ */
55
+ optional?: boolean;
56
+ /**
57
+ * Prefix to be placed before the input value.
58
+ */
59
+ prefix?: string;
60
+ /**
61
+ * Suffix to be placed after the input value.
62
+ */
63
+ suffix?: string;
64
+ /**
65
+ * This function will be called when the user types within the input
66
+ * element of the component. An object including the current value and
67
+ * the error (if the value entered is not valid) will be passed to this
68
+ * function. If there is no error, error will be null.
69
+ */
70
+ onChange?: (val: { value: string; error: string }) => void;
71
+ /**
72
+ * This function will be called when the input element loses the focus.
73
+ * An object including the input value and the error (if the value
74
+ * entered is not valid) will be passed to this function. If there is no error,
75
+ * error will be null.
76
+ */
77
+ onBlur?: (obj: { value: string; error: string }) => void;
78
+ /**
79
+ * If it is defined, the component will change its appearance, showing
80
+ * the error below the input component. If it is not defined, the error
81
+ * messages will be managed internally, but never displayed on its own.
82
+ */
83
+ error?: string;
84
+ /**
85
+ * These are the options to be displayed as suggestions. It can be either an array or a function:
86
+ * - Array: Array of options that will be filtered by the component.
87
+ * - Function: This function will be called when the user changes the value, we will send as a parameter the new value;
88
+ * apart from that this function should return one promise on which we should make 'then' to get the suggestions filtered.
89
+ */
90
+ suggestions?: string[] | (() => void);
91
+ /**
92
+ * Regular expression that defines the valid format allowed by the input.
93
+ * This will be checked both when the input element loses the focus and
94
+ * while typing within it. If the string entered does not match the
95
+ * pattern, the onBlur and onChange functions will be called with the
96
+ * current value and an internal error informing that this value does not
97
+ * match the pattern. If the pattern is met, the error parameter of both
98
+ * events will be null.
99
+ */
100
+ pattern?: string;
101
+ /**
102
+ * Specifies the minimun and maximum length allowed by the input.
103
+ * This will be checked both when the input element loses the
104
+ * focus and while typing within it. If the string entered does not
105
+ * comply the length, the onBlur and onChange functions will be called
106
+ * with the current value and an internal error informing that the value
107
+ * length does not comply the specified range. If a valid length is
108
+ * reached, the error parameter of both events will be null.
109
+ */
110
+ length?: { min?: number; max?: number };
111
+ /**
112
+ * HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the input value.
113
+ * Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
114
+ */
115
+ autocomplete?: string;
116
+ /**
117
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
118
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
119
+ */
120
+ margin?: Space | Margin;
121
+ /**
122
+ * Size of the component ('small' | 'medium' | 'large' | 'fillParent').
123
+ */
124
+ size?: Size;
125
+ /**
126
+ * Value of the tabindex attribute.
127
+ */
128
+ tabIndex?: number;
129
+ /**
130
+ * Reference to the component.
131
+ */
132
+ ref?: React.RefObject<HTMLDivElement>;
133
+ };
134
+
135
+ export default function DxcNewInputText(props: Props): JSX.Element;
@@ -93,18 +93,22 @@ function _templateObject() {
93
93
  return data;
94
94
  }
95
95
 
96
- var getLengthErrorMessage = function getLengthErrorMessage(length) {
97
- return "Min length ".concat(length.min, ", max length ").concat(length.max, ".");
96
+ var getNotOptionalErrorMessage = function getNotOptionalErrorMessage() {
97
+ return "This field is required. Please, enter a value.";
98
98
  };
99
99
 
100
- var patternMatch = function patternMatch(pattern, value) {
101
- return new RegExp(pattern).test(value);
100
+ var getLengthErrorMessage = function getLengthErrorMessage(length) {
101
+ return "Min length ".concat(length.min, ", max length ").concat(length.max, ".");
102
102
  };
103
103
 
104
104
  var getPatternErrorMessage = function getPatternErrorMessage() {
105
105
  return "Please match the format requested.";
106
106
  };
107
107
 
108
+ var patternMatch = function patternMatch(pattern, value) {
109
+ return new RegExp(pattern).test(value);
110
+ };
111
+
108
112
  var DxcNewTextarea = _react["default"].forwardRef(function (_ref, ref) {
109
113
  var _ref$label = _ref.label,
110
114
  label = _ref$label === void 0 ? "" : _ref$label,
@@ -123,12 +127,12 @@ var DxcNewTextarea = _react["default"].forwardRef(function (_ref, ref) {
123
127
  verticalGrow = _ref$verticalGrow === void 0 ? "auto" : _ref$verticalGrow,
124
128
  _ref$rows = _ref.rows,
125
129
  rows = _ref$rows === void 0 ? 4 : _ref$rows,
126
- length = _ref.length,
127
- pattern = _ref.pattern,
128
130
  onChange = _ref.onChange,
129
131
  onBlur = _ref.onBlur,
130
132
  _ref$error = _ref.error,
131
133
  error = _ref$error === void 0 ? "" : _ref$error,
134
+ pattern = _ref.pattern,
135
+ length = _ref.length,
132
136
  _ref$autocomplete = _ref.autocomplete,
133
137
  autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
134
138
  margin = _ref.margin,
@@ -142,45 +146,51 @@ var DxcNewTextarea = _react["default"].forwardRef(function (_ref, ref) {
142
146
  innerValue = _useState2[0],
143
147
  setInnerValue = _useState2[1];
144
148
 
145
- var _useState3 = (0, _react.useState)(""),
146
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
147
- validationError = _useState4[0],
148
- changeValidationError = _useState4[1];
149
-
150
149
  var colorsTheme = (0, _useTheme["default"])();
151
150
  var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
152
151
  var textareaRef = (0, _react.useRef)(null);
153
152
  var textareaId = "textarea-".concat((0, _uuid.v4)());
153
+ var errorId = "error-message-".concat(textareaId);
154
154
 
155
- var changeValue = function changeValue(newValue) {
156
- value !== null && value !== void 0 ? value : setInnerValue(newValue);
157
- typeof onChange === "function" && onChange(newValue);
155
+ var isNotOptional = function isNotOptional(value) {
156
+ return value === "" && !optional;
158
157
  };
159
158
 
160
159
  var isLengthIncorrect = function isLengthIncorrect(value) {
161
160
  return value !== "" && length && length.min && length.max && (value.length < length.min || value.length > length.max);
162
161
  };
163
162
 
163
+ var changeValue = function changeValue(newValue) {
164
+ value !== null && value !== void 0 ? value : setInnerValue(newValue);
165
+ if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
166
+ value: newValue,
167
+ error: getNotOptionalErrorMessage()
168
+ });else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
169
+ value: newValue,
170
+ error: getLengthErrorMessage(length)
171
+ });else if (newValue && pattern && !patternMatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
172
+ value: newValue,
173
+ error: getPatternErrorMessage()
174
+ });else onChange === null || onChange === void 0 ? void 0 : onChange({
175
+ value: newValue,
176
+ error: null
177
+ });
178
+ };
179
+
164
180
  var handleTOnBlur = function handleTOnBlur(event) {
165
- if (isLengthIncorrect(event.target.value)) {
166
- changeValidationError(getLengthErrorMessage(length, event));
167
- onBlur === null || onBlur === void 0 ? void 0 : onBlur({
168
- value: event.target.value,
169
- error: getLengthErrorMessage(length)
170
- });
171
- } else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) {
172
- changeValidationError(getPatternErrorMessage());
173
- onBlur === null || onBlur === void 0 ? void 0 : onBlur({
174
- value: event.target.value,
175
- error: getPatternErrorMessage()
176
- });
177
- } else {
178
- changeValidationError("");
179
- onBlur === null || onBlur === void 0 ? void 0 : onBlur({
180
- value: event.target.value,
181
- error: null
182
- });
183
- }
181
+ if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
182
+ value: event.target.value,
183
+ error: getNotOptionalErrorMessage()
184
+ });else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
185
+ value: event.target.value,
186
+ error: getLengthErrorMessage(length)
187
+ });else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
188
+ value: event.target.value,
189
+ error: getPatternErrorMessage()
190
+ });else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
191
+ value: event.target.value,
192
+ error: null
193
+ });
184
194
  };
185
195
 
186
196
  var handleTOnChange = function handleTOnChange(event) {
@@ -219,14 +229,20 @@ var DxcNewTextarea = _react["default"].forwardRef(function (_ref, ref) {
219
229
  onChange: handleTOnChange,
220
230
  onBlur: handleTOnBlur,
221
231
  disabled: disabled,
222
- error: error || validationError,
232
+ error: error,
233
+ minLength: length === null || length === void 0 ? void 0 : length.min,
234
+ maxLength: length === null || length === void 0 ? void 0 : length.max,
223
235
  autoComplete: autocomplete,
224
236
  backgroundType: backgroundType,
225
237
  ref: textareaRef,
226
- tabIndex: tabIndex
227
- }), _react["default"].createElement(Error, {
238
+ tabIndex: tabIndex,
239
+ "aria-invalid": error ? "true" : "false",
240
+ "aria-describedby": error ? errorId : undefined,
241
+ "aria-required": optional ? "false" : "true"
242
+ }), !disabled && _react["default"].createElement(Error, {
243
+ id: errorId,
228
244
  backgroundType: backgroundType
229
- }, error || validationError)));
245
+ }, error)));
230
246
  });
231
247
 
232
248
  var sizes = {
@@ -0,0 +1,117 @@
1
+ type Size = "small" | "medium" | "large" | "fillParent";
2
+ type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ type Margin = {
4
+ top?: Space;
5
+ bottom?: Space;
6
+ left?: Space;
7
+ right?: Space;
8
+ };
9
+
10
+ type Props = {
11
+ /**
12
+ * Text to be placed above the textarea.
13
+ */
14
+ label?: string;
15
+ /**
16
+ * Name attribute of the textarea element.
17
+ */
18
+ name?: string;
19
+ /**
20
+ * Value of the textarea. If undefined, the component will be uncontrolled and the value will be managed internally.
21
+ */
22
+ value?: string;
23
+ /**
24
+ * Helper text to be placed above the textarea.
25
+ */
26
+ helperText?: string;
27
+ /**
28
+ * Text to be put as placeholder of the textarea.
29
+ */
30
+ placeholder?: string;
31
+ /**
32
+ * If true, the component will be disabled.
33
+ */
34
+ disabled?: boolean;
35
+ /**
36
+ * If true, the textarea will be optional, showing '(Optional)'
37
+ * next to the label. Otherwise, the field will be considered required
38
+ * and an error will be passed as a parameter to the OnBlur and onChange functions
39
+ * when it has not been filled.
40
+ */
41
+ optional?: boolean;
42
+ /**
43
+ * Defines the textarea's ability to resize vertically. It can be:
44
+ * - 'auto': The textarea grows or shrinks automatically in order to fit the content.
45
+ * - 'manual': The height of the textarea is enabled to be manually modified.
46
+ * - 'none': The textarea has a fixed height and can't be modified.
47
+ */
48
+ verticalGrow?: "auto" | "manual" | "none";
49
+ /**
50
+ * Number of rows of the textarea.
51
+ */
52
+ rows?: number;
53
+ /**
54
+ * This function will be called when the user types within the textarea.
55
+ * An object including the current value and the error (if the value
56
+ * entered is not valid) will be passed to this function.
57
+ * If there is no error, error will be null.
58
+ */
59
+ onChange?: (val: { value: string; error: string }) => void;
60
+ /**
61
+ * This function will be called when the textarea loses the focus. An
62
+ * object including the textarea value and the error (if the value entered
63
+ * is not valid) will be passed to this function. If there is no error,
64
+ * error will be null.
65
+ */
66
+ onBlur?: (val: { value: string; error: string }) => void;
67
+ /**
68
+ * If it is defined, the component will change its appearance, showing
69
+ * the error below the textarea. If it is not defined, the error
70
+ * messages will be managed internally, but never displayed on its own.
71
+ */
72
+ error?: string;
73
+ /**
74
+ * Regular expression that defines the valid format allowed by the
75
+ * textarea. This will be checked both when the textarea loses the focus
76
+ * and while typing within it. If the string entered does not match the
77
+ * pattern, the onBlur and onChange functions will be called with the
78
+ * current value and an internal error informing that this value does not
79
+ * match the pattern. If the pattern is met, the error parameter of both
80
+ * events will be null.
81
+ */
82
+ pattern?: string;
83
+ /**
84
+ * Specifies the minimun and maximum length allowed by the textarea.
85
+ * This will be checked both when the textarea loses the
86
+ * focus and while typing within it. If the string entered does not
87
+ * comply the length, the onBlur and onChange functions will be called
88
+ * with the current value and an internal error informing that the value
89
+ * length does not comply the specified range. If a valid length is
90
+ * reached, the error parameter of both events will be null.
91
+ */
92
+ length?: { min: number; max: number };
93
+ /**
94
+ * HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the textarea value.
95
+ * Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
96
+ */
97
+ autocomplete?: string;
98
+ /**
99
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
100
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
101
+ */
102
+ margin?: Space | Margin;
103
+ /**
104
+ * Size of the component ('small' | 'medium' | 'large' | 'fillParent').
105
+ */
106
+ size?: Size;
107
+ /**
108
+ * Value of the tabindex attribute.
109
+ */
110
+ tabIndex?: number;
111
+ /**
112
+ * Reference to the component.
113
+ */
114
+ ref?: React.RefObject<HTMLDivElement>;
115
+ };
116
+
117
+ export default function DxcNewTextarea(props: Props): JSX.Element;
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
7
5
  Object.defineProperty(exports, "__esModule", {
@@ -13,7 +11,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
13
11
 
14
12
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
13
 
16
- var _react = _interopRequireWildcard(require("react"));
14
+ var _react = _interopRequireDefault(require("react"));
17
15
 
18
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
19
17
 
@@ -0,0 +1,113 @@
1
+ type Size = "small" | "medium" | "large" | "fillParent";
2
+ type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ type Margin = {
4
+ top?: Space;
5
+ bottom?: Space;
6
+ left?: Space;
7
+ right?: Space;
8
+ };
9
+ type Props = {
10
+ /**
11
+ * Text to be placed above the number.
12
+ */
13
+ label?: string;
14
+ /**
15
+ * Name attribute of the input element.
16
+ */
17
+ name?: string;
18
+ /**
19
+ * Value of the input element. If undefined, the component will be uncontrolled and the value will be managed internally by the component.
20
+ */
21
+ value?: string;
22
+ /**
23
+ * Helper text to be placed above the number.
24
+ */
25
+ helperText?: string;
26
+ /**
27
+ * Text to be put as placeholder of the number.
28
+ */
29
+ placeholder?: string;
30
+ /**
31
+ * If true, the component will be disabled.
32
+ */
33
+ disabled?: boolean;
34
+ /**
35
+ * If true, the number will be optional, showing '(Optional)'
36
+ * next to the label. Otherwise, the field will be considered required
37
+ * and an error will be passed as a parameter to the OnBlur and onChange
38
+ * functions when it has not been filled.
39
+ */
40
+ optional?: boolean;
41
+ /**
42
+ * Prefix to be placed before the number value.
43
+ */
44
+ prefix?: string;
45
+ /**
46
+ * Suffix to be placed after the number value.
47
+ */
48
+ suffix?: string;
49
+ /**
50
+ * Minimum value allowed by the number. If the typed value by the user is
51
+ * lower than min, the onBlur and onChange functions will be called with
52
+ * the current value and an internal error informing that the current
53
+ * value is not correct. If a valid state is reached, the error parameter
54
+ * will be null in both events.
55
+ */
56
+ min?: number;
57
+ /**
58
+ * Maximum value allowed by the number. If the typed value by the user
59
+ * surpasses max, the onBlur and onChange functions will be called with
60
+ * the current value and an internal error informing that the current
61
+ * value is not correct. If a valid state is reached, the error parameter
62
+ * will be null in both events.
63
+ */
64
+ max?: number;
65
+ /**
66
+ * The step interval to use when using the up and down arrows to adjust the value.
67
+ */
68
+ step?: number;
69
+ /**
70
+ * This function will be called when the user types within the input
71
+ * element of the component. An object including the current value and
72
+ * the error (if the value entered is not valid) will be passed to this
73
+ * function. If there is no error, error will be null.
74
+ */
75
+ onChange?: (val: { value: string; error: string }) => void;
76
+ /**
77
+ * This function will be called when the input element loses the focus.
78
+ * An object including the input value and the error (if the value
79
+ * entered is not valid) will be passed to this function. If there is no error,
80
+ * error will be null.
81
+ */
82
+ onBlur?: (val: { value: string; error: string }) => void;
83
+ /**
84
+ * If it is defined, the component will change its appearance, showing
85
+ * the error below the input component. If it is not defined, the error
86
+ * messages will be managed internally, but never displayed on its own.
87
+ */
88
+ error?: string;
89
+ /**
90
+ * HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the input value.
91
+ * Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
92
+ */
93
+ autocomplete?: string;
94
+ /**
95
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
96
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
97
+ */
98
+ margin?: Space | Margin;
99
+ /**
100
+ * Size of the component ('small' | 'medium' | 'large' | 'fillParent').
101
+ */
102
+ size?: Size;
103
+ /**
104
+ * Value of the tabindex attribute.
105
+ */
106
+ tabIndex?: number;
107
+ /**
108
+ * Reference to the component.
109
+ */
110
+ ref?: React.RefObject<HTMLDivElement>;
111
+ };
112
+
113
+ export default function DxcNumber(props: Props): JSX.Element;
@@ -45,17 +45,17 @@ var DxcPassword = _react["default"].forwardRef(function (_ref, ref) {
45
45
  value = _ref.value,
46
46
  _ref$helperText = _ref.helperText,
47
47
  helperText = _ref$helperText === void 0 ? "" : _ref$helperText,
48
- _ref$error = _ref.error,
49
- error = _ref$error === void 0 ? "" : _ref$error,
50
48
  _ref$clearable = _ref.clearable,
51
49
  clearable = _ref$clearable === void 0 ? false : _ref$clearable,
52
50
  onChange = _ref.onChange,
53
51
  onBlur = _ref.onBlur,
54
- margin = _ref.margin,
52
+ _ref$error = _ref.error,
53
+ error = _ref$error === void 0 ? "" : _ref$error,
55
54
  pattern = _ref.pattern,
56
55
  length = _ref.length,
57
56
  _ref$autocomplete = _ref.autocomplete,
58
57
  autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
58
+ margin = _ref.margin,
59
59
  _ref$size = _ref.size,
60
60
  size = _ref$size === void 0 ? "medium" : _ref$size,
61
61
  _ref$tabIndex = _ref.tabIndex,
@@ -0,0 +1,94 @@
1
+ type Size = "small" | "medium" | "large" | "fillParent";
2
+ type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ type Margin = {
4
+ top?: Space;
5
+ bottom?: Space;
6
+ left?: Space;
7
+ right?: Space;
8
+ };
9
+
10
+ type Props = {
11
+ /**
12
+ * Text to be placed above the password.
13
+ */
14
+ label?: string;
15
+ /**
16
+ * Name attribute of the input element.
17
+ */
18
+ name?: string;
19
+ /**
20
+ * Value of the input element. If undefined, the component will be uncontrolled and the value will be managed internally by the component.
21
+ */
22
+ value?: string;
23
+ /**
24
+ * Helper text to be placed above the password.
25
+ */
26
+ helperText?: string;
27
+ /**
28
+ * If true, the password will have an action to clear the entered value.
29
+ */
30
+ clearable?: boolean;
31
+ /**
32
+ * This function will be called when the user types within the input
33
+ * element of the component. An object including the current value and
34
+ * the error (if the value entered is not valid) will be passed to this
35
+ * function. If there is no error, error will be null.
36
+ * */
37
+ onChange?: (val: { value: string; error: string }) => void;
38
+ /**
39
+ * This function will be called when the input element loses the focus.
40
+ * An object including the input value and the error (if the value entered is
41
+ * not valid) will be passed to this function. If there is no error, error will be null.
42
+ */
43
+ onBlur?: (val: { value: string; error: string }) => void;
44
+ /**
45
+ * If it is defined, the component will change its appearance, showing
46
+ * the error below the password component. If it is not defined, the
47
+ * error messages will be managed internally, but never displayed on its own.
48
+ */
49
+ error?: string;
50
+ /**
51
+ * Regular expression that defines the valid format allowed by the
52
+ * password. This will be checked both when the input element loses the
53
+ * focus and while typing within it. If the string entered does not match
54
+ * the pattern, the onBlur and onChange functions will be called with the
55
+ * current value and an internal error informing that this value does not
56
+ * match the pattern. If the pattern is met, the error parameter of both
57
+ * events will be null.
58
+ */
59
+ pattern?: string;
60
+ /**
61
+ * Specifies the minimun and maximum length allowed by the password.
62
+ * This will be checked both when the input element loses the
63
+ * focus and while typing within it. If the string entered does not
64
+ * comply the length, the onBlur and onChange functions will be called
65
+ * with the current value and an internal error informing that the value
66
+ * length does not comply the specified range. If a valid length is
67
+ * reached, the error parameter of both events will be null.
68
+ */
69
+ length?: { min?: number; max?: number };
70
+ /**
71
+ * HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the input value.
72
+ * Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
73
+ */
74
+ autocomplete?: string;
75
+ /**
76
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
77
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
78
+ */
79
+ margin?: Space | Margin;
80
+ /**
81
+ * Size of the component ('small' | 'medium' | 'large' | 'fillParent').
82
+ */
83
+ size?: Size;
84
+ /**
85
+ * Value of the tabindex attribute.
86
+ */
87
+ tabIndex?: number;
88
+ /**
89
+ * Reference to the component.
90
+ */
91
+ ref?: React.RefObject<HTMLDivElement>;
92
+ };
93
+
94
+ export default function DxcPassword(props: Props): JSX.Element;
@@ -80,7 +80,7 @@ function _templateObject2() {
80
80
  }
81
81
 
82
82
  function _templateObject() {
83
- var data = (0, _taggedTemplateLiteral2["default"])(["\n background-color: ", ";\n opacity: ", ";\n width: ", ";\n display: flex;\n flex-wrap: wrap;\n justify-content: ", ";\n height: ", ";\n align-items: ", ";\n min-width: 100px;\n max-width: ", ";\n position: ", ";\n top: ", ";\n bottom: ", ";\n left: ", ";\n right: ", ";\n z-index: ", ";\n"]);
83
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n background-color: ", ";\n opacity: ", ";\n width: ", ";\n display: flex;\n flex-wrap: wrap;\n justify-content: ", ";\n height: ", ";\n align-items: ", ";\n min-width: 100px;\n max-width: ", ";\n position: ", ";\n top: ", ";\n bottom: ", ";\n left: ", ";\n right: ", ";\n z-index: ", ";\n width: 100%;\n"]);
84
84
 
85
85
  _templateObject = function _templateObject() {
86
86
  return data;