@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
|
@@ -37,7 +37,7 @@ var _variables = require("../common/variables.js");
|
|
|
37
37
|
|
|
38
38
|
var _useTheme = _interopRequireDefault(require("../useTheme.js"));
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _TextInput = _interopRequireDefault(require("../text-input/TextInput"));
|
|
41
41
|
|
|
42
42
|
function _templateObject() {
|
|
43
43
|
var data = (0, _taggedTemplateLiteral2["default"])([""]);
|
|
@@ -49,9 +49,7 @@ function _templateObject() {
|
|
|
49
49
|
return data;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
var
|
|
53
|
-
var _colorsTheme$date, _colorsTheme$date2;
|
|
54
|
-
|
|
52
|
+
var DxcDateInput = _react["default"].forwardRef(function (_ref, ref) {
|
|
55
53
|
var _ref$label = _ref.label,
|
|
56
54
|
label = _ref$label === void 0 ? "" : _ref$label,
|
|
57
55
|
_ref$name = _ref.name,
|
|
@@ -86,20 +84,15 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
86
84
|
innerValue = _useState2[0],
|
|
87
85
|
setInnerValue = _useState2[1];
|
|
88
86
|
|
|
89
|
-
var _useState3 = (0, _react.useState)(
|
|
87
|
+
var _useState3 = (0, _react.useState)(false),
|
|
90
88
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
isOpen = _useState4[0],
|
|
90
|
+
setIsOpen = _useState4[1];
|
|
93
91
|
|
|
94
|
-
var _useState5 = (0, _react.useState)(
|
|
92
|
+
var _useState5 = (0, _react.useState)(null),
|
|
95
93
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
var _useState7 = (0, _react.useState)(null),
|
|
100
|
-
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
101
|
-
anchorEl = _useState8[0],
|
|
102
|
-
setAnchorEl = _useState8[1];
|
|
94
|
+
anchorEl = _useState6[0],
|
|
95
|
+
setAnchorEl = _useState6[1];
|
|
103
96
|
|
|
104
97
|
var colorsTheme = (0, _useTheme["default"])();
|
|
105
98
|
|
|
@@ -114,31 +107,36 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
114
107
|
};
|
|
115
108
|
|
|
116
109
|
var handleCalendarOnClick = function handleCalendarOnClick(newDate) {
|
|
117
|
-
var
|
|
118
|
-
value !== null && value !== void 0 ? value : setInnerValue(
|
|
119
|
-
|
|
120
|
-
value:
|
|
110
|
+
var newValue = (0, _moment["default"])(newDate).format(format.toUpperCase());
|
|
111
|
+
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
112
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
113
|
+
value: newValue,
|
|
114
|
+
error: null,
|
|
121
115
|
date: newDate && newDate.toJSON() ? newDate : null
|
|
122
116
|
});
|
|
123
117
|
};
|
|
124
118
|
|
|
125
|
-
var handleIOnChange = function handleIOnChange(
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
119
|
+
var handleIOnChange = function handleIOnChange(_ref2) {
|
|
120
|
+
var newValue = _ref2.value,
|
|
121
|
+
inputError = _ref2.error;
|
|
122
|
+
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
123
|
+
var momentDate = (0, _moment["default"])(newValue, format.toUpperCase(), true);
|
|
124
|
+
var invalidDateMessage = newValue !== "" && !momentDate.isValid() ? "Invalid date." : null;
|
|
125
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
126
|
+
value: newValue,
|
|
127
|
+
error: inputError || invalidDateMessage,
|
|
130
128
|
date: momentDate.isValid() ? momentDate._d : null
|
|
131
129
|
});
|
|
132
130
|
};
|
|
133
131
|
|
|
134
|
-
var handleIOnBlur = function handleIOnBlur(
|
|
135
|
-
var value =
|
|
132
|
+
var handleIOnBlur = function handleIOnBlur(_ref3) {
|
|
133
|
+
var value = _ref3.value,
|
|
134
|
+
inputError = _ref3.error;
|
|
136
135
|
var momentDate = (0, _moment["default"])(value, format.toUpperCase(), true);
|
|
137
136
|
var invalidDateMessage = value !== "" && !momentDate.isValid() ? "Invalid date." : null;
|
|
138
|
-
|
|
139
|
-
typeof onBlur === "function" && onBlur({
|
|
137
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
140
138
|
value: value,
|
|
141
|
-
error: invalidDateMessage,
|
|
139
|
+
error: inputError || invalidDateMessage,
|
|
142
140
|
date: momentDate.isValid() ? momentDate._d : null
|
|
143
141
|
});
|
|
144
142
|
};
|
|
@@ -162,44 +160,44 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
162
160
|
onClick: openCalendar,
|
|
163
161
|
icon: _react["default"].createElement("svg", {
|
|
164
162
|
xmlns: "http://www.w3.org/2000/svg",
|
|
165
|
-
height: "
|
|
163
|
+
height: "24",
|
|
166
164
|
viewBox: "0 0 24 24",
|
|
167
|
-
width: "
|
|
165
|
+
width: "24",
|
|
168
166
|
fill: "currentColor"
|
|
169
167
|
}, _react["default"].createElement("path", {
|
|
170
|
-
d: "M0
|
|
168
|
+
d: "M0 0h24v24H0z",
|
|
171
169
|
fill: "none"
|
|
172
170
|
}), _react["default"].createElement("path", {
|
|
173
|
-
d: "
|
|
171
|
+
d: "M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 18H4V8h16v13z"
|
|
174
172
|
}))
|
|
175
173
|
};
|
|
176
174
|
var dateTheme = (0, _core.createMuiTheme)({
|
|
177
175
|
overrides: {
|
|
178
176
|
MuiTypography: {
|
|
179
177
|
root: {
|
|
180
|
-
fontFamily: "".concat(colorsTheme.
|
|
178
|
+
fontFamily: "".concat(colorsTheme.dateInput.pickerFontFamily, " !important")
|
|
181
179
|
}
|
|
182
180
|
},
|
|
183
181
|
MuiPickersYearSelection: {
|
|
184
182
|
container: {
|
|
185
|
-
color: colorsTheme.
|
|
183
|
+
color: colorsTheme.dateInput.pickerYearFontColor,
|
|
186
184
|
"&::-webkit-scrollbar": {
|
|
187
185
|
width: "3px"
|
|
188
186
|
},
|
|
189
187
|
"&::-webkit-scrollbar-track": {
|
|
190
|
-
backgroundColor:
|
|
188
|
+
backgroundColor: "#D9D9D9",
|
|
191
189
|
borderRadius: "3px"
|
|
192
190
|
},
|
|
193
191
|
"&::-webkit-scrollbar-thumb": {
|
|
194
|
-
backgroundColor:
|
|
192
|
+
backgroundColor: "#666666",
|
|
195
193
|
borderRadius: "3px"
|
|
196
194
|
}
|
|
197
195
|
}
|
|
198
196
|
},
|
|
199
197
|
MuiPickersToolbar: {
|
|
200
198
|
toolbar: {
|
|
201
|
-
backgroundColor: colorsTheme.
|
|
202
|
-
color: colorsTheme.
|
|
199
|
+
backgroundColor: colorsTheme.dateInput.pickerBackgroundColor,
|
|
200
|
+
color: colorsTheme.dateInput.pickerDayFontColor
|
|
203
201
|
}
|
|
204
202
|
},
|
|
205
203
|
MuiIconButton: {
|
|
@@ -217,7 +215,7 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
217
215
|
MuiButtonBase: {
|
|
218
216
|
root: {
|
|
219
217
|
"&:focus": {
|
|
220
|
-
outline: colorsTheme.
|
|
218
|
+
outline: colorsTheme.dateInput.pickerFocusColor + " solid 2px"
|
|
221
219
|
}
|
|
222
220
|
}
|
|
223
221
|
},
|
|
@@ -227,38 +225,38 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
227
225
|
maxWidth: "unset",
|
|
228
226
|
minHeight: "unset",
|
|
229
227
|
padding: "0px 10px",
|
|
230
|
-
height: colorsTheme.
|
|
231
|
-
width: colorsTheme.
|
|
232
|
-
backgroundColor: colorsTheme.
|
|
233
|
-
fontFamily: colorsTheme.
|
|
228
|
+
height: colorsTheme.dateInput.pickerHeight,
|
|
229
|
+
width: colorsTheme.dateInput.pickerWidth,
|
|
230
|
+
backgroundColor: colorsTheme.dateInput.pickerBackgroundColor,
|
|
231
|
+
fontFamily: colorsTheme.dateInput.pickerFontFamily
|
|
234
232
|
}
|
|
235
233
|
},
|
|
236
234
|
MuiPickersToolbarText: {
|
|
237
235
|
toolbarTxt: {
|
|
238
|
-
color: colorsTheme
|
|
239
|
-
fontFamily: colorsTheme
|
|
236
|
+
color: colorsTheme.dateInput.pickerActualDateFontColor,
|
|
237
|
+
fontFamily: colorsTheme.dateInput.pickerFontFamily,
|
|
240
238
|
fontSize: "2rem"
|
|
241
239
|
},
|
|
242
240
|
toolbarBtnSelected: {
|
|
243
|
-
color: colorsTheme.
|
|
241
|
+
color: colorsTheme.dateInput.pickerActualDateFontColor
|
|
244
242
|
}
|
|
245
243
|
},
|
|
246
244
|
MuiPickersCalendarHeader: {
|
|
247
245
|
transitionContainer: {
|
|
248
|
-
color: colorsTheme.
|
|
246
|
+
color: colorsTheme.dateInput.pickerMonthFontColor
|
|
249
247
|
},
|
|
250
248
|
dayLabel: {
|
|
251
|
-
color: colorsTheme.
|
|
252
|
-
fontFamily: colorsTheme.
|
|
249
|
+
color: colorsTheme.dateInput.pickerWeekFontColor,
|
|
250
|
+
fontFamily: colorsTheme.dateInput.pickerFontFamily
|
|
253
251
|
},
|
|
254
252
|
switchHeader: {
|
|
255
|
-
backgroundColor:
|
|
256
|
-
color: colorsTheme.
|
|
253
|
+
backgroundColor: "#ffffff",
|
|
254
|
+
color: colorsTheme.dateInput.pickerDayFontColor
|
|
257
255
|
},
|
|
258
256
|
iconButton: {
|
|
259
|
-
backgroundColor: colorsTheme.
|
|
257
|
+
backgroundColor: colorsTheme.dateInput.pickerMonthArrowsBackgroundColor,
|
|
260
258
|
"&:hover": {
|
|
261
|
-
backgroundColor: colorsTheme.
|
|
259
|
+
backgroundColor: colorsTheme.dateInput.pickerMonthArrowsBackgroundColor
|
|
262
260
|
}
|
|
263
261
|
}
|
|
264
262
|
},
|
|
@@ -269,38 +267,37 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
269
267
|
},
|
|
270
268
|
MuiPickersDay: {
|
|
271
269
|
current: {
|
|
272
|
-
|
|
273
|
-
color: colorsTheme.date.pickerFontColor
|
|
270
|
+
color: colorsTheme.dateInput.pickerDayFontColor
|
|
274
271
|
},
|
|
275
272
|
day: {
|
|
276
|
-
fontFamily: colorsTheme.
|
|
277
|
-
color: colorsTheme.
|
|
273
|
+
fontFamily: colorsTheme.dateInput.pickerFontFamily,
|
|
274
|
+
color: colorsTheme.dateInput.pickerDayFontColor,
|
|
278
275
|
"&:hover": {
|
|
279
|
-
backgroundColor: colorsTheme.
|
|
280
|
-
color: colorsTheme.
|
|
276
|
+
backgroundColor: colorsTheme.dateInput.pickerHoverDateBackgroundColor,
|
|
277
|
+
color: colorsTheme.dateInput.pickerHoverDateFontColor
|
|
281
278
|
}
|
|
282
279
|
},
|
|
283
280
|
daySelected: {
|
|
284
|
-
backgroundColor: colorsTheme.
|
|
285
|
-
color: colorsTheme.
|
|
281
|
+
backgroundColor: colorsTheme.dateInput.pickerSelectedDateBackgroundColor,
|
|
282
|
+
color: colorsTheme.dateInput.pickerSelectedDateColor,
|
|
286
283
|
"&:hover": {
|
|
287
|
-
backgroundColor: colorsTheme.
|
|
288
|
-
color: colorsTheme.
|
|
284
|
+
backgroundColor: colorsTheme.dateInput.pickerSelectedDateBackgroundColor,
|
|
285
|
+
color: colorsTheme.dateInput.pickerSelectedDateColor,
|
|
289
286
|
opacity: "1"
|
|
290
287
|
}
|
|
291
288
|
}
|
|
292
289
|
},
|
|
293
290
|
MuiPickersYear: {
|
|
294
291
|
yearSelected: {
|
|
295
|
-
color: colorsTheme.
|
|
296
|
-
backgroundColor: colorsTheme.
|
|
292
|
+
color: colorsTheme.dateInput.pickerSelectedDateColor,
|
|
293
|
+
backgroundColor: colorsTheme.dateInput.pickerSelectedDateBackgroundColor,
|
|
297
294
|
margin: "0px 100px",
|
|
298
295
|
borderRadius: "20px"
|
|
299
296
|
},
|
|
300
297
|
root: {
|
|
301
298
|
"&:focus": {
|
|
302
|
-
color: colorsTheme.
|
|
303
|
-
backgroundColor: colorsTheme.
|
|
299
|
+
color: colorsTheme.dateInput.pickerHoverDateFontColor,
|
|
300
|
+
backgroundColor: colorsTheme.dateInput.pickerHoverDateBackgroundColor
|
|
304
301
|
}
|
|
305
302
|
}
|
|
306
303
|
},
|
|
@@ -317,7 +314,7 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
317
314
|
theme: dateTheme
|
|
318
315
|
}, _react["default"].createElement(_pickers.MuiPickersUtilsProvider, {
|
|
319
316
|
utils: _dateFns["default"]
|
|
320
|
-
}, _react["default"].createElement(StyledDPicker, null, _react["default"].createElement(
|
|
317
|
+
}, _react["default"].createElement(StyledDPicker, null, _react["default"].createElement(_TextInput["default"], {
|
|
321
318
|
label: label,
|
|
322
319
|
name: name,
|
|
323
320
|
value: value !== null && value !== void 0 ? value : innerValue,
|
|
@@ -329,7 +326,7 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
|
|
|
329
326
|
optional: optional,
|
|
330
327
|
onChange: handleIOnChange,
|
|
331
328
|
onBlur: handleIOnBlur,
|
|
332
|
-
error: error
|
|
329
|
+
error: error,
|
|
333
330
|
autocomplete: autocomplete,
|
|
334
331
|
margin: margin,
|
|
335
332
|
size: size,
|
|
@@ -376,7 +373,7 @@ var sizes = {
|
|
|
376
373
|
|
|
377
374
|
var StyledDPicker = _styledComponents["default"].div(_templateObject());
|
|
378
375
|
|
|
379
|
-
|
|
376
|
+
DxcDateInput.propTypes = {
|
|
380
377
|
label: _propTypes["default"].string,
|
|
381
378
|
name: _propTypes["default"].string,
|
|
382
379
|
value: _propTypes["default"].string,
|
|
@@ -399,5 +396,5 @@ DxcNewDate.propTypes = {
|
|
|
399
396
|
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
|
|
400
397
|
tabIndex: _propTypes["default"].number
|
|
401
398
|
};
|
|
402
|
-
var _default =
|
|
399
|
+
var _default = DxcDateInput;
|
|
403
400
|
exports["default"] = _default;
|
|
@@ -0,0 +1,95 @@
|
|
|
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 date.
|
|
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
|
+
* The format in which the date value will be displayed. User must use this format when editing the value or it will be considered as an invalid date.
|
|
25
|
+
*/
|
|
26
|
+
format?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Helper text to be placed above the date.
|
|
29
|
+
*/
|
|
30
|
+
helperText?: string;
|
|
31
|
+
/**
|
|
32
|
+
* If true, the date format will appear as placeholder in the field.
|
|
33
|
+
*/
|
|
34
|
+
placeholder?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* If true, the date input will have an action to clear the entered value.
|
|
37
|
+
*/
|
|
38
|
+
clearable?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* If true, the component will be disabled.
|
|
41
|
+
*/
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* If true, the date will be optional, showing '(Optional)'
|
|
45
|
+
* next to the label. Otherwise, the field will be considered required and an error will be
|
|
46
|
+
* passed as a parameter to the OnBlur and onChange functions when it has
|
|
47
|
+
* not been filled.
|
|
48
|
+
*/
|
|
49
|
+
optional?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* This function will be called when the user types within the input
|
|
52
|
+
* element of the component. An object including the string value, the
|
|
53
|
+
* error and the date value will be passed to this function.
|
|
54
|
+
* If the string value is a valid date, error will
|
|
55
|
+
* be null. Also, if the string value is not a valid date, date will be null.
|
|
56
|
+
*/
|
|
57
|
+
onChange?: (val: { value: string; error: string; date: Date }) => void;
|
|
58
|
+
/**
|
|
59
|
+
* This function will be called when the input element loses the focus.
|
|
60
|
+
* An object including the string value, the error and the date value
|
|
61
|
+
* will be passed to this function. If the string value is a valid date, error will
|
|
62
|
+
* be null. Also, if the string value is not a valid date, date will be null.
|
|
63
|
+
*/
|
|
64
|
+
onBlur?: (val: { value: string; error: string; date: Date }) => void;
|
|
65
|
+
/**
|
|
66
|
+
* If it is defined, the component will change its appearance, showing
|
|
67
|
+
* the error below the date input component. If it is not defined, the error
|
|
68
|
+
* messages will be managed internally, but never displayed on its own.
|
|
69
|
+
*/
|
|
70
|
+
error?: string;
|
|
71
|
+
/**
|
|
72
|
+
* HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the input value.
|
|
73
|
+
* Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
|
|
74
|
+
*/
|
|
75
|
+
autocomplete?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
78
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
79
|
+
*/
|
|
80
|
+
margin?: Space | Margin;
|
|
81
|
+
/**
|
|
82
|
+
* Size of the component ('medium' | 'large' | 'fillParent').
|
|
83
|
+
*/
|
|
84
|
+
size?: Size;
|
|
85
|
+
/**
|
|
86
|
+
* Value of the tabindex attribute.
|
|
87
|
+
*/
|
|
88
|
+
tabIndex?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Reference to the component.
|
|
91
|
+
*/
|
|
92
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default function DxcDateInput(props: Props): JSX.Element;
|
|
@@ -108,7 +108,7 @@ function _templateObject5() {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
function _templateObject4() {
|
|
111
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: calc(320px - 2px);\n display: flex;\n flex-direction: ", ";\n align-items: center;\n border-radius: ", ";\n
|
|
111
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: calc(320px - 2px);\n display: flex;\n flex-direction: ", ";\n align-items: center;\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n background-color: ", ";\n border-color: ", ";\n cursor: ", ";\n"]);
|
|
112
112
|
|
|
113
113
|
_templateObject4 = function _templateObject4() {
|
|
114
114
|
return data;
|
|
@@ -138,7 +138,7 @@ function _templateObject2() {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
function _templateObject() {
|
|
141
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"]);
|
|
141
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n width: fit-content;\n"]);
|
|
142
142
|
|
|
143
143
|
_templateObject = function _templateObject() {
|
|
144
144
|
return data;
|
|
@@ -219,9 +219,11 @@ var DxcFileInput = function DxcFileInput(_ref) {
|
|
|
219
219
|
files = _useState4[0],
|
|
220
220
|
setFiles = _useState4[1];
|
|
221
221
|
|
|
222
|
+
var _useState5 = (0, _react.useState)("file-input-".concat((0, _uuid.v4)())),
|
|
223
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 1),
|
|
224
|
+
fileInputId = _useState6[0];
|
|
225
|
+
|
|
222
226
|
var colorsTheme = (0, _useTheme["default"])();
|
|
223
|
-
var fileInputId = "file-input-".concat((0, _uuid.v4)());
|
|
224
|
-
var labelFileInputId = "label-".concat(fileInputId);
|
|
225
227
|
(0, _react.useEffect)(function () {
|
|
226
228
|
if (value) {
|
|
227
229
|
setFiles(value);
|
|
@@ -442,7 +444,7 @@ var DxcFileInput = function DxcFileInput(_ref) {
|
|
|
442
444
|
name: name,
|
|
443
445
|
tabIndex: tabIndex
|
|
444
446
|
}, _react["default"].createElement(Label, {
|
|
445
|
-
|
|
447
|
+
htmlFor: fileInputId,
|
|
446
448
|
disabled: disabled
|
|
447
449
|
}, label), _react["default"].createElement(HelperText, {
|
|
448
450
|
disabled: disabled
|
|
@@ -566,9 +568,11 @@ var DragDropArea = _styledComponents["default"].div(_templateObject4(), function
|
|
|
566
568
|
}, function (props) {
|
|
567
569
|
return props.theme.dropBorderRadius;
|
|
568
570
|
}, function (props) {
|
|
569
|
-
return props.isDragging
|
|
571
|
+
return !props.isDragging ? props.theme.dropBorderThickness : "2px";
|
|
570
572
|
}, function (props) {
|
|
571
|
-
return !props.isDragging ? props.theme.
|
|
573
|
+
return !props.isDragging ? props.theme.dropBorderStyle : "solid";
|
|
574
|
+
}, function (props) {
|
|
575
|
+
return props.isDragging && props.theme.focusDropBackgroundColor;
|
|
572
576
|
}, function (props) {
|
|
573
577
|
return props.disabled ? props.theme.disabledDropBorderColor : props.isDragging ? props.theme.focusDropBorderColor : props.theme.dropBorderColor;
|
|
574
578
|
}, function (props) {
|
|
@@ -626,7 +630,6 @@ DxcFileInput.propTypes = {
|
|
|
626
630
|
multiple: _propTypes["default"].bool,
|
|
627
631
|
showPreview: _propTypes["default"].bool,
|
|
628
632
|
disabled: _propTypes["default"].bool,
|
|
629
|
-
error: _propTypes["default"].string,
|
|
630
633
|
callbackFile: _propTypes["default"].func,
|
|
631
634
|
value: _propTypes["default"].array,
|
|
632
635
|
tabIndex: _propTypes["default"].number,
|
|
@@ -90,7 +90,7 @@ function _templateObject4() {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
function _templateObject3() {
|
|
93
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n"]);
|
|
93
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n align-items: center;\n"]);
|
|
94
94
|
|
|
95
95
|
_templateObject3 = function _templateObject3() {
|
|
96
96
|
return data;
|
|
@@ -110,7 +110,7 @@ function _templateObject2() {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function _templateObject() {
|
|
113
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n padding: ", ";\n background-color: ", ";\n border-radius: ", ";\n width: ", ";\n height: ", ";\n border: ", "
|
|
113
|
+
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n padding: ", ";\n background-color: ", ";\n border-radius: ", ";\n width: ", ";\n min-height: ", ";\n border-color: ", ";\n border-width: ", ";\n border-style: ", ";\n display: flex;\n justify-content: center;\n"]);
|
|
114
114
|
|
|
115
115
|
_templateObject = function _templateObject() {
|
|
116
116
|
return data;
|
|
@@ -156,6 +156,19 @@ var FileItem = function FileItem(_ref) {
|
|
|
156
156
|
onDelete = _ref.onDelete;
|
|
157
157
|
var colorsTheme = (0, _useTheme["default"])();
|
|
158
158
|
var isImage = type.includes("image");
|
|
159
|
+
|
|
160
|
+
var getIconAriaLabel = function getIconAriaLabel() {
|
|
161
|
+
if (type.includes("video")) {
|
|
162
|
+
return "video";
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (type.includes("audio")) {
|
|
166
|
+
return "audio";
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return "file";
|
|
170
|
+
};
|
|
171
|
+
|
|
159
172
|
return _react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
160
173
|
theme: colorsTheme.fileInput
|
|
161
174
|
}, _react["default"].createElement(Container, {
|
|
@@ -165,9 +178,11 @@ var FileItem = function FileItem(_ref) {
|
|
|
165
178
|
showPreview: showPreview,
|
|
166
179
|
numFiles: numFiles
|
|
167
180
|
}, showPreview && (isImage ? _react["default"].createElement(ImagePreview, {
|
|
168
|
-
src: preview
|
|
181
|
+
src: preview,
|
|
182
|
+
alt: name
|
|
169
183
|
}) : _react["default"].createElement(IconPreviewContainer, {
|
|
170
|
-
error: error
|
|
184
|
+
error: error,
|
|
185
|
+
"aria-label": getIconAriaLabel()
|
|
171
186
|
}, _react["default"].createElement(IconPreview, {
|
|
172
187
|
error: error
|
|
173
188
|
}, preview))), _react["default"].createElement(FileItemContent, null, _react["default"].createElement(FileItemContainer, null, _react["default"].createElement(FileName, {
|
|
@@ -182,7 +197,7 @@ var FileItem = function FileItem(_ref) {
|
|
|
182
197
|
onClick: function onClick() {
|
|
183
198
|
return onDelete(name);
|
|
184
199
|
},
|
|
185
|
-
"aria-label": "Remove"
|
|
200
|
+
"aria-label": "Remove ".concat(name)
|
|
186
201
|
}, deleteIcon)), error && (multiple || numFiles > 1) && _react["default"].createElement(ErrorMessage, null, error))));
|
|
187
202
|
};
|
|
188
203
|
|
|
@@ -199,7 +214,9 @@ var Container = _styledComponents["default"].div(_templateObject(), function (pr
|
|
|
199
214
|
}, function (props) {
|
|
200
215
|
return props.error ? props.theme.errorFileItemBorderColor : props.theme.fileItemBorderColor;
|
|
201
216
|
}, function (props) {
|
|
202
|
-
return props.theme.
|
|
217
|
+
return props.theme.fileItemBorderThickness;
|
|
218
|
+
}, function (props) {
|
|
219
|
+
return props.theme.fileItemBorderStyle;
|
|
203
220
|
});
|
|
204
221
|
|
|
205
222
|
var FileItemContent = _styledComponents["default"].div(_templateObject2());
|
|
@@ -209,9 +226,9 @@ var FileItemContainer = _styledComponents["default"].div(_templateObject3());
|
|
|
209
226
|
var ImagePreview = _styledComponents["default"].img(_templateObject4());
|
|
210
227
|
|
|
211
228
|
var IconPreviewContainer = _styledComponents["default"].div(_templateObject5(), function (props) {
|
|
212
|
-
return props.error ?
|
|
229
|
+
return props.error ? props.theme.errorFileItemIconBackgroundColor : props.theme.fileItemIconBackgroundColor;
|
|
213
230
|
}, function (props) {
|
|
214
|
-
return props.error ?
|
|
231
|
+
return props.error ? props.theme.errorFileItemIconColor : props.theme.fileItemIconColor;
|
|
215
232
|
});
|
|
216
233
|
|
|
217
234
|
var IconPreview = _styledComponents["default"].div(_templateObject6());
|
|
@@ -0,0 +1,81 @@
|
|
|
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 FileData = {
|
|
10
|
+
error?: string;
|
|
11
|
+
file?: File;
|
|
12
|
+
preview?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type Props = {
|
|
16
|
+
/**
|
|
17
|
+
* Name attribute of the file input element.
|
|
18
|
+
*/
|
|
19
|
+
name?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Text to be placed above the file input.
|
|
22
|
+
*/
|
|
23
|
+
label?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Uses one of the available file input modes:
|
|
26
|
+
* 'file': Files are selected by clicking the button and selecting it through the file explorer.
|
|
27
|
+
* 'filedrop': Files can be selected by clicking the button and selecting it through the file explorer or by dropping them inside the drag and drop area.
|
|
28
|
+
* 'dropzone': Files can be selected by clicking the button and selecting it through the file explorer or by dropping them inside the drag and drop area.
|
|
29
|
+
* The drag and drop area of this mode is bigger than the one of the filedrop mode.
|
|
30
|
+
*/
|
|
31
|
+
mode?: "file" | "filedrop" | "dropzone";
|
|
32
|
+
/**
|
|
33
|
+
* Helper text to be placed above the file input.
|
|
34
|
+
*/
|
|
35
|
+
helperText?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Defines the file types accepted by the component. It is not possible to select a file with a non valid type.
|
|
38
|
+
*/
|
|
39
|
+
accept?: string;
|
|
40
|
+
/**
|
|
41
|
+
* An array of FileData representing the selected files.
|
|
42
|
+
*/
|
|
43
|
+
value?: FileData[];
|
|
44
|
+
/**
|
|
45
|
+
* Minimum file size allowed (in bytes). If the file size does not comply the minSize, an error will be passed to the FileData.
|
|
46
|
+
*/
|
|
47
|
+
minSize?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Maximum file size allowed (in bytes). If the file size does not comply the maxSize, an error will be passed to the FileData.
|
|
50
|
+
*/
|
|
51
|
+
maxSize?: number;
|
|
52
|
+
/**
|
|
53
|
+
* If true and if the file is an image, a preview of it will be shown. If it is not an image, an icon refering to the file's type will be shown.
|
|
54
|
+
* If mode is not multiple and there is one file already selected, the file will be replaced by the last selected one.
|
|
55
|
+
*/
|
|
56
|
+
showPreview?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* If true, more than one file can be selected. If false, only one file can be selected.
|
|
59
|
+
*/
|
|
60
|
+
multiple?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* If true, the component will be disabled.
|
|
63
|
+
*/
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* This function will be called when the user selects or drops a file. The list of files will be sent as a parameter.
|
|
67
|
+
* In this function, the files can be updated or returned as they come. These files must be passed to the value in order to be shown.
|
|
68
|
+
*/
|
|
69
|
+
callbackFile?: (files: FileData[]) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
72
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
73
|
+
*/
|
|
74
|
+
margin?: Space | Margin;
|
|
75
|
+
/**
|
|
76
|
+
* Value of the tabindex attribute.
|
|
77
|
+
*/
|
|
78
|
+
tabIndex?: number;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default function DxcTextInput(props: Props): JSX.Element;
|
|
@@ -166,7 +166,7 @@ var makeCancelable = function makeCancelable(promise) {
|
|
|
166
166
|
};
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
-
var
|
|
169
|
+
var V3DxcInputText = function V3DxcInputText(_ref) {
|
|
170
170
|
var _ref$label = _ref.label,
|
|
171
171
|
label = _ref$label === void 0 ? " " : _ref$label,
|
|
172
172
|
_ref$name = _ref.name,
|
|
@@ -672,7 +672,7 @@ var TextContainer = _styledComponents["default"].div(_templateObject10(), functi
|
|
|
672
672
|
return props.backgroundType === "dark" ? props.theme.disabledColorOnDark : props.theme.disabledColor;
|
|
673
673
|
});
|
|
674
674
|
|
|
675
|
-
|
|
675
|
+
V3DxcInputText.propTypes = {
|
|
676
676
|
label: _propTypes["default"].string,
|
|
677
677
|
name: _propTypes["default"].string,
|
|
678
678
|
value: _propTypes["default"].string,
|
|
@@ -703,5 +703,5 @@ DxcInputText.propTypes = {
|
|
|
703
703
|
autocompleteOptions: _propTypes["default"].any,
|
|
704
704
|
tabIndex: _propTypes["default"].number
|
|
705
705
|
};
|
|
706
|
-
var _default =
|
|
706
|
+
var _default = V3DxcInputText;
|
|
707
707
|
exports["default"] = _default;
|
package/dist/main.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
export { default as DxcAlert } from "./alert/index";
|
|
2
|
-
export { default as
|
|
2
|
+
export { default as DxcNewSelect } from "./new-select/index";
|
|
3
|
+
export { default as DxcTextInput } from "./text-input/index";
|
|
4
|
+
export { default as DxcDateInput } from "./date-input/index";
|
|
5
|
+
export { default as DxcNewTextarea } from "./new-textarea/index";
|
|
6
|
+
export { default as DxcNumberInput } from "./number-input/index";
|
|
7
|
+
export { default as DxcPasswordInput } from "./password-input/index";
|
|
8
|
+
export { default as DxcFileInput } from "./file-input/index";
|