@etsoo/materialui 1.1.36 → 1.1.38

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.
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { ListType1 } from "@etsoo/shared";
3
+ import { OptionGroupProps } from "./OptionGroup";
4
+ /**
5
+ * OptionBool props
6
+ */
7
+ export type OptionBoolProps = Omit<OptionGroupProps<ListType1, "id", "label">, "options" | "row" | "multiple">;
8
+ /**
9
+ * OptionBool (yes/no)
10
+ * @param props Props
11
+ * @returns Component
12
+ */
13
+ export declare function OptionBool(props: OptionBoolProps): JSX.Element;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { globalApp } from "./app/ReactApp";
3
+ import { OptionGroup } from "./OptionGroup";
4
+ /**
5
+ * OptionBool (yes/no)
6
+ * @param props Props
7
+ * @returns Component
8
+ */
9
+ export function OptionBool(props) {
10
+ // Options
11
+ const options = globalApp.getBools();
12
+ // Layout
13
+ return (React.createElement(OptionGroup, { options: options, row: true, multiple: false, ...props }));
14
+ }
@@ -1,5 +1,5 @@
1
1
  import { DataTypes, Utils } from "@etsoo/shared";
2
- import { Box, Checkbox, FormControl, FormControlLabel, FormGroup, FormHelperText, InputLabel, Radio, RadioGroup, useTheme } from "@mui/material";
2
+ import { Box, Checkbox, FormControl, FormControlLabel, FormGroup, FormHelperText, InputLabel, Radio, RadioGroup } from "@mui/material";
3
3
  import NotchedOutline from "@mui/material/OutlinedInput";
4
4
  import React from "react";
5
5
  /**
@@ -10,11 +10,18 @@ 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, itemHeight = row ? 56 : 42, helperText, variant, required, fullWidth, ...rest } = props;
14
- // Theme
15
- const theme = useTheme();
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, sx = {}, ...rest } = props;
16
14
  // Outlined
17
15
  const outlined = variant === "outlined";
16
+ if (sx) {
17
+ Object.assign(sx, {
18
+ height: outlined
19
+ ? row
20
+ ? `${itemHeight}px`
21
+ : `${options.length * itemHeight + 14}px`
22
+ : undefined
23
+ });
24
+ }
18
25
  // Get option value
19
26
  // D type should be the source id type
20
27
  const getOptionValue = (option) => {
@@ -94,7 +101,7 @@ export function OptionGroup(props) {
94
101
  } }, list));
95
102
  // Layout
96
103
  return (React.createElement(React.Fragment, null,
97
- React.createElement(FormControl, { component: "fieldset", fullWidth: fullWidth, ...rest },
104
+ React.createElement(FormControl, { component: "fieldset", fullWidth: fullWidth, sx: sx, ...rest },
98
105
  label && (React.createElement(InputLabel, { required: required, variant: variant, shrink: true }, label)),
99
106
  outlined && (React.createElement(NotchedOutline, { label: label && required ? label + " *" : label, notched: true, sx: {
100
107
  cursor: "default",
@@ -104,10 +111,6 @@ export function OptionGroup(props) {
104
111
  visibility: "hidden"
105
112
  }
106
113
  } })),
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)),
114
+ React.createElement(Box, { paddingLeft: 2, paddingY: "7px", position: outlined ? "absolute" : undefined }, group)),
112
115
  helperText && React.createElement(FormHelperText, null, helperText)));
113
116
  }
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { ListType1 } from '@etsoo/shared';
3
- import { SelectExProps } from './SelectEx';
2
+ import { ListType1 } from "@etsoo/shared";
3
+ import { SelectExProps } from "./SelectEx";
4
4
  /**
5
5
  * SelectBool props
6
6
  */
