@etsoo/materialui 1.4.22 → 1.4.23
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 +2 -1
- package/babel.config.json +12 -12
- package/lib/AddresSelector.d.ts +8 -2
- package/lib/AddresSelector.js +1 -1
- package/lib/AuditDisplay.d.ts +1 -1
- package/lib/BackButton.d.ts +1 -1
- package/lib/BackButton.js +5 -5
- package/lib/CountryList.d.ts +5 -4
- package/lib/CountryList.js +3 -3
- package/lib/CustomFabProps.d.ts +3 -3
- package/lib/DataGridEx.js +3 -6
- package/lib/DataGridRenderers.d.ts +3 -3
- package/lib/DataGridRenderers.js +17 -17
- package/lib/DataTable.d.ts +1 -7
- package/lib/DataTable.js +3 -13
- package/lib/DialogButton.d.ts +2 -2
- package/lib/DialogButton.js +4 -4
- package/lib/EmailInput.d.ts +2 -2
- package/lib/EmailInput.js +2 -2
- package/lib/FlexBox.d.ts +3 -3
- package/lib/FlexBox.js +1 -1
- package/lib/GridDataFormat.d.ts +2 -2
- package/lib/GridDataFormat.js +7 -7
- package/lib/GridUtils.js +2 -1
- package/lib/ListItemRightIcon.d.ts +1 -1
- package/lib/ListItemRightIcon.js +2 -2
- package/lib/LoadingButton.d.ts +1 -1
- package/lib/LoadingButton.js +2 -2
- package/lib/MUGlobal.d.ts +6 -6
- package/lib/MUGlobal.js +20 -22
- package/lib/MobileListItemRenderer.d.ts +3 -3
- package/lib/MobileListItemRenderer.js +8 -10
- package/lib/PList.js +1 -1
- package/lib/ProgressCount.js +12 -12
- package/lib/RegionsRQ.d.ts +22 -0
- package/lib/RegionsRQ.js +1 -0
- package/lib/SearchField.d.ts +1 -1
- package/lib/SearchField.js +4 -4
- package/lib/SearchOptionGroup.d.ts +2 -2
- package/lib/SearchOptionGroup.js +3 -3
- package/lib/Switch.d.ts +3 -3
- package/lib/Switch.js +5 -5
- package/lib/TabBox.d.ts +5 -5
- package/lib/TabBox.js +5 -5
- package/lib/TableEx.js +4 -7
- package/lib/TooltipClick.d.ts +3 -3
- package/lib/TooltipClick.js +3 -3
- package/lib/TwoFieldInput.d.ts +2 -2
- package/lib/TwoFieldInput.js +13 -13
- package/lib/app/IServicePage.d.ts +1 -1
- package/lib/app/Labels.d.ts +1 -1
- package/lib/app/Labels.js +31 -31
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/texts/MoneyText.d.ts +1 -1
- package/lib/texts/MoneyText.js +3 -3
- package/lib/texts/NumberText.d.ts +1 -1
- package/lib/texts/NumberText.js +3 -3
- package/package.json +20 -20
- package/src/AddresSelector.tsx +31 -4
- package/src/AuditDisplay.tsx +1 -1
- package/src/BackButton.tsx +39 -39
- package/src/CountryList.tsx +49 -48
- package/src/CustomFabProps.ts +19 -19
- package/src/DataGridEx.tsx +2 -7
- package/src/DataGridRenderers.tsx +119 -119
- package/src/DataTable.tsx +2 -31
- package/src/DialogButton.tsx +149 -151
- package/src/EmailInput.tsx +9 -11
- package/src/FlexBox.tsx +6 -6
- package/src/GridDataFormat.tsx +58 -58
- package/src/GridUtils.ts +2 -1
- package/src/ListItemRightIcon.tsx +3 -3
- package/src/LoadingButton.tsx +53 -53
- package/src/MUGlobal.ts +196 -203
- package/src/MobileListItemRenderer.tsx +63 -65
- package/src/NotifierPromptProps.ts +16 -16
- package/src/PList.tsx +14 -14
- package/src/ProgressCount.tsx +144 -148
- package/src/RegionsRQ.ts +26 -0
- package/src/SearchField.tsx +59 -59
- package/src/SearchOptionGroup.tsx +20 -20
- package/src/Switch.tsx +72 -72
- package/src/TabBox.tsx +87 -89
- package/src/TableEx.tsx +5 -8
- package/src/TooltipClick.tsx +62 -64
- package/src/TwoFieldInput.tsx +104 -104
- package/src/app/IServicePage.ts +1 -1
- package/src/app/Labels.ts +67 -67
- package/src/index.ts +1 -0
- package/src/texts/MoneyText.tsx +29 -35
- package/src/texts/NumberText.tsx +23 -23
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { CircularProgress } from
|
|
3
|
-
import { DateUtils, NumberUtils } from
|
|
4
|
-
import CheckIcon from
|
|
5
|
-
import ClearIcon from
|
|
6
|
-
import { DataGridExFooterItemRendererProps } from
|
|
7
|
-
import { DateText } from
|
|
8
|
-
import { GridCellRendererProps, GridDataType } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CircularProgress } from "@mui/material";
|
|
3
|
+
import { DateUtils, NumberUtils } from "@etsoo/shared";
|
|
4
|
+
import CheckIcon from "@mui/icons-material/Check";
|
|
5
|
+
import ClearIcon from "@mui/icons-material/Clear";
|
|
6
|
+
import { DataGridExFooterItemRendererProps } from "./DataGridEx";
|
|
7
|
+
import { DateText } from "./texts/DateText";
|
|
8
|
+
import { GridCellRendererProps, GridDataType } from "@etsoo/react";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Data grid renderers
|
|
12
12
|
*/
|
|
13
13
|
export namespace DataGridRenderers {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// No formatted value and data field
|
|
38
|
-
if (formattedValue == null && field == null) return undefined;
|
|
33
|
+
// Others return undefined
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (value == null) return undefined;
|
|
37
|
+
// No formatted value and data field
|
|
38
|
+
if (formattedValue == null && field == null) return undefined;
|
|
43
39
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const dateValue = value instanceof Date ? value : new Date(value);
|
|
40
|
+
// Cell value
|
|
41
|
+
const value = formattedValue ?? data[field!];
|
|
42
|
+
if (value == null) return undefined;
|
|
48
43
|
|
|
49
|
-
|
|
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);
|
|
50
48
|
|
|
51
|
-
|
|
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
|
-
}
|
|
49
|
+
const option = type === GridDataType.DateTime ? "ds" : "d";
|
|
63
50
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
+
}
|
|
71
63
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
type === GridDataType.IntMoney,
|
|
80
|
-
renderProps?.numberFormatOptions
|
|
81
|
-
);
|
|
82
|
-
else
|
|
83
|
-
return NumberUtils.format(
|
|
84
|
-
value,
|
|
85
|
-
renderProps?.culture,
|
|
86
|
-
renderProps?.numberFormatOptions
|
|
87
|
-
);
|
|
88
|
-
}
|
|
64
|
+
return DateUtils.format(
|
|
65
|
+
dateValue,
|
|
66
|
+
renderProps?.culture,
|
|
67
|
+
option,
|
|
68
|
+
renderProps?.timeZone
|
|
69
|
+
);
|
|
70
|
+
}
|
|
89
71
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
+
}
|
|
104
89
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
+
}
|
|
108
104
|
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
if (value) return <CheckIcon fontSize="small" />;
|
|
106
|
+
else return <ClearIcon fontSize="small" color="warning" />;
|
|
111
107
|
}
|
|
112
108
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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;
|
|
109
|
+
// To string
|
|
110
|
+
return new String(value);
|
|
111
|
+
}
|
|
126
112
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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;
|
|
137
126
|
|
|
138
|
-
|
|
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
|
+
}
|
|
139
136
|
}
|
|
137
|
+
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
140
|
}
|
package/src/DataTable.tsx
CHANGED
|
@@ -30,16 +30,6 @@ export type DataTableProps<R extends GridValidRowModel = any> = Omit<
|
|
|
30
30
|
* @returns Result
|
|
31
31
|
*/
|
|
32
32
|
onCellSelection?: (params: DataTableSelectedCellParams) => void | false;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Toolbar creator
|
|
36
|
-
* @returns Toolbar
|
|
37
|
-
*/
|
|
38
|
-
toolbarCreator?: (
|
|
39
|
-
selectedCellParams: DataTableSelectedCellParams | null,
|
|
40
|
-
setCellModesModel: React.Dispatch<React.SetStateAction<GridCellModesModel>>,
|
|
41
|
-
cellModesModel: GridCellModesModel
|
|
42
|
-
) => React.ReactElement;
|
|
43
33
|
};
|
|
44
34
|
|
|
45
35
|
/**
|
|
@@ -54,9 +44,9 @@ export function DataTable<R extends GridValidRowModel = any>(
|
|
|
54
44
|
const {
|
|
55
45
|
localeText = {},
|
|
56
46
|
onCellSelection,
|
|
57
|
-
toolbarCreator,
|
|
58
47
|
onProcessRowUpdateError = (error) =>
|
|
59
48
|
console.log("onProcessRowUpdateError", error),
|
|
49
|
+
slotProps,
|
|
60
50
|
...rest
|
|
61
51
|
} = props;
|
|
62
52
|
|
|
@@ -64,9 +54,6 @@ export function DataTable<R extends GridValidRowModel = any>(
|
|
|
64
54
|
const { noRows } = globalApp?.getLabels("noRows") ?? {};
|
|
65
55
|
if (noRows && !localeText.noRowsLabel) localeText.noRowsLabel = noRows;
|
|
66
56
|
|
|
67
|
-
const [selectedCellParams, setSelectedCellParams] =
|
|
68
|
-
React.useState<DataTableSelectedCellParams | null>(null);
|
|
69
|
-
|
|
70
57
|
const [cellModesModel, setCellModesModel] =
|
|
71
58
|
React.useState<GridCellModesModel>({});
|
|
72
59
|
|
|
@@ -92,8 +79,6 @@ export function DataTable<R extends GridValidRowModel = any>(
|
|
|
92
79
|
if (onCellSelection) {
|
|
93
80
|
if (onCellSelection(params) === false) return;
|
|
94
81
|
}
|
|
95
|
-
|
|
96
|
-
setSelectedCellParams(params);
|
|
97
82
|
},
|
|
98
83
|
[]
|
|
99
84
|
);
|
|
@@ -106,22 +91,8 @@ export function DataTable<R extends GridValidRowModel = any>(
|
|
|
106
91
|
cellModesModel={cellModesModel}
|
|
107
92
|
onCellModesModelChange={(model) => setCellModesModel(model)}
|
|
108
93
|
onProcessRowUpdateError={onProcessRowUpdateError}
|
|
109
|
-
slots={{
|
|
110
|
-
toolbar: toolbarCreator
|
|
111
|
-
? ({ selectedCellParams, setCellModesModel, cellModesModel }) =>
|
|
112
|
-
toolbarCreator(
|
|
113
|
-
selectedCellParams,
|
|
114
|
-
setCellModesModel,
|
|
115
|
-
cellModesModel
|
|
116
|
-
)
|
|
117
|
-
: undefined
|
|
118
|
-
}}
|
|
119
94
|
slotProps={{
|
|
120
|
-
|
|
121
|
-
selectedCellParams,
|
|
122
|
-
setCellModesModel,
|
|
123
|
-
cellModesModel
|
|
124
|
-
},
|
|
95
|
+
...slotProps,
|
|
125
96
|
cell: {
|
|
126
97
|
onFocus: handleCellFocus
|
|
127
98
|
}
|
package/src/DialogButton.tsx
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from
|
|
12
|
-
import React from
|
|
13
|
-
import { Labels } from
|
|
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
14
|
|
|
15
15
|
export interface DialogButtonProps extends ButtonProps {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
@@ -74,90 +74,88 @@ export interface DialogButtonProps extends ButtonProps {
|
|
|
74
74
|
* @returns Component
|
|
75
75
|
*/
|
|
76
76
|
export function DialogButton(props: DialogButtonProps) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
</React.Fragment>
|
|
162
|
-
);
|
|
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)}>{buttonLabel}</Button>
|
|
157
|
+
</DialogActions>
|
|
158
|
+
</Dialog>
|
|
159
|
+
</React.Fragment>
|
|
160
|
+
);
|
|
163
161
|
}
|
package/src/EmailInput.tsx
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { TextField, TextFieldProps } from
|
|
2
|
-
import React from
|
|
1
|
+
import { TextField, TextFieldProps } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Email input props
|
|
6
6
|
*/
|
|
7
|
-
export type EmailInputProps = Omit<TextFieldProps,
|
|
7
|
+
export type EmailInputProps = Omit<TextFieldProps, "type"> & {};
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Email input
|
|
11
11
|
* @param props Props
|
|
12
12
|
*/
|
|
13
13
|
export function EmailInput(props: EmailInputProps) {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// Destruct
|
|
15
|
+
const { inputProps = {}, ...rest } = props;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// Default max length
|
|
18
|
+
inputProps.maxLength ??= 128;
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<TextField type="email" fullWidth inputProps={inputProps} {...rest} />
|
|
23
|
-
);
|
|
20
|
+
// Layout
|
|
21
|
+
return <TextField type="email" fullWidth inputProps={inputProps} {...rest} />;
|
|
24
22
|
}
|