@astral/ui 1.34.2 → 1.36.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.
@@ -1,6 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { DataGridColumns, DataGridRow, DataGridSort } from './types';
3
3
  export declare type DataGridProps<Data extends object = DataGridRow, SortField extends keyof Data = keyof Data> = {
4
+ className?: string;
4
5
  /**
5
6
  * @example <DataGrid rows={[{name: 'test'}]} />
6
7
  * Массив данных для таблицы
@@ -74,5 +75,11 @@ export declare type DataGridProps<Data extends object = DataGridRow, SortField e
74
75
  * Используется для отображения переданного кол-ва строк при отсутствии данных
75
76
  */
76
77
  minDisplayRows?: number;
78
+ /**
79
+ * @default 50
80
+ * @example <DateGrid Footer={Footer} footerHeight={50} />
81
+ * Высота Footer, по-умолчанию указана высота Footer из кита
82
+ */
83
+ footerHeight?: number;
77
84
  };
78
- export declare function DataGrid<Data extends object = DataGridRow, SortField extends keyof Data = keyof Data>({ columns, rows, selectedRows, sorting, maxHeight, minDisplayRows, onRowClick, onSelectRow, Footer, noDataPlaceholder, loading, onSort, keyId, emptyCellValue, }: DataGridProps<Data, SortField>): JSX.Element;
85
+ export declare function DataGrid<Data extends object = DataGridRow, SortField extends keyof Data = keyof Data>({ columns, rows, selectedRows, sorting, maxHeight, minDisplayRows, onRowClick, onSelectRow, Footer, noDataPlaceholder, loading, onSort, keyId, emptyCellValue, className, footerHeight, }: DataGridProps<Data, SortField>): JSX.Element;
@@ -12,8 +12,9 @@ const DataGridBody_1 = require("./DataGridBody");
12
12
  const DataGridLoader_1 = __importDefault(require("./DataGridLoader/DataGridLoader"));
13
13
  const DataGridNoData_1 = require("./DataGridNoData");
14
14
  const styles_1 = require("./styles");
