@etsoo/materialui 1.5.15 → 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,
|
|
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
|
-
|
|
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 (
|
|
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 (
|
|
61
|
+
if (horizon >= 0) {
|
|
61
62
|
return {
|
|
62
|
-
marginLeft:
|
|
63
|
-
marginRight:
|
|
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,
|
|
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) => {
|
|
@@ -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,
|
|
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
|
-
|
|
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 (
|
|
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 (
|
|
55
|
+
if (horizon >= 0) {
|
|
55
56
|
return {
|
|
56
|
-
marginLeft:
|
|
57
|
-
marginRight:
|
|
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,
|
|
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) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.5.
|
|
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.
|
|
85
|
+
"typescript": "^5.8.3",
|
|
86
86
|
"vitest": "^3.1.1"
|
|
87
87
|
}
|
|
88
88
|
}
|
package/src/ScrollerListEx.tsx
CHANGED
|
@@ -47,10 +47,11 @@ const createGridStyle = (
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
// Default margin
|
|
50
|
-
|
|
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 (
|
|
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 (
|
|
64
|
+
if (horizon >= 0) {
|
|
64
65
|
return {
|
|
65
|
-
marginLeft:
|
|
66
|
-
marginRight:
|
|
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,
|
|
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,
|
|
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
|