carbon-react 124.2.2 → 124.3.0
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/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +1 -1
- package/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.js +6 -4
- package/esm/components/file-input/__internal__/file-upload-status/file-upload-status.component.d.ts +35 -0
- package/esm/components/file-input/__internal__/file-upload-status/file-upload-status.component.js +73 -0
- package/esm/components/file-input/__internal__/file-upload-status/file-upload-status.style.d.ts +12 -0
- package/esm/components/file-input/__internal__/file-upload-status/file-upload-status.style.js +97 -0
- package/esm/components/file-input/__internal__/file-upload-status/index.d.ts +2 -0
- package/esm/components/file-input/__internal__/file-upload-status/index.js +1 -0
- package/esm/components/file-input/file-input.component.d.ts +36 -0
- package/esm/components/file-input/file-input.component.js +353 -0
- package/esm/components/file-input/file-input.style.d.ts +14 -0
- package/esm/components/file-input/file-input.style.js +58 -0
- package/esm/components/file-input/index.d.ts +3 -0
- package/esm/components/file-input/index.js +1 -0
- package/esm/locales/en-gb.js +10 -0
- package/esm/locales/locale.d.ts +10 -0
- package/esm/locales/pl-pl.js +10 -0
- package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +1 -1
- package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.js +6 -4
- package/lib/components/file-input/__internal__/file-upload-status/file-upload-status.component.d.ts +35 -0
- package/lib/components/file-input/__internal__/file-upload-status/file-upload-status.component.js +81 -0
- package/lib/components/file-input/__internal__/file-upload-status/file-upload-status.style.d.ts +12 -0
- package/lib/components/file-input/__internal__/file-upload-status/file-upload-status.style.js +106 -0
- package/lib/components/file-input/__internal__/file-upload-status/index.d.ts +2 -0
- package/lib/components/file-input/__internal__/file-upload-status/index.js +13 -0
- package/lib/components/file-input/__internal__/file-upload-status/package.json +6 -0
- package/lib/components/file-input/file-input.component.d.ts +36 -0
- package/lib/components/file-input/file-input.component.js +361 -0
- package/lib/components/file-input/file-input.style.d.ts +14 -0
- package/lib/components/file-input/file-input.style.js +67 -0
- package/lib/components/file-input/index.d.ts +3 -0
- package/lib/components/file-input/index.js +13 -0
- package/lib/components/file-input/package.json +6 -0
- package/lib/locales/en-gb.js +10 -0
- package/lib/locales/locale.d.ts +10 -0
- package/lib/locales/pl-pl.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { InputProps } from "../../__internal__/input";
|
|
2
|
+
import type { ValidationProps } from "../../__internal__/validations";
|
|
3
|
+
export declare const StyledHiddenFileInput: import("styled-components").StyledComponent<"input", any, InputProps, never>;
|
|
4
|
+
interface StyledFileInputPresentationProps extends Pick<ValidationProps, "error"> {
|
|
5
|
+
isDraggedOver?: boolean;
|
|
6
|
+
isDraggingFile?: boolean;
|
|
7
|
+
hasUploadStatus?: boolean;
|
|
8
|
+
maxHeight?: string;
|
|
9
|
+
maxWidth?: string;
|
|
10
|
+
minHeight?: string;
|
|
11
|
+
minWidth?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const StyledFileInputPresentation: import("styled-components").StyledComponent<"div", any, StyledFileInputPresentationProps, never>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import StyledTypography from "../typography/typography.style";
|
|
3
|
+
export const StyledHiddenFileInput = styled.input`
|
|
4
|
+
display: none;
|
|
5
|
+
`;
|
|
6
|
+
export const StyledFileInputPresentation = styled.div`
|
|
7
|
+
${({
|
|
8
|
+
hasUploadStatus,
|
|
9
|
+
minWidth,
|
|
10
|
+
minHeight,
|
|
11
|
+
maxWidth,
|
|
12
|
+
maxHeight
|
|
13
|
+
}) => css`
|
|
14
|
+
min-width: ${minWidth};
|
|
15
|
+
min-height: ${minHeight};
|
|
16
|
+
max-width: ${maxWidth};
|
|
17
|
+
${!hasUploadStatus && css`
|
|
18
|
+
padding: var(--spacing150);
|
|
19
|
+
max-height: ${maxHeight};
|
|
20
|
+
`}
|
|
21
|
+
`}
|
|
22
|
+
|
|
23
|
+
${({
|
|
24
|
+
hasUploadStatus,
|
|
25
|
+
isDraggedOver,
|
|
26
|
+
isDraggingFile,
|
|
27
|
+
error
|
|
28
|
+
}) => {
|
|
29
|
+
const borderWidthToken = error || isDraggingFile ? "borderWidth200" : "borderWidth100";
|
|
30
|
+
let borderColorToken = "colorsUtilityMajor300";
|
|
31
|
+
let backgroundColorToken = "colorsUtilityYang100";
|
|
32
|
+
if (isDraggedOver) {
|
|
33
|
+
borderColorToken = "colorsUtilityMajor400";
|
|
34
|
+
backgroundColorToken = "colorsUtilityMajor100";
|
|
35
|
+
} else if (isDraggingFile) {
|
|
36
|
+
borderColorToken = "colorsUtilityMajor400";
|
|
37
|
+
}
|
|
38
|
+
if (error) {
|
|
39
|
+
borderColorToken = `colorsSemanticNegative${isDraggingFile ? 600 : 500}`;
|
|
40
|
+
}
|
|
41
|
+
return !hasUploadStatus && css`
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
flex-wrap: wrap;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
align-content: center;
|
|
47
|
+
align-items: center;
|
|
48
|
+
text-align: center;
|
|
49
|
+
gap: var(--spacing150);
|
|
50
|
+
border-radius: var(--borderRadius050);
|
|
51
|
+
border: var(--${borderWidthToken}) dashed var(--${borderColorToken});
|
|
52
|
+
background: var(--${backgroundColorToken});
|
|
53
|
+
${StyledTypography} {
|
|
54
|
+
color: var(--colorsUtilityYin055);
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
}}
|
|
58
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./file-input.component";
|
package/esm/locales/en-gb.js
CHANGED
|
@@ -67,6 +67,16 @@ const enGB = {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
|
+
fileInput: {
|
|
71
|
+
dragAndDrop: () => "or drag and drop your file",
|
|
72
|
+
selectFile: () => "Select file",
|
|
73
|
+
fileUploadStatus: () => "File upload status",
|
|
74
|
+
actions: {
|
|
75
|
+
cancel: () => "Cancel upload",
|
|
76
|
+
clear: () => "Clear",
|
|
77
|
+
delete: () => "Delete file"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
70
80
|
heading: {
|
|
71
81
|
backLinkAriaLabel: () => "Back"
|
|
72
82
|
},
|
package/esm/locales/locale.d.ts
CHANGED
|
@@ -50,6 +50,16 @@ interface Locale {
|
|
|
50
50
|
formSummary: (errors: number, warnings: number, type: string) => [string, string] | null;
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
+
fileInput: {
|
|
54
|
+
dragAndDrop: () => string;
|
|
55
|
+
selectFile: () => string;
|
|
56
|
+
fileUploadStatus: () => string;
|
|
57
|
+
actions: {
|
|
58
|
+
cancel: () => string;
|
|
59
|
+
clear: () => string;
|
|
60
|
+
delete: () => string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
53
63
|
heading: {
|
|
54
64
|
backLinkAriaLabel: () => string;
|
|
55
65
|
};
|
package/esm/locales/pl-pl.js
CHANGED
|
@@ -102,6 +102,16 @@ const plPL = {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
|
+
fileInput: {
|
|
106
|
+
dragAndDrop: () => "lub przeciągnij i upuść plik",
|
|
107
|
+
selectFile: () => "Wybierz pliki",
|
|
108
|
+
fileUploadStatus: () => "Status przesyłania plików",
|
|
109
|
+
actions: {
|
|
110
|
+
cancel: () => "Anuluj przesyłanie",
|
|
111
|
+
clear: () => "Wyczyść",
|
|
112
|
+
delete: () => "Usuń plik"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
105
115
|
heading: {
|
|
106
116
|
backLinkAriaLabel: () => "Wstecz"
|
|
107
117
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactWrapper, ShallowWrapper } from "enzyme";
|
|
2
2
|
declare const elementsTagTest: (wrapper: ReactWrapper | ShallowWrapper, elements: string[]) => void;
|
|
3
3
|
declare const rootTagTest: (rootNode: ReactWrapper | ShallowWrapper, comp: string, elem?: string, role?: string) => void;
|
|
4
|
-
declare const rootTagTestRtl: (
|
|
4
|
+
declare const rootTagTestRtl: (rootNode: HTMLElement, comp: string, elem?: string, role?: string) => void;
|
|
5
5
|
export { elementsTagTest, rootTagTest, rootTagTestRtl };
|
|
@@ -20,9 +20,11 @@ const rootTagTest = (rootNode, comp, elem, role) => {
|
|
|
20
20
|
expect(rootNode.prop("data-role")).toEqual(role);
|
|
21
21
|
};
|
|
22
22
|
exports.rootTagTest = rootTagTest;
|
|
23
|
-
const rootTagTestRtl = (
|
|
24
|
-
expect(
|
|
25
|
-
expect(
|
|
26
|
-
expect(
|
|
23
|
+
const rootTagTestRtl = (rootNode, comp, elem, role) => {
|
|
24
|
+
expect(rootNode).toHaveAttribute("data-component", comp);
|
|
25
|
+
expect(rootNode).toHaveAttribute("data-element", elem);
|
|
26
|
+
expect(rootNode).toHaveAttribute("data-role", role);
|
|
27
27
|
};
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line jest/no-export
|
|
28
30
|
exports.rootTagTestRtl = rootTagTestRtl;
|
package/lib/components/file-input/__internal__/file-upload-status/file-upload-status.component.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { LinkProps } from "../../../link";
|
|
3
|
+
import { IconType } from "../../../icon";
|
|
4
|
+
interface StatusUploadingProps {
|
|
5
|
+
/** the status of the upload */
|
|
6
|
+
status: "uploading";
|
|
7
|
+
/** a number from 0-100 giving the current upload progress as a percentage. Only used for the `uploading` status.
|
|
8
|
+
* If the progress prop is not specified in the `uploading` status, a loading animation will be shown instead
|
|
9
|
+
* (or text equivalent for users with a reduced-motion operating system preference).
|
|
10
|
+
*/
|
|
11
|
+
progress?: number;
|
|
12
|
+
}
|
|
13
|
+
interface StatusDoneProps extends LinkProps {
|
|
14
|
+
/** the status of the upload */
|
|
15
|
+
status: "completed" | "previously";
|
|
16
|
+
/** the URL opened by the file link. Must be provided for only the `completed` and `previously` statuses. */
|
|
17
|
+
href: string;
|
|
18
|
+
}
|
|
19
|
+
interface StatusErrorProps {
|
|
20
|
+
/** the status of the upload */
|
|
21
|
+
status: "error";
|
|
22
|
+
}
|
|
23
|
+
interface MandatoryStatusProps {
|
|
24
|
+
/** the name of the file */
|
|
25
|
+
filename: string;
|
|
26
|
+
/** a function to be executed when the user clicks the appropriate action button (Clear/Delete File/Cancel Upload) */
|
|
27
|
+
onAction: () => void;
|
|
28
|
+
/** The status message. Used to display the current upload progress, including error messages where appropriate. Not used for the `previously` status. */
|
|
29
|
+
message?: string;
|
|
30
|
+
/** The icon to use for the file during or after upload */
|
|
31
|
+
iconType?: IconType;
|
|
32
|
+
}
|
|
33
|
+
export declare type FileUploadStatusProps = MandatoryStatusProps & (StatusUploadingProps | StatusErrorProps | StatusDoneProps);
|
|
34
|
+
export declare const FileUploadStatus: ({ status, filename, message, onAction, iconType, ...statusProps }: FileUploadStatusProps) => React.JSX.Element;
|
|
35
|
+
export default FileUploadStatus;
|
package/lib/components/file-input/__internal__/file-upload-status/file-upload-status.component.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.FileUploadStatus = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _link = _interopRequireDefault(require("../../../link"));
|
|
10
|
+
var _buttonMinor = _interopRequireDefault(require("../../../button-minor"));
|
|
11
|
+
var _typography = _interopRequireDefault(require("../../../typography/typography.style"));
|
|
12
|
+
var _progressTracker = _interopRequireDefault(require("../../../progress-tracker"));
|
|
13
|
+
var _loaderBar = _interopRequireDefault(require("../../../loader-bar"));
|
|
14
|
+
var _icon = _interopRequireDefault(require("../../../icon"));
|
|
15
|
+
var _fileUploadStatus = require("./file-upload-status.style");
|
|
16
|
+
var _useLocale = _interopRequireDefault(require("../../../../hooks/__internal__/useLocale"));
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
const FileUploadStatus = ({
|
|
19
|
+
status,
|
|
20
|
+
filename,
|
|
21
|
+
message,
|
|
22
|
+
onAction,
|
|
23
|
+
iconType = "file_generic",
|
|
24
|
+
...statusProps
|
|
25
|
+
}) => {
|
|
26
|
+
const locale = (0, _useLocale.default)();
|
|
27
|
+
const statusMessage = message || locale.fileInput.fileUploadStatus();
|
|
28
|
+
let buttonText;
|
|
29
|
+
let linkProps;
|
|
30
|
+
let progressBar = null;
|
|
31
|
+
switch (status) {
|
|
32
|
+
case "uploading":
|
|
33
|
+
buttonText = locale.fileInput.actions.cancel();
|
|
34
|
+
progressBar = statusProps.progress === undefined ? /*#__PURE__*/_react.default.createElement(_loaderBar.default, {
|
|
35
|
+
size: "small"
|
|
36
|
+
}) : /*#__PURE__*/_react.default.createElement(_progressTracker.default, {
|
|
37
|
+
size: "small",
|
|
38
|
+
progress: statusProps.progress,
|
|
39
|
+
length: "100%"
|
|
40
|
+
});
|
|
41
|
+
break;
|
|
42
|
+
case "previously":
|
|
43
|
+
case "completed":
|
|
44
|
+
buttonText = locale.fileInput.actions.delete();
|
|
45
|
+
linkProps = {
|
|
46
|
+
...statusProps,
|
|
47
|
+
icon: iconType
|
|
48
|
+
};
|
|
49
|
+
break;
|
|
50
|
+
case "error":
|
|
51
|
+
buttonText = locale.fileInput.actions.clear();
|
|
52
|
+
break;
|
|
53
|
+
// istanbul ignore next
|
|
54
|
+
default:
|
|
55
|
+
// no other cases if consumers are using TS, but ESLint still insists on it
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
const actionButton = /*#__PURE__*/_react.default.createElement(_buttonMinor.default, {
|
|
59
|
+
onClick: onAction,
|
|
60
|
+
buttonType: "tertiary"
|
|
61
|
+
}, buttonText);
|
|
62
|
+
const fileLink = linkProps ? /*#__PURE__*/_react.default.createElement(_link.default, linkProps, filename) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
63
|
+
type: iconType
|
|
64
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, filename));
|
|
65
|
+
const mainRow = status !== "previously" ? /*#__PURE__*/_react.default.createElement(_fileUploadStatus.StyledFileUploadStatusRow, null, /*#__PURE__*/_react.default.createElement(_typography.default, {
|
|
66
|
+
as: "p",
|
|
67
|
+
mb: 0,
|
|
68
|
+
"aria-live": "polite"
|
|
69
|
+
}, statusMessage), actionButton) : /*#__PURE__*/_react.default.createElement(_fileUploadStatus.StyledFileUploadStatusRow, {
|
|
70
|
+
onlyRow: true
|
|
71
|
+
}, /*#__PURE__*/_react.default.createElement(_fileUploadStatus.StyledFileLinkContainer, null, fileLink), actionButton);
|
|
72
|
+
const secondRow = status !== "previously" ? /*#__PURE__*/_react.default.createElement(_fileUploadStatus.StyledFileUploadStatusRow, {
|
|
73
|
+
upperPadding: true,
|
|
74
|
+
lowerPadding: true
|
|
75
|
+
}, /*#__PURE__*/_react.default.createElement(_fileUploadStatus.StyledFileLinkContainer, null, fileLink)) : null;
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement(_fileUploadStatus.StyledFileUploadStatus, {
|
|
77
|
+
hasError: status === "error"
|
|
78
|
+
}, mainRow, secondRow, progressBar);
|
|
79
|
+
};
|
|
80
|
+
exports.FileUploadStatus = FileUploadStatus;
|
|
81
|
+
var _default = exports.default = FileUploadStatus;
|
package/lib/components/file-input/__internal__/file-upload-status/file-upload-status.style.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const StyledFileLinkContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
interface StyledFileUploadStatusRowProps {
|
|
3
|
+
upperPadding?: boolean;
|
|
4
|
+
lowerPadding?: boolean;
|
|
5
|
+
onlyRow?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const StyledFileUploadStatusRow: import("styled-components").StyledComponent<"div", any, StyledFileUploadStatusRowProps, never>;
|
|
8
|
+
interface StyledFileUploadStatusProps {
|
|
9
|
+
hasError: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const StyledFileUploadStatus: import("styled-components").StyledComponent<"div", any, StyledFileUploadStatusProps, never>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledFileUploadStatusRow = exports.StyledFileUploadStatus = exports.StyledFileLinkContainer = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
+
var _typography = _interopRequireDefault(require("../../../typography/typography.style"));
|
|
9
|
+
var _icon = _interopRequireDefault(require("../../../icon/icon.style"));
|
|
10
|
+
var _progressTracker = require("../../../progress-tracker/progress-tracker.style");
|
|
11
|
+
var _loaderBar = _interopRequireWildcard(require("../../../loader-bar/loader-bar.style"));
|
|
12
|
+
var _link = require("../../../link/link.style");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
const StyledFileLinkContainer = exports.StyledFileLinkContainer = _styledComponents.default.div`
|
|
17
|
+
color: var(--colorsActionMajorYin090);
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
overflow-x: clip;
|
|
21
|
+
overflow-y: visible;
|
|
22
|
+
padding-right: var(--spacing150);
|
|
23
|
+
|
|
24
|
+
${_link.StyledLink} {
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
${_link.StyledLink} a {
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
display: flex;
|
|
31
|
+
text-decoration: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
${_link.StyledContent} {
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
text-overflow: ellipsis;
|
|
37
|
+
text-decoration: underline;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&&& ${_icon.default} {
|
|
41
|
+
display: inline-flex;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
align-items: flex-start;
|
|
44
|
+
width: 24px;
|
|
45
|
+
height: 24px;
|
|
46
|
+
|
|
47
|
+
// only apply these styles when the icon is not part of a Link component
|
|
48
|
+
:not(${_link.StyledLink} ${_icon.default}) {
|
|
49
|
+
color: var(--colorsUtilityYin065);
|
|
50
|
+
padding-right: var(--spacing100);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
const StyledFileUploadStatusRow = exports.StyledFileUploadStatusRow = _styledComponents.default.div`
|
|
55
|
+
display: flex;
|
|
56
|
+
justify-content: space-between;
|
|
57
|
+
${({
|
|
58
|
+
onlyRow
|
|
59
|
+
}) => onlyRow ? "" : "align-items: baseline;"}
|
|
60
|
+
padding-left: var(--spacing150);
|
|
61
|
+
${({
|
|
62
|
+
upperPadding
|
|
63
|
+
}) => upperPadding ? "padding-top: var(--spacing050);" : ""}
|
|
64
|
+
${({
|
|
65
|
+
lowerPadding
|
|
66
|
+
}) => lowerPadding ? "padding-bottom: var(--spacing125);" : ""}
|
|
67
|
+
|
|
68
|
+
${_typography.default} {
|
|
69
|
+
color: var(--colorsUtilityYin055);
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
const StyledFileUploadStatus = exports.StyledFileUploadStatus = _styledComponents.default.div`
|
|
73
|
+
background-color: var(--colorsUtilityYang100);
|
|
74
|
+
${({
|
|
75
|
+
hasError
|
|
76
|
+
}) => {
|
|
77
|
+
const borderWidthToken = hasError ? "borderWidth200" : "borderWidth100";
|
|
78
|
+
const colorToken = hasError ? "colorsSemanticNegative500" : "colorsUtilityMajor300";
|
|
79
|
+
return (0, _styledComponents.css)`
|
|
80
|
+
border: var(--${borderWidthToken}) solid var(--${colorToken});
|
|
81
|
+
${hasError && `&& ${_typography.default} {
|
|
82
|
+
color: var(--${colorToken});
|
|
83
|
+
font-weight: 500;
|
|
84
|
+
}`}
|
|
85
|
+
`;
|
|
86
|
+
}}
|
|
87
|
+
border-radius: var(--borderRadius050);
|
|
88
|
+
width: 100%;
|
|
89
|
+
|
|
90
|
+
${_progressTracker.StyledProgressBar}, ${_progressTracker.InnerBar} {
|
|
91
|
+
border-radius: var(--borderRadius050);
|
|
92
|
+
border: none;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
${_loaderBar.StyledLoader} {
|
|
96
|
+
display: flex;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
${_loaderBar.default} {
|
|
100
|
+
background-color: var(--colorsSemanticNeutral200);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
${_loaderBar.InnerBar} {
|
|
104
|
+
background-color: var(--colorsSemanticNeutral500);
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _fileUploadStatus.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _fileUploadStatus = _interopRequireDefault(require("./file-upload-status.component"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MarginProps } from "styled-system";
|
|
3
|
+
import { ValidationProps } from "../../__internal__/validations";
|
|
4
|
+
import { InputProps } from "../../__internal__/input";
|
|
5
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
6
|
+
import { FileUploadStatusProps } from "./__internal__/file-upload-status";
|
|
7
|
+
export interface FileInputProps extends Pick<ValidationProps, "error">, Pick<InputProps, "id" | "name" | "required">, TagProps, MarginProps {
|
|
8
|
+
/** Which file format(s) to accept. Will be passed to the underlying HTML input.
|
|
9
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept */
|
|
10
|
+
accept?: string;
|
|
11
|
+
/** Text to appear on the main button. Defaults to "Select file" */
|
|
12
|
+
buttonText?: string;
|
|
13
|
+
/** Explanatory text to appear inside the input area. Defaults to "or drag and drop your file" */
|
|
14
|
+
dragAndDropText?: string;
|
|
15
|
+
/** A hint string rendered before the input but after the label. Intended to describe the purpose or content of the input. */
|
|
16
|
+
inputHint?: React.ReactNode;
|
|
17
|
+
/** Sets the default layout to vertical - with the button below the explanatory text rather than next to it.
|
|
18
|
+
* This is the equivalent of removing the maxHeight prop - it will be over-ridden if this prop is set explicitly. */
|
|
19
|
+
isVertical?: boolean;
|
|
20
|
+
/** Label content */
|
|
21
|
+
label?: string;
|
|
22
|
+
/** A valid CSS string for the max-height CSS property. Defaults to the same as the minHeight. */
|
|
23
|
+
maxHeight?: string;
|
|
24
|
+
/** A valid CSS string for the max-width CSS property. Defaults to the same as the minWidth. */
|
|
25
|
+
maxWidth?: string;
|
|
26
|
+
/** A valid CSS string for the min-height CSS property. Defaults to 40px. */
|
|
27
|
+
minHeight?: string;
|
|
28
|
+
/** A valid CSS string for the min-width CSS property. Defaults to 256px. */
|
|
29
|
+
minWidth?: string;
|
|
30
|
+
/** onChange event handler. Accepts a list of all files currently entered to the input. */
|
|
31
|
+
onChange: (files: FileList) => void;
|
|
32
|
+
/** used to control how to display the progress of uploaded file(s) within the component */
|
|
33
|
+
uploadStatus?: FileUploadStatusProps | FileUploadStatusProps[];
|
|
34
|
+
}
|
|
35
|
+
export declare const FileInput: React.ForwardRefExoticComponent<FileInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
36
|
+
export default FileInput;
|