15
- function DataGrid({ columns, rows = [], selectedRows = [], sorting, maxHeight, minDisplayRows = 10, onRowClick, onSelectRow, Footer, noDataPlaceholder, loading, onSort, keyId, emptyCellValue, }) {
15
+ function DataGrid({ columns, rows = [], selectedRows = [], sorting, maxHeight, minDisplayRows = 10, onRowClick, onSelectRow, Footer, noDataPlaceholder, loading, onSort, keyId, emptyCellValue, className, footerHeight = 50, }) {
16
16
  const selectable = Boolean(onSelectRow);
17
+ const withFooter = Boolean(Footer);
17
18
  const handleSelectAllRows = (event) => {
18
19
  if (!onSelectRow) {
19
20
  return;
@@ -43,6 +44,6 @@ function DataGrid({ columns, rows = [], selectedRows = [], sorting, maxHeight, m
43
44
  }
44
45
  return null;
45
46
  }, [noDataPlaceholder, loading]);
46
- return ((0, jsx_runtime_1.jsxs)(styles_1.DataGridContainer, { children: [(0, jsx_runtime_1.jsxs)(styles_1.StyledTableContainer, Object.assign({ maxHeight: maxHeight }, { children: [(0, jsx_runtime_1.jsxs)(Table_1.Table, Object.assign({ stickyHeader: true }, { children: [(0, jsx_runtime_1.jsx)(DataGridHead_1.DataGridHead, { onSort: onSort, rowsCount: rows.length, uncheckedRowsCount: uncheckedRowsCount, onSelectAllRows: handleSelectAllRows, selectable: selectable, sorting: sorting, columns: columns }), (0, jsx_runtime_1.jsx)(DataGridBody_1.DataGridBody, { keyId: keyId, selectedRows: selectedRows, minDisplayRows: minDisplayRows, onRowClick: onRowClick, onSelectRow: handleSelectRow, selectable: selectable, rows: rows, columns: columns, emptyCellValue: emptyCellValue, noDataPlaceholder: renderedPlaceholder() })] })), (0, jsx_runtime_1.jsx)(DataGridLoader_1.default, { loading: loading })] })), rows.length ? Footer : null] }));
47
+ return ((0, jsx_runtime_1.jsxs)(styles_1.DataGridContainer, Object.assign({ maxHeight: maxHeight, className: className }, { children: [(0, jsx_runtime_1.jsx)(styles_1.StyledTableContainer, { children: (0, jsx_runtime_1.jsxs)(Table_1.Table, Object.assign({ stickyHeader: true }, { children: [(0, jsx_runtime_1.jsx)(DataGridHead_1.DataGridHead, { onSort: onSort, rowsCount: rows.length, uncheckedRowsCount: uncheckedRowsCount, onSelectAllRows: handleSelectAllRows, selectable: selectable, sorting: sorting, columns: columns }), (0, jsx_runtime_1.jsx)(DataGridBody_1.DataGridBody, { keyId: keyId, selectedRows: selectedRows, minDisplayRows: minDisplayRows, onRowClick: onRowClick, onSelectRow: handleSelectRow, selectable: selectable, rows: rows, columns: columns, emptyCellValue: emptyCellValue, noDataPlaceholder: renderedPlaceholder() })] })) }), (0, jsx_runtime_1.jsx)(DataGridLoader_1.default, { footerHeight: footerHeight, withFooter: withFooter, loading: loading }), Footer] })));
47
48
  }
48
49
  exports.DataGrid = DataGrid;
@@ -9,5 +9,5 @@ exports.StyledTableBody = (0, styles_1.styled)(Table_1.TableBody, {
9
9
  }) `
10
10
  position: relative;
11
11
 
12
- height: ${({ empty, minDisplayRows }) => empty ? `${TABLE_ROW_HEIGHT * minDisplayRows}px` : 'auto'};
12
+ height: ${({ empty, minDisplayRows }) => empty ? `${TABLE_ROW_HEIGHT * minDisplayRows}px` : '100%'};
13
13
  `;
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  export declare type DataGridLoaderProps = {
3
3
  loading?: boolean;
4
+ withFooter: boolean;
5
+ footerHeight: number;
4
6
  };
5
- declare const DataGridLoader: ({ loading }: DataGridLoaderProps) => JSX.Element;
7
+ declare const DataGridLoader: ({ loading, withFooter, footerHeight, }: DataGridLoaderProps) => JSX.Element;
6
8
  export default DataGridLoader;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
4
  const styles_1 = require("./styles");
5
- const DataGridLoader = ({ loading = false }) => {
6
- return ((0, jsx_runtime_1.jsxs)(styles_1.LoaderWrapper, { children: [loading && (0, jsx_runtime_1.jsx)(styles_1.Backdrop, {}), loading ? (0, jsx_runtime_1.jsx)(styles_1.StyledLinearProgress, {}) : (0, jsx_runtime_1.jsx)(styles_1.StyledDivider, {})] }));
5
+ const DataGridLoader = ({ loading = false, withFooter, footerHeight, }) => {
6
+ return ((0, jsx_runtime_1.jsxs)(styles_1.LoaderWrapper, { children: [loading && ((0, jsx_runtime_1.jsx)(styles_1.Backdrop, { withFooter: withFooter, footerHeight: footerHeight })), loading && (0, jsx_runtime_1.jsx)(styles_1.StyledLinearProgress, {}), !loading && (0, jsx_runtime_1.jsx)(styles_1.StyledDivider, {})] }));
7
7
  };
8
8
  exports.default = DataGridLoader;
@@ -1,8 +1,12 @@
1
1
  /// <reference types="react" />
2
+ declare type BackdropProps = {
3
+ withFooter: boolean;
4
+ footerHeight: number;
5
+ };
2
6
  export declare const Backdrop: import("@emotion/styled").StyledComponent<{
3
7
  theme?: import("@emotion/react").Theme | undefined;
4
8
  as?: import("react").ElementType<any> | undefined;
5
- }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
9
+ } & BackdropProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
10
  export declare const StyledDivider: import("@emotion/styled").StyledComponent<import("../../Divider").DividerProps & {
7
11
  theme?: import("@emotion/react").Theme | undefined;
8
12
  }, {}, {}>;
@@ -13,3 +17,4 @@ export declare const LoaderWrapper: import("@emotion/styled").StyledComponent<{
13
17
  export declare const StyledLinearProgress: import("@emotion/styled").StyledComponent<import("@mui/material").LinearProgressProps & {
14
18
  theme?: import("@emotion/react").Theme | undefined;
15
19
  }, {}, {}>;
20
+ export {};
@@ -9,7 +9,9 @@ exports.Backdrop = styles_1.styled.div `
9
9
  top: 0;
10
10
 
11
11
  width: 100%;
12
- height: 100%;
12
+
13
+ /* Если в DataGrid передан Footer, нужно чтобы Backdrop не перекрывал его в состоянии loading, поэтому тут его высота вычитается из всей высоты бэкдропа */
14
+ height: ${({ withFooter, footerHeight }) => withFooter ? `calc(100% - ${footerHeight}px) ` : '100%'};
13
15
 
14
16
  background-color: ${({ theme }) => theme.palette.grey['100']};
15
17
  opacity: 0.6;
@@ -2,6 +2,14 @@
2
2
  export declare const DataGridContainer: import("@emotion/styled").StyledComponent<{
3
3
  theme?: import("@emotion/react").Theme | undefined;
4
4
  as?: import("react").ElementType<any> | undefined;
5
+ } & {
6
+ children?: import("react").ReactNode;
7
+ classes?: Partial<import("@mui/material").TableContainerClasses> | undefined;
8
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
9
+ } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "css" | "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
10
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
11
+ }, "sx" | "children" | keyof import("@mui/material/OverridableComponent").CommonProps> & {
12
+ maxHeight?: number | undefined;
5
13
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
14
  export declare const StyledTableContainer: import("@emotion/styled").StyledComponent<import("../Table").TableContainerProps & {
7
15
  theme?: import("@emotion/react").Theme | undefined;
@@ -4,13 +4,17 @@ exports.StyledTableContainer = exports.DataGridContainer = void 0;
4
4
  const styles_1 = require("../styles");
5
5
  const Table_1 = require("../Table");
6
6
  exports.DataGridContainer = styles_1.styled.div `
7
+ position: relative;
8
+
9
+ display: flex;
10
+ flex-direction: column;
7
11
  width: 100%;
12
+ height: 100%;
13
+ max-height: ${({ maxHeight }) => (maxHeight ? `${maxHeight}px` : 'initial')};
8
14
  overflow: hidden;
9
15
  `;
10
16
  exports.StyledTableContainer = (0, styles_1.styled)(Table_1.TableContainer, {
11
17
  shouldForwardProp: (prop) => prop !== 'maxHeight',
12
18
  }) `
13
- position: relative;
14
-
15
- max-height: ${({ maxHeight }) => `${maxHeight}px` || 'auto'};
19
+ height: 100%;
16
20
  `;
@@ -13,7 +13,6 @@ exports.NavMenuItemButtonRoot = (0, styles_1.styled)(ListItemButton_1.ListItemBu
13
13
  border-radius: ${({ theme }) => theme.shape.medium};
14
14
 
15
15
  .MuiListItemIcon-root {
16
-
17
16
  color: ${({ theme, selected }) => {
18
17
  return selected ? theme.palette.primary['800'] : 'inherit';
19
18
  }};
@@ -1,6 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { DataGridColumns, DataGridRow, DataGridSort } from './types';
3
3
  export declare type DataGridProps<Data extends object = DataGridRow, SortField extends keyof Data = keyof Data> = {
4
+ className?: string;
4
5
  /**
5
6
  * @example <DataGrid rows={[{name: 'test'}]} />
6
7
  * Массив данных для таблицы
@@ -74,5 +75,11 @@ export declare type DataGridProps<Data extends object = DataGridRow, SortField e
74
75
  * Используется для отображения переданного кол-ва строк при отсутствии данных
75
76
  */
76
77
  minDisplayRows?: number;
78
+ /**
79
+ * @default 50
80
+ * @example <DateGrid Footer={Footer} footerHeight={50} />
81
+ * Высота Footer, по-умолчанию указана высота Footer из кита
82
+ */
83
+ footerHeight?: number;
77
84
  };
78
- export declare function DataGrid<Data extends object = DataGridRow, SortField extends keyof Data = keyof Data>({ columns, rows, selectedRows, sorting, maxHeight, minDisplayRows, onRowClick, onSelectRow, Footer, noDataPlaceholder, loading, onSort, keyId, emptyCellValue, }: DataGridProps<Data, SortField>): JSX.Element;
85
+ export declare function DataGrid<Data extends object = DataGridRow, SortField extends keyof Data = keyof Data>({ columns, rows, selectedRows, sorting, maxHeight, minDisplayRows, onRowClick, onSelectRow, Footer, noDataPlaceholder, loading, onSort, keyId, emptyCellValue, className, footerHeight, }: DataGridProps<Data, SortField>): JSX.Element;
@@ -6,8 +6,9 @@ import { DataGridBody } from './DataGridBody';
6
6
  import DataGridLoader from './DataGridLoader/DataGridLoader';
7
7
  import { DataGridNoData } from './DataGridNoData';
8
8
  import { DataGridContainer, StyledTableContainer } from './styles';
9
- export function DataGrid({ columns, rows = [], selectedRows = [], sorting, maxHeight, minDisplayRows = 10, onRowClick, onSelectRow, Footer, noDataPlaceholder, loading, onSort, keyId, emptyCellValue, }) {
9
+ export function DataGrid({ columns, rows = [], selectedRows = [], sorting, maxHeight, minDisplayRows = 10, onRowClick, onSelectRow, Footer, noDataPlaceholder, loading, onSort, keyId, emptyCellValue, className, footerHeight = 50, }) {
10
10
  const selectable = Boolean(onSelectRow);
11
+ const withFooter = Boolean(Footer);
11
12
  const handleSelectAllRows = (event) => {
12
13
  if (!onSelectRow) {
13
14
  return;
@@ -37,5 +38,5 @@ export function DataGrid({ columns, rows = [], selectedRows = [], sorting, maxHe
37
38
  }
38
39
  return null;
39
40
  }, [noDataPlaceholder, loading]);
40
- return (_jsxs(DataGridContainer, { children: [_jsxs(StyledTableContainer, Object.assign({ maxHeight: maxHeight }, { children: [_jsxs(Table, Object.assign({ stickyHeader: true }, { children: [_jsx(DataGridHead, { onSort: onSort, rowsCount: rows.length, uncheckedRowsCount: uncheckedRowsCount, onSelectAllRows: handleSelectAllRows, selectable: selectable, sorting: sorting, columns: columns }), _jsx(DataGridBody, { keyId: keyId, selectedRows: selectedRows, minDisplayRows: minDisplayRows, onRowClick: onRowClick, onSelectRow: handleSelectRow, selectable: selectable, rows: rows, columns: columns, emptyCellValue: emptyCellValue, noDataPlaceholder: renderedPlaceholder() })] })), _jsx(DataGridLoader, { loading: loading })] })), rows.length ? Footer : null] }));
41
+ return (_jsxs(DataGridContainer, Object.assign({ maxHeight: maxHeight, className: className }, { children: [_jsx(StyledTableContainer, { children: _jsxs(Table, Object.assign({ stickyHeader: true }, { children: [_jsx(DataGridHead, { onSort: onSort, rowsCount: rows.length, uncheckedRowsCount: uncheckedRowsCount, onSelectAllRows: handleSelectAllRows, selectable: selectable, sorting: sorting, columns: columns }), _jsx(DataGridBody, { keyId: keyId, selectedRows: selectedRows, minDisplayRows: minDisplayRows, onRowClick: onRowClick, onSelectRow: handleSelectRow, selectable: selectable, rows: rows, columns: columns, emptyCellValue: emptyCellValue, noDataPlaceholder: renderedPlaceholder() })] })) }), _jsx(DataGridLoader, { footerHeight: footerHeight, withFooter: withFooter, loading: loading }), Footer] })));
41
42
  }
@@ -6,5 +6,5 @@ export const StyledTableBody = styled(TableBody, {
6
6
  }) `
7
7
  position: relative;
8
8
 
9
- height: ${({ empty, minDisplayRows }) => empty ? `${TABLE_ROW_HEIGHT * minDisplayRows}px` : 'auto'};
9
+ height: ${({ empty, minDisplayRows }) => empty ? `${TABLE_ROW_HEIGHT * minDisplayRows}px` : '100%'};
10
10
  `;
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  export declare type DataGridLoaderProps = {
3
3
  loading?: boolean;
4
+ withFooter: boolean;
5
+ footerHeight: number;
4
6
  };
5
- declare const DataGridLoader: ({ loading }: DataGridLoaderProps) => JSX.Element;
7
+ declare const DataGridLoader: ({ loading, withFooter, footerHeight, }: DataGridLoaderProps) => JSX.Element;
6
8
  export default DataGridLoader;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Backdrop, LoaderWrapper, StyledDivider, StyledLinearProgress, } from './styles';
3
- const DataGridLoader = ({ loading = false }) => {
4
- return (_jsxs(LoaderWrapper, { children: [loading && _jsx(Backdrop, {}), loading ? _jsx(StyledLinearProgress, {}) : _jsx(StyledDivider, {})] }));
3
+ const DataGridLoader = ({ loading = false, withFooter, footerHeight, }) => {
4
+ return (_jsxs(LoaderWrapper, { children: [loading && (_jsx(Backdrop, { withFooter: withFooter, footerHeight: footerHeight })), loading && _jsx(StyledLinearProgress, {}), !loading && _jsx(StyledDivider, {})] }));
5
5
  };
6
6
  export default DataGridLoader;
@@ -1,8 +1,12 @@
1
1
  /// <reference types="react" />
2
+ declare type BackdropProps = {
3
+ withFooter: boolean;
4
+ footerHeight: number;
5
+ };
2
6
  export declare const Backdrop: import("@emotion/styled").StyledComponent<{
3
7
  theme?: import("@emotion/react").Theme | undefined;
4
8
  as?: import("react").ElementType<any> | undefined;
5
- }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
9
+ } & BackdropProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
10
  export declare const StyledDivider: import("@emotion/styled").StyledComponent<import("../../Divider").DividerProps & {
7
11
  theme?: import("@emotion/react").Theme | undefined;
8
12
  }, {}, {}>;
@@ -13,3 +17,4 @@ export declare const LoaderWrapper: import("@emotion/styled").StyledComponent<{
13
17
  export declare const StyledLinearProgress: import("@emotion/styled").StyledComponent<import("@mui/material").LinearProgressProps & {
14
18
  theme?: import("@emotion/react").Theme | undefined;
15
19
  }, {}, {}>;
20
+ export {};
@@ -6,7 +6,9 @@ export const Backdrop = styled.div `
6
6
  top: 0;
7
7
 
8
8
  width: 100%;
9
- height: 100%;
9
+
10
+ /* Если в DataGrid передан Footer, нужно чтобы Backdrop не перекрывал его в состоянии loading, поэтому тут его высота вычитается из всей высоты бэкдропа */
11
+ height: ${({ withFooter, footerHeight }) => withFooter ? `calc(100% - ${footerHeight}px) ` : '100%'};
10
12
 
11
13
  background-color: ${({ theme }) => theme.palette.grey['100']};
12
14
  opacity: 0.6;
@@ -2,6 +2,14 @@
2
2
  export declare const DataGridContainer: import("@emotion/styled").StyledComponent<{
3
3
  theme?: import("@emotion/react").Theme | undefined;
4
4
  as?: import("react").ElementType<any> | undefined;
5
+ } & {
6
+ children?: import("react").ReactNode;
7
+ classes?: Partial<import("@mui/material").TableContainerClasses> | undefined;
8
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
9
+ } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "css" | "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
10
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
11
+ }, "sx" | "children" | keyof import("@mui/material/OverridableComponent").CommonProps> & {
12
+ maxHeight?: number | undefined;
5
13
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
14
  export declare const StyledTableContainer: import("@emotion/styled").StyledComponent<import("../Table").TableContainerProps & {
7
15
  theme?: import("@emotion/react").Theme | undefined;
@@ -1,13 +1,17 @@
1
1
  import { styled } from '../styles';
2
2
  import { TableContainer } from '../Table';
3
3
  export const DataGridContainer = styled.div `
4
+ position: relative;
5
+
6
+ display: flex;
7
+ flex-direction: column;
4
8
  width: 100%;
9
+ height: 100%;
10
+ max-height: ${({ maxHeight }) => (maxHeight ? `${maxHeight}px` : 'initial')};
5
11
  overflow: hidden;
6
12
  `;
7
13
  export const StyledTableContainer = styled(TableContainer, {
8
14
  shouldForwardProp: (prop) => prop !== 'maxHeight',
9
15
  }) `
10
- position: relative;
11
-
12
- max-height: ${({ maxHeight }) => `${maxHeight}px` || 'auto'};
16
+ height: 100%;
13
17
  `;
@@ -10,7 +10,6 @@ export const NavMenuItemButtonRoot = styled(ListItemButton) `
10
10
  border-radius: ${({ theme }) => theme.shape.medium};
11
11
 
12
12
  .MuiListItemIcon-root {
13
-
14
13
  color: ${({ theme, selected }) => {
15
14
  return selected ? theme.palette.primary['800'] : 'inherit';
16
15
  }};
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "1.34.2",
3
+ "version": "1.36.0",
4
4
  "browser": "./esm/index.js",
5
5
  "main": "./index.js",
6
6
  "dependencies": {
7
- "@astral/icons": "^1.34.2",
7
+ "@astral/icons": "^1.36.0",
8
8
  "@emotion/cache": "11.7.1",
9
9
  "@emotion/react": "11.9.0",
10
10
  "@emotion/server": "11.4.0",