@dxc-technology/halstack-react 0.0.0-a5074e7 → 0.0.0-a5b9b2c
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/HalstackContext.js +90 -50
- package/accordion/Accordion.js +7 -13
- package/accordion/Accordion.stories.tsx +102 -13
- package/alert/Alert.stories.tsx +28 -0
- package/box/Box.stories.tsx +15 -0
- package/button/Button.js +11 -13
- package/button/Button.stories.tsx +150 -8
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +4 -3
- package/checkbox/Checkbox.stories.tsx +52 -0
- package/checkbox/types.d.ts +4 -0
- package/chip/Chip.js +16 -22
- package/chip/Chip.stories.tsx +96 -9
- package/common/variables.js +259 -249
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.js +134 -237
- package/date-input/DateInput.stories.tsx +199 -33
- package/date-input/DateInput.test.js +494 -138
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +146 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +75 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +126 -0
- package/date-input/types.d.ts +51 -0
- package/dialog/Dialog.js +1 -3
- package/dialog/Dialog.stories.tsx +42 -20
- package/dropdown/Dropdown.js +35 -35
- package/dropdown/Dropdown.stories.tsx +210 -84
- package/dropdown/Dropdown.test.js +17 -22
- package/dropdown/DropdownMenu.js +8 -18
- package/dropdown/DropdownMenuItem.js +4 -15
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +25 -45
- package/file-input/FileInput.stories.tsx +96 -17
- package/file-input/FileInput.test.js +12 -12
- package/file-input/FileItem.d.ts +2 -12
- package/file-input/FileItem.js +28 -41
- package/file-input/types.d.ts +17 -0
- package/footer/Footer.stories.tsx +91 -0
- package/header/Header.js +18 -20
- package/header/Header.stories.tsx +149 -6
- package/link/Link.js +1 -1
- package/link/Link.stories.tsx +60 -0
- package/number-input/NumberInput.test.js +5 -6
- package/package.json +7 -12
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +5 -11
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +17 -10
- package/progress-bar/ProgressBar.js +4 -4
- package/progress-bar/ProgressBar.stories.jsx +35 -2
- package/quick-nav/QuickNav.stories.tsx +14 -0
- package/radio-group/RadioGroup.stories.tsx +131 -18
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.js +48 -105
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +40 -63
- package/resultsetTable/types.d.ts +2 -2
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +5 -34
- package/select/Option.js +11 -24
- package/select/Select.js +43 -24
- package/select/Select.stories.tsx +494 -150
- package/select/Select.test.js +17 -22
- package/select/types.d.ts +2 -2
- package/sidenav/Sidenav.js +8 -10
- package/sidenav/Sidenav.stories.tsx +148 -46
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +9 -8
- package/slider/Slider.stories.tsx +57 -0
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +2 -2
- package/spinner/Spinner.stories.jsx +27 -1
- package/switch/Switch.d.ts +3 -3
- package/switch/Switch.js +5 -4
- package/switch/Switch.stories.tsx +33 -0
- package/switch/types.d.ts +6 -1
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +1 -1
- package/tabs/Tab.js +3 -5
- package/tabs/Tabs.js +3 -3
- package/tabs/Tabs.stories.tsx +45 -5
- package/tabs-nav/NavTabs.stories.tsx +8 -6
- package/tabs-nav/Tab.js +5 -7
- package/tag/Tag.stories.tsx +14 -1
- package/text-input/Suggestion.js +32 -5
- package/text-input/TextInput.js +7 -11
- package/text-input/TextInput.stories.tsx +92 -4
- package/text-input/TextInput.test.js +587 -634
- package/textarea/Textarea.stories.jsx +60 -1
- package/toggle-group/ToggleGroup.stories.tsx +42 -0
- package/wizard/Wizard.stories.tsx +20 -0
- package/common/RequiredComponent.js +0 -32
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
@@ -13,26 +11,17 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
13
11
|
|
|
14
12
|
var _react = _interopRequireDefault(require("react"));
|
|
15
13
|
|
|
16
|
-
var _styledComponents =
|
|
17
|
-
|
|
18
|
-
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
19
15
|
|
|
20
16
|
var _templateObject, _templateObject2, _templateObject3;
|
|
21
17
|
|
|
22
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
-
|
|
24
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
-
|
|
26
18
|
var DropdownMenuItem = function DropdownMenuItem(_ref) {
|
|
27
19
|
var id = _ref.id,
|
|
28
20
|
visuallyFocused = _ref.visuallyFocused,
|
|
29
21
|
iconPosition = _ref.iconPosition,
|
|
30
22
|
_onClick = _ref.onClick,
|
|
31
23
|
option = _ref.option;
|
|
32
|
-
|
|
33
|
-
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
34
|
-
theme: colorsTheme.dropdown
|
|
35
|
-
}, /*#__PURE__*/_react["default"].createElement(DropdownMenuItemContainer, {
|
|
24
|
+
return /*#__PURE__*/_react["default"].createElement(DropdownMenuItemContainer, {
|
|
36
25
|
visuallyFocused: visuallyFocused,
|
|
37
26
|
onClick: function onClick() {
|
|
38
27
|
_onClick(option.value);
|
|
@@ -46,7 +35,7 @@ var DropdownMenuItem = function DropdownMenuItem(_ref) {
|
|
|
46
35
|
role: typeof option.icon === "string" ? undefined : "img"
|
|
47
36
|
}, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
48
37
|
src: option.icon
|
|
49
|
-
}) : option.icon), iconPosition === "before" && /*#__PURE__*/_react["default"].createElement(DropdownMenuItemLabel, null, option.label))
|
|
38
|
+
}) : option.icon), iconPosition === "before" && /*#__PURE__*/_react["default"].createElement(DropdownMenuItemLabel, null, option.label));
|
|
50
39
|
};
|
|
51
40
|
|
|
52
41
|
var DropdownMenuItemContainer = _styledComponents["default"].li(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: ", ";\n min-height: 36px;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n cursor: pointer;\n\n ", "\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n }\n"])), function (props) {
|
|
@@ -67,7 +56,7 @@ var DropdownMenuItemContainer = _styledComponents["default"].li(_templateObject
|
|
|
67
56
|
return props.theme.activeOptionBackgroundColor;
|
|
68
57
|
});
|
|
69
58
|
|
|
70
|
-
var DropdownMenuItemLabel = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.5rem;\n color: ", ";\n"])), function (props) {
|
|
59
|
+
var DropdownMenuItemLabel = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.5rem;\n color: ", ";\n white-space: nowrap;\n"])), function (props) {
|
|
71
60
|
return props.theme.optionFontFamily;
|
|
72
61
|
}, function (props) {
|
|
73
62
|
return props.theme.optionFontSize;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import FileInputPropsType from "./types";
|
|
3
|
-
declare const DxcFileInput:
|
|
3
|
+
declare const DxcFileInput: React.ForwardRefExoticComponent<FileInputPropsType & React.RefAttributes<HTMLDivElement>>;
|
|
4
4
|
export default DxcFileInput;
|
package/file-input/FileInput.js
CHANGED
|
@@ -39,7 +39,7 @@ var _Button = _interopRequireDefault(require("../button/Button"));
|
|
|
39
39
|
|
|
40
40
|
var _FileItem = _interopRequireDefault(require("./FileItem"));
|
|
41
41
|
|
|
42
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11
|
|
42
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
43
43
|
|
|
44
44
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
45
|
|
|
@@ -99,7 +99,7 @@ var getFilePreview = function getFilePreview(file) {
|
|
|
99
99
|
});else return fileIcon;
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
var DxcFileInput = function
|
|
102
|
+
var DxcFileInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
103
103
|
var _ref$name = _ref.name,
|
|
104
104
|
name = _ref$name === void 0 ? "" : _ref$name,
|
|
105
105
|
_ref$mode = _ref.mode,
|
|
@@ -370,15 +370,15 @@ var DxcFileInput = function DxcFileInput(_ref) {
|
|
|
370
370
|
theme: colorsTheme.fileInput
|
|
371
371
|
}, /*#__PURE__*/_react["default"].createElement(FileInputContainer, {
|
|
372
372
|
margin: margin,
|
|
373
|
-
name: name
|
|
373
|
+
name: name,
|
|
374
|
+
ref: ref
|
|
374
375
|
}, /*#__PURE__*/_react["default"].createElement(Label, {
|
|
375
376
|
htmlFor: fileInputId,
|
|
376
377
|
disabled: disabled
|
|
377
378
|
}, label), /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
378
379
|
disabled: disabled
|
|
379
380
|
}, helperText), mode === "file" ? /*#__PURE__*/_react["default"].createElement(FileContainer, {
|
|
380
|
-
|
|
381
|
-
files: files
|
|
381
|
+
singleFileMode: !multiple && files.length === 1
|
|
382
382
|
}, /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
383
383
|
id: fileInputId,
|
|
384
384
|
type: "file",
|
|
@@ -396,22 +396,17 @@ var DxcFileInput = function DxcFileInput(_ref) {
|
|
|
396
396
|
disabled: disabled,
|
|
397
397
|
size: "fitContent",
|
|
398
398
|
tabIndex: tabIndex
|
|
399
|
-
}), /*#__PURE__*/_react["default"].createElement(FileItemListContainer, {
|
|
400
|
-
mode: mode,
|
|
401
|
-
multiple: multiple,
|
|
402
|
-
files: files
|
|
403
|
-
}, files.map(function (file) {
|
|
399
|
+
}), files.length > 0 && /*#__PURE__*/_react["default"].createElement(FileItemListContainer, null, files.map(function (file, index) {
|
|
404
400
|
return /*#__PURE__*/_react["default"].createElement(_FileItem["default"], {
|
|
405
|
-
|
|
406
|
-
multiple: multiple,
|
|
407
|
-
name: file.file.name,
|
|
401
|
+
fileName: file.file.name,
|
|
408
402
|
error: file.error,
|
|
403
|
+
singleFileMode: !multiple && files.length === 1,
|
|
409
404
|
showPreview: mode === "file" && !multiple ? false : showPreview,
|
|
410
|
-
numFiles: files.length,
|
|
411
405
|
preview: file.preview,
|
|
412
406
|
type: file.file.type,
|
|
413
407
|
onDelete: onDelete,
|
|
414
|
-
tabIndex: tabIndex
|
|
408
|
+
tabIndex: tabIndex,
|
|
409
|
+
key: "file-".concat(index)
|
|
415
410
|
});
|
|
416
411
|
}))) : /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
417
412
|
id: fileInputId,
|
|
@@ -431,39 +426,30 @@ var DxcFileInput = function DxcFileInput(_ref) {
|
|
|
431
426
|
onDragEnter: handleDragIn,
|
|
432
427
|
onDragOver: handleDrag,
|
|
433
428
|
onDragLeave: handleDragOut
|
|
434
|
-
}, /*#__PURE__*/_react["default"].createElement(ButtonContainer, {
|
|
435
|
-
mode: mode
|
|
436
429
|
}, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
437
430
|
mode: "secondary",
|
|
438
431
|
label: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : translatedLabels.fileInput.dropAreaButtonLabelDefault,
|
|
439
432
|
onClick: handleClick,
|
|
440
433
|
disabled: disabled,
|
|
441
434
|
size: "fitContent"
|
|
442
|
-
})
|
|
435
|
+
}), mode === "dropzone" ? /*#__PURE__*/_react["default"].createElement(DropzoneLabel, {
|
|
443
436
|
disabled: disabled
|
|
444
437
|
}, dropAreaLabel !== null && dropAreaLabel !== void 0 ? dropAreaLabel : multiple ? translatedLabels.fileInput.multipleDropAreaLabelDefault : translatedLabels.fileInput.singleDropAreaLabelDefault) : /*#__PURE__*/_react["default"].createElement(FiledropLabel, {
|
|
445
438
|
disabled: disabled
|
|
446
|
-
}, dropAreaLabel !== null && dropAreaLabel !== void 0 ? dropAreaLabel : multiple ? translatedLabels.fileInput.multipleDropAreaLabelDefault : translatedLabels.fileInput.singleDropAreaLabelDefault)), /*#__PURE__*/_react["default"].createElement(FileItemListContainer, {
|
|
447
|
-
mode: mode,
|
|
448
|
-
multiple: multiple,
|
|
449
|
-
files: files
|
|
450
|
-
}, files.map(function (file) {
|
|
439
|
+
}, dropAreaLabel !== null && dropAreaLabel !== void 0 ? dropAreaLabel : multiple ? translatedLabels.fileInput.multipleDropAreaLabelDefault : translatedLabels.fileInput.singleDropAreaLabelDefault)), files.length > 0 && /*#__PURE__*/_react["default"].createElement(FileItemListContainer, null, files.map(function (file, index) {
|
|
451
440
|
return /*#__PURE__*/_react["default"].createElement(_FileItem["default"], {
|
|
452
|
-
|
|
453
|
-
multiple: multiple,
|
|
454
|
-
name: file.file.name,
|
|
441
|
+
fileName: file.file.name,
|
|
455
442
|
error: file.error,
|
|
443
|
+
singleFileMode: false,
|
|
456
444
|
showPreview: showPreview,
|
|
457
|
-
numFiles: files.length,
|
|
458
445
|
preview: file.preview,
|
|
459
446
|
type: file.file.type,
|
|
460
447
|
onDelete: onDelete,
|
|
461
|
-
tabIndex: tabIndex
|
|
448
|
+
tabIndex: tabIndex,
|
|
449
|
+
key: "file-".concat(index)
|
|
462
450
|
});
|
|
463
|
-
}))), files.length === 1 && files.
|
|
464
|
-
|
|
465
|
-
})));
|
|
466
|
-
};
|
|
451
|
+
}))), mode === "file" && !multiple && files.length === 1 && files[0].error && /*#__PURE__*/_react["default"].createElement(ErrorMessage, null, files[0].error)));
|
|
452
|
+
});
|
|
467
453
|
|
|
468
454
|
var FileInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (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"])), function (props) {
|
|
469
455
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -502,7 +488,7 @@ var HelperText = _styledComponents["default"].span(_templateObject3 || (_templat
|
|
|
502
488
|
});
|
|
503
489
|
|
|
504
490
|
var FileContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n ", "\n margin-top: 0.25rem;\n"])), function (props) {
|
|
505
|
-
return props.
|
|
491
|
+
return props.singleFileMode ? "flex-direction: row; column-gap: 0.25rem;" : "flex-direction: column; row-gap: 0.25rem;";
|
|
506
492
|
});
|
|
507
493
|
|
|
508
494
|
var ValueInput = _styledComponents["default"].input(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: none;\n"])));
|
|
@@ -511,12 +497,10 @@ var FileItemListContainer = _styledComponents["default"].div(_templateObject6 ||
|
|
|
511
497
|
|
|
512
498
|
var Container = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n row-gap: 0.25rem;\n margin-top: 0.25rem;\n"])));
|
|
513
499
|
|
|
514
|
-
var DragDropArea = _styledComponents["default"].div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n
|
|
515
|
-
return props.mode === "filedrop" ? "row" : "column";
|
|
516
|
-
}, function (props) {
|
|
517
|
-
return props.mode === "dropzone" && "justify-content: center; padding: 1rem;";
|
|
500
|
+
var DragDropArea = _styledComponents["default"].div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n ", "\n align-items: center;\n width: 320px;\n padding: ", ";\n overflow: hidden;\n box-shadow: 0 0 0 2px transparent;\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n ", "\n cursor: ", ";\n"])), function (props) {
|
|
501
|
+
return props.mode === "filedrop" ? "flex-direction: row; column-gap: 0.75rem; height: 48px;" : "justify-content: center; flex-direction: column; row-gap: 0.5rem; height: 160px;";
|
|
518
502
|
}, function (props) {
|
|
519
|
-
return props.mode === "filedrop" ? "
|
|
503
|
+
return props.mode === "filedrop" ? "calc(4px - ".concat(props.theme.dropBorderThickness, ") 1rem calc(4px - ").concat(props.theme.dropBorderThickness, ") calc(4px - ").concat(props.theme.dropBorderThickness, ")") : "1rem";
|
|
520
504
|
}, function (props) {
|
|
521
505
|
return props.theme.dropBorderRadius;
|
|
522
506
|
}, function (props) {
|
|
@@ -531,11 +515,7 @@ var DragDropArea = _styledComponents["default"].div(_templateObject8 || (_templa
|
|
|
531
515
|
return props.disabled && "not-allowed";
|
|
532
516
|
});
|
|
533
517
|
|
|
534
|
-
var
|
|
535
|
-
return props.mode === "filedrop" && "padding: 2px 12px 2px 3px";
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
var DropzoneLabel = _styledComponents["default"].div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n display: -webkit-box;\n -webkit-box-orient: vertical;\n overflow: hidden;\n text-overflow: ellipsis;\n -webkit-line-clamp: 3;\n text-align: center;\n margin-top: 0.5rem;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
518
|
+
var DropzoneLabel = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n display: -webkit-box;\n -webkit-box-orient: vertical;\n overflow: hidden;\n text-overflow: ellipsis;\n -webkit-line-clamp: 3;\n text-align: center;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
539
519
|
return props.disabled ? props.theme.disabledDropLabelFontColor : props.theme.dropLabelFontColor;
|
|
540
520
|
}, function (props) {
|
|
541
521
|
return props.theme.dropLabelFontFamily;
|
|
@@ -545,7 +525,7 @@ var DropzoneLabel = _styledComponents["default"].div(_templateObject10 || (_temp
|
|
|
545
525
|
return props.theme.dropLabelFontWeight;
|
|
546
526
|
});
|
|
547
527
|
|
|
548
|
-
var FiledropLabel = _styledComponents["default"].span(
|
|
528
|
+
var FiledropLabel = _styledComponents["default"].span(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
549
529
|
return props.disabled ? props.theme.disabledDropLabelFontColor : props.theme.dropLabelFontColor;
|
|
550
530
|
}, function (props) {
|
|
551
531
|
return props.theme.dropLabelFontFamily;
|
|
@@ -555,7 +535,7 @@ var FiledropLabel = _styledComponents["default"].span(_templateObject11 || (_tem
|
|
|
555
535
|
return props.theme.dropLabelFontWeight;
|
|
556
536
|
});
|
|
557
537
|
|
|
558
|
-
var ErrorMessage = _styledComponents["default"].div(
|
|
538
|
+
var ErrorMessage = _styledComponents["default"].div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n line-height: ", ";\n margin-top: 0.25rem;\n"])), function (props) {
|
|
559
539
|
return props.theme.errorMessageFontColor;
|
|
560
540
|
}, function (props) {
|
|
561
541
|
return props.theme.errorMessageFontFamily;
|
|
@@ -3,14 +3,14 @@ import DxcFileInput from "./FileInput";
|
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
5
|
import FileItem from "./FileItem";
|
|
6
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
title: "File input",
|
|
9
10
|
component: DxcFileInput,
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
const picPreview =
|
|
13
|
-
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABmJLR0QA/wD/AP+gvaeTAAAEDklEQVRogdXaXaxcUxQH8J/etloajVT1I9qgCbdIUB8PXPeKBJHgsV5ExAuVivBUgtSDxgNBVMVHxEeRUhIhkpJ40BYhoTShaQglQtA2VR+ttjMe1j45c6cztzNnzszc+09Ocs/Za+39/++zzt5rr7l0D1diA35P14b0bMJgAE+g2uR6FpP7xq4NZCL2YjlOSNdt6VkVj/eNXYu4VhD9G+c3aL8gtVWS7bjEsfhRCFk2ht2yZPNT8hl3WCUIfoZJY9gdhY+T7QM94NUWFmEfDuHCFuyXJNv9OL2LvNrGO2KGn2rD55nks6ErjAog+8B3YXYbfrPwR/Lt+4d/NLYLMrcW8F+efL/DtBJ5tY17EpEvxEbYLgawJfVxXxObRZhbiF2LWCjfE4Y66OeS1Mc/OLnm+Uw8ggP4oYP+j4hHxUy+VEJfL6e+3hTL8/X4RZ7W/FvCGE1xOdZp7wNvhvny9CULtSo+1QMhZWImPpQL+A03YbouCpkqXn8ZqA+jg1iD41P7NF0QMiAy2N0ipDrFWUa/hU9wXp1N6UIuEktsNug3HfY3gD2pr4rYTxrlZ6UJmY3n0mBZ7JYhhDi3ZP1+i6sb2HQsZBJuEEfUqljjV+Ic5QkhzifZylTF+xisae9IyBIRr1nnb+PU1DaoXCHkk5blXfvxGGYoKGQWnhbpdZb/XFNn0w0hGebgBXm4fY/rtClkOn6Wz8j96Vk9uikkw5DRm2JLQrKV4hB2pr+niJznuPI5toRN4rx/u1jZiLfUMqZiBf4Ss7Bb7Bu1WW0v3kgt5mA17i7iPB8vymN1Cy5Obb0W0jFm4Fd5jFbEfjJsggl5UBDeiLvk4bZP/4RcJj76W1p1OE2sXAfFBkgcotYrL0UpghF5BfOkVhzeTQ5rGrRdIXbiVWWxaxNvCG6vHckwq4jsFPXa8YYF8gPYVc2MaisiN/eGVyGsEBy3C86H4d5k8LliFZFeYSq+FlwP218WiJWpIpbY8Y5heeXllNqGdcqriPQKrwrO67MHZwh1ezGvT6SKIKu8VLCYWGareKgPZEZECrS5oP/Dgvtq2Jpuzi6FWmuYh7XyfK5asJ9zk++X5EWARuePsjEZd9SM+afOhBwjz9TtSDeDY3mUgBH526/gFRHnnQhZLD9NejLdvG7sn8yKoj6MtuLSmvaiQibJ8781RNl+V3rwEZaKpGxKQeIZ6sNoD+5s0G87QqYkbksT1yydWpQZDMl/kS16bawb9AN5GK3VfGnvZMwd0qEv+w+ETTgTN4rEcRAninSgVdTP6oE2fFvFf6JIuA1v4XmRkXQVk+UFhGoacKXDJ6eTj72nmGt0DWCbONdkmDBCMgzjK6MrmAtNQCGUvyH2HfXhNmGFZBgRNYD3Ou3ofwlpcfptqgzTAAAAAElFTkSuQmCC";
|
|
13
|
+
const picPreview = "https://cdn.mos.cms.futurecdn.net/CAZ6JXi6huSuN4QGE627NR.jpg";
|
|
14
14
|
|
|
15
15
|
const file1 = new File(["file1"], "file.pdf", { type: "text/plain" });
|
|
16
16
|
const file2 = new File(["file2"], "file2.mp3", {
|
|
@@ -22,7 +22,7 @@ const file3 = new File(["file3"], "file3.png", {
|
|
|
22
22
|
const file4 = new File(["file4"], "file4file4file4file4file4file4file4file4file4.mp4", {
|
|
23
23
|
type: "video",
|
|
24
24
|
});
|
|
25
|
-
const file5 = new File(["
|
|
25
|
+
const file5 = new File(["file5"], "file5file5file5file5file5file5file5file5file5.mp4", {
|
|
26
26
|
type: "video",
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -54,7 +54,7 @@ const filesExamples = [
|
|
|
54
54
|
file: file4,
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
|
-
error: "
|
|
57
|
+
error: "This error message is a multiline paragraph for testing.",
|
|
58
58
|
file: file5,
|
|
59
59
|
},
|
|
60
60
|
{
|
|
@@ -64,17 +64,22 @@ const filesExamples = [
|
|
|
64
64
|
},
|
|
65
65
|
];
|
|
66
66
|
|
|
67
|
+
const opinionatedTheme = {
|
|
68
|
+
fileInput: {
|
|
69
|
+
fontColor: "#000000",
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
67
73
|
export const Chromatic = () => (
|
|
68
74
|
<>
|
|
69
75
|
<Title title="File item states" theme="light" level={2} />
|
|
70
76
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
71
77
|
<Title title="Hovered" theme="light" level={4} />
|
|
72
78
|
<FileItem
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
fileName="file"
|
|
80
|
+
error=""
|
|
81
|
+
singleFileMode={false}
|
|
76
82
|
showPreview={false}
|
|
77
|
-
numFiles={1}
|
|
78
83
|
preview={picPreview}
|
|
79
84
|
type="image/png"
|
|
80
85
|
onDelete={() => {}}
|
|
@@ -84,11 +89,10 @@ export const Chromatic = () => (
|
|
|
84
89
|
<ExampleContainer pseudoState="pseudo-focus">
|
|
85
90
|
<Title title="Focused" theme="light" level={4} />
|
|
86
91
|
<FileItem
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
fileName="file"
|
|
93
|
+
error=""
|
|
94
|
+
singleFileMode={false}
|
|
90
95
|
showPreview={false}
|
|
91
|
-
numFiles={1}
|
|
92
96
|
preview={picPreview}
|
|
93
97
|
type="image/png"
|
|
94
98
|
onDelete={() => {}}
|
|
@@ -98,11 +102,10 @@ export const Chromatic = () => (
|
|
|
98
102
|
<ExampleContainer pseudoState="pseudo-active">
|
|
99
103
|
<Title title="Actived" theme="light" level={4} />
|
|
100
104
|
<FileItem
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
fileName="file"
|
|
106
|
+
error=""
|
|
107
|
+
singleFileMode={false}
|
|
104
108
|
showPreview={false}
|
|
105
|
-
numFiles={1}
|
|
106
109
|
preview={picPreview}
|
|
107
110
|
type="image/png"
|
|
108
111
|
onDelete={() => {}}
|
|
@@ -533,7 +536,83 @@ export const Chromatic = () => (
|
|
|
533
536
|
mode="dropzone"
|
|
534
537
|
margin="xxlarge"
|
|
535
538
|
/>
|
|
536
|
-
|
|
539
|
+
</ExampleContainer>
|
|
540
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
541
|
+
<ExampleContainer>
|
|
542
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
543
|
+
<Title title="Single file" theme="light" level={4} />
|
|
544
|
+
<DxcFileInput
|
|
545
|
+
label="File input"
|
|
546
|
+
helperText="Please select files"
|
|
547
|
+
value={fileExample}
|
|
548
|
+
multiple={false}
|
|
549
|
+
callbackFile={() => {}}
|
|
550
|
+
/>
|
|
551
|
+
</HalstackProvider>
|
|
552
|
+
</ExampleContainer>
|
|
553
|
+
<ExampleContainer>
|
|
554
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
555
|
+
<Title title="Invalid single file" theme="light" level={4} />
|
|
556
|
+
<DxcFileInput
|
|
557
|
+
label="File input"
|
|
558
|
+
helperText="Please select files"
|
|
559
|
+
value={fileExampleError}
|
|
560
|
+
multiple={false}
|
|
561
|
+
callbackFile={() => {}}
|
|
562
|
+
/>
|
|
563
|
+
</HalstackProvider>
|
|
564
|
+
</ExampleContainer>
|
|
565
|
+
<ExampleContainer>
|
|
566
|
+
<Title title="Single file" theme="light" level={4} />
|
|
567
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
568
|
+
<DxcFileInput
|
|
569
|
+
mode="filedrop"
|
|
570
|
+
label="File input"
|
|
571
|
+
helperText="Please select files"
|
|
572
|
+
value={fileExample}
|
|
573
|
+
multiple={false}
|
|
574
|
+
callbackFile={() => {}}
|
|
575
|
+
/>
|
|
576
|
+
</HalstackProvider>
|
|
577
|
+
</ExampleContainer>
|
|
578
|
+
<ExampleContainer>
|
|
579
|
+
<Title title="Invalid single file" theme="light" level={4} />
|
|
580
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
581
|
+
<DxcFileInput
|
|
582
|
+
mode="filedrop"
|
|
583
|
+
label="File input"
|
|
584
|
+
helperText="Please select files"
|
|
585
|
+
value={fileExampleError}
|
|
586
|
+
multiple={false}
|
|
587
|
+
callbackFile={() => {}}
|
|
588
|
+
/>
|
|
589
|
+
</HalstackProvider>
|
|
590
|
+
</ExampleContainer>
|
|
591
|
+
<ExampleContainer>
|
|
592
|
+
<Title title="Single file" theme="light" level={4} />
|
|
593
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
594
|
+
<DxcFileInput
|
|
595
|
+
label="File input"
|
|
596
|
+
helperText="Please select files"
|
|
597
|
+
mode="dropzone"
|
|
598
|
+
value={fileExample}
|
|
599
|
+
callbackFile={() => {}}
|
|
600
|
+
multiple={false}
|
|
601
|
+
/>
|
|
602
|
+
</HalstackProvider>
|
|
603
|
+
</ExampleContainer>
|
|
604
|
+
<ExampleContainer>
|
|
605
|
+
<Title title="Invalid single file" theme="light" level={4} />{" "}
|
|
606
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
607
|
+
<DxcFileInput
|
|
608
|
+
label="File input"
|
|
609
|
+
helperText="Please select files"
|
|
610
|
+
mode="dropzone"
|
|
611
|
+
value={fileExampleError}
|
|
612
|
+
callbackFile={() => {}}
|
|
613
|
+
multiple={false}
|
|
614
|
+
/>
|
|
615
|
+
</HalstackProvider>
|
|
537
616
|
</ExampleContainer>
|
|
538
617
|
</>
|
|
539
618
|
);
|
|
@@ -14,19 +14,19 @@ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
|
14
14
|
|
|
15
15
|
var _FileInput = _interopRequireDefault(require("./FileInput"));
|
|
16
16
|
|
|
17
|
+
var file1 = new File(["file1"], "file1.png", {
|
|
18
|
+
type: "image/png"
|
|
19
|
+
});
|
|
20
|
+
var file2 = new File(["file2"], "file2.txt", {
|
|
21
|
+
type: "text/plain"
|
|
22
|
+
});
|
|
23
|
+
var allFiles = [{
|
|
24
|
+
file: file1
|
|
25
|
+
}, {
|
|
26
|
+
error: "Error message",
|
|
27
|
+
file: file2
|
|
28
|
+
}];
|
|
17
29
|
describe("FileInput component tests", function () {
|
|
18
|
-
var file1 = new File(["file1"], "file1.png", {
|
|
19
|
-
type: "image/png"
|
|
20
|
-
});
|
|
21
|
-
var file2 = new File(["file2"], "file2.txt", {
|
|
22
|
-
type: "text/plain"
|
|
23
|
-
});
|
|
24
|
-
var allFiles = [{
|
|
25
|
-
file: file1
|
|
26
|
-
}, {
|
|
27
|
-
error: "Error message",
|
|
28
|
-
file: file2
|
|
29
|
-
}];
|
|
30
30
|
test("Renders with correct labels and helper text in file mode", function () {
|
|
31
31
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_FileInput["default"], {
|
|
32
32
|
label: "File input label",
|
package/file-input/FileItem.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
multiple: any;
|
|
5
|
-
name?: string;
|
|
6
|
-
error?: string;
|
|
7
|
-
showPreview: any;
|
|
8
|
-
preview: any;
|
|
9
|
-
type: any;
|
|
10
|
-
numFiles: any;
|
|
11
|
-
onDelete: any;
|
|
12
|
-
tabIndex: any;
|
|
13
|
-
}) => JSX.Element>;
|
|
2
|
+
import { FileItemProps } from "./types";
|
|
3
|
+
declare const _default: React.MemoExoticComponent<({ fileName, error, singleFileMode, showPreview, preview, type, onDelete, tabIndex, }: FileItemProps) => JSX.Element>;
|
|
14
4
|
export default _default;
|
package/file-input/FileItem.js
CHANGED
|
@@ -15,11 +15,13 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
15
15
|
|
|
16
16
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
17
17
|
|
|
18
|
+
var _main = require("../main");
|
|
19
|
+
|
|
18
20
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
19
21
|
|
|
20
22
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
21
23
|
|
|
22
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8
|
|
24
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
23
25
|
|
|
24
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
27
|
|
|
@@ -49,16 +51,14 @@ var errorIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
|
49
51
|
}));
|
|
50
52
|
|
|
51
53
|
var FileItem = function FileItem(_ref) {
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
_ref$name = _ref.name,
|
|
55
|
-
name = _ref$name === void 0 ? "" : _ref$name,
|
|
54
|
+
var _ref$fileName = _ref.fileName,
|
|
55
|
+
fileName = _ref$fileName === void 0 ? "" : _ref$fileName,
|
|
56
56
|
_ref$error = _ref.error,
|
|
57
57
|
error = _ref$error === void 0 ? "" : _ref$error,
|
|
58
|
+
singleFileMode = _ref.singleFileMode,
|
|
58
59
|
showPreview = _ref.showPreview,
|
|
59
60
|
preview = _ref.preview,
|
|
60
61
|
type = _ref.type,
|
|
61
|
-
numFiles = _ref.numFiles,
|
|
62
62
|
onDelete = _ref.onDelete,
|
|
63
63
|
tabIndex = _ref.tabIndex;
|
|
64
64
|
var colorsTheme = (0, _useTheme["default"])();
|
|
@@ -70,43 +70,34 @@ var FileItem = function FileItem(_ref) {
|
|
|
70
70
|
|
|
71
71
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
72
72
|
theme: colorsTheme.fileInput
|
|
73
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
74
|
-
mode: mode,
|
|
75
|
-
multiple: multiple,
|
|
73
|
+
}, /*#__PURE__*/_react["default"].createElement(MainContainer, {
|
|
76
74
|
error: error,
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
singleFileMode: singleFileMode,
|
|
76
|
+
showPreview: showPreview
|
|
79
77
|
}, showPreview && (type.includes("image") ? /*#__PURE__*/_react["default"].createElement(ImagePreview, {
|
|
80
78
|
src: preview,
|
|
81
|
-
alt:
|
|
82
|
-
}) : /*#__PURE__*/_react["default"].createElement(
|
|
79
|
+
alt: fileName
|
|
80
|
+
}) : /*#__PURE__*/_react["default"].createElement(IconPreview, {
|
|
83
81
|
error: error,
|
|
84
82
|
"aria-label": getIconAriaLabel()
|
|
85
|
-
}, preview)), /*#__PURE__*/_react["default"].createElement(FileItemContent, null, /*#__PURE__*/_react["default"].createElement(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
error: error,
|
|
89
|
-
showPreview: showPreview,
|
|
90
|
-
numFiles: numFiles
|
|
91
|
-
}, name), error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, null, errorIcon), /*#__PURE__*/_react["default"].createElement(DeleteFileAction, {
|
|
92
|
-
error: error,
|
|
83
|
+
}, preview)), /*#__PURE__*/_react["default"].createElement(FileItemContent, null, /*#__PURE__*/_react["default"].createElement(FileName, null, fileName), /*#__PURE__*/_react["default"].createElement(_main.DxcFlex, {
|
|
84
|
+
gap: "0.25rem"
|
|
85
|
+
}, error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, null, errorIcon), /*#__PURE__*/_react["default"].createElement(DeleteFileAction, {
|
|
93
86
|
onClick: function onClick() {
|
|
94
|
-
onDelete(
|
|
87
|
+
onDelete(fileName);
|
|
95
88
|
},
|
|
96
89
|
title: translatedLabels.fileInput.deleteFileActionTitle,
|
|
97
90
|
"aria-label": translatedLabels.fileInput.deleteFileActionTitle,
|
|
98
91
|
tabIndex: tabIndex
|
|
99
|
-
}, deleteIcon)), error &&
|
|
92
|
+
}, deleteIcon)), error && !singleFileMode && /*#__PURE__*/_react["default"].createElement(ErrorMessage, null, error))));
|
|
100
93
|
};
|
|
101
94
|
|
|
102
|
-
var
|
|
103
|
-
return props.
|
|
104
|
-
}, function (props) {
|
|
105
|
-
return props.mode === "file" && !props.multiple && props.numFiles === 1 ? "calc(230px - 26px)" : !props.showPreview ? "calc(320px - 26px)" : props.showPreview && "calc(320px - 18px)";
|
|
95
|
+
var MainContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n justify-content: center;\n gap: 0.75rem;\n width: ", ";\n padding: ", ";\n ", ";\n border-color: ", ";\n border-width: ", ";\n border-style: ", ";\n border-radius: ", ";\n"])), function (props) {
|
|
96
|
+
return props.singleFileMode ? "230px" : "320px";
|
|
106
97
|
}, function (props) {
|
|
107
|
-
return props.
|
|
98
|
+
return props.showPreview ? "calc(8px - ".concat(props.theme.fileItemBorderThickness, ")") : "calc(8px - ".concat(props.theme.fileItemBorderThickness, ") calc(8px - ").concat(props.theme.fileItemBorderThickness, ") calc(8px - ").concat(props.theme.fileItemBorderThickness, ") 16px");
|
|
108
99
|
}, function (props) {
|
|
109
|
-
return props.error
|
|
100
|
+
return props.error ? "background-color: ".concat(props.theme.errorFileItemBackgroundColor, ";") : "";
|
|
110
101
|
}, function (props) {
|
|
111
102
|
return props.error ? props.theme.errorFileItemBorderColor : props.theme.fileItemBorderColor;
|
|
112
103
|
}, function (props) {
|
|
@@ -117,22 +108,18 @@ var Container = _styledComponents["default"].div(_templateObject || (_templateOb
|
|
|
117
108
|
return props.theme.fileItemBorderRadius;
|
|
118
109
|
});
|
|
119
110
|
|
|
120
|
-
var
|
|
111
|
+
var ImagePreview = _styledComponents["default"].img(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n width: 48px;\n height: 48px;\n border-radius: 2px;\n object-fit: contain;\n"])));
|
|
121
112
|
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
var ImagePreview = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n width: 48px;\n height: 48px;\n object-fit: contain;\n border-radius: 2px;\n"])));
|
|
125
|
-
|
|
126
|
-
var IconPreviewContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: ", ";\n width: 48px;\n height: 48px;\n border-radius: 2px;\n color: ", ";\n"])), function (props) {
|
|
113
|
+
var IconPreview = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: ", ";\n width: 48px;\n height: 48px;\n padding: 15px;\n border-radius: 2px;\n color: ", ";\n\n svg {\n height: 18px;\n width: 18px;\n }\n"])), function (props) {
|
|
127
114
|
return props.error ? props.theme.errorFilePreviewBackgroundColor : props.theme.filePreviewBackgroundColor;
|
|
128
115
|
}, function (props) {
|
|
129
116
|
return props.error ? props.theme.errorFilePreviewIconColor : props.theme.filePreviewIconColor;
|
|
130
117
|
});
|
|
131
118
|
|
|
132
|
-
var
|
|
119
|
+
var FileItemContent = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n flex-grow: 1;\n display: grid;\n grid-template-columns: auto min-content;\n grid-template-rows: min-content auto;\n column-gap: 0.25rem;\n"])));
|
|
120
|
+
|
|
121
|
+
var FileName = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n align-self: center;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n line-height: ", ";\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n"])), function (props) {
|
|
133
122
|
return props.theme.fileNameFontColor;
|
|
134
|
-
}, function (props) {
|
|
135
|
-
return props.mode === "file" && !props.multiple && props.error && props.numFiles === 1 ? "calc(230px - 76px)" : props.mode === "file" && !props.multiple && !props.error && props.numFiles === 1 ? "calc(230px - 50px)" : !props.showPreview && !props.error ? "calc(320px - 52px)" : !props.showPreview && props.error ? "calc(320px - 76px)" : props.showPreview && props.error ? "calc(320px - 128px)" : props.showPreview && !props.error && "calc(320px - 102px)";
|
|
136
123
|
}, function (props) {
|
|
137
124
|
return props.theme.fileItemFontFamily;
|
|
138
125
|
}, function (props) {
|
|
@@ -143,9 +130,9 @@ var FileName = _styledComponents["default"].span(_templateObject6 || (_templateO
|
|
|
143
130
|
return props.theme.fileItemLineHeight;
|
|
144
131
|
});
|
|
145
132
|
|
|
146
|
-
var ErrorIcon = _styledComponents["default"].span(
|
|
133
|
+
var ErrorIcon = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n padding: 3px;\n height: 18px;\n width: 18px;\n color: #d0011b;\n"])));
|
|
147
134
|
|
|
148
|
-
var DeleteFileAction = _styledComponents["default"].button(
|
|
135
|
+
var DeleteFileAction = _styledComponents["default"].button(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n font-size: 1rem;\n font-family: ", ";\n border: 1px solid transparent;\n border-radius: 2px;\n background-color: transparent;\n box-shadow: 0 0 0 2px transparent;\n padding: 3px;\n cursor: pointer;\n color: ", ";\n\n svg {\n line-height: 18px;\n }\n &:hover {\n background-color: ", ";\n }\n &:focus,\n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ", ";\n }\n &:active {\n background-color: ", ";\n }\n"])), function (props) {
|
|
149
136
|
return props.theme.fontFamily;
|
|
150
137
|
}, function (props) {
|
|
151
138
|
return props.theme.deleteFileItemColor;
|
|
@@ -157,7 +144,7 @@ var DeleteFileAction = _styledComponents["default"].button(_templateObject8 || (
|
|
|
157
144
|
return props.theme.activeDeleteFileItemBackgroundColor;
|
|
158
145
|
});
|
|
159
146
|
|
|
160
|
-
var ErrorMessage = _styledComponents["default"].span(
|
|
147
|
+
var ErrorMessage = _styledComponents["default"].span(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
|
|
161
148
|
return props.theme.errorMessageFontColor;
|
|
162
149
|
}, function (props) {
|
|
163
150
|
return props.theme.errorMessageFontFamily;
|
package/file-input/types.d.ts
CHANGED
|
@@ -108,5 +108,22 @@ declare type FileModeProps = CommonProps & {
|
|
|
108
108
|
*/
|
|
109
109
|
dropAreaLabel?: never;
|
|
110
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Reference to the component.
|
|
113
|
+
*/
|
|
114
|
+
export declare type RefType = HTMLDivElement;
|
|
111
115
|
declare type Props = DropModeProps | FileModeProps;
|
|
116
|
+
/**
|
|
117
|
+
* Single file item preview.
|
|
118
|
+
*/
|
|
119
|
+
export declare type FileItemProps = {
|
|
120
|
+
fileName?: string;
|
|
121
|
+
error?: string;
|
|
122
|
+
showPreview: boolean;
|
|
123
|
+
singleFileMode: boolean;
|
|
124
|
+
preview: string;
|
|
125
|
+
type: string;
|
|
126
|
+
onDelete: (fileName: string) => void;
|
|
127
|
+
tabIndex: number;
|
|
128
|
+
};
|
|
112
129
|
export default Props;
|