@etsoo/materialui 1.5.14 → 1.5.16

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.
@@ -27,9 +27,9 @@ export interface ScrollerListExInnerItemRendererProps<T> extends ListChildCompon
27
27
  * Extended ScrollerList ItemSize type
28
28
  * 1. Callback function
29
29
  * 2. Static sets
30
- * 3. Dynamic calculation
30
+ * 3. Dynamic left & right margin calculation
31
31
  */
32
- export type ScrollerListExItemSize = ((index: number) => [number, number] | [number, number, object]) | [number, number] | [number, object, boolean?];
32
+ export type ScrollerListExItemSize = ((index: number) => [number, number] | [number, number, object]) | [number, number] | [number, object, number?];
33
33
  /**
34
34
  * Extended ScrollerList Props
35
35
  */
@@ -46,9 +46,10 @@ const createGridStyle = (alternatingColors, selectedColor) => {
46
46
  });
47
47
  };
48
48
  // Default margin
49
- const defaultMargin = (margin, isNarrow) => {
49
+ // horizon: null means full horizontal margin, -1 means all half, >=0 means left/right
50
+ const defaultMargin = (margin, horizon) => {
50
51
  const half = MUGlobal_1.MUGlobal.half(margin);
51
- if (isNarrow == null) {
52
+ if (horizon == null) {
52
53
  const half = MUGlobal_1.MUGlobal.half(margin);
53
54
  return {
54
55
  marginLeft: margin,
@@ -57,10 +58,10 @@ const defaultMargin = (margin, isNarrow) => {
57
58
  marginBottom: half
58
59
  };
59
60
  }
60
- if (isNarrow) {
61
+ if (horizon >= 0) {
61
62
  return {
62
- marginLeft: 0,
63
- marginRight: 0,
63
+ marginLeft: horizon,
64
+ marginRight: horizon,
64
65
  marginTop: half,
65
66
  marginBottom: half
66
67
  };
@@ -137,14 +138,10 @@ function ScrollerListEx(props) {
137
138
  const itemSizeResult = react_2.default.useMemo(() => {
138
139
  if (typeof itemSize === "function")
139
140
  return undefined;
140
- const [size, spaces, isNarrow] = itemSize;
141
+ const [size, spaces, h] = itemSize;
141
142
  if (typeof spaces === "number")
142
143
  return [size, spaces, defaultMargin(MUGlobal_1.MUGlobal.pagePaddings, undefined)];
143
- return [
144
- size,
145
- MUGlobal_1.MUGlobal.getSpace(spaces, theme),
146
- defaultMargin(spaces, isNarrow)
147
- ];
144
+ return [size, MUGlobal_1.MUGlobal.getSpace(spaces, theme), defaultMargin(spaces, h)];
148
145
  }, [itemSize]);
149
146
  // Calculate size
150
147
  const calculateItemSize = (index) => {
@@ -7,8 +7,8 @@ exports.SearchField = SearchField;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const react_1 = require("@etsoo/react");
9
9
  const react_2 = __importDefault(require("react"));
10
- const TextField_1 = __importDefault(require("@mui/material/TextField"));
11
10
  const MUGlobal_1 = require("./MUGlobal");
11
+ const TextField_1 = __importDefault(require("@mui/material/TextField"));
12
12
  /**
13
13
  * Search field
14
14
  * @param props Props
@@ -16,13 +16,14 @@ const MUGlobal_1 = require("./MUGlobal");
16
16
  */
17
17
  function SearchField(props) {
18
18
  // Destruct
19
- const { changeDelay, onChange, readOnly, slotProps = {}, size = MUGlobal_1.MUGlobal.searchFieldSize, variant = MUGlobal_1.MUGlobal.searchFieldVariant, minChars = 0, ...rest } = props;
19
+ const { changeDelay, InputLabelProps = {}, InputProps = {}, inputProps = {}, onChange, readOnly, size = MUGlobal_1.MUGlobal.searchFieldSize, variant = MUGlobal_1.MUGlobal.searchFieldVariant, minChars = 0, ...rest } = props;
20
20
  // Shrink
21
- const defaultProps = {
22
- input: { readOnly: readOnly },
23
- inputLabel: { shrink: MUGlobal_1.MUGlobal.searchFieldShrink },
24
- htmlInput: { "data-min-chars": minChars }
25
- };
21
+ InputLabelProps.shrink ??= MUGlobal_1.MUGlobal.searchFieldShrink;
22
+ // Read only
23
+ if (readOnly != null)
24
+ InputProps.readOnly = readOnly;
25
+ // Min characters
26
+ inputProps["data-min-chars"] = minChars;
26
27
  const isMounted = react_2.default.useRef(true);
27
28
  const delayed = onChange != null && changeDelay != null && changeDelay >= 1
28
29
  ? (0, react_1.useDelayedExecutor)(onChange, changeDelay)
@@ -51,5 +52,5 @@ function SearchField(props) {
51
52
  };
52
53
  }, []);
53
54
  // Layout
54
- return ((0, jsx_runtime_1.jsx)(TextField_1.default, { slotProps: Object.assign(slotProps, defaultProps), onChange: onChangeEx, size: size, variant: variant, ...rest }));
55
+ return ((0, jsx_runtime_1.jsx)(TextField_1.default, { InputLabelProps: InputLabelProps, InputProps: InputProps, inputProps: inputProps, onChange: onChangeEx, size: size, variant: variant, ...rest }));
55
56
  }
@@ -27,9 +27,9 @@ export interface ScrollerListExInnerItemRendererProps<T> extends ListChildCompon
27
27
  * Extended ScrollerList ItemSize type
28
28
  * 1. Callback function
29
29
  * 2. Static sets
30
- * 3. Dynamic calculation
30
+ * 3. Dynamic left & right margin calculation
31
31
  */
32
- export type ScrollerListExItemSize = ((index: number) => [number, number] | [number, number, object]) | [number, number] | [number, object, boolean?];
32
+ export type ScrollerListExItemSize = ((index: number) => [number, number] | [number, number, object]) | [number, number] | [number, object, number?];
33
33
  /**
34
34
  * Extended ScrollerList Props
35
35
  */
@@ -40,9 +40,10 @@ const createGridStyle = (alternatingColors, selectedColor) => {
40
40
  });
41
41
  };
42
42
  // Default margin
43
- const defaultMargin = (margin, isNarrow) => {
43
+ // horizon: null means full horizontal margin, -1 means all half, >=0 means left/right
44
+ const defaultMargin = (margin, horizon) => {
44
45
  const half = MUGlobal.half(margin);
45
- if (isNarrow == null) {
46
+ if (horizon == null) {
46
47
  const half = MUGlobal.half(margin);
47
48
  return {
48
49
  marginLeft: margin,
@@ -51,10 +52,10 @@ const defaultMargin = (margin, isNarrow) => {
51
52
  marginBottom: half
52
53
  };
53
54
  }
54
- if (isNarrow) {
55
+ if (horizon >= 0) {
55
56
  return {
56
- marginLeft: 0,
57
- marginRight: 0,
57
+ marginLeft: horizon,
58
+ marginRight: horizon,
58
59
  marginTop: half,
59
60
  marginBottom: half
60
61
  };
@@ -131,14 +132,10 @@ export function ScrollerListEx(props) {
131
132
  const itemSizeResult = React.useMemo(() => {
132
133
  if (typeof itemSize === "function")
133
134
  return undefined;
134
- const [size, spaces, isNarrow] = itemSize;
135
+ const [size, spaces, h] = itemSize;
135
136
  if (typeof spaces === "number")
136
137
  return [size, spaces, defaultMargin(MUGlobal.pagePaddings, undefined)];
137
- return [
138
- size,
139
- MUGlobal.getSpace(spaces, theme),
140
- defaultMargin(spaces, isNarrow)
141
- ];
138
+ return [size, MUGlobal.getSpace(spaces, theme), defaultMargin(spaces, h)];
142
139
  }, [itemSize]);
143
140
  // Calculate size
144
141
  const calculateItemSize = (index) => {
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useDelayedExecutor } from "@etsoo/react";
3
3
  import React from "react";
4
- import TextField from "@mui/material/TextField";
5
4
  import { MUGlobal } from "./MUGlobal";
5
+ import TextField from "@mui/material/TextField";
6
6
  /**
7
7
  * Search field
8
8
  * @param props Props
@@ -10,13 +10,14 @@ import { MUGlobal } from "./MUGlobal";
10
10
  */
11
11
  export function SearchField(props) {
12
12
  // Destruct
13
- const { changeDelay, onChange, readOnly, slotProps = {}, size = MUGlobal.searchFieldSize, variant = MUGlobal.searchFieldVariant, minChars = 0, ...rest } = props;
13
+ const { changeDelay, InputLabelProps = {}, InputProps = {}, inputProps = {}, onChange, readOnly, size = MUGlobal.searchFieldSize, variant = MUGlobal.searchFieldVariant, minChars = 0, ...rest } = props;
14
14
  // Shrink
15
- const defaultProps = {
16
- input: { readOnly: readOnly },
17
- inputLabel: { shrink: MUGlobal.searchFieldShrink },
18
- htmlInput: { "data-min-chars": minChars }
19
- };
15
+ InputLabelProps.shrink ??= MUGlobal.searchFieldShrink;
16
+ // Read only
17
+ if (readOnly != null)
18
+ InputProps.readOnly = readOnly;
19
+ // Min characters
20
+ inputProps["data-min-chars"] = minChars;
20
21
  const isMounted = React.useRef(true);
21
22
  const delayed = onChange != null && changeDelay != null && changeDelay >= 1
22
23
  ? useDelayedExecutor(onChange, changeDelay)
@@ -45,5 +46,5 @@ export function SearchField(props) {
45
46
  };
46
47
  }, []);
47
48
  // Layout
48
- return (_jsx(TextField, { slotProps: Object.assign(slotProps, defaultProps), onChange: onChangeEx, size: size, variant: variant, ...rest }));
49
+ return (_jsx(TextField, { InputLabelProps: InputLabelProps, InputProps: InputProps, inputProps: inputProps, onChange: onChangeEx, size: size, variant: variant, ...rest }));
49
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.5.14",
3
+ "version": "1.5.16",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -82,7 +82,7 @@
82
82
  "@types/react-window": "^1.8.8",
83
83
  "@vitejs/plugin-react": "^4.3.4",
84
84
  "jsdom": "^26.0.0",
85
- "typescript": "^5.8.2",
85
+ "typescript": "^5.8.3",
86
86
  "vitest": "^3.1.1"
87
87
  }
88
88
  }
@@ -47,10 +47,11 @@ const createGridStyle = (
47
47
  };
48
48
 
49
49
  // Default margin
50
- const defaultMargin = (margin: object, isNarrow?: boolean) => {
50
+ // horizon: null means full horizontal margin, -1 means all half, >=0 means left/right
51
+ const defaultMargin = (margin: object, horizon?: number) => {
51
52
  const half = MUGlobal.half(margin);
52
53
 
53
- if (isNarrow == null) {
54
+ if (horizon == null) {
54
55
  const half = MUGlobal.half(margin);
55
56
  return {
56
57
  marginLeft: margin,
@@ -60,10 +61,10 @@ const defaultMargin = (margin: object, isNarrow?: boolean) => {
60
61
  };
61
62
  }
62
63
 
63
- if (isNarrow) {
64
+ if (horizon >= 0) {
64
65
  return {
65
- marginLeft: 0,
66
- marginRight: 0,
66
+ marginLeft: horizon,
67
+ marginRight: horizon,
67
68
  marginTop: half,
68
69
  marginBottom: half
69
70
  };
@@ -107,12 +108,12 @@ export interface ScrollerListExInnerItemRendererProps<T>
107
108
  * Extended ScrollerList ItemSize type
108
109
  * 1. Callback function
109
110
  * 2. Static sets
110
- * 3. Dynamic calculation
111
+ * 3. Dynamic left & right margin calculation
111
112
  */
112
113
  export type ScrollerListExItemSize =
113
114
  | ((index: number) => [number, number] | [number, number, object])
114
115
  | [number, number]
115
- | [number, object, boolean?];
116
+ | [number, object, number?];
116
117
 
117
118
  /**
118
119
  * Extended ScrollerList Props
@@ -321,15 +322,11 @@ export function ScrollerListEx<T extends object>(
321
322
  | [number, number, object]
322
323
  | undefined => {
323
324
  if (typeof itemSize === "function") return undefined;
324
- const [size, spaces, isNarrow] = itemSize;
325
+ const [size, spaces, h] = itemSize;
325
326
  if (typeof spaces === "number")
326
327
  return [size, spaces, defaultMargin(MUGlobal.pagePaddings, undefined)];
327
328
 
328
- return [
329
- size,
330
- MUGlobal.getSpace(spaces, theme),
331
- defaultMargin(spaces, isNarrow)
332
- ];
329
+ return [size, MUGlobal.getSpace(spaces, theme), defaultMargin(spaces, h)];
333
330
  }, [itemSize]);
334
331
 
335
332
  // Calculate size
@@ -1,7 +1,7 @@
1
1
  import { useDelayedExecutor } from "@etsoo/react";
2
2
  import React from "react";
3
- import TextField, { TextFieldProps } from "@mui/material/TextField";
4
3
  import { MUGlobal } from "./MUGlobal";
4
+ import TextField, { TextFieldProps } from "@mui/material/TextField";
5
5
 
6
6
  /**
7
7
  * Search field props
@@ -32,9 +32,11 @@ export function SearchField(props: SearchFieldProps) {
32
32
  // Destruct
33
33
  const {
34
34
  changeDelay,
35
+ InputLabelProps = {},
36
+ InputProps = {},
37
+ inputProps = {},
35
38
  onChange,
36
39
  readOnly,
37
- slotProps = {},
38
40
  size = MUGlobal.searchFieldSize,
39
41
  variant = MUGlobal.searchFieldVariant,
40
42
  minChars = 0,
@@ -42,11 +44,13 @@ export function SearchField(props: SearchFieldProps) {
42
44
  } = props;
43
45
 
44
46
  // Shrink
45
- const defaultProps: typeof slotProps = {
46
- input: { readOnly: readOnly },
47
- inputLabel: { shrink: MUGlobal.searchFieldShrink },
48
- htmlInput: { "data-min-chars": minChars }
49
- };
47
+ InputLabelProps.shrink ??= MUGlobal.searchFieldShrink;
48
+
49
+ // Read only
50
+ if (readOnly != null) InputProps.readOnly = readOnly;
51
+
52
+ // Min characters
53
+ inputProps["data-min-chars"] = minChars;
50
54
 
51
55
  const isMounted = React.useRef(true);
52
56
  const delayed =
@@ -86,7 +90,9 @@ export function SearchField(props: SearchFieldProps) {
86
90
  // Layout
87
91
  return (
88
92
  <TextField
89
- slotProps={Object.assign(slotProps, defaultProps)}
93
+ InputLabelProps={InputLabelProps}
94
+ InputProps={InputProps}
95
+ inputProps={inputProps}
90
96
  onChange={onChangeEx}
91
97
  size={size}
92
98
  variant={variant}