@evoke-platform/ui-components 1.0.0-dev.214 → 1.0.0-dev.216

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.
@@ -18,6 +18,7 @@ export declare type BuilderGridProps<T extends GridValidRowModel> = MuiDataGridP
18
18
  disablePagination?: boolean;
19
19
  hideEmptyContent?: boolean;
20
20
  hideToolbar?: boolean;
21
+ hideSearchbar?: boolean;
21
22
  noRowsOverlay?: React.ReactElement;
22
23
  filterComponent?: React.ReactElement;
23
24
  error?: number;
@@ -18,9 +18,9 @@ import { EmptyContent } from './EmptyContent';
18
18
  import ErrorComponent from '../ErrorComponent';
19
19
  const BuilderGrid = (props) => {
20
20
  var _a, _b, _c, _d, _e;
21
- const { loading, actions, item, rows, initialSort, emptyContentSelectOptions, emptyContentActionIndex, title, subtitle, disablePagination, hideEmptyContent, hideToolbar, noRowsOverlay, filterComponent, error } = props, rest = __rest(props, ["loading", "actions", "item", "rows", "initialSort", "emptyContentSelectOptions", "emptyContentActionIndex", "title", "subtitle", "disablePagination", "hideEmptyContent", "hideToolbar", "noRowsOverlay", "filterComponent", "error"]);
21
+ const { loading, actions, item, rows, initialSort, emptyContentSelectOptions, emptyContentActionIndex, title, subtitle, disablePagination, hideEmptyContent, hideToolbar, hideSearchbar, noRowsOverlay, filterComponent, error } = props, rest = __rest(props, ["loading", "actions", "item", "rows", "initialSort", "emptyContentSelectOptions", "emptyContentActionIndex", "title", "subtitle", "disablePagination", "hideEmptyContent", "hideToolbar", "hideSearchbar", "noRowsOverlay", "filterComponent", "error"]);
22
22
  const [anchorEl, setAnchorEl] = useState();
23
- const toolbar = useMemo(() => () => (React.createElement(BuilderGridToolbar, { loading: loading, actions: actions, title: title, subtitle: subtitle, filter: filterComponent })), [loading, actions]);
23
+ const toolbar = useMemo(() => () => (React.createElement(BuilderGridToolbar, { loading: loading, actions: actions, title: title, subtitle: subtitle, hideSearchbar: hideSearchbar, filter: filterComponent })), [loading, actions]);
24
24
  return (React.createElement(UIThemeProvider, null, loading || rows.length || hideEmptyContent ? (React.createElement(Box, { sx: {
25
25
  backgroundColor: '#fff',
26
26
  borderRadius: '6px',
@@ -6,6 +6,7 @@ export declare type BuilderGridToolbar = MuiGridToolbarProps & {
6
6
  title?: string;
7
7
  subtitle?: string;
8
8
  filter?: React.ReactElement;
9
+ hideSearchbar?: boolean;
9
10
  };
10
11
  declare function BuilderGridToolbar(props: BuilderGridToolbar): JSX.Element;
11
12
  export default BuilderGridToolbar;
@@ -1,4 +1,4 @@
1
- import { Box, Typography } from '@mui/material';
1
+ import { Typography } from '@mui/material';
2
2
  import { GridToolbarContainer, GridToolbarQuickFilter, } from '@mui/x-data-grid';
3
3
  import React from 'react';
4
4
  import UIThemeProvider from '../../../theme';
@@ -6,11 +6,13 @@ import { Grid } from '../../layout';
6
6
  import { ToolbarActions } from './ToolbarActions';
7
7
  function BuilderGridToolbar(props) {
8
8
  var _a, _b, _c;
9
- const { theme, actions, title, subtitle, filter } = props;
9
+ const { theme, actions, title, subtitle, filter, hideSearchbar } = props;
10
10
  const styles = {
11
11
  container: {
12
12
  display: 'flex',
13
13
  margin: '0 0 15px 0',
14
+ justifyContent: 'space-between',
15
+ width: '100%',
14
16
  },
15
17
  iconButton: {
16
18
  minWidth: '36px',
@@ -42,19 +44,18 @@ function BuilderGridToolbar(props) {
42
44
  };
43
45
  return (React.createElement(UIThemeProvider, { args: { theme: theme } },
44
46
  React.createElement(GridToolbarContainer, { sx: { padding: '0' } },
45
- title && (React.createElement(React.Fragment, null,
46
- React.createElement(Box, { display: subtitle ? 'flex' : 'block', justifyContent: 'space-between', width: '100%' },
47
- React.createElement(Box, null,
48
- React.createElement(Typography, { sx: { fontSize: '18px', fontWeight: 700, marginBottom: '6px', marginTop: '6px' } }, title),
49
- subtitle && React.createElement(Typography, { sx: { fontSize: '14px' } }, subtitle)),
50
- React.createElement(ToolbarActions, { actions: actions })))),
51
- React.createElement(Grid, { container: true, sx: styles.container },
52
- !subtitle && (React.createElement(Grid, { item: true, xs: filter ? 3 : 6, sx: {
53
- display: 'flex',
54
- alignItems: 'center',
55
- } },
56
- React.createElement(GridToolbarQuickFilter, { variant: "outlined", size: "small", sx: Object.assign(Object.assign({}, styles.quickFilter), { flex: filter ? 1 : 0 }) }))),
57
- filter && (React.createElement(Grid, { xs: 6, item: true, sx: { display: 'flex' } }, filter)),
58
- !title && React.createElement(ToolbarActions, { actions: actions })))));
47
+ React.createElement(Grid, { xs: 12, sx: styles.container },
48
+ React.createElement(Grid, { display: 'block' },
49
+ title && (React.createElement(Typography, { sx: {
50
+ fontSize: '18px',
51
+ fontWeight: 700,
52
+ marginBottom: '6px',
53
+ } }, title)),
54
+ React.createElement(Grid, { sx: { display: 'flex' } },
55
+ !hideSearchbar && (React.createElement(GridToolbarQuickFilter, { variant: "outlined", size: "small", sx: styles.quickFilter })),
56
+ filter && (React.createElement(Grid, { item: true, sx: { display: 'flex', marginLeft: '16px' } }, filter))),
57
+ subtitle && (React.createElement(Typography, { sx: { fontSize: '14px', marginTop: !hideSearchbar ? '8px' : '0px' } }, subtitle))),
58
+ React.createElement(Grid, null,
59
+ React.createElement(ToolbarActions, { actions: actions }))))));
59
60
  }
60
61
  export default BuilderGridToolbar;
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import { Button } from '../../core';
3
3
  import { Grid } from '../../layout';
4
4
  export const ToolbarActions = (props) => {
5
- const { filter, actions } = props;
6
- return (React.createElement(Grid, { item: true, container: true, xs: filter ? 3 : 6, display: 'flex', alignItems: 'center', justifyContent: 'flex-end' }, actions === null || actions === void 0 ? void 0 : actions.filter((a) => !a.isHidden).map((action, index) => (React.createElement(Grid, { item: true, display: 'flex', alignItems: 'center', justifyContent: 'flex-end' },
5
+ const { actions } = props;
6
+ return (React.createElement(Grid, { item: true, container: true, display: 'flex', alignItems: 'center', justifyContent: 'flex-end' }, actions === null || actions === void 0 ? void 0 : actions.filter((a) => !a.isHidden).map((action, index) => (React.createElement(Grid, { item: true, display: 'flex', alignItems: 'center', justifyContent: 'flex-end' },
7
7
  React.createElement(Button, { sx: {
8
8
  fontWeight: 700,
9
9
  height: '36px',
@@ -6,6 +6,10 @@ export declare type BulkAction = {
6
6
  onClick: () => void;
7
7
  selectionCount?: number;
8
8
  };
9
+ declare type LoadingOptions = {
10
+ color: string;
11
+ messages?: string[];
12
+ };
9
13
  export declare type DataGridProps<T extends GridValidRowModel> = MuiDataGridProps<T> & {
10
14
  onRefresh?: () => void;
11
15
  theme?: Theme;
@@ -14,7 +18,10 @@ export declare type DataGridProps<T extends GridValidRowModel> = MuiDataGridProp
14
18
  filterSettings?: {
15
19
  mode: 'client' | 'server';
16
20
  maxRows?: number;
21
+ filterColumns?: boolean;
17
22
  };
18
23
  hideSearchbar?: boolean;
24
+ loadingOptions?: LoadingOptions;
19
25
  };
20
26
  export default function <T extends GridValidRowModel>(props: DataGridProps<T>): JSX.Element;
27
+ export {};
@@ -10,27 +10,43 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { DataGrid as MuiDataGrid, getGridStringOperators, getGridDateOperators, getGridSingleSelectOperators, getGridBooleanOperators, GridPagination, getGridNumericOperators, } from '@mui/x-data-grid';
13
- import React, { useState } from 'react';
13
+ import { lighten } from '@mui/material';
14
+ import React, { useEffect, useState } from 'react';
14
15
  import Toolbar from './Toolbar';
15
16
  import UIThemeProvider from '../../../theme';
16
17
  import { Box, Typography } from '@mui/material';
18
+ import { dateTimeBetweenOperator } from './DateTimeCustomOperator';
19
+ import LinearProgress from '../../core/LinearProgress';
17
20
  export default function (props) {
18
21
  var _a;
19
- const { onRefresh, loading, theme, title, bulkAction, filterSettings, columns, rows, hideSearchbar } = props, rest = __rest(props, ["onRefresh", "loading", "theme", "title", "bulkAction", "filterSettings", "columns", "rows", "hideSearchbar"]);
22
+ const { onRefresh, loading, theme, title, bulkAction, filterSettings, columns, rows, hideSearchbar, loadingOptions } = props, rest = __rest(props, ["onRefresh", "loading", "theme", "title", "bulkAction", "filterSettings", "columns", "rows", "hideSearchbar", "loadingOptions"]);
20
23
  const [anchorEl, setAnchorEl] = useState();
24
+ const [loadingMessageIndex, setLoadingMessageIndex] = useState(0);
21
25
  const addColumnFilterOperators = (columns) => {
22
- return (filterSettings === null || filterSettings === void 0 ? void 0 : filterSettings.mode) === 'server'
26
+ return (filterSettings === null || filterSettings === void 0 ? void 0 : filterSettings.mode) === 'server' || !!(filterSettings === null || filterSettings === void 0 ? void 0 : filterSettings.filterColumns)
23
27
  ? columns.map((column) => (Object.assign(Object.assign({}, column), { filterOperators: column.type === 'string'
24
- ? getGridStringOperators().filter((o) => !['isEmpty', 'isNotEmpty', 'isAny'].includes(o.value))
28
+ ? getGridStringOperators().filter((o) => !['isEmpty', 'isNotEmpty', 'isAnyOf'].includes(o.value))
25
29
  : column.type === 'date' || column.type === 'dateTime'
26
- ? getGridDateOperators(column.type === 'dateTime').filter((o) => !['isEmpty', 'isNotEmpty'].includes(o.value))
30
+ ? getGridDateOperators(column.type === 'dateTime')
31
+ .filter((o) => !['isEmpty', 'isNotEmpty', 'isAnyOf'].includes(o.value))
32
+ .concat(dateTimeBetweenOperator)
27
33
  : column.type === 'number'
28
- ? getGridNumericOperators().filter((o) => !['isEmpty', 'isNotEmpty'].includes(o.value))
34
+ ? getGridNumericOperators().filter((o) => !['isEmpty', 'isNotEmpty', 'isAnyOf'].includes(o.value))
29
35
  : column.type === 'singleSelect'
30
36
  ? getGridSingleSelectOperators().filter((o) => !['isEmpty', 'isNotEmpty', 'isAnyOf'].includes(o.value))
31
- : getGridBooleanOperators().filter((o) => !['isEmpty', 'isNotEmpty'].includes(o.value)) })))
37
+ : getGridBooleanOperators().filter((o) => !['isEmpty', 'isNotEmpty', 'isAnyOf'].includes(o.value)) })))
32
38
  : columns;
33
39
  };
40
+ useEffect(() => {
41
+ var _a;
42
+ if (!loading || !((_a = loadingOptions === null || loadingOptions === void 0 ? void 0 : loadingOptions.messages) === null || _a === void 0 ? void 0 : _a.length))
43
+ return;
44
+ const intervalId = setInterval(() => {
45
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
46
+ setLoadingMessageIndex((prevIndex) => (prevIndex + 1) % loadingOptions.messages.length);
47
+ }, 1500);
48
+ return () => clearInterval(intervalId);
49
+ }, [loading, loadingMessageIndex, loadingOptions]);
34
50
  return (React.createElement(UIThemeProvider, { args: { theme: theme } },
35
51
  React.createElement(MuiDataGrid, Object.assign({ onMenuOpen: (env) => setAnchorEl(env.target), loading: loading, filterMode: (_a = filterSettings === null || filterSettings === void 0 ? void 0 : filterSettings.mode) !== null && _a !== void 0 ? _a : 'client', rows: rows }, rest, { columns: addColumnFilterOperators(columns), sx: Object.assign({ borderRadius: '8px', border: 'none', '& .MuiDataGrid-columnHeaders': {
36
52
  backgroundColor: '#F4F6F8',
@@ -39,7 +55,7 @@ export default function (props) {
39
55
  }, '& .MuiDataGrid-virtualScrollerContent': {
40
56
  borderRight: '1px solid #eee',
41
57
  borderLeft: '1px solid #eee',
42
- }, '& .MuiDataGrid-toolbarContainer': {
58
+ }, '& .MuiDataGrid-virtualScroller': Object.assign({}, (loading ? { overflow: 'hidden' } : {})), '& .MuiDataGrid-toolbarContainer': {
43
59
  padding: '0',
44
60
  fontColor: '#212B36',
45
61
  }, '& .MuiDataGrid-row': {
@@ -81,6 +97,10 @@ export default function (props) {
81
97
  boxShadow: '0px 24px 48px rgba(145, 158, 171, 0.4)',
82
98
  padding: '8px',
83
99
  stop: -120,
100
+ '& .MuiDataGrid-filterFormValueInput': {
101
+ minWidth: '190px',
102
+ width: 'auto',
103
+ },
84
104
  },
85
105
  },
86
106
  },
@@ -92,5 +112,28 @@ export default function (props) {
92
112
  search.`))),
93
113
  React.createElement(GridPagination, null)));
94
114
  },
115
+ LoadingOverlay: () => {
116
+ var _a, _b;
117
+ return (React.createElement(Box, { sx: {
118
+ minHeight: '100%',
119
+ display: 'flex',
120
+ justifyContent: 'center',
121
+ alignItems: 'center',
122
+ backgroundColor: '#fff',
123
+ overflow: 'hidden',
124
+ } },
125
+ React.createElement(Box, { width: '225px' },
126
+ React.createElement(Typography, { sx: { marginBottom: '8px', color: '#aaa', width: '100%', textAlign: 'center' } }, (loadingOptions === null || loadingOptions === void 0 ? void 0 : loadingOptions.messages)
127
+ ? loadingOptions.messages[loadingMessageIndex]
128
+ : 'Loading'),
129
+ React.createElement(LinearProgress, { sx: {
130
+ backgroundColor: (_a = loadingOptions === null || loadingOptions === void 0 ? void 0 : loadingOptions.color) !== null && _a !== void 0 ? _a : '#0075A7',
131
+ '& .MuiLinearProgress-bar': {
132
+ backgroundColor: lighten((_b = loadingOptions === null || loadingOptions === void 0 ? void 0 : loadingOptions.color) !== null && _b !== void 0 ? _b : '#0075A7', 0.5),
133
+ },
134
+ borderRadius: '6px',
135
+ width: '100%',
136
+ } }))));
137
+ },
95
138
  } }))));
96
139
  }
@@ -0,0 +1,2 @@
1
+ import { GridFilterOperator } from '@mui/x-data-grid';
2
+ export declare const dateTimeBetweenOperator: GridFilterOperator[];
@@ -0,0 +1,65 @@
1
+ import { Box, debounce, TextField } from '@mui/material';
2
+ import { useGridRootProps } from '@mui/x-data-grid';
3
+ import React, { useEffect, useState } from 'react';
4
+ import { isNil } from 'lodash';
5
+ function DateTimeRangeFilter(props) {
6
+ var _a;
7
+ const rootProps = useGridRootProps();
8
+ const { item, applyValue, focusElementRef = null } = props;
9
+ const [filterValueState, setFilterValueState] = useState((_a = item.value) !== null && _a !== void 0 ? _a : '');
10
+ useEffect(() => {
11
+ var _a;
12
+ const itemValue = (_a = item.value) !== null && _a !== void 0 ? _a : [undefined, undefined];
13
+ setFilterValueState(itemValue);
14
+ }, [item.value]);
15
+ const updateFilterValue = (from, to) => {
16
+ setFilterValueState([from, to]);
17
+ debounce(() => {
18
+ applyValue(Object.assign(Object.assign({}, item), { value: [from, to] }));
19
+ }, rootProps.filterDebounceMs)();
20
+ };
21
+ const handleChange = (event) => {
22
+ const updatedValue = event.target.value;
23
+ if (event.target.name === 'from') {
24
+ updateFilterValue(updatedValue, filterValueState[1]);
25
+ }
26
+ else if (event.target.name === 'to') {
27
+ updateFilterValue(filterValueState[0], updatedValue);
28
+ }
29
+ };
30
+ return (React.createElement(Box, { sx: {
31
+ display: 'inline-flex',
32
+ flexDirection: 'row',
33
+ alignItems: 'end',
34
+ height: 48,
35
+ pl: '20px',
36
+ } },
37
+ React.createElement(TextField, { name: "from", label: "From", variant: "standard", value: filterValueState[0], onChange: handleChange, type: "datetime-local", inputRef: focusElementRef, InputLabelProps: { shrink: true }, sx: { mr: 2, width: '175px' } }),
38
+ React.createElement(TextField, { name: "to", label: "To", variant: "standard", value: filterValueState[1], onChange: handleChange, InputLabelProps: { shrink: true }, type: "datetime-local", sx: { width: '175px' } })));
39
+ }
40
+ export const dateTimeBetweenOperator = [
41
+ {
42
+ label: 'between',
43
+ value: 'between',
44
+ getApplyFilterFn: () => null,
45
+ getApplyFilterFnV7: (filterItem) => {
46
+ const to = filterItem.value[0];
47
+ const from = filterItem.value[1];
48
+ return (value) => {
49
+ if (isNil(value))
50
+ return false;
51
+ if (to && from) {
52
+ return to <= value && value <= from;
53
+ }
54
+ else if (to) {
55
+ return value <= to;
56
+ }
57
+ else if (from) {
58
+ return value >= from;
59
+ }
60
+ return false;
61
+ };
62
+ },
63
+ InputComponent: DateTimeRangeFilter,
64
+ },
65
+ ];
@@ -52,7 +52,13 @@ function Toolbar(props) {
52
52
  !bulkAction ? (React.createElement(Grid, { item: true },
53
53
  React.createElement(Grid, { container: true, spacing: 1, sx: styles.icon },
54
54
  React.createElement(Grid, { item: true, sx: { paddingRight: '15px' } },
55
- React.createElement(GridToolbarExport, { sx: { color: '#212B36' }, printOptions: { disableToolbarButton: true }, startIcon: React.createElement(FileDownloadRounded, null) })),
55
+ React.createElement(GridToolbarExport, { sx: {
56
+ color: '#212B36',
57
+ height: '95%',
58
+ '&:hover': { backgroundColor: '#f2f3f5' },
59
+ paddingLeft: '10px',
60
+ paddingRight: '10px',
61
+ }, printOptions: { disableToolbarButton: true }, startIcon: React.createElement(FileDownloadRounded, null) })),
56
62
  React.createElement(Grid, { item: true },
57
63
  React.createElement(GridToolbarFilterButton, { componentsProps: {
58
64
  button: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.0.0-dev.214",
3
+ "version": "1.0.0-dev.216",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",