@etsoo/materialui 1.1.54 → 1.1.56

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
  */
@@ -78,6 +82,10 @@ export type ResponsibleContainerProps<T extends object, F extends DataTypes.Basi
78
82
  * Size ready to read miliseconds span
79
83
  */
80
84
  sizeReadyMiliseconds?: number;
85
+ /**
86
+ * SearchBar height
87
+ */
88
+ searchBarHeight?: number;
81
89
  };
82
90
  /**
83
91
  * Responsible container
@@ -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, searchBarHeight, ...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'}` }));
138
- }, [showDataGrid, hasFields]);
135
+ return (React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}`, innerHeight: searchBarHeight }));
136
+ }, [showDataGrid, hasFields, searchBarHeight]);
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
  }
@@ -52,7 +52,7 @@ const setChildState = (child, enabled) => {
52
52
  */
53
53
  export function SearchBar(props) {
54
54
  // Destruct
55
- const { className, fields, innerHeight = 40, onSubmit } = props;
55
+ const { className, fields, innerHeight = 45.6, onSubmit } = props;
56
56
  // Labels
57
57
  const labels = Labels.CommonPage;
58
58
  // Spacing
@@ -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;
@@ -225,27 +223,27 @@ export function SearchBar(props) {
225
223
  if (form)
226
224
  state.form = form;
227
225
  } },
