@spaced-out/ui-design-system 0.1.32 → 0.1.34
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/.cspell/custom-words.txt +1 -0
- package/.github/workflows/publish_to_npm.yml +1 -1
- package/CHANGELOG.md +19 -0
- package/lib/components/Badge/Badge.js +3 -3
- package/lib/components/Badge/Badge.js.flow +3 -3
- package/lib/components/Badge/Badge.module.css +6 -0
- package/lib/components/Dialog/index.js +11 -31
- package/lib/components/Dialog/index.js.flow +1 -13
- package/lib/components/FileUpload/FileBlock/FileBlock.js +111 -0
- package/lib/components/FileUpload/FileBlock/FileBlock.js.flow +139 -0
- package/lib/components/FileUpload/FileBlock/index.js +16 -0
- package/lib/components/FileUpload/FileBlock/index.js.flow +3 -0
- package/lib/components/FileUpload/FileUpload.js +5 -98
- package/lib/components/FileUpload/FileUpload.js.flow +5 -107
- package/lib/components/FileUpload/FileUpload.module.css +1 -1
- package/lib/components/FileUpload/index.js +11 -0
- package/lib/components/FileUpload/index.js.flow +1 -0
- package/lib/components/Stepper/Step/Step.js +63 -0
- package/lib/components/Stepper/Step/Step.js.flow +101 -0
- package/lib/components/Stepper/Step/StepContent.js +30 -0
- package/lib/components/Stepper/Step/StepContent.js.flow +40 -0
- package/lib/components/{CodeBlock/CodeBlock.js → Stepper/Step/StepLabel.js} +18 -11
- package/lib/components/Stepper/Step/StepLabel.js.flow +40 -0
- package/lib/components/Stepper/Step/index.js +38 -0
- package/lib/components/Stepper/Step/index.js.flow +5 -0
- package/lib/components/Stepper/Stepper.js +48 -0
- package/lib/components/Stepper/Stepper.js.flow +64 -0
- package/lib/components/Stepper/Stepper.module.css +110 -0
- package/lib/components/Stepper/index.js +27 -0
- package/lib/components/Stepper/index.js.flow +4 -0
- package/lib/components/index.js +11 -11
- package/lib/components/index.js.flow +1 -1
- package/package.json +1 -2
- package/lib/components/CodeBlock/CodeBlock.js.flow +0 -20
- package/lib/components/CodeBlock/index.js +0 -12
- package/lib/components/CodeBlock/index.js.flow +0 -3
package/.cspell/custom-words.txt
CHANGED
|
@@ -22,7 +22,7 @@ jobs:
|
|
|
22
22
|
- name: Check Permissions
|
|
23
23
|
id: check-permissions
|
|
24
24
|
env:
|
|
25
|
-
ALLOWED_USERS: superrover, Anant-Raj
|
|
25
|
+
ALLOWED_USERS: superrover, Anant-Raj, nsfmc
|
|
26
26
|
if: ${{ !contains(env.ALLOWED_USERS, github.actor) }}
|
|
27
27
|
run: |
|
|
28
28
|
echo "You don't have correct permissions to do this release"
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.34](https://github.com/spaced-out/ui-design-system/compare/v0.1.33...v0.1.34) (2023-06-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* remove CodeBlock ([#122](https://github.com/spaced-out/ui-design-system/issues/122)) ([fedffc6](https://github.com/spaced-out/ui-design-system/commit/fedffc68d7571582692c67147894f6c2f2b7ada1))
|
|
11
|
+
|
|
12
|
+
### [0.1.33](https://github.com/spaced-out/ui-design-system/compare/v0.1.32...v0.1.33) (2023-06-28)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* :new: stepper component and FileBlock separation ([#121](https://github.com/spaced-out/ui-design-system/issues/121)) ([3f20562](https://github.com/spaced-out/ui-design-system/commit/3f20562507b3fc9ed9b8854512d6bd0ac805d638))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* collapsible card docs fix ([f1115e3](https://github.com/spaced-out/ui-design-system/commit/f1115e38ea4b1c270adc9ac3f83cae05fa6daf10))
|
|
23
|
+
|
|
5
24
|
### [0.1.32](https://github.com/spaced-out/ui-design-system/compare/v0.1.31...v0.1.32) (2023-06-16)
|
|
6
25
|
|
|
7
26
|
|
|
@@ -30,12 +30,12 @@ const Badge = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
30
30
|
} = _ref;
|
|
31
31
|
return /*#__PURE__*/React.createElement("div", {
|
|
32
32
|
"data-testid": "Badge",
|
|
33
|
+
style: {
|
|
34
|
+
'--wrapperBgColor': BADGE_COLOR[fill]
|
|
35
|
+
},
|
|
33
36
|
className: (0, _classify.default)(_BadgeModule.default.badgeWrapper, {
|
|
34
37
|
[_BadgeModule.default.fixedWidth]: text.length <= 2
|
|
35
38
|
}, classNames?.wrapper),
|
|
36
|
-
style: {
|
|
37
|
-
backgroundColor: BADGE_COLOR[fill]
|
|
38
|
-
},
|
|
39
39
|
ref: ref
|
|
40
40
|
}, /*#__PURE__*/React.createElement(_Text.ButtonTextSmall, {
|
|
41
41
|
className: classNames?.text
|
|
@@ -40,6 +40,9 @@ export const Badge: React$AbstractComponent<BadgeProps, HTMLDivElement> =
|
|
|
40
40
|
({classNames, text, fill = 'gray'}: BadgeProps, ref): React.Node => (
|
|
41
41
|
<div
|
|
42
42
|
data-testid="Badge"
|
|
43
|
+
style={{
|
|
44
|
+
'--wrapperBgColor': BADGE_COLOR[fill],
|
|
45
|
+
}}
|
|
43
46
|
className={classify(
|
|
44
47
|
css.badgeWrapper,
|
|
45
48
|
{
|
|
@@ -47,9 +50,6 @@ export const Badge: React$AbstractComponent<BadgeProps, HTMLDivElement> =
|
|
|
47
50
|
},
|
|
48
51
|
classNames?.wrapper,
|
|
49
52
|
)}
|
|
50
|
-
style={{
|
|
51
|
-
backgroundColor: BADGE_COLOR[fill],
|
|
52
|
-
}}
|
|
53
53
|
ref={ref}
|
|
54
54
|
>
|
|
55
55
|
<ButtonTextSmall className={classNames?.text}>{text}</ButtonTextSmall>
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
@value (size22, size100) from '../../styles/variables/_size.css';
|
|
2
2
|
@value (spaceXSmall, spaceNone) from '../../styles/variables/_space.css';
|
|
3
|
+
@value (colorGrayLightest) from '../../styles/variables/_color.css';
|
|
3
4
|
|
|
4
5
|
.badgeWrapper {
|
|
6
|
+
--wrapperBgColor: colorGrayLightest;
|
|
5
7
|
display: flex;
|
|
6
8
|
align-items: center;
|
|
7
9
|
justify-content: center;
|
|
8
10
|
border-radius: size100;
|
|
9
11
|
height: size22;
|
|
10
12
|
padding: spaceNone spaceXSmall;
|
|
13
|
+
min-width: fit-content;
|
|
11
14
|
width: fit-content;
|
|
15
|
+
background-color: var(--wrapperBgColor);
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
.fixedWidth {
|
|
15
19
|
padding: initial;
|
|
16
20
|
width: size22;
|
|
17
21
|
height: size22;
|
|
22
|
+
min-width: size22;
|
|
23
|
+
min-height: size22;
|
|
18
24
|
}
|
|
@@ -3,34 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "DialogBody", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _Dialog.DialogBody;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "DialogFooter", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _Dialog.DialogFooter;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "DialogHeader", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _Dialog.DialogHeader;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
var _Dialog = require("./Dialog");
|
|
6
|
+
var _Dialog = require("./Dialog");
|
|
7
|
+
Object.keys(_Dialog).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _Dialog[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _Dialog[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -1,14 +1,2 @@
|
|
|
1
1
|
//@flow strict
|
|
2
|
-
export
|
|
3
|
-
DialogBodyProps,
|
|
4
|
-
DialogFooterProps,
|
|
5
|
-
DialogHeaderProps,
|
|
6
|
-
DialogProps,
|
|
7
|
-
} from './Dialog';
|
|
8
|
-
export {
|
|
9
|
-
Dialog,
|
|
10
|
-
DIALOG_SEMANTIC,
|
|
11
|
-
DialogBody,
|
|
12
|
-
DialogFooter,
|
|
13
|
-
DialogHeader,
|
|
14
|
-
} from './Dialog';
|
|
2
|
+
export * from './Dialog';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FileBlock = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classify = _interopRequireDefault(require("../../../utils/classify"));
|
|
9
|
+
var _Icon = require("../../Icon");
|
|
10
|
+
var _LinearLoader = require("../../LinearLoader");
|
|
11
|
+
var _Truncate = require("../../Truncate");
|
|
12
|
+
var _FileUploadModule = _interopRequireDefault(require("../FileUpload.module.css"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
const FileBlock = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
18
|
+
let {
|
|
19
|
+
classNames,
|
|
20
|
+
fileObject,
|
|
21
|
+
onFileRefreshClick,
|
|
22
|
+
handleFileClear
|
|
23
|
+
} = _ref;
|
|
24
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: (0, _classify.default)(_FileUploadModule.default.file, classNames?.wrapper),
|
|
26
|
+
ref: ref
|
|
27
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
className: _FileUploadModule.default.fileInfo
|
|
29
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: _FileUploadModule.default.fileNameBlock
|
|
31
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
className: _FileUploadModule.default.icon
|
|
33
|
+
}, /*#__PURE__*/React.createElement(FileStatusIcon, {
|
|
34
|
+
fileObject: fileObject
|
|
35
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: _FileUploadModule.default.fileName
|
|
37
|
+
}, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, fileObject.file.name))), fileObject.success && !!fileObject.successMessage && !fileObject.progress && /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
className: _FileUploadModule.default.fileSuccess
|
|
39
|
+
}, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, fileObject.successMessage)), fileObject.reject && !!fileObject.rejectReason && !fileObject.progress && /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
className: _FileUploadModule.default.fileError
|
|
41
|
+
}, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, fileObject.rejectReason)), !!fileObject.progress && /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
className: _FileUploadModule.default.progress
|
|
43
|
+
}, /*#__PURE__*/React.createElement(_LinearLoader.LinearLoader, {
|
|
44
|
+
size: "small",
|
|
45
|
+
value: fileObject.progress === 'indeterminate' ? 0 : fileObject.progress,
|
|
46
|
+
indeterminate: fileObject.progress === 'indeterminate'
|
|
47
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: _FileUploadModule.default.rightSection
|
|
49
|
+
}, fileObject.showReUpload && /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
className: _FileUploadModule.default.rightBlock
|
|
51
|
+
}, /*#__PURE__*/React.createElement(_Icon.ClickableIcon, {
|
|
52
|
+
name: "refresh",
|
|
53
|
+
size: "small",
|
|
54
|
+
onClick: () => onFileRefreshClick?.(fileObject)
|
|
55
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
className: _FileUploadModule.default.rightBlock
|
|
57
|
+
}, /*#__PURE__*/React.createElement(_Icon.CloseIcon, {
|
|
58
|
+
size: "small",
|
|
59
|
+
onClick: () => handleFileClear?.(fileObject.id)
|
|
60
|
+
})))));
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// This function returns the status of a file
|
|
64
|
+
exports.FileBlock = FileBlock;
|
|
65
|
+
const getFileStatus = fileObject => {
|
|
66
|
+
if (fileObject.progress) {
|
|
67
|
+
return 'progress';
|
|
68
|
+
}
|
|
69
|
+
if (fileObject.success) {
|
|
70
|
+
return 'success';
|
|
71
|
+
}
|
|
72
|
+
if (fileObject.reject) {
|
|
73
|
+
return 'error';
|
|
74
|
+
}
|
|
75
|
+
return 'default';
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// This component renders the status icon for a file
|
|
79
|
+
const FileStatusIcon = _ref2 => {
|
|
80
|
+
let {
|
|
81
|
+
fileObject
|
|
82
|
+
} = _ref2;
|
|
83
|
+
const status = getFileStatus(fileObject);
|
|
84
|
+
switch (status) {
|
|
85
|
+
case 'progress':
|
|
86
|
+
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
87
|
+
size: "small",
|
|
88
|
+
name: "loader",
|
|
89
|
+
color: "tertiary"
|
|
90
|
+
});
|
|
91
|
+
case 'success':
|
|
92
|
+
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
93
|
+
size: "small",
|
|
94
|
+
name: "check",
|
|
95
|
+
color: "success"
|
|
96
|
+
});
|
|
97
|
+
case 'error':
|
|
98
|
+
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
99
|
+
size: "small",
|
|
100
|
+
name: "circle-exclamation",
|
|
101
|
+
color: "danger",
|
|
102
|
+
type: "solid"
|
|
103
|
+
});
|
|
104
|
+
default:
|
|
105
|
+
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
106
|
+
size: "small",
|
|
107
|
+
name: "check",
|
|
108
|
+
color: "success"
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import classify from '../../../utils/classify';
|
|
6
|
+
import {ClickableIcon, CloseIcon, Icon} from '../../Icon';
|
|
7
|
+
import {LinearLoader} from '../../LinearLoader';
|
|
8
|
+
import {Truncate} from '../../Truncate';
|
|
9
|
+
import type {FileObject} from '../FileUpload';
|
|
10
|
+
|
|
11
|
+
import css from '../FileUpload.module.css';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
type ClassNames = $ReadOnly<{
|
|
15
|
+
wrapper?: string,
|
|
16
|
+
}>;
|
|
17
|
+
|
|
18
|
+
export type FileBlockProps = {
|
|
19
|
+
classNames?: ClassNames,
|
|
20
|
+
fileObject: FileObject,
|
|
21
|
+
onFileRefreshClick?: (file: FileObject) => void,
|
|
22
|
+
handleFileClear?: (id: string) => mixed,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const FileBlock: React$AbstractComponent<
|
|
26
|
+
FileBlockProps,
|
|
27
|
+
HTMLDivElement,
|
|
28
|
+
> = React.forwardRef<FileBlockProps, HTMLDivElement>(
|
|
29
|
+
(
|
|
30
|
+
{
|
|
31
|
+
classNames,
|
|
32
|
+
fileObject,
|
|
33
|
+
onFileRefreshClick,
|
|
34
|
+
handleFileClear,
|
|
35
|
+
}: FileBlockProps,
|
|
36
|
+
ref,
|
|
37
|
+
): React.Node => (
|
|
38
|
+
<>
|
|
39
|
+
<div className={classify(css.file, classNames?.wrapper)} ref={ref}>
|
|
40
|
+
<div className={css.fileInfo}>
|
|
41
|
+
<div className={css.fileNameBlock}>
|
|
42
|
+
<div className={css.icon}>
|
|
43
|
+
<FileStatusIcon fileObject={fileObject} />
|
|
44
|
+
</div>
|
|
45
|
+
<div className={css.fileName}>
|
|
46
|
+
<Truncate>{fileObject.file.name}</Truncate>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
{fileObject.success &&
|
|
51
|
+
!!fileObject.successMessage &&
|
|
52
|
+
!fileObject.progress && (
|
|
53
|
+
<div className={css.fileSuccess}>
|
|
54
|
+
<Truncate>{fileObject.successMessage}</Truncate>
|
|
55
|
+
</div>
|
|
56
|
+
)}
|
|
57
|
+
|
|
58
|
+
{fileObject.reject &&
|
|
59
|
+
!!fileObject.rejectReason &&
|
|
60
|
+
!fileObject.progress && (
|
|
61
|
+
<div className={css.fileError}>
|
|
62
|
+
<Truncate>{fileObject.rejectReason}</Truncate>
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
65
|
+
|
|
66
|
+
{!!fileObject.progress && (
|
|
67
|
+
<div className={css.progress}>
|
|
68
|
+
<LinearLoader
|
|
69
|
+
size="small"
|
|
70
|
+
value={
|
|
71
|
+
fileObject.progress === 'indeterminate'
|
|
72
|
+
? 0
|
|
73
|
+
: fileObject.progress
|
|
74
|
+
}
|
|
75
|
+
indeterminate={fileObject.progress === 'indeterminate'}
|
|
76
|
+
></LinearLoader>
|
|
77
|
+
</div>
|
|
78
|
+
)}
|
|
79
|
+
</div>
|
|
80
|
+
<div className={css.rightSection}>
|
|
81
|
+
{fileObject.showReUpload && (
|
|
82
|
+
<div className={css.rightBlock}>
|
|
83
|
+
<ClickableIcon
|
|
84
|
+
name="refresh"
|
|
85
|
+
size="small"
|
|
86
|
+
onClick={() => onFileRefreshClick?.(fileObject)}
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
|
|
91
|
+
<div className={css.rightBlock}>
|
|
92
|
+
<CloseIcon
|
|
93
|
+
size="small"
|
|
94
|
+
onClick={() => handleFileClear?.(fileObject.id)}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</>
|
|
100
|
+
),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
// This function returns the status of a file
|
|
104
|
+
const getFileStatus = (fileObject: FileObject) => {
|
|
105
|
+
if (fileObject.progress) {
|
|
106
|
+
return 'progress';
|
|
107
|
+
}
|
|
108
|
+
if (fileObject.success) {
|
|
109
|
+
return 'success';
|
|
110
|
+
}
|
|
111
|
+
if (fileObject.reject) {
|
|
112
|
+
return 'error';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return 'default';
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// This component renders the status icon for a file
|
|
119
|
+
const FileStatusIcon = ({fileObject}: {fileObject: FileObject}) => {
|
|
120
|
+
const status = getFileStatus(fileObject);
|
|
121
|
+
switch (status) {
|
|
122
|
+
case 'progress':
|
|
123
|
+
return <Icon size="small" name="loader" color="tertiary" />;
|
|
124
|
+
case 'success':
|
|
125
|
+
return <Icon size="small" name="check" color="success" />;
|
|
126
|
+
case 'error':
|
|
127
|
+
return (
|
|
128
|
+
<Icon
|
|
129
|
+
size="small"
|
|
130
|
+
name="circle-exclamation"
|
|
131
|
+
color="danger"
|
|
132
|
+
type="solid"
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
default:
|
|
137
|
+
return <Icon size="small" name="check" color="success" />;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _FileBlock = require("./FileBlock");
|
|
7
|
+
Object.keys(_FileBlock).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _FileBlock[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _FileBlock[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -8,9 +8,8 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _useFileUpload = require("../../hooks/useFileUpload");
|
|
9
9
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
10
10
|
var _Button = require("../Button");
|
|
11
|
-
var _Icon = require("../Icon");
|
|
12
|
-
var _LinearLoader = require("../LinearLoader");
|
|
13
11
|
var _Truncate = require("../Truncate");
|
|
12
|
+
var _FileBlock = require("./FileBlock");
|
|
14
13
|
var _FileUploadModule = _interopRequireDefault(require("./FileUpload.module.css"));
|
|
15
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -91,105 +90,13 @@ const FileUploadBase = (props, ref) => {
|
|
|
91
90
|
className: (0, _classify.default)(_FileUploadModule.default.secondaryInstruction, classNames?.secondaryInstruction)
|
|
92
91
|
}, secondaryInstruction)), files.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
93
92
|
className: _FileUploadModule.default.files
|
|
94
|
-
}, files.map(
|
|
95
|
-
key:
|
|
96
|
-
}, /*#__PURE__*/React.createElement(FileBlock, {
|
|
97
|
-
|
|
93
|
+
}, files.map(fileObject => /*#__PURE__*/React.createElement(React.Fragment, {
|
|
94
|
+
key: fileObject.id
|
|
95
|
+
}, /*#__PURE__*/React.createElement(_FileBlock.FileBlock, {
|
|
96
|
+
fileObject: fileObject,
|
|
98
97
|
onFileRefreshClick: onFileRefreshClick,
|
|
99
98
|
handleFileClear: handleFileClear
|
|
100
99
|
})))));
|
|
101
100
|
};
|
|
102
|
-
const FileBlock = _ref => {
|
|
103
|
-
let {
|
|
104
|
-
file,
|
|
105
|
-
onFileRefreshClick,
|
|
106
|
-
handleFileClear
|
|
107
|
-
} = _ref;
|
|
108
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
109
|
-
className: _FileUploadModule.default.file
|
|
110
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
111
|
-
className: _FileUploadModule.default.fileInfo
|
|
112
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
113
|
-
className: _FileUploadModule.default.fileNameBlock
|
|
114
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
115
|
-
className: _FileUploadModule.default.icon
|
|
116
|
-
}, /*#__PURE__*/React.createElement(FileStatusIcon, {
|
|
117
|
-
file: file
|
|
118
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
119
|
-
className: _FileUploadModule.default.fileName
|
|
120
|
-
}, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, file.file.name))), file.success && !!file.successMessage && /*#__PURE__*/React.createElement("div", {
|
|
121
|
-
className: _FileUploadModule.default.fileSuccess
|
|
122
|
-
}, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, file.successMessage)), file.reject && !!file.rejectReason && /*#__PURE__*/React.createElement("div", {
|
|
123
|
-
className: _FileUploadModule.default.fileError
|
|
124
|
-
}, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, file.rejectReason)), !!file.progress && /*#__PURE__*/React.createElement("div", {
|
|
125
|
-
className: _FileUploadModule.default.progress
|
|
126
|
-
}, /*#__PURE__*/React.createElement(_LinearLoader.LinearLoader, {
|
|
127
|
-
size: "small",
|
|
128
|
-
value: file.progress === 'indeterminate' ? 0 : file.progress,
|
|
129
|
-
indeterminate: file.progress === 'indeterminate'
|
|
130
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
131
|
-
className: _FileUploadModule.default.rightSection
|
|
132
|
-
}, file.showReUpload && /*#__PURE__*/React.createElement("div", {
|
|
133
|
-
className: _FileUploadModule.default.rightBlock
|
|
134
|
-
}, /*#__PURE__*/React.createElement(_Icon.ClickableIcon, {
|
|
135
|
-
name: "refresh",
|
|
136
|
-
size: "small",
|
|
137
|
-
onClick: () => onFileRefreshClick?.(file)
|
|
138
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
139
|
-
className: _FileUploadModule.default.rightBlock
|
|
140
|
-
}, /*#__PURE__*/React.createElement(_Icon.CloseIcon, {
|
|
141
|
-
size: "small",
|
|
142
|
-
onClick: () => handleFileClear?.(file.id)
|
|
143
|
-
})))));
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
// This function returns the status of a file
|
|
147
|
-
const getFileStatus = file => {
|
|
148
|
-
if (file.progress) {
|
|
149
|
-
return 'progress';
|
|
150
|
-
}
|
|
151
|
-
if (file.success) {
|
|
152
|
-
return 'success';
|
|
153
|
-
}
|
|
154
|
-
if (file.reject) {
|
|
155
|
-
return 'error';
|
|
156
|
-
}
|
|
157
|
-
return 'default';
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
// This component renders the status icon for a file
|
|
161
|
-
const FileStatusIcon = _ref2 => {
|
|
162
|
-
let {
|
|
163
|
-
file
|
|
164
|
-
} = _ref2;
|
|
165
|
-
const status = getFileStatus(file);
|
|
166
|
-
switch (status) {
|
|
167
|
-
case 'progress':
|
|
168
|
-
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
169
|
-
size: "small",
|
|
170
|
-
name: "loader",
|
|
171
|
-
color: "tertiary"
|
|
172
|
-
});
|
|
173
|
-
case 'success':
|
|
174
|
-
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
175
|
-
size: "small",
|
|
176
|
-
name: "check",
|
|
177
|
-
color: "success"
|
|
178
|
-
});
|
|
179
|
-
case 'error':
|
|
180
|
-
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
181
|
-
size: "small",
|
|
182
|
-
name: "circle-exclamation",
|
|
183
|
-
color: "danger",
|
|
184
|
-
type: "solid"
|
|
185
|
-
});
|
|
186
|
-
default:
|
|
187
|
-
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
188
|
-
size: "small",
|
|
189
|
-
name: "check",
|
|
190
|
-
color: "success"
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
101
|
const FileUpload = /*#__PURE__*/React.forwardRef(FileUploadBase);
|
|
195
102
|
exports.FileUpload = FileUpload;
|