@astral/ui 0.21.0 → 0.23.0-alpha.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/Button/Button.d.ts +2 -1
- package/Button/Button.js +6 -17
- package/Button/types.d.ts +18 -6
- package/ButtonBase/styled.d.ts +5 -2
- package/ButtonBase/styled.js +10 -9
- package/CircularProgress/CircularProgress.d.ts +1 -1
- package/CircularProgress/CircularProgress.js +12 -7
- package/CircularProgress/CircularProgressStory.d.ts +5 -0
- package/CircularProgress/CircularProgressStory.js +11 -0
- package/CircularProgress/CircularProgressStoryTemplate.d.ts +4 -0
- package/CircularProgress/CircularProgressStoryTemplate.js +21 -0
- package/CircularProgress/types.d.ts +8 -5
- package/DataGrid/DataGrid.d.ts +3 -0
- package/DataGrid/DataGrid.js +64 -0
- package/DataGrid/DataGridBody/DataGridBody.d.ts +3 -0
- package/DataGrid/DataGridBody/DataGridBody.js +39 -0
- package/DataGrid/DataGridBody/index.d.ts +1 -0
- package/DataGrid/DataGridBody/index.js +13 -0
- package/DataGrid/DataGridBody/styled.d.ts +13 -0
- package/DataGrid/DataGridBody/styled.js +17 -0
- package/DataGrid/DataGridBody/types.d.ts +11 -0
- package/DataGrid/DataGridBody/types.js +2 -0
- package/DataGrid/DataGridCell/DataGridCell.d.ts +3 -0
- package/DataGrid/DataGridCell/DataGridCell.js +29 -0
- package/DataGrid/DataGridCell/index.d.ts +1 -0
- package/DataGrid/DataGridCell/index.js +13 -0
- package/DataGrid/DataGridCell/types.d.ts +5 -0
- package/DataGrid/DataGridCell/types.js +2 -0
- package/DataGrid/DataGridHead/DataGridHead.d.ts +3 -0
- package/DataGrid/DataGridHead/DataGridHead.js +71 -0
- package/DataGrid/DataGridHead/index.d.ts +2 -0
- package/DataGrid/DataGridHead/index.js +14 -0
- package/DataGrid/DataGridHead/types.d.ts +11 -0
- package/DataGrid/DataGridHead/types.js +2 -0
- package/DataGrid/DataGridHeadColumn/DataGridHeadColumn.d.ts +3 -0
- package/DataGrid/DataGridHeadColumn/DataGridHeadColumn.js +30 -0
- package/DataGrid/DataGridHeadColumn/index.d.ts +2 -0
- package/DataGrid/DataGridHeadColumn/index.js +14 -0
- package/DataGrid/DataGridHeadColumn/styled.d.ts +38 -0
- package/DataGrid/DataGridHeadColumn/styled.js +20 -0
- package/DataGrid/DataGridHeadColumn/types.d.ts +11 -0
- package/DataGrid/DataGridHeadColumn/types.js +2 -0
- package/DataGrid/DataGridLoader/DataGridLoader.d.ts +4 -0
- package/DataGrid/DataGridLoader/DataGridLoader.js +9 -0
- package/DataGrid/DataGridLoader/index.d.ts +2 -0
- package/DataGrid/DataGridLoader/index.js +14 -0
- package/DataGrid/DataGridLoader/styled.d.ts +27 -0
- package/DataGrid/DataGridLoader/styled.js +18 -0
- package/DataGrid/DataGridLoader/types.d.ts +3 -0
- package/DataGrid/DataGridLoader/types.js +2 -0
- package/DataGrid/constants.d.ts +4 -0
- package/DataGrid/constants.js +8 -0
- package/DataGrid/index.d.ts +2 -0
- package/DataGrid/index.js +14 -0
- package/DataGrid/styled.d.ts +16 -0
- package/DataGrid/styled.js +17 -0
- package/DataGrid/types.d.ts +32 -0
- package/DataGrid/types.js +2 -0
- package/DataGridPagination/DataGridPagination.d.ts +3 -0
- package/DataGridPagination/DataGridPagination.js +38 -0
- package/DataGridPagination/index.d.ts +2 -0
- package/DataGridPagination/index.js +14 -0
- package/DataGridPagination/styled.d.ts +10 -0
- package/DataGridPagination/styled.js +18 -0
- package/DataGridPagination/types.d.ts +6 -0
- package/DataGridPagination/types.js +2 -0
- package/FormHelperText/styled.d.ts +2 -2
- package/Grid/styled.d.ts +1 -1
- package/IconButton/styled.d.ts +3 -5
- package/ListItemButton/styled.d.ts +1 -1
- package/Pagination/Pagination.d.ts +3 -0
- package/Pagination/Pagination.js +32 -0
- package/Pagination/index.d.ts +2 -0
- package/Pagination/index.js +14 -0
- package/Pagination/types.d.ts +2 -0
- package/Pagination/types.js +2 -0
- package/Radio/Radio.d.ts +1 -1
- package/Select/styled.d.ts +1 -1
- package/Table/Table.d.ts +3 -0
- package/Table/Table.js +32 -0
- package/Table/TableBody/TableBody.d.ts +3 -0
- package/Table/TableBody/TableBody.js +5 -0
- package/Table/TableBody/index.d.ts +1 -0
- package/Table/TableBody/index.js +13 -0
- package/Table/TableCell/TableCell.d.ts +3 -0
- package/Table/TableCell/TableCell.js +5 -0
- package/Table/TableCell/index.d.ts +1 -0
- package/Table/TableCell/index.js +13 -0
- package/Table/TableContainer/TableContainer.d.ts +3 -0
- package/Table/TableContainer/TableContainer.js +5 -0
- package/Table/TableContainer/index.d.ts +1 -0
- package/Table/TableContainer/index.js +13 -0
- package/Table/TableFooter/TableFooter.d.ts +3 -0
- package/Table/TableFooter/TableFooter.js +5 -0
- package/Table/TableFooter/index.d.ts +1 -0
- package/Table/TableFooter/index.js +13 -0
- package/Table/TableHead/TableHead.d.ts +3 -0
- package/Table/TableHead/TableHead.js +5 -0
- package/Table/TableHead/index.d.ts +1 -0
- package/Table/TableHead/index.js +13 -0
- package/Table/TableRow/TableRow.d.ts +3 -0
- package/Table/TableRow/TableRow.js +5 -0
- package/Table/TableRow/index.d.ts +1 -0
- package/Table/TableRow/index.js +13 -0
- package/Table/TableSortLabel/TableSortLabel.d.ts +3 -0
- package/Table/TableSortLabel/TableSortLabel.js +5 -0
- package/Table/TableSortLabel/index.d.ts +1 -0
- package/Table/TableSortLabel/index.js +13 -0
- package/Table/index.d.ts +7 -0
- package/Table/index.js +19 -0
- package/TextArea/TextArea.d.ts +1 -1
- package/TextField/TextField.d.ts +1 -1
- package/Tooltip/Tooltip.d.ts +1 -1
- package/esm/Button/Button.d.ts +2 -1
- package/esm/Button/Button.js +7 -17
- package/esm/Button/types.d.ts +18 -6
- package/esm/ButtonBase/styled.d.ts +5 -2
- package/esm/ButtonBase/styled.js +10 -9
- package/esm/CircularProgress/CircularProgress.d.ts +1 -1
- package/esm/CircularProgress/CircularProgress.js +9 -6
- package/esm/CircularProgress/CircularProgressStory.d.ts +5 -0
- package/esm/CircularProgress/CircularProgressStory.js +7 -0
- package/esm/CircularProgress/CircularProgressStoryTemplate.d.ts +4 -0
- package/esm/CircularProgress/CircularProgressStoryTemplate.js +17 -0
- package/esm/CircularProgress/types.d.ts +8 -5
- package/esm/DataGrid/DataGrid.d.ts +3 -0
- package/esm/DataGrid/DataGrid.js +57 -0
- package/esm/DataGrid/DataGridBody/DataGridBody.d.ts +3 -0
- package/esm/DataGrid/DataGridBody/DataGridBody.js +35 -0
- package/esm/DataGrid/DataGridBody/index.d.ts +1 -0
- package/esm/DataGrid/DataGridBody/index.js +1 -0
- package/esm/DataGrid/DataGridBody/styled.d.ts +13 -0
- package/esm/DataGrid/DataGridBody/styled.js +14 -0
- package/esm/DataGrid/DataGridBody/types.d.ts +11 -0
- package/esm/DataGrid/DataGridBody/types.js +1 -0
- package/esm/DataGrid/DataGridCell/DataGridCell.d.ts +3 -0
- package/esm/DataGrid/DataGridCell/DataGridCell.js +25 -0
- package/esm/DataGrid/DataGridCell/index.d.ts +1 -0
- package/esm/DataGrid/DataGridCell/index.js +1 -0
- package/esm/DataGrid/DataGridCell/types.d.ts +5 -0
- package/esm/DataGrid/DataGridCell/types.js +1 -0
- package/esm/DataGrid/DataGridHead/DataGridHead.d.ts +3 -0
- package/esm/DataGrid/DataGridHead/DataGridHead.js +67 -0
- package/esm/DataGrid/DataGridHead/index.d.ts +2 -0
- package/esm/DataGrid/DataGridHead/index.js +2 -0
- package/esm/DataGrid/DataGridHead/types.d.ts +11 -0
- package/esm/DataGrid/DataGridHead/types.js +1 -0
- package/esm/DataGrid/DataGridHeadColumn/DataGridHeadColumn.d.ts +3 -0
- package/esm/DataGrid/DataGridHeadColumn/DataGridHeadColumn.js +26 -0
- package/esm/DataGrid/DataGridHeadColumn/index.d.ts +2 -0
- package/esm/DataGrid/DataGridHeadColumn/index.js +2 -0
- package/esm/DataGrid/DataGridHeadColumn/styled.d.ts +38 -0
- package/esm/DataGrid/DataGridHeadColumn/styled.js +17 -0
- package/esm/DataGrid/DataGridHeadColumn/types.d.ts +11 -0
- package/esm/DataGrid/DataGridHeadColumn/types.js +1 -0
- package/esm/DataGrid/DataGridLoader/DataGridLoader.d.ts +4 -0
- package/esm/DataGrid/DataGridLoader/DataGridLoader.js +7 -0
- package/esm/DataGrid/DataGridLoader/index.d.ts +2 -0
- package/esm/DataGrid/DataGridLoader/index.js +2 -0
- package/esm/DataGrid/DataGridLoader/styled.d.ts +27 -0
- package/esm/DataGrid/DataGridLoader/styled.js +15 -0
- package/esm/DataGrid/DataGridLoader/types.d.ts +3 -0
- package/esm/DataGrid/DataGridLoader/types.js +1 -0
- package/esm/DataGrid/constants.d.ts +4 -0
- package/esm/DataGrid/constants.js +5 -0
- package/esm/DataGrid/index.d.ts +2 -0
- package/esm/DataGrid/index.js +2 -0
- package/esm/DataGrid/styled.d.ts +16 -0
- package/esm/DataGrid/styled.js +14 -0
- package/esm/DataGrid/types.d.ts +32 -0
- package/esm/DataGrid/types.js +1 -0
- package/esm/DataGridPagination/DataGridPagination.d.ts +3 -0
- package/esm/DataGridPagination/DataGridPagination.js +34 -0
- package/esm/DataGridPagination/index.d.ts +2 -0
- package/esm/DataGridPagination/index.js +2 -0
- package/esm/DataGridPagination/styled.d.ts +10 -0
- package/esm/DataGridPagination/styled.js +15 -0
- package/esm/DataGridPagination/types.d.ts +6 -0
- package/esm/DataGridPagination/types.js +1 -0
- package/esm/FormHelperText/styled.d.ts +2 -2
- package/esm/Grid/styled.d.ts +1 -1
- package/esm/IconButton/styled.d.ts +3 -5
- package/esm/ListItemButton/styled.d.ts +1 -1
- package/esm/Pagination/Pagination.d.ts +3 -0
- package/esm/Pagination/Pagination.js +28 -0
- package/esm/Pagination/index.d.ts +2 -0
- package/esm/Pagination/index.js +2 -0
- package/esm/Pagination/types.d.ts +2 -0
- package/esm/Pagination/types.js +1 -0
- package/esm/Radio/Radio.d.ts +1 -1
- package/esm/Select/styled.d.ts +1 -1
- package/esm/Table/Table.d.ts +3 -0
- package/esm/Table/Table.js +28 -0
- package/esm/Table/TableBody/TableBody.d.ts +3 -0
- package/esm/Table/TableBody/TableBody.js +2 -0
- package/esm/Table/TableBody/index.d.ts +1 -0
- package/esm/Table/TableBody/index.js +1 -0
- package/esm/Table/TableCell/TableCell.d.ts +3 -0
- package/esm/Table/TableCell/TableCell.js +2 -0
- package/esm/Table/TableCell/index.d.ts +1 -0
- package/esm/Table/TableCell/index.js +1 -0
- package/esm/Table/TableContainer/TableContainer.d.ts +3 -0
- package/esm/Table/TableContainer/TableContainer.js +2 -0
- package/esm/Table/TableContainer/index.d.ts +1 -0
- package/esm/Table/TableContainer/index.js +1 -0
- package/esm/Table/TableFooter/TableFooter.d.ts +3 -0
- package/esm/Table/TableFooter/TableFooter.js +2 -0
- package/esm/Table/TableFooter/index.d.ts +1 -0
- package/esm/Table/TableFooter/index.js +1 -0
- package/esm/Table/TableHead/TableHead.d.ts +3 -0
- package/esm/Table/TableHead/TableHead.js +2 -0
- package/esm/Table/TableHead/index.d.ts +1 -0
- package/esm/Table/TableHead/index.js +1 -0
- package/esm/Table/TableRow/TableRow.d.ts +3 -0
- package/esm/Table/TableRow/TableRow.js +2 -0
- package/esm/Table/TableRow/index.d.ts +1 -0
- package/esm/Table/TableRow/index.js +1 -0
- package/esm/Table/TableSortLabel/TableSortLabel.d.ts +3 -0
- package/esm/Table/TableSortLabel/TableSortLabel.js +2 -0
- package/esm/Table/TableSortLabel/index.d.ts +1 -0
- package/esm/Table/TableSortLabel/index.js +1 -0
- package/esm/Table/index.d.ts +7 -0
- package/esm/Table/index.js +7 -0
- package/esm/TextArea/TextArea.d.ts +1 -1
- package/esm/TextField/TextField.d.ts +1 -1
- package/esm/Tooltip/Tooltip.d.ts +1 -1
- package/esm/index.d.ts +3 -0
- package/esm/index.js +3 -0
- package/esm/theme/__tests__/BaseTheme.test.js +1 -1
- package/esm/theme/components/MuiButton.d.ts +3 -0
- package/esm/theme/components/MuiButton.js +96 -0
- package/esm/theme/components/MuiCircularProgress.d.ts +4 -0
- package/esm/theme/components/MuiCircularProgress.js +14 -0
- package/esm/theme/components/MuiLoadingButton.d.ts +4 -0
- package/esm/theme/components/MuiLoadingButton.js +45 -0
- package/esm/theme/components/MuiPaginationItem.d.ts +3 -0
- package/esm/theme/components/MuiPaginationItem.js +14 -0
- package/esm/theme/components/MuiTableCell.d.ts +3 -0
- package/esm/theme/components/MuiTableCell.js +9 -0
- package/esm/theme/components/MuiTableHead.d.ts +3 -0
- package/esm/theme/components/MuiTableHead.js +12 -0
- package/esm/theme/components/components.js +13 -1
- package/esm/theme/elevation.js +5 -5
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +2 -2
- package/theme/__tests__/BaseTheme.test.js +1 -1
- package/theme/components/MuiButton.d.ts +3 -0
- package/theme/components/MuiButton.js +99 -0
- package/theme/components/MuiCircularProgress.d.ts +4 -0
- package/theme/components/MuiCircularProgress.js +17 -0
- package/theme/components/MuiLoadingButton.d.ts +4 -0
- package/theme/components/MuiLoadingButton.js +48 -0
- package/theme/components/MuiPaginationItem.d.ts +3 -0
- package/theme/components/MuiPaginationItem.js +17 -0
- package/theme/components/MuiTableCell.d.ts +3 -0
- package/theme/components/MuiTableCell.js +12 -0
- package/theme/components/MuiTableHead.d.ts +3 -0
- package/theme/components/MuiTableHead.js +15 -0
- package/theme/components/components.js +13 -1
- package/theme/elevation.js +5 -5
- package/Button/styled.d.ts +0 -12
- package/Button/styled.js +0 -36
- package/CircularProgress/styled.d.ts +0 -6
- package/CircularProgress/styled.js +0 -20
- package/esm/Button/styled.d.ts +0 -12
- package/esm/Button/styled.js +0 -33
- package/esm/CircularProgress/styled.d.ts +0 -6
- package/esm/CircularProgress/styled.js +0 -17
package/esm/Button/Button.js
CHANGED
|
@@ -9,21 +9,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { forwardRef } from 'react';
|
|
14
|
+
import { LoadingButton } from '@mui/lab';
|
|
24
15
|
import { CircularProgress } from '../CircularProgress';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
16
|
+
export var Button = forwardRef(function (props, ref) {
|
|
17
|
+
return (_jsx(LoadingButton, __assign({ ref: ref }, props, { loadingIndicator: _jsx(CircularProgress, { size: "small" }, void 0) }), void 0));
|
|
18
|
+
});
|
|
19
|
+
export default Button;
|
package/esm/Button/types.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { LoadingButtonProps } from '@mui/lab';
|
|
2
|
+
declare module '@mui/material/Button' {
|
|
3
|
+
interface ButtonPropsVariantOverrides {
|
|
4
|
+
contained: true;
|
|
5
|
+
light: true;
|
|
6
|
+
text: true;
|
|
7
|
+
link: true;
|
|
8
|
+
}
|
|
9
|
+
interface ButtonPropsColorVariantOverrides {
|
|
10
|
+
primary: true;
|
|
11
|
+
success: true;
|
|
12
|
+
warning: true;
|
|
13
|
+
error: true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export declare type ButtonProps = Omit<LoadingButtonProps, 'variant' | 'color'> & {
|
|
17
|
+
variant?: 'contained' | 'light' | 'text' | 'link';
|
|
18
|
+
color?: 'primary' | 'success' | 'warning' | 'error';
|
|
7
19
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Theme } from '../theme';
|
|
3
3
|
import { BaseButtonProps, ButtonColor, ButtonSize, ButtonState, ButtonVariant } from './types';
|
|
4
|
-
declare type
|
|
4
|
+
export declare type StyledButtonBaseProps = Omit<BaseButtonProps, 'color' | 'variant'> & {
|
|
5
|
+
customColor?: ButtonColor;
|
|
6
|
+
customVariant?: ButtonVariant;
|
|
7
|
+
};
|
|
8
|
+
export declare type StyledButtonBaseThemeProps = {
|
|
5
9
|
customColor?: ButtonColor;
|
|
6
10
|
customVariant?: ButtonVariant;
|
|
7
11
|
size?: ButtonSize;
|
|
@@ -24,4 +28,3 @@ export declare const StyledButtonBase: import("@emotion/styled").StyledComponent
|
|
|
24
28
|
customColor?: "error" | "primary" | "success" | "warning" | undefined;
|
|
25
29
|
customVariant?: "link" | "text" | "light" | "contained" | undefined;
|
|
26
30
|
}, {}, {}>;
|
|
27
|
-
export {};
|
package/esm/ButtonBase/styled.js
CHANGED
|
@@ -23,13 +23,13 @@ export var getColor = function (_a) {
|
|
|
23
23
|
error: {
|
|
24
24
|
default: theme.palette.red['900'],
|
|
25
25
|
hover: theme.palette.red['900'],
|
|
26
|
-
active: theme.palette.red['
|
|
26
|
+
active: theme.palette.red['800'],
|
|
27
27
|
focus: theme.palette.red['900'],
|
|
28
28
|
},
|
|
29
29
|
success: {
|
|
30
30
|
default: theme.palette.green['900'],
|
|
31
31
|
hover: theme.palette.green['900'],
|
|
32
|
-
active: theme.palette.green['
|
|
32
|
+
active: theme.palette.green['800'],
|
|
33
33
|
focus: theme.palette.green['900'],
|
|
34
34
|
},
|
|
35
35
|
primary: {
|
|
@@ -41,7 +41,7 @@ export var getColor = function (_a) {
|
|
|
41
41
|
warning: {
|
|
42
42
|
default: theme.palette.yellow['900'],
|
|
43
43
|
hover: theme.palette.yellow['900'],
|
|
44
|
-
active: theme.palette.yellow['
|
|
44
|
+
active: theme.palette.yellow['800'],
|
|
45
45
|
focus: theme.palette.yellow['900'],
|
|
46
46
|
},
|
|
47
47
|
},
|
|
@@ -159,15 +159,16 @@ export var getButtonPadding = function (_a) {
|
|
|
159
159
|
export var getDisabledBgColor = function (_a) {
|
|
160
160
|
var theme = _a.theme, customVariant = _a.customVariant;
|
|
161
161
|
if (customVariant === ButtonVariants.LINK ||
|
|
162
|
-
customVariant === ButtonVariants.TEXT)
|
|
162
|
+
customVariant === ButtonVariants.TEXT) {
|
|
163
163
|
return 'transparent';
|
|
164
|
+
}
|
|
164
165
|
return theme.palette.grey['100'];
|
|
165
166
|
};
|
|
166
167
|
export var StyledButtonBase = styled(ButtonUnstyled, {
|
|
167
168
|
shouldForwardProp: function (prop) {
|
|
168
169
|
return prop !== 'customColor' && prop !== 'customVariant';
|
|
169
170
|
},
|
|
170
|
-
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n\n display: inline-flex;\n align-items: center;\n justify-content: center;\n height: ", ";\n padding: ", ";\n\n color: ", ";\n font-weight: ", ";\n font-size: ", ";\n font-family: Ubuntu, serif;\n\n background-color: ", ";\n border: none;\n border-radius: ", ";\n cursor: pointer;\n\n &:hover {\n color: ", ";\n\n background-color: ", ";\n }\n\n &:focus {\n color: ", ";\n\n background-color: ", ";\n
|
|
171
|
+
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n\n display: inline-flex;\n align-items: center;\n justify-content: center;\n height: ", ";\n padding: ", ";\n\n color: ", ";\n font-weight: ", ";\n font-size: ", ";\n font-family: Ubuntu, serif;\n\n background-color: ", ";\n border: none;\n border-radius: ", ";\n cursor: pointer;\n\n &:hover {\n color: ", ";\n\n background-color: ", ";\n }\n\n &:focus {\n color: ", ";\n\n background-color: ", ";\n }\n\n &:active {\n color: ", ";\n\n background-color: ", ";\n outline: none;\n }\n\n &.", " {\n color: ", ";\n\n background-color: ", ";\n cursor: unset;\n }\n\n &.", " {\n outline: 2px solid ", ";\n }\n"], ["\n position: relative;\n\n display: inline-flex;\n align-items: center;\n justify-content: center;\n height: ", ";\n padding: ", ";\n\n color: ", ";\n font-weight: ", ";\n font-size: ", ";\n font-family: Ubuntu, serif;\n\n background-color: ", ";\n border: none;\n border-radius: ", ";\n cursor: pointer;\n\n &:hover {\n color: ", ";\n\n background-color: ", ";\n }\n\n &:focus {\n color: ", ";\n\n background-color: ", ";\n }\n\n &:active {\n color: ", ";\n\n background-color: ", ";\n outline: none;\n }\n\n &.", " {\n color: ", ";\n\n background-color: ", ";\n cursor: unset;\n }\n\n &.", " {\n outline: 2px solid ", ";\n }\n"])), getButtonHeight, getButtonPadding, function (props) {
|
|
171
172
|
return getColor(__assign(__assign({}, props), { buttonState: ButtonStates.DEFAULT }));
|
|
172
173
|
}, function (_a) {
|
|
173
174
|
var theme = _a.theme;
|
|
@@ -188,9 +189,6 @@ export var StyledButtonBase = styled(ButtonUnstyled, {
|
|
|
188
189
|
return getColor(__assign(__assign({}, props), { buttonState: ButtonStates.FOCUS }));
|
|
189
190
|
}, function (props) {
|
|
190
191
|
return getBgColor(__assign(__assign({}, props), { buttonState: ButtonStates.FOCUS }));
|
|
191
|
-
}, function (_a) {
|
|
192
|
-
var theme = _a.theme;
|
|
193
|
-
return theme.palette.primary['400'];
|
|
194
192
|
}, function (props) {
|
|
195
193
|
return getColor(__assign(__assign({}, props), { buttonState: ButtonStates.ACTIVE }));
|
|
196
194
|
}, function (props) {
|
|
@@ -198,5 +196,8 @@ export var StyledButtonBase = styled(ButtonUnstyled, {
|
|
|
198
196
|
}, buttonUnstyledClasses.disabled, function (_a) {
|
|
199
197
|
var theme = _a.theme;
|
|
200
198
|
return theme.palette.grey['500'];
|
|
201
|
-
}, getDisabledBgColor)
|
|
199
|
+
}, getDisabledBgColor, buttonUnstyledClasses.focusVisible, function (_a) {
|
|
200
|
+
var theme = _a.theme;
|
|
201
|
+
return theme.palette.primary['400'];
|
|
202
|
+
});
|
|
202
203
|
var templateObject_1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CircularProgressProps } from './types';
|
|
3
|
-
export declare const CircularProgress: (
|
|
3
|
+
export declare const CircularProgress: import("react").ForwardRefExoticComponent<Pick<CircularProgressProps, "className" | "style" | "classes" | "sx" | "variant" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "css" | "value" | "size" | "disableShrink" | "thickness"> & import("react").RefAttributes<HTMLElement>>;
|
|
4
4
|
export default CircularProgress;
|
|
@@ -21,10 +21,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
26
|
-
export var CircularProgress = function (
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
import { forwardRef, useMemo } from 'react';
|
|
25
|
+
import MuiCircularProgress from '@mui/material/CircularProgress';
|
|
26
|
+
export var CircularProgress = forwardRef(function (props, ref) {
|
|
27
|
+
var sizeProp = props.size, color = props.color, restProps = __rest(props, ["size", "color"]);
|
|
28
|
+
var size = useMemo(function () {
|
|
29
|
+
return sizeProp === 'small' ? 16 : 24;
|
|
30
|
+
}, [sizeProp]);
|
|
31
|
+
return (_jsx(MuiCircularProgress, __assign({ ref: ref }, restProps, { size: size, color: "inherit", "data-color": color }), void 0));
|
|
32
|
+
});
|
|
30
33
|
export default CircularProgress;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CircularProgressProps } from '../CircularProgress';
|
|
3
|
+
export declare type CircularProgressStoryProps = CircularProgressProps;
|
|
4
|
+
export declare const CircularProgressStory: FC<CircularProgressStoryProps>;
|
|
5
|
+
export default CircularProgressStory;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CircularProgress } from '../CircularProgress';
|
|
3
|
+
export var CircularProgressStory = function (props) {
|
|
4
|
+
var size = props.size, color = props.color;
|
|
5
|
+
return _jsx(CircularProgress, { size: size, color: color }, void 0);
|
|
6
|
+
};
|
|
7
|
+
export default CircularProgressStory;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { CircularProgressStory } from './CircularProgressStory';
|
|
14
|
+
export var CircularProgressStoryTemplate = function (args) {
|
|
15
|
+
return _jsx(CircularProgressStory, __assign({}, args), void 0);
|
|
16
|
+
};
|
|
17
|
+
export default CircularProgressStoryTemplate;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { CircularProgressProps as MuiCircularProgressProps } from '@mui/material';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
declare module '@mui/material/CircularProgress' {
|
|
3
|
+
interface CircularProgressPropsColorOverrides {
|
|
4
|
+
primary: true;
|
|
5
|
+
inverted: true;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
5
8
|
export declare type CircularProgressProps = Omit<MuiCircularProgressProps, 'color' | 'size'> & {
|
|
6
|
-
color?:
|
|
7
|
-
size?:
|
|
9
|
+
color?: 'primary' | 'inverted';
|
|
10
|
+
size?: 'small' | 'medium';
|
|
8
11
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { useCallback, useMemo } from 'react';
|
|
23
|
+
import { Table } from '../Table';
|
|
24
|
+
import { DataGridHead } from './DataGridHead';
|
|
25
|
+
import { DataGridBody } from './DataGridBody';
|
|
26
|
+
import DataGridLoader from './DataGridLoader/DataGridLoader';
|
|
27
|
+
import { DataGridContainer, StyledTableContainer } from './styled';
|
|
28
|
+
export function DataGrid(_a) {
|
|
29
|
+
var columns = _a.columns, _b = _a.rows, rows = _b === void 0 ? [] : _b, _c = _a.selectedRows, selectedRows = _c === void 0 ? [] : _c, _d = _a.sorting, sorting = _d === void 0 ? [] : _d, maxHeight = _a.maxHeight, _e = _a.minDisplayRows, minDisplayRows = _e === void 0 ? 10 : _e, onSelectRow = _a.onSelectRow, Footer = _a.Footer, loading = _a.loading, onSort = _a.onSort, keyId = _a.keyId;
|
|
30
|
+
var selectable = Boolean(onSelectRow);
|
|
31
|
+
var handleSelectAllRows = function (event) {
|
|
32
|
+
if (!onSelectRow)
|
|
33
|
+
return;
|
|
34
|
+
if (event.target.checked) {
|
|
35
|
+
var mergedSelectedRows = __spreadArray(__spreadArray([], selectedRows, true), rows, true);
|
|
36
|
+
return onSelectRow(mergedSelectedRows);
|
|
37
|
+
}
|
|
38
|
+
var filteredRows = selectedRows.filter(function (selectedRow) { return !rows.find(function (row) { return row[keyId] === selectedRow[keyId]; }); });
|
|
39
|
+
onSelectRow(filteredRows);
|
|
40
|
+
};
|
|
41
|
+
var handleSelectRow = useCallback(function (row) {
|
|
42
|
+
return function (event) {
|
|
43
|
+
if (!onSelectRow)
|
|
44
|
+
return;
|
|
45
|
+
if (event.target.checked) {
|
|
46
|
+
return onSelectRow(__spreadArray(__spreadArray([], selectedRows, true), [row], false));
|
|
47
|
+
}
|
|
48
|
+
return onSelectRow(selectedRows.filter(function (selectedRow) { return selectedRow[keyId] !== row[keyId]; }));
|
|
49
|
+
};
|
|
50
|
+
}, [selectedRows, onSelectRow]);
|
|
51
|
+
var uncheckedRowsCount = useMemo(function () {
|
|
52
|
+
return rows.filter(function (row) {
|
|
53
|
+
return !selectedRows.find(function (selectedRow) { return selectedRow[keyId] === row[keyId]; });
|
|
54
|
+
}).length;
|
|
55
|
+
}, [rows, selectedRows, keyId]);
|
|
56
|
+
return (_jsxs(DataGridContainer, { children: [_jsxs(StyledTableContainer, __assign({ maxHeight: maxHeight }, { children: [_jsxs(Table, __assign({ stickyHeader: true }, { children: [_jsx(DataGridHead, { onSort: onSort, rowsCount: rows.length, uncheckedRowsCount: uncheckedRowsCount, onSelectAllRows: handleSelectAllRows, selectable: selectable, sorting: sorting, columns: columns }, void 0), _jsx(DataGridBody, { keyId: keyId, selectedRows: selectedRows, minDisplayRows: minDisplayRows, onSelectRow: handleSelectRow, selectable: selectable, rows: rows, columns: columns }, void 0)] }), void 0), _jsx(DataGridLoader, { loading: loading }, void 0)] }), void 0), Footer] }, void 0));
|
|
57
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useCallback, useMemo } from 'react';
|
|
14
|
+
import { TableCell, TableRow } from '../../Table';
|
|
15
|
+
import { DataGridCell } from '../DataGridCell';
|
|
16
|
+
import { Checkbox } from '../../Checkbox';
|
|
17
|
+
import { StyledTableBody } from './styled';
|
|
18
|
+
export function DataGridBody(_a) {
|
|
19
|
+
var rows = _a.rows, columns = _a.columns, selectable = _a.selectable, onSelectRow = _a.onSelectRow, _b = _a.selectedRows, selectedRows = _b === void 0 ? [] : _b, minDisplayRows = _a.minDisplayRows, keyId = _a.keyId;
|
|
20
|
+
var renderCells = useCallback(function (row, rowId) {
|
|
21
|
+
return columns.map(function (cell, index) {
|
|
22
|
+
var cellId = "".concat(rowId, "-").concat(index);
|
|
23
|
+
return _jsx(DataGridCell, { row: row, cell: cell }, cellId);
|
|
24
|
+
});
|
|
25
|
+
}, [columns]);
|
|
26
|
+
var renderedRows = useMemo(function () {
|
|
27
|
+
return rows.map(function (row) {
|
|
28
|
+
var rowId = row[keyId];
|
|
29
|
+
var checked = selectable &&
|
|
30
|
+
Boolean(selectedRows.find(function (selectedRow) { return selectedRow[keyId] === rowId; }));
|
|
31
|
+
return (_jsxs(TableRow, { children: [selectable && (_jsx(TableCell, __assign({ padding: "checkbox" }, { children: _jsx(Checkbox, { checked: checked, onChange: onSelectRow(row) }, void 0) }), void 0)), renderCells(row, rowId)] }, rowId));
|
|
32
|
+
});
|
|
33
|
+
}, [rows, keyId, selectable, selectedRows, onSelectRow, columns]);
|
|
34
|
+
return (_jsx(StyledTableBody, __assign({ empty: !rows.length, minDisplayRows: minDisplayRows }, { children: renderedRows }), void 0));
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DataGridBody';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DataGridBody';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledTableBody: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
classes?: Partial<import("@mui/material").TableBodyClasses> | undefined;
|
|
5
|
+
sx?: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
|
|
6
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "key" | keyof import("react").HTMLAttributes<HTMLTableSectionElement>> & {
|
|
7
|
+
ref?: ((instance: HTMLTableSectionElement | null) => void) | import("react").RefObject<HTMLTableSectionElement> | null | undefined;
|
|
8
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx"> & {
|
|
9
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
10
|
+
} & {
|
|
11
|
+
empty: boolean;
|
|
12
|
+
minDisplayRows: number;
|
|
13
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { styled } from '../../styles';
|
|
6
|
+
import { TableBody } from '../../Table';
|
|
7
|
+
var TABLE_ROW_HEIGHT = 44;
|
|
8
|
+
export var StyledTableBody = styled(TableBody, {
|
|
9
|
+
shouldForwardProp: function (prop) { return prop !== 'empty' && prop !== 'minDisplayRows'; },
|
|
10
|
+
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: ", ";\n"], ["\n height: ", ";\n"])), function (_a) {
|
|
11
|
+
var empty = _a.empty, minDisplayRows = _a.minDisplayRows;
|
|
12
|
+
return empty ? "".concat(TABLE_ROW_HEIGHT * minDisplayRows, "px") : 'auto';
|
|
13
|
+
});
|
|
14
|
+
var templateObject_1;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ChangeEvent } from 'react';
|
|
2
|
+
import { DataGridColumns, DataGridRow } from '../types';
|
|
3
|
+
export declare type DataGridBodyProps<T = DataGridRow> = {
|
|
4
|
+
columns: DataGridColumns<T>[];
|
|
5
|
+
keyId: keyof DataGridRow;
|
|
6
|
+
selectable?: boolean;
|
|
7
|
+
selectedRows?: Array<T>;
|
|
8
|
+
rows: T[];
|
|
9
|
+
onSelectRow: (row: T) => (event: ChangeEvent<HTMLInputElement>) => void;
|
|
10
|
+
minDisplayRows: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useMemo } from 'react';
|
|
14
|
+
import { TableCell } from '../../Table';
|
|
15
|
+
import { Typography } from '../../Typography';
|
|
16
|
+
export function DataGridCell(_a) {
|
|
17
|
+
var row = _a.row, _b = _a.cell, field = _b.field, renderCell = _b.renderCell, format = _b.format, _c = _b.align, align = _c === void 0 ? 'left' : _c;
|
|
18
|
+
var formattedValue = useMemo(function () {
|
|
19
|
+
if (format) {
|
|
20
|
+
return format(row);
|
|
21
|
+
}
|
|
22
|
+
return row[field];
|
|
23
|
+
}, [field, format, row]);
|
|
24
|
+
return (_jsxs(TableCell, __assign({ align: align }, { children: [renderCell && renderCell(row), !renderCell && _jsx(Typography, { children: formattedValue }, void 0)] }), void 0));
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DataGridCell';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DataGridCell';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { useCallback, useMemo } from 'react';
|
|
23
|
+
import { TableHead } from '../../Table/TableHead';
|
|
24
|
+
import { TableCell, TableRow } from '../../Table';
|
|
25
|
+
import { Checkbox } from '../../Checkbox';
|
|
26
|
+
import { SortStates } from '../constants';
|
|
27
|
+
import { DataGridHeadColumn } from '../DataGridHeadColumn';
|
|
28
|
+
export function DataGridHead(_a) {
|
|
29
|
+
var columns = _a.columns, selectable = _a.selectable, onSelectAllRows = _a.onSelectAllRows, rowsCount = _a.rowsCount, onSort = _a.onSort, _b = _a.sorting, sorting = _b === void 0 ? [] : _b, uncheckedRowsCount = _a.uncheckedRowsCount;
|
|
30
|
+
var checked = useMemo(function () { return !Boolean(uncheckedRowsCount) && rowsCount > 0; }, [uncheckedRowsCount, rowsCount]);
|
|
31
|
+
var indeterminate = useMemo(function () { return uncheckedRowsCount > 0 && uncheckedRowsCount < rowsCount; }, [uncheckedRowsCount, rowsCount]);
|
|
32
|
+
var handleSort = useCallback(function (field, sortable) { return function () {
|
|
33
|
+
if (sortable) {
|
|
34
|
+
var currentSort = sorting.find(function (_a) {
|
|
35
|
+
var fieldId = _a.fieldId;
|
|
36
|
+
return fieldId === field;
|
|
37
|
+
});
|
|
38
|
+
// если для выбранного столбца текущая сортировка ASC - меняем на DESC
|
|
39
|
+
if (currentSort && currentSort.sort === SortStates.ASC) {
|
|
40
|
+
var newSorting = __spreadArray(__spreadArray([], sorting.filter(function (_a) {
|
|
41
|
+
var fieldId = _a.fieldId;
|
|
42
|
+
return fieldId !== field;
|
|
43
|
+
}), true), [
|
|
44
|
+
{ fieldId: field, sort: SortStates.DESC },
|
|
45
|
+
], false);
|
|
46
|
+
return onSort(newSorting);
|
|
47
|
+
// если для выбранного столбца текущая сортировка DESC - убираем сортировку
|
|
48
|
+
}
|
|
49
|
+
else if (currentSort && currentSort.sort === SortStates.DESC) {
|
|
50
|
+
var newSorting = sorting.filter(function (_a) {
|
|
51
|
+
var fieldId = _a.fieldId;
|
|
52
|
+
return fieldId !== field;
|
|
53
|
+
});
|
|
54
|
+
return onSort(newSorting);
|
|
55
|
+
}
|
|
56
|
+
// если для выбранного столбца нет сортировки - добавляем сортировку ASC
|
|
57
|
+
onSort(__spreadArray(__spreadArray([], sorting, true), [{ fieldId: field, sort: SortStates.ASC }], false));
|
|
58
|
+
}
|
|
59
|
+
}; }, [sorting]);
|
|
60
|
+
var renderColumns = useMemo(function () {
|
|
61
|
+
return columns.map(function (_a) {
|
|
62
|
+
var field = _a.field, label = _a.label, sortable = _a.sortable, align = _a.align, renderCell = _a.renderCell;
|
|
63
|
+
return (_jsx(DataGridHeadColumn, { sorting: sorting, renderCell: renderCell, field: field, onSort: handleSort, label: label, sortable: sortable, align: align }, void 0));
|
|
64
|
+
});
|
|
65
|
+
}, [columns, handleSort, sorting]);
|
|
66
|
+
return (_jsx(TableHead, { children: _jsxs(TableRow, { children: [selectable && (_jsx(TableCell, __assign({ padding: "checkbox" }, { children: _jsx(Checkbox, { checked: checked, indeterminate: indeterminate, onChange: onSelectAllRows }, void 0) }), void 0)), renderColumns] }, void 0) }, void 0));
|
|
67
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ChangeEvent } from 'react';
|
|
2
|
+
import { DataGridColumns, DataGridRow, DataGridSort } from '../types';
|
|
3
|
+
export declare type DataGridHeadProps<T = DataGridRow> = {
|
|
4
|
+
columns: DataGridColumns<T>[];
|
|
5
|
+
selectable: boolean;
|
|
6
|
+
onSelectAllRows: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
7
|
+
sorting: DataGridSort<T>[];
|
|
8
|
+
onSort: (sorting: DataGridSort<T>[]) => void;
|
|
9
|
+
uncheckedRowsCount: number;
|
|
10
|
+
rowsCount: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Typography } from '../../Typography/Typography';
|
|
14
|
+
import { SortStates } from '../constants';
|
|
15
|
+
import { StyledTableCell, StyledTableSortLabel } from './styled';
|
|
16
|
+
export function DataGridHeadColumn(_a) {
|
|
17
|
+
var onSort = _a.onSort, field = _a.field, sortable = _a.sortable, align = _a.align, label = _a.label, sorting = _a.sorting, renderCell = _a.renderCell;
|
|
18
|
+
var sortParams = sorting.find(function (_a) {
|
|
19
|
+
var fieldId = _a.fieldId;
|
|
20
|
+
return field === fieldId;
|
|
21
|
+
});
|
|
22
|
+
var hideSortIcon = !Boolean(sortParams);
|
|
23
|
+
var sortDirection = sortParams ? sortParams.sort : SortStates.ASC;
|
|
24
|
+
var fitContent = Boolean(renderCell);
|
|
25
|
+
return (_jsxs(StyledTableCell, __assign({ onClick: onSort(field, sortable), fitContent: fitContent, align: align }, { children: [_jsx(Typography, __assign({ variant: "pointer" }, { children: label }), void 0), sortable && (_jsx(StyledTableSortLabel, { hideSortIcon: hideSortIcon, direction: sortDirection, active: true }, void 0))] }), void 0));
|
|
26
|
+
}
|