@etsoo/react 1.4.35 → 1.4.36
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.
package/lib/mu/MUGlobal.d.ts
CHANGED
|
@@ -40,14 +40,20 @@ export declare class MUGlobal {
|
|
|
40
40
|
* @returns Updated object
|
|
41
41
|
*/
|
|
42
42
|
static half(input: {}): {};
|
|
43
|
+
/**
|
|
44
|
+
* Reverse object number properties, like 5 to -5
|
|
45
|
+
* @param input Input object
|
|
46
|
+
* @returns Updated object
|
|
47
|
+
*/
|
|
48
|
+
static reverse(input: {}): {};
|
|
43
49
|
/**
|
|
44
50
|
* Update object number properties with adjustment
|
|
45
51
|
* @param input Input object
|
|
46
|
-
* @param adjust Adjust value
|
|
52
|
+
* @param adjust Adjust value or new size object
|
|
47
53
|
* @param field Specific field
|
|
48
54
|
* @returns Updated object
|
|
49
55
|
*/
|
|
50
|
-
static increase(input: {}, adjust: number, field?: string): {};
|
|
56
|
+
static increase(input: {}, adjust: number | {}, field?: string): {};
|
|
51
57
|
/**
|
|
52
58
|
* Adjust size with theme update
|
|
53
59
|
* @param size Base size
|
package/lib/mu/MUGlobal.js
CHANGED
|
@@ -14,10 +14,24 @@ export class MUGlobal {
|
|
|
14
14
|
});
|
|
15
15
|
return newObj;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Reverse object number properties, like 5 to -5
|
|
19
|
+
* @param input Input object
|
|
20
|
+
* @returns Updated object
|
|
21
|
+
*/
|
|
22
|
+
static reverse(input) {
|
|
23
|
+
const newObj = { ...input };
|
|
24
|
+
Object.entries(newObj).forEach(([key, value]) => {
|
|
25
|
+
if (typeof value === 'number') {
|
|
26
|
+
Reflect.set(newObj, key, -value);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return newObj;
|
|
30
|
+
}
|
|
17
31
|
/**
|
|
18
32
|
* Update object number properties with adjustment
|
|
19
33
|
* @param input Input object
|
|
20
|
-
* @param adjust Adjust value
|
|
34
|
+
* @param adjust Adjust value or new size object
|
|
21
35
|
* @param field Specific field
|
|
22
36
|
* @returns Updated object
|
|
23
37
|
*/
|
|
@@ -25,8 +39,14 @@ export class MUGlobal {
|
|
|
25
39
|
const newObj = { ...input };
|
|
26
40
|
Object.entries(newObj).forEach(([key, value]) => {
|
|
27
41
|
if (typeof value === 'number') {
|
|
28
|
-
if (field == null || field === key)
|
|
29
|
-
|
|
42
|
+
if (field == null || field === key) {
|
|
43
|
+
const adjustValue = typeof adjust === 'number'
|
|
44
|
+
? adjust
|
|
45
|
+
: Reflect.get(adjust, key);
|
|
46
|
+
if (adjustValue == null || typeof adjustValue !== 'number')
|
|
47
|
+
return;
|
|
48
|
+
Reflect.set(newObj, key, value + adjustValue);
|
|
49
|
+
}
|
|
30
50
|
}
|
|
31
51
|
});
|
|
32
52
|
return newObj;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SxProps, Theme } from '@mui/material';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { ListItemReact } from '../components/ListItemReact';
|
|
3
4
|
import { ScrollerListExInnerItemRendererProps } from './ScrollerListEx';
|
|
@@ -8,7 +9,7 @@ import { ScrollerListExInnerItemRendererProps } from './ScrollerListEx';
|
|
|
8
9
|
* @param renderer Renderer for card content
|
|
9
10
|
* @returns Component
|
|
10
11
|
*/
|
|
11
|
-
export declare function MobileListItemRenderer<T>({ data, itemHeight }: ScrollerListExInnerItemRendererProps<T>, margin: {}, renderer: (data: T) => [
|
|
12
|
+
export declare function MobileListItemRenderer<T>({ data, itemHeight }: ScrollerListExInnerItemRendererProps<T>, margin: {} | [{}, boolean] | (() => SxProps<Theme>), renderer: (data: T) => [
|
|
12
13
|
string,
|
|
13
14
|
string | undefined,
|
|
14
15
|
React.ReactNode | (ListItemReact | boolean)[],
|
|
@@ -26,13 +26,45 @@ export function MobileListItemRenderer({ data, itemHeight }, margin, renderer) {
|
|
|
26
26
|
// Elements
|
|
27
27
|
const [title, subheader, actions, children] = renderer(data);
|
|
28
28
|
// Half
|
|
29
|
-
const halfMargin = MUGlobal.half(margin);
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
//const halfMargin = MUGlobal.half(margin);
|
|
30
|
+
//const nMargin = MUGlobal.reverse(margin);
|
|
31
|
+
const calculateMargin = () => {
|
|
32
|
+
if (typeof margin === 'function')
|
|
33
|
+
return margin();
|
|
34
|
+
if (Array.isArray(margin)) {
|
|
35
|
+
const marginValue = margin[0];
|
|
36
|
+
const isNarrow = margin[1];
|
|
37
|
+
const nMargin = MUGlobal.reverse(marginValue);
|
|
38
|
+
const half = MUGlobal.half(marginValue);
|
|
39
|
+
if (isNarrow) {
|
|
40
|
+
const nHalf = MUGlobal.reverse(half);
|
|
41
|
+
return {
|
|
42
|
+
marginLeft: nHalf,
|
|
43
|
+
marginRight: nHalf,
|
|
44
|
+
marginTop: half,
|
|
45
|
+
marginBottom: half
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return {
|
|
50
|
+
marginLeft: nMargin,
|
|
51
|
+
marginRight: nMargin,
|
|
52
|
+
marginTop: half,
|
|
53
|
+
marginBottom: half
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const half = MUGlobal.half(margin);
|
|
58
|
+
return {
|
|
32
59
|
marginLeft: margin,
|
|
33
60
|
marginRight: margin,
|
|
34
|
-
marginTop:
|
|
35
|
-
marginBottom:
|
|
61
|
+
marginTop: half,
|
|
62
|
+
marginBottom: half
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
return (React.createElement(Card, { sx: {
|
|
66
|
+
height: (theme) => MUGlobal.adjustWithTheme(itemHeight, margin, theme.spacing),
|
|
67
|
+
...calculateMargin()
|
|
36
68
|
} },
|
|
37
69
|
React.createElement(CardHeader, { sx: { paddingBottom: 0.5 }, action: Array.isArray(actions) ? (React.createElement(MoreFab, { iconButton: true, size: "small", anchorOrigin: {
|
|
38
70
|
vertical: 'bottom',
|
package/package.json
CHANGED
package/src/mu/MUGlobal.ts
CHANGED
|
@@ -56,19 +56,42 @@ export class MUGlobal {
|
|
|
56
56
|
return newObj;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Reverse object number properties, like 5 to -5
|
|
61
|
+
* @param input Input object
|
|
62
|
+
* @returns Updated object
|
|
63
|
+
*/
|
|
64
|
+
static reverse(input: {}) {
|
|
65
|
+
const newObj = { ...input };
|
|
66
|
+
Object.entries(newObj).forEach(([key, value]) => {
|
|
67
|
+
if (typeof value === 'number') {
|
|
68
|
+
Reflect.set(newObj, key, -value);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return newObj;
|
|
72
|
+
}
|
|
73
|
+
|
|
59
74
|
/**
|
|
60
75
|
* Update object number properties with adjustment
|
|
61
76
|
* @param input Input object
|
|
62
|
-
* @param adjust Adjust value
|
|
77
|
+
* @param adjust Adjust value or new size object
|
|
63
78
|
* @param field Specific field
|
|
64
79
|
* @returns Updated object
|
|
65
80
|
*/
|
|
66
|
-
static increase(input: {}, adjust: number, field?: string) {
|
|
81
|
+
static increase(input: {}, adjust: number | {}, field?: string) {
|
|
67
82
|
const newObj = { ...input };
|
|
68
83
|
Object.entries(newObj).forEach(([key, value]) => {
|
|
69
84
|
if (typeof value === 'number') {
|
|
70
|
-
if (field == null || field === key)
|
|
71
|
-
|
|
85
|
+
if (field == null || field === key) {
|
|
86
|
+
const adjustValue =
|
|
87
|
+
typeof adjust === 'number'
|
|
88
|
+
? adjust
|
|
89
|
+
: Reflect.get(adjust, key);
|
|
90
|
+
if (adjustValue == null || typeof adjustValue !== 'number')
|
|
91
|
+
return;
|
|
92
|
+
|
|
93
|
+
Reflect.set(newObj, key, value + adjustValue);
|
|
94
|
+
}
|
|
72
95
|
}
|
|
73
96
|
});
|
|
74
97
|
return newObj;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Card,
|
|
3
|
+
CardContent,
|
|
4
|
+
CardHeader,
|
|
5
|
+
LinearProgress,
|
|
6
|
+
SxProps,
|
|
7
|
+
Theme
|
|
8
|
+
} from '@mui/material';
|
|
2
9
|
import React from 'react';
|
|
3
10
|
import { ListItemReact } from '../components/ListItemReact';
|
|
4
11
|
import { MoreFab } from './MoreFab';
|
|
@@ -24,7 +31,7 @@ function getActions(input: (ListItemReact | boolean)[]): ListItemReact[] {
|
|
|
24
31
|
*/
|
|
25
32
|
export function MobileListItemRenderer<T>(
|
|
26
33
|
{ data, itemHeight }: ScrollerListExInnerItemRendererProps<T>,
|
|
27
|
-
margin: {},
|
|
34
|
+
margin: {} | [{}, boolean] | (() => SxProps<Theme>),
|
|
28
35
|
renderer: (
|
|
29
36
|
data: T
|
|
30
37
|
) => [
|
|
@@ -41,17 +48,48 @@ export function MobileListItemRenderer<T>(
|
|
|
41
48
|
const [title, subheader, actions, children] = renderer(data);
|
|
42
49
|
|
|
43
50
|
// Half
|
|
44
|
-
const halfMargin = MUGlobal.half(margin);
|
|
51
|
+
//const halfMargin = MUGlobal.half(margin);
|
|
52
|
+
//const nMargin = MUGlobal.reverse(margin);
|
|
53
|
+
const calculateMargin = () => {
|
|
54
|
+
if (typeof margin === 'function') return margin();
|
|
55
|
+
if (Array.isArray(margin)) {
|
|
56
|
+
const marginValue = margin[0];
|
|
57
|
+
const isNarrow = margin[1];
|
|
58
|
+
const nMargin = MUGlobal.reverse(marginValue);
|
|
59
|
+
const half = MUGlobal.half(marginValue);
|
|
60
|
+
if (isNarrow) {
|
|
61
|
+
const nHalf = MUGlobal.reverse(half);
|
|
62
|
+
return {
|
|
63
|
+
marginLeft: nHalf,
|
|
64
|
+
marginRight: nHalf,
|
|
65
|
+
marginTop: half,
|
|
66
|
+
marginBottom: half
|
|
67
|
+
};
|
|
68
|
+
} else {
|
|
69
|
+
return {
|
|
70
|
+
marginLeft: nMargin,
|
|
71
|
+
marginRight: nMargin,
|
|
72
|
+
marginTop: half,
|
|
73
|
+
marginBottom: half
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const half = MUGlobal.half(margin);
|
|
79
|
+
return {
|
|
80
|
+
marginLeft: margin,
|
|
81
|
+
marginRight: margin,
|
|
82
|
+
marginTop: half,
|
|
83
|
+
marginBottom: half
|
|
84
|
+
};
|
|
85
|
+
};
|
|
45
86
|
|
|
46
87
|
return (
|
|
47
88
|
<Card
|
|
48
89
|
sx={{
|
|
49
90
|
height: (theme) =>
|
|
50
91
|
MUGlobal.adjustWithTheme(itemHeight, margin, theme.spacing),
|
|
51
|
-
|
|
52
|
-
marginRight: margin,
|
|
53
|
-
marginTop: halfMargin,
|
|
54
|
-
marginBottom: halfMargin
|
|
92
|
+
...calculateMargin()
|
|
55
93
|
}}
|
|
56
94
|
>
|
|
57
95
|
<CardHeader
|