@etsoo/materialui 1.0.1
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/.eslintignore +3 -0
- package/.eslintrc.json +38 -0
- package/.gitattributes +2 -0
- package/.github/workflows/main.yml +48 -0
- package/.prettierignore +5 -0
- package/.prettierrc +6 -0
- package/LICENSE +21 -0
- package/README.md +16 -0
- package/__tests__/ComboBox.tsx +30 -0
- package/__tests__/MUGlobalTests.tsx +58 -0
- package/__tests__/NotifierMUTests.tsx +217 -0
- package/__tests__/SelectEx.tsx +26 -0
- package/__tests__/tsconfig.json +19 -0
- package/babel.config.json +11 -0
- package/lib/AuditDisplay.d.ts +33 -0
- package/lib/AuditDisplay.js +52 -0
- package/lib/AutocompleteExtendedProps.d.ts +64 -0
- package/lib/AutocompleteExtendedProps.js +1 -0
- package/lib/BackButton.d.ts +13 -0
- package/lib/BackButton.js +33 -0
- package/lib/BridgeCloseButton.d.ts +23 -0
- package/lib/BridgeCloseButton.js +32 -0
- package/lib/ButtonLink.d.ts +17 -0
- package/lib/ButtonLink.js +19 -0
- package/lib/ComboBox.d.ts +38 -0
- package/lib/ComboBox.js +108 -0
- package/lib/CountdownButton.d.ts +23 -0
- package/lib/CountdownButton.js +81 -0
- package/lib/CustomFabProps.d.ts +27 -0
- package/lib/CustomFabProps.js +1 -0
- package/lib/DataGridEx.d.ts +94 -0
- package/lib/DataGridEx.js +329 -0
- package/lib/DataGridRenderers.d.ts +22 -0
- package/lib/DataGridRenderers.js +99 -0
- package/lib/DialogButton.d.ts +54 -0
- package/lib/DialogButton.js +45 -0
- package/lib/DnDList.d.ts +87 -0
- package/lib/DnDList.js +153 -0
- package/lib/DraggablePaperComponent.d.ts +8 -0
- package/lib/DraggablePaperComponent.js +12 -0
- package/lib/EmailInput.d.ts +11 -0
- package/lib/EmailInput.js +15 -0
- package/lib/FabBox.d.ts +21 -0
- package/lib/FabBox.js +31 -0
- package/lib/FlexBox.d.ts +14 -0
- package/lib/FlexBox.js +18 -0
- package/lib/GridDataFormat.d.ts +10 -0
- package/lib/GridDataFormat.js +43 -0
- package/lib/IconButtonLink.d.ts +17 -0
- package/lib/IconButtonLink.js +16 -0
- package/lib/InputField.d.ts +21 -0
- package/lib/InputField.js +39 -0
- package/lib/ItemList.d.ts +56 -0
- package/lib/ItemList.js +69 -0
- package/lib/ListItemRightIcon.d.ts +4 -0
- package/lib/ListItemRightIcon.js +8 -0
- package/lib/ListMoreDisplay.d.ts +35 -0
- package/lib/ListMoreDisplay.js +99 -0
- package/lib/LoadingButton.d.ts +16 -0
- package/lib/LoadingButton.js +41 -0
- package/lib/MUGlobal.d.ts +102 -0
- package/lib/MUGlobal.js +184 -0
- package/lib/MaskInput.d.ts +34 -0
- package/lib/MaskInput.js +43 -0
- package/lib/MobileListItemRenderer.d.ts +17 -0
- package/lib/MobileListItemRenderer.js +35 -0
- package/lib/MoreFab.d.ts +45 -0
- package/lib/MoreFab.js +95 -0
- package/lib/NotifierMU.d.ts +47 -0
- package/lib/NotifierMU.js +387 -0
- package/lib/NotifierPromptProps.d.ts +22 -0
- package/lib/NotifierPromptProps.js +1 -0
- package/lib/OptionGroup.d.ts +58 -0
- package/lib/OptionGroup.js +81 -0
- package/lib/PList.d.ts +15 -0
- package/lib/PList.js +12 -0
- package/lib/ProgressCount.d.ts +44 -0
- package/lib/ProgressCount.js +79 -0
- package/lib/PullToRefreshUI.d.ts +9 -0
- package/lib/PullToRefreshUI.js +18 -0
- package/lib/RLink.d.ts +14 -0
- package/lib/RLink.js +37 -0
- package/lib/ResponsibleContainer.d.ts +87 -0
- package/lib/ResponsibleContainer.js +156 -0
- package/lib/ScrollTopFab.d.ts +7 -0
- package/lib/ScrollTopFab.js +25 -0
- package/lib/ScrollerListEx.d.ts +81 -0
- package/lib/ScrollerListEx.js +167 -0
- package/lib/SearchBar.d.ts +29 -0
- package/lib/SearchBar.js +260 -0
- package/lib/SearchField.d.ts +21 -0
- package/lib/SearchField.js +39 -0
- package/lib/SearchOptionGroup.d.ts +9 -0
- package/lib/SearchOptionGroup.js +14 -0
- package/lib/SelectBool.d.ts +13 -0
- package/lib/SelectBool.js +22 -0
- package/lib/SelectEx.d.ts +50 -0
- package/lib/SelectEx.js +156 -0
- package/lib/ShowDataComparison.d.ts +20 -0
- package/lib/ShowDataComparison.js +58 -0
- package/lib/Switch.d.ts +29 -0
- package/lib/Switch.js +34 -0
- package/lib/SwitchAnt.d.ts +25 -0
- package/lib/SwitchAnt.js +40 -0
- package/lib/TabBox.d.ts +54 -0
- package/lib/TabBox.js +31 -0
- package/lib/TableEx.d.ts +65 -0
- package/lib/TableEx.js +270 -0
- package/lib/TextFieldEx.d.ts +101 -0
- package/lib/TextFieldEx.js +126 -0
- package/lib/Tiplist.d.ts +18 -0
- package/lib/Tiplist.js +157 -0
- package/lib/TooltipClick.d.ts +15 -0
- package/lib/TooltipClick.js +40 -0
- package/lib/UserAvatar.d.ts +24 -0
- package/lib/UserAvatar.js +25 -0
- package/lib/UserAvatarEditor.d.ts +53 -0
- package/lib/UserAvatarEditor.js +129 -0
- package/lib/app/CommonApp.d.ts +38 -0
- package/lib/app/CommonApp.js +149 -0
- package/lib/app/IServiceAppSettings.d.ts +11 -0
- package/lib/app/IServiceAppSettings.js +1 -0
- package/lib/app/IServicePage.d.ts +6 -0
- package/lib/app/IServicePage.js +1 -0
- package/lib/app/IServiceUser.d.ts +14 -0
- package/lib/app/IServiceUser.js +1 -0
- package/lib/app/ISmartERPUser.d.ts +14 -0
- package/lib/app/ISmartERPUser.js +1 -0
- package/lib/app/Labels.d.ts +65 -0
- package/lib/app/Labels.js +62 -0
- package/lib/app/ReactApp.d.ts +195 -0
- package/lib/app/ReactApp.js +296 -0
- package/lib/app/ServiceApp.d.ts +78 -0
- package/lib/app/ServiceApp.js +244 -0
- package/lib/index.d.ts +74 -0
- package/lib/index.js +74 -0
- package/lib/pages/CommonPage.d.ts +11 -0
- package/lib/pages/CommonPage.js +60 -0
- package/lib/pages/CommonPageProps.d.ts +59 -0
- package/lib/pages/CommonPageProps.js +1 -0
- package/lib/pages/DataGridPage.d.ts +9 -0
- package/lib/pages/DataGridPage.js +79 -0
- package/lib/pages/DataGridPageProps.d.ts +17 -0
- package/lib/pages/DataGridPageProps.js +1 -0
- package/lib/pages/EditPage.d.ts +33 -0
- package/lib/pages/EditPage.js +29 -0
- package/lib/pages/FixedListPage.d.ts +15 -0
- package/lib/pages/FixedListPage.js +70 -0
- package/lib/pages/ListPage.d.ts +9 -0
- package/lib/pages/ListPage.js +50 -0
- package/lib/pages/ListPageProps.d.ts +7 -0
- package/lib/pages/ListPageProps.js +1 -0
- package/lib/pages/ResponsivePage.d.ts +9 -0
- package/lib/pages/ResponsivePage.js +45 -0
- package/lib/pages/ResponsivePageProps.d.ts +39 -0
- package/lib/pages/ResponsivePageProps.js +1 -0
- package/lib/pages/SearchPageProps.d.ts +30 -0
- package/lib/pages/SearchPageProps.js +1 -0
- package/lib/pages/TablePage.d.ts +9 -0
- package/lib/pages/TablePage.js +69 -0
- package/lib/pages/TablePageProps.d.ts +7 -0
- package/lib/pages/TablePageProps.js +1 -0
- package/lib/pages/ViewPage.d.ts +66 -0
- package/lib/pages/ViewPage.js +105 -0
- package/lib/texts/DateText.d.ts +34 -0
- package/lib/texts/DateText.js +25 -0
- package/lib/texts/MoneyText.d.ts +21 -0
- package/lib/texts/MoneyText.js +14 -0
- package/lib/texts/NumberText.d.ts +25 -0
- package/lib/texts/NumberText.js +14 -0
- package/package.json +97 -0
- package/src/AuditDisplay.tsx +114 -0
- package/src/AutocompleteExtendedProps.ts +83 -0
- package/src/BackButton.tsx +55 -0
- package/src/BridgeCloseButton.tsx +69 -0
- package/src/ButtonLink.tsx +32 -0
- package/src/ComboBox.tsx +251 -0
- package/src/CountdownButton.tsx +119 -0
- package/src/CustomFabProps.ts +32 -0
- package/src/DataGridEx.tsx +713 -0
- package/src/DataGridRenderers.tsx +140 -0
- package/src/DialogButton.tsx +163 -0
- package/src/DnDList.tsx +344 -0
- package/src/DraggablePaperComponent.tsx +19 -0
- package/src/EmailInput.tsx +24 -0
- package/src/FabBox.tsx +51 -0
- package/src/FlexBox.tsx +20 -0
- package/src/GridDataFormat.tsx +77 -0
- package/src/IconButtonLink.tsx +29 -0
- package/src/InputField.tsx +82 -0
- package/src/ItemList.tsx +204 -0
- package/src/ListItemRightIcon.tsx +9 -0
- package/src/ListMoreDisplay.tsx +205 -0
- package/src/LoadingButton.tsx +75 -0
- package/src/MUGlobal.ts +220 -0
- package/src/MaskInput.tsx +107 -0
- package/src/MobileListItemRenderer.tsx +79 -0
- package/src/MoreFab.tsx +211 -0
- package/src/NotifierMU.tsx +654 -0
- package/src/NotifierPromptProps.ts +24 -0
- package/src/OptionGroup.tsx +223 -0
- package/src/PList.tsx +27 -0
- package/src/ProgressCount.tsx +166 -0
- package/src/PullToRefreshUI.tsx +21 -0
- package/src/RLink.tsx +64 -0
- package/src/ResponsibleContainer.tsx +394 -0
- package/src/ScrollTopFab.tsx +34 -0
- package/src/ScrollerListEx.tsx +387 -0
- package/src/SearchBar.tsx +396 -0
- package/src/SearchField.tsx +82 -0
- package/src/SearchOptionGroup.tsx +31 -0
- package/src/SelectBool.tsx +33 -0
- package/src/SelectEx.tsx +290 -0
- package/src/ShowDataComparison.tsx +106 -0
- package/src/Switch.tsx +94 -0
- package/src/SwitchAnt.tsx +95 -0
- package/src/TabBox.tsx +118 -0
- package/src/TableEx.tsx +558 -0
- package/src/TextFieldEx.tsx +249 -0
- package/src/Tiplist.tsx +303 -0
- package/src/TooltipClick.tsx +84 -0
- package/src/UserAvatar.tsx +64 -0
- package/src/UserAvatarEditor.tsx +287 -0
- package/src/app/CommonApp.ts +223 -0
- package/src/app/IServiceAppSettings.ts +13 -0
- package/src/app/IServicePage.ts +6 -0
- package/src/app/IServiceUser.ts +17 -0
- package/src/app/ISmartERPUser.ts +16 -0
- package/src/app/Labels.ts +77 -0
- package/src/app/ReactApp.ts +504 -0
- package/src/app/ServiceApp.ts +352 -0
- package/src/index.ts +77 -0
- package/src/pages/CommonPage.tsx +128 -0
- package/src/pages/CommonPageProps.ts +70 -0
- package/src/pages/DataGridPage.tsx +140 -0
- package/src/pages/DataGridPageProps.ts +24 -0
- package/src/pages/EditPage.tsx +114 -0
- package/src/pages/FixedListPage.tsx +141 -0
- package/src/pages/ListPage.tsx +90 -0
- package/src/pages/ListPageProps.ts +12 -0
- package/src/pages/ResponsivePage.tsx +68 -0
- package/src/pages/ResponsivePageProps.ts +57 -0
- package/src/pages/SearchPageProps.ts +39 -0
- package/src/pages/TablePage.tsx +126 -0
- package/src/pages/TablePageProps.ts +12 -0
- package/src/pages/ViewPage.tsx +282 -0
- package/src/texts/DateText.tsx +74 -0
- package/src/texts/MoneyText.tsx +49 -0
- package/src/texts/NumberText.tsx +40 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { DataTypes, Utils } from '@etsoo/shared';
|
|
2
|
+
import { Checkbox, FormControl, FormControlLabel, FormGroup, FormLabel, Radio, RadioGroup } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* OptionGroup
|
|
6
|
+
* @param props Props
|
|
7
|
+
* @returns Component
|
|
8
|
+
*/
|
|
9
|
+
export function OptionGroup(props) {
|
|
10
|
+
// Destruct
|
|
11
|
+
const { getOptionLabel, defaultValue, idField = 'id', label, labelField = 'label', multiple = false, name, onValueChange, options, readOnly, row, size, ...rest } = props;
|
|
12
|
+
// Get option value
|
|
13
|
+
// D type should be the source id type
|
|
14
|
+
const getOptionValue = (option) => {
|
|
15
|
+
const value = DataTypes.getValue(option, idField);
|
|
16
|
+
if (value == null)
|
|
17
|
+
return null;
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
// Checkbox values
|
|
21
|
+
const [values, setValues] = React.useState(defaultValue == null
|
|
22
|
+
? []
|
|
23
|
+
: Array.isArray(defaultValue)
|
|
24
|
+
? defaultValue
|
|
25
|
+
: [defaultValue]);
|
|
26
|
+
// Item checked
|
|
27
|
+
const itemChecked = (option) => {
|
|
28
|
+
// Value
|
|
29
|
+
const value = getOptionValue(option);
|
|
30
|
+
if (value == null)
|
|
31
|
+
return false;
|
|
32
|
+
return values.includes(value);
|
|
33
|
+
};
|
|
34
|
+
// First item value
|
|
35
|
+
const firstOptionValue = getOptionValue(options[0]);
|
|
36
|
+
// Items
|
|
37
|
+
const list = options.map((option) => {
|
|
38
|
+
// Control
|
|
39
|
+
const control = multiple ? (React.createElement(Checkbox, { name: name, readOnly: readOnly, size: size, checked: itemChecked(option), onChange: (event) => {
|
|
40
|
+
if (firstOptionValue == null)
|
|
41
|
+
return;
|
|
42
|
+
const typeValue = Utils.parseString(event.target.value, firstOptionValue);
|
|
43
|
+
const changedValues = [...values];
|
|
44
|
+
if (event.target.checked) {
|
|
45
|
+
if (changedValues.includes(typeValue))
|
|
46
|
+
return;
|
|
47
|
+
changedValues.push(typeValue);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const index = changedValues.findIndex((v) => v === typeValue);
|
|
51
|
+
if (index === -1)
|
|
52
|
+
return;
|
|
53
|
+
changedValues.splice(index, 1);
|
|
54
|
+
}
|
|
55
|
+
if (onValueChange)
|
|
56
|
+
onValueChange(changedValues);
|
|
57
|
+
setValues(changedValues);
|
|
58
|
+
} })) : (React.createElement(Radio, { size: size, readOnly: readOnly }));
|
|
59
|
+
// Label
|
|
60
|
+
const label = getOptionLabel == null
|
|
61
|
+
? `${option[labelField]}`
|
|
62
|
+
: getOptionLabel(option);
|
|
63
|
+
// Value, convert to string
|
|
64
|
+
// Will fail when type is number
|
|
65
|
+
const value = getOptionValue(option);
|
|
66
|
+
return (React.createElement(FormControlLabel, { key: value, control: control, value: value, label: label }));
|
|
67
|
+
});
|
|
68
|
+
// Group
|
|
69
|
+
const group = multiple ? (React.createElement(FormGroup, { row: row }, list)) : (React.createElement(RadioGroup, { row: row, name: name, value: values[0], onChange: (_event, value) => {
|
|
70
|
+
if (firstOptionValue == null)
|
|
71
|
+
return;
|
|
72
|
+
const typeValue = Utils.parseString(value, firstOptionValue);
|
|
73
|
+
if (onValueChange)
|
|
74
|
+
onValueChange(typeValue);
|
|
75
|
+
setValues([typeValue]);
|
|
76
|
+
} }, list));
|
|
77
|
+
// Layout
|
|
78
|
+
return (React.createElement(FormControl, { component: "fieldset", ...rest },
|
|
79
|
+
label && React.createElement(FormLabel, { component: "legend" }, label),
|
|
80
|
+
group));
|
|
81
|
+
}
|
package/lib/PList.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* Paragraph items list props
|
|
4
|
+
*/
|
|
5
|
+
export interface PListProps {
|
|
6
|
+
/**
|
|
7
|
+
* List items
|
|
8
|
+
*/
|
|
9
|
+
items?: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Paragraph items list
|
|
13
|
+
* @param items Items
|
|
14
|
+
*/
|
|
15
|
+
export declare function PList(props: PListProps): JSX.Element;
|
package/lib/PList.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Paragraph items list
|
|
4
|
+
* @param items Items
|
|
5
|
+
*/
|
|
6
|
+
export function PList(props) {
|
|
7
|
+
const { items } = props;
|
|
8
|
+
return (React.createElement(React.Fragment, null, items != null &&
|
|
9
|
+
items.map((item, index) => {
|
|
10
|
+
return React.createElement("p", { key: index }, item);
|
|
11
|
+
})));
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* Process count props
|
|
4
|
+
*/
|
|
5
|
+
export interface ProgressCountProps {
|
|
6
|
+
/**
|
|
7
|
+
* Is countdown or opposite
|
|
8
|
+
* @default 'true'
|
|
9
|
+
*/
|
|
10
|
+
countdown?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Is linear or circular
|
|
13
|
+
* @default 'true'
|
|
14
|
+
*/
|
|
15
|
+
linear?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Min width
|
|
18
|
+
* @default 36
|
|
19
|
+
*/
|
|
20
|
+
minWidth?: number;
|
|
21
|
+
/**
|
|
22
|
+
* On complete callback, return false will stop it
|
|
23
|
+
*/
|
|
24
|
+
onComplete?: () => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* On progress callback
|
|
27
|
+
*/
|
|
28
|
+
onProgress?: (value: number) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Seconds for count
|
|
31
|
+
*/
|
|
32
|
+
seconds: number;
|
|
33
|
+
/**
|
|
34
|
+
* Value unit, like 's' or '%'
|
|
35
|
+
* @default ''
|
|
36
|
+
*/
|
|
37
|
+
valueUnit?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Progress count
|
|
41
|
+
* @param props Props
|
|
42
|
+
* @returns Component
|
|
43
|
+
*/
|
|
44
|
+
export declare function ProgressCount(props: ProgressCountProps): JSX.Element;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Box, CircularProgress, LinearProgress, Typography } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Progress count
|
|
5
|
+
* @param props Props
|
|
6
|
+
* @returns Component
|
|
7
|
+
*/
|
|
8
|
+
export function ProgressCount(props) {
|
|
9
|
+
// Destruct
|
|
10
|
+
const { countdown = true, linear = true, minWidth = 36, onComplete, onProgress, seconds, valueUnit = '' } = props;
|
|
11
|
+
// Progress value
|
|
12
|
+
const [value, setValue] = React.useState(countdown ? seconds : 0);
|
|
13
|
+
// Variant
|
|
14
|
+
const [variant, setVariant] = React.useState('determinate');
|
|
15
|
+
// Progress value
|
|
16
|
+
const progressValue = (100.0 * value) / seconds;
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
const timer = setInterval(() => {
|
|
19
|
+
setValue((prev) => {
|
|
20
|
+
const newValue = countdown
|
|
21
|
+
? prev === 0
|
|
22
|
+
? seconds
|
|
23
|
+
: prev - 1
|
|
24
|
+
: prev === seconds
|
|
25
|
+
? 0
|
|
26
|
+
: prev + 1;
|
|
27
|
+
if (countdown) {
|
|
28
|
+
if (newValue === 0) {
|
|
29
|
+
if (onComplete) {
|
|
30
|
+
const result = onComplete();
|
|
31
|
+
// Finish
|
|
32
|
+
if (result === false) {
|
|
33
|
+
clearInterval(timer);
|
|
34
|
+
setVariant('indeterminate');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
if (newValue === seconds) {
|
|
41
|
+
if (onComplete) {
|
|
42
|
+
const result = onComplete();
|
|
43
|
+
// Finish
|
|
44
|
+
if (result === false) {
|
|
45
|
+
clearInterval(timer);
|
|
46
|
+
setVariant('indeterminate');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (onProgress)
|
|
52
|
+
onProgress(newValue);
|
|
53
|
+
return newValue;
|
|
54
|
+
});
|
|
55
|
+
}, 1000);
|
|
56
|
+
return () => {
|
|
57
|
+
clearInterval(timer);
|
|
58
|
+
};
|
|
59
|
+
}, []);
|
|
60
|
+
if (linear)
|
|
61
|
+
return (React.createElement(Box, { sx: { display: 'flex', alignItems: 'center', width: '100%' } },
|
|
62
|
+
React.createElement(Box, { sx: { width: '100%', mr: 1 } },
|
|
63
|
+
React.createElement(LinearProgress, { variant: variant, value: progressValue })),
|
|
64
|
+
React.createElement(Box, { sx: { minWidth } },
|
|
65
|
+
React.createElement(Typography, { variant: "body2", color: "text.secondary" }, `${value}${valueUnit}`))));
|
|
66
|
+
return (React.createElement(Box, { sx: { position: 'relative', display: 'inline-flex' } },
|
|
67
|
+
React.createElement(CircularProgress, { variant: variant, value: progressValue }),
|
|
68
|
+
React.createElement(Box, { sx: {
|
|
69
|
+
top: 0,
|
|
70
|
+
left: 0,
|
|
71
|
+
bottom: 0,
|
|
72
|
+
right: 0,
|
|
73
|
+
position: 'absolute',
|
|
74
|
+
display: 'flex',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
justifyContent: 'center'
|
|
77
|
+
} },
|
|
78
|
+
React.createElement(Typography, { variant: "caption", component: "div", color: "text.secondary" }, `${value}${valueUnit}`))));
|
|
79
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Options } from 'pulltorefreshjs';
|
|
3
|
+
/**
|
|
4
|
+
* PullToRefresh UI
|
|
5
|
+
* Use hammerjs or touchemulator to simulate browser as mobile device
|
|
6
|
+
* @param props Props
|
|
7
|
+
* @returns Component
|
|
8
|
+
*/
|
|
9
|
+
export declare function PullToRefreshUI(props: Options): JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PullToRefresh from 'pulltorefreshjs';
|
|
3
|
+
/**
|
|
4
|
+
* PullToRefresh UI
|
|
5
|
+
* Use hammerjs or touchemulator to simulate browser as mobile device
|
|
6
|
+
* @param props Props
|
|
7
|
+
* @returns Component
|
|
8
|
+
*/
|
|
9
|
+
export function PullToRefreshUI(props) {
|
|
10
|
+
// Ready
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
PullToRefresh.init(props);
|
|
13
|
+
return () => {
|
|
14
|
+
PullToRefresh.destroyAll();
|
|
15
|
+
};
|
|
16
|
+
}, [props]);
|
|
17
|
+
return React.createElement(React.Fragment, null);
|
|
18
|
+
}
|
package/lib/RLink.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LinkProps } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Router Link properties
|
|
5
|
+
*/
|
|
6
|
+
export declare type RLinkProps = LinkProps & {
|
|
7
|
+
delay?: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Router Link
|
|
11
|
+
* @param props Props
|
|
12
|
+
* @returns Component
|
|
13
|
+
*/
|
|
14
|
+
export declare const RLink: React.ForwardRefExoticComponent<Pick<RLinkProps, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "p" | "slot" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "position" | "type" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint" | "underline" | "media" | "target" | "href" | "download" | "hrefLang" | "ping" | "rel" | "referrerPolicy" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping" | "TypographyClasses" | "delay"> & React.RefAttributes<HTMLAnchorElement>>;
|
package/lib/RLink.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useDelayedExecutor } from '@etsoo/react';
|
|
2
|
+
import { Link } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { globalApp } from './app/ReactApp';
|
|
5
|
+
/**
|
|
6
|
+
* Router Link
|
|
7
|
+
* @param props Props
|
|
8
|
+
* @returns Component
|
|
9
|
+
*/
|
|
10
|
+
export const RLink = React.forwardRef((props, ref) => {
|
|
11
|
+
// Destruct
|
|
12
|
+
const { delay = 0, href, target, onClick, ...rest } = props;
|
|
13
|
+
const delayed = useDelayedExecutor((href) => {
|
|
14
|
+
// Router push
|
|
15
|
+
globalApp.history.push(href);
|
|
16
|
+
}, delay);
|
|
17
|
+
// Click handler
|
|
18
|
+
const onClickLocl = (event) => {
|
|
19
|
+
if (onClick)
|
|
20
|
+
onClick(event);
|
|
21
|
+
if (!event.isDefaultPrevented() &&
|
|
22
|
+
href &&
|
|
23
|
+
(!target || target === '_self') && // Let browser handle "target=_blank" etc
|
|
24
|
+
globalApp) {
|
|
25
|
+
// Prevent href action
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
// Delayed excution
|
|
28
|
+
delayed.call(undefined, href);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
// Clear when exit
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
return () => delayed.clear();
|
|
34
|
+
}, [delayed]);
|
|
35
|
+
// Component
|
|
36
|
+
return (React.createElement(Link, { ...rest, onClick: onClickLocl, href: href, target: target, ref: ref }));
|
|
37
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
2
|
+
import { SxProps, Theme } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { ListChildComponentProps } from 'react-window';
|
|
5
|
+
import { GridColumn, GridJsonData, GridMethodRef } from '@etsoo/react';
|
|
6
|
+
import { DataGridExProps } from './DataGridEx';
|
|
7
|
+
import { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from './ScrollerListEx';
|
|
8
|
+
/**
|
|
9
|
+
* ResponsibleContainer props
|
|
10
|
+
*/
|
|
11
|
+
export declare type ResponsibleContainerProps<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>> = Omit<DataGridExProps<T, D>, 'height' | 'itemKey' | 'loadData' | 'mRef' | 'onScroll' | 'onItemsRendered'> & {
|
|
12
|
+
/**
|
|
13
|
+
* Height will be deducted
|
|
14
|
+
* @param height Current calcuated height
|
|
15
|
+
*/
|
|
16
|
+
adjustHeight?: (height: number) => number;
|
|
17
|
+
/**
|
|
18
|
+
* Columns
|
|
19
|
+
*/
|
|
20
|
+
columns: GridColumn<T>[];
|
|
21
|
+
/**
|
|
22
|
+
* Container box SX (dataGrid determines the case)
|
|
23
|
+
*/
|
|
24
|
+
containerBoxSx?: (paddings: Record<string, string | number>, hasFields: boolean, dataGrid?: boolean) => SxProps<Theme>;
|
|
25
|
+
/**
|
|
26
|
+
* Min width to show Datagrid
|
|
27
|
+
*/
|
|
28
|
+
dataGridMinWidth?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Search fields
|
|
31
|
+
*/
|
|
32
|
+
fields?: React.ReactElement[];
|
|
33
|
+
/**
|
|
34
|
+
* Search field template
|
|
35
|
+
*/
|
|
36
|
+
fieldTemplate?: F;
|
|
37
|
+
/**
|
|
38
|
+
* Grid height
|
|
39
|
+
*/
|
|
40
|
+
height?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Inner item renderer
|
|
43
|
+
*/
|
|
44
|
+
innerItemRenderer: (props: ScrollerListExInnerItemRendererProps<T>) => React.ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Item renderer
|
|
47
|
+
*/
|
|
48
|
+
itemRenderer?: (props: ListChildComponentProps<T>) => React.ReactElement;
|
|
49
|
+
/**
|
|
50
|
+
* Item size, a function indicates its a variable size list
|
|
51
|
+
*/
|
|
52
|
+
itemSize: ScrollerListExItemSize;
|
|
53
|
+
/**
|
|
54
|
+
* Load data callback
|
|
55
|
+
*/
|
|
56
|
+
loadData: (data: GridJsonData & DataTypes.BasicTemplateType<F>) => PromiseLike<T[] | null | undefined>;
|
|
57
|
+
/**
|
|
58
|
+
* Methods
|
|
59
|
+
*/
|
|
60
|
+
mRef?: React.MutableRefObject<GridMethodRef<T> | undefined>;
|
|
61
|
+
/**
|
|
62
|
+
* Element ready callback
|
|
63
|
+
*/
|
|
64
|
+
elementReady?: (element: HTMLElement, isDataGrid: boolean) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Paddings
|
|
67
|
+
*/
|
|
68
|
+
paddings?: Record<string, string | number>;
|
|
69
|
+
/**
|
|
70
|
+
* Pull to refresh data
|
|
71
|
+
*/
|
|
72
|
+
pullToRefresh?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Quick action for double click or click under mobile
|
|
75
|
+
*/
|
|
76
|
+
quickAction?: (data: T) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Size ready to read miliseconds span
|
|
79
|
+
*/
|
|
80
|
+
sizeReadyMiliseconds?: number;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Responsible container
|
|
84
|
+
* @param props Props
|
|
85
|
+
* @returns Layout
|
|
86
|
+
*/
|
|
87
|
+
export declare function ResponsibleContainer<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: ResponsibleContainerProps<T, F, D>): JSX.Element;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Box, Stack } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { GridDataGet, ReactUtils, useCombinedRefs, useDimensions } from '@etsoo/react';
|
|
4
|
+
import { DataGridEx, DataGridExCalColumns } from './DataGridEx';
|
|
5
|
+
import { MUGlobal } from './MUGlobal';
|
|
6
|
+
import { PullToRefreshUI } from './PullToRefreshUI';
|
|
7
|
+
import { ScrollerListEx } from './ScrollerListEx';
|
|
8
|
+
import { SearchBar } from './SearchBar';
|
|
9
|
+
import { Labels } from './app/Labels';
|
|
10
|
+
function defaultContainerBoxSx(paddings, hasField, _dataGrid) {
|
|
11
|
+
const half = MUGlobal.half(paddings);
|
|
12
|
+
return {
|
|
13
|
+
'& .SearchBox': {
|
|
14
|
+
marginBottom: hasField ? half : 0
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Responsible container
|
|
20
|
+
* @param props Props
|
|
21
|
+
* @returns Layout
|
|
22
|
+
*/
|
|
23
|
+
export function ResponsibleContainer(props) {
|
|
24
|
+
// Destruct
|
|
25
|
+
const { adjustHeight, columns, containerBoxSx = defaultContainerBoxSx, dataGridMinWidth = Math.max(576, DataGridExCalColumns(columns).total), elementReady, fields, fieldTemplate, height, loadData, mRef, paddings = MUGlobal.pagePaddings, pullToRefresh = true, quickAction, sizeReadyMiliseconds = 0, ...rest } = props;
|
|
26
|
+
// Labels
|
|
27
|
+
const labels = Labels.CommonPage;
|
|
28
|
+
// Refs
|
|
29
|
+
const refs = React.useRef({});
|
|
30
|
+
const state = refs.current;
|
|
31
|
+
const mRefs = useCombinedRefs(mRef, (ref) => {
|
|
32
|
+
if (ref == null)
|
|
33
|
+
return;
|
|
34
|
+
state.ref = ref;
|
|
35
|
+
});
|
|
36
|
+
// Update mounted state
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
return () => {
|
|
39
|
+
state.mounted = false;
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
// Has fields
|
|
43
|
+
const hasFields = fields != null && fields.length > 0;
|
|
44
|
+
// Load data
|
|
45
|
+
const localLoadData = (props) => {
|
|
46
|
+
state.mounted = true;
|
|
47
|
+
const data = GridDataGet(props, fieldTemplate);
|
|
48
|
+
return loadData(data);
|
|
49
|
+
};
|
|
50
|
+
// On submit callback
|
|
51
|
+
const onSubmit = (data, _reset) => {
|
|
52
|
+
if (data == null || state.ref == null)
|
|
53
|
+
return;
|
|
54
|
+
state.ref.reset({ data });
|
|
55
|
+
};
|
|
56
|
+
// Watch container
|
|
57
|
+
const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds, (_preRect, rect) => {
|
|
58
|
+
// Check
|
|
59
|
+
if (rect == null)
|
|
60
|
+
return true;
|
|
61
|
+
// Last rect
|
|
62
|
+
const lastRect = state.rect;
|
|
63
|
+
// 32 = scroll bar width
|
|
64
|
+
if (lastRect != null &&
|
|
65
|
+
state.mounted !== true &&
|
|
66
|
+
Math.abs(rect.width - lastRect.width) <= 32 &&
|
|
67
|
+
Math.abs(rect.height - lastRect.height) <= 32)
|
|
68
|
+
return true;
|
|
69
|
+
// Hold the new rect
|
|
70
|
+
state.rect = rect;
|
|
71
|
+
return false;
|
|
72
|
+
});
|
|
73
|
+
// Rect
|
|
74
|
+
const rect = dimensions[0][2];
|
|
75
|
+
// Create list
|
|
76
|
+
const [list, showDataGrid] = (() => {
|
|
77
|
+
// No layout
|
|
78
|
+
if (rect == null)
|
|
79
|
+
return [null, undefined];
|
|
80
|
+
// Width
|
|
81
|
+
const width = rect.width;
|
|
82
|
+
// Show DataGrid or List dependng on width
|
|
83
|
+
const showDataGrid = width >= dataGridMinWidth;
|
|
84
|
+
// Height
|
|
85
|
+
let heightLocal;
|
|
86
|
+
if (height != null) {
|
|
87
|
+
heightLocal = height;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// Auto calculation
|
|
91
|
+
heightLocal =
|
|
92
|
+
document.documentElement.clientHeight -
|
|
93
|
+
Math.round(rect.bottom + 1);
|
|
94
|
+
const style = window.getComputedStyle(dimensions[0][1]);
|
|
95
|
+
const boxMargin = parseFloat(style.marginBottom);
|
|
96
|
+
if (!isNaN(boxMargin))
|
|
97
|
+
heightLocal -= 3 * boxMargin; // 1 - Box, 2 - Page bottom
|
|
98
|
+
if (adjustHeight != null) {
|
|
99
|
+
heightLocal -= adjustHeight(heightLocal);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (showDataGrid) {
|
|
103
|
+
// Delete
|
|
104
|
+
delete rest.itemRenderer;
|
|
105
|
+
return [
|
|
106
|
+
React.createElement(Box, { className: "DataGridBox" },
|
|
107
|
+
React.createElement(DataGridEx, { autoLoad: !hasFields, height: heightLocal, width: rect.width, loadData: localLoadData, mRef: mRefs, onDoubleClick: (_, data) => quickAction && quickAction(data), outerRef: (element) => {
|
|
108
|
+
if (element != null && elementReady)
|
|
109
|
+
elementReady(element, true);
|
|
110
|
+
}, columns: columns, ...rest })),
|
|
111
|
+
true
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
// Delete
|
|
115
|
+
delete rest.checkable;
|
|
116
|
+
delete rest.borderRowsCount;
|
|
117
|
+
delete rest.bottomHeight;
|
|
118
|
+
delete rest.footerItemRenderer;
|
|
119
|
+
delete rest.headerHeight;
|
|
120
|
+
delete rest.hideFooter;
|
|
121
|
+
delete rest.hoverColor;
|
|
122
|
+
delete rest.selectable;
|
|
123
|
+
return [
|
|
124
|
+
React.createElement(Box, { className: "ListBox", sx: { height: heightLocal } },
|
|
125
|
+
React.createElement(ScrollerListEx, { autoLoad: !hasFields, height: heightLocal, loadData: localLoadData, mRef: mRefs, onClick: (event, data) => quickAction &&
|
|
126
|
+
ReactUtils.isSafeClick(event) &&
|
|
127
|
+
quickAction(data), oRef: (element) => {
|
|
128
|
+
if (element != null && elementReady)
|
|
129
|
+
elementReady(element, false);
|
|
130
|
+
}, ...rest })),
|
|
131
|
+
false
|
|
132
|
+
];
|
|
133
|
+
})();
|
|
134
|
+
const searchBar = React.useMemo(() => {
|
|
135
|
+
if (!hasFields || showDataGrid == null)
|
|
136
|
+
return;
|
|
137
|
+
return (React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit, className: `searchBar${showDataGrid ? 'Grid' : 'List'}` }));
|
|
138
|
+
}, [showDataGrid, hasFields]);
|
|
139
|
+
// Pull container
|
|
140
|
+
const pullContainer = showDataGrid == null
|
|
141
|
+
? undefined
|
|
142
|
+
: showDataGrid
|
|
143
|
+
? '.DataGridEx-Body'
|
|
144
|
+
: '.ScrollerListEx-Body';
|
|
145
|
+
// Layout
|
|
146
|
+
return (React.createElement(Box, { sx: containerBoxSx == null
|
|
147
|
+
? undefined
|
|
148
|
+
: containerBoxSx(paddings, hasFields, showDataGrid) },
|
|
149
|
+
React.createElement(Stack, null,
|
|
150
|
+
React.createElement(Box, { ref: dimensions[0][0], className: "SearchBox", sx: { height: hasFields ? 40 : 0 } }, searchBar),
|
|
151
|
+
list),
|
|
152
|
+
pullToRefresh && pullContainer && (React.createElement(PullToRefreshUI, { mainElement: pullContainer, triggerElement: pullContainer, instructionsPullToRefresh: labels.pullToRefresh, instructionsReleaseToRefresh: labels.releaseToRefresh, instructionsRefreshing: labels.refreshing, onRefresh: () => { var _a; return (_a = state.ref) === null || _a === void 0 ? void 0 : _a.reset(); }, shouldPullToRefresh: () => {
|
|
153
|
+
const container = document.querySelector(pullContainer);
|
|
154
|
+
return !(container === null || container === void 0 ? void 0 : container.scrollTop);
|
|
155
|
+
} }))));
|
|
156
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Fab, useScrollTrigger, Zoom } from '@mui/material';
|
|
3
|
+
import VerticalAlignTopIcon from '@mui/icons-material/VerticalAlignTop';
|
|
4
|
+
/**
|
|
5
|
+
* Scroll to top fab
|
|
6
|
+
* @returns Component
|
|
7
|
+
*/
|
|
8
|
+
export function ScrollTopFab(props) {
|
|
9
|
+
// Destruct
|
|
10
|
+
const { color, size, target, title } = props;
|
|
11
|
+
// Scroll trigger
|
|
12
|
+
const trigger = useScrollTrigger({
|
|
13
|
+
target,
|
|
14
|
+
disableHysteresis: true,
|
|
15
|
+
threshold: 120
|
|
16
|
+
});
|
|
17
|
+
// Icon click handler
|
|
18
|
+
// behavior: 'smooth'
|
|
19
|
+
const handleClick = () => {
|
|
20
|
+
target.scrollTo({ top: 0 });
|
|
21
|
+
};
|
|
22
|
+
return (React.createElement(Zoom, { in: trigger },
|
|
23
|
+
React.createElement(Fab, { color: color, size: size, title: title, onClick: handleClick },
|
|
24
|
+
React.createElement(VerticalAlignTopIcon, null))));
|
|
25
|
+
}
|