@evoke-platform/ui-components 1.0.0-dev.213 → 1.0.0-dev.215

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.
@@ -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: {
@@ -52,7 +52,7 @@ test('returns selected date', () => __awaiter(void 0, void 0, void 0, function*
52
52
  const feb29 = yield within(calendar).findByRole('gridcell', { name: '29' });
53
53
  yield user.click(feb29);
54
54
  expect(onChangeMock).toBeCalledWith('testDate', LocalDate.of(2024, Month.FEBRUARY, 29), dateProperty);
55
- }));
55
+ }), 10000);
56
56
  test('returns manually entered date', () => __awaiter(void 0, void 0, void 0, function* () {
57
57
  const user = userEvent.setup();
58
58
  const onChangeMock = jest.fn((name, value, property) => { });
@@ -56,7 +56,7 @@ test('returns selected date time', () => __awaiter(void 0, void 0, void 0, funct
56
56
  // https://stackoverflow.com/questions/74812963/how-do-i-pick-the-time-in-an-mui-datetimepicker-using-testing-library-react-and.
57
57
  // All it can do is check the date picker part works.
58
58
  expect(onChangeMock).toBeCalledWith('testDateTime', LocalDateTime.of(2024, Month.FEBRUARY, 29, 0, 0, 0), dateTimeProperty);
59
- }));
59
+ }), 10000);
60
60
  test('returns manually entered date time', () => __awaiter(void 0, void 0, void 0, function* () {
61
61
  const user = userEvent.setup();
62
62
  const onChangeMock = jest.fn((name, value, property) => { });
@@ -5,4 +5,7 @@ export { BuilderGrid, CriteriaBuilder, DataGrid, ErrorComponent, FormField, Menu
5
5
  export { Box, Container, Grid, Stack } from './components/layout';
6
6
  export * from './util';
7
7
  export * as EVOKE_TYPES from './types';
8
- export type { FormControlProps, FormHelperTextProps, GridSize } from '@mui/material';
8
+ export type { ButtonBaseActions, ButtonBaseClasses, FormControlProps, FormHelperTextProps, GridSize, MenuItemClasses, Theme, } from '@mui/material';
9
+ export type { TouchRippleProps, TouchRippleActions } from '@mui/material/ButtonBase/TouchRipple';
10
+ export type { CommonProps } from '@mui/material/OverridableComponent';
11
+ export type { SxProps } from '@mui/system';
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { ComponentStory, ComponentMeta } from '@storybook/react';
3
- declare const _default: ComponentMeta<(props: import("@mui/system").SystemProps<import("@mui/material").Theme> & {
3
+ declare const _default: ComponentMeta<(props: import("@mui/system").SystemProps<import("@mui/material/styles/createTheme").Theme> & {
4
4
  children?: React.ReactNode;
5
5
  component?: React.ElementType<any> | undefined;
6
6
  ref?: React.Ref<unknown> | undefined;
7
- sx?: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
7
+ sx?: import("@mui/system/styleFunctionSx/styleFunctionSx").SxProps<import("@mui/material/styles/createTheme").Theme> | undefined;
8
8
  } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
9
9
  ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
10
10
  }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("zIndex" | "typography" | "fontFamily" | "fontSize" | "color" | "fontWeight" | "lineHeight" | "p" | "margin" | "border" | "boxShadow" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint") | "component"> & {
@@ -12,11 +12,11 @@ declare const _default: ComponentMeta<(props: import("@mui/system").SystemProps<
12
12
  component?: React.ElementType<any> | undefined;
13
13
  }) => JSX.Element>;
14
14
  export default _default;
15
- export declare const Palette: ComponentStory<(props: import("@mui/system").SystemProps<import("@mui/material").Theme> & {
15
+ export declare const Palette: ComponentStory<(props: import("@mui/system").SystemProps<import("@mui/material/styles/createTheme").Theme> & {
16
16
  children?: React.ReactNode;
17
17
  component?: React.ElementType<any> | undefined;
18
18
  ref?: React.Ref<unknown> | undefined;
19
- sx?: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
19
+ sx?: import("@mui/system/styleFunctionSx/styleFunctionSx").SxProps<import("@mui/material/styles/createTheme").Theme> | undefined;
20
20
  } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
21
21
  ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
22
22
  }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("zIndex" | "typography" | "fontFamily" | "fontSize" | "color" | "fontWeight" | "lineHeight" | "p" | "margin" | "border" | "boxShadow" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint") | "component"> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.0.0-dev.213",
3
+ "version": "1.0.0-dev.215",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",