@azrico/reactgrid 1.3.54 → 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,92 +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
- }
13
-
14
- .InovuaReactDataGrid--theme-amber-dark {
15
- --grid-bg: #313943;
16
- --grid-fg: #c5cae9;
17
- --grid-bg-hover: oklch(var(--b2, 40.8% 0.011 128.75));
18
- --grid-fg-hover: #ececec;
19
- }
20
- .InovuaReactDataGrid__row {
21
- border: none !important;
22
- border-top-width: 0 !important;
23
- border-bottom-width: 0 !important;
24
- color: var(--grid-fg);
25
- }
26
- .InovuaReactDataGrid__cell {
27
- border: 0.1px solid rgba(1, 1, 1, 0.1) !important ;
28
- }
29
- .InovuaReactDataGrid--theme-default-light .InovuaReactDataGrid__row--odd {
30
- background-color: #fafafa;
31
- }
32
- .InovuaReactDataGrid--theme-default-light .InovuaReactDataGrid__row--even {
33
- background-color: #fff;
34
- }
35
- /* --------------------------- selected row color --------------------------- */
36
- .InovuaReactDataGrid
37
- .InovuaReactDataGrid__row--active
38
- .InovuaReactDataGrid__cell:not(.InovuaReactDataGrid__cell--no-background),
39
- .InovuaReactDataGrid
40
- .InovuaReactDataGrid__row--active.InovuaReactDataGrid__row--even
41
- .InovuaReactDataGrid__cell:not(.InovuaReactDataGrid__cell--no-background),
42
- .InovuaReactDataGrid
43
- .InovuaReactDataGrid__row--active.InovuaReactDataGrid__row--odd
44
- .InovuaReactDataGrid__cell:not(.InovuaReactDataGrid__cell--no-background) {
45
- color: var(--grid-fg-hover);
46
- }
47
- /* ----------------------------- hover row color ---------------------------- */
48
- .InovuaReactDataGrid--show-hover-rows
49
- .InovuaReactDataGrid__row:not(.InovuaReactDataGrid__row--scrolling):not(
50
- .InovuaReactDataGrid__row--empty
51
- )
52
- .InovuaReactDataGrid__row-hover-target:hover {
53
- background: var(--grid-bg-hover) !important;
54
- color: var(--grid-fg-hover) !important;
55
- }
56
- .InovuaReactDataGrid--theme-default-light.InovuaReactDataGrid--show-hover-rows
57
- .InovuaReactDataGrid__row--no-zebra:not(.InovuaReactDataGrid__row--scrolling):not(
58
- .InovuaReactDataGrid__row--empty
59
- )
60
- .InovuaReactDataGrid__row-hover-target:hover
61
- .InovuaReactDataGrid__row-index-column,
62
- .InovuaReactDataGrid--theme-default-light.InovuaReactDataGrid--show-hover-rows
63
- .InovuaReactDataGrid__row-hover-target:hover
64
- .InovuaReactDataGrid__row-index-column {
65
- background: var(--grid-bg-hover2) !important;
66
- }
67
- /* -------------------------------------------------------------------------- */
68
- .inovua-react-toolkit-text-input {
69
- font-family: inherit;
70
- }
71
- .inovua-react-toolkit-text-input input {
72
- font-family: inherit;
73
- }
74
-
75
- .InovuaReactDataGrid__cell .InovuaReactDataGrid__cell__content {
76
- height: 100%;
77
- display: flex;
78
- align-items: center;
79
- }
80
- .InovuaReactDataGrid__column-header__content {
81
- text-overflow: clip;
82
- }
83
-
84
- .InovuaReactDataGrid__row.deleted:after {
85
- position: absolute;
86
- content: '';
87
- left: 5px;
88
- top: 50%;
89
- right: 5px;
90
- border-top: 1.5px solid;
91
- 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;
92
17
  }
@@ -1,5 +1,5 @@
1
1
  import { ModifyFields } from '../func/func_grid';
2
- import { ConvertableToMenuItem } from '@azrico/controls';
2
+ import { ConvertableToMenuItem } from '@azrico/controls/context-menu';
3
3
  import React from 'react';
