@etsoo/materialui 1.1.24 → 1.1.26

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.
@@ -67,6 +67,10 @@ export type OptionGroupProps<T extends object, D extends DataTypes.Keys<T>, L ex
67
67
  * Item size
68
68
  */
69
69
  itemSize?: "small" | "medium";
70
+ /**
71
+ * Item height in px
72
+ */
73
+ itemHeight?: number;
70
74
  /**
71
75
  * Helper text
72
76
  */
@@ -10,9 +10,11 @@ import React from "react";
10
10
  export function OptionGroup(props) {
11
11
  var _a;
12
12
  // Destruct
13
- const { getOptionLabel, defaultValue, idField = "id", label, labelField = "label", multiple = false, mRef, name, onValueChange, options, readOnly, row, itemSize, helperText, variant, required, fullWidth, ...rest } = props;
13
+ const { getOptionLabel, defaultValue, idField = "id", label, labelField = "label", multiple = false, mRef, name, onValueChange, options, readOnly, row, itemSize, itemHeight = row ? 56 : 42, helperText, variant, required, fullWidth, ...rest } = props;
14
14
  // Theme
15
15
  const theme = useTheme();
16
+ // Outlined
17
+ const outlined = variant === "outlined";
16
18
  // Get option value
17
19
  // D type should be the source id type
18
20
  const getOptionValue = (option) => {
@@ -92,9 +94,9 @@ export function OptionGroup(props) {
92
94
  } }, list));
93
95
  // Layout