7
- export type SelectBoolProps = Omit<SelectExProps<ListType1>, 'options' | 'loadData'>;
7
+ export type SelectBoolProps = Omit<SelectExProps<ListType1>, "options" | "loadData">;
8
8
  /**
9
9
  * SelectBool (yes/no)
10
10
  * @param props Props
package/lib/SelectBool.js CHANGED
@@ -1,7 +1,7 @@
1
- import { Utils } from '@etsoo/shared';
2
- import React from 'react';
3
- import { globalApp } from './app/ReactApp';
4
- import { SelectEx } from './SelectEx';
1
+ import { Utils } from "@etsoo/shared";
2
+ import React from "react";
3
+ import { globalApp } from "./app/ReactApp";
4
+ import { SelectEx } from "./SelectEx";
5
5
  /**
6
6
  * SelectBool (yes/no)
7
7
  * @param props Props
@@ -11,10 +11,7 @@ export function SelectBool(props) {
11
11
  // Destruct
12
12
  const { search = true, autoAddBlankItem = search, ...rest } = props;
13
13
  // Options
14
- const options = [
15
- { id: 'false', label: globalApp.get('no') },
16
- { id: 'true', label: globalApp.get('yes') }
17
- ];
14
+ const options = globalApp.getBools();
18
15
  if (autoAddBlankItem)
19
16
  Utils.addBlankItem(options);
20
17
  // Layout
package/lib/index.d.ts CHANGED
@@ -61,6 +61,7 @@ export * from "./MoneyInputField";
61
61
  export * from "./MoreFab";
62
62
  export * from "./MUGlobal";
63
63
  export * from "./NotifierMU";
64
+ export * from "./OptionBool";
64
65
  export * from "./OptionGroup";
65
66
  export * from "./PList";
66
67
  export * from "./ProgressCount";
package/lib/index.js CHANGED
@@ -61,6 +61,7 @@ export * from "./MoneyInputField";
61
61
  export * from "./MoreFab";
62
62
  export * from "./MUGlobal";
63
63
  export * from "./NotifierMU";
64
+ export * from "./OptionBool";
64
65
  export * from "./OptionGroup";
65
66
  export * from "./PList";
66
67
  export * from "./ProgressCount";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.1.36",
3
+ "version": "1.1.38",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -47,12 +47,12 @@
47
47
  "dependencies": {
48
48
  "@dnd-kit/core": "^6.0.7",
49
49
  "@dnd-kit/sortable": "^7.0.2",
50
- "@emotion/css": "^11.10.5",
51
- "@emotion/react": "^11.10.5",
52
- "@emotion/styled": "^11.10.5",
53
- "@etsoo/appscript": "^1.3.65",
50
+ "@emotion/css": "^11.10.6",
51
+ "@emotion/react": "^11.10.6",
52
+ "@emotion/styled": "^11.10.6",
53
+ "@etsoo/appscript": "^1.3.66",
54
54
  "@etsoo/notificationbase": "^1.1.23",
55
- "@etsoo/react": "^1.6.47",
55
+ "@etsoo/react": "^1.6.48",
56
56
  "@etsoo/shared": "^1.1.88",
57
57
  "@mui/icons-material": "^5.11.9",
58
58
  "@mui/material": "^5.11.9",
@@ -82,7 +82,7 @@
82
82
  "@babel/preset-typescript": "^7.18.6",
83
83
  "@babel/runtime-corejs3": "^7.20.13",
84
84
  "@testing-library/jest-dom": "^5.16.5",
85
- "@testing-library/react": "^13.4.0",
85
+ "@testing-library/react": "^14.0.0",
86
86
  "@types/jest": "^29.4.0",
87
87
  "@typescript-eslint/eslint-plugin": "^5.52.0",
88
88
  "@typescript-eslint/parser": "^5.52.0",
@@ -0,0 +1,27 @@
1
+ import { ListType1 } from "@etsoo/shared";
2
+ import React from "react";
3
+ import { globalApp } from "./app/ReactApp";
4
+ import { OptionGroup, OptionGroupProps } from "./OptionGroup";
5
+
6
+ /**
7
+ * OptionBool props
8
+ */
9
+ export type OptionBoolProps = Omit<
10
+ OptionGroupProps<ListType1, "id", "label">,
11
+ "options" | "row" | "multiple"
12
+ >;
13
+
14
+ /**
15
+ * OptionBool (yes/no)
16
+ * @param props Props
17
+ * @returns Component
18
+ */
19
+ export function OptionBool(props: OptionBoolProps) {
20
+ // Options
21
+ const options = globalApp.getBools();
22
+
23
+ // Layout
24
+ return (
25
+ <OptionGroup<ListType1> options={options} row multiple={false} {...props} />
26
+ );
27
+ }
@@ -15,8 +15,7 @@ import {
15
15
  FormHelperText,
16
16
  InputLabel,
17
17
  Radio,
18
- RadioGroup,
19
- useTheme
18
+ RadioGroup
20
19
  } from "@mui/material";
