@mailstep/design-system 0.4.21 → 0.5.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/package.json +17 -4
- package/ui/Blocks/CommonGrid/CommonGrid.d.ts +3 -0
- package/ui/Blocks/CommonGrid/CommonGrid.js +115 -0
- package/ui/Blocks/CommonGrid/CommonGridContext.d.ts +12 -0
- package/ui/Blocks/CommonGrid/CommonGridContext.js +45 -0
- package/ui/Blocks/CommonGrid/HoC/withReduxActions.d.ts +2 -0
- package/ui/Blocks/CommonGrid/HoC/withReduxActions.js +36 -0
- package/ui/Blocks/CommonGrid/components/ActionColumnHead.d.ts +4 -0
- package/ui/Blocks/CommonGrid/components/ActionColumnHead.js +16 -0
- package/ui/Blocks/CommonGrid/components/ButtonStrip.d.ts +7 -0
- package/ui/Blocks/CommonGrid/components/ButtonStrip.js +35 -0
- package/ui/Blocks/CommonGrid/components/ColumnFilterCell.d.ts +11 -0
- package/ui/Blocks/CommonGrid/components/ColumnFilterCell.js +41 -0
- package/ui/Blocks/CommonGrid/components/ColumnTitle.d.ts +9 -0
- package/ui/Blocks/CommonGrid/components/ColumnTitle.js +20 -0
- package/ui/Blocks/CommonGrid/components/ConfigForm.d.ts +9 -0
- package/ui/Blocks/CommonGrid/components/ConfigForm.js +58 -0
- package/ui/Blocks/CommonGrid/components/DataCell.d.ts +11 -0
- package/ui/Blocks/CommonGrid/components/DataCell.js +52 -0
- package/ui/Blocks/CommonGrid/components/DataRow.d.ts +21 -0
- package/ui/Blocks/CommonGrid/components/DataRow.js +110 -0
- package/ui/Blocks/CommonGrid/components/DefaultPaginator.d.ts +3 -0
- package/ui/Blocks/CommonGrid/components/DefaultPaginator.js +11 -0
- package/ui/Blocks/CommonGrid/components/Dialog.d.ts +11 -0
- package/ui/Blocks/CommonGrid/components/Dialog.js +19 -0
- package/ui/Blocks/CommonGrid/components/DropdownMenu.d.ts +21 -0
- package/ui/Blocks/CommonGrid/components/DropdownMenu.js +59 -0
- package/ui/Blocks/CommonGrid/components/DropdownSelect.d.ts +15 -0
- package/ui/Blocks/CommonGrid/components/DropdownSelect.js +35 -0
- package/ui/Blocks/CommonGrid/components/FilterDropdown.d.ts +3 -0
- package/ui/Blocks/CommonGrid/components/FilterDropdown.js +36 -0
- package/ui/Blocks/CommonGrid/components/FilterRow.d.ts +15 -0
- package/ui/Blocks/CommonGrid/components/FilterRow.js +35 -0
- package/ui/Blocks/CommonGrid/components/FloatingButton.d.ts +6 -0
- package/ui/Blocks/CommonGrid/components/FloatingButton.js +13 -0
- package/ui/Blocks/CommonGrid/components/GroupRow.d.ts +9 -0
- package/ui/Blocks/CommonGrid/components/GroupRow.js +27 -0
- package/ui/Blocks/CommonGrid/components/HeadCell.d.ts +27 -0
- package/ui/Blocks/CommonGrid/components/HeadCell.js +43 -0
- package/ui/Blocks/CommonGrid/components/HeadRow.d.ts +15 -0
- package/ui/Blocks/CommonGrid/components/HeadRow.js +69 -0
- package/ui/Blocks/CommonGrid/components/OversizedScroll.d.ts +11 -0
- package/ui/Blocks/CommonGrid/components/OversizedScroll.js +24 -0
- package/ui/Blocks/CommonGrid/components/Resize.d.ts +7 -0
- package/ui/Blocks/CommonGrid/components/Resize.js +33 -0
- package/ui/Blocks/CommonGrid/components/Table.d.ts +16 -0
- package/ui/Blocks/CommonGrid/components/Table.js +30 -0
- package/ui/Blocks/CommonGrid/components/icons/ArrowSimple.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/icons/ArrowSimple.js +14 -0
- package/ui/Blocks/CommonGrid/components/icons/Edit.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/icons/Edit.js +14 -0
- package/ui/Blocks/CommonGrid/components/icons/EyeOpen.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/icons/EyeOpen.js +14 -0
- package/ui/Blocks/CommonGrid/components/icons/Sorting.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/icons/Sorting.js +14 -0
- package/ui/Blocks/CommonGrid/components/utils.d.ts +8 -0
- package/ui/Blocks/CommonGrid/components/utils.js +22 -0
- package/ui/Blocks/CommonGrid/hooks/useColumnSizes.d.ts +12 -0
- package/ui/Blocks/CommonGrid/hooks/useColumnSizes.js +83 -0
- package/ui/Blocks/CommonGrid/hooks/useControlButtons.d.ts +10 -0
- package/ui/Blocks/CommonGrid/hooks/useControlButtons.js +64 -0
- package/ui/Blocks/CommonGrid/hooks/useRowsKeyControls.d.ts +4 -0
- package/ui/Blocks/CommonGrid/hooks/useRowsKeyControls.js +21 -0
- package/ui/Blocks/CommonGrid/hooks/useUxReset.d.ts +3 -0
- package/ui/Blocks/CommonGrid/hooks/useUxReset.js +15 -0
- package/ui/Blocks/CommonGrid/index.d.ts +7 -0
- package/ui/Blocks/CommonGrid/index.js +7 -0
- package/ui/Blocks/CommonGrid/store/index.d.ts +58 -0
- package/ui/Blocks/CommonGrid/store/index.js +230 -0
- package/ui/Blocks/CommonGrid/store/migrateState.d.ts +3 -0
- package/ui/Blocks/CommonGrid/store/migrateState.js +14 -0
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.d.ts +11 -0
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.js +31 -0
- package/ui/Blocks/CommonGrid/storybook/stories/customControllButtons.stories.d.ts +13 -0
- package/ui/Blocks/CommonGrid/storybook/stories/customControllButtons.stories.js +49 -0
- package/ui/Blocks/CommonGrid/storybook/stories/default.stories.d.ts +6 -0
- package/ui/Blocks/CommonGrid/storybook/stories/default.stories.js +14 -0
- package/ui/Blocks/CommonGrid/storybook/stories/loading.stories.d.ts +10 -0
- package/ui/Blocks/CommonGrid/storybook/stories/loading.stories.js +11 -0
- package/ui/Blocks/CommonGrid/storybook/stories/manyColumnsNoScrollLayout.stories.d.ts +10 -0
- package/ui/Blocks/CommonGrid/storybook/stories/manyColumnsNoScrollLayout.stories.js +12 -0
- package/ui/Blocks/CommonGrid/storybook/stories/manyColumnsNormalLayout.stories.d.ts +10 -0
- package/ui/Blocks/CommonGrid/storybook/stories/manyColumnsNormalLayout.stories.js +12 -0
- package/ui/Blocks/CommonGrid/storybook/stories/styledCommonGrid.stories.d.ts +6 -0
- package/ui/Blocks/CommonGrid/storybook/stories/styledCommonGrid.stories.js +15 -0
- package/ui/Blocks/CommonGrid/storybook/stories/withCustomGridActions.stories.d.ts +10 -0
- package/ui/Blocks/CommonGrid/storybook/stories/withCustomGridActions.stories.js +15 -0
- package/ui/Blocks/CommonGrid/storybook/stories/withForcedCheckboxes.stories.d.ts +14 -0
- package/ui/Blocks/CommonGrid/storybook/stories/withForcedCheckboxes.stories.js +24 -0
- package/ui/Blocks/CommonGrid/storybook/utils/actions.d.ts +4 -0
- package/ui/Blocks/CommonGrid/storybook/utils/actions.js +6 -0
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.d.ts +10 -0
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.js +97 -0
- package/ui/Blocks/CommonGrid/storybook/utils/filters.d.ts +2 -0
- package/ui/Blocks/CommonGrid/storybook/utils/filters.js +23 -0
- package/ui/Blocks/CommonGrid/storybook/utils/utils.d.ts +17 -0
- package/ui/Blocks/CommonGrid/storybook/utils/utils.js +66 -0
- package/ui/Blocks/CommonGrid/storybook/utils/withRedux.d.ts +2 -0
- package/ui/Blocks/CommonGrid/storybook/utils/withRedux.js +12 -0
- package/ui/Blocks/CommonGrid/storybook/utils/withRouter.d.ts +2 -0
- package/ui/Blocks/CommonGrid/storybook/utils/withRouter.js +4 -0
- package/ui/Blocks/CommonGrid/storybook/utils/withTheme.d.ts +2 -0
- package/ui/Blocks/CommonGrid/storybook/utils/withTheme.js +18 -0
- package/ui/Blocks/CommonGrid/types.d.ts +299 -0
- package/ui/Blocks/CommonGrid/types.js +8 -0
- package/ui/Blocks/CommonGrid/utils/index.d.ts +17 -0
- package/ui/Blocks/CommonGrid/utils/index.js +60 -0
- package/ui/Blocks/CommonGrid/utils/public.d.ts +16 -0
- package/ui/Blocks/CommonGrid/utils/public.js +52 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import React from 'react';
|
|
12
|
+
export var oversizedArrayColumns = 25;
|
|
13
|
+
export var enumValues = ['option A', 'option B', 'option C'];
|
|
14
|
+
var ComplexCell = function (props) {
|
|
15
|
+
var handleActionClick = React.useCallback(function () {
|
|
16
|
+
if (props.onRowAction)
|
|
17
|
+
props.onRowAction(props.rowData.id, 'get_invoice', null);
|
|
18
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
+
}, [props.rowData, props.onRowAction]);
|
|
20
|
+
return _jsxs("button", { onClick: handleActionClick, children: [" download ", props.rowData.id, " "] });
|
|
21
|
+
};
|
|
22
|
+
export var oversizedColumnDefinition = new Array(oversizedArrayColumns).fill(null).map(function (unused, index) { return ({
|
|
23
|
+
name: "column_".concat(index),
|
|
24
|
+
title: "column_".concat(index),
|
|
25
|
+
flexBasis: 120,
|
|
26
|
+
}); });
|
|
27
|
+
export var enumColumn = {
|
|
28
|
+
name: 'enumColumn',
|
|
29
|
+
title: 'Enum Column',
|
|
30
|
+
flexBasis: 160,
|
|
31
|
+
filterOptions: __spreadArray([{ value: '', label: 'all' }], enumValues.map(function (v) { return ({ value: v, label: v }); }), true),
|
|
32
|
+
filtering: true,
|
|
33
|
+
sorting: false,
|
|
34
|
+
};
|
|
35
|
+
export var columnDefinitions = [
|
|
36
|
+
{
|
|
37
|
+
name: 'textColumn',
|
|
38
|
+
title: 'Text column',
|
|
39
|
+
flexBasis: 160,
|
|
40
|
+
filtering: true,
|
|
41
|
+
sorting: true,
|
|
42
|
+
},
|
|
43
|
+
enumColumn,
|
|
44
|
+
{
|
|
45
|
+
name: 'numberColumn',
|
|
46
|
+
title: 'Number Column',
|
|
47
|
+
flexBasis: 160,
|
|
48
|
+
filtering: true,
|
|
49
|
+
filteringType: 'number',
|
|
50
|
+
sorting: true,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'dateColumn',
|
|
54
|
+
group: 'group1',
|
|
55
|
+
title: 'Date Column',
|
|
56
|
+
flexBasis: 160,
|
|
57
|
+
filtering: true,
|
|
58
|
+
filteringType: 'date',
|
|
59
|
+
sorting: true,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'boolColumn',
|
|
63
|
+
group: 'group1',
|
|
64
|
+
title: 'Bool Column',
|
|
65
|
+
flexBasis: 160,
|
|
66
|
+
filtering: true,
|
|
67
|
+
filteringType: 'flag',
|
|
68
|
+
sorting: true,
|
|
69
|
+
formatRowValue: function (row) {
|
|
70
|
+
return row.boolColumn ? 'Yes' : 'No';
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'advancedColumn',
|
|
75
|
+
group: 'group2',
|
|
76
|
+
title: 'Advanced Column',
|
|
77
|
+
flexBasis: 160,
|
|
78
|
+
formatRowValue: function (row) {
|
|
79
|
+
return "".concat((row.numberColumn / 4) * row.textColumn.length);
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'complexColumn',
|
|
84
|
+
group: 'group2',
|
|
85
|
+
title: 'Complex Column',
|
|
86
|
+
flexBasis: 350,
|
|
87
|
+
cellComponent: ComplexCell,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'stickyColumn',
|
|
91
|
+
title: 'Sticky Column',
|
|
92
|
+
flexBasis: 160,
|
|
93
|
+
alwaysOn: true,
|
|
94
|
+
sticky: true,
|
|
95
|
+
stickTo: 'right',
|
|
96
|
+
},
|
|
97
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
var DefaultSelect = function (props) { return (_jsx("select", __assign({ multiple: props.isMulti }, props, { children: (props.options || []).map(function (_a) {
|
|
14
|
+
var value = _a.value, label = _a.label;
|
|
15
|
+
return (_jsx("option", { value: value, children: label }, value));
|
|
16
|
+
}) }))); };
|
|
17
|
+
export var filters = {
|
|
18
|
+
options: { CellComponent: DefaultSelect },
|
|
19
|
+
number: { CellComponent: function () { return _jsx("input", { type: "number" }); } },
|
|
20
|
+
text: { CellComponent: function () { return _jsx("input", { type: "text" }); } },
|
|
21
|
+
date: { CellComponent: function () { return _jsx("input", { type: "date" }); } },
|
|
22
|
+
flag: { CellComponent: function () { return _jsx("input", { type: "text" }); } },
|
|
23
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GridActionsType, rowClassSymbol } from '../../types';
|
|
2
|
+
export declare const enumValues: string[];
|
|
3
|
+
export declare const oversizedArrayColumns = 25;
|
|
4
|
+
export declare const gridSelectors: {};
|
|
5
|
+
export declare const createRandomData: (count: number) => {
|
|
6
|
+
id: string;
|
|
7
|
+
stickyColumn: string;
|
|
8
|
+
textColumn: string;
|
|
9
|
+
enumColumn: string;
|
|
10
|
+
numberColumn: number;
|
|
11
|
+
dateColumn: string;
|
|
12
|
+
boolColumn: boolean;
|
|
13
|
+
[rowClassSymbol]: string | undefined;
|
|
14
|
+
}[];
|
|
15
|
+
export declare const gridDummyActions: Required<GridActionsType>;
|
|
16
|
+
export declare const createOversizedRandomData: (count: number) => any[];
|
|
17
|
+
export declare const ReduxGrid: (props: any) => JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
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 React from 'react';
|
|
14
|
+
import faker from 'faker';
|
|
15
|
+
import { rowClassSymbol } from '../../types';
|
|
16
|
+
import withReduxActions from '../../HoC/withReduxActions';
|
|
17
|
+
import CommonGrid from '../../CommonGrid';
|
|
18
|
+
export var enumValues = ['option A', 'option B', 'option C'];
|
|
19
|
+
export var oversizedArrayColumns = 25;
|
|
20
|
+
export var gridSelectors = {};
|
|
21
|
+
/**
|
|
22
|
+
* randomly returns given data or undefined. used to simulate optional pros on object data types
|
|
23
|
+
*/
|
|
24
|
+
function makeOptional(fakerData, chance) {
|
|
25
|
+
chance = chance || 0.5;
|
|
26
|
+
return Math.random() < chance ? fakerData : undefined;
|
|
27
|
+
}
|
|
28
|
+
export var createRandomData = function (count) {
|
|
29
|
+
return new Array(count).fill(null).map(function () {
|
|
30
|
+
var _a;
|
|
31
|
+
return (_a = {
|
|
32
|
+
id: faker.random.uuid(),
|
|
33
|
+
stickyColumn: faker.random.word(),
|
|
34
|
+
textColumn: faker.random.word(),
|
|
35
|
+
enumColumn: enumValues[faker.random.number({ min: 0, max: 2 })],
|
|
36
|
+
numberColumn: faker.random.number(),
|
|
37
|
+
dateColumn: faker.date.recent().toISOString(),
|
|
38
|
+
boolColumn: faker.random.boolean()
|
|
39
|
+
},
|
|
40
|
+
_a[rowClassSymbol] = makeOptional('foo'),
|
|
41
|
+
_a);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
export var gridDummyActions = {
|
|
45
|
+
// @see types for full list of actions
|
|
46
|
+
setPage: function (number) { return console.log('setPage', number); },
|
|
47
|
+
setRowsPerPage: function (number) { return console.log('setRowsPerPage', number); },
|
|
48
|
+
addFilter: function (column, value, filterProps) {
|
|
49
|
+
return console.log('setRowsPerPage', column, value, filterProps);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
export var createOversizedRandomData = function (count) {
|
|
53
|
+
return new Array(count).fill(null).map(function () {
|
|
54
|
+
var newData = {
|
|
55
|
+
id: "".concat(faker.random.uuid()),
|
|
56
|
+
};
|
|
57
|
+
for (var index = 0; index < oversizedArrayColumns; index++) {
|
|
58
|
+
newData["column_".concat(index)] = faker.name.lastName();
|
|
59
|
+
}
|
|
60
|
+
return newData;
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
export var ReduxGrid = function (props) {
|
|
64
|
+
var WithActions = React.useMemo(function () { return withReduxActions('storybookGrid')(CommonGrid); }, []);
|
|
65
|
+
return _jsx(WithActions, __assign({}, props));
|
|
66
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Provider } from 'react-redux';
|
|
3
|
+
import { combineReducers, createStore } from 'redux';
|
|
4
|
+
import commonGridReducer from '../../store';
|
|
5
|
+
export var withProvider = function (story) {
|
|
6
|
+
var reducers = combineReducers({
|
|
7
|
+
commonGrid: commonGridReducer,
|
|
8
|
+
});
|
|
9
|
+
var store = createStore(reducers);
|
|
10
|
+
return _jsx(Provider, { store: store, children: story() });
|
|
11
|
+
};
|
|
12
|
+
export default withProvider;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import Theme from '@designSystem/Theme'
|
|
4
|
+
import Normalize, { NormalizeBaseFonts } from '@designSystem/Normalize'
|
|
5
|
+
|
|
6
|
+
const withProvider = (story: Function): JSX.Element => (
|
|
7
|
+
<Theme>
|
|
8
|
+
<Normalize />
|
|
9
|
+
<NormalizeBaseFonts />
|
|
10
|
+
{story()}
|
|
11
|
+
</Theme>
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
export default withProvider
|
|
15
|
+
*/
|
|
16
|
+
// @TODO do theme
|
|
17
|
+
var withProvider = function (story) { return (story()); };
|
|
18
|
+
export default withProvider;
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const rowClassSymbol: unique symbol;
|
|
3
|
+
type Option = {
|
|
4
|
+
value: string | number;
|
|
5
|
+
label: string | number;
|
|
6
|
+
};
|
|
7
|
+
type TranslatorPublicInterfaceProps = {
|
|
8
|
+
id?: string;
|
|
9
|
+
defaults?: string;
|
|
10
|
+
};
|
|
11
|
+
type ButtonPublicInterfaceProps = {
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
type?: 'button' | 'submit' | 'reset';
|
|
14
|
+
appearance?: string;
|
|
15
|
+
isLoading?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
margin?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
onClick?: (arg?: any) => void;
|
|
20
|
+
};
|
|
21
|
+
type CheckboxPublicInterfaceProps = {
|
|
22
|
+
name?: string;
|
|
23
|
+
label?: string | JSX.Element;
|
|
24
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
25
|
+
checked?: boolean;
|
|
26
|
+
};
|
|
27
|
+
type SwitchPublicInterfaceProps = {
|
|
28
|
+
onChange?: (event: React.ChangeEvent) => void;
|
|
29
|
+
label?: string;
|
|
30
|
+
name: string;
|
|
31
|
+
checked?: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type PaginatorProps = {
|
|
34
|
+
page: number;
|
|
35
|
+
itemCount: number;
|
|
36
|
+
itemPerPage: number;
|
|
37
|
+
onPageChange: (number: number) => void;
|
|
38
|
+
};
|
|
39
|
+
export type FilterComponentProps<VT> = {
|
|
40
|
+
name: string;
|
|
41
|
+
onChange: (value: VT | {
|
|
42
|
+
event: {
|
|
43
|
+
target: VT;
|
|
44
|
+
};
|
|
45
|
+
} | null) => void;
|
|
46
|
+
value: VT | null;
|
|
47
|
+
OverlayComponent: React.FunctionComponent;
|
|
48
|
+
};
|
|
49
|
+
export type ColumnTitleComponentType = React.ComponentType<{
|
|
50
|
+
title?: string | JSX.Element;
|
|
51
|
+
isSortable: boolean;
|
|
52
|
+
onSetSort: (value: SortingValueType) => void;
|
|
53
|
+
sortValue: SortingValueType;
|
|
54
|
+
}>;
|
|
55
|
+
export type ComponentsProps = {
|
|
56
|
+
Translator: React.ComponentType<TranslatorPublicInterfaceProps>;
|
|
57
|
+
Checkbox: React.ComponentType<CheckboxPublicInterfaceProps>;
|
|
58
|
+
Button: React.ComponentType<ButtonPublicInterfaceProps>;
|
|
59
|
+
Switch: React.ComponentType<SwitchPublicInterfaceProps>;
|
|
60
|
+
Paginator: React.ComponentType<PaginatorProps>;
|
|
61
|
+
ColumnTitle?: ColumnTitleComponentType;
|
|
62
|
+
};
|
|
63
|
+
export type FiltersConfig = {
|
|
64
|
+
[name: string]: {
|
|
65
|
+
CellComponent: React.ComponentType<FilterComponentProps<any>>;
|
|
66
|
+
defaultExtraProps?: {
|
|
67
|
+
[name: string]: any;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
type Filtering = {
|
|
72
|
+
[column: string]: {
|
|
73
|
+
value: any;
|
|
74
|
+
filterProps: FilterProps;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
type Sorting = {
|
|
78
|
+
column: string;
|
|
79
|
+
direction: SortingValueType;
|
|
80
|
+
}[];
|
|
81
|
+
export type Settings = {
|
|
82
|
+
filter: Filtering;
|
|
83
|
+
sorting: Sorting;
|
|
84
|
+
offset: number;
|
|
85
|
+
limit: number;
|
|
86
|
+
};
|
|
87
|
+
export interface SelectMenuItem {
|
|
88
|
+
label: string;
|
|
89
|
+
value: string | number;
|
|
90
|
+
labelInList?: string;
|
|
91
|
+
disabled?: boolean;
|
|
92
|
+
}
|
|
93
|
+
export type RowProps = {
|
|
94
|
+
id: string;
|
|
95
|
+
[rowClassSymbol]?: string;
|
|
96
|
+
};
|
|
97
|
+
type ColumnBaseProps = {
|
|
98
|
+
flexBasis: number;
|
|
99
|
+
};
|
|
100
|
+
export type RowValueType = string | JSX.Element | number | void;
|
|
101
|
+
export type ColumnDefinition<ColumnName extends string = string> = ColumnBaseProps & {
|
|
102
|
+
name: ColumnName;
|
|
103
|
+
group?: Group['name'];
|
|
104
|
+
systemName?: string;
|
|
105
|
+
systemFilter?: string;
|
|
106
|
+
title?: string | JSX.Element;
|
|
107
|
+
filtering?: boolean;
|
|
108
|
+
filteringType?: 'number' | 'text' | 'date' | 'flag';
|
|
109
|
+
disableRowTouch?: boolean;
|
|
110
|
+
filterExtraProps?: {
|
|
111
|
+
isMulti?: boolean;
|
|
112
|
+
comparators?: any;
|
|
113
|
+
filterTime?: boolean;
|
|
114
|
+
decimals?: number;
|
|
115
|
+
isFloat?: boolean;
|
|
116
|
+
isBigInt?: boolean;
|
|
117
|
+
isUuid?: boolean;
|
|
118
|
+
defaultComparator?: string;
|
|
119
|
+
};
|
|
120
|
+
getFilterCriteria?: (value: string) => {
|
|
121
|
+
[column: string]: any;
|
|
122
|
+
} | null;
|
|
123
|
+
filterOptions?: Option[];
|
|
124
|
+
sorting?: boolean;
|
|
125
|
+
formatRowValue?: (row: any) => RowValueType;
|
|
126
|
+
cellComponent?: React.ComponentType<DataCellProps<any>>;
|
|
127
|
+
flexGrow?: number;
|
|
128
|
+
flexShrink?: number;
|
|
129
|
+
fixedSize?: boolean;
|
|
130
|
+
alwaysOn?: boolean;
|
|
131
|
+
defaultHidden?: boolean;
|
|
132
|
+
sticky?: boolean;
|
|
133
|
+
stickTo?: StickTo;
|
|
134
|
+
};
|
|
135
|
+
export type StickTo = 'left' | 'right';
|
|
136
|
+
type batchAction = {
|
|
137
|
+
value: string;
|
|
138
|
+
label: string;
|
|
139
|
+
isEnabled?: (checkedRows: any[]) => boolean;
|
|
140
|
+
};
|
|
141
|
+
export type OnBatchActionFn<T = RowProps> = (action: batchAction, affectedRows: T[]) => void;
|
|
142
|
+
export type ActionColumn = ColumnBaseProps & {
|
|
143
|
+
actionOptions?: batchAction[];
|
|
144
|
+
canRowEdit?: boolean | ((row: any) => boolean);
|
|
145
|
+
canRowRead?: boolean | ((row: any) => boolean);
|
|
146
|
+
createLink?: (params?: object) => string;
|
|
147
|
+
forceCheckboxes?: boolean;
|
|
148
|
+
checkAllPosition?: 'top' | 'bottom';
|
|
149
|
+
addRowNumbers?: boolean;
|
|
150
|
+
addRowNumbersLabel?: string;
|
|
151
|
+
};
|
|
152
|
+
export type ActionColumnHeadProps = {
|
|
153
|
+
actionColumn: ActionColumn;
|
|
154
|
+
onBatchAction?: OnBatchActionFn;
|
|
155
|
+
handleUxChange?: GridActionsType['handleUxChange'];
|
|
156
|
+
rowsData: RowProps[];
|
|
157
|
+
uxState: UxState;
|
|
158
|
+
};
|
|
159
|
+
export type DataCellProps<T> = {
|
|
160
|
+
rowData: T;
|
|
161
|
+
onRowAction?: (id: string, field: string, value: any) => void | Promise<any>;
|
|
162
|
+
column: ColumnDefinition;
|
|
163
|
+
};
|
|
164
|
+
type SingleColumnConfig = {
|
|
165
|
+
isHidden?: boolean;
|
|
166
|
+
};
|
|
167
|
+
export type ColumnConfig = {
|
|
168
|
+
[key: string]: SingleColumnConfig;
|
|
169
|
+
};
|
|
170
|
+
export type SortingValueType = 'asc' | 'desc' | null;
|
|
171
|
+
export type InitProps = {
|
|
172
|
+
defaultSorting?: Settings['sorting'];
|
|
173
|
+
};
|
|
174
|
+
export type FilterProps = {
|
|
175
|
+
type: Required<ColumnDefinition>['filteringType'] | 'options';
|
|
176
|
+
filterExtraProps: ColumnDefinition['filterExtraProps'];
|
|
177
|
+
computedValue?: any;
|
|
178
|
+
};
|
|
179
|
+
export type UxState = {
|
|
180
|
+
checkedRows?: {
|
|
181
|
+
[key: string]: boolean;
|
|
182
|
+
};
|
|
183
|
+
selectedRow?: string | null;
|
|
184
|
+
};
|
|
185
|
+
export type ColumnLayout = 'normal' | 'no-scroll' | 'sticky';
|
|
186
|
+
export type GridState = {
|
|
187
|
+
page: number;
|
|
188
|
+
rowsPerPage: number;
|
|
189
|
+
filter: Settings['filter'];
|
|
190
|
+
sorting: Settings['sorting'];
|
|
191
|
+
defaultSorting: Settings['sorting'];
|
|
192
|
+
isConfigFormOpen: boolean;
|
|
193
|
+
uxState: UxState;
|
|
194
|
+
columnConfig: ColumnConfig;
|
|
195
|
+
columnsOrder: string[];
|
|
196
|
+
columnsWidth: {
|
|
197
|
+
[anyKey: string]: number;
|
|
198
|
+
};
|
|
199
|
+
columnsWidthVariant?: string;
|
|
200
|
+
};
|
|
201
|
+
export type GridSelectorsType = {
|
|
202
|
+
uxState?: UxState;
|
|
203
|
+
columnConfig?: ColumnConfig;
|
|
204
|
+
page?: number;
|
|
205
|
+
rowsPerPage?: number;
|
|
206
|
+
filter?: Settings['filter'];
|
|
207
|
+
sorting?: Settings['sorting'];
|
|
208
|
+
isConfigFormOpen?: boolean;
|
|
209
|
+
columnsWidth?: {
|
|
210
|
+
[anyColumn: string]: number;
|
|
211
|
+
};
|
|
212
|
+
columnsWidthVariant?: string;
|
|
213
|
+
columnsOrder?: string[];
|
|
214
|
+
};
|
|
215
|
+
export type RowsPerPageType = {
|
|
216
|
+
gridName: string;
|
|
217
|
+
rowsPerPage: number;
|
|
218
|
+
type: string;
|
|
219
|
+
};
|
|
220
|
+
export type GridActionsType = {
|
|
221
|
+
init?: (params?: InitProps) => void;
|
|
222
|
+
clearUxState?: () => void;
|
|
223
|
+
handleUxChange?: (uxKey: keyof UxState, uxValue: any) => void;
|
|
224
|
+
setColumnConfig?: (columnConfig: ColumnConfig) => void | Promise<any>;
|
|
225
|
+
setPage?: (number: number) => void;
|
|
226
|
+
setRowsPerPage?: (number: number) => RowsPerPageType | null;
|
|
227
|
+
addFilter?: (column: string, value: any, filterProps: FilterProps) => void;
|
|
228
|
+
resetFilters?: () => void;
|
|
229
|
+
addSorting?: (column: string, direction: SortingValueType) => void;
|
|
230
|
+
openConfigForm?: () => void;
|
|
231
|
+
closeConfigForm?: () => void;
|
|
232
|
+
clearSettings?: () => void;
|
|
233
|
+
resetGrid?: () => void;
|
|
234
|
+
setColumnWidth?: (columnsWidth: null | {
|
|
235
|
+
[anyColumn: string]: number;
|
|
236
|
+
}, columnLayout: ColumnLayout) => void;
|
|
237
|
+
setColumnsOrder?: (columnsOrder: string[]) => void;
|
|
238
|
+
};
|
|
239
|
+
export type AsyncFilters = {
|
|
240
|
+
[anyColumn: string]: Option[];
|
|
241
|
+
};
|
|
242
|
+
export type CommonGridProps<TData extends RowProps = RowProps> = {
|
|
243
|
+
components?: ComponentsProps;
|
|
244
|
+
filters?: FiltersConfig;
|
|
245
|
+
gridSelectors: GridSelectorsType;
|
|
246
|
+
gridActions: GridActionsType;
|
|
247
|
+
isLoading?: boolean;
|
|
248
|
+
rowsData: TData[];
|
|
249
|
+
hasColouredRows?: boolean;
|
|
250
|
+
columnsDefinitions: ColumnDefinition[];
|
|
251
|
+
actionColumnDefinition?: ActionColumn;
|
|
252
|
+
totalRowsCount?: number;
|
|
253
|
+
allowRowSelect?: boolean;
|
|
254
|
+
allowRowSelectOnAction?: boolean;
|
|
255
|
+
onRowAction?: (id: string, field: string, value: any) => void;
|
|
256
|
+
onRowEditClick?: (id: string, props: TData) => void;
|
|
257
|
+
onRowReadClick?: (id: string, props: TData) => void;
|
|
258
|
+
onRowClick?: (id: string, props: TData) => void;
|
|
259
|
+
onBatchAction?: OnBatchActionFn;
|
|
260
|
+
columnLayout?: ColumnLayout;
|
|
261
|
+
confirmOnReset?: () => boolean;
|
|
262
|
+
hideColumnConfig?: boolean;
|
|
263
|
+
hideAllControls?: boolean;
|
|
264
|
+
className?: string;
|
|
265
|
+
gridRef?: React.MutableRefObject<HTMLElement>;
|
|
266
|
+
minColumnWidth?: number;
|
|
267
|
+
errorMessage?: string;
|
|
268
|
+
extraControlButtons?: ExtraControlButton[];
|
|
269
|
+
perPageOptions?: number[];
|
|
270
|
+
floatingButton?: JSX.Element;
|
|
271
|
+
};
|
|
272
|
+
export declare enum ExtraControlButtonPosition {
|
|
273
|
+
TopLeft = "top-left",
|
|
274
|
+
TopRight = "top-right",
|
|
275
|
+
BottomLeft = "bottom-left",
|
|
276
|
+
BottomRight = "bottom-right"
|
|
277
|
+
}
|
|
278
|
+
export type ExtraControlButton = {
|
|
279
|
+
node?: React.ReactNode;
|
|
280
|
+
onClick?: () => void;
|
|
281
|
+
onSelect?: (value: string | number) => void;
|
|
282
|
+
label?: string | JSX.Element;
|
|
283
|
+
style?: 'primary' | 'secondary';
|
|
284
|
+
options?: {
|
|
285
|
+
label: string | JSX.Element;
|
|
286
|
+
value?: string | number;
|
|
287
|
+
onClick?: () => void;
|
|
288
|
+
}[];
|
|
289
|
+
position?: ExtraControlButtonPosition;
|
|
290
|
+
hide?: boolean;
|
|
291
|
+
hideChevron?: boolean;
|
|
292
|
+
disabled?: boolean;
|
|
293
|
+
};
|
|
294
|
+
export type Group = {
|
|
295
|
+
name?: string;
|
|
296
|
+
start: boolean;
|
|
297
|
+
end: boolean;
|
|
298
|
+
};
|
|
299
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var rowClassSymbol = Symbol();
|
|
2
|
+
export var ExtraControlButtonPosition;
|
|
3
|
+
(function (ExtraControlButtonPosition) {
|
|
4
|
+
ExtraControlButtonPosition["TopLeft"] = "top-left";
|
|
5
|
+
ExtraControlButtonPosition["TopRight"] = "top-right";
|
|
6
|
+
ExtraControlButtonPosition["BottomLeft"] = "bottom-left";
|
|
7
|
+
ExtraControlButtonPosition["BottomRight"] = "bottom-right";
|
|
8
|
+
})(ExtraControlButtonPosition || (ExtraControlButtonPosition = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ColumnDefinition, ActionColumn, ColumnConfig, FilterProps, Group, StickTo } from '../types';
|
|
2
|
+
export declare const getActionCellSizeProps: (column: ActionColumn) => object;
|
|
3
|
+
export declare const getCellSizeProps: (column: ColumnDefinition, columnWidth: number) => object;
|
|
4
|
+
export declare const getSortName: (column: ColumnDefinition) => string;
|
|
5
|
+
export declare const getFilterName: (column: ColumnDefinition) => string;
|
|
6
|
+
export declare const isColumnOn: (column: ColumnDefinition, columnConfig?: ColumnConfig) => boolean;
|
|
7
|
+
export declare const calculatePaginator: (page: number, rowsPerPage: number) => {
|
|
8
|
+
offset: number;
|
|
9
|
+
limit: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const createFilterType: (columnDefinition: {
|
|
12
|
+
filterOptions?: ColumnDefinition['filterOptions'];
|
|
13
|
+
filteringType?: ColumnDefinition['filteringType'];
|
|
14
|
+
}) => FilterProps['type'];
|
|
15
|
+
export declare const getGroups: (columns: ColumnDefinition[]) => Group[];
|
|
16
|
+
export declare const getGroupClassNames: (group?: Group) => string;
|
|
17
|
+
export declare const getStickyCollClassNames: (sticky: boolean, stickTo?: StickTo) => string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var isDefined = function (val) { return typeof val !== 'undefined'; };
|
|
2
|
+
export var getActionCellSizeProps = function (column) {
|
|
3
|
+
return {
|
|
4
|
+
flexBasis: column.flexBasis,
|
|
5
|
+
flexGrow: 0,
|
|
6
|
+
flexShrink: 0,
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export var getCellSizeProps = function (column, columnWidth) {
|
|
10
|
+
if (!column)
|
|
11
|
+
return {};
|
|
12
|
+
var fixedSize = column.fixedSize, flexGrow = column.flexGrow, flexShrink = column.flexShrink, sticky = column.sticky;
|
|
13
|
+
return {
|
|
14
|
+
flexBasis: columnWidth,
|
|
15
|
+
flexGrow: fixedSize ? 0 : isDefined(flexGrow) ? flexGrow : 1,
|
|
16
|
+
flexShrink: isDefined(flexShrink) ? flexShrink : 1,
|
|
17
|
+
maxWidth: sticky ? columnWidth : 'auto',
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export var getSortName = function (column) {
|
|
21
|
+
return column.systemName || column.name;
|
|
22
|
+
};
|
|
23
|
+
export var getFilterName = function (column) {
|
|
24
|
+
return column.systemFilter || column.systemName || column.name;
|
|
25
|
+
};
|
|
26
|
+
export var isColumnOn = function (column, columnConfig) {
|
|
27
|
+
var _a;
|
|
28
|
+
if (column.alwaysOn)
|
|
29
|
+
return true;
|
|
30
|
+
var isHidden = (_a = columnConfig === null || columnConfig === void 0 ? void 0 : columnConfig[column.name]) === null || _a === void 0 ? void 0 : _a.isHidden;
|
|
31
|
+
if (typeof isHidden === 'boolean')
|
|
32
|
+
return !isHidden; // isHidden is defined/stored => use user value
|
|
33
|
+
return !column.defaultHidden; // isHidden is undefined => use default value
|
|
34
|
+
};
|
|
35
|
+
export var calculatePaginator = function (page, rowsPerPage) { return ({
|
|
36
|
+
offset: rowsPerPage ? rowsPerPage * (page - 1) : rowsPerPage,
|
|
37
|
+
limit: rowsPerPage,
|
|
38
|
+
}); };
|
|
39
|
+
export var createFilterType = function (columnDefinition) {
|
|
40
|
+
if (columnDefinition.filterOptions)
|
|
41
|
+
return 'options';
|
|
42
|
+
else
|
|
43
|
+
return columnDefinition.filteringType || 'text';
|
|
44
|
+
};
|
|
45
|
+
export var getGroups = function (columns) {
|
|
46
|
+
return columns.map(function (column, key) {
|
|
47
|
+
var previousGroup = key > 0 && columns[key - 1].group;
|
|
48
|
+
return {
|
|
49
|
+
name: column.group,
|
|
50
|
+
start: !!(column.group && (!previousGroup || (previousGroup && previousGroup !== column.group))),
|
|
51
|
+
end: !!(column.group && (!columns[key + 1] || columns[key + 1].group !== column.group)),
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
export var getGroupClassNames = function (group) {
|
|
56
|
+
return "".concat((group === null || group === void 0 ? void 0 : group.start) ? 'group-start' : '', " ").concat((group === null || group === void 0 ? void 0 : group.end) ? 'group-end' : '');
|
|
57
|
+
};
|
|
58
|
+
export var getStickyCollClassNames = function (sticky, stickTo) {
|
|
59
|
+
return !sticky ? '' : "".concat(stickTo ? " sticky sticky-".concat(stickTo) : ' sticky sticky-left');
|
|
60
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RowProps, GridActionsType, ColumnDefinition, UxState, ActionColumn, OnBatchActionFn } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* hook for checkbox that select and unselects all row
|
|
4
|
+
* returns [checked state, toggleAllHandler()] for checkbox
|
|
5
|
+
*/
|
|
6
|
+
type ToggleAllCheckboxRet = [boolean, () => void];
|
|
7
|
+
export declare const useToggleAllCheckbox: (rowsData: RowProps[], uxState: UxState, handleUxChange?: GridActionsType['handleUxChange']) => ToggleAllCheckboxRet;
|
|
8
|
+
/**
|
|
9
|
+
* hook for action selection and trigger
|
|
10
|
+
* returns [subset of actions that are enabled, onSelect(value) - param1: selected action value]
|
|
11
|
+
*/
|
|
12
|
+
type GridActionTriggerRet = [Required<ActionColumn>['actionOptions'], (value: any) => void];
|
|
13
|
+
export declare const useGridActionTrigger: (rowsData: RowProps[], uxState: UxState, actionOptions?: ActionColumn['actionOptions'], onBatchAction?: OnBatchActionFn) => GridActionTriggerRet;
|
|
14
|
+
type AddFilterRet = (value: any, column: ColumnDefinition) => void;
|
|
15
|
+
export declare const useAddFilter: (onChange: Required<GridActionsType>['addFilter']) => AddFilterRet;
|
|
16
|
+
export {};
|