@etsoo/react 1.4.15 → 1.4.19

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.
@@ -1,11 +1,12 @@
1
+ import { Utils } from '@etsoo/shared';
1
2
  import React from 'react';
2
3
  import { FixedSizeList, VariableSizeList } from 'react-window';
3
4
  import useCombinedRefs from '../uses/useCombinedRefs';
4
5
  import { GridSizeGet } from './GridLoader';
5
6
  // Calculate loadBatchSize
6
7
  const calculateBatchSize = (height, itemSize) => {
7
- return (2 +
8
- Math.ceil(height / (typeof itemSize === 'function' ? itemSize(0) : itemSize)));
8
+ const size = Utils.getResult(itemSize, 0);
9
+ return 2 + Math.ceil(height / size);
9
10
  };
10
11
  /**
11
12
  * Scroller vertical list
@@ -23,9 +23,8 @@ export function ResponsibleContainer(props) {
23
23
  const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
24
24
  const rect = dimensions[0][2];
25
25
  const showDataGrid = ((_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0) >= dataGridMinWidth;
26
- console.log(hasFields, showDataGrid, refs);
27
26
  React.useEffect(() => {
28
- if (rect != null && rect.height > 50 && height == null) {
27
+ if (rect != null && rect.height >= 0 && height == null) {
29
28
  let gridHeight = window.innerHeight - Math.round(rect.top + rect.height + 1);
30
29
  const style = window.getComputedStyle(dimensions[0][1]);
31
30
  const boxPadding = parseFloat(style.paddingLeft);
@@ -44,6 +43,7 @@ export function ResponsibleContainer(props) {
44
43
  return loadData(data);
45
44
  };
46
45
  const gridHeight = refs.current.height;
46
+ console.log(rect, gridHeight, showDataGrid);
47
47
  const list = React.useMemo(() => {
48
48
  if (gridHeight == null)
49
49
  return;
@@ -72,7 +72,7 @@ export function ResponsibleContainer(props) {
72
72
  refs.current.ref.reset({ data });
73
73
  };
74
74
  // Layout
75
- return (React.createElement(Stack, null,
75
+ return (React.createElement(Stack, { ref: hasFields ? undefined : dimensions[0][0] },
76
76
  hasFields && (React.createElement(Box, { ref: dimensions[0][0], sx: searchBoxSx },
77
77
  React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit }))),
78
78
  list));
@@ -7,7 +7,7 @@ export interface TabBoxPanel extends Omit<TabProps, 'value' | 'children'> {
7
7
  /**
8
8
  * Children
9
9
  */
10
- children?: React.ReactNode;
10
+ children?: ((visible: boolean) => React.ReactNode) | React.ReactNode;
11
11
  /**
12
12
  * Panel box props
13
13
  */
package/lib/mu/TabBox.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { Utils } from '@etsoo/shared';
1
2
  import { Box, Tab, Tabs } from '@mui/material';
2
3
  import React from 'react';
3
4
  /**
@@ -20,5 +21,5 @@ export function TabBox(props) {
20
21
  if (onChange)
21
22
  onChange(event, newValue);
22
23
  }, ...rest }, tabs.map(({ children, panel, ...tabRest }, index) => (React.createElement(Tab, { key: index, value: index, ...tabRest }))))),
23
- tabs.map(({ children, panel }, index) => (React.createElement(Box, { key: index, hidden: value !== index, ...panel }, children)))));
24
+ tabs.map(({ children, panel }, index) => (React.createElement(Box, { key: index, hidden: value !== index, ...panel }, Utils.getResult(children, value === index))))));
24
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.4.15",
3
+ "version": "1.4.19",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,9 +50,9 @@
50
50
  "@emotion/react": "^11.7.1",
51
51
  "@emotion/style": "^0.8.0",
52
52
  "@emotion/styled": "^11.6.0",
53
- "@etsoo/appscript": "^1.2.20",
53
+ "@etsoo/appscript": "^1.2.21",
54
54
  "@etsoo/notificationbase": "^1.1.0",
55
- "@etsoo/shared": "^1.1.0",
55
+ "@etsoo/shared": "^1.1.3",
56
56
  "@mui/icons-material": "^5.2.5",
57
57
  "@mui/material": "^5.2.7",
58
58
  "@reach/router": "^1.3.4",
@@ -1,3 +1,4 @@
1
+ import { Utils } from '@etsoo/shared';
1
2
  import React from 'react';
2
3
  import {
3
4
  Align,
@@ -88,12 +89,8 @@ const calculateBatchSize = (
88
89
  height: number,
89
90
  itemSize: ((index: number) => number) | number
90
91
  ) => {
91
- return (
92
- 2 +
93
- Math.ceil(
94
- height / (typeof itemSize === 'function' ? itemSize(0) : itemSize)
95
- )
96
- );
92
+ const size = Utils.getResult(itemSize, 0);
93
+ return 2 + Math.ceil(height / size);
97
94
  };
98
95
 
99
96
  /**
@@ -151,10 +151,8 @@ export function ResponsibleContainer<
151
151
  const rect = dimensions[0][2];
152
152
  const showDataGrid = (rect?.width ?? 0) >= dataGridMinWidth;
153
153
 
154
- console.log(hasFields, showDataGrid, refs);
155
-
156
154
  React.useEffect(() => {
157
- if (rect != null && rect.height > 50 && height == null) {
155
+ if (rect != null && rect.height >= 0 && height == null) {
158
156
  let gridHeight =
159
157
  window.innerHeight - Math.round(rect.top + rect.height + 1);
160
158
 
@@ -178,6 +176,7 @@ export function ResponsibleContainer<
178
176
  };
179
177
 
180
178
  const gridHeight = refs.current.height;
179
+ console.log(rect, gridHeight, showDataGrid);
181
180
  const list = React.useMemo(() => {
182
181
  if (gridHeight == null) return;
183
182
 
@@ -230,7 +229,7 @@ export function ResponsibleContainer<
230
229
 
231
230
  // Layout
232
231
  return (
233
- <Stack>
232
+ <Stack ref={hasFields ? undefined : dimensions[0][0]}>
234
233
  {hasFields && (
235
234
  <Box ref={dimensions[0][0]} sx={searchBoxSx}>
236
235
  <SearchBar fields={fields} onSubmit={onSubmit} />
package/src/mu/TabBox.tsx CHANGED
@@ -1,3 +1,4 @@
1
+ import { Utils } from '@etsoo/shared';
1
2
  import { Box, BoxProps, Tab, TabProps, Tabs, TabsProps } from '@mui/material';
2
3
  import React from 'react';
3
4
 
@@ -8,7 +9,7 @@ export interface TabBoxPanel extends Omit<TabProps, 'value' | 'children'> {
8
9
  /**
9
10
  * Children
10
11
  */
11
- children?: React.ReactNode;
12
+ children?: ((visible: boolean) => React.ReactNode) | React.ReactNode;
12
13
 
13
14
  /**
14
15
  * Panel box props
@@ -76,7 +77,7 @@ export function TabBox(props: TabBoxPros) {
76
77
  </Box>
77
78
  {tabs.map(({ children, panel }, index) => (
78
79
  <Box key={index} hidden={value !== index} {...panel}>
79
- {children}
80
+ {Utils.getResult(children, value === index)}
80
81
  </Box>
81
82
  ))}
82
83
  </React.Fragment>