@dxc-technology/halstack-react 0.0.0-8d633bd → 0.0.0-9196773
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/dist/ThemeContext.js +69 -61
- package/dist/alert/Alert.js +4 -4
- package/dist/alert/index.d.ts +30 -5
- package/dist/common/variables.js +199 -47
- package/dist/date/Date.js +4 -6
- package/dist/{new-date/NewDate.js → date-input/DateInput.js} +69 -72
- package/dist/date-input/index.d.ts +95 -0
- package/dist/file-input/FileInput.js +11 -8
- package/dist/file-input/FileItem.js +25 -8
- package/dist/file-input/index.d.ts +81 -0
- package/dist/input-text/InputText.js +3 -3
- package/dist/main.d.ts +7 -1
- package/dist/main.js +22 -14
- package/dist/new-select/NewSelect.js +836 -0
- package/dist/new-select/index.d.ts +53 -0
- package/dist/new-textarea/NewTextarea.js +52 -48
- package/dist/new-textarea/index.d.ts +117 -0
- package/dist/{number/Number.js → number-input/NumberInput.js} +9 -11
- package/dist/{number/NumberContext.js → number-input/NumberInputContext.js} +2 -2
- package/dist/number-input/index.d.ts +113 -0
- package/dist/{password/Password.js → password-input/PasswordInput.js} +11 -13
- package/dist/password-input/index.d.ts +94 -0
- package/dist/slider/Slider.js +89 -14
- package/dist/{new-input-text/NewInputText.js → text-input/TextInput.js} +129 -135
- package/dist/text-input/index.d.ts +135 -0
- package/dist/toggle-group/ToggleGroup.js +132 -28
- package/dist/upload/Upload.js +3 -3
- package/dist/upload/readme.md +2 -2
- package/package.json +1 -1
- package/test/{NewDate.test.js → DateInput.test.js} +66 -27
- package/test/FileInput.test.js +164 -2
- package/test/InputText.test.js +24 -16
- package/test/NewTextarea.test.js +71 -128
- package/test/{Number.test.js → NumberInput.test.js} +84 -66
- package/test/PasswordInput.test.js +83 -0
- package/test/{NewInputText.test.js → TextInput.test.js} +134 -268
- package/test/ToggleGroup.test.js +5 -1
- package/test/Upload.test.js +5 -5
- package/dist/footer/Footer.stories.js +0 -94
- package/dist/input-text/InputText.stories.js +0 -209
- package/dist/password/styles.css +0 -3
- package/dist/slider/Slider.stories.js +0 -241
- package/test/Password.test.js +0 -76
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
type SVG = string | (HTMLElement & SVGElement);
|
|
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 OptionGroup = {
|
|
11
|
+
label: string;
|
|
12
|
+
options: Option[];
|
|
13
|
+
};
|
|
14
|
+
type Option = {
|
|
15
|
+
icon?: string | SVG;
|
|
16
|
+
label: string;
|
|
17
|
+
value: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type Props = {
|
|
21
|
+
label?: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
value?: string | string[];
|
|
24
|
+
options?: Option[] | OptionGroup[];
|
|
25
|
+
helperText?: string;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
optional?: boolean;
|
|
29
|
+
searchable?: boolean;
|
|
30
|
+
multiple?: boolean;
|
|
31
|
+
onChange?: (value: string | string[]) => void;
|
|
32
|
+
onBlur?: (val: { value: string | string[]; error: string }) => void;
|
|
33
|
+
error?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
36
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
37
|
+
*/
|
|
38
|
+
margin?: Space | Margin;
|
|
39
|
+
/**
|
|
40
|
+
* Size of the component ('small' | 'medium' | 'large' | 'fillParent').
|
|
41
|
+
*/
|
|
42
|
+
size?: "small" | "medium" | "large" | "fillParent";
|
|
43
|
+
/**
|
|
44
|
+
* Value of the tabindex attribute.
|
|
45
|
+
*/
|
|
46
|
+
tabIndex?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Reference to the component.
|
|
49
|
+
*/
|
|
50
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default function DxcNewSelect(props: Props): JSX.Element;
|
|
@@ -54,7 +54,7 @@ function _templateObject5() {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
function _templateObject4() {
|
|
57
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height:
|
|
57
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"]);
|
|
58
58
|
|
|
59
59
|
_templateObject4 = function _templateObject4() {
|
|
60
60
|
return data;
|
|
@@ -74,7 +74,7 @@ function _templateObject3() {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
function _templateObject2() {
|
|
77
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height:
|
|
77
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"]);
|
|
78
78
|
|
|
79
79
|
_templateObject2 = function _templateObject2() {
|
|
80
80
|
return data;
|
|
@@ -101,14 +101,14 @@ var getLengthErrorMessage = function getLengthErrorMessage(length) {
|
|
|
101
101
|
return "Min length ".concat(length.min, ", max length ").concat(length.max, ".");
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
var patternMatch = function patternMatch(pattern, value) {
|
|
105
|
-
return new RegExp(pattern).test(value);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
104
|
var getPatternErrorMessage = function getPatternErrorMessage() {
|
|
109
105
|
return "Please match the format requested.";
|
|
110
106
|
};
|
|
111
107
|
|
|
108
|
+
var patternMatch = function patternMatch(pattern, value) {
|
|
109
|
+
return new RegExp(pattern).test(value);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
112
|
var DxcNewTextarea = _react["default"].forwardRef(function (_ref, ref) {
|
|
113
113
|
var _ref$label = _ref.label,
|
|
114
114
|
label = _ref$label === void 0 ? "" : _ref$label,
|
|
@@ -127,12 +127,12 @@ var DxcNewTextarea = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
127
127
|
verticalGrow = _ref$verticalGrow === void 0 ? "auto" : _ref$verticalGrow,
|
|
128
128
|
_ref$rows = _ref.rows,
|
|
129
129
|
rows = _ref$rows === void 0 ? 4 : _ref$rows,
|
|
130
|
-
length = _ref.length,
|
|
131
|
-
pattern = _ref.pattern,
|
|
132
130
|
onChange = _ref.onChange,
|
|
133
131
|
onBlur = _ref.onBlur,
|
|
134
132
|
_ref$error = _ref.error,
|
|
135
133
|
error = _ref$error === void 0 ? "" : _ref$error,
|
|
134
|
+
pattern = _ref.pattern,
|
|
135
|
+
length = _ref.length,
|
|
136
136
|
_ref$autocomplete = _ref.autocomplete,
|
|
137
137
|
autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
|
|
138
138
|
margin = _ref.margin,
|
|
@@ -146,23 +146,16 @@ var DxcNewTextarea = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
146
146
|
innerValue = _useState2[0],
|
|
147
147
|
setInnerValue = _useState2[1];
|
|
148
148
|
|
|
149
|
-
var _useState3 = (0, _react.useState)(""),
|
|
150
|
-
_useState4 = (0, _slicedToArray2["default"])(_useState3,
|
|
151
|
-
|
|
152
|
-
changeValidationError = _useState4[1];
|
|
149
|
+
var _useState3 = (0, _react.useState)("textarea-".concat((0, _uuid.v4)())),
|
|
150
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
|
|
151
|
+
textareaId = _useState4[0];
|
|
153
152
|
|
|
154
153
|
var colorsTheme = (0, _useTheme["default"])();
|
|
155
154
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
156
155
|
var textareaRef = (0, _react.useRef)(null);
|
|
157
|
-
var textareaId = "textarea-".concat((0, _uuid.v4)());
|
|
158
156
|
var errorId = "error-message-".concat(textareaId);
|
|
159
157
|
|
|
160
|
-
var
|
|
161
|
-
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
162
|
-
typeof onChange === "function" && onChange(newValue);
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
var notOptionalCheck = function notOptionalCheck(value) {
|
|
158
|
+
var isNotOptional = function isNotOptional(value) {
|
|
166
159
|
return value === "" && !optional;
|
|
167
160
|
};
|
|
168
161
|
|
|
@@ -170,32 +163,37 @@ var DxcNewTextarea = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
170
163
|
return value !== "" && length && length.min && length.max && (value.length < length.min || value.length > length.max);
|
|
171
164
|
};
|
|
172
165
|
|
|
166
|
+
var changeValue = function changeValue(newValue) {
|
|
167
|
+
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
168
|
+
if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
169
|
+
value: newValue,
|
|
170
|
+
error: getNotOptionalErrorMessage()
|
|
171
|
+
});else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
172
|
+
value: newValue,
|
|
173
|
+
error: getLengthErrorMessage(length)
|
|
174
|
+
});else if (newValue && pattern && !patternMatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
175
|
+
value: newValue,
|
|
176
|
+
error: getPatternErrorMessage()
|
|
177
|
+
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
178
|
+
value: newValue,
|
|
179
|
+
error: null
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
173
183
|
var handleTOnBlur = function handleTOnBlur(event) {
|
|
174
|
-
if (
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
changeValidationError(getPatternErrorMessage());
|
|
188
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
189
|
-
value: event.target.value,
|
|
190
|
-
error: getPatternErrorMessage()
|
|
191
|
-
});
|
|
192
|
-
} else {
|
|
193
|
-
changeValidationError("");
|
|
194
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
195
|
-
value: event.target.value,
|
|
196
|
-
error: null
|
|
197
|
-
});
|
|
198
|
-
}
|
|
184
|
+
if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
185
|
+
value: event.target.value,
|
|
186
|
+
error: getNotOptionalErrorMessage()
|
|
187
|
+
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
188
|
+
value: event.target.value,
|
|
189
|
+
error: getLengthErrorMessage(length)
|
|
190
|
+
});else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
191
|
+
value: event.target.value,
|
|
192
|
+
error: getPatternErrorMessage()
|
|
193
|
+
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
194
|
+
value: event.target.value,
|
|
195
|
+
error: null
|
|
196
|
+
});
|
|
199
197
|
};
|
|
200
198
|
|
|
201
199
|
var handleTOnChange = function handleTOnChange(event) {
|
|
@@ -234,18 +232,20 @@ var DxcNewTextarea = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
234
232
|
onChange: handleTOnChange,
|
|
235
233
|
onBlur: handleTOnBlur,
|
|
236
234
|
disabled: disabled,
|
|
237
|
-
error: error
|
|
235
|
+
error: error,
|
|
236
|
+
minLength: length === null || length === void 0 ? void 0 : length.min,
|
|
237
|
+
maxLength: length === null || length === void 0 ? void 0 : length.max,
|
|
238
238
|
autoComplete: autocomplete,
|
|
239
239
|
backgroundType: backgroundType,
|
|
240
240
|
ref: textareaRef,
|
|
241
241
|
tabIndex: tabIndex,
|
|
242
|
-
"aria-invalid": error
|
|
243
|
-
"aria-describedby": error
|
|
242
|
+
"aria-invalid": error ? "true" : "false",
|
|
243
|
+
"aria-describedby": error ? errorId : undefined,
|
|
244
244
|
"aria-required": optional ? "false" : "true"
|
|
245
245
|
}), !disabled && _react["default"].createElement(Error, {
|
|
246
246
|
id: errorId,
|
|
247
247
|
backgroundType: backgroundType
|
|
248
|
-
}, error
|
|
248
|
+
}, error)));
|
|
249
249
|
});
|
|
250
250
|
|
|
251
251
|
var sizes = {
|
|
@@ -283,6 +283,8 @@ var Label = _styledComponents["default"].label(_templateObject2(), function (pro
|
|
|
283
283
|
return props.theme.labelFontStyle;
|
|
284
284
|
}, function (props) {
|
|
285
285
|
return props.theme.labelFontWeight;
|
|
286
|
+
}, function (props) {
|
|
287
|
+
return props.theme.labelLineHeight;
|
|
286
288
|
});
|
|
287
289
|
|
|
288
290
|
var OptionalLabel = _styledComponents["default"].span(_templateObject3(), function (props) {
|
|
@@ -299,6 +301,8 @@ var HelperText = _styledComponents["default"].span(_templateObject4(), function
|
|
|
299
301
|
return props.theme.helperTextFontStyle;
|
|
300
302
|
}, function (props) {
|
|
301
303
|
return props.theme.helperTextFontWeight;
|
|
304
|
+
}, function (props) {
|
|
305
|
+
return props.theme.helperTextLineHeight;
|
|
302
306
|
});
|
|
303
307
|
|
|
304
308
|
var Textarea = _styledComponents["default"].textarea(_templateObject5(), function (props) {
|
|
@@ -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,15 +11,15 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
13
11
|
|
|
14
12
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
13
|
|
|
16
|
-
var _react =
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
15
|
|
|
18
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
17
|
|
|
20
18
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
21
19
|
|
|
22
|
-
var
|
|
20
|
+
var _TextInput = _interopRequireDefault(require("../text-input/TextInput"));
|
|
23
21
|
|
|
24
|
-
var
|
|
22
|
+
var _NumberInputContext = _interopRequireDefault(require("./NumberInputContext"));
|
|
25
23
|
|
|
26
24
|
var _variables = require("../common/variables.js");
|
|
27
25
|
|
|
@@ -35,7 +33,7 @@ function _templateObject() {
|
|
|
35
33
|
return data;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
var
|
|
36
|
+
var DxcNumberInput = _react["default"].forwardRef(function (_ref, ref) {
|
|
39
37
|
var _ref$label = _ref.label,
|
|
40
38
|
label = _ref$label === void 0 ? "" : _ref$label,
|
|
41
39
|
_ref$name = _ref.name,
|
|
@@ -67,14 +65,14 @@ var DxcNumber = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
67
65
|
size = _ref$size === void 0 ? "medium" : _ref$size,
|
|
68
66
|
_ref$tabIndex = _ref.tabIndex,
|
|
69
67
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
70
|
-
return _react["default"].createElement(
|
|
68
|
+
return _react["default"].createElement(_NumberInputContext["default"].Provider, {
|
|
71
69
|
value: {
|
|
72
70
|
typeNumber: "number",
|
|
73
71
|
minNumber: min,
|
|
74
72
|
maxNumber: max,
|
|
75
73
|
stepNumber: step
|
|
76
74
|
}
|
|
77
|
-
}, _react["default"].createElement(
|
|
75
|
+
}, _react["default"].createElement(NumberInputContainer, null, _react["default"].createElement(_TextInput["default"], {
|
|
78
76
|
label: label,
|
|
79
77
|
name: name,
|
|
80
78
|
value: value,
|
|
@@ -102,9 +100,9 @@ var sizes = {
|
|
|
102
100
|
fillParent: "100%"
|
|
103
101
|
};
|
|
104
102
|
|
|
105
|
-
var
|
|
103
|
+
var NumberInputContainer = _styledComponents["default"].div(_templateObject());
|
|
106
104
|
|
|
107
|
-
|
|
105
|
+
DxcNumberInput.propTypes = {
|
|
108
106
|
label: _propTypes["default"].string,
|
|
109
107
|
name: _propTypes["default"].string,
|
|
110
108
|
value: _propTypes["default"].string,
|
|
@@ -134,5 +132,5 @@ DxcNumber.propTypes = {
|
|
|
134
132
|
size: _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(sizes))),
|
|
135
133
|
tabIndex: _propTypes["default"].number
|
|
136
134
|
};
|
|
137
|
-
var _default =
|
|
135
|
+
var _default = DxcNumberInput;
|
|
138
136
|
exports["default"] = _default;
|
|
@@ -10,7 +10,7 @@ exports["default"] = void 0;
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
12
|
/* eslint-disable prefer-template */
|
|
13
|
-
var
|
|
13
|
+
var NumberInputContext = _react["default"].createContext();
|
|
14
14
|
|
|
15
|
-
var _default =
|
|
15
|
+
var _default = NumberInputContext;
|
|
16
16
|
exports["default"] = _default;
|
|
@@ -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 input. 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 input. 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 DxcNumberInput(props: Props): JSX.Element;
|
|
@@ -21,14 +21,12 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
21
21
|
|
|
22
22
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _TextInput = _interopRequireDefault(require("../text-input/TextInput"));
|
|
25
25
|
|
|
26
26
|
var _variables = require("../common/variables.js");
|
|
27
27
|
|
|
28
|
-
require("./styles.css");
|
|
29
|
-
|
|
30
28
|
function _templateObject() {
|
|
31
|
-
var data = (0, _taggedTemplateLiteral2["default"])([""]);
|
|
29
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n & ::-ms-reveal {\n display: none;\n }\n"]);
|
|
32
30
|
|
|
33
31
|
_templateObject = function _templateObject() {
|
|
34
32
|
return data;
|
|
@@ -37,7 +35,7 @@ function _templateObject() {
|
|
|
37
35
|
return data;
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
var
|
|
38
|
+
var DxcPasswordInput = _react["default"].forwardRef(function (_ref, ref) {
|
|
41
39
|
var _ref$label = _ref.label,
|
|
42
40
|
label = _ref$label === void 0 ? "" : _ref$label,
|
|
43
41
|
_ref$name = _ref.name,
|
|
@@ -45,17 +43,17 @@ var DxcPassword = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
45
43
|
value = _ref.value,
|
|
46
44
|
_ref$helperText = _ref.helperText,
|
|
47
45
|
helperText = _ref$helperText === void 0 ? "" : _ref$helperText,
|
|
48
|
-
_ref$error = _ref.error,
|
|
49
|
-
error = _ref$error === void 0 ? "" : _ref$error,
|
|
50
46
|
_ref$clearable = _ref.clearable,
|
|
51
47
|
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
52
48
|
onChange = _ref.onChange,
|
|
53
49
|
onBlur = _ref.onBlur,
|
|
54
|
-
|
|
50
|
+
_ref$error = _ref.error,
|
|
51
|
+
error = _ref$error === void 0 ? "" : _ref$error,
|
|
55
52
|
pattern = _ref.pattern,
|
|
56
53
|
length = _ref.length,
|
|
57
54
|
_ref$autocomplete = _ref.autocomplete,
|
|
58
55
|
autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
|
|
56
|
+
margin = _ref.margin,
|
|
59
57
|
_ref$size = _ref.size,
|
|
60
58
|
size = _ref$size === void 0 ? "medium" : _ref$size,
|
|
61
59
|
_ref$tabIndex = _ref.tabIndex,
|
|
@@ -141,9 +139,9 @@ var DxcPassword = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
141
139
|
d: "M12 6c3.79 0 7.17 2.13 8.82 5.5C19.17 14.87 15.79 17 12 17s-7.17-2.13-8.82-5.5C4.83 8.13 8.21 6 12 6m0-2C7 4 2.73 7.11 1 11.5 2.73 15.89 7 19 12 19s9.27-3.11 11-7.5C21.27 7.11 17 4 12 4zm0 5c1.38 0 2.5 1.12 2.5 2.5S13.38 14 12 14s-2.5-1.12-2.5-2.5S10.62 9 12 9m0-2c-2.48 0-4.5 2.02-4.5 4.5S9.52 16 12 16s4.5-2.02 4.5-4.5S14.48 7 12 7z"
|
|
142
140
|
}))
|
|
143
141
|
};
|
|
144
|
-
return _react["default"].createElement(
|
|
142
|
+
return _react["default"].createElement(PasswordInput, {
|
|
145
143
|
ref: ref
|
|
146
|
-
}, _react["default"].createElement(
|
|
144
|
+
}, _react["default"].createElement(_TextInput["default"], {
|
|
147
145
|
ref: inputRef,
|
|
148
146
|
label: label,
|
|
149
147
|
name: name,
|
|
@@ -170,9 +168,9 @@ var sizes = {
|
|
|
170
168
|
fillParent: "100%"
|
|
171
169
|
};
|
|
172
170
|
|
|
173
|
-
var
|
|
171
|
+
var PasswordInput = _styledComponents["default"].div(_templateObject());
|
|
174
172
|
|
|
175
|
-
|
|
173
|
+
DxcPasswordInput.propTypes = {
|
|
176
174
|
label: _propTypes["default"].string,
|
|
177
175
|
name: _propTypes["default"].string,
|
|
178
176
|
value: _propTypes["default"].string,
|
|
@@ -196,5 +194,5 @@ DxcPassword.propTypes = {
|
|
|
196
194
|
}),
|
|
197
195
|
tabIndex: _propTypes["default"].number
|
|
198
196
|
};
|
|
199
|
-
var _default =
|
|
197
|
+
var _default = DxcPasswordInput;
|
|
200
198
|
exports["default"] = _default;
|