@etsoo/react 1.5.79 → 1.5.82
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 +9 -21
- 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/MUGlobalTests.tsx +0 -58
- package/__tests__/mu/NotifierMUTests.tsx +0 -213
- 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/OptionGroup.tsx
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DataTypes,
|
|
3
|
-
IdDefaultType,
|
|
4
|
-
LabelDefaultType,
|
|
5
|
-
ListType,
|
|
6
|
-
Utils
|
|
7
|
-
} from '@etsoo/shared';
|
|
8
|
-
import {
|
|
9
|
-
Checkbox,
|
|
10
|
-
FormControl,
|
|
11
|
-
FormControlLabel,
|
|
12
|
-
FormControlProps,
|
|
13
|
-
FormGroup,
|
|
14
|
-
FormLabel,
|
|
15
|
-
Radio,
|
|
16
|
-
RadioGroup
|
|
17
|
-
} from '@mui/material';
|
|
18
|
-
import React from 'react';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* OptionGroup props
|
|
22
|
-
*/
|
|
23
|
-
export type OptionGroupProps<
|
|
24
|
-
T extends object,
|
|
25
|
-
D extends DataTypes.Keys<T>,
|
|
26
|
-
L extends DataTypes.Keys<T, string>
|
|
27
|
-
> = Omit<FormControlProps<'fieldset'>, 'defaultValue'> & {
|
|
28
|
-
/**
|
|
29
|
-
* Default value
|
|
30
|
-
*/
|
|
31
|
-
defaultValue?: T[D] | T[D][];
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Get option label function
|
|
35
|
-
*/
|
|
36
|
-
getOptionLabel?: (option: T) => string;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Id field
|
|
40
|
-
*/
|
|
41
|
-
idField?: D;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Label
|
|
45
|
-
*/
|
|
46
|
-
label?: string;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Label field
|
|
50
|
-
*/
|
|
51
|
-
labelField?: L;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Multiple choose item
|
|
55
|
-
*/
|
|
56
|
-
multiple?: boolean;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Field name
|
|
60
|
-
*/
|
|
61
|
-
name: string;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* On value change handler
|
|
65
|
-
*/
|
|
66
|
-
onValueChange?: (value: T[D] | T[D][] | undefined) => void;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Array of options.
|
|
70
|
-
*/
|
|
71
|
-
options: ReadonlyArray<T>;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Is the field read only?
|
|
75
|
-
*/
|
|
76
|
-
readOnly?: boolean;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Display group of elements in a compact row
|
|
80
|
-
*/
|
|
81
|
-
row?: boolean;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* OptionGroup
|
|
86
|
-
* @param props Props
|
|
87
|
-
* @returns Component
|
|
88
|
-
*/
|
|
89
|
-
export function OptionGroup<
|
|
90
|
-
T extends object = ListType,
|
|
91
|
-
D extends DataTypes.Keys<T> = IdDefaultType<T>,
|
|
92
|
-
L extends DataTypes.Keys<T, string> = LabelDefaultType<T>
|
|
93
|
-
>(props: OptionGroupProps<T, D, L>) {
|
|
94
|
-
// Destruct
|
|
95
|
-
const {
|
|
96
|
-
getOptionLabel,
|
|
97
|
-
defaultValue,
|
|
98
|
-
idField = 'id' as D,
|
|
99
|
-
label,
|
|
100
|
-
labelField = 'label' as L,
|
|
101
|
-
multiple = false,
|
|
102
|
-
name,
|
|
103
|
-
onValueChange,
|
|
104
|
-
options,
|
|
105
|
-
readOnly,
|
|
106
|
-
row,
|
|
107
|
-
size,
|
|
108
|
-
...rest
|
|
109
|
-
} = props;
|
|
110
|
-
|
|
111
|
-
// Get option value
|
|
112
|
-
// D type should be the source id type
|
|
113
|
-
const getOptionValue = (option: T): T[D] | null => {
|
|
114
|
-
const value = DataTypes.getValue(option, idField);
|
|
115
|
-
if (value == null) return null;
|
|
116
|
-
return value as T[D];
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
// Checkbox values
|
|
120
|
-
const [values, setValues] = React.useState(
|
|
121
|
-
defaultValue == null
|
|
122
|
-
? []
|
|
123
|
-
: Array.isArray(defaultValue)
|
|
124
|
-
? defaultValue
|
|
125
|
-
: [defaultValue]
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
// Item checked
|
|
129
|
-
const itemChecked = (option: T) => {
|
|
130
|
-
// Value
|
|
131
|
-
const value = getOptionValue(option);
|
|
132
|
-
if (value == null) return false;
|
|
133
|
-
|
|
134
|
-
return values.includes(value);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// First item value
|
|
138
|
-
const firstOptionValue = getOptionValue(options[0]);
|
|
139
|
-
|
|
140
|
-
// Items
|
|
141
|
-
const list = options.map((option) => {
|
|
142
|
-
// Control
|
|
143
|
-
const control = multiple ? (
|
|
144
|
-
<Checkbox
|
|
145
|
-
name={name}
|
|
146
|
-
readOnly={readOnly}
|
|
147
|
-
size={size}
|
|
148
|
-
checked={itemChecked(option)}
|
|
149
|
-
onChange={(event) => {
|
|
150
|
-
if (firstOptionValue == null) return;
|
|
151
|
-
|
|
152
|
-
const typeValue = Utils.parseString(
|
|
153
|
-
event.target.value,
|
|
154
|
-
firstOptionValue
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
const changedValues = [...values];
|
|
158
|
-
if (event.target.checked) {
|
|
159
|
-
if (changedValues.includes(typeValue)) return;
|
|
160
|
-
changedValues.push(typeValue);
|
|
161
|
-
} else {
|
|
162
|
-
const index = changedValues.findIndex(
|
|
163
|
-
(v) => v === typeValue
|
|
164
|
-
);
|
|
165
|
-
if (index === -1) return;
|
|
166
|
-
changedValues.splice(index, 1);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (onValueChange) onValueChange(changedValues);
|
|
170
|
-
setValues(changedValues);
|
|
171
|
-
}}
|
|
172
|
-
/>
|
|
173
|
-
) : (
|
|
174
|
-
<Radio size={size} readOnly={readOnly} />
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
// Label
|
|
178
|
-
const label =
|
|
179
|
-
getOptionLabel == null
|
|
180
|
-
? `${option[labelField]}`
|
|
181
|
-
: getOptionLabel(option);
|
|
182
|
-
|
|
183
|
-
// Value, convert to string
|
|
184
|
-
// Will fail when type is number
|
|
185
|
-
const value = getOptionValue(option) as unknown as React.Key;
|
|
186
|
-
|
|
187
|
-
return (
|
|
188
|
-
<FormControlLabel
|
|
189
|
-
key={value}
|
|
190
|
-
control={control}
|
|
191
|
-
value={value}
|
|
192
|
-
label={label}
|
|
193
|
-
/>
|
|
194
|
-
);
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// Group
|
|
198
|
-
const group = multiple ? (
|
|
199
|
-
<FormGroup row={row}>{list}</FormGroup>
|
|
200
|
-
) : (
|
|
201
|
-
<RadioGroup
|
|
202
|
-
row={row}
|
|
203
|
-
name={name}
|
|
204
|
-
value={values[0]}
|
|
205
|
-
onChange={(_event, value) => {
|
|
206
|
-
if (firstOptionValue == null) return;
|
|
207
|
-
const typeValue = Utils.parseString(value, firstOptionValue);
|
|
208
|
-
if (onValueChange) onValueChange(typeValue);
|
|
209
|
-
setValues([typeValue]);
|
|
210
|
-
}}
|
|
211
|
-
>
|
|
212
|
-
{list}
|
|
213
|
-
</RadioGroup>
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
// Layout
|
|
217
|
-
return (
|
|
218
|
-
<FormControl component="fieldset" {...rest}>
|
|
219
|
-
{label && <FormLabel component="legend">{label}</FormLabel>}
|
|
220
|
-
{group}
|
|
221
|
-
</FormControl>
|
|
222
|
-
);
|
|
223
|
-
}
|
package/src/mu/PList.tsx
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Paragraph items list props
|
|
5
|
-
*/
|
|
6
|
-
export interface PListProps {
|
|
7
|
-
/**
|
|
8
|
-
* List items
|
|
9
|
-
*/
|
|
10
|
-
items?: string[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Paragraph items list
|
|
15
|
-
* @param items Items
|
|
16
|
-
*/
|
|
17
|
-
export function PList(props: PListProps) {
|
|
18
|
-
const { items } = props;
|
|
19
|
-
return (
|
|
20
|
-
<React.Fragment>
|
|
21
|
-
{items != null &&
|
|
22
|
-
items.map((item, index) => {
|
|
23
|
-
return <p key={index}>{item}</p>;
|
|
24
|
-
})}
|
|
25
|
-
</React.Fragment>
|
|
26
|
-
);
|
|
27
|
-
}
|
package/src/mu/ProgressCount.tsx
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
CircularProgress,
|
|
4
|
-
LinearProgress,
|
|
5
|
-
Typography
|
|
6
|
-
} from '@mui/material';
|
|
7
|
-
import React from 'react';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Process count props
|
|
11
|
-
*/
|
|
12
|
-
export interface ProgressCountProps {
|
|
13
|
-
/**
|
|
14
|
-
* Is countdown or opposite
|
|
15
|
-
* @default 'true'
|
|
16
|
-
*/
|
|
17
|
-
countdown?: boolean;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Is linear or circular
|
|
21
|
-
* @default 'true'
|
|
22
|
-
*/
|
|
23
|
-
linear?: boolean;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Min width
|
|
27
|
-
* @default 36
|
|
28
|
-
*/
|
|
29
|
-
minWidth?: number;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* On complete callback, return false will stop it
|
|
33
|
-
*/
|
|
34
|
-
onComplete?: () => boolean;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* On progress callback
|
|
38
|
-
*/
|
|
39
|
-
onProgress?: (value: number) => void;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Seconds for count
|
|
43
|
-
*/
|
|
44
|
-
seconds: number;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Value unit, like 's' or '%'
|
|
48
|
-
* @default ''
|
|
49
|
-
*/
|
|
50
|
-
valueUnit?: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Progress count
|
|
55
|
-
* @param props Props
|
|
56
|
-
* @returns Component
|
|
57
|
-
*/
|
|
58
|
-
export function ProgressCount(props: ProgressCountProps) {
|
|
59
|
-
// Destruct
|
|
60
|
-
const {
|
|
61
|
-
countdown = true,
|
|
62
|
-
linear = true,
|
|
63
|
-
minWidth = 36,
|
|
64
|
-
onComplete,
|
|
65
|
-
onProgress,
|
|
66
|
-
seconds,
|
|
67
|
-
valueUnit = ''
|
|
68
|
-
} = props;
|
|
69
|
-
|
|
70
|
-
// Progress value
|
|
71
|
-
const [value, setValue] = React.useState(countdown ? seconds : 0);
|
|
72
|
-
|
|
73
|
-
// Variant
|
|
74
|
-
const [variant, setVariant] = React.useState<
|
|
75
|
-
'determinate' | 'indeterminate'
|
|
76
|
-
>('determinate');
|
|
77
|
-
|
|
78
|
-
// Progress value
|
|
79
|
-
const progressValue = (100.0 * value) / seconds;
|
|
80
|
-
|
|
81
|
-
React.useEffect(() => {
|
|
82
|
-
const timer = setInterval(() => {
|
|
83
|
-
setValue((prev) => {
|
|
84
|
-
const newValue = countdown
|
|
85
|
-
? prev === 0
|
|
86
|
-
? seconds
|
|
87
|
-
: prev - 1
|
|
88
|
-
: prev === seconds
|
|
89
|
-
? 0
|
|
90
|
-
: prev + 1;
|
|
91
|
-
|
|
92
|
-
if (countdown) {
|
|
93
|
-
if (newValue === 0) {
|
|
94
|
-
if (onComplete) {
|
|
95
|
-
const result = onComplete();
|
|
96
|
-
// Finish
|
|
97
|
-
if (result === false) {
|
|
98
|
-
clearInterval(timer);
|
|
99
|
-
setVariant('indeterminate');
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
if (newValue === seconds) {
|
|
105
|
-
if (onComplete) {
|
|
106
|
-
const result = onComplete();
|
|
107
|
-
// Finish
|
|
108
|
-
if (result === false) {
|
|
109
|
-
clearInterval(timer);
|
|
110
|
-
setVariant('indeterminate');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (onProgress) onProgress(newValue);
|
|
117
|
-
|
|
118
|
-
return newValue;
|
|
119
|
-
});
|
|
120
|
-
}, 1000);
|
|
121
|
-
return () => {
|
|
122
|
-
clearInterval(timer);
|
|
123
|
-
};
|
|
124
|
-
}, []);
|
|
125
|
-
|
|
126
|
-
if (linear)
|
|
127
|
-
return (
|
|
128
|
-
<Box sx={{ display: 'flex', alignItems: 'center', width: '100%' }}>
|
|
129
|
-
<Box sx={{ width: '100%', mr: 1 }}>
|
|
130
|
-
<LinearProgress variant={variant} value={progressValue} />
|
|
131
|
-
</Box>
|
|
132
|
-
<Box sx={{ minWidth }}>
|
|
133
|
-
<Typography
|
|
134
|
-
variant="body2"
|
|
135
|
-
color="text.secondary"
|
|
136
|
-
>{`${value}${valueUnit}`}</Typography>
|
|
137
|
-
</Box>
|
|
138
|
-
</Box>
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<Box sx={{ position: 'relative', display: 'inline-flex' }}>
|
|
143
|
-
<CircularProgress variant={variant} value={progressValue} />
|
|
144
|
-
<Box
|
|
145
|
-
sx={{
|
|
146
|
-
top: 0,
|
|
147
|
-
left: 0,
|
|
148
|
-
bottom: 0,
|
|
149
|
-
right: 0,
|
|
150
|
-
position: 'absolute',
|
|
151
|
-
display: 'flex',
|
|
152
|
-
alignItems: 'center',
|
|
153
|
-
justifyContent: 'center'
|
|
154
|
-
}}
|
|
155
|
-
>
|
|
156
|
-
<Typography
|
|
157
|
-
variant="caption"
|
|
158
|
-
component="div"
|
|
159
|
-
color="text.secondary"
|
|
160
|
-
>
|
|
161
|
-
{`${value}${valueUnit}`}
|
|
162
|
-
</Typography>
|
|
163
|
-
</Box>
|
|
164
|
-
</Box>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PullToRefresh, { Options } from 'pulltorefreshjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* PullToRefresh UI
|
|
6
|
-
* Use hammerjs or touchemulator to simulate browser as mobile device
|
|
7
|
-
* @param props Props
|
|
8
|
-
* @returns Component
|
|
9
|
-
*/
|
|
10
|
-
export function PullToRefreshUI(props: Options) {
|
|
11
|
-
// Ready
|
|
12
|
-
React.useEffect(() => {
|
|
13
|
-
PullToRefresh.init(props);
|
|
14
|
-
|
|
15
|
-
return () => {
|
|
16
|
-
PullToRefresh.destroyAll();
|
|
17
|
-
};
|
|
18
|
-
}, [props]);
|
|
19
|
-
|
|
20
|
-
return <React.Fragment />;
|
|
21
|
-
}
|
package/src/mu/RLink.tsx
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Link, LinkProps } from '@mui/material';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { globalApp } from '../app/ReactApp';
|
|
4
|
-
import { useDelayedExecutor } from '../uses/useDelayedExecutor';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Router Link properties
|
|
8
|
-
*/
|
|
9
|
-
export type RLinkProps = LinkProps & {
|
|
10
|
-
delay?: number;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Router Link
|
|
15
|
-
* @param props Props
|
|
16
|
-
* @returns Component
|
|
17
|
-
*/
|
|
18
|
-
export const RLink = React.forwardRef<HTMLAnchorElement, RLinkProps>(
|
|
19
|
-
(props, ref) => {
|
|
20
|
-
// Destruct
|
|
21
|
-
const { delay = 0, href, target, onClick, ...rest } = props;
|
|
22
|
-
|
|
23
|
-
const delayed = useDelayedExecutor((href: string) => {
|
|
24
|
-
// Router push
|
|
25
|
-
globalApp.history.push(href);
|
|
26
|
-
}, delay);
|
|
27
|
-
|
|
28
|
-
// Click handler
|
|
29
|
-
const onClickLocl = (
|
|
30
|
-
event: React.MouseEvent<HTMLAnchorElement, MouseEvent>
|
|
31
|
-
) => {
|
|
32
|
-
if (onClick) onClick(event);
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
!event.isDefaultPrevented() &&
|
|
36
|
-
href &&
|
|
37
|
-
(!target || target === '_self') && // Let browser handle "target=_blank" etc
|
|
38
|
-
globalApp
|
|
39
|
-
) {
|
|
40
|
-
// Prevent href action
|
|
41
|
-
event.preventDefault();
|
|
42
|
-
|
|
43
|
-
// Delayed excution
|
|
44
|
-
delayed.call(undefined, href);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// Clear when exit
|
|
49
|
-
React.useEffect(() => {
|
|
50
|
-
return () => delayed.clear();
|
|
51
|
-
}, [delayed]);
|
|
52
|
-
|
|
53
|
-
// Component
|
|
54
|
-
return (
|
|
55
|
-
<Link
|
|
56
|
-
{...rest}
|
|
57
|
-
onClick={onClickLocl}
|
|
58
|
-
href={href}
|
|
59
|
-
target={target}
|
|
60
|
-
ref={ref}
|
|
61
|
-
/>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
);
|