flipper-ui 0.24.12 → 0.25.2
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/core/Advertise.d.ts +4 -11
- package/core/AutoComplete.d.ts +3 -3
- package/core/Avatar.d.ts +3 -3
- package/core/Badge.d.ts +4 -4
- package/core/Box.d.ts +3 -3
- package/core/Button.d.ts +3 -3
- package/core/Card.d.ts +7 -7
- package/core/Checkbox.d.ts +3 -3
- package/core/Chip.d.ts +3 -3
- package/core/ChipField.d.ts +2 -2
- package/core/Collapse.d.ts +3 -3
- package/core/Container.d.ts +2 -2
- package/core/Content.d.ts +2 -2
- package/core/DataTable/DataTable.d.ts +61 -0
- package/core/DataTable/DataTable.js +254 -0
- package/core/DataTable/DataTableAction.d.ts +8 -0
- package/core/DataTable/DataTableAction.js +28 -0
- package/core/DataTable/DataTablePaginationActions.d.ts +13 -0
- package/core/DataTable/DataTablePaginationActions.js +76 -0
- package/core/DataTable/Rows.d.ts +17 -0
- package/core/DataTable/Rows.js +198 -0
- package/core/DataTable/index.d.ts +6 -0
- package/core/DataTable/index.js +31 -0
- package/core/DataTable/types.d.ts +103 -0
- package/core/DataTable/types.js +15 -0
- package/core/DataTable/useRowsState.d.ts +8 -0
- package/core/DataTable/useRowsState.js +153 -0
- package/core/DateTime.d.ts +3 -3
- package/core/Dialog.d.ts +3 -3
- package/core/Divider.d.ts +3 -3
- package/core/Drawer.d.ts +4 -4
- package/core/EditableTable.d.ts +2 -2
- package/core/EditableTable.js +8 -10
- package/core/ExpansionPanel.d.ts +3 -3
- package/core/Fab.d.ts +3 -3
- package/core/Fade.d.ts +3 -3
- package/core/Grow.d.ts +3 -3
- package/core/Header.d.ts +3 -3
- package/core/IconButton.d.ts +3 -3
- package/core/InputAdornment.d.ts +3 -3
- package/core/InputBase.d.ts +3 -3
- package/core/Line.d.ts +3 -3
- package/core/List.d.ts +3 -3
- package/core/ListItem.d.ts +3 -3
- package/core/MaskField.d.ts +4 -4
- package/core/Menu.d.ts +4 -4
- package/core/Node.d.ts +3 -3
- package/core/Pagination.d.ts +3 -3
- package/core/Paper.d.ts +3 -3
- package/core/Progress.d.ts +3 -3
- package/core/Radio.d.ts +3 -3
- package/core/RadioGroup.d.ts +4 -4
- package/core/Select.d.ts +5 -3
- package/core/Select.js +42 -13
- package/core/Sidebar.d.ts +5 -5
- package/core/Sidebar.js +2 -1
- package/core/Slide.d.ts +3 -3
- package/core/Slider.d.ts +3 -3
- package/core/Snackbar.d.ts +3 -3
- package/core/Stepper.d.ts +3 -3
- package/core/Tab.d.ts +3 -3
- package/core/Table.d.ts +5 -5
- package/core/TableBody.d.ts +2 -2
- package/core/TableCell.d.ts +5 -5
- package/core/TableHead.d.ts +3 -3
- package/core/TableRow.d.ts +4 -4
- package/core/Tabs.d.ts +3 -3
- package/core/TextField.d.ts +8 -6
- package/core/TextField.js +62 -15
- package/core/ThemeProvider.d.ts +2 -2
- package/core/Tooltip.d.ts +3 -3
- package/core/Tree.d.ts +2 -2
- package/core/Typography.d.ts +2 -2
- package/core/Zoom.d.ts +3 -3
- package/core/types.d.ts +9 -0
- package/core/types.js +1 -0
- package/package.json +84 -79
- package/stories/Advertise.stories.js +31 -0
- package/stories/AutoComplete.stories.js +133 -0
- package/stories/AutoCompleteLab.stories.js +64 -0
- package/stories/Avatar.stories.js +44 -0
- package/stories/Badge.stories.js +63 -0
- package/stories/Box.stories.js +29 -0
- package/stories/Breadcrumb.stories.js +41 -0
- package/stories/Button.stories.js +132 -0
- package/stories/Card.stories.js +43 -0
- package/stories/Checkbox.stories.js +98 -0
- package/stories/Chip.stories.js +72 -0
- package/stories/ChipField.stories.js +60 -0
- package/stories/Collapse.stories.js +70 -0
- package/stories/Container.stories.js +24 -0
- package/stories/Content.stories.js +28 -0
- package/stories/DataTable.stories.js +737 -0
- package/stories/Dialog.stories.js +82 -0
- package/stories/Divider.stories.js +46 -0
- package/stories/Drawer.stories.js +55 -0
- package/stories/EditTable.stories.js +149 -0
- package/stories/ExpansionPanel.stories.js +54 -0
- package/stories/Fab.stories.js +28 -0
- package/stories/Fade.stories.js +54 -0
- package/stories/Grow.stories.js +63 -0
- package/stories/Header.stories.js +41 -0
- package/stories/IconButton.stories.js +48 -0
- package/stories/InputAdornment.stories.js +28 -0
- package/stories/InputBase.stories.js +54 -0
- package/stories/Line.stories.js +35 -0
- package/stories/List.stories.js +112 -0
- package/stories/MaskField.stories.js +58 -0
- package/stories/Menu.stories.js +82 -0
- package/stories/Node.stories.js +39 -0
- package/stories/Pagination.stories.js +39 -0
- package/stories/Paper.stories.js +65 -0
- package/stories/Progress.stories.js +86 -0
- package/stories/Radio.stories.js +52 -0
- package/stories/RadioGroup.stories.js +47 -0
- package/stories/Select.stories.js +100 -0
- package/stories/Sidebar.stories.js +43 -0
- package/stories/Slide.stories.js +62 -0
- package/stories/Slider.stories.js +69 -0
- package/stories/Snackbar.stories.js +102 -0
- package/stories/Stepper.stories.js +43 -0
- package/stories/Table.stories.js +32 -0
- package/stories/Tabs.stories.js +37 -0
- package/stories/TextField.stories.js +151 -0
- package/stories/Tooltip.stories.js +129 -0
- package/stories/Tree.stories.js +45 -0
- package/stories/Typography.stories.js +130 -0
- package/stories/Zooms.stories.js +54 -0
- package/docz/Wrapper.js +0 -20
package/core/Advertise.d.ts
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import { FC
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
className?: string;
|
|
5
|
-
margin?: number | string;
|
|
6
|
-
padding?: number | string;
|
|
7
|
-
name?: string;
|
|
8
|
-
id?: string;
|
|
9
|
-
}
|
|
10
|
-
interface IProps extends IDefault {
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import type { DefaultProps } from './types';
|
|
3
|
+
interface AdvertiseProps extends DefaultProps {
|
|
11
4
|
comment: string;
|
|
12
5
|
author: string;
|
|
13
6
|
commentStyle?: object;
|
|
14
7
|
authorStyle?: object;
|
|
15
8
|
}
|
|
16
|
-
declare const Advertise: FC<
|
|
9
|
+
declare const Advertise: FC<AdvertiseProps>;
|
|
17
10
|
export default Advertise;
|
package/core/AutoComplete.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode, FC, ChangeEvent, KeyboardEvent, CSSProperties, Ref, FocusEvent } from 'react';
|
|
2
|
-
interface
|
|
2
|
+
interface AutoCompleteProps {
|
|
3
3
|
autoFocus?: boolean;
|
|
4
4
|
defaultIsOpen?: boolean;
|
|
5
5
|
openOnFocus?: boolean;
|
|
@@ -8,7 +8,7 @@ interface IProps {
|
|
|
8
8
|
fade?: boolean;
|
|
9
9
|
focusDelay?: number;
|
|
10
10
|
suggestions: ISelected[];
|
|
11
|
-
value
|
|
11
|
+
value?: TSelected;
|
|
12
12
|
defaultValue?: string;
|
|
13
13
|
style?: CSSProperties;
|
|
14
14
|
maxHeight?: number;
|
|
@@ -36,5 +36,5 @@ interface ISelected {
|
|
|
36
36
|
subheader?: boolean;
|
|
37
37
|
}
|
|
38
38
|
declare type TSelected = ISelected | string;
|
|
39
|
-
declare const AutoComplete: FC<
|
|
39
|
+
declare const AutoComplete: FC<AutoCompleteProps>;
|
|
40
40
|
export default AutoComplete;
|
package/core/Avatar.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
interface
|
|
2
|
+
import type { DefaultProps } from './types';
|
|
3
|
+
interface AvatarProps extends DefaultProps {
|
|
4
4
|
name?: string;
|
|
5
5
|
id?: string;
|
|
6
6
|
sizes?: string;
|
|
@@ -8,5 +8,5 @@ interface IProps extends IDefault {
|
|
|
8
8
|
imgProps?: object;
|
|
9
9
|
primary?: boolean;
|
|
10
10
|
}
|
|
11
|
-
declare const Avatar: FC<
|
|
11
|
+
declare const Avatar: FC<AvatarProps>;
|
|
12
12
|
export default Avatar;
|
package/core/Badge.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
interface
|
|
2
|
+
import { BadgeProps as MuiBadgeProps } from '@material-ui/core/Badge';
|
|
3
|
+
import type { DefaultProps } from './types';
|
|
4
|
+
interface BadgeProps extends DefaultProps, MuiBadgeProps {
|
|
5
5
|
max?: number;
|
|
6
6
|
counter: number | string;
|
|
7
7
|
position?: {
|
|
@@ -11,5 +11,5 @@ interface IProps extends IDefault, BadgeProps {
|
|
|
11
11
|
right?: number;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
declare const Badge: FC<
|
|
14
|
+
declare const Badge: FC<BadgeProps>;
|
|
15
15
|
export default Badge;
|
package/core/Box.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
interface
|
|
2
|
+
import type { DefaultProps } from './types';
|
|
3
|
+
interface BoxProps extends DefaultProps {
|
|
4
4
|
minHeight?: number;
|
|
5
5
|
}
|
|
6
|
-
declare const Box: FC<
|
|
6
|
+
declare const Box: FC<BoxProps>;
|
|
7
7
|
export default Box;
|
package/core/Button.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC, ElementType, MouseEvent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export interface
|
|
2
|
+
import { DefaultProps } from './types';
|
|
3
|
+
export interface ButtonProps extends DefaultProps {
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
selected?: boolean;
|
|
6
6
|
disableTouchRipple?: boolean;
|
|
@@ -13,5 +13,5 @@ export interface IProps extends IDefault {
|
|
|
13
13
|
target?: string;
|
|
14
14
|
onClick?(event: MouseEvent<HTMLButtonElement>): void;
|
|
15
15
|
}
|
|
16
|
-
declare const Button: FC<
|
|
16
|
+
declare const Button: FC<ButtonProps>;
|
|
17
17
|
export default Button;
|
package/core/Card.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { DefaultProps } from './types';
|
|
3
3
|
import { CardProps } from '@material-ui/core/Card';
|
|
4
4
|
import { CardActionAreaProps } from '@material-ui/core/CardActionArea';
|
|
5
5
|
import { CardActionsProps } from '@material-ui/core/CardActions';
|
|
6
6
|
import { CardContentProps } from '@material-ui/core/CardContent';
|
|
7
7
|
import { CardMediaProps } from '@material-ui/core/CardMedia';
|
|
8
8
|
import { CardHeaderProps } from '@material-ui/core/CardHeader';
|
|
9
|
-
export declare const CardActionArea: FC<
|
|
10
|
-
export declare const CardActions: FC<
|
|
11
|
-
export declare const CardContent: FC<
|
|
12
|
-
export declare const CardMedia: FC<
|
|
13
|
-
export declare const CardHeader: FC<
|
|
14
|
-
declare const Card: FC<
|
|
9
|
+
export declare const CardActionArea: FC<DefaultProps & CardActionAreaProps>;
|
|
10
|
+
export declare const CardActions: FC<DefaultProps & CardActionsProps>;
|
|
11
|
+
export declare const CardContent: FC<DefaultProps & CardContentProps>;
|
|
12
|
+
export declare const CardMedia: FC<DefaultProps & CardMediaProps>;
|
|
13
|
+
export declare const CardHeader: FC<DefaultProps & CardHeaderProps>;
|
|
14
|
+
declare const Card: FC<DefaultProps & CardProps>;
|
|
15
15
|
export default Card;
|
package/core/Checkbox.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ChangeEvent, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
interface
|
|
2
|
+
import { DefaultProps } from './types';
|
|
3
|
+
interface CheckboxProps extends DefaultProps {
|
|
4
4
|
name: string;
|
|
5
5
|
label?: ReactNode;
|
|
6
6
|
color?: 'primary' | 'secondary' | 'default';
|
|
@@ -13,5 +13,5 @@ interface IProps extends IDefault {
|
|
|
13
13
|
onHelperClick?: () => void;
|
|
14
14
|
onChange?: (event: ChangeEvent<HTMLElement>) => void;
|
|
15
15
|
}
|
|
16
|
-
declare const Checkbox: (props:
|
|
16
|
+
declare const Checkbox: (props: CheckboxProps) => JSX.Element;
|
|
17
17
|
export default Checkbox;
|
package/core/Chip.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { DefaultProps } from './types';
|
|
3
3
|
import { ChipProps } from '@material-ui/core/Chip';
|
|
4
|
-
interface
|
|
4
|
+
interface IChipProps extends DefaultProps {
|
|
5
5
|
square?: boolean;
|
|
6
6
|
}
|
|
7
|
-
declare const Chip: FC<ChipProps &
|
|
7
|
+
declare const Chip: FC<ChipProps & IChipProps>;
|
|
8
8
|
export default Chip;
|
package/core/ChipField.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChipRenderer } from 'material-ui-chip-input';
|
|
3
3
|
import { InputLabelProps } from '@material-ui/core';
|
|
4
|
-
interface
|
|
4
|
+
interface ChipFieldProps<T extends TChipValues> {
|
|
5
5
|
allowDuplicates?: boolean;
|
|
6
6
|
values: T[];
|
|
7
7
|
variant?: 'outlined' | 'standard' | 'filled';
|
|
@@ -20,5 +20,5 @@ interface IProps<T extends TChipValues> {
|
|
|
20
20
|
export declare type TChipValues = {
|
|
21
21
|
value: string | number;
|
|
22
22
|
};
|
|
23
|
-
declare const ChipField: <T extends TChipValues>(props:
|
|
23
|
+
declare const ChipField: <T extends TChipValues>(props: ChipFieldProps<T>) => JSX.Element;
|
|
24
24
|
export default ChipField;
|
package/core/Collapse.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
interface
|
|
2
|
+
import { DefaultProps } from './types';
|
|
3
|
+
interface CollapseProps extends DefaultProps {
|
|
4
4
|
collapsedHeight?: string;
|
|
5
5
|
in: boolean;
|
|
6
6
|
timeout?: number | {
|
|
@@ -8,5 +8,5 @@ interface IProps extends IDefault {
|
|
|
8
8
|
exit?: number;
|
|
9
9
|
} | 'auto';
|
|
10
10
|
}
|
|
11
|
-
declare const Collapse: FC<
|
|
11
|
+
declare const Collapse: FC<CollapseProps>;
|
|
12
12
|
export default Collapse;
|
package/core/Container.d.ts
CHANGED
package/core/Content.d.ts
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { MutableRefObject, CSSProperties } from 'react';
|
|
2
|
+
import { ColumnSpec, Data, DataTableController, Errors, PaginationOptions, RowViewComponent, StackView } from './types';
|
|
3
|
+
export declare type DataTableProps<D extends Data, V extends StackView = {}> = {
|
|
4
|
+
/**
|
|
5
|
+
* The data to be shown in the table
|
|
6
|
+
*/
|
|
7
|
+
data: D[];
|
|
8
|
+
/**
|
|
9
|
+
* Errors as an object where the key is the ID of the row and the value is
|
|
10
|
+
* a Set with the fields of error
|
|
11
|
+
*/
|
|
12
|
+
errors?: Errors<D>;
|
|
13
|
+
/**
|
|
14
|
+
* The columns specification
|
|
15
|
+
*/
|
|
16
|
+
columns: ColumnSpec<D>[];
|
|
17
|
+
/**
|
|
18
|
+
* Hide the table header
|
|
19
|
+
*/
|
|
20
|
+
noHeader?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Component to show when there are no data
|
|
23
|
+
*/
|
|
24
|
+
componentForEmpty?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Custom style to be applied to the table body
|
|
27
|
+
*/
|
|
28
|
+
bodyStyle?: CSSProperties;
|
|
29
|
+
/**
|
|
30
|
+
* Custom style to be applied to the table head
|
|
31
|
+
*/
|
|
32
|
+
headStyle?: CSSProperties;
|
|
33
|
+
/**
|
|
34
|
+
* Custom style to be applied to all rows of the table body
|
|
35
|
+
*/
|
|
36
|
+
bodyRowStyle?: CSSProperties;
|
|
37
|
+
/**
|
|
38
|
+
* Custom style to be applied to all rows of the table head
|
|
39
|
+
*/
|
|
40
|
+
headRowStyle?: CSSProperties;
|
|
41
|
+
/**
|
|
42
|
+
* Height of a hidden row, when you need to have some blank space in case
|
|
43
|
+
* you fill in the pagination.rowsPerPage
|
|
44
|
+
*/
|
|
45
|
+
hiddenRowHeight?: number;
|
|
46
|
+
/**
|
|
47
|
+
* The pagination configuration
|
|
48
|
+
*/
|
|
49
|
+
pagination?: Partial<PaginationOptions>;
|
|
50
|
+
/**
|
|
51
|
+
* A React MutableRefObject for the row controller
|
|
52
|
+
*/
|
|
53
|
+
controllerRef?: MutableRefObject<DataTableController<D, V> | undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* Custom rowViews used as a Stac
|
|
56
|
+
*/
|
|
57
|
+
rowViews?: Record<keyof V, RowViewComponent<D>>;
|
|
58
|
+
onRowClick?: (event: React.MouseEvent<HTMLTableRowElement>, rowData: D) => void;
|
|
59
|
+
};
|
|
60
|
+
export declare const DataTable: <D extends Data, V extends Record<string, unknown>>(props: DataTableProps<D, V>) => JSX.Element;
|
|
61
|
+
export default DataTable;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = exports.DataTable = void 0;
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
18
|
+
var _last = _interopRequireDefault(require("ramda/es/last"));
|
|
19
|
+
|
|
20
|
+
var _Table = _interopRequireDefault(require("@material-ui/core/Table"));
|
|
21
|
+
|
|
22
|
+
var _TableBody = _interopRequireDefault(require("@material-ui/core/TableBody"));
|
|
23
|
+
|
|
24
|
+
var _TableCell = _interopRequireDefault(require("@material-ui/core/TableCell"));
|
|
25
|
+
|
|
26
|
+
var _TableContainer = _interopRequireDefault(require("@material-ui/core/TableContainer"));
|
|
27
|
+
|
|
28
|
+
var _TableHead = _interopRequireDefault(require("@material-ui/core/TableHead"));
|
|
29
|
+
|
|
30
|
+
var _TableRow = _interopRequireDefault(require("@material-ui/core/TableRow"));
|
|
31
|
+
|
|
32
|
+
var _Paper = _interopRequireDefault(require("@material-ui/core/Paper"));
|
|
33
|
+
|
|
34
|
+
var _TablePagination = _interopRequireDefault(require("@material-ui/core/TablePagination"));
|
|
35
|
+
|
|
36
|
+
var _TableFooter = _interopRequireDefault(require("@material-ui/core/TableFooter"));
|
|
37
|
+
|
|
38
|
+
var _types = require("./types");
|
|
39
|
+
|
|
40
|
+
var _useRowsState2 = require("./useRowsState");
|
|
41
|
+
|
|
42
|
+
var _Rows = require("./Rows");
|
|
43
|
+
|
|
44
|
+
var _DataTablePaginationActions = require("./DataTablePaginationActions");
|
|
45
|
+
|
|
46
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
47
|
+
|
|
48
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
49
|
+
|
|
50
|
+
var defaultPagination = {
|
|
51
|
+
rowsPerPage: 10,
|
|
52
|
+
labelRowsPerPage: 'Rows per page:',
|
|
53
|
+
labelDisplayedRows: function labelDisplayedRows(_ref) {
|
|
54
|
+
var from = _ref.from,
|
|
55
|
+
to = _ref.to,
|
|
56
|
+
count = _ref.count;
|
|
57
|
+
return "".concat(from, "-").concat(to, " of ").concat(count !== -1 ? count : "more than ".concat(to));
|
|
58
|
+
},
|
|
59
|
+
disabled: false,
|
|
60
|
+
showFirstButton: false,
|
|
61
|
+
showLastButton: false,
|
|
62
|
+
rowsPerPageOptions: [5, 10, 20]
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
var sliceData = function sliceData(data, page, rowsPerPage) {
|
|
66
|
+
var start = page * rowsPerPage;
|
|
67
|
+
var end = start + rowsPerPage;
|
|
68
|
+
return data.slice(start, end);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
var DataTable = function DataTable(props) {
|
|
72
|
+
var _useState = (0, _react.useState)(0),
|
|
73
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
74
|
+
page = _useState2[0],
|
|
75
|
+
setPage = _useState2[1];
|
|
76
|
+
|
|
77
|
+
var pagination = _objectSpread(_objectSpread({}, defaultPagination), props.pagination);
|
|
78
|
+
|
|
79
|
+
var _useState3 = (0, _react.useState)(pagination.rowsPerPage),
|
|
80
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
81
|
+
rowsPerPage = _useState4[0],
|
|
82
|
+
setRowsPerPage = _useState4[1];
|
|
83
|
+
|
|
84
|
+
var data = props.data,
|
|
85
|
+
columns = props.columns,
|
|
86
|
+
rowViews = props.rowViews,
|
|
87
|
+
onRowClick = props.onRowClick,
|
|
88
|
+
controllerRef = props.controllerRef,
|
|
89
|
+
noHeader = props.noHeader,
|
|
90
|
+
bodyRowStyle = props.bodyRowStyle,
|
|
91
|
+
headRowStyle = props.headRowStyle,
|
|
92
|
+
errors = props.errors,
|
|
93
|
+
componentForEmpty = props.componentForEmpty,
|
|
94
|
+
bodyStyle = props.bodyStyle,
|
|
95
|
+
headStyle = props.headStyle,
|
|
96
|
+
hiddenRowHeight = props.hiddenRowHeight;
|
|
97
|
+
|
|
98
|
+
var _useState5 = (0, _react.useState)(),
|
|
99
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
100
|
+
newRow = _useState6[0],
|
|
101
|
+
setNewRow = _useState6[1];
|
|
102
|
+
|
|
103
|
+
var rows = (0, _react.useMemo)(function () {
|
|
104
|
+
if (pagination.disabled) {
|
|
105
|
+
return data;
|
|
106
|
+
} // this case is not good for the useRowsMode hook
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
if (newRow && page === 0) {
|
|
110
|
+
return sliceData(data, page, rowsPerPage - 1);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return sliceData(data, page, rowsPerPage);
|
|
114
|
+
}, [pagination.disabled, data, rowsPerPage, page, newRow]);
|
|
115
|
+
|
|
116
|
+
var _useRowsState = (0, _useRowsState2.useRowsState)(rows, newRow),
|
|
117
|
+
getRowState = _useRowsState.getRowState,
|
|
118
|
+
setEditableRowState = _useRowsState.setEditableRowState,
|
|
119
|
+
setRowState = _useRowsState.setRowState,
|
|
120
|
+
pushRowView = _useRowsState.pushRowView,
|
|
121
|
+
popRowView = _useRowsState.popRowView;
|
|
122
|
+
|
|
123
|
+
var controller = (0, _react.useRef)();
|
|
124
|
+
(0, _react.useEffect)(function () {
|
|
125
|
+
var nextController = {
|
|
126
|
+
editRow: function editRow(id) {
|
|
127
|
+
setRowState(id, {
|
|
128
|
+
mode: _types.RowMode.Edit
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
viewRow: function viewRow(id) {
|
|
132
|
+
setRowState(id, {
|
|
133
|
+
mode: _types.RowMode.View
|
|
134
|
+
});
|
|
135
|
+
setNewRow(undefined);
|
|
136
|
+
},
|
|
137
|
+
addRow: function addRow(partial) {
|
|
138
|
+
setPage(0);
|
|
139
|
+
setNewRow(partial);
|
|
140
|
+
},
|
|
141
|
+
getEditedRowData: function getEditedRowData(id) {
|
|
142
|
+
var _getRowState;
|
|
143
|
+
|
|
144
|
+
return _objectSpread({
|
|
145
|
+
id: id
|
|
146
|
+
}, (_getRowState = getRowState(id)) === null || _getRowState === void 0 ? void 0 : _getRowState.editableState);
|
|
147
|
+
},
|
|
148
|
+
getRowData: function getRowData(id) {
|
|
149
|
+
var raw = getRowState(id);
|
|
150
|
+
return {
|
|
151
|
+
edited: _objectSpread({
|
|
152
|
+
id: id
|
|
153
|
+
}, raw === null || raw === void 0 ? void 0 : raw.editableState),
|
|
154
|
+
current: raw === null || raw === void 0 ? void 0 : raw.currentState
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
pushRowView: pushRowView,
|
|
158
|
+
popRowView: popRowView
|
|
159
|
+
};
|
|
160
|
+
controller.current = nextController;
|
|
161
|
+
|
|
162
|
+
if (controllerRef) {
|
|
163
|
+
controllerRef.current = nextController;
|
|
164
|
+
}
|
|
165
|
+
}, [setRowState, pushRowView, popRowView, getRowState, controllerRef]);
|
|
166
|
+
var rowsList = (0, _react.useMemo)(function () {
|
|
167
|
+
return rows.map(function (row) {
|
|
168
|
+
var rowState = getRowState(row.id);
|
|
169
|
+
var lastView = (rowState === null || rowState === void 0 ? void 0 : rowState.stackView) && (0, _last["default"])(rowState.stackView);
|
|
170
|
+
var view = lastView && (rowViews === null || rowViews === void 0 ? void 0 : rowViews[lastView]);
|
|
171
|
+
var mode = (rowState === null || rowState === void 0 ? void 0 : rowState.mode) || _types.RowMode.View;
|
|
172
|
+
return /*#__PURE__*/_react["default"].createElement(_TableRow["default"], {
|
|
173
|
+
key: row.id,
|
|
174
|
+
"data-id": row.id,
|
|
175
|
+
style: bodyRowStyle,
|
|
176
|
+
onClick: function onClick(event) {
|
|
177
|
+
return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(event, row);
|
|
178
|
+
}
|
|
179
|
+
}, view ? view({
|
|
180
|
+
data: row
|
|
181
|
+
}) : /*#__PURE__*/_react["default"].createElement(_Rows.StatefulRow, {
|
|
182
|
+
columns: columns,
|
|
183
|
+
data: row,
|
|
184
|
+
errors: errors,
|
|
185
|
+
mode: mode,
|
|
186
|
+
onUpdate: setEditableRowState(row.id)
|
|
187
|
+
}));
|
|
188
|
+
});
|
|
189
|
+
}, [rows, getRowState, onRowClick, setEditableRowState, errors, rowViews, bodyRowStyle, columns]);
|
|
190
|
+
var columnsList = (0, _react.useMemo)(function () {
|
|
191
|
+
return columns.map(function (column) {
|
|
192
|
+
return /*#__PURE__*/_react["default"].createElement(_TableCell["default"], {
|
|
193
|
+
key: column.title,
|
|
194
|
+
variant: "head",
|
|
195
|
+
style: column.headerStyle,
|
|
196
|
+
align: column.align
|
|
197
|
+
}, column.title);
|
|
198
|
+
});
|
|
199
|
+
}, [columns]);
|
|
200
|
+
var currentRowsNumber = rows.length + (newRow ? 1 : 0);
|
|
201
|
+
var hiddenRowsNumber = pagination.disabled ? 0 : rowsPerPage - currentRowsNumber;
|
|
202
|
+
|
|
203
|
+
var hiddenRowFiller = hiddenRowsNumber !== 0 && /*#__PURE__*/_react["default"].createElement(_TableRow["default"], {
|
|
204
|
+
style: bodyRowStyle
|
|
205
|
+
}, /*#__PURE__*/_react["default"].createElement(_TableCell["default"], {
|
|
206
|
+
colSpan: columns.length,
|
|
207
|
+
padding: "none",
|
|
208
|
+
style: {
|
|
209
|
+
height: hiddenRowHeight && "".concat(hiddenRowHeight * hiddenRowsNumber, "px")
|
|
210
|
+
}
|
|
211
|
+
}));
|
|
212
|
+
|
|
213
|
+
var rowsElements = /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (newRow === null || newRow === void 0 ? void 0 : newRow.id) && /*#__PURE__*/_react["default"].createElement(_Rows.NewRow, {
|
|
214
|
+
data: newRow,
|
|
215
|
+
errors: errors,
|
|
216
|
+
columns: columns,
|
|
217
|
+
onUpdate: setEditableRowState(newRow.id)
|
|
218
|
+
}), rowsList);
|
|
219
|
+
|
|
220
|
+
var paginationActionsComponent = (0, _react.useMemo)(function () {
|
|
221
|
+
return (0, _DataTablePaginationActions.makeDataTablePaginationActions)({
|
|
222
|
+
showFirstButton: pagination.showFirstButton,
|
|
223
|
+
showLastButton: pagination.showLastButton
|
|
224
|
+
});
|
|
225
|
+
}, [pagination.showFirstButton, pagination.showLastButton]);
|
|
226
|
+
return /*#__PURE__*/_react["default"].createElement(_TableContainer["default"], {
|
|
227
|
+
component: _Paper["default"]
|
|
228
|
+
}, /*#__PURE__*/_react["default"].createElement(_Table["default"], null, !noHeader && /*#__PURE__*/_react["default"].createElement(_TableHead["default"], {
|
|
229
|
+
style: headStyle
|
|
230
|
+
}, /*#__PURE__*/_react["default"].createElement(_TableRow["default"], {
|
|
231
|
+
style: headRowStyle
|
|
232
|
+
}, columnsList)), /*#__PURE__*/_react["default"].createElement(_TableBody["default"], {
|
|
233
|
+
style: bodyStyle
|
|
234
|
+
}, currentRowsNumber === 0 ? componentForEmpty : rowsElements, hiddenRowFiller), !pagination.disabled && /*#__PURE__*/_react["default"].createElement(_TableFooter["default"], null, /*#__PURE__*/_react["default"].createElement(_TableRow["default"], null, /*#__PURE__*/_react["default"].createElement(_TablePagination["default"], {
|
|
235
|
+
count: data.length,
|
|
236
|
+
page: page,
|
|
237
|
+
rowsPerPageOptions: pagination.rowsPerPageOptions,
|
|
238
|
+
rowsPerPage: rowsPerPage,
|
|
239
|
+
labelRowsPerPage: pagination.labelRowsPerPage,
|
|
240
|
+
labelDisplayedRows: pagination.labelDisplayedRows,
|
|
241
|
+
onChangePage: function onChangePage(_, page) {
|
|
242
|
+
setPage(page);
|
|
243
|
+
},
|
|
244
|
+
onChangeRowsPerPage: function onChangeRowsPerPage(event) {
|
|
245
|
+
setRowsPerPage(parseInt(event.target.value, 10));
|
|
246
|
+
setPage(0);
|
|
247
|
+
},
|
|
248
|
+
ActionsComponent: paginationActionsComponent
|
|
249
|
+
})))));
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
exports.DataTable = DataTable;
|
|
253
|
+
var _default = DataTable;
|
|
254
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export declare type DataTableActionProps = {
|
|
3
|
+
label: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
color?: 'primary' | 'secondary' | 'inherit' | 'default';
|
|
6
|
+
onClick(): void;
|
|
7
|
+
};
|
|
8
|
+
export declare const DataTableAction: ({ label, children, color, onClick }: DataTableActionProps) => JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.DataTableAction = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
|
|
13
|
+
|
|
14
|
+
var DataTableAction = function DataTableAction(_ref) {
|
|
15
|
+
var label = _ref.label,
|
|
16
|
+
children = _ref.children,
|
|
17
|
+
_ref$color = _ref.color,
|
|
18
|
+
color = _ref$color === void 0 ? 'default' : _ref$color,
|
|
19
|
+
onClick = _ref.onClick;
|
|
20
|
+
return /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
21
|
+
size: "small",
|
|
22
|
+
color: color,
|
|
23
|
+
"aria-label": label,
|
|
24
|
+
onClick: onClick
|
|
25
|
+
}, children);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.DataTableAction = DataTableAction;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface DataTablePaginationActionsProps {
|
|
3
|
+
count: number;
|
|
4
|
+
page: number;
|
|
5
|
+
rowsPerPage: number;
|
|
6
|
+
onChangePage(event: React.MouseEvent<HTMLButtonElement>, newPage: number): void;
|
|
7
|
+
}
|
|
8
|
+
interface DataTablePaginationActionsBuilder {
|
|
9
|
+
showFirstButton?: boolean;
|
|
10
|
+
showLastButton?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const makeDataTablePaginationActions: ({ showFirstButton, showLastButton }: DataTablePaginationActionsBuilder) => ({ count, page, rowsPerPage, onChangePage }: DataTablePaginationActionsProps) => JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.makeDataTablePaginationActions = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton/IconButton"));
|
|
13
|
+
|
|
14
|
+
var _FirstPage = _interopRequireDefault(require("@material-ui/icons/FirstPage"));
|
|
15
|
+
|
|
16
|
+
var _LastPage = _interopRequireDefault(require("@material-ui/icons/LastPage"));
|
|
17
|
+
|
|
18
|
+
var _KeyboardArrowLeft = _interopRequireDefault(require("@material-ui/icons/KeyboardArrowLeft"));
|
|
19
|
+
|
|
20
|
+
var _KeyboardArrowRight = _interopRequireDefault(require("@material-ui/icons/KeyboardArrowRight"));
|
|
21
|
+
|
|
22
|
+
/* eslint-disable @typescript-eslint/interface-name-prefix */
|
|
23
|
+
var PAGINATION_WRAPPER_STYLE = {
|
|
24
|
+
display: 'flex',
|
|
25
|
+
marginLeft: '12px'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var makeDataTablePaginationActions = function makeDataTablePaginationActions(_ref) {
|
|
29
|
+
var showFirstButton = _ref.showFirstButton,
|
|
30
|
+
showLastButton = _ref.showLastButton;
|
|
31
|
+
return function (_ref2) {
|
|
32
|
+
var count = _ref2.count,
|
|
33
|
+
page = _ref2.page,
|
|
34
|
+
rowsPerPage = _ref2.rowsPerPage,
|
|
35
|
+
onChangePage = _ref2.onChangePage;
|
|
36
|
+
var totalPages = Math.ceil(count / rowsPerPage) - 1;
|
|
37
|
+
|
|
38
|
+
var handleFirstPageButtonClick = function handleFirstPageButtonClick(event) {
|
|
39
|
+
onChangePage(event, 0);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var handleBackButtonClick = function handleBackButtonClick(event) {
|
|
43
|
+
onChangePage(event, page - 1);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var handleNextButtonClick = function handleNextButtonClick(event) {
|
|
47
|
+
onChangePage(event, page + 1);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var handleLastPageButtonClick = function handleLastPageButtonClick(event) {
|
|
51
|
+
onChangePage(event, Math.max(0, totalPages));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
55
|
+
style: PAGINATION_WRAPPER_STYLE
|
|
56
|
+
}, showFirstButton && /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
57
|
+
onClick: handleFirstPageButtonClick,
|
|
58
|
+
disabled: page === 0,
|
|
59
|
+
"aria-label": "first page"
|
|
60
|
+
}, /*#__PURE__*/_react["default"].createElement(_FirstPage["default"], null)), /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
61
|
+
onClick: handleBackButtonClick,
|
|
62
|
+
disabled: page === 0,
|
|
63
|
+
"aria-label": "previous page"
|
|
64
|
+
}, /*#__PURE__*/_react["default"].createElement(_KeyboardArrowLeft["default"], null)), /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
65
|
+
onClick: handleNextButtonClick,
|
|
66
|
+
disabled: page >= totalPages,
|
|
67
|
+
"aria-label": "next page"
|
|
68
|
+
}, /*#__PURE__*/_react["default"].createElement(_KeyboardArrowRight["default"], null)), showLastButton && /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
69
|
+
onClick: handleLastPageButtonClick,
|
|
70
|
+
disabled: page >= totalPages,
|
|
71
|
+
"aria-label": "last page"
|
|
72
|
+
}, /*#__PURE__*/_react["default"].createElement(_LastPage["default"], null)));
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
exports.makeDataTablePaginationActions = makeDataTablePaginationActions;
|