@spaced-out/ui-design-system 0.1.49 → 0.1.51
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/CHANGELOG.md +14 -0
- package/lib/components/FileUpload/FileBlock/FileBlock.js.flow +1 -1
- package/lib/components/FileUpload/FileUpload.js +4 -2
- package/lib/components/FileUpload/FileUpload.js.flow +20 -7
- package/lib/components/Table/DefaultTableHeader.js +5 -2
- package/lib/components/Table/DefaultTableHeader.js.flow +9 -1
- package/lib/components/Table/StaticTable.js +6 -2
- package/lib/components/Table/StaticTable.js.flow +10 -1
- package/lib/components/Table/Table.js.flow +3 -0
- package/lib/components/Table/Table.module.css +22 -3
- package/lib/components/Table/TableBar.module.css +8 -15
- package/lib/utils/helpers/helpers.js +2 -1
- package/lib/utils/helpers/helpers.js.flow +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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.51](https://github.com/spaced-out/ui-design-system/compare/v0.1.50...v0.1.51) (2023-09-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* new table actions ([#144](https://github.com/spaced-out/ui-design-system/issues/144)) ([d28c032](https://github.com/spaced-out/ui-design-system/commit/d28c0321fff272694e2363fd0a634c6a9030b50a))
|
|
11
|
+
|
|
12
|
+
### [0.1.50](https://github.com/spaced-out/ui-design-system/compare/v0.1.49...v0.1.50) (2023-09-15)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* external file deletion support for file upload ([32cf857](https://github.com/spaced-out/ui-design-system/commit/32cf857a9688c2a20b1214381caccde699c192c4))
|
|
18
|
+
|
|
5
19
|
### [0.1.49](https://github.com/spaced-out/ui-design-system/compare/v0.1.48...v0.1.49) (2023-09-15)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -18,7 +18,7 @@ type ClassNames = $ReadOnly<{
|
|
|
18
18
|
export type FileBlockProps = {
|
|
19
19
|
classNames?: ClassNames,
|
|
20
20
|
fileObject: FileObject,
|
|
21
|
-
onFileRefreshClick?: (file: FileObject) =>
|
|
21
|
+
onFileRefreshClick?: (file: FileObject) => mixed,
|
|
22
22
|
handleFileClear?: (id: string) => mixed,
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -31,7 +31,8 @@ const FileUploadBase = (props, ref) => {
|
|
|
31
31
|
onRejectedFilesDrop,
|
|
32
32
|
onFileClear,
|
|
33
33
|
onFileRefreshClick,
|
|
34
|
-
maxFiles = 1
|
|
34
|
+
maxFiles = 1,
|
|
35
|
+
handleFileDeletionExternally
|
|
35
36
|
} = props;
|
|
36
37
|
|
|
37
38
|
// Get file upload state from useFileUpload hook
|
|
@@ -62,6 +63,7 @@ const FileUploadBase = (props, ref) => {
|
|
|
62
63
|
moveFileToProgress,
|
|
63
64
|
moveFileToSuccess,
|
|
64
65
|
moveFileToReject,
|
|
66
|
+
handleFileClear,
|
|
65
67
|
setShowReUpload,
|
|
66
68
|
validFiles,
|
|
67
69
|
rejectedFiles,
|
|
@@ -95,7 +97,7 @@ const FileUploadBase = (props, ref) => {
|
|
|
95
97
|
}, /*#__PURE__*/React.createElement(_FileBlock.FileBlock, {
|
|
96
98
|
fileObject: fileObject,
|
|
97
99
|
onFileRefreshClick: onFileRefreshClick,
|
|
98
|
-
handleFileClear: handleFileClear
|
|
100
|
+
handleFileClear: handleFileDeletionExternally ? onFileClear : handleFileClear
|
|
99
101
|
})))));
|
|
100
102
|
};
|
|
101
103
|
const FileUpload = /*#__PURE__*/React.forwardRef(FileUploadBase);
|
|
@@ -23,8 +23,15 @@ type ClassNames = $ReadOnly<{
|
|
|
23
23
|
|
|
24
24
|
export type FileProgress = number | 'indeterminate';
|
|
25
25
|
|
|
26
|
+
type LocalFileProps = {
|
|
27
|
+
name?: string,
|
|
28
|
+
type?: string,
|
|
29
|
+
size?: number,
|
|
30
|
+
...
|
|
31
|
+
};
|
|
32
|
+
|
|
26
33
|
export type FileObject = {
|
|
27
|
-
file: File,
|
|
34
|
+
file: File | LocalFileProps,
|
|
28
35
|
id: string,
|
|
29
36
|
reject?: boolean,
|
|
30
37
|
rejectReason?: string,
|
|
@@ -53,6 +60,7 @@ export type FileUploadRef = {
|
|
|
53
60
|
moveFileToSuccess: (id: string, successMessage?: string) => mixed,
|
|
54
61
|
moveFileToReject: (id: string, rejectReason?: string) => mixed,
|
|
55
62
|
setShowReUpload: (id: string, showReUpload?: boolean) => mixed,
|
|
63
|
+
handleFileClear: (id: string) => mixed,
|
|
56
64
|
validFiles: Array<FileObject>,
|
|
57
65
|
rejectedFiles: Array<FileObject>,
|
|
58
66
|
files: Array<FileObject>,
|
|
@@ -66,12 +74,12 @@ export type FileUploadBaseProps = {
|
|
|
66
74
|
disabled?: boolean,
|
|
67
75
|
|
|
68
76
|
// File drop callbacks
|
|
69
|
-
onValidFilesDrop?: (acceptedFiles: Array<FileObject>) =>
|
|
70
|
-
onRejectedFilesDrop?: (fileRejections: Array<FileObject>) =>
|
|
77
|
+
onValidFilesDrop?: (acceptedFiles: Array<FileObject>) => mixed,
|
|
78
|
+
onRejectedFilesDrop?: (fileRejections: Array<FileObject>) => mixed,
|
|
71
79
|
|
|
72
80
|
// File clear callbacks
|
|
73
|
-
onFileClear?: (id: string) =>
|
|
74
|
-
onClear?: () =>
|
|
81
|
+
onFileClear?: (id: string) => mixed,
|
|
82
|
+
onClear?: () => mixed,
|
|
75
83
|
};
|
|
76
84
|
|
|
77
85
|
export type FileUploadProps = {
|
|
@@ -83,9 +91,10 @@ export type FileUploadProps = {
|
|
|
83
91
|
draggingInstruction?: React.Node,
|
|
84
92
|
secondaryInstruction?: React.Node,
|
|
85
93
|
required?: boolean,
|
|
94
|
+
handleFileDeletionExternally?: boolean,
|
|
86
95
|
|
|
87
96
|
// File refresh callback
|
|
88
|
-
onFileRefreshClick?: (file: FileObject) =>
|
|
97
|
+
onFileRefreshClick?: (file: FileObject) => mixed,
|
|
89
98
|
};
|
|
90
99
|
|
|
91
100
|
const FileUploadBase = (props: FileUploadProps, ref) => {
|
|
@@ -105,6 +114,7 @@ const FileUploadBase = (props: FileUploadProps, ref) => {
|
|
|
105
114
|
onFileClear,
|
|
106
115
|
onFileRefreshClick,
|
|
107
116
|
maxFiles = 1,
|
|
117
|
+
handleFileDeletionExternally,
|
|
108
118
|
} = props;
|
|
109
119
|
|
|
110
120
|
// Get file upload state from useFileUpload hook
|
|
@@ -135,6 +145,7 @@ const FileUploadBase = (props: FileUploadProps, ref) => {
|
|
|
135
145
|
moveFileToProgress,
|
|
136
146
|
moveFileToSuccess,
|
|
137
147
|
moveFileToReject,
|
|
148
|
+
handleFileClear,
|
|
138
149
|
setShowReUpload,
|
|
139
150
|
validFiles,
|
|
140
151
|
rejectedFiles,
|
|
@@ -183,7 +194,9 @@ const FileUploadBase = (props: FileUploadProps, ref) => {
|
|
|
183
194
|
<FileBlock
|
|
184
195
|
fileObject={fileObject}
|
|
185
196
|
onFileRefreshClick={onFileRefreshClick}
|
|
186
|
-
handleFileClear={
|
|
197
|
+
handleFileClear={
|
|
198
|
+
handleFileDeletionExternally ? onFileClear : handleFileClear
|
|
199
|
+
}
|
|
187
200
|
/>
|
|
188
201
|
</React.Fragment>
|
|
189
202
|
))}
|
|
@@ -63,7 +63,8 @@ function DefaultTableHeader(props) {
|
|
|
63
63
|
sortDirection = 'original',
|
|
64
64
|
handleCheckboxClick,
|
|
65
65
|
checked,
|
|
66
|
-
disabled
|
|
66
|
+
disabled,
|
|
67
|
+
stickyHeader
|
|
67
68
|
} = props;
|
|
68
69
|
const tableHeaderCells = () => /*#__PURE__*/React.createElement(React.Fragment, null, columns.map((columnData, index) => {
|
|
69
70
|
const {
|
|
@@ -130,7 +131,9 @@ function DefaultTableHeader(props) {
|
|
|
130
131
|
}, filterIcon))));
|
|
131
132
|
}));
|
|
132
133
|
return /*#__PURE__*/React.createElement(BasicTableHead, {
|
|
133
|
-
className: (0, _classify.default)(_TableModule.default.tableHeaderSortable,
|
|
134
|
+
className: (0, _classify.default)(_TableModule.default.tableHeaderSortable, {
|
|
135
|
+
[_TableModule.default.stickyHeader]: stickyHeader
|
|
136
|
+
}, className)
|
|
134
137
|
}, /*#__PURE__*/React.createElement(_DefaultRow.BasicRow, {
|
|
135
138
|
className: _TableModule.default.defaultHeaderRow
|
|
136
139
|
}, handleCheckboxClick && /*#__PURE__*/React.createElement(BasicHeadCell, {
|
|
@@ -56,6 +56,7 @@ export type TableHeaderProps<T, U> = {
|
|
|
56
56
|
checked?: 'true' | 'false' | 'mixed',
|
|
57
57
|
handleCheckboxClick?: ({value: string, checked: boolean}) => mixed,
|
|
58
58
|
disabled?: boolean,
|
|
59
|
+
stickyHeader?: boolean,
|
|
59
60
|
};
|
|
60
61
|
|
|
61
62
|
const SortIcon = ({
|
|
@@ -113,6 +114,7 @@ export function DefaultTableHeader<T: GenericObject, U: GenericObject>(
|
|
|
113
114
|
handleCheckboxClick,
|
|
114
115
|
checked,
|
|
115
116
|
disabled,
|
|
117
|
+
stickyHeader,
|
|
116
118
|
} = props;
|
|
117
119
|
|
|
118
120
|
const tableHeaderCells = () => (
|
|
@@ -208,7 +210,13 @@ export function DefaultTableHeader<T: GenericObject, U: GenericObject>(
|
|
|
208
210
|
);
|
|
209
211
|
|
|
210
212
|
return (
|
|
211
|
-
<BasicTableHead
|
|
213
|
+
<BasicTableHead
|
|
214
|
+
className={classify(
|
|
215
|
+
css.tableHeaderSortable,
|
|
216
|
+
{[css.stickyHeader]: stickyHeader},
|
|
217
|
+
className,
|
|
218
|
+
)}
|
|
219
|
+
>
|
|
212
220
|
<BasicRow className={css.defaultHeaderRow}>
|
|
213
221
|
{handleCheckboxClick && (
|
|
214
222
|
<BasicHeadCell scope="col">
|
|
@@ -55,7 +55,8 @@ function StaticTable(props) {
|
|
|
55
55
|
emptyText,
|
|
56
56
|
disabled,
|
|
57
57
|
customLoader,
|
|
58
|
-
borderRadius
|
|
58
|
+
borderRadius,
|
|
59
|
+
stickyHeader
|
|
59
60
|
} = props;
|
|
60
61
|
|
|
61
62
|
// this is a fallback and honestly probably doesn't need the
|
|
@@ -86,7 +87,9 @@ function StaticTable(props) {
|
|
|
86
87
|
}
|
|
87
88
|
}, /*#__PURE__*/React.createElement(BasicTable, {
|
|
88
89
|
"data-id": "basic-table",
|
|
89
|
-
className: (0, _classify.classify)(className,
|
|
90
|
+
className: (0, _classify.classify)(className, {
|
|
91
|
+
[_TableModule.default.fullHeightTable]: isLoading || !entries.length && !!emptyText
|
|
92
|
+
}, classNames?.table)
|
|
90
93
|
}, showHeader && /*#__PURE__*/React.createElement(_DefaultTableHeader.DefaultTableHeader, {
|
|
91
94
|
className: (0, _classify.classify)(tableHeaderClassName, classNames?.tableHeader),
|
|
92
95
|
sortable: sortable,
|
|
@@ -96,6 +99,7 @@ function StaticTable(props) {
|
|
|
96
99
|
sortDirection: sortDirection,
|
|
97
100
|
disabled: disabled,
|
|
98
101
|
handleCheckboxClick: handleHeaderCheckboxClick,
|
|
102
|
+
stickyHeader: stickyHeader,
|
|
99
103
|
checked: selectedKeys == null || selectedKeys.length === 0 ? 'false' : selectedKeys.length < entries.length ? 'mixed' : 'true'
|
|
100
104
|
}), /*#__PURE__*/React.createElement(BasicTableBody, {
|
|
101
105
|
className: classNames?.tableBody
|
|
@@ -65,6 +65,7 @@ export function StaticTable<Data: GenericObject, Extras: GenericObject>(props: {
|
|
|
65
65
|
disabled,
|
|
66
66
|
customLoader,
|
|
67
67
|
borderRadius,
|
|
68
|
+
stickyHeader,
|
|
68
69
|
} = props;
|
|
69
70
|
|
|
70
71
|
// this is a fallback and honestly probably doesn't need the
|
|
@@ -102,7 +103,14 @@ export function StaticTable<Data: GenericObject, Extras: GenericObject>(props: {
|
|
|
102
103
|
>
|
|
103
104
|
<BasicTable
|
|
104
105
|
data-id="basic-table"
|
|
105
|
-
className={classify(
|
|
106
|
+
className={classify(
|
|
107
|
+
className,
|
|
108
|
+
{
|
|
109
|
+
[css.fullHeightTable]:
|
|
110
|
+
isLoading || (!entries.length && !!emptyText),
|
|
111
|
+
},
|
|
112
|
+
classNames?.table,
|
|
113
|
+
)}
|
|
106
114
|
>
|
|
107
115
|
{showHeader && (
|
|
108
116
|
<DefaultTableHeader
|
|
@@ -114,6 +122,7 @@ export function StaticTable<Data: GenericObject, Extras: GenericObject>(props: {
|
|
|
114
122
|
sortDirection={sortDirection}
|
|
115
123
|
disabled={disabled}
|
|
116
124
|
handleCheckboxClick={handleHeaderCheckboxClick}
|
|
125
|
+
stickyHeader={stickyHeader}
|
|
117
126
|
checked={
|
|
118
127
|
selectedKeys == null || selectedKeys.length === 0
|
|
119
128
|
? 'false'
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
colorGrayLightest
|
|
12
12
|
) from '../../styles/variables/_color.css';
|
|
13
13
|
@value (spaceNone, spaceXXSmall, spaceXSmall, spaceSmall, spaceMedium) from '../../styles/variables/_space.css';
|
|
14
|
-
@value (sizeFluid, size48, size60, size240, size300) from '../../styles/variables/_size.css';
|
|
15
|
-
@value (borderWidthNone, borderWidthPrimary, borderRadiusNone, borderRadiusMedium) from '../../styles/variables/_border.css';
|
|
14
|
+
@value (sizeFluid, size2, size48, size60, size240, size300) from '../../styles/variables/_size.css';
|
|
15
|
+
@value (borderWidthNone, borderWidthPrimary, borderRadiusNone, borderRadiusMedium, borderWidthSecondary) from '../../styles/variables/_border.css';
|
|
16
16
|
@value (fontLineHeight170) from '../../styles/variables/_font.css';
|
|
17
17
|
@value (elevationCard) from '../../styles/variables/_elevation.css';
|
|
18
18
|
|
|
@@ -40,6 +40,9 @@
|
|
|
40
40
|
table-layout: fixed;
|
|
41
41
|
white-space: nowrap;
|
|
42
42
|
}
|
|
43
|
+
.fullHeightTable {
|
|
44
|
+
height: sizeFluid;
|
|
45
|
+
}
|
|
43
46
|
.defaultTableBody {
|
|
44
47
|
flex-flow: column;
|
|
45
48
|
border-radius: borderRadiusNone borderRadiusNone var(--border-radius)
|
|
@@ -121,7 +124,7 @@
|
|
|
121
124
|
.stickyCell {
|
|
122
125
|
position: sticky;
|
|
123
126
|
left: spaceNone;
|
|
124
|
-
z-index: elevationCard;
|
|
127
|
+
z-index: calc(elevationCard / 2);
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
.stickyHeaderCell {
|
|
@@ -254,3 +257,19 @@
|
|
|
254
257
|
.selectedSortArrow {
|
|
255
258
|
color: colorTextPrimary;
|
|
256
259
|
}
|
|
260
|
+
|
|
261
|
+
.stickyHeader {
|
|
262
|
+
position: sticky;
|
|
263
|
+
top: spaceNone;
|
|
264
|
+
z-index: elevationCard;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.stickyHeader::after {
|
|
268
|
+
content: '';
|
|
269
|
+
position: absolute;
|
|
270
|
+
bottom: calc(borderWidthSecondary * -1);
|
|
271
|
+
left: spaceNone;
|
|
272
|
+
width: sizeFluid;
|
|
273
|
+
height: calc(size2 / 2);
|
|
274
|
+
background: colorBorderPrimary;
|
|
275
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@value (spaceNone, spaceXXSmall, spaceXSmall, spaceSmall, spaceMedium, spaceHalfFluid, spaceNegHalfFluid) from '../../styles/variables/_space.css';
|
|
2
|
-
@value (size2, size22, size48, size60, size240, size300, sizeFluid) from '../../styles/variables/_size.css';
|
|
2
|
+
@value (size2, size22, size48, size50, size60, size240, size300, sizeFluid) from '../../styles/variables/_size.css';
|
|
3
3
|
@value (borderRadiusMedium, borderRadiusNone) from '../../styles/variables/_border.css';
|
|
4
|
-
@value (colorBackgroundTertiary) from '../../styles/variables/_color.css';
|
|
4
|
+
@value (colorBackgroundTertiary, colorFillPrimary) from '../../styles/variables/_color.css';
|
|
5
5
|
@value (elevationMenu) from '../../styles/variables/_elevation.css';
|
|
6
6
|
|
|
7
7
|
.tableBar {
|
|
@@ -30,19 +30,12 @@
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
.tableActionBar {
|
|
33
|
-
composes: borderPrimary from '../../styles/border.module.css';
|
|
34
|
-
composes: boxShadow4 from '../../styles/shadow.module.css';
|
|
35
|
-
position: absolute;
|
|
36
|
-
left: spaceHalfFluid;
|
|
37
|
-
z-index: elevationMenu;
|
|
38
|
-
transform: translateX(spaceNegHalfFluid);
|
|
39
|
-
bottom: calc(spaceMedium * -1);
|
|
40
33
|
display: flex;
|
|
34
|
+
height: size50;
|
|
35
|
+
background-color: colorFillPrimary;
|
|
36
|
+
composes: boxShadow3 from '../../styles/shadow.module.css';
|
|
41
37
|
align-items: center;
|
|
42
|
-
|
|
43
|
-
width:
|
|
44
|
-
padding: spaceSmall;
|
|
45
|
-
background-color: colorBackgroundTertiary;
|
|
46
|
-
border-radius: borderRadiusMedium;
|
|
47
|
-
width: max-content;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
width: sizeFluid;
|
|
40
|
+
padding: spaceXSmall spaceSmall spaceXSmall spaceMedium;
|
|
48
41
|
}
|
|
@@ -21,7 +21,8 @@ const range = (start, end) => {
|
|
|
21
21
|
}, (_, i) => start + i);
|
|
22
22
|
};
|
|
23
23
|
exports.range = range;
|
|
24
|
-
const convertFileSize =
|
|
24
|
+
const convertFileSize = function () {
|
|
25
|
+
let fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
25
26
|
let sizeInBytes = fileSize;
|
|
26
27
|
// Check if the file size is less than 1024
|
|
27
28
|
if (sizeInBytes < 0) {
|
|
@@ -15,7 +15,7 @@ export const range = (start: number, end: number): Array<number> => {
|
|
|
15
15
|
return Array.from({length}, (_, i) => start + i);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export const convertFileSize = (fileSize: number): string => {
|
|
18
|
+
export const convertFileSize = (fileSize: number = 0): string => {
|
|
19
19
|
let sizeInBytes = fileSize;
|
|
20
20
|
// Check if the file size is less than 1024
|
|
21
21
|
if (sizeInBytes < 0) {
|