@azrico/reactgrid 1.3.52 → 1.4.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.
@@ -19,8 +19,9 @@
19
19
  display: flex;
20
20
  flex-direction: column;
21
21
  }
22
- .azgrid-testborder {
23
- border: 3px solid red;
22
+ .azgrid-scope {
23
+ min-height: 0;
24
+ min-width: 0;
24
25
  }
25
26
  .azgrid-pad50px {
26
27
  padding: 50px;
@@ -0,0 +1,49 @@
1
+ /* Example host preset; separate from the neutral grid theme. */
2
+ .azgrid-example-deco, .azgrid-theme-deco {
3
+ --azgrid-bg: #0A0A0A;
4
+ --azgrid-fg: #eee7d6;
5
+ --azgrid-border: #6b5824;
6
+ --azgrid-accent: #D4AF37;
7
+ --azgrid-muted-fg: #9b8a5b;
8
+ --azgrid-radius: 0;
9
+ --azgrid-font-family: Georgia, serif;
10
+ --azgrid-header-bg: #0A0A0A;
11
+ --azgrid-header-fg: #D4AF37;
12
+ --azgrid-header-border: #6b5824;
13
+ --azgrid-header-text-transform: uppercase;
14
+ --azgrid-header-letter-spacing: .1em;
15
+ --azgrid-header-font-weight: 600;
16
+ --azgrid-row-bg-even: #0A0A0A;
17
+ --azgrid-row-bg-odd: #12110e;
18
+ --azgrid-row-bg-hover: #282211;
19
+ --azgrid-row-fg-hover: #fff6dc;
20
+ --azgrid-row-bg-selected: #423619;
21
+ --azgrid-row-fg-selected: #fff6dc;
22
+ --azgrid-row-bg-active: #332a15;
23
+ --azgrid-cell-border: #6b5824;
24
+ --azgrid-cell-border-width: 1px;
25
+ --azgrid-cell-padding: 0 10px;
26
+ --azgrid-filter-bg: #12110e;
27
+ --azgrid-filter-fg: #eee7d6;
28
+ --azgrid-filter-border: #6b5824;
29
+ --azgrid-filter-placeholder: #9b8a5b;
30
+ --azgrid-filter-focus-ring: #D4AF37;
31
+ --azgrid-pagination-bg: #0A0A0A;
32
+ --azgrid-pagination-fg: #D4AF37;
33
+ --azgrid-pagination-border: #6b5824;
34
+ --azgrid-menu-bg: #12110e;
35
+ --azgrid-menu-fg: #eee7d6;
36
+ --azgrid-menu-border: #6b5824;
37
+ --azgrid-menu-bg-hover: #282211;
38
+ --azgrid-scrollbar-track: #0A0A0A;
39
+ --azgrid-scrollbar-thumb: #6b5824;
40
+ --azgrid-empty-bg: #0A0A0A;
41
+ --azgrid-empty-fg: #9b8a5b;
42
+ --azgrid-loading-bg: rgba(10, 10, 10, .85);
43
+ --azgrid-loading-fg: #D4AF37;
44
+ --azgrid-tree-bg: #12110e;
45
+ --azgrid-tree-fg: #D4AF37;
46
+ --azgrid-details-bg: #12110e;
47
+ --azgrid-shadow-color: rgba(0, 0, 0, .6);
48
+ --azgrid-locked-column-shadow: 0 0 5px #6b5824;
49
+ }
@@ -1,85 +1,17 @@
1
- .InovuaReactDataGrid {
2
- z-index: 1000;
3
- font-family: 'Nunito Sans', 'Iran Sans', sans-serif;
4
- }
5
-
6
- .InovuaReactDataGrid {
7
- --grid-bg: oklch(var(--b1, 100% 0 106));
8
- --grid-fg: oklch(var(--bc, 23.5% 0 0));
9
- --grid-bg-hover: oklch(var(--b2, 94.75% 0.014 277.06));
10
- --grid-bg-hover2: oklch(var(--b3, 94.75% 0.014 277.06));
11
- --grid-fg-hover: oklch(var(--bc, 23.5% 0 0));
12
- }.InovuaReactDataGrid--theme-amber-dark {
13
- --grid-bg: #313943;
14
- --grid-fg: #c5cae9;
15
- --grid-bg-hover: oklch(var(--b2, 40.8% 0.011 128.75));
16
- --grid-fg-hover: #ececec;
17
- }
18
- .InovuaReactDataGrid__row {
19
- color: var(--grid-fg);
20
- border-top-width: 1px;
21
- }
22
- .InovuaReactDataGrid--theme-default-light .InovuaReactDataGrid__row--odd {
23
- background-color: #fafafa;
24
- }
25
- .InovuaReactDataGrid--theme-default-light .InovuaReactDataGrid__row--even {
26
- background-color: #fff;
27
- }
28
- /* --------------------------- selected row color --------------------------- */
29
- .InovuaReactDataGrid
30
- .InovuaReactDataGrid__row--active
31
- .InovuaReactDataGrid__cell:not(.InovuaReactDataGrid__cell--no-background),
32
- .InovuaReactDataGrid
33
- .InovuaReactDataGrid__row--active.InovuaReactDataGrid__row--even
34
- .InovuaReactDataGrid__cell:not(.InovuaReactDataGrid__cell--no-background),
35
- .InovuaReactDataGrid
36
- .InovuaReactDataGrid__row--active.InovuaReactDataGrid__row--odd
37
- .InovuaReactDataGrid__cell:not(.InovuaReactDataGrid__cell--no-background) {
38
- color: var(--grid-fg-hover);
39
- }
40
- /* ----------------------------- hover row color ---------------------------- */
41
- .InovuaReactDataGrid--show-hover-rows
42
- .InovuaReactDataGrid__row:not(.InovuaReactDataGrid__row--scrolling):not(
43
- .InovuaReactDataGrid__row--empty
44
- )
45
- .InovuaReactDataGrid__row-hover-target:hover {
46
- background: var(--grid-bg-hover) !important;
47
- color: var(--grid-fg-hover) !important;
48
- }
49
- .InovuaReactDataGrid--theme-default-light.InovuaReactDataGrid--show-hover-rows
50
- .InovuaReactDataGrid__row--no-zebra:not(.InovuaReactDataGrid__row--scrolling):not(
51
- .InovuaReactDataGrid__row--empty
52
- )
53
- .InovuaReactDataGrid__row-hover-target:hover
54
- .InovuaReactDataGrid__row-index-column,
55
- .InovuaReactDataGrid--theme-default-light.InovuaReactDataGrid--show-hover-rows
56
- .InovuaReactDataGrid__row-hover-target:hover
57
- .InovuaReactDataGrid__row-index-column {
58
- background: var(--grid-bg-hover2) !important;
59
- }
60
- /* -------------------------------------------------------------------------- */
61
- .inovua-react-toolkit-text-input {
62
- font-family: inherit;
63
- }
64
- .inovua-react-toolkit-text-input input {
65
- font-family: inherit;
66
- }
67
-
68
- .InovuaReactDataGrid__cell .InovuaReactDataGrid__cell__content {
69
- height: 100%;
70
- display: flex;
71
- align-items: center;
72
- }
73
- .InovuaReactDataGrid__column-header__content {
74
- text-overflow: clip;
75
- }
76
-
77
- .InovuaReactDataGrid__row.deleted:after {
78
- position: absolute;
79
- content: '';
80
- left: 5px;
81
- top: 50%;
82
- right: 5px;
83
- border-top: 1.5px solid;
84
- border-color: gray;
1
+ .InovuaReactDataGrid { z-index: 1000; }
2
+ .inovua-react-toolkit-text-input,
3
+ .inovua-react-toolkit-text-input input { font-family: inherit; }
4
+ .InovuaReactDataGrid__cell .InovuaReactDataGrid__cell__content {
5
+ height: 100%;
6
+ display: flex;
7
+ align-items: center;
8
+ }
9
+ .InovuaReactDataGrid__column-header__content { text-overflow: clip; }
10
+ .InovuaReactDataGrid__row.deleted:after {
11
+ position: absolute;
12
+ content: '';
13
+ left: 5px;
14
+ top: 50%;
15
+ right: 5px;
16
+ border-top: 1.5px solid;
85
17
  }
@@ -1,122 +1,124 @@
1
- import { ModifyFields } from '../func/func_grid';
2
- import { ConvertableToMenuItem } from '@azrico/controls';
3
- import React from 'react';
4
- import {
5
- TypeCellSelection,
6
- TypeColumn,
7
- TypeDataGridProps,
8
- TypeDataSource,
9
- TypeEditInfo,
10
- TypeFilterTypes,
11
- TypeFilterValue,
12
- TypeRowDetailsInfo,
13
- TypeRowProps,
14
- TypeRowSelection,
15
- TypeComputedProps,
16
- } from '@inovua/reactdatagrid-community/types';
17
-
18
- import { TypeOnSelectionChangeArg } from '@inovua/reactdatagrid-community/types/TypeDataGridProps';
19
-
20
- /* -------------------------------------------------------------------------- */
21
- export type ColumnDefinition = TypeColumn;
22
- export type CellDefinition = any;
23
- export type RowDefinition = any;
24
- export type RowProps = TypeRowProps;
25
- export type RowSelectionValue = TypeRowSelection;
26
- export type CellSelectionValue = TypeCellSelection;
27
- export type DataRowDefinition = any;
28
- export type FilterTypes = TypeFilterTypes;
29
- export type FilterValues = TypeFilterValue;
30
- export type DataSourceDefinition = TypeDataSource;
31
- export type OnSelectionChangeFunc = (config: TypeOnSelectionChangeArg) => void;
32
- export type OnCellSelectionChangeFunc = (s: { [key: string]: boolean }) => void;
33
- export type RowDetailsFunc = (rowDetailsInfo: TypeRowDetailsInfo) => React.ReactNode;
34
-
35
- export type loose_column_names = {
36
- key: string;
37
- field: string;
38
- columnName: string;
39
- name: string;
40
- };
41
- export type loose_column_fields = loose_column_names & {
42
- title: string;
43
- type: string;
44
- items: any[];
45
- };
46
- export type LooseColumnDefinition = Partial<loose_column_fields & ColumnDefinition>;
47
- //
48
-
49
- export type CustomColumnDefinition = {
50
- name: string;
51
- render: (cell: any, formatterParams, onRendered) => React.ReactNode | undefined | null;
52
- };
53
- export type AzGridOptions = Partial<TypeDataGridProps>;
54
- /* -------------------------------------------------------------------------- */
55
- export type AzGridProps = {
56
- dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
57
- details_dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>); //details is rendered under each row
58
- details_columns?: LooseColumnDefinition[];
59
- details_filter?: FilterValues;
60
-
61
- licenseKey?: string;
62
-
63
- gridRef?: React.MutableRefObject<TypeComputedProps>;
64
- gridOptions?: AzGridOptions;
65
-
66
- columns?: LooseColumnDefinition[];
67
- columnExtensions?: Partial<LooseColumnDefinition>;
68
-
69
- editableColumns?: string[];
70
- leftColumns?: string[];
71
- rightColumns?: string[];
72
- customColumns?: CustomColumnDefinition[];
73
-
74
- contextMenuItems?: ConvertableToMenuItem;
75
-
76
- highlightedRow?: any;
77
- RowDetail?: RowDetailsFunc;
78
-
79
- selected?: RowSelectionValue;
80
- cellSelection?: CellSelectionValue;
81
- /* -------------------------------------------------------------------------- */
82
- onEditComplete?: (editInfo: TypeEditInfo) => void;
83
- onSelectionChange?: OnSelectionChangeFunc;
84
- onCellSelectionChange?: OnCellSelectionChangeFunc;
85
-
86
- onRowClick?: (rowIndex: number, row: any) => void;
87
- onRowDoubleClick?: (rowIndex: number, row: any) => void;
88
- onLimitChange?: (v: number) => void;
89
- onSkipChange?: (v: number) => void;
90
- /* -------------------------------------------------------------------------- */
91
- skip?: number;
92
- limit?: number;
93
- //
94
- editable?: boolean | ((editValue: any, cellProps: any) => boolean);
95
- advancedFilterFields?: string[];
96
- //
97
-
98
- loading?: boolean;
99
- dark?: boolean;
100
- delayedSize?: boolean;
101
- allowChildRows?: boolean;
102
- looseCacheCheck?: boolean;
103
- className?: string;
104
- };
105
-
106
- export type DataGridProps = ModifyFields<
107
- AzGridProps,
108
- {
109
- columns: ColumnDefinition[];
110
- dataSource: any;
111
- }
112
- >;
113
- export type GridType = TypeComputedProps;
114
- export type DataGridWrapperProps = ModifyFields<
115
- DataGridProps,
116
- {
117
- gridRef: React.MutableRefObject<TypeComputedProps>;
118
- static_gridOptions: AzGridOptions;
119
- dynamic_gridOptions: AzGridOptions;
120
- children?: React.ReactNode;
121
- }
122
- >;
1
+ import { ModifyFields } from '../func/func_grid';
2
+ import { ConvertableToMenuItem } from '@azrico/controls/context-menu';
3
+ import React from 'react';
4
+ import {
5
+ TypeCellSelection,
6
+ TypeColumn,
7
+ TypeDataGridProps,
8
+ TypeDataSource,
9
+ TypeEditInfo,
10
+ TypeFilterTypes,
11
+ TypeFilterValue,
12
+ TypeRowDetailsInfo,
13
+ TypeRowProps,
14
+ TypeRowSelection,
15
+ TypeComputedProps,
16
+ } from '@inovua/reactdatagrid-community/types';
17
+
18
+ import { TypeOnSelectionChangeArg } from '@inovua/reactdatagrid-community/types/TypeDataGridProps';
19
+
20
+ /* -------------------------------------------------------------------------- */
21
+ export type ColumnDefinition = TypeColumn;
22
+ export type CellDefinition = any;
23
+ export type RowDefinition = any;
24
+ export type RowProps = TypeRowProps;
25
+ export type RowSelectionValue = TypeRowSelection;
26
+ export type CellSelectionValue = TypeCellSelection;
27
+ export type DataRowDefinition = any;
28
+ export type FilterTypes = TypeFilterTypes;
29
+ export type FilterValues = TypeFilterValue;
30
+ export type DataSourceDefinition = TypeDataSource;
31
+ export type OnSelectionChangeFunc = (config: TypeOnSelectionChangeArg) => void;
32
+ export type OnCellSelectionChangeFunc = (s: { [key: string]: boolean }) => void;
33
+ export type RowDetailsFunc = (rowDetailsInfo: TypeRowDetailsInfo) => React.ReactNode;
34
+
35
+ export type loose_column_names = {
36
+ key: string;
37
+ field: string;
38
+ columnName: string;
39
+ name: string;
40
+ };
41
+ export type loose_column_fields = loose_column_names & {
42
+ title: string;
43
+ type: string;
44
+ items: any[];
45
+ };
46
+ export type LooseColumnDefinition = Partial<loose_column_fields & ColumnDefinition>;
47
+ //
48
+
49
+ export type CustomColumnDefinition = {
50
+ name: string;
51
+ render: (cell: any, formatterParams, onRendered) => React.ReactNode | undefined | null;
52
+ };
53
+ export type AzGridOptions = Partial<TypeDataGridProps>;
54
+ /* -------------------------------------------------------------------------- */
55
+ export type AzGridProps = {
56
+ dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
57
+ details_dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>); //details is rendered under each row
58
+ details_columns?: LooseColumnDefinition[];
59
+ details_filter?: FilterValues;
60
+
61
+ licenseKey?: string;
62
+
63
+ gridRef?: React.MutableRefObject<TypeComputedProps>;
64
+ gridOptions?: AzGridOptions;
65
+
66
+ columns?: LooseColumnDefinition[];
67
+ columnExtensions?: Partial<LooseColumnDefinition>;
68
+
69
+ editableColumns?: string[];
70
+ leftColumns?: string[];
71
+ rightColumns?: string[];
72
+ customColumns?: CustomColumnDefinition[];
73
+
74
+ contextMenuItems?: ConvertableToMenuItem;
75
+
76
+ highlightedRow?: any;
77
+ RowDetail?: RowDetailsFunc;
78
+
79
+ selected?: RowSelectionValue;
80
+ cellSelection?: CellSelectionValue;
81
+ /* -------------------------------------------------------------------------- */
82
+ onEditComplete?: (editInfo: TypeEditInfo) => void;
83
+ onSelectionChange?: OnSelectionChangeFunc;
84
+ onCellSelectionChange?: OnCellSelectionChangeFunc;
85
+
86
+ onRowClick?: (rowIndex: number, row: any) => void;
87
+ onRowDoubleClick?: (rowIndex: number, row: any) => void;
88
+ onLimitChange?: (v: number) => void;
89
+ onSkipChange?: (v: number) => void;
90
+ /* -------------------------------------------------------------------------- */
91
+ skip?: number;
92
+ limit?: number;
93
+ //
94
+ editable?: boolean | ((editValue: any, cellProps: any) => boolean);
95
+ advancedFilterFields?: string[];
96
+ //
97
+
98
+ loading?: boolean;
99
+ theme?: 'light' | 'dark' | (string & {});
100
+ /** @deprecated Use theme="dark" or theme="light" instead. */
101
+ dark?: boolean;
102
+ delayedSize?: boolean;
103
+ allowChildRows?: boolean;
104
+ looseCacheCheck?: boolean;
105
+ className?: string;
106
+ };
107
+
108
+ export type DataGridProps = ModifyFields<
109
+ AzGridProps,
110
+ {
111
+ columns: ColumnDefinition[];
112
+ dataSource: any;
113
+ }
114
+ >;
115
+ export type GridType = TypeComputedProps;
116
+ export type DataGridWrapperProps = ModifyFields<
117
+ DataGridProps,
118
+ {
119
+ gridRef: React.MutableRefObject<TypeComputedProps>;
120
+ static_gridOptions: AzGridOptions;
121
+ dynamic_gridOptions: AzGridOptions;
122
+ children?: React.ReactNode;
123
+ }
124
+ >;
@@ -1,19 +1,15 @@
1
1
  import '@inovua/reactdatagrid-enterprise/index.css';
2
- import '@inovua/reactdatagrid-enterprise/theme/default-dark.css';
3
- import '@inovua/reactdatagrid-enterprise/theme/amber-dark.css';
4
2
  import '../themes/base_styles.css';
5
3
  import '../themes/grid.css';
6
- import { applyColumnData, ApplyDataSource, get_default_key } from '../func/func_grid';
7
- import { ContextMenu } from '@azrico/controls';
4
+ import { get_default_key } from '../func/func_grid';
5
+ import { ContextMenu } from '@azrico/controls/context-menu';
8
6
  import React from 'react';
9
-
10
- import { array_intersection, fn_eval } from '@azrico/object';
7
+ import { createTheme, ThemeProvider, useTheme } from '@mui/material/styles';
11
8
 
12
9
  import ReactDataGrid from '@inovua/reactdatagrid-enterprise';
13
10
  import clsx from 'clsx';
14
11
  import { useComponentSize } from 'react-use-size';
15
12
 
16
- import debounce from 'lodash.debounce';
17
13
  import { AzGridOptions, AzGridProps, DataGridWrapperProps } from '../types/types';
18
14
  import { useGridEvents } from '../hooks/useGridEvents';
19
15
  import { useColumnData } from '../hooks/useColumnData';
@@ -37,6 +33,7 @@ const defaultOptions: AzGridOptions = {
37
33
  const forcedOptions: AzGridOptions = {
38
34
  idProperty: '__table_id',
39
35
  nodesProperty: '__children',
36
+ theme: 'default-light',
40
37
  };
41
38
 
42
39
  const dynamic_option_names = ['selected', 'cellSelection', 'loading', 'limit', 'skip'];
@@ -70,7 +67,6 @@ export function AzGrid(props: AzGridProps) {
70
67
  editable: props.editable as any, //bug in types of the plugin
71
68
  treeColumn: props.allowChildRows ? firstcolumn.name : undefined,
72
69
  renderRowDetails: props.RowDetail,
73
- theme: props.dark ? 'amber-dark' : 'default-light',
74
70
  };
75
71
  return { ...defaultOptions, ...events, ...extra_ops };
76
72
  }, [
@@ -126,6 +122,16 @@ export function AzGrid(props: AzGridProps) {
126
122
  * @returns
127
123
  */
128
124
  function DataGridEventsWrapper(props: DataGridWrapperProps) {
125
+ const scopeRef = React.useRef<HTMLDivElement>(null);
126
+ const hostTheme = useTheme();
127
+ // Keep the existing context menu and its portal in this grid's CSS scope.
128
+ const menuTheme = React.useMemo(
129
+ () => createTheme(hostTheme, {
130
+ components: { MuiPopper: { defaultProps: { container: () => scopeRef.current } } },
131
+ }),
132
+ [hostTheme]
133
+ );
134
+ const themeClass = `azgrid-theme-${props.theme ?? (props.dark ? 'dark' : 'light')}`;
129
135
  /* -------------------------------------------------------------------------- */
130
136
  const {
131
137
  onRowClick,
@@ -158,20 +164,23 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
158
164
  /* -------------------------------------------------------------------------- */
159
165
  //TODO ContextMenu not from mui...
160
166
  return (
161
- <>
162
- <ContextMenu
163
- menuAnchorEl={menuAnchorEl}
164
- menuRow={menuRow}
165
- close={update_menuRow}
166
- dontAutoClose={false}
167
- menu_items={props.contextMenuItems as any}
168
- />
167
+ <div ref={scopeRef} className={clsx('azgrid-scope azgrid-flexed azgrid-flexlayout', themeClass)}>
168
+ <ThemeProvider theme={menuTheme}>
169
+ <ContextMenu
170
+ classname="azgrid-context-menu"
171
+ menuAnchorEl={menuAnchorEl}
172
+ menuRow={menuRow}
173
+ close={update_menuRow}
174
+ dontAutoClose={false}
175
+ menu_items={props.contextMenuItems as any}
176
+ />
177
+ </ThemeProvider>
169
178
  {props.details_dataSource ? (
170
179
  <DataGridDetailsWrapper {...props} static_gridOptions={static_gridOptions} />
171
180
  ) : (
172
181
  <DataGridSizeWrapper {...props} static_gridOptions={static_gridOptions} />
173
182
  )}
174
- </>
183
+ </div>
175
184
  );
176
185
  }
177
186
 
@@ -181,6 +190,8 @@ function DataGridDetailsWrapper(props: DataGridWrapperProps) {
181
190
  const renderDetailsGrid = ({ data }) => {
182
191
  return (
183
192
  <ReactDataGrid
193
+ theme="default-light"
194
+ className={clsx('azgrid', `azgrid-theme-${props.theme ?? (props.dark ? 'dark' : 'light')}`)}
184
195
  defaultFilterValue={props.details_filter}
185
196
  dataSource={details_dataSource}
186
197
  columns={cached_details_columns}
@@ -195,7 +206,7 @@ function DataGridDetailsWrapper(props: DataGridWrapperProps) {
195
206
  const finalresult = props.static_gridOptions || {};
196
207
  finalresult['renderDetailsGrid'] = renderDetailsGrid;
197
208
  return finalresult;
198
- }, [props.static_gridOptions]);
209
+ }, [props.static_gridOptions, props.theme, props.dark]);
199
210
 
200
211
  return <DataGridSizeWrapper {...props} static_gridOptions={static_gridOptions} />;
201
212
  }
@@ -253,7 +264,12 @@ function DataGridCore(props: DataGridWrapperProps) {
253
264
  handle={(ref) => {
254
265
  if (ref) props.gridRef.current = ref.current as any;
255
266
  }}
256
- className={'azgrid-flexed'}
267
+ theme="default-light"
268
+ className={clsx(
269
+ 'azgrid azgrid-flexed',
270
+ props.allowChildRows && 'azgrid-tree',
271
+ `azgrid-theme-${props.theme ?? (props.dark ? 'dark' : 'light')}`
272
+ )}
257
273
  columns={props.columns}
258
274
  dataSource={props.dataSource}
259
275
  />
@@ -1,4 +1,4 @@
1
- export * from './DataGrid';
2
-
3
- import AzGrid from './DataGrid';
4
- export default AzGrid;
1
+ export * from './DataGrid';
2
+
3
+ import AzGrid from './DataGrid';
4
+ export default AzGrid;