21
20
  import NotchedOutline from "@mui/material/OutlinedInput";
22
21
  import React from "react";
@@ -146,15 +145,23 @@ export function OptionGroup<
146
145
  variant,
147
146
  required,
148
147
  fullWidth,
148
+ sx = {},
149
149
  ...rest
150
150
  } = props;
151
151
 
152
- // Theme
153
- const theme = useTheme();
154
-
155
152
  // Outlined
156
153
  const outlined = variant === "outlined";
157
154
 
155
+ if (sx) {
156
+ Object.assign(sx, {
157
+ height: outlined
158
+ ? row
159
+ ? `${itemHeight}px`
160
+ : `${options.length * itemHeight + 14}px`
161
+ : undefined
162
+ });
163
+ }
164
+
158
165
  // Get option value
159
166
  // D type should be the source id type
160
167
  const getOptionValue = (option: T): T[D] | null => {
@@ -285,7 +292,7 @@ export function OptionGroup<
285
292
  // Layout
286
293
  return (
287
294
  <React.Fragment>
288
- <FormControl component="fieldset" fullWidth={fullWidth} {...rest}>
295
+ <FormControl component="fieldset" fullWidth={fullWidth} sx={sx} {...rest}>
289
296
  {label && (
290
297
  <InputLabel required={required} variant={variant} shrink>
291
298
  {label}
@@ -309,13 +316,6 @@ export function OptionGroup<
309
316
  paddingLeft={2}
310
317
  paddingY="7px"
311
318
  position={outlined ? "absolute" : undefined}
312
- height={
313
- outlined
314
- ? row
315
- ? `${itemHeight}px`
316
- : `${options.length * itemHeight + 14}px`
317
- : undefined
318
- }
319
319
  >
320
320
  {group}
321
321
  </Box>
@@ -1,14 +1,14 @@
1
- import { ListType1, Utils } from '@etsoo/shared';
2
- import React from 'react';
3
- import { globalApp } from './app/ReactApp';
4
- import { SelectEx, SelectExProps } from './SelectEx';
1
+ import { ListType1, Utils } from "@etsoo/shared";
2
+ import React from "react";
3
+ import { globalApp } from "./app/ReactApp";
4
+ import { SelectEx, SelectExProps } from "./SelectEx";
5
5
 
6
6
  /**
7
7
  * SelectBool props
8
8
  */
9
9
  export type SelectBoolProps = Omit<
10
- SelectExProps<ListType1>,
11
- 'options' | 'loadData'
10
+ SelectExProps<ListType1>,
11
+ "options" | "loadData"
12
12
  >;
13
13
 
14
14
  /**
@@ -17,17 +17,14 @@ export type SelectBoolProps = Omit<
17
17
  * @returns Component
18
18
  */
19
19
  export function SelectBool(props: SelectBoolProps) {
20
- // Destruct
21
- const { search = true, autoAddBlankItem = search, ...rest } = props;
20
+ // Destruct
21
+ const { search = true, autoAddBlankItem = search, ...rest } = props;
22
22
 
23
- // Options
24
- const options: ListType1[] = [
25
- { id: 'false', label: globalApp.get('no')! },
26
- { id: 'true', label: globalApp.get('yes')! }
27
- ];
23
+ // Options
24
+ const options = globalApp.getBools();
28
25
 
29
- if (autoAddBlankItem) Utils.addBlankItem(options);
26
+ if (autoAddBlankItem) Utils.addBlankItem(options);
30
27
 
31
- // Layout
32
- return <SelectEx<ListType1> options={options} search={search} {...rest} />;
28
+ // Layout
29
+ return <SelectEx<ListType1> options={options} search={search} {...rest} />;
33
30
  }
package/src/index.ts CHANGED
@@ -64,6 +64,7 @@ export * from "./MoneyInputField";
64
64
  export * from "./MoreFab";
65
65
  export * from "./MUGlobal";
66
66
  export * from "./NotifierMU";
67
+ export * from "./OptionBool";
67
68
  export * from "./OptionGroup";
68
69
  export * from "./PList";
69
70
  export * from "./ProgressCount";