@etsoo/react 1.5.80 → 1.5.81
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/README.md +7 -2
- package/__tests__/ReactUtils.ts +6 -0
- package/lib/{mu → components}/DnDList.d.ts +1 -14
- package/lib/{mu → components}/DnDList.js +1 -24
- package/lib/components/GridMethodRef.d.ts +11 -0
- package/lib/{mu → components}/GridMethodRef.js +0 -0
- package/lib/components/ScrollerGrid.d.ts +3 -3
- package/lib/components/ScrollerList.d.ts +3 -3
- package/lib/index.d.ts +2 -74
- package/lib/index.js +2 -75
- package/lib/notifier/Notifier.d.ts +2 -3
- package/lib/uses/useWindowScroll.d.ts +10 -0
- package/lib/uses/useWindowScroll.js +46 -0
- package/lib/uses/useWindowSize.js +11 -5
- package/package.json +3 -15
- package/src/{mu → components}/DnDList.tsx +11 -34
- package/src/components/GridMethodRef.ts +12 -0
- package/src/components/ScrollerGrid.tsx +3 -3
- package/src/components/ScrollerList.tsx +5 -3
- package/src/index.ts +2 -78
- package/src/notifier/Notifier.ts +2 -3
- package/src/uses/useWindowScroll.ts +60 -0
- package/src/uses/useWindowSize.ts +14 -5
- package/__tests__/mu/ComboBox.tsx +0 -30
- package/__tests__/mu/MUGlobalTests.tsx +0 -58
- package/__tests__/mu/NotifierMUTests.tsx +0 -213
- package/__tests__/mu/SelectEx.tsx +0 -26
- package/lib/app/CommonApp.d.ts +0 -39
- package/lib/app/CommonApp.js +0 -149
- package/lib/app/IServiceAppSettings.d.ts +0 -11
- package/lib/app/IServiceAppSettings.js +0 -1
- package/lib/app/IServicePage.d.ts +0 -6
- package/lib/app/IServicePage.js +0 -1
- package/lib/app/IServiceUser.d.ts +0 -14
- package/lib/app/IServiceUser.js +0 -1
- package/lib/app/ISmartERPUser.d.ts +0 -14
- package/lib/app/ISmartERPUser.js +0 -1
- package/lib/app/Labels.d.ts +0 -65
- package/lib/app/Labels.js +0 -62
- package/lib/app/ReactApp.d.ts +0 -194
- package/lib/app/ReactApp.js +0 -298
- package/lib/app/ServiceApp.d.ts +0 -78
- package/lib/app/ServiceApp.js +0 -244
- package/lib/components/ShowDataComparison.d.ts +0 -20
- package/lib/components/ShowDataComparison.js +0 -60
- package/lib/mu/AuditDisplay.d.ts +0 -33
- package/lib/mu/AuditDisplay.js +0 -52
- package/lib/mu/AutocompleteExtendedProps.d.ts +0 -64
- package/lib/mu/AutocompleteExtendedProps.js +0 -1
- package/lib/mu/BackButton.d.ts +0 -13
- package/lib/mu/BackButton.js +0 -33
- package/lib/mu/BridgeCloseButton.d.ts +0 -23
- package/lib/mu/BridgeCloseButton.js +0 -32
- package/lib/mu/ButtonLink.d.ts +0 -17
- package/lib/mu/ButtonLink.js +0 -19
- package/lib/mu/ComboBox.d.ts +0 -38
- package/lib/mu/ComboBox.js +0 -108
- package/lib/mu/CountdownButton.d.ts +0 -23
- package/lib/mu/CountdownButton.js +0 -81
- package/lib/mu/CustomFabProps.d.ts +0 -27
- package/lib/mu/CustomFabProps.js +0 -1
- package/lib/mu/DataGridEx.d.ts +0 -96
- package/lib/mu/DataGridEx.js +0 -331
- package/lib/mu/DataGridRenderers.d.ts +0 -22
- package/lib/mu/DataGridRenderers.js +0 -99
- package/lib/mu/DialogButton.d.ts +0 -54
- package/lib/mu/DialogButton.js +0 -45
- package/lib/mu/DraggablePaperComponent.d.ts +0 -8
- package/lib/mu/DraggablePaperComponent.js +0 -12
- package/lib/mu/EmailInput.d.ts +0 -11
- package/lib/mu/EmailInput.js +0 -15
- package/lib/mu/FabBox.d.ts +0 -21
- package/lib/mu/FabBox.js +0 -31
- package/lib/mu/FlexBox.d.ts +0 -14
- package/lib/mu/FlexBox.js +0 -18
- package/lib/mu/GridDataFormat.d.ts +0 -10
- package/lib/mu/GridDataFormat.js +0 -43
- package/lib/mu/GridMethodRef.d.ts +0 -11
- package/lib/mu/IconButtonLink.d.ts +0 -17
- package/lib/mu/IconButtonLink.js +0 -16
- package/lib/mu/InputField.d.ts +0 -21
- package/lib/mu/InputField.js +0 -39
- package/lib/mu/ItemList.d.ts +0 -56
- package/lib/mu/ItemList.js +0 -69
- package/lib/mu/ListItemRightIcon.d.ts +0 -4
- package/lib/mu/ListItemRightIcon.js +0 -8
- package/lib/mu/ListMoreDisplay.d.ts +0 -35
- package/lib/mu/ListMoreDisplay.js +0 -99
- package/lib/mu/LoadingButton.d.ts +0 -16
- package/lib/mu/LoadingButton.js +0 -41
- package/lib/mu/MUGlobal.d.ts +0 -102
- package/lib/mu/MUGlobal.js +0 -184
- package/lib/mu/MaskInput.d.ts +0 -34
- package/lib/mu/MaskInput.js +0 -43
- package/lib/mu/MobileListItemRenderer.d.ts +0 -17
- package/lib/mu/MobileListItemRenderer.js +0 -35
- package/lib/mu/MoreFab.d.ts +0 -45
- package/lib/mu/MoreFab.js +0 -95
- package/lib/mu/NotifierMU.d.ts +0 -47
- package/lib/mu/NotifierMU.js +0 -387
- package/lib/mu/NotifierPromptProps.d.ts +0 -22
- package/lib/mu/NotifierPromptProps.js +0 -1
- package/lib/mu/OptionGroup.d.ts +0 -58
- package/lib/mu/OptionGroup.js +0 -81
- package/lib/mu/PList.d.ts +0 -15
- package/lib/mu/PList.js +0 -12
- package/lib/mu/ProgressCount.d.ts +0 -44
- package/lib/mu/ProgressCount.js +0 -79
- package/lib/mu/PullToRefreshUI.d.ts +0 -9
- package/lib/mu/PullToRefreshUI.js +0 -18
- package/lib/mu/RLink.d.ts +0 -14
- package/lib/mu/RLink.js +0 -37
- package/lib/mu/ResponsibleContainer.d.ts +0 -89
- package/lib/mu/ResponsibleContainer.js +0 -159
- package/lib/mu/ScrollTopFab.d.ts +0 -7
- package/lib/mu/ScrollTopFab.js +0 -25
- package/lib/mu/ScrollerListEx.d.ts +0 -81
- package/lib/mu/ScrollerListEx.js +0 -167
- package/lib/mu/SearchBar.d.ts +0 -29
- package/lib/mu/SearchBar.js +0 -262
- package/lib/mu/SearchField.d.ts +0 -21
- package/lib/mu/SearchField.js +0 -39
- package/lib/mu/SearchOptionGroup.d.ts +0 -9
- package/lib/mu/SearchOptionGroup.js +0 -14
- package/lib/mu/SelectBool.d.ts +0 -13
- package/lib/mu/SelectBool.js +0 -22
- package/lib/mu/SelectEx.d.ts +0 -50
- package/lib/mu/SelectEx.js +0 -156
- package/lib/mu/Switch.d.ts +0 -29
- package/lib/mu/Switch.js +0 -34
- package/lib/mu/SwitchAnt.d.ts +0 -25
- package/lib/mu/SwitchAnt.js +0 -40
- package/lib/mu/TabBox.d.ts +0 -54
- package/lib/mu/TabBox.js +0 -31
- package/lib/mu/TableEx.d.ts +0 -66
- package/lib/mu/TableEx.js +0 -271
- package/lib/mu/TextFieldEx.d.ts +0 -101
- package/lib/mu/TextFieldEx.js +0 -127
- package/lib/mu/Tiplist.d.ts +0 -18
- package/lib/mu/Tiplist.js +0 -158
- package/lib/mu/TooltipClick.d.ts +0 -15
- package/lib/mu/TooltipClick.js +0 -40
- package/lib/mu/UserAvatar.d.ts +0 -24
- package/lib/mu/UserAvatar.js +0 -25
- package/lib/mu/UserAvatarEditor.d.ts +0 -53
- package/lib/mu/UserAvatarEditor.js +0 -129
- package/lib/mu/pages/CommonPage.d.ts +0 -11
- package/lib/mu/pages/CommonPage.js +0 -60
- package/lib/mu/pages/CommonPageProps.d.ts +0 -60
- package/lib/mu/pages/CommonPageProps.js +0 -1
- package/lib/mu/pages/DataGridPage.d.ts +0 -9
- package/lib/mu/pages/DataGridPage.js +0 -81
- package/lib/mu/pages/DataGridPageProps.d.ts +0 -17
- package/lib/mu/pages/DataGridPageProps.js +0 -1
- package/lib/mu/pages/EditPage.d.ts +0 -33
- package/lib/mu/pages/EditPage.js +0 -29
- package/lib/mu/pages/FixedListPage.d.ts +0 -15
- package/lib/mu/pages/FixedListPage.js +0 -72
- package/lib/mu/pages/ListPage.d.ts +0 -9
- package/lib/mu/pages/ListPage.js +0 -51
- package/lib/mu/pages/ListPageProps.d.ts +0 -7
- package/lib/mu/pages/ListPageProps.js +0 -1
- package/lib/mu/pages/ResponsivePage.d.ts +0 -9
- package/lib/mu/pages/ResponsivePage.js +0 -45
- package/lib/mu/pages/ResponsivePageProps.d.ts +0 -39
- package/lib/mu/pages/ResponsivePageProps.js +0 -1
- package/lib/mu/pages/SearchPageProps.d.ts +0 -30
- package/lib/mu/pages/SearchPageProps.js +0 -1
- package/lib/mu/pages/TablePage.d.ts +0 -9
- package/lib/mu/pages/TablePage.js +0 -71
- package/lib/mu/pages/TablePageProps.d.ts +0 -7
- package/lib/mu/pages/TablePageProps.js +0 -1
- package/lib/mu/pages/ViewPage.d.ts +0 -66
- package/lib/mu/pages/ViewPage.js +0 -105
- package/lib/mu/texts/DateText.d.ts +0 -34
- package/lib/mu/texts/DateText.js +0 -25
- package/lib/mu/texts/MoneyText.d.ts +0 -21
- package/lib/mu/texts/MoneyText.js +0 -14
- package/lib/mu/texts/NumberText.d.ts +0 -25
- package/lib/mu/texts/NumberText.js +0 -14
- package/src/app/CommonApp.ts +0 -225
- package/src/app/IServiceAppSettings.ts +0 -13
- package/src/app/IServicePage.ts +0 -6
- package/src/app/IServiceUser.ts +0 -17
- package/src/app/ISmartERPUser.ts +0 -16
- package/src/app/Labels.ts +0 -77
- package/src/app/ReactApp.ts +0 -500
- package/src/app/ServiceApp.ts +0 -353
- package/src/components/ShowDataComparison.tsx +0 -108
- package/src/mu/AuditDisplay.tsx +0 -117
- package/src/mu/AutocompleteExtendedProps.ts +0 -83
- package/src/mu/BackButton.tsx +0 -55
- package/src/mu/BridgeCloseButton.tsx +0 -69
- package/src/mu/ButtonLink.tsx +0 -32
- package/src/mu/ComboBox.tsx +0 -251
- package/src/mu/CountdownButton.tsx +0 -119
- package/src/mu/CustomFabProps.ts +0 -32
- package/src/mu/DataGridEx.tsx +0 -712
- package/src/mu/DataGridRenderers.tsx +0 -140
- package/src/mu/DialogButton.tsx +0 -163
- package/src/mu/DraggablePaperComponent.tsx +0 -19
- package/src/mu/EmailInput.tsx +0 -24
- package/src/mu/FabBox.tsx +0 -51
- package/src/mu/FlexBox.tsx +0 -20
- package/src/mu/GridDataFormat.tsx +0 -77
- package/src/mu/GridMethodRef.ts +0 -12
- package/src/mu/IconButtonLink.tsx +0 -29
- package/src/mu/InputField.tsx +0 -82
- package/src/mu/ItemList.tsx +0 -204
- package/src/mu/ListItemRightIcon.tsx +0 -9
- package/src/mu/ListMoreDisplay.tsx +0 -205
- package/src/mu/LoadingButton.tsx +0 -75
- package/src/mu/MUGlobal.ts +0 -220
- package/src/mu/MaskInput.tsx +0 -107
- package/src/mu/MobileListItemRenderer.tsx +0 -79
- package/src/mu/MoreFab.tsx +0 -211
- package/src/mu/NotifierMU.tsx +0 -654
- package/src/mu/NotifierPromptProps.ts +0 -26
- package/src/mu/OptionGroup.tsx +0 -223
- package/src/mu/PList.tsx +0 -27
- package/src/mu/ProgressCount.tsx +0 -166
- package/src/mu/PullToRefreshUI.tsx +0 -21
- package/src/mu/RLink.tsx +0 -64
- package/src/mu/ResponsibleContainer.tsx +0 -394
- package/src/mu/ScrollTopFab.tsx +0 -34
- package/src/mu/ScrollerListEx.tsx +0 -387
- package/src/mu/SearchBar.tsx +0 -398
- package/src/mu/SearchField.tsx +0 -82
- package/src/mu/SearchOptionGroup.tsx +0 -31
- package/src/mu/SelectBool.tsx +0 -33
- package/src/mu/SelectEx.tsx +0 -290
- package/src/mu/Switch.tsx +0 -94
- package/src/mu/SwitchAnt.tsx +0 -95
- package/src/mu/TabBox.tsx +0 -118
- package/src/mu/TableEx.tsx +0 -560
- package/src/mu/TextFieldEx.tsx +0 -250
- package/src/mu/Tiplist.tsx +0 -304
- package/src/mu/TooltipClick.tsx +0 -84
- package/src/mu/UserAvatar.tsx +0 -64
- package/src/mu/UserAvatarEditor.tsx +0 -287
- package/src/mu/pages/CommonPage.tsx +0 -128
- package/src/mu/pages/CommonPageProps.ts +0 -71
- package/src/mu/pages/DataGridPage.tsx +0 -137
- package/src/mu/pages/DataGridPageProps.ts +0 -24
- package/src/mu/pages/EditPage.tsx +0 -114
- package/src/mu/pages/FixedListPage.tsx +0 -135
- package/src/mu/pages/ListPage.tsx +0 -87
- package/src/mu/pages/ListPageProps.ts +0 -12
- package/src/mu/pages/ResponsivePage.tsx +0 -68
- package/src/mu/pages/ResponsivePageProps.ts +0 -57
- package/src/mu/pages/SearchPageProps.ts +0 -39
- package/src/mu/pages/TablePage.tsx +0 -120
- package/src/mu/pages/TablePageProps.ts +0 -12
- package/src/mu/pages/ViewPage.tsx +0 -285
- package/src/mu/texts/DateText.tsx +0 -74
- package/src/mu/texts/MoneyText.tsx +0 -49
- package/src/mu/texts/NumberText.tsx +0 -40
package/src/mu/MaskInput.tsx
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { TextField, TextFieldProps } from '@mui/material';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { MUGlobal } from './MUGlobal';
|
|
4
|
-
import { useIMask } from 'react-imask';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Mask input props
|
|
8
|
-
*/
|
|
9
|
-
export type MaskInputProps<T extends IMask.AnyMaskedOptions> =
|
|
10
|
-
TextFieldProps & {
|
|
11
|
-
/**
|
|
12
|
-
* Mask props
|
|
13
|
-
*/
|
|
14
|
-
mask: T;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Accept hanlder
|
|
18
|
-
*/
|
|
19
|
-
onAccept?: (
|
|
20
|
-
value: unknown,
|
|
21
|
-
maskRef: IMask.InputMask<T>,
|
|
22
|
-
e?: InputEvent
|
|
23
|
-
) => void;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Complete handler
|
|
27
|
-
*/
|
|
28
|
-
onComplete?: (
|
|
29
|
-
value: unknown,
|
|
30
|
-
maskRef: IMask.InputMask<T>,
|
|
31
|
-
e?: InputEvent
|
|
32
|
-
) => void;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Is the field read only?
|
|
36
|
-
*/
|
|
37
|
-
readOnly?: boolean;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Search case
|
|
41
|
-
*/
|
|
42
|
-
search?: boolean;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Mask input
|
|
47
|
-
* https://imask.js.org/
|
|
48
|
-
* @param props Props
|
|
49
|
-
* @returns Component
|
|
50
|
-
*/
|
|
51
|
-
export function MaskInput<
|
|
52
|
-
T extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions
|
|
53
|
-
>(props: MaskInputProps<T>) {
|
|
54
|
-
// Destruct
|
|
55
|
-
const {
|
|
56
|
-
defaultValue,
|
|
57
|
-
mask,
|
|
58
|
-
InputLabelProps = {},
|
|
59
|
-
InputProps = {},
|
|
60
|
-
onAccept,
|
|
61
|
-
onComplete,
|
|
62
|
-
readOnly,
|
|
63
|
-
search = false,
|
|
64
|
-
size = search ? MUGlobal.searchFieldSize : MUGlobal.inputFieldSize,
|
|
65
|
-
value,
|
|
66
|
-
variant = search
|
|
67
|
-
? MUGlobal.searchFieldVariant
|
|
68
|
-
: MUGlobal.inputFieldVariant,
|
|
69
|
-
...rest
|
|
70
|
-
} = props;
|
|
71
|
-
|
|
72
|
-
const { ref, maskRef } = useIMask(mask, {
|
|
73
|
-
onAccept: (value, maskRef, event) => {
|
|
74
|
-
if (onAccept) onAccept(value, maskRef, event);
|
|
75
|
-
},
|
|
76
|
-
onComplete: (value, maskRef, event) => {
|
|
77
|
-
if (onComplete) onComplete(value, maskRef, event);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
const localValue = defaultValue ?? value;
|
|
81
|
-
|
|
82
|
-
// Shrink
|
|
83
|
-
InputLabelProps.shrink = search
|
|
84
|
-
? MUGlobal.searchFieldShrink
|
|
85
|
-
: MUGlobal.inputFieldShrink;
|
|
86
|
-
|
|
87
|
-
// Read only
|
|
88
|
-
if (readOnly != null) InputProps.readOnly = readOnly;
|
|
89
|
-
InputProps.inputRef = ref;
|
|
90
|
-
|
|
91
|
-
React.useEffect(() => {
|
|
92
|
-
if (maskRef.current == null || localValue == null) return;
|
|
93
|
-
maskRef.current.value = String(localValue);
|
|
94
|
-
maskRef.current.updateValue();
|
|
95
|
-
}, [maskRef.current, localValue]);
|
|
96
|
-
|
|
97
|
-
// Layout
|
|
98
|
-
return (
|
|
99
|
-
<TextField
|
|
100
|
-
InputLabelProps={InputLabelProps}
|
|
101
|
-
InputProps={InputProps}
|
|
102
|
-
size={size}
|
|
103
|
-
variant={variant}
|
|
104
|
-
{...rest}
|
|
105
|
-
/>
|
|
106
|
-
);
|
|
107
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Card, CardContent, CardHeader, LinearProgress } from '@mui/material';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { ListItemReact } from '../components/ListItemReact';
|
|
4
|
-
import { MoreFab } from './MoreFab';
|
|
5
|
-
import { ScrollerListExInnerItemRendererProps } from './ScrollerListEx';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Default mobile list item renderer
|
|
9
|
-
* @param param0 List renderer props
|
|
10
|
-
* @param margin Margin
|
|
11
|
-
* @param renderer Renderer for card content
|
|
12
|
-
* @returns Component
|
|
13
|
-
*/
|
|
14
|
-
export function MobileListItemRenderer<T>(
|
|
15
|
-
{ data, itemHeight, margins }: ScrollerListExInnerItemRendererProps<T>,
|
|
16
|
-
renderer: (
|
|
17
|
-
data: T
|
|
18
|
-
) => [
|
|
19
|
-
string,
|
|
20
|
-
string | undefined,
|
|
21
|
-
React.ReactNode | (ListItemReact | boolean)[],
|
|
22
|
-
React.ReactNode,
|
|
23
|
-
React.ReactNode?
|
|
24
|
-
]
|
|
25
|
-
) {
|
|
26
|
-
// Loading
|
|
27
|
-
if (data == null) return <LinearProgress />;
|
|
28
|
-
|
|
29
|
-
// Elements
|
|
30
|
-
const [title, subheader, actions, children, cardActions] = renderer(data);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<Card
|
|
34
|
-
sx={{
|
|
35
|
-
height: itemHeight,
|
|
36
|
-
...margins
|
|
37
|
-
}}
|
|
38
|
-
>
|
|
39
|
-
<CardHeader
|
|
40
|
-
sx={{ paddingBottom: 0.5 }}
|
|
41
|
-
action={
|
|
42
|
-
Array.isArray(actions) ? (
|
|
43
|
-
<MoreFab
|
|
44
|
-
iconButton
|
|
45
|
-
size="small"
|
|
46
|
-
anchorOrigin={{
|
|
47
|
-
vertical: 'bottom',
|
|
48
|
-
horizontal: 'right'
|
|
49
|
-
}}
|
|
50
|
-
transformOrigin={{
|
|
51
|
-
vertical: 'top',
|
|
52
|
-
horizontal: 'right'
|
|
53
|
-
}}
|
|
54
|
-
actions={actions}
|
|
55
|
-
/>
|
|
56
|
-
) : (
|
|
57
|
-
actions
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
title={title}
|
|
61
|
-
titleTypographyProps={{ variant: 'body2' }}
|
|
62
|
-
subheader={subheader}
|
|
63
|
-
subheaderTypographyProps={{ variant: 'caption' }}
|
|
64
|
-
/>
|
|
65
|
-
<CardContent
|
|
66
|
-
sx={{
|
|
67
|
-
paddingTop: 0,
|
|
68
|
-
paddingBottom:
|
|
69
|
-
cardActions == null
|
|
70
|
-
? Reflect.get(margins, 'marginBottom')
|
|
71
|
-
: 0
|
|
72
|
-
}}
|
|
73
|
-
>
|
|
74
|
-
{children}
|
|
75
|
-
</CardContent>
|
|
76
|
-
{cardActions}
|
|
77
|
-
</Card>
|
|
78
|
-
);
|
|
79
|
-
}
|
package/src/mu/MoreFab.tsx
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { CustomFabProps } from './CustomFabProps';
|
|
2
|
-
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
Divider,
|
|
6
|
-
Fab,
|
|
7
|
-
IconButton,
|
|
8
|
-
ListItemIcon,
|
|
9
|
-
ListItemText,
|
|
10
|
-
Menu,
|
|
11
|
-
MenuItem,
|
|
12
|
-
PaperProps,
|
|
13
|
-
PopoverOrigin
|
|
14
|
-
} from '@mui/material';
|
|
15
|
-
import { ListItemReact } from '../components/ListItemReact';
|
|
16
|
-
import { Link } from 'react-router-dom';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* More fab props
|
|
20
|
-
*/
|
|
21
|
-
export interface MoreFabProps extends CustomFabProps {
|
|
22
|
-
/**
|
|
23
|
-
* Actions
|
|
24
|
-
*/
|
|
25
|
-
actions?: (ListItemReact | boolean)[];
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Dray arrow
|
|
29
|
-
*/
|
|
30
|
-
drawArrow?: boolean;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Main icon
|
|
34
|
-
*/
|
|
35
|
-
icon?: React.ReactNode;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Show as icon button
|
|
39
|
-
*/
|
|
40
|
-
iconButton?: boolean;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* This is the point on the anchor where the popover's
|
|
44
|
-
* `anchorEl` will attach to
|
|
45
|
-
*/
|
|
46
|
-
anchorOrigin?: PopoverOrigin;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Props applied to the [`Paper`](/api/paper/) element.
|
|
50
|
-
* @default {}
|
|
51
|
-
*/
|
|
52
|
-
PaperProps?: Partial<PaperProps>;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* This is the point on the popover which
|
|
56
|
-
* will attach to the anchor's origin
|
|
57
|
-
*/
|
|
58
|
-
transformOrigin?: PopoverOrigin;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function getActions(input: (ListItemReact | boolean)[]): ListItemReact[] {
|
|
62
|
-
// Actions
|
|
63
|
-
const actions: ListItemReact[] = [];
|
|
64
|
-
input.forEach((action) => {
|
|
65
|
-
if (typeof action === 'boolean') return;
|
|
66
|
-
actions.push(action);
|
|
67
|
-
});
|
|
68
|
-
return actions;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* More fab
|
|
73
|
-
* @returns Component
|
|
74
|
-
*/
|
|
75
|
-
export function MoreFab(props: MoreFabProps) {
|
|
76
|
-
// Destruct
|
|
77
|
-
const {
|
|
78
|
-
actions,
|
|
79
|
-
drawArrow = true,
|
|
80
|
-
anchorOrigin = {
|
|
81
|
-
vertical: 'top',
|
|
82
|
-
horizontal: 'right'
|
|
83
|
-
},
|
|
84
|
-
color = 'primary',
|
|
85
|
-
icon = <MoreHorizIcon />,
|
|
86
|
-
iconButton = false,
|
|
87
|
-
PaperProps = drawArrow
|
|
88
|
-
? {
|
|
89
|
-
elevation: 0,
|
|
90
|
-
sx: {
|
|
91
|
-
overflow: 'visible',
|
|
92
|
-
filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',
|
|
93
|
-
mt: -0.4,
|
|
94
|
-
'& .MuiAvatar-root': {
|
|
95
|
-
width: 32,
|
|
96
|
-
height: 32,
|
|
97
|
-
ml: -0.5,
|
|
98
|
-
mr: 1
|
|
99
|
-
},
|
|
100
|
-
'&:before': {
|
|
101
|
-
content: '""',
|
|
102
|
-
display: 'block',
|
|
103
|
-
position: 'absolute',
|
|
104
|
-
top: 0,
|
|
105
|
-
right: 14,
|
|
106
|
-
width: 10,
|
|
107
|
-
height: 10,
|
|
108
|
-
bgcolor: 'background.paper',
|
|
109
|
-
transform: 'translateY(-50%) rotate(45deg)',
|
|
110
|
-
zIndex: 0
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
: undefined,
|
|
115
|
-
size,
|
|
116
|
-
title,
|
|
117
|
-
transformOrigin = {
|
|
118
|
-
vertical: 'bottom',
|
|
119
|
-
horizontal: 'right'
|
|
120
|
-
}
|
|
121
|
-
} = props;
|
|
122
|
-
|
|
123
|
-
// State
|
|
124
|
-
const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement>();
|
|
125
|
-
|
|
126
|
-
// Open state
|
|
127
|
-
const open = Boolean(anchorEl);
|
|
128
|
-
|
|
129
|
-
// Handle click
|
|
130
|
-
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
131
|
-
setAnchorEl(event.currentTarget);
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
// Handle close
|
|
135
|
-
const handleClose = () => {
|
|
136
|
-
setAnchorEl(undefined);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// No actions
|
|
140
|
-
if (actions == null || actions.length == 0) return <React.Fragment />;
|
|
141
|
-
|
|
142
|
-
// Actions
|
|
143
|
-
const actionsLocal = getActions(actions);
|
|
144
|
-
|
|
145
|
-
// Has any icon
|
|
146
|
-
const hasIcon = actionsLocal.some((action) => action.icon != null);
|
|
147
|
-
|
|
148
|
-
// Main
|
|
149
|
-
const main = iconButton ? (
|
|
150
|
-
<IconButton
|
|
151
|
-
color={color}
|
|
152
|
-
size={size}
|
|
153
|
-
title={title}
|
|
154
|
-
onClick={handleClick}
|
|
155
|
-
>
|
|
156
|
-
{icon}
|
|
157
|
-
</IconButton>
|
|
158
|
-
) : (
|
|
159
|
-
<Fab color={color} size={size} title={title} onClick={handleClick}>
|
|
160
|
-
{icon}
|
|
161
|
-
</Fab>
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
return (
|
|
165
|
-
<React.Fragment>
|
|
166
|
-
{main}
|
|
167
|
-
<Menu
|
|
168
|
-
disableScrollLock={true}
|
|
169
|
-
anchorEl={anchorEl}
|
|
170
|
-
anchorOrigin={anchorOrigin}
|
|
171
|
-
keepMounted
|
|
172
|
-
transformOrigin={transformOrigin}
|
|
173
|
-
open={open}
|
|
174
|
-
onClose={handleClose}
|
|
175
|
-
PaperProps={PaperProps}
|
|
176
|
-
>
|
|
177
|
-
{actionsLocal.map(({ label, icon, action }, index) =>
|
|
178
|
-
label === '-' ? (
|
|
179
|
-
<Divider key={index} />
|
|
180
|
-
) : (
|
|
181
|
-
<MenuItem
|
|
182
|
-
key={label}
|
|
183
|
-
{...(typeof action === 'string'
|
|
184
|
-
? action.includes('://')
|
|
185
|
-
? {
|
|
186
|
-
component: 'a',
|
|
187
|
-
href: action,
|
|
188
|
-
target: '_blank'
|
|
189
|
-
}
|
|
190
|
-
: { component: Link, to: action }
|
|
191
|
-
: {
|
|
192
|
-
onClick: () => {
|
|
193
|
-
handleClose();
|
|
194
|
-
if (typeof action === 'function')
|
|
195
|
-
action();
|
|
196
|
-
}
|
|
197
|
-
})}
|
|
198
|
-
>
|
|
199
|
-
{icon != null && (
|
|
200
|
-
<ListItemIcon>{icon}</ListItemIcon>
|
|
201
|
-
)}
|
|
202
|
-
<ListItemText inset={icon == null && hasIcon}>
|
|
203
|
-
{label}
|
|
204
|
-
</ListItemText>
|
|
205
|
-
</MenuItem>
|
|
206
|
-
)
|
|
207
|
-
)}
|
|
208
|
-
</Menu>
|
|
209
|
-
</React.Fragment>
|
|
210
|
-
);
|
|
211
|
-
}
|