94
96
  return (React.createElement(React.Fragment, null,
95
- React.createElement(FormControl, { component: "fieldset", fullWidth: fullWidth, sx: { height: "56px" }, ...rest },
97
+ React.createElement(FormControl, { component: "fieldset", fullWidth: fullWidth, ...rest },
96
98
  label && (React.createElement(InputLabel, { required: required, variant: variant, shrink: true }, label)),
97
- variant === "outlined" && (React.createElement(NotchedOutline, { label: label && required ? label + " *" : label, notched: true, sx: {
99
+ outlined && (React.createElement(NotchedOutline, { label: label && required ? label + " *" : label, notched: true, sx: {
98
100
  cursor: "default",
99
101
  position: "absolute",
100
102
  width: fullWidth ? "100%" : "auto",
@@ -102,6 +104,10 @@ export function OptionGroup(props) {
102
104
  visibility: "hidden"
103
105
  }
104
106
  } })),
105
- React.createElement(Box, { paddingLeft: 2, paddingY: "7px", position: "absolute" }, group)),
107
+ React.createElement(Box, { paddingLeft: 2, paddingY: "7px", position: outlined ? "absolute" : undefined, height: outlined
108
+ ? row
109
+ ? `${itemHeight}px`
110
+ : `${options.length * itemHeight + 14}px`
111
+ : undefined }, group)),
106
112
  helperText && React.createElement(FormHelperText, null, helperText)));
107
113
  }
@@ -1,9 +1,9 @@
1
- import { FormEventHandler } from 'react';
2
- import { CommonPageProps } from './CommonPageProps';
1
+ import React, { FormEventHandler } from "react";
2
+ import { CommonPageProps } from "./CommonPageProps";
3
3
  /**
4
4
  * Add / Edit page props
5
5
  */
6
- export interface EditPageProps extends Omit<CommonPageProps, 'onSubmit'> {
6
+ export interface EditPageProps extends Omit<CommonPageProps, "onSubmit"> {
7
7
  /**
8
8
  * Is editing
9
9
  */
@@ -25,6 +25,10 @@ export interface EditPageProps extends Omit<CommonPageProps, 'onSubmit'> {
25
25
  * @default true
26
26
  */
27
27
  supportBack?: boolean;
28
+ /**
29
+ * Top part
30
+ */
31
+ topPart?: React.ReactNode;
28
32
  }
29
33
  /**
30
34
  * Add / Edit page
@@ -1,25 +1,26 @@
1
- import { Button, Grid } from '@mui/material';
2
- import React from 'react';
3
- import { MUGlobal } from '../MUGlobal';
4
- import { CommonPage, CommonPageScrollContainer } from './CommonPage';
5
- import SaveIcon from '@mui/icons-material/Save';
6
- import DeleteIcon from '@mui/icons-material/Delete';
7
- import { BackButton } from '../BackButton';
8
- import { Labels } from '../app/Labels';
1
+ import { Button, Grid } from "@mui/material";
2
+ import React from "react";
3
+ import { MUGlobal } from "../MUGlobal";
4
+ import { CommonPage, CommonPageScrollContainer } from "./CommonPage";
5
+ import SaveIcon from "@mui/icons-material/Save";
6
+ import DeleteIcon from "@mui/icons-material/Delete";
7
+ import { BackButton } from "../BackButton";
8
+ import { Labels } from "../app/Labels";
9
9
  /**
10
10
  * Add / Edit page
11
11
  * @param props Props
12
12
  */
13
13
  export function EditPage(props) {
14
14
  // Destruct
15
- const { children, isEditing, onDelete, onSubmit, paddings = MUGlobal.pagePaddings, scrollContainer = CommonPageScrollContainer, supportBack = true, submitDisabled = false, ...rest } = props;
15
+ const { children, isEditing, onDelete, onSubmit, paddings = MUGlobal.pagePaddings, scrollContainer = CommonPageScrollContainer, supportBack = true, submitDisabled = false, topPart, ...rest } = props;
16
16
  // Labels
17
17
  const labels = Labels.CommonPage;
18
18
  return (React.createElement(CommonPage, { paddings: paddings, scrollContainer: scrollContainer, ...rest },
19
+ topPart,
19
20
  React.createElement("form", { onSubmit: onSubmit },
20
21
  React.createElement(Grid, { container: true, justifyContent: "left", spacing: paddings, paddingTop: 1 }, children),
21
22
  React.createElement(Grid, { container: true, position: "sticky", display: "flex", gap: paddings, sx: {
22
- top: 'auto',
23
+ top: "auto",
23
24
  bottom: (theme) => MUGlobal.updateWithTheme(paddings, theme.spacing),
24
25
  paddingTop: paddings
25
26
  } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.1.24",
3
+ "version": "1.1.26",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -55,7 +55,7 @@
55
55
  "@etsoo/react": "^1.6.44",
56
56
  "@etsoo/shared": "^1.1.88",
57
57
  "@mui/icons-material": "^5.11.0",
58
- "@mui/material": "^5.11.6",
58
+ "@mui/material": "^5.11.7",
59
59
  "@types/pica": "^9.0.1",
60
60
  "@types/pulltorefreshjs": "^0.1.5",
61
61
  "@types/react": "^18.0.27",
@@ -84,10 +84,10 @@
84
84
  "@testing-library/jest-dom": "^5.16.5",
85
85
  "@testing-library/react": "^13.4.0",
86
86
  "@types/jest": "^29.4.0",
87
- "@typescript-eslint/eslint-plugin": "^5.49.0",
88
- "@typescript-eslint/parser": "^5.49.0",
87
+ "@typescript-eslint/eslint-plugin": "^5.50.0",
88
+ "@typescript-eslint/parser": "^5.50.0",
89
89
  "jest": "^29.4.1",
90
90
  "jest-environment-jsdom": "^29.4.1",
91
- "typescript": "^4.9.4"
91
+ "typescript": "^4.9.5"
92
92
  }
93
93
  }
@@ -105,6 +105,11 @@ export type OptionGroupProps<
105
105
  */
106
106
  itemSize?: "small" | "medium";
107
107
 
108
+ /**
109
+ * Item height in px
110
+ */
111
+ itemHeight?: number;
112
+
108
113
  /**
109
114
  * Helper text
110
115
  */
@@ -136,6 +141,7 @@ export function OptionGroup<
136
141
  readOnly,
137
142
  row,
138
143
  itemSize,
144
+ itemHeight = row ? 56 : 42,
139
145
  helperText,
140
146
  variant,
141
147
  required,
@@ -146,6 +152,9 @@ export function OptionGroup<
146
152
  // Theme
147
153
  const theme = useTheme();
148
154
 
155
+ // Outlined
156
+ const outlined = variant === "outlined";
157
+
149
158
  // Get option value
150
159
  // D type should be the source id type
151
160
  const getOptionValue = (option: T): T[D] | null => {
@@ -276,18 +285,13 @@ export function OptionGroup<
276
285
  // Layout
277
286
  return (
278
287
  <React.Fragment>
279
- <FormControl
280
- component="fieldset"
281
- fullWidth={fullWidth}
282
- sx={{ height: "56px" }} // absolute layout inside relative layout needed
283
- {...rest}
284
- >
288
+ <FormControl component="fieldset" fullWidth={fullWidth} {...rest}>
285
289
  {label && (
286
290
  <InputLabel required={required} variant={variant} shrink>
287
291
  {label}
288
292
  </InputLabel>
289
293
  )}
290
- {variant === "outlined" && (
294
+ {outlined && (
291
295
  <NotchedOutline
292
296
  label={label && required ? label + " *" : label}
293
297
  notched
@@ -301,7 +305,18 @@ export function OptionGroup<
301
305
  }}
302
306
  />
303
307
  )}
304
- <Box paddingLeft={2} paddingY="7px" position="absolute">
308
+ <Box
309
+ paddingLeft={2}
310
+ paddingY="7px"
311
+ position={outlined ? "absolute" : undefined}
312
+ height={
313
+ outlined
314
+ ? row
315
+ ? `${itemHeight}px`
316
+ : `${options.length * itemHeight + 14}px`
317
+ : undefined
318
+ }
319
+ >
305
320
  {group}
306
321
  </Box>
307
322
  </FormControl>
@@ -1,42 +1,47 @@
1
- import { Button, Grid } from '@mui/material';
2
- import React, { FormEventHandler } from 'react';
3
- import { MUGlobal } from '../MUGlobal';
4
- import { CommonPage, CommonPageScrollContainer } from './CommonPage';
5
- import { CommonPageProps } from './CommonPageProps';
6
- import SaveIcon from '@mui/icons-material/Save';
7
- import DeleteIcon from '@mui/icons-material/Delete';
8
- import { BackButton } from '../BackButton';
9
- import { Labels } from '../app/Labels';
1
+ import { Button, Grid } from "@mui/material";
2
+ import React, { FormEventHandler } from "react";
3
+ import { MUGlobal } from "../MUGlobal";
4
+ import { CommonPage, CommonPageScrollContainer } from "./CommonPage";
5
+ import { CommonPageProps } from "./CommonPageProps";
6
+ import SaveIcon from "@mui/icons-material/Save";
7
+ import DeleteIcon from "@mui/icons-material/Delete";
8
+ import { BackButton } from "../BackButton";
9
+ import { Labels } from "../app/Labels";
10
10
 
11
11
  /**
12
12
  * Add / Edit page props
13
13
  */
14
- export interface EditPageProps extends Omit<CommonPageProps, 'onSubmit'> {
15
- /**
16
- * Is editing
17
- */
18
- isEditing?: boolean;
14
+ export interface EditPageProps extends Omit<CommonPageProps, "onSubmit"> {
15
+ /**
16
+ * Is editing
17
+ */
18
+ isEditing?: boolean;
19
19
 
20
- /**
21
- * On form submit
22
- */
23
- onSubmit?: FormEventHandler<HTMLFormElement>;
20
+ /**
21
+ * On form submit
22
+ */
23
+ onSubmit?: FormEventHandler<HTMLFormElement>;
24
24
 
25
- /**
26
- * On delete callback
27
- */
28
- onDelete?: () => Promise<void> | void;
25
+ /**
26
+ * On delete callback
27
+ */
28
+ onDelete?: () => Promise<void> | void;
29
29
 
30
- /**
31
- * Submit button disabled or not
32
- */
33
- submitDisabled?: boolean;
30
+ /**
31
+ * Submit button disabled or not
32
+ */
33
+ submitDisabled?: boolean;
34
34
 
35
- /**
36
- * Support back click
37
- * @default true
38
- */
39
- supportBack?: boolean;
35
+ /**
36
+ * Support back click
37
+ * @default true
38
+ */
39
+ supportBack?: boolean;
40
+
41
+ /**
42
+ * Top part
43
+ */
44
+ topPart?: React.ReactNode;
40
45
  }
41
46
 
42
47
  /**
@@ -44,71 +49,64 @@ export interface EditPageProps extends Omit<CommonPageProps, 'onSubmit'> {
44
49
  * @param props Props
45
50
  */
46
51
  export function EditPage(props: EditPageProps) {
47
- // Destruct
48
- const {
49
- children,
50
- isEditing,
51
- onDelete,
52
- onSubmit,
53
- paddings = MUGlobal.pagePaddings,
54
- scrollContainer = CommonPageScrollContainer,
55
- supportBack = true,
56
- submitDisabled = false,
57
- ...rest
58
- } = props;
52
+ // Destruct
53
+ const {
54
+ children,
55
+ isEditing,
56
+ onDelete,
57
+ onSubmit,
58
+ paddings = MUGlobal.pagePaddings,
59
+ scrollContainer = CommonPageScrollContainer,
60
+ supportBack = true,
61
+ submitDisabled = false,
62
+ topPart,
63
+ ...rest
64
+ } = props;
59
65
 
60
- // Labels
61
- const labels = Labels.CommonPage;
66
+ // Labels
67
+ const labels = Labels.CommonPage;
62
68
 
63
- return (
64
- <CommonPage
65
- paddings={paddings}
66
- scrollContainer={scrollContainer}
67
- {...rest}
69
+ return (
70
+ <CommonPage paddings={paddings} scrollContainer={scrollContainer} {...rest}>
71
+ {topPart}
72
+ <form onSubmit={onSubmit}>
73
+ <Grid container justifyContent="left" spacing={paddings} paddingTop={1}>
74
+ {children}
75
+ </Grid>
76
+ <Grid
77
+ container
78
+ position="sticky"
79
+ display="flex"
80
+ gap={paddings}
81
+ sx={{
82
+ top: "auto",
83
+ bottom: (theme) =>
84
+ MUGlobal.updateWithTheme(paddings, theme.spacing),
85
+ paddingTop: paddings
86
+ }}
68
87
  >
69
- <form onSubmit={onSubmit}>
70
- <Grid
71
- container
72
- justifyContent="left"
73
- spacing={paddings}
74
- paddingTop={1}
75
- >
76
- {children}
77
- </Grid>
78
- <Grid
79
- container
80
- position="sticky"
81
- display="flex"
82
- gap={paddings}
83
- sx={{
84
- top: 'auto',
85
- bottom: (theme) =>
86
- MUGlobal.updateWithTheme(paddings, theme.spacing),
87
- paddingTop: paddings
88
- }}
89
- >
90
- {isEditing && onDelete && (
91
- <Button
92
- color="primary"
93
- variant="outlined"
94
- onClick={() => onDelete()}
95
- startIcon={<DeleteIcon color="warning" />}
96
- >
97
- {labels.delete}
98
- </Button>
99
- )}
100
- <Button
101
- variant="contained"
102
- type="submit"
103
- startIcon={<SaveIcon />}
104
- sx={{ flexGrow: 1 }}
105
- disabled={submitDisabled}
106
- >
107
- {labels.save}
108
- </Button>
109
- {supportBack && <BackButton title={labels.back} />}
110
- </Grid>
111
- </form>
112
- </CommonPage>
113
- );
88
+ {isEditing && onDelete && (
89
+ <Button
90
+ color="primary"
91
+ variant="outlined"
92
+ onClick={() => onDelete()}
93
+ startIcon={<DeleteIcon color="warning" />}
94
+ >
95
+ {labels.delete}
96
+ </Button>
97
+ )}
98
+ <Button
99
+ variant="contained"
100
+ type="submit"
101
+ startIcon={<SaveIcon />}
102
+ sx={{ flexGrow: 1 }}
103
+ disabled={submitDisabled}
104
+ >
105
+ {labels.save}
106
+ </Button>
107
+ {supportBack && <BackButton title={labels.back} />}
108
+ </Grid>
109
+ </form>
110
+ </CommonPage>
111
+ );
114
112
  }