@itwin/itwinui-react 2.5.0 → 2.6.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/CHANGELOG.md +36 -0
- package/cjs/core/ComboBox/ComboBox.js +4 -1
- package/cjs/core/FileUpload/FileEmptyCard.d.ts +29 -0
- package/cjs/core/FileUpload/FileEmptyCard.js +50 -0
- package/cjs/core/FileUpload/FileUploadCard.d.ts +116 -0
- package/cjs/core/FileUpload/FileUploadCard.js +144 -0
- package/cjs/core/FileUpload/FileUploadTemplate.d.ts +1 -1
- package/cjs/core/FileUpload/FileUploadTemplate.js +4 -3
- package/cjs/core/FileUpload/index.d.ts +4 -0
- package/cjs/core/FileUpload/index.js +5 -1
- package/cjs/core/Header/HeaderLogo.d.ts +8 -11
- package/cjs/core/Header/HeaderLogo.js +7 -12
- package/cjs/core/Table/SubRowExpander.d.ts +1 -0
- package/cjs/core/Table/SubRowExpander.js +4 -2
- package/cjs/core/Table/Table.js +3 -2
- package/cjs/core/Table/TableCell.d.ts +1 -0
- package/cjs/core/Table/TableCell.js +15 -4
- package/cjs/core/Table/TableRowMemoized.d.ts +2 -0
- package/cjs/core/Table/TableRowMemoized.js +4 -3
- package/cjs/core/Table/columns/selectionColumn.d.ts +1 -0
- package/cjs/core/Table/columns/selectionColumn.js +5 -4
- package/cjs/core/Table/hooks/useSelectionCell.d.ts +1 -1
- package/cjs/core/Table/hooks/useSelectionCell.js +5 -2
- package/cjs/core/ToggleSwitch/ToggleSwitch.d.ts +12 -2
- package/cjs/core/ToggleSwitch/ToggleSwitch.js +2 -2
- package/cjs/core/index.d.ts +2 -2
- package/cjs/core/index.js +5 -3
- package/cjs/core/utils/hooks/index.d.ts +1 -0
- package/cjs/core/utils/hooks/index.js +1 -0
- package/cjs/core/utils/hooks/useId.d.ts +5 -0
- package/cjs/core/utils/hooks/useId.js +20 -0
- package/cjs/core/utils/icons/SvgDocument.d.ts +2 -0
- package/cjs/core/utils/icons/SvgDocument.js +36 -0
- package/cjs/core/utils/icons/index.d.ts +1 -0
- package/cjs/core/utils/icons/index.js +1 -0
- package/esm/core/ComboBox/ComboBox.js +4 -1
- package/esm/core/FileUpload/FileEmptyCard.d.ts +29 -0
- package/esm/core/FileUpload/FileEmptyCard.js +44 -0
- package/esm/core/FileUpload/FileUploadCard.d.ts +116 -0
- package/esm/core/FileUpload/FileUploadCard.js +138 -0
- package/esm/core/FileUpload/FileUploadTemplate.d.ts +1 -1
- package/esm/core/FileUpload/FileUploadTemplate.js +4 -3
- package/esm/core/FileUpload/index.d.ts +4 -0
- package/esm/core/FileUpload/index.js +2 -0
- package/esm/core/Header/HeaderLogo.d.ts +8 -11
- package/esm/core/Header/HeaderLogo.js +7 -11
- package/esm/core/Table/SubRowExpander.d.ts +1 -0
- package/esm/core/Table/SubRowExpander.js +4 -2
- package/esm/core/Table/Table.js +3 -2
- package/esm/core/Table/TableCell.d.ts +1 -0
- package/esm/core/Table/TableCell.js +15 -4
- package/esm/core/Table/TableRowMemoized.d.ts +2 -0
- package/esm/core/Table/TableRowMemoized.js +4 -3
- package/esm/core/Table/columns/selectionColumn.d.ts +1 -0
- package/esm/core/Table/columns/selectionColumn.js +5 -4
- package/esm/core/Table/hooks/useSelectionCell.d.ts +1 -1
- package/esm/core/Table/hooks/useSelectionCell.js +5 -2
- package/esm/core/ToggleSwitch/ToggleSwitch.d.ts +12 -2
- package/esm/core/ToggleSwitch/ToggleSwitch.js +2 -2
- package/esm/core/index.d.ts +2 -2
- package/esm/core/index.js +1 -1
- package/esm/core/utils/hooks/index.d.ts +1 -0
- package/esm/core/utils/hooks/index.js +1 -0
- package/esm/core/utils/hooks/useId.d.ts +5 -0
- package/esm/core/utils/hooks/useId.js +14 -0
- package/esm/core/utils/icons/SvgDocument.d.ts +2 -0
- package/esm/core/utils/icons/SvgDocument.js +9 -0
- package/esm/core/utils/icons/index.d.ts +1 -0
- package/esm/core/utils/icons/index.js +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 85af52c6: Add small size toggle switch option using `size` prop as follows: `<ToggleSwitch size='small' />`
|
|
8
|
+
- 1b541699: Added a new FileUploadCard component which serves as a default UI for when a single file is uploaded. This can also be used as a child of FileUpload
|
|
9
|
+
|
|
10
|
+
```jsx
|
|
11
|
+
<FileUploadCard />
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```jsx
|
|
15
|
+
const [files, setFiles] = React.useState<File[]>([]);
|
|
16
|
+
|
|
17
|
+
<FileUpload
|
|
18
|
+
onFileDropped={(files) => {
|
|
19
|
+
setFiles(files);
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
<FileUploadCard files={files} onFilesChange={(files) => setFiles(files)} />
|
|
23
|
+
</FileUpload>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- d2ffe2f2: `ComboBox` will not crash when user provided value is not in Options list.
|
|
29
|
+
- 56f9d524: HeaderLogo now supports `as` prop to allow rendering as a link. It will default to a `button` if `onClick` is passed, and `div` if not.
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
- @itwin/itwinui-css@1.7.0
|
|
32
|
+
|
|
33
|
+
## 2.5.1
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- 9ad85ff2: The different density settings for table will now also affect horizontal spacing.
|
|
38
|
+
|
|
3
39
|
## 2.5.0
|
|
4
40
|
|
|
5
41
|
### Minor Changes
|
|
@@ -83,7 +83,10 @@ const ComboBox = (props) => {
|
|
|
83
83
|
if (isMultipleEnabled(valueProp, multiple)) {
|
|
84
84
|
const indexArray = [];
|
|
85
85
|
valueProp === null || valueProp === void 0 ? void 0 : valueProp.forEach((value) => {
|
|
86
|
-
|
|
86
|
+
const indexToAdd = options.findIndex((option) => option.value === value);
|
|
87
|
+
if (indexToAdd > -1) {
|
|
88
|
+
indexArray.push(indexToAdd);
|
|
89
|
+
}
|
|
87
90
|
});
|
|
88
91
|
return indexArray;
|
|
89
92
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type FileEmptyCardIconProps = React.ComponentPropsWithRef<'span'>;
|
|
3
|
+
export declare type FileEmptyCardTextProps = React.ComponentPropsWithRef<'span'>;
|
|
4
|
+
export declare type FileEmptyCardProps = React.ComponentPropsWithoutRef<'div'>;
|
|
5
|
+
/**
|
|
6
|
+
* Empty file card to be used with the `FileUploadCard` component when no file has been uploaded.
|
|
7
|
+
* @example
|
|
8
|
+
* <FileEmptyCard />
|
|
9
|
+
* <FileEmptyCard>
|
|
10
|
+
* <FileEmptyCard.Icon>
|
|
11
|
+
* <SvgSmileySadVery />
|
|
12
|
+
* </FileEmptyCard.Icon>
|
|
13
|
+
* <FileEmptyCard.Text>
|
|
14
|
+
* <FileUploadCard.InputLabel>
|
|
15
|
+
* Custom Label Text
|
|
16
|
+
* </FileUploadCard.InputLabel>
|
|
17
|
+
* <div>Custom Description Text</div>
|
|
18
|
+
* </FileEmptyCard.Text>
|
|
19
|
+
* </FileEmptyCard>
|
|
20
|
+
*/
|
|
21
|
+
export declare const FileEmptyCard: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>> & {
|
|
22
|
+
Icon: React.ForwardRefExoticComponent<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
|
|
23
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
24
|
+
}, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & React.RefAttributes<HTMLSpanElement>>;
|
|
25
|
+
Text: React.ForwardRefExoticComponent<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
|
|
26
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
27
|
+
}, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & React.RefAttributes<HTMLSpanElement>>;
|
|
28
|
+
};
|
|
29
|
+
export default FileEmptyCard;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FileEmptyCard = void 0;
|
|
7
|
+
/*---------------------------------------------------------------------------------------------
|
|
8
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
9
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
10
|
+
*--------------------------------------------------------------------------------------------*/
|
|
11
|
+
const react_1 = __importDefault(require("react"));
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
14
|
+
const FileUploadCard_1 = __importDefault(require("./FileUploadCard"));
|
|
15
|
+
const FileEmptyCardIcon = react_1.default.forwardRef((props, ref) => {
|
|
16
|
+
const { children, className, ...rest } = props;
|
|
17
|
+
return (react_1.default.createElement("span", { className: (0, classnames_1.default)('iui-file-card-empty-icon', className), ref: ref, ...rest }, children !== null && children !== void 0 ? children : react_1.default.createElement(utils_1.SvgUpload, null)));
|
|
18
|
+
});
|
|
19
|
+
const FileEmptyCardText = react_1.default.forwardRef((props, ref) => {
|
|
20
|
+
const { children, className, ...rest } = props;
|
|
21
|
+
return (react_1.default.createElement("span", { className: (0, classnames_1.default)('iui-file-card-empty-action', className), ref: ref, ...rest }, children));
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Empty file card to be used with the `FileUploadCard` component when no file has been uploaded.
|
|
25
|
+
* @example
|
|
26
|
+
* <FileEmptyCard />
|
|
27
|
+
* <FileEmptyCard>
|
|
28
|
+
* <FileEmptyCard.Icon>
|
|
29
|
+
* <SvgSmileySadVery />
|
|
30
|
+
* </FileEmptyCard.Icon>
|
|
31
|
+
* <FileEmptyCard.Text>
|
|
32
|
+
* <FileUploadCard.InputLabel>
|
|
33
|
+
* Custom Label Text
|
|
34
|
+
* </FileUploadCard.InputLabel>
|
|
35
|
+
* <div>Custom Description Text</div>
|
|
36
|
+
* </FileEmptyCard.Text>
|
|
37
|
+
* </FileEmptyCard>
|
|
38
|
+
*/
|
|
39
|
+
exports.FileEmptyCard = Object.assign(react_1.default.forwardRef((props, ref) => {
|
|
40
|
+
const { children, className, ...rest } = props;
|
|
41
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)('iui-file-card-empty', className), ref: ref, ...rest }, children !== null && children !== void 0 ? children : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
42
|
+
react_1.default.createElement(exports.FileEmptyCard.Icon, null),
|
|
43
|
+
react_1.default.createElement(exports.FileEmptyCard.Text, null,
|
|
44
|
+
react_1.default.createElement(FileUploadCard_1.default.InputLabel, null, "Choose a file"),
|
|
45
|
+
react_1.default.createElement("div", null, "to upload."))))));
|
|
46
|
+
}), {
|
|
47
|
+
Icon: FileEmptyCardIcon,
|
|
48
|
+
Text: FileEmptyCardText,
|
|
49
|
+
});
|
|
50
|
+
exports.default = exports.FileEmptyCard;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type FileUploadCardIconProps = React.ComponentPropsWithRef<'span'>;
|
|
3
|
+
export declare type FileUploadCardInfoProps = React.ComponentPropsWithRef<'span'>;
|
|
4
|
+
export declare type FileUploadCardTitleProps = React.ComponentPropsWithRef<'span'>;
|
|
5
|
+
export declare type FileUploadCardDescriptionProps = React.ComponentPropsWithRef<'span'>;
|
|
6
|
+
export declare type FileUploadCardActionProps = React.ComponentPropsWithRef<'div'>;
|
|
7
|
+
export declare type FileUploadCardInputLabelProps = React.ComponentPropsWithRef<'label'>;
|
|
8
|
+
export declare type FileUploadCardInputProps = React.ComponentPropsWithRef<'input'>;
|
|
9
|
+
export declare type FileUploadCardProps = {
|
|
10
|
+
/**
|
|
11
|
+
* Files to pass (only needed when passing a custom action)
|
|
12
|
+
*/
|
|
13
|
+
files?: File[];
|
|
14
|
+
/**
|
|
15
|
+
* Callback fired when files has changed (only needed passing custom action)
|
|
16
|
+
*/
|
|
17
|
+
onFilesChange?: (files: File[]) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Node that is shown when there is no file uploaded
|
|
20
|
+
* Either pass `FileEmptyCard` (for default state) or a different component to show
|
|
21
|
+
* @default <FileEmptyCard />
|
|
22
|
+
*/
|
|
23
|
+
emptyCard?: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Input node
|
|
26
|
+
* @default <FileUploadCard.Input />
|
|
27
|
+
*/
|
|
28
|
+
input?: React.ReactNode;
|
|
29
|
+
} & React.ComponentPropsWithoutRef<'div'>;
|
|
30
|
+
/**
|
|
31
|
+
* Default card to be used with the `FileUpload` wrapper component for single-file uploading.
|
|
32
|
+
* @example
|
|
33
|
+
* <FileUploadCard />
|
|
34
|
+
* <FileUploadCard files={files} onFilesChange={(files) => setFiles(files)}>
|
|
35
|
+
* <FileUploadCard.Icon>
|
|
36
|
+
* <SvgSmileyHappyVery />
|
|
37
|
+
* </FileUploadCard.Icon>
|
|
38
|
+
* <FileUploadCard.Info>
|
|
39
|
+
* <FileUploadCard.Title>Custom File Name</FileUploadCard.Title>
|
|
40
|
+
* <FileUploadCard.Description>
|
|
41
|
+
* Custom File Description
|
|
42
|
+
* </FileUploadCard.Description>
|
|
43
|
+
* </FileUploadCard.Info>
|
|
44
|
+
* <FileUploadCard.Action>
|
|
45
|
+
* <Button
|
|
46
|
+
* onClick={() => {
|
|
47
|
+
* setFiles([]);
|
|
48
|
+
* }}
|
|
49
|
+
* />
|
|
50
|
+
* <FileUploadCard.Input name={fileInputId} ref={inputRef} />
|
|
51
|
+
* </FileUploadCard.Action>
|
|
52
|
+
* </FileUploadCard>
|
|
53
|
+
*/
|
|
54
|
+
export declare const FileUploadCard: React.ForwardRefExoticComponent<{
|
|
55
|
+
/**
|
|
56
|
+
* Files to pass (only needed when passing a custom action)
|
|
57
|
+
*/
|
|
58
|
+
files?: File[] | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Callback fired when files has changed (only needed passing custom action)
|
|
61
|
+
*/
|
|
62
|
+
onFilesChange?: ((files: File[]) => void) | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Node that is shown when there is no file uploaded
|
|
65
|
+
* Either pass `FileEmptyCard` (for default state) or a different component to show
|
|
66
|
+
* @default <FileEmptyCard />
|
|
67
|
+
*/
|
|
68
|
+
emptyCard?: React.ReactNode;
|
|
69
|
+
/**
|
|
70
|
+
* Input node
|
|
71
|
+
* @default <FileUploadCard.Input />
|
|
72
|
+
*/
|
|
73
|
+
input?: React.ReactNode;
|
|
74
|
+
} & Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>> & {
|
|
75
|
+
Icon: React.ForwardRefExoticComponent<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
|
|
76
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
77
|
+
}, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & React.RefAttributes<HTMLSpanElement>>;
|
|
78
|
+
Info: React.ForwardRefExoticComponent<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
|
|
79
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
80
|
+
}, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & React.RefAttributes<HTMLSpanElement>>;
|
|
81
|
+
Title: React.ForwardRefExoticComponent<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
|
|
82
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
83
|
+
}, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & React.RefAttributes<HTMLSpanElement>>;
|
|
84
|
+
Description: React.ForwardRefExoticComponent<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
|
|
85
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
86
|
+
}, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & React.RefAttributes<HTMLSpanElement>>;
|
|
87
|
+
Action: React.ForwardRefExoticComponent<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
88
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
89
|
+
}, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
|
|
90
|
+
InputLabel: React.ForwardRefExoticComponent<Pick<Pick<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "key" | keyof React.LabelHTMLAttributes<HTMLLabelElement>> & {
|
|
91
|
+
ref?: ((instance: HTMLLabelElement | null) => void) | React.RefObject<HTMLLabelElement> | null | undefined;
|
|
92
|
+
}, "key" | keyof React.LabelHTMLAttributes<HTMLLabelElement>> & React.RefAttributes<HTMLLabelElement>>;
|
|
93
|
+
Input: React.ForwardRefExoticComponent<Pick<Pick<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "key" | keyof React.InputHTMLAttributes<HTMLInputElement>> & {
|
|
94
|
+
ref?: ((instance: HTMLInputElement | null) => void) | React.RefObject<HTMLInputElement> | null | undefined;
|
|
95
|
+
}, "key" | keyof React.InputHTMLAttributes<HTMLInputElement>> & React.RefAttributes<HTMLInputElement>>;
|
|
96
|
+
};
|
|
97
|
+
export default FileUploadCard;
|
|
98
|
+
export declare const FileUploadCardContext: React.Context<{
|
|
99
|
+
/**
|
|
100
|
+
* Files to pass
|
|
101
|
+
*/
|
|
102
|
+
files: File[];
|
|
103
|
+
/**
|
|
104
|
+
* Callback fired when files have changed
|
|
105
|
+
*/
|
|
106
|
+
onFilesChange?: ((files: File[]) => void) | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Sets the state of the files within FileUploadCard
|
|
109
|
+
*/
|
|
110
|
+
setInternalFiles: (files: File[]) => void;
|
|
111
|
+
/**
|
|
112
|
+
* Id to pass to input
|
|
113
|
+
*/
|
|
114
|
+
inputId?: string | undefined;
|
|
115
|
+
setInputId: (inputId: string) => void;
|
|
116
|
+
} | undefined>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FileUploadCardContext = exports.FileUploadCard = void 0;
|
|
7
|
+
/*---------------------------------------------------------------------------------------------
|
|
8
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
9
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
10
|
+
*--------------------------------------------------------------------------------------------*/
|
|
11
|
+
const react_1 = __importDefault(require("react"));
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
14
|
+
const FileEmptyCard_1 = require("./FileEmptyCard");
|
|
15
|
+
const utils_2 = require("../utils");
|
|
16
|
+
const toBytes = (bytes) => {
|
|
17
|
+
const units = [' bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
18
|
+
let i = 0;
|
|
19
|
+
while (bytes >= 1024 && ++i) {
|
|
20
|
+
bytes = bytes / 1024;
|
|
21
|
+
}
|
|
22
|
+
return bytes.toFixed(bytes < 10 && i > 0 ? 2 : 0) + units[i];
|
|
23
|
+
};
|
|
24
|
+
const toDate = (dateNumber) => {
|
|
25
|
+
const date = new Date(dateNumber);
|
|
26
|
+
return date.toDateString() + ' ' + date.toLocaleTimeString();
|
|
27
|
+
};
|
|
28
|
+
const FileUploadCardIcon = react_1.default.forwardRef((props, ref) => {
|
|
29
|
+
const { children, className, ...rest } = props;
|
|
30
|
+
return (react_1.default.createElement("span", { className: (0, classnames_1.default)('iui-file-card-icon', className), ref: ref, ...rest }, children !== null && children !== void 0 ? children : react_1.default.createElement(utils_1.SvgDocument, null)));
|
|
31
|
+
});
|
|
32
|
+
const FileUploadCardInfo = react_1.default.forwardRef((props, ref) => {
|
|
33
|
+
const { children, className, ...rest } = props;
|
|
34
|
+
return (react_1.default.createElement("span", { className: (0, classnames_1.default)('iui-file-card-text', className), ref: ref, ...rest }, children));
|
|
35
|
+
});
|
|
36
|
+
const FileUploadCardTitle = react_1.default.forwardRef((props, ref) => {
|
|
37
|
+
const { children, className, ...rest } = props;
|
|
38
|
+
const { files } = (0, utils_1.useSafeContext)(exports.FileUploadCardContext);
|
|
39
|
+
const title = files.length > 1 ? files.length + ' files selected' : files[0].name;
|
|
40
|
+
return (react_1.default.createElement("span", { className: (0, classnames_1.default)('iui-file-card-title', className), ref: ref, ...rest }, children !== null && children !== void 0 ? children : title));
|
|
41
|
+
});
|
|
42
|
+
const FileUploadCardDescription = react_1.default.forwardRef((props, ref) => {
|
|
43
|
+
const { children, className, ...rest } = props;
|
|
44
|
+
const { files } = (0, utils_1.useSafeContext)(exports.FileUploadCardContext);
|
|
45
|
+
let description = files.length > 1
|
|
46
|
+
? files[0].name + ', ' + files[1].name
|
|
47
|
+
: toBytes(files[0].size) + ' ' + toDate(files[0].lastModified);
|
|
48
|
+
if (files.length > 2) {
|
|
49
|
+
description += ', and ' + (files.length - 2) + ' others';
|
|
50
|
+
}
|
|
51
|
+
return (react_1.default.createElement("span", { className: (0, classnames_1.default)('iui-file-card-description', className), ref: ref, ...rest }, children !== null && children !== void 0 ? children : description));
|
|
52
|
+
});
|
|
53
|
+
const FileUploadCardAction = react_1.default.forwardRef((props, ref) => {
|
|
54
|
+
const { children, className, ...rest } = props;
|
|
55
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)('iui-file-card-action', className), ref: ref, ...rest }, children));
|
|
56
|
+
});
|
|
57
|
+
const FileUploadCardInputLabel = react_1.default.forwardRef((props, ref) => {
|
|
58
|
+
const { children, className, ...rest } = props;
|
|
59
|
+
const { inputId } = (0, utils_1.useSafeContext)(exports.FileUploadCardContext);
|
|
60
|
+
return (react_1.default.createElement("label", { className: (0, classnames_1.default)('iui-anchor', className), ref: ref, htmlFor: inputId, ...rest }, children));
|
|
61
|
+
});
|
|
62
|
+
const FileUploadCardInput = react_1.default.forwardRef((props, ref) => {
|
|
63
|
+
const { children, className, onChange, id, ...rest } = props;
|
|
64
|
+
const { files, onFilesChange, setInternalFiles, inputId, setInputId } = (0, utils_1.useSafeContext)(exports.FileUploadCardContext);
|
|
65
|
+
const setNativeFilesRef = react_1.default.useCallback((node) => {
|
|
66
|
+
var _a;
|
|
67
|
+
if (!node || !((_a = (0, utils_1.getWindow)()) === null || _a === void 0 ? void 0 : _a.DataTransfer)) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const dataTransfer = new DataTransfer();
|
|
71
|
+
dataTransfer.items.clear();
|
|
72
|
+
Array.from(files).forEach((file) => dataTransfer.items.add(file));
|
|
73
|
+
node.files = dataTransfer.files;
|
|
74
|
+
}, [files]);
|
|
75
|
+
const refs = (0, utils_1.useMergedRefs)(ref, setNativeFilesRef);
|
|
76
|
+
if (id && id !== inputId) {
|
|
77
|
+
setInputId(id);
|
|
78
|
+
}
|
|
79
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
80
|
+
react_1.default.createElement("input", { className: (0, classnames_1.default)('iui-visually-hidden', className), type: 'file', onChange: (e) => {
|
|
81
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
82
|
+
if (!e.isDefaultPrevented()) {
|
|
83
|
+
const _files = Array.from(e.currentTarget.files || []);
|
|
84
|
+
onFilesChange === null || onFilesChange === void 0 ? void 0 : onFilesChange(_files);
|
|
85
|
+
setInternalFiles(_files);
|
|
86
|
+
}
|
|
87
|
+
}, ref: refs, id: id !== null && id !== void 0 ? id : inputId, ...rest }),
|
|
88
|
+
children));
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* Default card to be used with the `FileUpload` wrapper component for single-file uploading.
|
|
92
|
+
* @example
|
|
93
|
+
* <FileUploadCard />
|
|
94
|
+
* <FileUploadCard files={files} onFilesChange={(files) => setFiles(files)}>
|
|
95
|
+
* <FileUploadCard.Icon>
|
|
96
|
+
* <SvgSmileyHappyVery />
|
|
97
|
+
* </FileUploadCard.Icon>
|
|
98
|
+
* <FileUploadCard.Info>
|
|
99
|
+
* <FileUploadCard.Title>Custom File Name</FileUploadCard.Title>
|
|
100
|
+
* <FileUploadCard.Description>
|
|
101
|
+
* Custom File Description
|
|
102
|
+
* </FileUploadCard.Description>
|
|
103
|
+
* </FileUploadCard.Info>
|
|
104
|
+
* <FileUploadCard.Action>
|
|
105
|
+
* <Button
|
|
106
|
+
* onClick={() => {
|
|
107
|
+
* setFiles([]);
|
|
108
|
+
* }}
|
|
109
|
+
* />
|
|
110
|
+
* <FileUploadCard.Input name={fileInputId} ref={inputRef} />
|
|
111
|
+
* </FileUploadCard.Action>
|
|
112
|
+
* </FileUploadCard>
|
|
113
|
+
*/
|
|
114
|
+
exports.FileUploadCard = Object.assign(react_1.default.forwardRef((props, ref) => {
|
|
115
|
+
var _a;
|
|
116
|
+
const { className, children, files: filesProp, onFilesChange, emptyCard = react_1.default.createElement(FileEmptyCard_1.FileEmptyCard, null), input, ...rest } = props;
|
|
117
|
+
const [internalFiles, setInternalFiles] = react_1.default.useState();
|
|
118
|
+
const [inputId, setInputId] = react_1.default.useState((0, utils_2.useId)());
|
|
119
|
+
const files = (_a = filesProp !== null && filesProp !== void 0 ? filesProp : internalFiles) !== null && _a !== void 0 ? _a : [];
|
|
120
|
+
return (react_1.default.createElement(exports.FileUploadCardContext.Provider, { value: {
|
|
121
|
+
files,
|
|
122
|
+
onFilesChange,
|
|
123
|
+
setInternalFiles,
|
|
124
|
+
inputId,
|
|
125
|
+
setInputId,
|
|
126
|
+
} },
|
|
127
|
+
(files === null || files === void 0 ? void 0 : files.length) ? (react_1.default.createElement("div", { className: (0, classnames_1.default)('iui-file-card', className), ref: ref, ...rest }, children !== null && children !== void 0 ? children : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
128
|
+
react_1.default.createElement(exports.FileUploadCard.Icon, null),
|
|
129
|
+
react_1.default.createElement(exports.FileUploadCard.Info, null,
|
|
130
|
+
react_1.default.createElement(exports.FileUploadCard.Title, null),
|
|
131
|
+
react_1.default.createElement(exports.FileUploadCard.Description, null)),
|
|
132
|
+
react_1.default.createElement(exports.FileUploadCard.Action, null,
|
|
133
|
+
react_1.default.createElement(exports.FileUploadCard.InputLabel, null, "Replace")))))) : (emptyCard), input !== null && input !== void 0 ? input : react_1.default.createElement(exports.FileUploadCard.Input, null)));
|
|
134
|
+
}), {
|
|
135
|
+
Icon: FileUploadCardIcon,
|
|
136
|
+
Info: FileUploadCardInfo,
|
|
137
|
+
Title: FileUploadCardTitle,
|
|
138
|
+
Description: FileUploadCardDescription,
|
|
139
|
+
Action: FileUploadCardAction,
|
|
140
|
+
InputLabel: FileUploadCardInputLabel,
|
|
141
|
+
Input: FileUploadCardInput,
|
|
142
|
+
});
|
|
143
|
+
exports.default = exports.FileUploadCard;
|
|
144
|
+
exports.FileUploadCardContext = react_1.default.createContext(undefined);
|
|
@@ -30,7 +30,7 @@ export declare type FileUploadTemplateProps = {
|
|
|
30
30
|
* Optional children appended to the template.
|
|
31
31
|
*/
|
|
32
32
|
children?: React.ReactNode;
|
|
33
|
-
}
|
|
33
|
+
} & React.ComponentProps<'div'>;
|
|
34
34
|
/**
|
|
35
35
|
* Default template to be used with the `FileUpload` wrapper component.
|
|
36
36
|
* Contains a hidden input with styled labels (customizable).
|
|
@@ -9,6 +9,7 @@ exports.FileUploadTemplate = void 0;
|
|
|
9
9
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
10
10
|
*--------------------------------------------------------------------------------------------*/
|
|
11
11
|
const react_1 = __importDefault(require("react"));
|
|
12
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
12
13
|
const utils_1 = require("../utils");
|
|
13
14
|
require("@itwin/itwinui-css/css/file-upload.css");
|
|
14
15
|
/**
|
|
@@ -18,10 +19,10 @@ require("@itwin/itwinui-css/css/file-upload.css");
|
|
|
18
19
|
* <FileUploadTemplate onChange={(e) => console.log(e.target.files)} />
|
|
19
20
|
*/
|
|
20
21
|
const FileUploadTemplate = (props) => {
|
|
21
|
-
const { onChange, acceptMultiple = true, acceptType, label = 'Choose a file', subtitle = 'or drag & drop it here.', children, } = props;
|
|
22
|
+
const { onChange, acceptMultiple = true, acceptType, label = 'Choose a file', subtitle = 'or drag & drop it here.', children, className, ...rest } = props;
|
|
22
23
|
(0, utils_1.useTheme)();
|
|
23
|
-
return (react_1.default.createElement(
|
|
24
|
-
react_1.default.createElement(utils_1.SvgUpload, { className: 'iui-icon', "aria-hidden": true }),
|
|
24
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)('iui-file-upload-template', className), ...rest },
|
|
25
|
+
react_1.default.createElement(utils_1.SvgUpload, { className: 'iui-template-icon', "aria-hidden": true }),
|
|
25
26
|
react_1.default.createElement("div", { className: 'iui-template-text' },
|
|
26
27
|
react_1.default.createElement("label", { className: 'iui-anchor' },
|
|
27
28
|
react_1.default.createElement("input", { className: 'iui-browse-input', type: 'file', onChange: onChange, multiple: acceptMultiple, accept: acceptType }),
|
|
@@ -4,3 +4,7 @@ declare const _default: "./FileUpload";
|
|
|
4
4
|
export default _default;
|
|
5
5
|
export { FileUploadTemplate } from './FileUploadTemplate';
|
|
6
6
|
export type { FileUploadTemplateProps } from './FileUploadTemplate';
|
|
7
|
+
export { FileUploadCard } from './FileUploadCard';
|
|
8
|
+
export type { FileUploadCardProps, FileUploadCardIconProps, FileUploadCardInfoProps, FileUploadCardTitleProps, FileUploadCardDescriptionProps, FileUploadCardActionProps, FileUploadCardInputLabelProps, FileUploadCardInputProps, } from './FileUploadCard';
|
|
9
|
+
export { FileEmptyCard } from './FileEmptyCard';
|
|
10
|
+
export type { FileEmptyCardProps, FileEmptyCardIconProps, FileEmptyCardTextProps, } from './FileEmptyCard';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileUploadTemplate = exports.FileUpload = void 0;
|
|
3
|
+
exports.FileEmptyCard = exports.FileUploadCard = exports.FileUploadTemplate = exports.FileUpload = void 0;
|
|
4
4
|
/*---------------------------------------------------------------------------------------------
|
|
5
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -10,3 +10,7 @@ Object.defineProperty(exports, "FileUpload", { enumerable: true, get: function (
|
|
|
10
10
|
exports.default = './FileUpload';
|
|
11
11
|
var FileUploadTemplate_1 = require("./FileUploadTemplate");
|
|
12
12
|
Object.defineProperty(exports, "FileUploadTemplate", { enumerable: true, get: function () { return FileUploadTemplate_1.FileUploadTemplate; } });
|
|
13
|
+
var FileUploadCard_1 = require("./FileUploadCard");
|
|
14
|
+
Object.defineProperty(exports, "FileUploadCard", { enumerable: true, get: function () { return FileUploadCard_1.FileUploadCard; } });
|
|
15
|
+
var FileEmptyCard_1 = require("./FileEmptyCard");
|
|
16
|
+
Object.defineProperty(exports, "FileEmptyCard", { enumerable: true, get: function () { return FileEmptyCard_1.FileEmptyCard; } });
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { PolymorphicForwardRefComponent, PolymorphicComponentProps } from '../utils';
|
|
3
3
|
import '@itwin/itwinui-css/css/header.css';
|
|
4
|
-
|
|
4
|
+
declare type HeaderLogoOwnProps = {
|
|
5
5
|
/**
|
|
6
6
|
* Logo shown before the main content.
|
|
7
7
|
*/
|
|
8
8
|
logo: JSX.Element;
|
|
9
9
|
/**
|
|
10
10
|
* Click event handler.
|
|
11
|
-
*
|
|
11
|
+
* If passed, the component will be rendered as a `<button>` rather than `<div>`.
|
|
12
12
|
*/
|
|
13
|
-
onClick?: () => void;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
children?: React.ReactNode;
|
|
18
|
-
} & CommonProps;
|
|
13
|
+
onClick?: (e: unknown) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare type HeaderLogoProps = PolymorphicComponentProps<'div', HeaderLogoOwnProps>;
|
|
19
16
|
/**
|
|
20
17
|
* Header Title section
|
|
21
18
|
* @example
|
|
@@ -24,5 +21,5 @@ export declare type HeaderLogoProps = {
|
|
|
24
21
|
* <HeaderLogo logo={<img src='image.png' />} />
|
|
25
22
|
* <HeaderLogo logo={<img src='data:image/png;base64,...' />}>Downloaded Image</HeaderLogo>
|
|
26
23
|
*/
|
|
27
|
-
export declare const HeaderLogo:
|
|
24
|
+
export declare const HeaderLogo: PolymorphicForwardRefComponent<"div", HeaderLogoOwnProps>;
|
|
28
25
|
export default HeaderLogo;
|
|
@@ -20,23 +20,18 @@ require("@itwin/itwinui-css/css/header.css");
|
|
|
20
20
|
* <HeaderLogo logo={<img src='image.png' />} />
|
|
21
21
|
* <HeaderLogo logo={<img src='data:image/png;base64,...' />}>Downloaded Image</HeaderLogo>
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
|
-
const { className, children, logo, onClick, ...rest } = props;
|
|
25
|
-
const keyDownHandler = (e) => {
|
|
26
|
-
if (onClick &&
|
|
27
|
-
(e.key === 'Enter' || e.key === ' ' || e.key === 'Spacebar')) {
|
|
28
|
-
e.preventDefault();
|
|
29
|
-
onClick();
|
|
30
|
-
}
|
|
31
|
-
};
|
|
23
|
+
exports.HeaderLogo = react_1.default.forwardRef((props, ref) => {
|
|
24
|
+
const { className, children, logo, onClick, as: Element = !!onClick ? 'button' : 'div', ...rest } = props;
|
|
32
25
|
(0, utils_1.useTheme)();
|
|
33
|
-
return (react_1.default.createElement(
|
|
26
|
+
return (react_1.default.createElement(Element, { className: (0, classnames_1.default)('iui-header-brand', className), onClick: onClick,
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- TS complains here but it's ok; it is an implementation detail
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
ref: ref, ...rest },
|
|
34
30
|
react_1.default.isValidElement(logo)
|
|
35
31
|
? react_1.default.cloneElement(logo, {
|
|
36
32
|
className: (0, classnames_1.default)('iui-header-brand-icon', logo.props.className),
|
|
37
33
|
})
|
|
38
34
|
: undefined,
|
|
39
35
|
children && react_1.default.createElement("span", { className: 'iui-header-brand-label' }, children)));
|
|
40
|
-
};
|
|
41
|
-
exports.HeaderLogo = HeaderLogo;
|
|
36
|
+
});
|
|
42
37
|
exports.default = exports.HeaderLogo;
|
|
@@ -5,6 +5,7 @@ export declare type SubRowExpanderProps<T extends Record<string, unknown>> = {
|
|
|
5
5
|
expanderCell?: (cellProps: CellProps<T>) => React.ReactNode;
|
|
6
6
|
isDisabled: boolean;
|
|
7
7
|
cellProps: CellProps<T>;
|
|
8
|
+
density?: 'default' | 'condensed' | 'extra-condensed';
|
|
8
9
|
};
|
|
9
10
|
export declare const SubRowExpander: <T extends Record<string, unknown>>(props: SubRowExpanderProps<T>) => JSX.Element;
|
|
10
11
|
export default SubRowExpander;
|
|
@@ -12,8 +12,10 @@ const react_1 = __importDefault(require("react"));
|
|
|
12
12
|
const utils_1 = require("../utils");
|
|
13
13
|
const Buttons_1 = require("../Buttons");
|
|
14
14
|
const SubRowExpander = (props) => {
|
|
15
|
-
const { cell, isDisabled, cellProps, expanderCell } = props;
|
|
16
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, expanderCell ? (expanderCell(cellProps)) : (react_1.default.createElement(Buttons_1.IconButton, { style: {
|
|
15
|
+
const { cell, isDisabled, cellProps, expanderCell, density } = props;
|
|
16
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, expanderCell ? (expanderCell(cellProps)) : (react_1.default.createElement(Buttons_1.IconButton, { style: {
|
|
17
|
+
marginRight: density === 'default' || density === undefined ? 8 : 4,
|
|
18
|
+
}, className: 'iui-table-row-expander', styleType: 'borderless', size: 'small', onClick: (e) => {
|
|
17
19
|
e.stopPropagation();
|
|
18
20
|
cell.row.toggleRowExpanded();
|
|
19
21
|
}, disabled: isDisabled }, react_1.default.createElement(utils_1.SvgChevronRight, { style: {
|
package/cjs/core/Table/Table.js
CHANGED
|
@@ -204,7 +204,7 @@ const Table = (props) => {
|
|
|
204
204
|
getSubRows,
|
|
205
205
|
initialState: { pageSize, ...props.initialState },
|
|
206
206
|
columnResizeMode,
|
|
207
|
-
}, react_table_1.useFlexLayout, (0, hooks_1.useResizeColumns)(ownerDocument), react_table_1.useFilters, (0, hooks_1.useSubRowFiltering)(hasAnySubRows), react_table_1.useGlobalFilter, react_table_1.useSortBy, react_table_1.useExpanded, react_table_1.usePagination, react_table_1.useRowSelect, hooks_1.useSubRowSelection, (0, hooks_1.useExpanderCell)(subComponent, expanderCell, isRowDisabled), (0, hooks_1.useSelectionCell)(isSelectable, selectionMode, isRowDisabled), react_table_1.useColumnOrder, (0, hooks_1.useColumnDragAndDrop)(enableColumnReordering), hooks_1.useStickyColumns);
|
|
207
|
+
}, react_table_1.useFlexLayout, (0, hooks_1.useResizeColumns)(ownerDocument), react_table_1.useFilters, (0, hooks_1.useSubRowFiltering)(hasAnySubRows), react_table_1.useGlobalFilter, react_table_1.useSortBy, react_table_1.useExpanded, react_table_1.usePagination, react_table_1.useRowSelect, hooks_1.useSubRowSelection, (0, hooks_1.useExpanderCell)(subComponent, expanderCell, isRowDisabled), (0, hooks_1.useSelectionCell)(isSelectable, selectionMode, isRowDisabled, density), react_table_1.useColumnOrder, (0, hooks_1.useColumnDragAndDrop)(enableColumnReordering), hooks_1.useStickyColumns);
|
|
208
208
|
const { getTableProps, rows, headerGroups: _headerGroups, getTableBodyProps, prepareRow, state, allColumns, dispatch, page, gotoPage, setPageSize, flatHeaders, visibleColumns, setGlobalFilter, } = instance;
|
|
209
209
|
let headerGroups = _headerGroups;
|
|
210
210
|
if (columns.length === 1 && 'columns' in columns[0]) {
|
|
@@ -342,7 +342,7 @@ const Table = (props) => {
|
|
|
342
342
|
const getPreparedRow = react_1.default.useCallback((index) => {
|
|
343
343
|
const row = page[index];
|
|
344
344
|
prepareRow(row);
|
|
345
|
-
return (react_1.default.createElement(TableRowMemoized_1.TableRowMemoized, { row: row, rowProps: rowProps, isLast: index === page.length - 1, onRowInViewport: onRowInViewportRef, onBottomReached: onBottomReachedRef, intersectionMargin: intersectionMargin, state: state, key: row.getRowProps().key, onClick: onRowClickHandler, subComponent: subComponent, isDisabled: !!(isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original)), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell, bodyRef: bodyRef.current, tableRowRef: enableVirtualization ? undefined : tableRowRef(row) }));
|
|
345
|
+
return (react_1.default.createElement(TableRowMemoized_1.TableRowMemoized, { row: row, rowProps: rowProps, isLast: index === page.length - 1, onRowInViewport: onRowInViewportRef, onBottomReached: onBottomReachedRef, intersectionMargin: intersectionMargin, state: state, key: row.getRowProps().key, onClick: onRowClickHandler, subComponent: subComponent, isDisabled: !!(isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original)), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell, bodyRef: bodyRef.current, tableRowRef: enableVirtualization ? undefined : tableRowRef(row), density: density }));
|
|
346
346
|
}, [
|
|
347
347
|
page,
|
|
348
348
|
prepareRow,
|
|
@@ -357,6 +357,7 @@ const Table = (props) => {
|
|
|
357
357
|
expanderCell,
|
|
358
358
|
enableVirtualization,
|
|
359
359
|
tableRowRef,
|
|
360
|
+
density,
|
|
360
361
|
]);
|
|
361
362
|
const virtualizedItemRenderer = react_1.default.useCallback((index) => getPreparedRow(index), [getPreparedRow]);
|
|
362
363
|
const updateStickyState = () => {
|
|
@@ -7,6 +7,7 @@ export declare type TableCellProps<T extends Record<string, unknown>> = {
|
|
|
7
7
|
tableHasSubRows: boolean;
|
|
8
8
|
tableInstance: TableInstance<T>;
|
|
9
9
|
expanderCell?: (cellProps: CellProps<T>) => React.ReactNode;
|
|
10
|
+
density?: 'default' | 'condensed' | 'extra-condensed';
|
|
10
11
|
};
|
|
11
12
|
export declare const TableCell: <T extends Record<string, unknown>>(props: TableCellProps<T>) => JSX.Element;
|
|
12
13
|
export default TableCell;
|
|
@@ -15,7 +15,7 @@ const SubRowExpander_1 = require("./SubRowExpander");
|
|
|
15
15
|
const columns_1 = require("./columns");
|
|
16
16
|
const cells_1 = require("./cells");
|
|
17
17
|
const TableCell = (props) => {
|
|
18
|
-
const { cell, cellIndex, isDisabled, tableHasSubRows, tableInstance, expanderCell, } = props;
|
|
18
|
+
const { cell, cellIndex, isDisabled, tableHasSubRows, tableInstance, expanderCell, density, } = props;
|
|
19
19
|
const hasSubRowExpander = cellIndex ===
|
|
20
20
|
cell.row.cells.findIndex((c) => c.column.id !== columns_1.SELECTION_CELL_ID);
|
|
21
21
|
const getSubRowStyle = () => {
|
|
@@ -23,9 +23,20 @@ const TableCell = (props) => {
|
|
|
23
23
|
return undefined;
|
|
24
24
|
}
|
|
25
25
|
// If it doesn't have sub-rows then shift by another level to align with expandable rows on the same depth
|
|
26
|
-
|
|
26
|
+
const dynamicMargin = cell.row.depth + (cell.row.canExpand ? 0 : 1);
|
|
27
|
+
let cellPadding = 16;
|
|
28
|
+
let expanderMargin = 8;
|
|
29
|
+
if (density === 'condensed') {
|
|
30
|
+
cellPadding = 12;
|
|
31
|
+
expanderMargin = 4;
|
|
32
|
+
}
|
|
33
|
+
else if (density === 'extra-condensed') {
|
|
34
|
+
cellPadding = 8;
|
|
35
|
+
expanderMargin = 4;
|
|
36
|
+
}
|
|
37
|
+
const multiplier = 26 + expanderMargin; // 26 = expander width
|
|
27
38
|
return {
|
|
28
|
-
paddingLeft:
|
|
39
|
+
paddingLeft: cellPadding + dynamicMargin * multiplier,
|
|
29
40
|
};
|
|
30
41
|
};
|
|
31
42
|
const cellElementProps = cell.getCellProps({
|
|
@@ -43,7 +54,7 @@ const TableCell = (props) => {
|
|
|
43
54
|
...{ cell, row: cell.row, value: cell.value, column: cell.column },
|
|
44
55
|
};
|
|
45
56
|
const cellContent = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
46
|
-
tableHasSubRows && hasSubRowExpander && cell.row.canExpand && (react_1.default.createElement(SubRowExpander_1.SubRowExpander, { cell: cell, isDisabled: isDisabled, cellProps: cellProps, expanderCell: expanderCell })),
|
|
57
|
+
tableHasSubRows && hasSubRowExpander && cell.row.canExpand && (react_1.default.createElement(SubRowExpander_1.SubRowExpander, { cell: cell, isDisabled: isDisabled, cellProps: cellProps, expanderCell: expanderCell, density: density })),
|
|
47
58
|
cell.render('Cell')));
|
|
48
59
|
const cellRendererProps = {
|
|
49
60
|
cellElementProps,
|