@etsoo/materialui 1.1.54 → 1.1.55

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,19 +1,23 @@
1
- import { DataTypes, IdDefaultType } from '@etsoo/shared';
2
- import { SxProps, Theme } from '@mui/material';
3
- import React from 'react';
4
- import { ListChildComponentProps } from 'react-window';
5
- import { GridColumn, GridJsonData, GridMethodRef } from '@etsoo/react';
6
- import { DataGridExProps } from './DataGridEx';
7
- import { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from './ScrollerListEx';
1
+ import { DataTypes, IdDefaultType } from "@etsoo/shared";
2
+ import { SxProps, Theme } from "@mui/material";
3
+ import React from "react";
4
+ import { ListChildComponentProps } from "react-window";
5
+ import { GridColumn, GridJsonData, GridMethodRef } from "@etsoo/react";
6
+ import { DataGridExProps } from "./DataGridEx";
7
+ import { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from "./ScrollerListEx";
8
8
  /**
9
9
  * ResponsibleContainer props
10
10
  */
11
- export type ResponsibleContainerProps<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>> = Omit<DataGridExProps<T, D>, 'height' | 'itemKey' | 'loadData' | 'mRef' | 'onScroll' | 'onItemsRendered'> & {
11
+ export type ResponsibleContainerProps<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>> = Omit<DataGridExProps<T, D>, "height" | "itemKey" | "loadData" | "mRef" | "onScroll" | "onItemsRendered"> & {
12
12
  /**
13
13
  * Height will be deducted
14
14
  * @param height Current calcuated height
15
15
  */
16
16
  adjustHeight?: (height: number) => number;
17
+ /**
18
+ * Top height
19
+ */
20
+ topHeight?: number;
17
21
  /**
18
22
  * Columns
19
23
  */
@@ -1,16 +1,16 @@
1
- import { Box, Stack } from '@mui/material';
2
- import React from 'react';
3
- import { GridDataGet, ReactUtils, useCombinedRefs, useDimensions } from '@etsoo/react';
4
- import { DataGridEx, DataGridExCalColumns } from './DataGridEx';
5
- import { MUGlobal } from './MUGlobal';
6
- import { PullToRefreshUI } from './PullToRefreshUI';
7
- import { ScrollerListEx } from './ScrollerListEx';
8
- import { SearchBar } from './SearchBar';
9
- import { Labels } from './app/Labels';
1
+ import { Box, Stack } from "@mui/material";
2
+ import React from "react";
3
+ import { GridDataGet, ReactUtils, useCombinedRefs, useDimensions } from "@etsoo/react";
4
+ import { DataGridEx, DataGridExCalColumns } from "./DataGridEx";
5
+ import { MUGlobal } from "./MUGlobal";
6
+ import { PullToRefreshUI } from "./PullToRefreshUI";
7
+ import { ScrollerListEx } from "./ScrollerListEx";
8
+ import { SearchBar } from "./SearchBar";
9
+ import { Labels } from "./app/Labels";
10
10
  function defaultContainerBoxSx(paddings, hasField, _dataGrid) {
11
11
  const half = MUGlobal.half(paddings);
12
12
  return {
13
- '& .SearchBox': {
13
+ "& .SearchBox": {
14
14
  marginBottom: hasField ? half : 0
15
15
  }
16
16
  };
@@ -22,7 +22,7 @@ function defaultContainerBoxSx(paddings, hasField, _dataGrid) {
22
22
  */
23
23
  export function ResponsibleContainer(props) {
24
24
  // Destruct
25
- const { adjustHeight, columns, containerBoxSx = defaultContainerBoxSx, dataGridMinWidth = Math.max(576, DataGridExCalColumns(columns).total), elementReady, fields, fieldTemplate, height, loadData, mRef, paddings = MUGlobal.pagePaddings, pullToRefresh = true, quickAction, sizeReadyMiliseconds = 0, ...rest } = props;
25
+ const { adjustHeight, columns, containerBoxSx = defaultContainerBoxSx, dataGridMinWidth = Math.max(576, DataGridExCalColumns(columns).total), elementReady, fields, fieldTemplate, height, topHeight, loadData, mRef, paddings = MUGlobal.pagePaddings, pullToRefresh = true, quickAction, sizeReadyMiliseconds = 0, ...rest } = props;
26
26
  // Labels
27
27
  const labels = Labels.CommonPage;
28
28
  // Refs
@@ -90,7 +90,7 @@ export function ResponsibleContainer(props) {
90
90
  // Auto calculation
91
91
  heightLocal =
92
92
  document.documentElement.clientHeight -
93
- Math.round(rect.bottom + 1);
93
+ (topHeight !== null && topHeight !== void 0 ? topHeight : Math.round(rect.bottom + 1));
94
94
  const style = window.getComputedStyle(dimensions[0][1]);
95
95
  const boxMargin = parseFloat(style.marginBottom);
96
96
  if (!isNaN(boxMargin))
@@ -122,9 +122,7 @@ export function ResponsibleContainer(props) {
122
122
  delete rest.selectable;
123
123
  return [
124
124
  React.createElement(Box, { className: "ListBox", sx: { height: heightLocal } },
125
- React.createElement(ScrollerListEx, { autoLoad: !hasFields, height: heightLocal, loadData: localLoadData, mRef: mRefs, onClick: (event, data) => quickAction &&
126
- ReactUtils.isSafeClick(event) &&
127
- quickAction(data), oRef: (element) => {
125
+ React.createElement(ScrollerListEx, { autoLoad: !hasFields, height: heightLocal, loadData: localLoadData, mRef: mRefs, onClick: (event, data) => quickAction && ReactUtils.isSafeClick(event) && quickAction(data), oRef: (element) => {
128
126
  if (element != null && elementReady)
129
127
  elementReady(element, false);
130
128
  }, ...rest })),
@@ -134,14 +132,14 @@ export function ResponsibleContainer(props) {
134
132
  const searchBar = React.useMemo(() => {
135
133
  if (!hasFields || showDataGrid == null)
136
134
  return;
137
- return (React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit, className: `searchBar${showDataGrid ? 'Grid' : 'List'}` }));
135
+ return (React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}` }));
138
136
  }, [showDataGrid, hasFields]);
139
137
  // Pull container
140
138
  const pullContainer = showDataGrid == null
141
139
  ? undefined
142
140
  : showDataGrid
143
- ? '.DataGridEx-Body'
144
- : '.ScrollerListEx-Body';
141
+ ? ".DataGridEx-Body"
142
+ : ".ScrollerListEx-Body";
145
143
  // Layout
146
144
  return (React.createElement(Box, { sx: containerBoxSx == null
147
145
  ? undefined
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  /**
3
3
  * Search bar props
4
4
  */
package/lib/SearchBar.js CHANGED
@@ -1,31 +1,31 @@
1
- import { Button, Drawer, IconButton, Stack, useTheme } from '@mui/material';
2
- import React from 'react';
3
- import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
4
- import { DomUtils } from '@etsoo/shared';
5
- import { ReactUtils, useDelayedExecutor, useDimensions } from '@etsoo/react';
6
- import { Labels } from './app/Labels';
1
+ import { Button, Drawer, IconButton, Stack, useTheme } from "@mui/material";
2
+ import React from "react";
3
+ import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
4
+ import { DomUtils } from "@etsoo/shared";
5
+ import { ReactUtils, useDelayedExecutor, useDimensions } from "@etsoo/react";
6
+ import { Labels } from "./app/Labels";
7
7
  // Cached width attribute name
8
- const cachedWidthName = 'data-cached-width';
8
+ const cachedWidthName = "data-cached-width";
9
9
  // Reset form
10
10
  const resetForm = (form) => {
11
11
  for (const input of form.elements) {
12
12
  // Ignore disabled inputs
13
- if ('disabled' in input && input.disabled)
13
+ if ("disabled" in input && input.disabled)
14
14
  continue;
15
15
  // All non hidden inputs
16
16
  if (input instanceof HTMLInputElement) {
17
17
  // Ignore hidden input
18
- if (input.type === 'hidden')
18
+ if (input.type === "hidden")
19
19
  continue;
20
20
  // Ignore readOnly without data-reset=true inputs
21
- if (!input.readOnly || input.dataset.reset === 'true') {
22
- ReactUtils.triggerChange(input, '', true);
21
+ if (!input.readOnly || input.dataset.reset === "true") {
22
+ ReactUtils.triggerChange(input, "", true);
23
23
  }
24
24
  continue;
25
25
  }
26
26
  // All selects
27
27
  if (input instanceof HTMLSelectElement) {
28
- if (input.options.length > 0 && input.options[0].value === '') {
28
+ if (input.options.length > 0 && input.options[0].value === "") {
29
29
  input.selectedIndex = 0;
30
30
  }
31
31
  else {
@@ -35,12 +35,12 @@ const resetForm = (form) => {
35
35
  }
36
36
  }
37
37
  // Trigger reset event
38
- const resetEvent = new Event('reset');
38
+ const resetEvent = new Event("reset");
39
39
  form.dispatchEvent(resetEvent);
40
40
  };
41
41
  // Disable inputs avoid auto trigger change events for them
42
42
  const setChildState = (child, enabled) => {
43
- const inputs = child.getElementsByTagName('input');
43
+ const inputs = child.getElementsByTagName("input");
44
44
  for (const input of inputs) {
45
45
  input.disabled = !enabled;
46
46
  }
@@ -74,13 +74,13 @@ export function SearchBar(props) {
74
74
  const len = target.children.length;
75
75
  for (let i = 0; i < len; i++) {
76
76
  var classList = target.children[i].classList;
77
- classList.remove('showChild');
77
+ classList.remove("showChild");
78
78
  }
79
79
  }, 0);
80
80
  // Show or hide element
81
81
  const setElementVisible = (element, visible) => {
82
- element.classList.remove(visible ? 'hiddenChild' : 'showChild');
83
- element.classList.add(visible ? 'showChild' : 'hiddenChild');
82
+ element.classList.remove(visible ? "hiddenChild" : "showChild");
83
+ element.classList.add(visible ? "showChild" : "hiddenChild");
84
84
  };
85
85
  // Reset button ref
86
86
  const resetButtonRef = (instance) => {
@@ -90,9 +90,7 @@ export function SearchBar(props) {
90
90
  return;
91
91
  // First
92
92
  const [_, container, containerRect] = dimensions[0];
93
- if (container == null ||
94
- containerRect == null ||
95
- containerRect.width < 10)
93
+ if (container == null || containerRect == null || containerRect.width < 10)
96
94
  return;
97
95
  // Container width
98
96
  let maxWidth = containerRect.width;
@@ -226,26 +224,28 @@ export function SearchBar(props) {
226
224
  state.form = form;
227
225
  } },
228
226
  React.createElement(Stack, { ref: dimensions[0][0], justifyContent: "center", alignItems: "center", direction: "row", spacing: 1, height: innerHeight, sx: {
229
- '& > :not(style)': {
230
- flexBasis: 'auto',
227
+ "& > :not(style)": {
228
+ flexBasis: "auto",
231
229
  flexGrow: 0,
232
230
  flexShrink: 0,
233
- maxWidth: '180px',
234
- visibility: 'hidden'
231
+ maxWidth: "180px"
235
232
  },
236
- '& > .hiddenChild': {
237
- display: 'none'
233
+ "& > :not:first-child": {
234
+ visibility: "hidden"
238
235
  },
239
- '& > .showChild': {
240
- display: 'block',
241
- visibility: 'visible'
236
+ "& > .hiddenChild": {
237
+ display: "none"
238
+ },
239
+ "& > .showChild": {
240
+ display: "block",
241
+ visibility: "visible"
242
242
  }
243
243
  } },
244
244
  fields.map((item, index) => (React.createElement(React.Fragment, { key: index }, item))),
245
245
  React.createElement(IconButton, { "aria-label": "delete", size: "medium", onClick: handleMore },
246
246
  React.createElement(MoreHorizIcon, null)),
247
247
  React.createElement(Button, { variant: "contained", size: "medium", ref: resetButtonRef, onClick: handleReset }, labels.reset))),
248
- index != null && index < fields.length && (React.createElement(Drawer, { anchor: "right", sx: { minWidth: '250px' }, ModalProps: {
248
+ index != null && index < fields.length && (React.createElement(Drawer, { anchor: "right", sx: { minWidth: "250px" }, ModalProps: {
249
249
  keepMounted: true // Better open performance on mobile.
250
250
  }, open: open, onClose: () => updateOpen(false) },
251
251
  React.createElement("form", { onChange: moreFormChange, ref: (form) => {
@@ -253,8 +253,8 @@ export function SearchBar(props) {
253
253
  state.moreForm = form;
254
254
  } },
255
255
  React.createElement(Stack, { direction: "column", alignItems: "stretch", spacing: 2, padding: 2, sx: {
256
- '& > :not(style)': {
257
- minWidth: '100px'
256
+ "& > :not(style)": {
257
+ minWidth: "100px"
258
258
  }
259
259
  } }, moreItems))))));
260
260
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.1.54",
3
+ "version": "1.1.55",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,13 +50,13 @@
50
50
  "@emotion/css": "^11.10.6",
51
51
  "@emotion/react": "^11.10.6",
52
52
  "@emotion/styled": "^11.10.6",
53
- "@etsoo/appscript": "^1.3.80",
53
+ "@etsoo/appscript": "^1.3.81",
54
54
  "@etsoo/notificationbase": "^1.1.24",
55
- "@etsoo/react": "^1.6.51",
55
+ "@etsoo/react": "^1.6.52",
56
56
  "@etsoo/shared": "^1.1.92",
57
57
  "@mui/icons-material": "^5.11.11",
58
58
  "@mui/material": "^5.11.14",
59
- "@mui/x-data-grid": "^6.0.2",
59
+ "@mui/x-data-grid": "^6.0.3",
60
60
  "@types/pica": "^9.0.1",
61
61
  "@types/pulltorefreshjs": "^0.1.5",
62
62
  "@types/react": "^18.0.28",