4
4
  import {
5
5
  TypeCellSelection,
@@ -96,6 +96,8 @@ export type AzGridProps = {
96
96
  //
97
97
 
98
98
  loading?: boolean;
99
+ theme?: 'light' | 'dark' | (string & {});
100
+ /** @deprecated Use theme="dark" or theme="light" instead. */
99
101
  dark?: boolean;
100
102
  delayedSize?: boolean;
101
103
  allowChildRows?: boolean;
@@ -1,11 +1,10 @@
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
4
  import { get_default_key } from '../func/func_grid';
7
- import { ContextMenu } from '@azrico/controls';
5
+ import { ContextMenu } from '@azrico/controls/context-menu';
8
6
  import React from 'react';
7
+ import { createTheme, ThemeProvider, useTheme } from '@mui/material/styles';
9
8
 
10
9
  import ReactDataGrid from '@inovua/reactdatagrid-enterprise';
11
10
  import clsx from 'clsx';
@@ -34,6 +33,7 @@ const defaultOptions: AzGridOptions = {
34
33
  const forcedOptions: AzGridOptions = {
35
34
  idProperty: '__table_id',
36
35
  nodesProperty: '__children',
36
+ theme: 'default-light',
37
37
  };
38
38
 
39
39
  const dynamic_option_names = ['selected', 'cellSelection', 'loading', 'limit', 'skip'];
@@ -67,7 +67,6 @@ export function AzGrid(props: AzGridProps) {
67
67
  editable: props.editable as any, //bug in types of the plugin
68
68
  treeColumn: props.allowChildRows ? firstcolumn.name : undefined,
69
69
  renderRowDetails: props.RowDetail,
70
- theme: props.dark ? 'amber-dark' : 'default-light',
71
70
  };
72
71
  return { ...defaultOptions, ...events, ...extra_ops };
73
72
  }, [
@@ -123,6 +122,16 @@ export function AzGrid(props: AzGridProps) {
123
122
  * @returns
124
123
  */
125
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')}`;
126
135
  /* -------------------------------------------------------------------------- */
127
136
  const {
128
137
  onRowClick,
@@ -155,20 +164,23 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
155
164
  /* -------------------------------------------------------------------------- */
156
165
  //TODO ContextMenu not from mui...
157
166
  return (
158
- <>
159
- <ContextMenu
160
- menuAnchorEl={menuAnchorEl}
161
- menuRow={menuRow}
162
- close={update_menuRow}
163
- dontAutoClose={false}
164
- menu_items={props.contextMenuItems as any}
165
- />
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>
166
178
  {props.details_dataSource ? (
167
179
  <DataGridDetailsWrapper {...props} static_gridOptions={static_gridOptions} />
168
180
  ) : (
169
181
  <DataGridSizeWrapper {...props} static_gridOptions={static_gridOptions} />
170
182
  )}
171
- </>
183
+ </div>
172
184
  );
173
185
  }
174
186
 
@@ -178,6 +190,8 @@ function DataGridDetailsWrapper(props: DataGridWrapperProps) {
178
190
  const renderDetailsGrid = ({ data }) => {
179
191
  return (
180
192
  <ReactDataGrid
193
+ theme="default-light"
194
+ className={clsx('azgrid', `azgrid-theme-${props.theme ?? (props.dark ? 'dark' : 'light')}`)}
181
195
  defaultFilterValue={props.details_filter}
182
196
  dataSource={details_dataSource}
183
197
  columns={cached_details_columns}
@@ -192,7 +206,7 @@ function DataGridDetailsWrapper(props: DataGridWrapperProps) {
192
206
  const finalresult = props.static_gridOptions || {};
193
207
  finalresult['renderDetailsGrid'] = renderDetailsGrid;
194
208
  return finalresult;
195
- }, [props.static_gridOptions]);
209
+ }, [props.static_gridOptions, props.theme, props.dark]);
196
210
 
197
211
  return <DataGridSizeWrapper {...props} static_gridOptions={static_gridOptions} />;
198
212
  }
@@ -250,7 +264,12 @@ function DataGridCore(props: DataGridWrapperProps) {
250
264
  handle={(ref) => {
251
265
  if (ref) props.gridRef.current = ref.current as any;
252
266
  }}
253
- 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
+ )}
254
273
  columns={props.columns}
255
274
  dataSource={props.dataSource}
256
275
  />