@etsoo/react 1.5.80 → 1.5.83
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/states/UserState.d.ts +1 -1
- 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 +4 -16
- 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/states/UserState.ts +7 -2
- 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
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CircularProgress } from '@mui/material';
|
|
3
|
-
import { GridCellRendererProps, GridDataType } from '../components/GridColumn';
|
|
4
|
-
import { DateUtils, NumberUtils } from '@etsoo/shared';
|
|
5
|
-
import CheckIcon from '@mui/icons-material/Check';
|
|
6
|
-
import ClearIcon from '@mui/icons-material/Clear';
|
|
7
|
-
import { DataGridExFooterItemRendererProps } from './DataGridEx';
|
|
8
|
-
import { DateText } from './texts/DateText';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Data grid renderers
|
|
12
|
-
*/
|
|
13
|
-
export namespace DataGridRenderers {
|
|
14
|
-
/**
|
|
15
|
-
* Default cell renderer
|
|
16
|
-
* @param param Props
|
|
17
|
-
* @returns Component
|
|
18
|
-
*/
|
|
19
|
-
export function defaultCellRenderer<T extends Record<string, any>>({
|
|
20
|
-
cellProps,
|
|
21
|
-
data,
|
|
22
|
-
field,
|
|
23
|
-
formattedValue,
|
|
24
|
-
columnIndex,
|
|
25
|
-
type,
|
|
26
|
-
renderProps
|
|
27
|
-
}: GridCellRendererProps<T>): React.ReactNode {
|
|
28
|
-
// Is loading
|
|
29
|
-
if (data == null) {
|
|
30
|
-
// First column, show loading indicator
|
|
31
|
-
if (columnIndex === 0) return <CircularProgress size={15} />;
|
|
32
|
-
|
|
33
|
-
// Others return undefined
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// No formatted value and data field
|
|
38
|
-
if (formattedValue == null && field == null) return undefined;
|
|
39
|
-
|
|
40
|
-
// Cell value
|
|
41
|
-
const value = formattedValue ?? data[field!];
|
|
42
|
-
if (value == null) return undefined;
|
|
43
|
-
|
|
44
|
-
// For date time
|
|
45
|
-
// Conversion if necessary
|
|
46
|
-
if (type === GridDataType.Date || type === GridDataType.DateTime) {
|
|
47
|
-
const dateValue = value instanceof Date ? value : new Date(value);
|
|
48
|
-
|
|
49
|
-
const option = type === GridDataType.DateTime ? 'ds' : 'd';
|
|
50
|
-
|
|
51
|
-
const nearDays = renderProps?.nearDays;
|
|
52
|
-
if (nearDays != null) {
|
|
53
|
-
return (
|
|
54
|
-
<DateText
|
|
55
|
-
value={dateValue}
|
|
56
|
-
locale={renderProps?.culture}
|
|
57
|
-
timeZone={renderProps?.timeZone}
|
|
58
|
-
options={option}
|
|
59
|
-
nearDays={nearDays}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return DateUtils.format(
|
|
65
|
-
dateValue,
|
|
66
|
-
renderProps?.culture,
|
|
67
|
-
option,
|
|
68
|
-
renderProps?.timeZone
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// For numbers
|
|
73
|
-
if (typeof value === 'number') {
|
|
74
|
-
if (type === GridDataType.Money || type === GridDataType.IntMoney)
|
|
75
|
-
return NumberUtils.formatMoney(
|
|
76
|
-
value,
|
|
77
|
-
renderProps?.currency,
|
|
78
|
-
renderProps?.culture,
|
|
79
|
-
type === GridDataType.IntMoney,
|
|
80
|
-
renderProps?.numberFormatOptions
|
|
81
|
-
);
|
|
82
|
-
else
|
|
83
|
-
return NumberUtils.format(
|
|
84
|
-
value,
|
|
85
|
-
renderProps?.culture,
|
|
86
|
-
renderProps?.numberFormatOptions
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// For boolean
|
|
91
|
-
if (typeof value === 'boolean') {
|
|
92
|
-
// Add style
|
|
93
|
-
if ('align' in cellProps) {
|
|
94
|
-
cellProps.sx = {
|
|
95
|
-
paddingTop: '12px!important',
|
|
96
|
-
paddingBottom: '6px!important'
|
|
97
|
-
};
|
|
98
|
-
} else {
|
|
99
|
-
cellProps.sx = {
|
|
100
|
-
paddingTop: '16px!important',
|
|
101
|
-
paddingBottom: '8px!important'
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (value) return <CheckIcon fontSize="small" />;
|
|
106
|
-
else return <ClearIcon fontSize="small" color="warning" />;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// To string
|
|
110
|
-
return new String(value);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Default footer item renderer
|
|
115
|
-
* @param rows Rows
|
|
116
|
-
* @param props Renderer props
|
|
117
|
-
* @param location Renderer location (column index)
|
|
118
|
-
* @returns Component
|
|
119
|
-
*/
|
|
120
|
-
export function defaultFooterItemRenderer<T extends object>(
|
|
121
|
-
_rows: T[],
|
|
122
|
-
{ index, states, checkable }: DataGridExFooterItemRendererProps<T>,
|
|
123
|
-
location: number = 0
|
|
124
|
-
) {
|
|
125
|
-
const { selectedItems, loadedItems, hasNextPage } = states;
|
|
126
|
-
|
|
127
|
-
if (index === location) {
|
|
128
|
-
if (checkable) {
|
|
129
|
-
return [
|
|
130
|
-
selectedItems.length,
|
|
131
|
-
loadedItems.toLocaleString() + (hasNextPage ? '+' : '')
|
|
132
|
-
].join(' / ');
|
|
133
|
-
} else {
|
|
134
|
-
return loadedItems.toLocaleString() + (hasNextPage ? '+' : '');
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return undefined;
|
|
139
|
-
}
|
|
140
|
-
}
|
package/src/mu/DialogButton.tsx
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Breakpoint,
|
|
3
|
-
Button,
|
|
4
|
-
ButtonProps,
|
|
5
|
-
Dialog,
|
|
6
|
-
DialogActions,
|
|
7
|
-
DialogContent,
|
|
8
|
-
DialogContentText,
|
|
9
|
-
DialogTitle,
|
|
10
|
-
IconButton
|
|
11
|
-
} from '@mui/material';
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import { Labels } from '../app/Labels';
|
|
14
|
-
|
|
15
|
-
export interface DialogButtonProps extends ButtonProps {
|
|
16
|
-
/**
|
|
17
|
-
* Button label
|
|
18
|
-
*/
|
|
19
|
-
buttonLabel?: string;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Dialog content
|
|
23
|
-
*/
|
|
24
|
-
content: string;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Show content in pre component
|
|
28
|
-
*/
|
|
29
|
-
contentPre?: boolean;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Default is label
|
|
33
|
-
*/
|
|
34
|
-
dialogTitle?: string;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Disable the scroll lock behavior.
|
|
38
|
-
* @default false
|
|
39
|
-
*/
|
|
40
|
-
disableScrollLock?: boolean;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Show fullscreen dialog
|
|
44
|
-
*/
|
|
45
|
-
fullScreen?: boolean;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* If `true`, the dialog stretches to `maxWidth`.
|
|
49
|
-
*
|
|
50
|
-
* Notice that the dialog width grow is limited by the default margin.
|
|
51
|
-
* @default false
|
|
52
|
-
*/
|
|
53
|
-
fullWidth?: boolean;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Other layouts
|
|
57
|
-
*/
|
|
58
|
-
inputs?: React.ReactNode;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Max width of the dialog
|
|
62
|
-
*/
|
|
63
|
-
maxWidth?: Breakpoint | false;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Icon button
|
|
67
|
-
*/
|
|
68
|
-
icon?: React.ReactNode;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Dialog button
|
|
73
|
-
* @param props Props
|
|
74
|
-
* @returns Component
|
|
75
|
-
*/
|
|
76
|
-
export function DialogButton(props: DialogButtonProps) {
|
|
77
|
-
// Labels shared with NotificationMU
|
|
78
|
-
const labels = Labels.NotificationMU;
|
|
79
|
-
|
|
80
|
-
// Destruct
|
|
81
|
-
const {
|
|
82
|
-
buttonLabel = labels.alertOK,
|
|
83
|
-
children,
|
|
84
|
-
content,
|
|
85
|
-
contentPre,
|
|
86
|
-
dialogTitle,
|
|
87
|
-
disableScrollLock,
|
|
88
|
-
fullScreen,
|
|
89
|
-
fullWidth,
|
|
90
|
-
icon,
|
|
91
|
-
inputs,
|
|
92
|
-
maxWidth,
|
|
93
|
-
onClick,
|
|
94
|
-
title,
|
|
95
|
-
...rest
|
|
96
|
-
} = props;
|
|
97
|
-
|
|
98
|
-
// Open state
|
|
99
|
-
const [open, setOpen] = React.useState(false);
|
|
100
|
-
|
|
101
|
-
const handleClickOpen = () => {
|
|
102
|
-
setOpen(true);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// Onclick handler
|
|
106
|
-
const onClickLocal = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
107
|
-
// Stop propagation
|
|
108
|
-
event.stopPropagation();
|
|
109
|
-
event.preventDefault();
|
|
110
|
-
|
|
111
|
-
// Show dialog
|
|
112
|
-
handleClickOpen();
|
|
113
|
-
|
|
114
|
-
// Additional callback
|
|
115
|
-
if (onClick) onClick(event);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// Layout
|
|
119
|
-
return (
|
|
120
|
-
<React.Fragment>
|
|
121
|
-
{icon == null ? (
|
|
122
|
-
<Button {...rest} title={title} onClick={onClickLocal}>
|
|
123
|
-
{children}
|
|
124
|
-
</Button>
|
|
125
|
-
) : (
|
|
126
|
-
<IconButton
|
|
127
|
-
{...rest}
|
|
128
|
-
onClick={onClickLocal}
|
|
129
|
-
title={title ?? children?.toString()}
|
|
130
|
-
>
|
|
131
|
-
{icon}
|
|
132
|
-
</IconButton>
|
|
133
|
-
)}
|
|
134
|
-
|
|
135
|
-
<Dialog
|
|
136
|
-
disableScrollLock={disableScrollLock}
|
|
137
|
-
fullScreen={fullScreen}
|
|
138
|
-
fullWidth={fullWidth}
|
|
139
|
-
maxWidth={maxWidth}
|
|
140
|
-
open={open}
|
|
141
|
-
onClose={() => setOpen(false)}
|
|
142
|
-
onClick={(event) => {
|
|
143
|
-
// The dialog will be embeded and the click event will bubble up
|
|
144
|
-
// Stop propatation but will also cancel onClose and onBackdropClick event
|
|
145
|
-
event.stopPropagation();
|
|
146
|
-
}}
|
|
147
|
-
>
|
|
148
|
-
<DialogTitle>{dialogTitle ?? title ?? children}</DialogTitle>
|
|
149
|
-
<DialogContent>
|
|
150
|
-
<DialogContentText component={contentPre ? 'pre' : 'span'}>
|
|
151
|
-
{content}
|
|
152
|
-
</DialogContentText>
|
|
153
|
-
{inputs}
|
|
154
|
-
</DialogContent>
|
|
155
|
-
<DialogActions>
|
|
156
|
-
<Button onClick={() => setOpen(false)}>
|
|
157
|
-
{buttonLabel}
|
|
158
|
-
</Button>
|
|
159
|
-
</DialogActions>
|
|
160
|
-
</Dialog>
|
|
161
|
-
</React.Fragment>
|
|
162
|
-
);
|
|
163
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Paper, PaperProps } from '@mui/material';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import Draggable from 'react-draggable';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Draggable paper component
|
|
7
|
-
* @param props Props
|
|
8
|
-
* @returns Component
|
|
9
|
-
*/
|
|
10
|
-
export function DraggablePaperComponent(props: PaperProps) {
|
|
11
|
-
return (
|
|
12
|
-
<Draggable
|
|
13
|
-
handle=".draggable-dialog-title"
|
|
14
|
-
cancel={'[class*="MuiDialogContent-root"]'}
|
|
15
|
-
>
|
|
16
|
-
<Paper {...props} />
|
|
17
|
-
</Draggable>
|
|
18
|
-
);
|
|
19
|
-
}
|
package/src/mu/EmailInput.tsx
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { TextField, TextFieldProps } from '@mui/material';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Email input props
|
|
6
|
-
*/
|
|
7
|
-
export type EmailInputProps = Omit<TextFieldProps, 'type'> & {};
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Email input
|
|
11
|
-
* @param props Props
|
|
12
|
-
*/
|
|
13
|
-
export function EmailInput(props: EmailInputProps) {
|
|
14
|
-
// Destruct
|
|
15
|
-
const { inputProps = {}, ...rest } = props;
|
|
16
|
-
|
|
17
|
-
// Default max length
|
|
18
|
-
inputProps.maxLength ??= 128;
|
|
19
|
-
|
|
20
|
-
// Layout
|
|
21
|
-
return (
|
|
22
|
-
<TextField type="email" fullWidth inputProps={inputProps} {...rest} />
|
|
23
|
-
);
|
|
24
|
-
}
|
package/src/mu/FabBox.tsx
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Box, BoxProps, useTheme } from '@mui/material';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Fabs container box props
|
|
6
|
-
*/
|
|
7
|
-
export type FabBoxProps = BoxProps & {
|
|
8
|
-
/**
|
|
9
|
-
* Item gap
|
|
10
|
-
*/
|
|
11
|
-
itemGap?: number;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Flex direction, row or column
|
|
15
|
-
*/
|
|
16
|
-
columnDirection?: boolean;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Fabs container box
|
|
21
|
-
* @param props Props
|
|
22
|
-
* @returns Component
|
|
23
|
-
*/
|
|
24
|
-
export function FabBox(props: FabBoxProps) {
|
|
25
|
-
// Destruct
|
|
26
|
-
const { columnDirection, itemGap = 1, sx = {}, ...rest } = props;
|
|
27
|
-
|
|
28
|
-
// Theme
|
|
29
|
-
const theme = useTheme();
|
|
30
|
-
const spaceGap = theme.spacing(itemGap);
|
|
31
|
-
|
|
32
|
-
if (columnDirection == null) return <React.Fragment />;
|
|
33
|
-
|
|
34
|
-
// margin
|
|
35
|
-
const margin = columnDirection
|
|
36
|
-
? { marginTop: spaceGap }
|
|
37
|
-
: { marginLeft: spaceGap };
|
|
38
|
-
|
|
39
|
-
// Default style
|
|
40
|
-
if (typeof sx === 'object') {
|
|
41
|
-
Object.assign(sx as any, {
|
|
42
|
-
position: 'fixed',
|
|
43
|
-
display: 'flex',
|
|
44
|
-
alignItems: 'center',
|
|
45
|
-
flexDirection: columnDirection ? 'column' : 'row',
|
|
46
|
-
'& > :not(style) + :not(style)': margin
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return <Box sx={sx} {...rest} />;
|
|
51
|
-
}
|
package/src/mu/FlexBox.tsx
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Stack, StackProps } from '@mui/material';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Horizonal box
|
|
6
|
-
* @param props Props
|
|
7
|
-
* @returns Component
|
|
8
|
-
*/
|
|
9
|
-
export function HBox(props: Omit<StackProps, 'ref'>) {
|
|
10
|
-
return <Stack direction="row" width="100%" {...props} />;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Vertial box
|
|
15
|
-
* @param props Props
|
|
16
|
-
* @returns Component
|
|
17
|
-
*/
|
|
18
|
-
export function VBox(props: Omit<StackProps, 'ref'>) {
|
|
19
|
-
return <Stack direction="column" {...props} />;
|
|
20
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { DateUtils, NumberUtils } from '@etsoo/shared';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { DateText } from './texts/DateText';
|
|
4
|
-
import { GridColumnRenderProps, GridDataType } from '../components/GridColumn';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Grid data format
|
|
8
|
-
* @param data Input data
|
|
9
|
-
* @param type Data type
|
|
10
|
-
* @param renderProps Render props
|
|
11
|
-
* @returns Result
|
|
12
|
-
*/
|
|
13
|
-
export function GridDataFormat(
|
|
14
|
-
data: unknown,
|
|
15
|
-
type: GridDataType,
|
|
16
|
-
renderProps?: GridColumnRenderProps
|
|
17
|
-
): React.ReactNode {
|
|
18
|
-
// Null
|
|
19
|
-
if (data == null) return undefined;
|
|
20
|
-
|
|
21
|
-
// For date time
|
|
22
|
-
// Conversion if necessary
|
|
23
|
-
if (type === GridDataType.Date || type === GridDataType.DateTime) {
|
|
24
|
-
const dateValue =
|
|
25
|
-
data instanceof Date
|
|
26
|
-
? data
|
|
27
|
-
: typeof data === 'number' || typeof data === 'string'
|
|
28
|
-
? new Date(data)
|
|
29
|
-
: undefined;
|
|
30
|
-
|
|
31
|
-
if (dateValue == null) return undefined;
|
|
32
|
-
|
|
33
|
-
const option = type === GridDataType.DateTime ? 'ds' : 'd';
|
|
34
|
-
|
|
35
|
-
const nearDays = renderProps?.nearDays;
|
|
36
|
-
if (nearDays != null) {
|
|
37
|
-
return (
|
|
38
|
-
<DateText
|
|
39
|
-
value={dateValue}
|
|
40
|
-
locale={renderProps?.culture}
|
|
41
|
-
timeZone={renderProps?.timeZone}
|
|
42
|
-
options={option}
|
|
43
|
-
nearDays={nearDays}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return DateUtils.format(
|
|
49
|
-
dateValue,
|
|
50
|
-
renderProps?.culture,
|
|
51
|
-
option,
|
|
52
|
-
renderProps?.timeZone
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// For numbers
|
|
57
|
-
if (typeof data === 'number') {
|
|
58
|
-
if (type === GridDataType.Money || type === GridDataType.IntMoney)
|
|
59
|
-
return NumberUtils.formatMoney(
|
|
60
|
-
data,
|
|
61
|
-
renderProps?.currency,
|
|
62
|
-
renderProps?.culture,
|
|
63
|
-
type === GridDataType.IntMoney,
|
|
64
|
-
renderProps?.numberFormatOptions
|
|
65
|
-
);
|
|
66
|
-
else
|
|
67
|
-
return NumberUtils.format(
|
|
68
|
-
data,
|
|
69
|
-
renderProps?.culture,
|
|
70
|
-
renderProps?.numberFormatOptions
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (typeof data === 'string') return data;
|
|
75
|
-
|
|
76
|
-
return `${data}`;
|
|
77
|
-
}
|
package/src/mu/GridMethodRef.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { IconButton, IconButtonProps } from '@mui/material';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { useNavigate } from 'react-router-dom';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* IconButtonLink props
|
|
7
|
-
*/
|
|
8
|
-
export type IconButtonLinkProps = Omit<IconButtonProps, 'href' | 'onClick'> & {
|
|
9
|
-
/**
|
|
10
|
-
* To href
|
|
11
|
-
*/
|
|
12
|
-
href: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* IconButtonLink
|
|
17
|
-
* @param props Props
|
|
18
|
-
* @returns Component
|
|
19
|
-
*/
|
|
20
|
-
export function IconButtonLink(props: IconButtonLinkProps) {
|
|
21
|
-
// Destruct
|
|
22
|
-
const { href, ...rest } = props;
|
|
23
|
-
|
|
24
|
-
// Navigate
|
|
25
|
-
const navigate = useNavigate();
|
|
26
|
-
|
|
27
|
-
// Layout
|
|
28
|
-
return <IconButton {...rest} onClick={() => navigate(href)} />;
|
|
29
|
-
}
|
package/src/mu/InputField.tsx
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { TextField, TextFieldProps } from '@mui/material';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { useDelayedExecutor } from '../uses/useDelayedExecutor';
|
|
4
|
-
import { MUGlobal } from './MUGlobal';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Input field props
|
|
8
|
-
*/
|
|
9
|
-
export type InputFieldProps = TextFieldProps & {
|
|
10
|
-
/**
|
|
11
|
-
* Change delay (ms) to avoid repeatly dispatch onChange
|
|
12
|
-
*/
|
|
13
|
-
changeDelay?: number;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Is the field read only?
|
|
17
|
-
*/
|
|
18
|
-
readOnly?: boolean;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Input field
|
|
23
|
-
* @param props Props
|
|
24
|
-
* @returns Component
|
|
25
|
-
*/
|
|
26
|
-
export function InputField(props: InputFieldProps) {
|
|
27
|
-
// Destruct
|
|
28
|
-
const {
|
|
29
|
-
changeDelay,
|
|
30
|
-
InputLabelProps = {},
|
|
31
|
-
InputProps = {},
|
|
32
|
-
onChange,
|
|
33
|
-
readOnly,
|
|
34
|
-
size = MUGlobal.inputFieldSize,
|
|
35
|
-
variant = MUGlobal.inputFieldVariant,
|
|
36
|
-
...rest
|
|
37
|
-
} = props;
|
|
38
|
-
|
|
39
|
-
// Shrink
|
|
40
|
-
InputLabelProps.shrink = MUGlobal.searchFieldShrink;
|
|
41
|
-
|
|
42
|
-
// Read only
|
|
43
|
-
if (readOnly != null) InputProps.readOnly = readOnly;
|
|
44
|
-
|
|
45
|
-
const isMounted = React.useRef(true);
|
|
46
|
-
const delayed =
|
|
47
|
-
onChange != null && changeDelay != null && changeDelay >= 1
|
|
48
|
-
? useDelayedExecutor(onChange, changeDelay)
|
|
49
|
-
: undefined;
|
|
50
|
-
|
|
51
|
-
const onChangeEx = (
|
|
52
|
-
event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
|
|
53
|
-
) => {
|
|
54
|
-
if (onChange == null) return;
|
|
55
|
-
|
|
56
|
-
if (changeDelay == null || changeDelay < 1) {
|
|
57
|
-
onChange(event);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
delayed?.call(undefined, event);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
React.useEffect(() => {
|
|
65
|
-
return () => {
|
|
66
|
-
isMounted.current = false;
|
|
67
|
-
delayed?.clear();
|
|
68
|
-
};
|
|
69
|
-
}, []);
|
|
70
|
-
|
|
71
|
-
// Layout
|
|
72
|
-
return (
|
|
73
|
-
<TextField
|
|
74
|
-
InputLabelProps={InputLabelProps}
|
|
75
|
-
InputProps={InputProps}
|
|
76
|
-
onChange={onChangeEx}
|
|
77
|
-
size={size}
|
|
78
|
-
variant={variant}
|
|
79
|
-
{...rest}
|
|
80
|
-
/>
|
|
81
|
-
);
|
|
82
|
-
}
|