@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/lib/mu/TableEx.js
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
|
-
import { Checkbox, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TablePagination, TableRow, TableSortLabel, useTheme } from '@mui/material';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { GridAlignGet } from '../components/GridColumn';
|
|
5
|
-
import { GridSizeGet } from '../components/GridLoader';
|
|
6
|
-
import { DataGridRenderers } from './DataGridRenderers';
|
|
7
|
-
/**
|
|
8
|
-
* Extended table min width for width-unset column
|
|
9
|
-
*/
|
|
10
|
-
export const TableExMinWidth = 180;
|
|
11
|
-
/**
|
|
12
|
-
* Extended Table
|
|
13
|
-
* @param props Props
|
|
14
|
-
* @returns Component
|
|
15
|
-
*/
|
|
16
|
-
export function TableEx(props) {
|
|
17
|
-
var _a;
|
|
18
|
-
// Theme
|
|
19
|
-
const theme = useTheme();
|
|
20
|
-
// Destruct
|
|
21
|
-
const { alternatingColors = [theme.palette.action.hover, undefined], autoLoad = true, columns, defaultOrderBy, headerColors = [undefined, undefined], idField = 'id', loadBatchSize, loadData, maxHeight, mRef, onSelectChange, rowHeight = 53, otherHeight = 110, threshold, ...rest } = props;
|
|
22
|
-
const selectable = onSelectChange != null;
|
|
23
|
-
// Rows per page
|
|
24
|
-
let rowsPerPageLocal;
|
|
25
|
-
if (maxHeight != null) {
|
|
26
|
-
if (loadBatchSize != null)
|
|
27
|
-
rowsPerPageLocal = GridSizeGet(loadBatchSize, maxHeight);
|
|
28
|
-
else
|
|
29
|
-
rowsPerPageLocal = Math.floor((maxHeight - otherHeight) / rowHeight);
|
|
30
|
-
}
|
|
31
|
-
else if (typeof loadBatchSize === 'number') {
|
|
32
|
-
rowsPerPageLocal = loadBatchSize;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
rowsPerPageLocal = 10;
|
|
36
|
-
}
|
|
37
|
-
// Rows
|
|
38
|
-
const [rows, updateRows] = React.useState([]);
|
|
39
|
-
const setRows = (rows) => {
|
|
40
|
-
state.loadedItems = rows.length;
|
|
41
|
-
updateRows(rows);
|
|
42
|
-
};
|
|
43
|
-
// States
|
|
44
|
-
const stateRefs = React.useRef({
|
|
45
|
-
autoLoad,
|
|
46
|
-
currentPage: 0,
|
|
47
|
-
loadedItems: 0,
|
|
48
|
-
hasNextPage: true,
|
|
49
|
-
isNextPageLoading: false,
|
|
50
|
-
orderBy: defaultOrderBy,
|
|
51
|
-
orderByAsc: defaultOrderBy
|
|
52
|
-
? (_a = columns.find((column) => column.field === defaultOrderBy)) === null || _a === void 0 ? void 0 : _a.sortAsc
|
|
53
|
-
: undefined,
|
|
54
|
-
batchSize: rowsPerPageLocal,
|
|
55
|
-
selectedItems: []
|
|
56
|
-
});
|
|
57
|
-
const state = stateRefs.current;
|
|
58
|
-
// Reset the state and load again
|
|
59
|
-
const reset = (add) => {
|
|
60
|
-
const resetState = {
|
|
61
|
-
autoLoad: true,
|
|
62
|
-
currentPage: 0,
|
|
63
|
-
loadedItems: 0,
|
|
64
|
-
hasNextPage: true,
|
|
65
|
-
isNextPageLoading: false,
|
|
66
|
-
lastLoadedItems: undefined,
|
|
67
|
-
...add
|
|
68
|
-
};
|
|
69
|
-
Object.assign(state, resetState);
|
|
70
|
-
};
|
|
71
|
-
React.useImperativeHandle(mRef, () => ({
|
|
72
|
-
/**
|
|
73
|
-
* Refresh data
|
|
74
|
-
*/
|
|
75
|
-
refresh() {
|
|
76
|
-
loadDataLocal();
|
|
77
|
-
},
|
|
78
|
-
/**
|
|
79
|
-
* Reset
|
|
80
|
-
*/
|
|
81
|
-
reset
|
|
82
|
-
}), []);
|
|
83
|
-
// Load data
|
|
84
|
-
const loadDataLocal = () => {
|
|
85
|
-
// Prevent multiple loadings
|
|
86
|
-
if (!state.hasNextPage || state.isNextPageLoading)
|
|
87
|
-
return;
|
|
88
|
-
// Update state
|
|
89
|
-
state.isNextPageLoading = true;
|
|
90
|
-
// Parameters
|
|
91
|
-
const { currentPage, batchSize, orderBy, orderByAsc, data, isMounted } = state;
|
|
92
|
-
const loadProps = {
|
|
93
|
-
currentPage,
|
|
94
|
-
batchSize,
|
|
95
|
-
orderBy,
|
|
96
|
-
orderByAsc,
|
|
97
|
-
data
|
|
98
|
-
};
|
|
99
|
-
loadData(loadProps).then((result) => {
|
|
100
|
-
state.isMounted = true;
|
|
101
|
-
if (result == null || isMounted === false) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const newItems = result.length;
|
|
105
|
-
state.lastLoadedItems = newItems;
|
|
106
|
-
state.hasNextPage = newItems >= batchSize;
|
|
107
|
-
state.isNextPageLoading = false;
|
|
108
|
-
// Update rows
|
|
109
|
-
setRows(result);
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
const handleChangePage = (_event, newPage) => {
|
|
113
|
-
state.hasNextPage = true;
|
|
114
|
-
state.currentPage = newPage;
|
|
115
|
-
loadDataLocal();
|
|
116
|
-
};
|
|
117
|
-
const handleChangeRowsPerPage = (event) => {
|
|
118
|
-
const batchSize = parseInt(event.target.value);
|
|
119
|
-
reset({ batchSize });
|
|
120
|
-
};
|
|
121
|
-
const handleSelect = (item, checked) => {
|
|
122
|
-
const selectedItems = state.selectedItems;
|
|
123
|
-
const index = selectedItems.findIndex((selectedItem) => selectedItem[idField] === item[idField]);
|
|
124
|
-
if (checked) {
|
|
125
|
-
if (index === -1)
|
|
126
|
-
selectedItems.push(item);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
if (index !== -1)
|
|
130
|
-
selectedItems.splice(index, 1);
|
|
131
|
-
}
|
|
132
|
-
if (onSelectChange != null) {
|
|
133
|
-
onSelectChange(selectedItems);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
const handleSelectAll = (checked) => {
|
|
137
|
-
const selectedItems = state.selectedItems;
|
|
138
|
-
rows.forEach((row) => {
|
|
139
|
-
const index = selectedItems.findIndex((selectedItem) => selectedItem[idField] === row[idField]);
|
|
140
|
-
if (checked) {
|
|
141
|
-
if (index === -1)
|
|
142
|
-
selectedItems.push(row);
|
|
143
|
-
}
|
|
144
|
-
else if (index !== -1) {
|
|
145
|
-
selectedItems.splice(index, 1);
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
if (onSelectChange != null) {
|
|
149
|
-
onSelectChange(selectedItems);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
// New sort
|
|
153
|
-
const handleSort = (field, asc) => {
|
|
154
|
-
reset({ orderBy: field, orderByAsc: asc });
|
|
155
|
-
};
|
|
156
|
-
// Destruct states
|
|
157
|
-
const { autoLoad: stateAutoLoad, currentPage, hasNextPage, lastLoadedItems, orderBy, batchSize, selectedItems } = state;
|
|
158
|
-
// Current page selected items
|
|
159
|
-
const pageSelectedItems = selectable
|
|
160
|
-
? rows.reduce((previousValue, currentItem) => {
|
|
161
|
-
if (selectedItems.some((item) => item[idField] === currentItem[idField]))
|
|
162
|
-
return previousValue + 1;
|
|
163
|
-
return previousValue;
|
|
164
|
-
}, 0)
|
|
165
|
-
: 0;
|
|
166
|
-
// Total rows
|
|
167
|
-
const totalRows = hasNextPage
|
|
168
|
-
? -1
|
|
169
|
-
: currentPage * batchSize + (lastLoadedItems !== null && lastLoadedItems !== void 0 ? lastLoadedItems : 0);
|
|
170
|
-
// Auto load data when current page is 0
|
|
171
|
-
if (currentPage === 0 && stateAutoLoad && lastLoadedItems == null)
|
|
172
|
-
loadDataLocal();
|
|
173
|
-
React.useEffect(() => {
|
|
174
|
-
return () => {
|
|
175
|
-
state.isMounted = false;
|
|
176
|
-
};
|
|
177
|
-
}, []);
|
|
178
|
-
// Layout
|
|
179
|
-
return (React.createElement(Paper, null,
|
|
180
|
-
React.createElement(TableContainer, { sx: { maxHeight } },
|
|
181
|
-
React.createElement(Table, { ...rest },
|
|
182
|
-
React.createElement(TableHead, null,
|
|
183
|
-
React.createElement(TableRow, { sx: {
|
|
184
|
-
'& th': {
|
|
185
|
-
backgroundColor: headerColors[0],
|
|
186
|
-
color: headerColors[1]
|
|
187
|
-
}
|
|
188
|
-
} },
|
|
189
|
-
selectable && (React.createElement(TableCell, { padding: "checkbox" },
|
|
190
|
-
React.createElement(Checkbox, { color: "primary", indeterminate: pageSelectedItems > 0 &&
|
|
191
|
-
pageSelectedItems < rows.length, checked: pageSelectedItems > 0, onChange: (_event, checked) => handleSelectAll(checked) }))),
|
|
192
|
-
columns.map((column, index) => {
|
|
193
|
-
// Destruct
|
|
194
|
-
const { align, field, header, minWidth, sortable, sortAsc = true, type, width } = column;
|
|
195
|
-
// Header text
|
|
196
|
-
const headerText = header !== null && header !== void 0 ? header : field;
|
|
197
|
-
// Sortable
|
|
198
|
-
let sortLabel;
|
|
199
|
-
if (sortable && field != null) {
|
|
200
|
-
const active = orderBy === field;
|
|
201
|
-
sortLabel = (React.createElement(TableSortLabel, { active: active, direction: sortAsc ? 'asc' : 'desc', onClick: (_event) => {
|
|
202
|
-
if (active)
|
|
203
|
-
column.sortAsc = !sortAsc;
|
|
204
|
-
handleSort(field, column.sortAsc);
|
|
205
|
-
} }, headerText));
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
sortLabel = headerText;
|
|
209
|
-
}
|
|
210
|
-
return (React.createElement(TableCell, { align: GridAlignGet(align, type), key: field !== null && field !== void 0 ? field : index.toString(), width: width, sx: {
|
|
211
|
-
minWidth: minWidth == null
|
|
212
|
-
? width == null
|
|
213
|
-
? TableExMinWidth
|
|
214
|
-
: undefined
|
|
215
|
-
: minWidth
|
|
216
|
-
} }, sortLabel));
|
|
217
|
-
}))),
|
|
218
|
-
React.createElement(TableBody, { sx: {
|
|
219
|
-
'& tr:nth-of-type(odd):not(.Mui-selected)': {
|
|
220
|
-
backgroundColor: alternatingColors[0]
|
|
221
|
-
},
|
|
222
|
-
'& tr:nth-of-type(even):not(.Mui-selected)': {
|
|
223
|
-
backgroundColor: alternatingColors[1]
|
|
224
|
-
}
|
|
225
|
-
} }, [...Array(batchSize)].map((_item, rowIndex) => {
|
|
226
|
-
var _a;
|
|
227
|
-
// Row
|
|
228
|
-
const row = rowIndex < rows.length
|
|
229
|
-
? rows[rowIndex]
|
|
230
|
-
: undefined;
|
|
231
|
-
// Row id field value
|
|
232
|
-
const rowId = (_a = DataTypes.getValue(row, idField)) !== null && _a !== void 0 ? _a : rowIndex;
|
|
233
|
-
// Selected or not
|
|
234
|
-
const isItemSelected = selectable
|
|
235
|
-
? selectedItems.some((item) => item[idField] === rowId)
|
|
236
|
-
: false;
|
|
237
|
-
return (React.createElement(TableRow, { key: rowId, selected: isItemSelected },
|
|
238
|
-
selectable && (React.createElement(TableCell, { padding: "checkbox" }, row && (React.createElement(Checkbox, { color: "primary", checked: isItemSelected, onChange: (_event, checked) => handleSelect(row, checked) })))),
|
|
239
|
-
columns.map(({ align, cellRenderer = DataGridRenderers.defaultCellRenderer, field, type, valueFormatter }, columnIndex) => {
|
|
240
|
-
const formatProps = {
|
|
241
|
-
data: row,
|
|
242
|
-
field,
|
|
243
|
-
rowIndex,
|
|
244
|
-
columnIndex
|
|
245
|
-
};
|
|
246
|
-
const cellProps = {
|
|
247
|
-
align: GridAlignGet(align, type),
|
|
248
|
-
valign: 'middle'
|
|
249
|
-
};
|
|
250
|
-
const child = row ? (cellRenderer({
|
|
251
|
-
data: row,
|
|
252
|
-
field,
|
|
253
|
-
formattedValue: valueFormatter
|
|
254
|
-
? valueFormatter(formatProps)
|
|
255
|
-
: undefined,
|
|
256
|
-
selected: isItemSelected,
|
|
257
|
-
type,
|
|
258
|
-
rowIndex,
|
|
259
|
-
columnIndex,
|
|
260
|
-
cellProps
|
|
261
|
-
})) : (React.createElement(React.Fragment, null, "\u00A0"));
|
|
262
|
-
return (React.createElement(TableCell, { key: `${rowId}${columnIndex}`, ...cellProps }, child));
|
|
263
|
-
})));
|
|
264
|
-
})))),
|
|
265
|
-
React.createElement(TablePagination, { component: "div", showFirstButton: true, count: totalRows, rowsPerPage: batchSize, page: currentPage, onPageChange: handleChangePage, onRowsPerPageChange: handleChangeRowsPerPage, rowsPerPageOptions: [
|
|
266
|
-
batchSize,
|
|
267
|
-
2 * batchSize,
|
|
268
|
-
5 * batchSize,
|
|
269
|
-
10 * batchSize
|
|
270
|
-
] })));
|
|
271
|
-
}
|
package/lib/mu/TextFieldEx.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TextFieldProps } from '@mui/material';
|
|
3
|
-
/**
|
|
4
|
-
* Extended text field props
|
|
5
|
-
*/
|
|
6
|
-
export declare type TextFieldExProps = TextFieldProps & {
|
|
7
|
-
/**
|
|
8
|
-
* Change delay (ms) to avoid repeatly dispatch onChange
|
|
9
|
-
*/
|
|
10
|
-
changeDelay?: number;
|
|
11
|
-
/**
|
|
12
|
-
* On enter click
|
|
13
|
-
*/
|
|
14
|
-
onEnter?: React.KeyboardEventHandler<HTMLDivElement>;
|
|
15
|
-
/**
|
|
16
|
-
* Is the field read only?
|
|
17
|
-
*/
|
|
18
|
-
readOnly?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Show clear button
|
|
21
|
-
*/
|
|
22
|
-
showClear?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Show password button
|
|
25
|
-
*/
|
|
26
|
-
showPassword?: boolean;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Extended text field methods
|
|
30
|
-
*/
|
|
31
|
-
export interface TextFieldExMethods {
|
|
32
|
-
/**
|
|
33
|
-
* Set error
|
|
34
|
-
* @param error Error
|
|
35
|
-
*/
|
|
36
|
-
setError(error: React.ReactNode): void;
|
|
37
|
-
}
|
|
38
|
-
export declare const TextFieldEx: React.ForwardRefExoticComponent<(Pick<import("@mui/material").StandardTextFieldProps & {
|
|
39
|
-
/**
|
|
40
|
-
* Change delay (ms) to avoid repeatly dispatch onChange
|
|
41
|
-
*/
|
|
42
|
-
changeDelay?: number | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* On enter click
|
|
45
|
-
*/
|
|
46
|
-
onEnter?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* Is the field read only?
|
|
49
|
-
*/
|
|
50
|
-
readOnly?: boolean | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* Show clear button
|
|
53
|
-
*/
|
|
54
|
-
showClear?: boolean | undefined;
|
|
55
|
-
/**
|
|
56
|
-
* Show password button
|
|
57
|
-
*/
|
|
58
|
-
showPassword?: boolean | undefined;
|
|
59
|
-
}, "name" | "role" | "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "type" | "fullWidth" | "className" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "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" | "disabled" | "sx" | "margin" | "size" | "variant" | "key" | "autoFocus" | "autoComplete" | "readOnly" | "required" | "rows" | "error" | "inputProps" | "onEnter" | "inputRef" | "focused" | "hiddenLabel" | "multiline" | "maxRows" | "minRows" | "SelectProps" | "changeDelay" | "InputLabelProps" | "InputProps" | "FormHelperTextProps" | "helperText" | "showClear" | "showPassword"> | Pick<import("@mui/material").FilledTextFieldProps & {
|
|
60
|
-
/**
|
|
61
|
-
* Change delay (ms) to avoid repeatly dispatch onChange
|
|
62
|
-
*/
|
|
63
|
-
changeDelay?: number | undefined;
|
|
64
|
-
/**
|
|
65
|
-
* On enter click
|
|
66
|
-
*/
|
|
67
|
-
onEnter?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
|
|
68
|
-
/**
|
|
69
|
-
* Is the field read only?
|
|
70
|
-
*/
|
|
71
|
-
readOnly?: boolean | undefined;
|
|
72
|
-
/**
|
|
73
|
-
* Show clear button
|
|
74
|
-
*/
|
|
75
|
-
showClear?: boolean | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* Show password button
|
|
78
|
-
*/
|
|
79
|
-
showPassword?: boolean | undefined;
|
|
80
|
-
}, "name" | "role" | "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "type" | "fullWidth" | "className" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "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" | "disabled" | "sx" | "margin" | "size" | "variant" | "key" | "autoFocus" | "autoComplete" | "readOnly" | "required" | "rows" | "error" | "inputProps" | "onEnter" | "inputRef" | "focused" | "hiddenLabel" | "multiline" | "maxRows" | "minRows" | "SelectProps" | "changeDelay" | "InputLabelProps" | "InputProps" | "FormHelperTextProps" | "helperText" | "showClear" | "showPassword"> | Pick<import("@mui/material").OutlinedTextFieldProps & {
|
|
81
|
-
/**
|
|
82
|
-
* Change delay (ms) to avoid repeatly dispatch onChange
|
|
83
|
-
*/
|
|
84
|
-
changeDelay?: number | undefined;
|
|
85
|
-
/**
|
|
86
|
-
* On enter click
|
|
87
|
-
*/
|
|
88
|
-
onEnter?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
|
|
89
|
-
/**
|
|
90
|
-
* Is the field read only?
|
|
91
|
-
*/
|
|
92
|
-
readOnly?: boolean | undefined;
|
|
93
|
-
/**
|
|
94
|
-
* Show clear button
|
|
95
|
-
*/
|
|
96
|
-
showClear?: boolean | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Show password button
|
|
99
|
-
*/
|
|
100
|
-
showPassword?: boolean | undefined;
|
|
101
|
-
}, "name" | "role" | "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "type" | "fullWidth" | "className" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "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" | "disabled" | "sx" | "margin" | "size" | "variant" | "key" | "autoFocus" | "autoComplete" | "readOnly" | "required" | "rows" | "error" | "inputProps" | "onEnter" | "inputRef" | "focused" | "hiddenLabel" | "multiline" | "maxRows" | "minRows" | "SelectProps" | "changeDelay" | "InputLabelProps" | "InputProps" | "FormHelperTextProps" | "helperText" | "showClear" | "showPassword">) & React.RefAttributes<TextFieldExMethods>>;
|
package/lib/mu/TextFieldEx.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { IconButton, InputAdornment, TextField } from '@mui/material';
|
|
3
|
-
import { MUGlobal } from './MUGlobal';
|
|
4
|
-
import { Clear, Visibility } from '@mui/icons-material';
|
|
5
|
-
import useCombinedRefs from '../uses/useCombinedRefs';
|
|
6
|
-
import { Keyboard } from '@etsoo/shared';
|
|
7
|
-
import { useDelayedExecutor } from '../uses/useDelayedExecutor';
|
|
8
|
-
export const TextFieldEx = React.forwardRef((props, ref) => {
|
|
9
|
-
// Destructure
|
|
10
|
-
const { changeDelay, error, fullWidth = true, helperText, InputProps = {}, onChange, onKeyPress, onEnter, inputRef, readOnly, showClear, showPassword, type, variant = MUGlobal.textFieldVariant, ...rest } = props;
|
|
11
|
-
// State
|
|
12
|
-
const [errorText, updateErrorText] = React.useState();
|
|
13
|
-
const [empty, updateEmpty] = React.useState(true);
|
|
14
|
-
// Read only
|
|
15
|
-
if (readOnly != null)
|
|
16
|
-
InputProps.readOnly = readOnly;
|
|
17
|
-
// Calculate
|
|
18
|
-
let errorEx = error;
|
|
19
|
-
let helperTextEx = helperText;
|
|
20
|
-
if (errorText != null) {
|
|
21
|
-
errorEx = true;
|
|
22
|
-
helperTextEx = errorText;
|
|
23
|
-
}
|
|
24
|
-
let typeEx = showPassword ? 'password' : type;
|
|
25
|
-
let input;
|
|
26
|
-
const localRef = (ref) => {
|
|
27
|
-
input = ref;
|
|
28
|
-
if (input.value !== '') {
|
|
29
|
-
updateEmpty(false);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const clearClick = () => {
|
|
33
|
-
if (input != null) {
|
|
34
|
-
input.value = '';
|
|
35
|
-
input.focus();
|
|
36
|
-
}
|
|
37
|
-
if (errorText != null) {
|
|
38
|
-
// Reset
|
|
39
|
-
updateErrorText(undefined);
|
|
40
|
-
}
|
|
41
|
-
updateEmpty(true);
|
|
42
|
-
};
|
|
43
|
-
const preventDefault = (e) => {
|
|
44
|
-
// Prevent long press
|
|
45
|
-
if (e.isPropagationStopped())
|
|
46
|
-
e.stopPropagation();
|
|
47
|
-
if (e.isDefaultPrevented())
|
|
48
|
-
e.preventDefault();
|
|
49
|
-
};
|
|
50
|
-
const touchStart = (e) => {
|
|
51
|
-
// Show the password
|
|
52
|
-
if (input) {
|
|
53
|
-
input.blur();
|
|
54
|
-
input.type = 'text';
|
|
55
|
-
}
|
|
56
|
-
preventDefault(e);
|
|
57
|
-
};
|
|
58
|
-
const touchEnd = (e) => {
|
|
59
|
-
// Show the password
|
|
60
|
-
if (input)
|
|
61
|
-
input.type = 'password';
|
|
62
|
-
preventDefault(e);
|
|
63
|
-
};
|
|
64
|
-
// Show password and/or clear button
|
|
65
|
-
if (!empty && (showPassword || showClear)) {
|
|
66
|
-
InputProps.endAdornment = (React.createElement(InputAdornment, { position: "end" },
|
|
67
|
-
showPassword && (React.createElement(IconButton, { tabIndex: -1, onContextMenu: (event) => event.preventDefault(), onMouseDown: touchStart, onMouseUp: touchEnd, onTouchStart: touchStart, onTouchCancel: touchEnd, onTouchEnd: touchEnd },
|
|
68
|
-
React.createElement(Visibility, null))),
|
|
69
|
-
showClear && (React.createElement(IconButton, { onClick: clearClick, tabIndex: -1 },
|
|
70
|
-
React.createElement(Clear, null)))));
|
|
71
|
-
}
|
|
72
|
-
// Extend key precess
|
|
73
|
-
const onKeyPressEx = onEnter == null
|
|
74
|
-
? onKeyPress
|
|
75
|
-
: (e) => {
|
|
76
|
-
if (e.key === Keyboard.Keys.Enter) {
|
|
77
|
-
// Enter press callback
|
|
78
|
-
onEnter(e);
|
|
79
|
-
}
|
|
80
|
-
if (!e.isDefaultPrevented && onKeyPress != null) {
|
|
81
|
-
// Common press callback
|
|
82
|
-
onKeyPress(e);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
React.useImperativeHandle(ref, () => ({
|
|
86
|
-
/**
|
|
87
|
-
* Set error
|
|
88
|
-
* @param error Error
|
|
89
|
-
*/
|
|
90
|
-
setError(error) {
|
|
91
|
-
updateErrorText(error);
|
|
92
|
-
}
|
|
93
|
-
}), []);
|
|
94
|
-
const isMounted = React.useRef(true);
|
|
95
|
-
const delayed = onChange != null && changeDelay != null && changeDelay >= 1
|
|
96
|
-
? useDelayedExecutor(onChange, changeDelay)
|
|
97
|
-
: undefined;
|
|
98
|
-
const onChangeEx = (event) => {
|
|
99
|
-
if (errorText != null) {
|
|
100
|
-
// Reset
|
|
101
|
-
updateErrorText(undefined);
|
|
102
|
-
}
|
|
103
|
-
if (showClear || showPassword) {
|
|
104
|
-
if (event.target.value === '') {
|
|
105
|
-
updateEmpty(true);
|
|
106
|
-
}
|
|
107
|
-
else if (empty) {
|
|
108
|
-
updateEmpty(false);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (onChange == null)
|
|
112
|
-
return;
|
|
113
|
-
if (changeDelay == null || changeDelay < 1) {
|
|
114
|
-
onChange(event);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
delayed === null || delayed === void 0 ? void 0 : delayed.call(undefined, event);
|
|
118
|
-
};
|
|
119
|
-
React.useEffect(() => {
|
|
120
|
-
return () => {
|
|
121
|
-
isMounted.current = false;
|
|
122
|
-
delayed === null || delayed === void 0 ? void 0 : delayed.clear();
|
|
123
|
-
};
|
|
124
|
-
}, []);
|
|
125
|
-
// Textfield
|
|
126
|
-
return (React.createElement(TextField, { error: errorEx, fullWidth: fullWidth, helperText: helperTextEx, inputRef: useCombinedRefs(inputRef, localRef), InputProps: InputProps, onChange: onChangeEx, onKeyPress: onKeyPressEx, type: typeEx, variant: variant, ...rest }));
|
|
127
|
-
});
|
package/lib/mu/Tiplist.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { DataTypes, IdDefaultType, ListType } from '@etsoo/shared';
|
|
3
|
-
import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
|
|
4
|
-
/**
|
|
5
|
-
* Tiplist props
|
|
6
|
-
*/
|
|
7
|
-
export declare type TiplistProps<T extends object, D extends DataTypes.Keys<T>> = Omit<AutocompleteExtendedProps<T, D>, 'open'> & {
|
|
8
|
-
/**
|
|
9
|
-
* Load data callback
|
|
10
|
-
*/
|
|
11
|
-
loadData: (keyword?: string, id?: T[D]) => PromiseLike<T[] | null | undefined>;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Tiplist
|
|
15
|
-
* @param props Props
|
|
16
|
-
* @returns Component
|
|
17
|
-
*/
|
|
18
|
-
export declare function Tiplist<T extends object = ListType, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: TiplistProps<T, D>): JSX.Element;
|