228
- React.createElement(Stack, { ref: dimensions[0][0], justifyContent: "center", alignItems: "center", direction: "row", spacing: 1, height: innerHeight, sx: {
229
- '& > :not(style)': {
230
- flexBasis: 'auto',
226
+ React.createElement(Stack, { ref: dimensions[0][0], justifyContent: "center", alignItems: "center", direction: "row", spacing: 1, height: innerHeight < 1 ? undefined : innerHeight, sx: {
227
+ "& > :not(style)": {
228
+ flexBasis: "auto",
231
229
  flexGrow: 0,
232
230
  flexShrink: 0,
233
- maxWidth: '180px',
234
- visibility: 'hidden'
231
+ maxWidth: "180px",
232
+ visibility: "hidden"
235
233
  },
236
- '& > .hiddenChild': {
237
- display: 'none'
234
+ "& > .hiddenChild": {
235
+ display: "none"
238
236
  },
239
- '& > .showChild': {
240
- display: 'block',
241
- visibility: 'visible'
237
+ "& > .showChild": {
238
+ display: "block",
239
+ visibility: "visible"
242
240
  }
243
241
  } },
244
242
  fields.map((item, index) => (React.createElement(React.Fragment, { key: index }, item))),
245
243
  React.createElement(IconButton, { "aria-label": "delete", size: "medium", onClick: handleMore },
246
244
  React.createElement(MoreHorizIcon, null)),
247
245
  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: {
246
+ index != null && index < fields.length && (React.createElement(Drawer, { anchor: "right", sx: { minWidth: "250px" }, ModalProps: {
249
247
  keepMounted: true // Better open performance on mobile.
250
248
  }, open: open, onClose: () => updateOpen(false) },
251
249
  React.createElement("form", { onChange: moreFormChange, ref: (form) => {
@@ -253,8 +251,8 @@ export function SearchBar(props) {
253
251
  state.moreForm = form;
254
252
  } },
255
253
  React.createElement(Stack, { direction: "column", alignItems: "stretch", spacing: 2, padding: 2, sx: {
256
- '& > :not(style)': {
257
- minWidth: '100px'
254
+ "& > :not(style)": {
255
+ minWidth: "100px"
258
256
  }
259
257
  } }, moreItems))))));
260
258
  }
@@ -61,10 +61,11 @@ export interface IReactAppBase {
61
61
  */
62
62
  setPageData(data: IPageData): void;
63
63
  /**
64
- * Set page title and data
65
- * @param key Page title resource key
64
+ * Set page title and subtitle
65
+ * @param title Page title
66
+ * @param subtitle Page subtitle
66
67
  */
67
- setPageKey(key: string): void;
68
+ setPageTitle(title: string, subtitle?: string): void;
68
69
  /**
69
70
  * Set page title and data
70
71
  * @param title Page title
@@ -183,10 +184,11 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
183
184
  */
184
185
  setPageData(data: P): void;
185
186
  /**
186
- * Set page title and data
187
+ * Set page title and subtitle
187
188
  * @param title Page title
189
+ * @param subtitle Page subtitle
188
190
  */
189
- setPageTitle(title: string): void;
191
+ setPageTitle(title: string, subtitle?: string): void;
190
192
  /**
191
193
  * Navigate to Url or delta
192
194
  * @param url Url or delta
@@ -206,12 +206,13 @@ export class ReactApp extends CoreApp {
206
206
  }
207
207
  }
208
208
  /**
209
- * Set page title and data
209
+ * Set page title and subtitle
210
210
  * @param title Page title
211
+ * @param subtitle Page subtitle
211
212
  */
212
- setPageTitle(title) {
213
+ setPageTitle(title, subtitle) {
213
214
  // Data
214
- const data = { title };
215
+ const data = { title, subtitle };
215
216
  // Dispatch the change
216
217
  if (this.pageStateDispatch != null) {
217
218
  this.pageStateDispatch({
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { DataTypes, IdDefaultType } from '@etsoo/shared';
3
- import { ResponsePageProps } from './ResponsivePageProps';
2
+ import { DataTypes, IdDefaultType } from "@etsoo/shared";
3
+ import { ResponsePageProps } from "./ResponsivePageProps";
4
4
  /**
5
5
  * Fixed height list page
6
6
  * @param props Props
@@ -1,7 +1,7 @@
1
- import React from 'react';
2
- import { MUGlobal } from '../MUGlobal';
3
- import { ResponsibleContainer } from '../ResponsibleContainer';
4
- import { CommonPage } from './CommonPage';
1
+ import React from "react";
2
+ import { MUGlobal } from "../MUGlobal";
3
+ import { ResponsibleContainer } from "../ResponsibleContainer";
4
+ import { CommonPage } from "./CommonPage";
5
5
  /**
6
6
  * Fixed height list page
7
7
  * @param props Props
@@ -24,15 +24,15 @@ export function ResponsivePage(props) {
24
24
  // .SearchBox keep the same to avoid flick when switching between DataGrid and List
25
25
  return {
26
26
  paddingTop: paddings,
27
- '& .SearchBox': {
27
+ "& .SearchBox": {
28
28
  marginLeft: paddings,
29
29
  marginRight: paddings,
30
30
  marginBottom: hasField ? half : 0
31
31
  },
32
- '& .ListBox': {
32
+ "& .ListBox": {
33
33
  marginBottom: paddings
34
34
  },
35
- '& .DataGridBox': {
35
+ "& .DataGridBox": {
36
36
  marginLeft: paddings,
37
37
  marginRight: paddings,
38
38
  marginBottom: paddings
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" />
2
- import { GridJsonData, GridLoader } from '@etsoo/react';
3
- import { DataTypes } from '@etsoo/shared';
4
- import { CommonPageProps } from './CommonPageProps';
2
+ import { GridJsonData, GridLoader } from "@etsoo/react";
3
+ import { DataTypes } from "@etsoo/shared";
4
+ import { CommonPageProps } from "./CommonPageProps";
5
5
  /**
6
6
  * Search page props
7
7
  */
8
- export type SearchPageProps<T extends object, F extends DataTypes.BasicTemplate> = Omit<GridLoader<T>, 'loadData'> & {
8
+ export type SearchPageProps<T extends object, F extends DataTypes.BasicTemplate> = Omit<GridLoader<T>, "loadData"> & {
9
9
  /**
10
10
  * Search fields
11
11
  */
@@ -27,4 +27,12 @@ export type SearchPageProps<T extends object, F extends DataTypes.BasicTemplate>
27
27
  * @default 100
28
28
  */
29
29
  sizeReadyMiliseconds?: number;
30
+ /**
31
+ * Top height
32
+ */
33
+ topHeight?: number;
34
+ /**
35
+ * SearchBar height
36
+ */
37
+ searchBarHeight?: number;
30
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.1.54",
3
+ "version": "1.1.56",
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",