@evoke-platform/ui-components 1.0.0-dev.194 → 1.0.0-dev.196

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.
@@ -47,3 +47,4 @@ export { SvgIcon, TableBody, TableCell, TableContainer, TableHead, TablePaginati
47
47
  export { LoadingButton, TabContext, TabList, TabPanel, TreeItem, TreeView } from '@mui/lab';
48
48
  export type { GridSize } from '@mui/material';
49
49
  export type { AutocompleteOption } from './Autocomplete/Autocomplete';
50
+ export type { GridCellParams, GridColDef, GridValueFormatterParams, GridValueGetterParams, GridEventListener, } from '@mui/x-data-grid';
@@ -4,6 +4,7 @@ import { EmptyContentSelectOptions } from './EmptyContent';
4
4
  export declare type GridAction = {
5
5
  label: string;
6
6
  onClick: () => void;
7
+ isHidden?: boolean;
7
8
  };
8
9
  export declare type BuilderGridProps<T extends GridValidRowModel> = MuiDataGridProps<T> & {
9
10
  action?: GridAction;
@@ -15,6 +16,7 @@ export declare type BuilderGridProps<T extends GridValidRowModel> = MuiDataGridP
15
16
  hideEmptyContent?: boolean;
16
17
  hideToolbar?: boolean;
17
18
  noRowsOverlay?: React.ReactElement;
19
+ filterComponent?: React.ReactElement;
18
20
  };
19
21
  declare const BuilderGrid: <T extends GridValidRowModel>(props: BuilderGridProps<T>) => JSX.Element;
20
22
  export default BuilderGrid;
@@ -17,9 +17,9 @@ import BuilderGridToolbar from './BuilderGridToolbar';
17
17
  import { EmptyContent } from './EmptyContent';
18
18
  const BuilderGrid = (props) => {
19
19
  var _a, _b;
20
- const { loading, action, item, rows, initialSort, emptyContentSelectOptions, title, disablePagination, hideEmptyContent, hideToolbar, noRowsOverlay } = props, rest = __rest(props, ["loading", "action", "item", "rows", "initialSort", "emptyContentSelectOptions", "title", "disablePagination", "hideEmptyContent", "hideToolbar", "noRowsOverlay"]);
20
+ const { loading, action, item, rows, initialSort, emptyContentSelectOptions, title, disablePagination, hideEmptyContent, hideToolbar, noRowsOverlay, filterComponent } = props, rest = __rest(props, ["loading", "action", "item", "rows", "initialSort", "emptyContentSelectOptions", "title", "disablePagination", "hideEmptyContent", "hideToolbar", "noRowsOverlay", "filterComponent"]);
21
21
  const [anchorEl, setAnchorEl] = useState();
22
- const toolbar = useMemo(() => () => React.createElement(BuilderGridToolbar, { loading: loading, action: action, title: title }), [loading, action]);
22
+ const toolbar = useMemo(() => () => React.createElement(BuilderGridToolbar, { loading: loading, action: action, title: title, filter: filterComponent }), [loading, action]);
23
23
  return (React.createElement(UIThemeProvider, null, loading || rows.length || hideEmptyContent ? (React.createElement(Box, { sx: {
24
24
  backgroundColor: '#fff',
25
25
  borderRadius: '6px',
@@ -59,7 +59,7 @@ const BuilderGrid = (props) => {
59
59
  fontWeight: 700,
60
60
  }, '& .MuiDataGrid-iconButtonContainer': {
61
61
  marginLeft: '4px',
62
- }, height: !disablePagination ? 'calc(100vh - 240px)' : 'auto' }, rest.sx), getRowId: (row) => row.id, disableColumnMenu: true, initialState: {
62
+ }, height: disablePagination && !loading ? 'auto' : 'calc(100vh - 240px)' }, rest.sx), getRowId: (row) => row.id, disableColumnMenu: true, initialState: {
63
63
  sorting: {
64
64
  sortModel: initialSort ? [initialSort] : [],
65
65
  },
@@ -1,9 +1,10 @@
1
- /// <reference types="react" />
2
1
  import { GridToolbarProps as MuiGridToolbarProps } from '@mui/x-data-grid';
2
+ import React from 'react';
3
3
  import { GridAction } from './BuilderGrid';
4
4
  export declare type BuilderGridToolbar = MuiGridToolbarProps & {
5
5
  action?: GridAction;
6
6
  title?: string;
7
+ filter?: React.ReactElement;
7
8
  };
8
9
  declare function BuilderGridToolbar(props: BuilderGridToolbar): JSX.Element;
9
10
  export default BuilderGridToolbar;
@@ -6,9 +6,12 @@ import { Button } from '../../core';
6
6
  import { Grid } from '../../layout';
7
7
  function BuilderGridToolbar(props) {
8
8
  var _a, _b, _c;
9
- const { theme, action, title } = props;
9
+ const { theme, action, title, filter } = props;
10
10
  const styles = {
11
- container: { display: 'flex', justifyContent: 'space-between', margin: '0 0 15px 0' },
11
+ container: {
12
+ display: 'flex',
13
+ margin: '0 0 15px 0',
14
+ },
12
15
  iconButton: {
13
16
  minWidth: '36px',
14
17
  height: '36px',
@@ -25,6 +28,7 @@ function BuilderGridToolbar(props) {
25
28
  },
26
29
  quickFilter: {
27
30
  '& .MuiOutlinedInput-root': {
31
+ minWidth: '300px',
28
32
  '&.Mui-focused fieldset': {
29
33
  borderColor: (_c = (_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) !== null && _c !== void 0 ? _c : 'primary',
30
34
  },
@@ -40,16 +44,20 @@ function BuilderGridToolbar(props) {
40
44
  React.createElement(GridToolbarContainer, { sx: { padding: '0' } },
41
45
  title && (React.createElement(Typography, { sx: { fontSize: '18px', fontWeight: 700, marginBottom: '6px', marginTop: '6px' } }, title)),
42
46
  React.createElement(Grid, { container: true, sx: styles.container },
43
- React.createElement(Grid, { item: true, xs: 6, sx: { display: 'flex', alignItems: 'center' } },
44
- React.createElement(GridToolbarQuickFilter, { variant: "outlined", size: "small", sx: styles.quickFilter })),
45
- React.createElement(Grid, { item: true, xs: 6, display: 'flex', alignItems: 'center', justifyContent: 'flex-end' },
47
+ React.createElement(Grid, { item: true, xs: filter ? 3 : 6, sx: {
48
+ display: 'flex',
49
+ alignItems: 'center',
50
+ } },
51
+ React.createElement(GridToolbarQuickFilter, { variant: "outlined", size: "small", sx: Object.assign(Object.assign({}, styles.quickFilter), { flex: filter ? 1 : 0 }) })),
52
+ filter && (React.createElement(Grid, { xs: 6, item: true, sx: { display: 'flex' } }, filter)),
53
+ action && !action.isHidden && (React.createElement(Grid, { item: true, xs: filter ? 3 : 6, display: 'flex', alignItems: 'center', justifyContent: 'flex-end' },
46
54
  React.createElement(Button, { sx: {
47
55
  fontWeight: 700,
48
- height: '40px',
56
+ height: '36px',
49
57
  padding: '0px 14px',
50
58
  '&:hover': {
51
59
  boxShadow: 'none',
52
60
  },
53
- }, onClick: action === null || action === void 0 ? void 0 : action.onClick, variant: 'contained' }, action === null || action === void 0 ? void 0 : action.label))))));
61
+ }, onClick: action.onClick, variant: 'contained' }, action.label)))))));
54
62
  }
55
63
  export default BuilderGridToolbar;
@@ -169,22 +169,27 @@ const CriteriaBuilder = (props) => {
169
169
  if (criteria || originalCriteria) {
170
170
  const criteriaToParse = criteria || originalCriteria || {};
171
171
  const updatedQuery = parseMongoDB(criteriaToParse);
172
- setQuery(Object.assign(Object.assign({}, updatedQuery), {
173
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
174
- rules: updatedQuery.rules.map((rule) => {
175
- var _a, _b;
176
- const propertyType = (_a = properties.find((property) => property.id === rule.field)) === null || _a === void 0 ? void 0 : _a.type;
177
- return Object.assign(Object.assign({}, rule), { value: propertyType === 'array' ||
178
- (propertyType === 'string' && rule.operator === 'in') ||
179
- rule.operator === 'notIn'
180
- ? (_b = rule.value) === null || _b === void 0 ? void 0 : _b.split(',')
181
- : rule.value });
182
- }) }));
172
+ setQuery(Object.assign(Object.assign({}, updatedQuery), { rules: processRules(updatedQuery.rules) }));
183
173
  }
184
174
  else {
185
175
  setQuery({ combinator: 'and', rules: [] });
186
176
  }
187
177
  }, [originalCriteria]);
178
+ function processRules(rules) {
179
+ return rules.map((rule) => {
180
+ var _a, _b;
181
+ if ('rules' in rule) {
182
+ return Object.assign(Object.assign({}, rule), { rules: processRules(rule.rules) });
183
+ }
184
+ else {
185
+ const propertyType = (_a = properties.find((property) => property.id === rule.field)) === null || _a === void 0 ? void 0 : _a.type;
186
+ return Object.assign(Object.assign({}, rule), { value: propertyType === 'array' ||
187
+ (propertyType === 'string' && (rule.operator === 'in' || rule.operator === 'notIn'))
188
+ ? (_b = rule.value) === null || _b === void 0 ? void 0 : _b.split(',')
189
+ : rule.value });
190
+ }
191
+ });
192
+ }
188
193
  const handleQueryChange = (q) => {
189
194
  setQuery(q);
190
195
  const newCriteria = JSON.parse(formatQuery(q, 'mongodb'));
@@ -5,6 +5,7 @@ export declare type DropdownOption = {
5
5
  value: boolean;
6
6
  disabled?: boolean;
7
7
  tooltip?: string;
8
+ deleted?: boolean;
8
9
  };
9
10
  export declare type MultiSelectProps = {
10
11
  options: DropdownOption[];
@@ -7,7 +7,7 @@ import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, us
7
7
  import { SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from '@dnd-kit/sortable';
8
8
  import { restrictToVerticalAxis, restrictToWindowEdges } from '@dnd-kit/modifiers';
9
9
  import { SortableItem } from './SortableItem';
10
- import { Tooltip } from '../../core';
10
+ import { Link, Tooltip } from '../../core';
11
11
  const styles = {
12
12
  textField: {
13
13
  borderRadius: '8px',
@@ -51,6 +51,7 @@ export default function MultiSelect(props) {
51
51
  const [optionsArray, setOptions] = useState(options);
52
52
  const [selectAll, setSelectAll] = useState(false);
53
53
  const [searchText, setSearchText] = useState('');
54
+ const [deletedOptions] = useState(options.filter((opt) => opt.deleted).map((opt) => { var _a; return (_a = opt.id) !== null && _a !== void 0 ? _a : ''; }));
54
55
  const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
55
56
  coordinateGetter: sortableKeyboardCoordinates,
56
57
  }), useSensor(PointerSensor, {
@@ -96,6 +97,16 @@ export default function MultiSelect(props) {
96
97
  updateOptions(false);
97
98
  setSelectAll(false);
98
99
  };
100
+ const handleDeletedOptions = (event) => {
101
+ const newOptions = optionsArray.map((option) => {
102
+ if (option.id && deletedOptions.includes(option.id)) {
103
+ option.value = false;
104
+ }
105
+ return option;
106
+ });
107
+ onChange(newOptions);
108
+ setOptions(newOptions);
109
+ };
99
110
  const filterItems = (event) => {
100
111
  setSearchText(event.target.value);
101
112
  const keyword = event.target.value.toLowerCase();
@@ -137,11 +148,18 @@ export default function MultiSelect(props) {
137
148
  startAdornment: (React.createElement(InputAdornment, { position: "start" },
138
149
  React.createElement(Search, null))),
139
150
  }, fullWidth: true, sx: styles.textField, value: searchText, onChange: filterItems }))),
140
- (optionsArray === null || optionsArray === void 0 ? void 0 : optionsArray.length) > 1 && (React.createElement(Grid, { container: true },
141
- React.createElement(Grid, null,
142
- React.createElement(Button, { sx: styles.button, variant: "text", onClick: (e) => handleSelectAllChange(e), disabled: optionsArray.every((option) => option.disabled === true || selectAll) }, "Select All")),
143
- React.createElement(Grid, { item: true, xs: 6 },
144
- React.createElement(Button, { sx: Object.assign({}, styles.button), variant: "text", onClick: (e) => handleClearAll(e), disabled: optionsArray.every((option) => option.disabled === true) ||
151
+ (optionsArray === null || optionsArray === void 0 ? void 0 : optionsArray.length) && (React.createElement(Grid, { container: true },
152
+ deletedOptions.length && (React.createElement(Grid, { item: true, xs: 6, sx: { display: 'flex', justifyContent: 'start', textAlign: 'center' } },
153
+ React.createElement(Link, { sx: {
154
+ color: 'red',
155
+ '&:hover': { backgroundColor: 'transparent', cursor: 'pointer' },
156
+ textDecoration: 'none',
157
+ margin: '8px',
158
+ }, onClick: (e) => handleDeletedOptions(e) }, `Clear ${deletedOptions.length} deleted fields`))),
159
+ React.createElement(Grid, { item: true, xs: 3 },
160
+ React.createElement(Button, { sx: Object.assign(Object.assign({}, styles.button), { fontWeight: 'bold' }), variant: "text", onClick: (e) => handleSelectAllChange(e), disabled: optionsArray.every((option) => option.disabled === true || selectAll) }, "Select All")),
161
+ React.createElement(Grid, { item: true, xs: 3 },
162
+ React.createElement(Button, { sx: Object.assign(Object.assign({}, styles.button), { color: 'gray', fontWeight: 'bold' }), variant: "text", onClick: (e) => handleClearAll(e), disabled: optionsArray.every((option) => option.disabled === true) ||
145
163
  optionsArray.every((option) => option.value === false) }, "Clear All")))),
146
164
  React.createElement(Box, { sx: Object.assign(Object.assign({}, styles.list), { maxHeight: maxHeight !== null && maxHeight !== void 0 ? maxHeight : 'auto' }) }, isSortable ? (React.createElement(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, modifiers: [restrictToVerticalAxis, restrictToWindowEdges] },
147
165
  React.createElement(SortableContext, { items: optionsArray, strategy: verticalListSortingStrategy }, optionsArray.map((option) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.0.0-dev.194",
3
+ "version": "1.0.0-dev.196",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",