@etsoo/react 1.4.19 → 1.4.20

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.
@@ -7,7 +7,6 @@ import { DataGridEx, DataGridExCalColumns } from './DataGridEx';
7
7
  import { ScrollerListEx } from './ScrollerListEx';
8
8
  import { SearchBar } from './SearchBar';
9
9
  export function ResponsibleContainer(props) {
10
- var _a;
11
10
  // Destruct
12
11
  const { adjustHeight, columns, dataGridMinWidth = DataGridExCalColumns(columns).total, fields, fieldTemplate, height, listBoxSx, loadData, mRef, searchBoxSx, sizeReadyMiliseconds = 0, ...rest } = props;
13
12
  // Refs
@@ -22,36 +21,43 @@ export function ResponsibleContainer(props) {
22
21
  // Watch container
23
22
  const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
24
23
  const rect = dimensions[0][2];
25
- const showDataGrid = ((_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0) >= dataGridMinWidth;
26
- React.useEffect(() => {
27
- if (rect != null && rect.height >= 0 && height == null) {
28
- let gridHeight = window.innerHeight - Math.round(rect.top + rect.height + 1);
24
+ const localLoadData = (props) => {
25
+ const data = GridDataGet(props, fieldTemplate);
26
+ return loadData(data);
27
+ };
28
+ const list = React.useMemo(() => {
29
+ // No rect
30
+ if (rect == null)
31
+ return;
32
+ // If height is the same
33
+ let heightLocal;
34
+ if (height != null) {
35
+ heightLocal = height;
36
+ }
37
+ else {
38
+ // Auto calculation
39
+ heightLocal =
40
+ window.innerHeight - Math.round(rect.top + rect.height + 1);
29
41
  const style = window.getComputedStyle(dimensions[0][1]);
30
42
  const boxPadding = parseFloat(style.paddingLeft);
31
43
  if (!isNaN(boxPadding))
32
- gridHeight -= 2 * boxPadding;
44
+ heightLocal -= 2 * boxPadding;
33
45
  if (adjustHeight != null) {
34
- gridHeight -= adjustHeight(gridHeight);
35
- }
36
- if (gridHeight !== refs.current.height) {
37
- refs.current.height = gridHeight;
46
+ heightLocal -= adjustHeight(heightLocal);
38
47
  }
39
48
  }
40
- }, [rect]);
41
- const localLoadData = (props) => {
42
- const data = GridDataGet(props, fieldTemplate);
43
- return loadData(data);
44
- };
45
- const gridHeight = refs.current.height;
46
- console.log(rect, gridHeight, showDataGrid);
47
- const list = React.useMemo(() => {
48
- if (gridHeight == null)
49
+ console.log(rect, heightLocal, refs.current.height);
50
+ // Same height
51
+ if (heightLocal === refs.current.height)
49
52
  return;
53
+ refs.current.height = heightLocal;
54
+ // Show DataGrid or List dependng on width
55
+ const showDataGrid = rect.width >= dataGridMinWidth;
50
56
  if (showDataGrid) {
51
57
  // Delete
52
58
  delete rest.itemRenderer;
53
59
  return (React.createElement(Box, { sx: listBoxSx == null ? undefined : listBoxSx(true) },
54
- React.createElement(DataGridEx, { autoLoad: !hasFields, height: gridHeight, loadData: localLoadData, mRef: mRefs, columns: columns, ...rest })));
60
+ React.createElement(DataGridEx, { autoLoad: !hasFields, height: heightLocal, loadData: localLoadData, mRef: mRefs, columns: columns, ...rest })));
55
61
  }
56
62
  // Delete
57
63
  delete rest.checkable;
@@ -63,8 +69,8 @@ export function ResponsibleContainer(props) {
63
69
  delete rest.hoverColor;
64
70
  delete rest.selectable;
65
71
  return (React.createElement(Box, { sx: listBoxSx == null ? undefined : listBoxSx(false) },
66
- React.createElement(ScrollerListEx, { autoLoad: !hasFields, height: gridHeight, loadData: localLoadData, mRef: mRefs, ...rest })));
67
- }, [gridHeight, showDataGrid]);
72
+ React.createElement(ScrollerListEx, { autoLoad: !hasFields, height: heightLocal, loadData: localLoadData, mRef: mRefs, ...rest })));
73
+ }, [rect, height]);
68
74
  // On submit callback
69
75
  const onSubmit = (data, _reset) => {
70
76
  if (data == null || rect == null || refs.current.ref == null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.4.19",
3
+ "version": "1.4.20",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -149,36 +149,42 @@ export function ResponsibleContainer<
149
149
  // Watch container
150
150
  const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
151
151
  const rect = dimensions[0][2];
152
- const showDataGrid = (rect?.width ?? 0) >= dataGridMinWidth;
153
152
 
154
- React.useEffect(() => {
155
- if (rect != null && rect.height >= 0 && height == null) {
156
- let gridHeight =
153
+ const localLoadData = (props: GridLoadDataProps) => {
154
+ const data = GridDataGet(props, fieldTemplate);
155
+ return loadData(data);
156
+ };
157
+
158
+ const list = React.useMemo(() => {
159
+ // No rect
160
+ if (rect == null) return;
161
+
162
+ // If height is the same
163
+ let heightLocal: number;
164
+ if (height != null) {
165
+ heightLocal = height;
166
+ } else {
167
+ // Auto calculation
168
+ heightLocal =
157
169
  window.innerHeight - Math.round(rect.top + rect.height + 1);
158
170
 
159
171
  const style = window.getComputedStyle(dimensions[0][1]!);
160
172
  const boxPadding = parseFloat(style.paddingLeft);
161
- if (!isNaN(boxPadding)) gridHeight -= 2 * boxPadding;
173
+ if (!isNaN(boxPadding)) heightLocal -= 2 * boxPadding;
162
174
 
163
175
  if (adjustHeight != null) {
164
- gridHeight -= adjustHeight(gridHeight);
165
- }
166
-
167
- if (gridHeight !== refs.current.height) {
168
- refs.current.height = gridHeight;
176
+ heightLocal -= adjustHeight(heightLocal);
169
177
  }
170
178
  }
171
- }, [rect]);
172
179
 
173
- const localLoadData = (props: GridLoadDataProps) => {
174
- const data = GridDataGet(props, fieldTemplate);
175
- return loadData(data);
176
- };
180
+ console.log(rect, heightLocal, refs.current.height);
177
181
 
178
- const gridHeight = refs.current.height;
179
- console.log(rect, gridHeight, showDataGrid);
180
- const list = React.useMemo(() => {
181
- if (gridHeight == null) return;
182
+ // Same height
183
+ if (heightLocal === refs.current.height) return;
184
+ refs.current.height = heightLocal;
185
+
186
+ // Show DataGrid or List dependng on width
187
+ const showDataGrid = rect.width >= dataGridMinWidth;
182
188
 
183
189
  if (showDataGrid) {
184
190
  // Delete
@@ -188,7 +194,7 @@ export function ResponsibleContainer<
188
194
  <Box sx={listBoxSx == null ? undefined : listBoxSx(true)}>
189
195
  <DataGridEx<T>
190
196
  autoLoad={!hasFields}
191
- height={gridHeight}
197
+ height={heightLocal}
192
198
  loadData={localLoadData}
193
199
  mRef={mRefs}
194
200
  columns={columns}
@@ -212,14 +218,14 @@ export function ResponsibleContainer<
212
218
  <Box sx={listBoxSx == null ? undefined : listBoxSx(false)}>
213
219
  <ScrollerListEx<T>
214
220
  autoLoad={!hasFields}
215
- height={gridHeight}
221
+ height={heightLocal}
216
222
  loadData={localLoadData}
217
223
  mRef={mRefs}
218
224
  {...rest}
219
225
  />
220
226
  </Box>
221
227
  );
222
- }, [gridHeight, showDataGrid]);
228
+ }, [rect, height]);
223
229
 
224
230
  // On submit callback
225
231
  const onSubmit = (data: FormData, _reset: boolean) => {