@etsoo/materialui 1.3.42 → 1.3.44
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/__tests__/NotifierMUTests.tsx +140 -140
- package/__tests__/ResponsePage.tsx +48 -0
- package/__tests__/SelectEx.tsx +2 -2
- package/__tests__/SwitchAnt.tsx +17 -17
- package/__tests__/tsconfig.json +17 -17
- package/lib/AddresSelector.js +1 -2
- package/lib/AuditDisplay.js +2 -3
- package/lib/BridgeCloseButton.js +1 -2
- package/lib/ComboBox.js +5 -5
- package/lib/ComboBoxMultiple.js +7 -8
- package/lib/ComboBoxPro.js +1 -2
- package/lib/CultureDataTable.js +2 -2
- package/lib/DataGridEx.d.ts +2 -3
- package/lib/DataGridEx.js +12 -14
- package/lib/DataGridRenderers.js +6 -6
- package/lib/DataSteps.js +1 -2
- package/lib/DataTable.js +1 -2
- package/lib/DialogButton.js +2 -3
- package/lib/DnDList.js +1 -1
- package/lib/EmailInput.js +1 -2
- package/lib/FileUploadButton.js +1 -1
- package/lib/GridDataFormat.js +5 -5
- package/lib/GridUtils.js +1 -2
- package/lib/HiSelector.js +1 -1
- package/lib/HiSelectorTL.js +1 -1
- package/lib/InputField.js +4 -5
- package/lib/InputTipField.js +1 -1
- package/lib/ItemList.js +2 -3
- package/lib/ListChooser.js +4 -5
- package/lib/LoadingButton.js +1 -2
- package/lib/MaskInput.js +2 -3
- package/lib/NotifierMU.js +14 -19
- package/lib/OptionBool.js +1 -2
- package/lib/OptionGroup.js +3 -4
- package/lib/OptionGroupFlag.js +1 -1
- package/lib/QuickList.js +2 -2
- package/lib/ResponsibleContainer.d.ts +3 -3
- package/lib/ResponsibleContainer.js +3 -3
- package/lib/ScrollerListEx.d.ts +6 -7
- package/lib/ScrollerListEx.js +30 -36
- package/lib/SearchField.js +3 -4
- package/lib/SelectBool.js +1 -2
- package/lib/SelectEx.js +6 -8
- package/lib/ShowDataComparison.js +3 -4
- package/lib/Switch.js +1 -2
- package/lib/SwitchAnt.js +6 -7
- package/lib/TableEx.js +5 -7
- package/lib/TagList.js +3 -5
- package/lib/TagListPro.js +3 -5
- package/lib/TextFieldEx.js +2 -2
- package/lib/Tiplist.js +6 -8
- package/lib/TiplistPro.js +9 -10
- package/lib/TooltipClick.js +2 -2
- package/lib/TwoFieldInput.js +1 -1
- package/lib/UserAvatar.js +1 -2
- package/lib/UserAvatarEditor.js +4 -6
- package/lib/app/CommonApp.js +1 -1
- package/lib/app/ReactApp.js +4 -6
- package/lib/app/ServiceApp.js +5 -7
- package/lib/pages/DataGridPage.d.ts +2 -2
- package/lib/pages/DataGridPage.js +2 -3
- package/lib/pages/DataGridPageProps.d.ts +2 -2
- package/lib/pages/FixedListPage.d.ts +2 -2
- package/lib/pages/FixedListPage.js +2 -3
- package/lib/pages/LeftDrawer.js +2 -3
- package/lib/pages/ListPage.d.ts +2 -2
- package/lib/pages/ListPage.js +2 -3
- package/lib/pages/ListPageProps.d.ts +1 -1
- package/lib/pages/ResponsivePage.d.ts +2 -2
- package/lib/pages/ResponsivePage.js +1 -2
- package/lib/pages/ResponsivePageProps.d.ts +2 -2
- package/lib/pages/TablePage.js +3 -5
- package/lib/pages/UserMenu.js +1 -2
- package/lib/pages/ViewPage.js +6 -7
- package/package.json +14 -12
- package/src/DataGridEx.tsx +6 -12
- package/src/ResponsibleContainer.tsx +7 -9
- package/src/ScrollerListEx.tsx +301 -311
- package/src/pages/DataGridPage.tsx +4 -5
- package/src/pages/DataGridPageProps.ts +3 -4
- package/src/pages/FixedListPage.tsx +4 -5
- package/src/pages/ListPage.tsx +4 -5
- package/src/pages/ListPageProps.ts +2 -3
- package/src/pages/ResponsivePage.tsx +4 -5
- package/src/pages/ResponsivePageProps.ts +3 -4
- package/tsconfig.json +3 -3
package/lib/QuickList.js
CHANGED
|
@@ -11,7 +11,7 @@ import { VBox } from "./FlexBox";
|
|
|
11
11
|
*/
|
|
12
12
|
export function QuickList(props) {
|
|
13
13
|
// Destruct
|
|
14
|
-
const { buttonProps = {}, label, inputProps, itemLabel = DataTypes.getListItemLabel, itemRenderer = (item) => itemLabel(item), itemProps, loadData, noMatchesLabel = globalApp
|
|
14
|
+
const { buttonProps = {}, label, inputProps, itemLabel = DataTypes.getListItemLabel, itemRenderer = (item) => itemLabel(item), itemProps, loadData, noMatchesLabel = globalApp?.get("noMatches"), gap = 1, height = "480px", onItemClick, ...rest } = props;
|
|
15
15
|
const { onClick, ...buttonRest } = buttonProps;
|
|
16
16
|
// States
|
|
17
17
|
const [loading, setLoading] = React.useState(false);
|
|
@@ -20,7 +20,7 @@ export function QuickList(props) {
|
|
|
20
20
|
setLoading(true);
|
|
21
21
|
loadData(keyword).then((result) => {
|
|
22
22
|
setLoading(false);
|
|
23
|
-
setItems(result
|
|
23
|
+
setItems(result ?? []);
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
React.useEffect(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes
|
|
1
|
+
import { DataTypes } from "@etsoo/shared";
|
|
2
2
|
import { SxProps, Theme } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { ListChildComponentProps } from "react-window";
|
|
@@ -8,7 +8,7 @@ import { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from "./
|
|
|
8
8
|
/**
|
|
9
9
|
* ResponsibleContainer props
|
|
10
10
|
*/
|
|
11
|
-
export type ResponsibleContainerProps<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
11
|
+
export type ResponsibleContainerProps<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate> = Omit<DataGridExProps<T>, "height" | "itemKey" | "loadData" | "mRef" | "onScroll" | "onItemsRendered" | "onInitLoad" | "onUpdateRows"> & {
|
|
12
12
|
/**
|
|
13
13
|
* Height will be deducted
|
|
14
14
|
* @param height Current calcuated height
|
|
@@ -96,4 +96,4 @@ export type ResponsibleContainerProps<T extends object, F extends DataTypes.Basi
|
|
|
96
96
|
* @param props Props
|
|
97
97
|
* @returns Layout
|
|
98
98
|
*/
|
|
99
|
-
export declare function ResponsibleContainer<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
99
|
+
export declare function ResponsibleContainer<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ResponsibleContainerProps<T, F>): React.JSX.Element;
|
|
@@ -172,7 +172,7 @@ export function ResponsibleContainer(props) {
|
|
|
172
172
|
const searchBar = React.useMemo(() => {
|
|
173
173
|
if (!hasFields || showDataGrid == null)
|
|
174
174
|
return;
|
|
175
|
-
const f = typeof fields == "function" ? fields(searchData
|
|
175
|
+
const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
|
|
176
176
|
return (React.createElement(SearchBar, { fields: f, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}` }));
|
|
177
177
|
}, [showDataGrid, hasFields, searchBarHeight]);
|
|
178
178
|
// Pull container
|
|
@@ -188,8 +188,8 @@ export function ResponsibleContainer(props) {
|
|
|
188
188
|
React.createElement(Stack, null,
|
|
189
189
|
React.createElement(Box, { ref: dimensions[0][0], className: "SearchBox", sx: { height: hasFields ? searchBarHeight : 0 } }, searchBar),
|
|
190
190
|
list),
|
|
191
|
-
pullToRefresh && pullContainer && (React.createElement(PullToRefreshUI, { mainElement: pullContainer, triggerElement: pullContainer, instructionsPullToRefresh: labels.pullToRefresh, instructionsReleaseToRefresh: labels.releaseToRefresh, instructionsRefreshing: labels.refreshing, onRefresh: () =>
|
|
191
|
+
pullToRefresh && pullContainer && (React.createElement(PullToRefreshUI, { mainElement: pullContainer, triggerElement: pullContainer, instructionsPullToRefresh: labels.pullToRefresh, instructionsReleaseToRefresh: labels.releaseToRefresh, instructionsRefreshing: labels.refreshing, onRefresh: () => state.ref?.reset(), shouldPullToRefresh: () => {
|
|
192
192
|
const container = document.querySelector(pullContainer);
|
|
193
|
-
return !
|
|
193
|
+
return !container?.scrollTop;
|
|
194
194
|
} }))));
|
|
195
195
|
}
|
package/lib/ScrollerListEx.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ScrollerListProps } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { MouseEventWithDataHandler } from './MUGlobal';
|
|
1
|
+
import { ScrollerListProps } from "@etsoo/react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ListChildComponentProps } from "react-window";
|
|
4
|
+
import { MouseEventWithDataHandler } from "./MUGlobal";
|
|
6
5
|
/**
|
|
7
6
|
* Extended ScrollerList inner item renderer props
|
|
8
7
|
*/
|
|
@@ -34,7 +33,7 @@ export type ScrollerListExItemSize = ((index: number) => [number, number] | [num
|
|
|
34
33
|
/**
|
|
35
34
|
* Extended ScrollerList Props
|
|
36
35
|
*/
|
|
37
|
-
export type ScrollerListExProps<T extends object
|
|
36
|
+
export type ScrollerListExProps<T extends object> = Omit<ScrollerListProps<T>, "itemRenderer" | "itemSize"> & {
|
|
38
37
|
/**
|
|
39
38
|
* Alternating colors for odd/even rows
|
|
40
39
|
*/
|
|
@@ -73,4 +72,4 @@ export type ScrollerListExProps<T extends object, D extends DataTypes.Keys<T>> =
|
|
|
73
72
|
* @param props Props
|
|
74
73
|
* @returns Component
|
|
75
74
|
*/
|
|
76
|
-
export declare function ScrollerListEx<T extends object
|
|
75
|
+
export declare function ScrollerListEx<T extends object>(props: ScrollerListExProps<T>): React.JSX.Element;
|
package/lib/ScrollerListEx.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { css } from
|
|
2
|
-
import { ScrollerList } from
|
|
3
|
-
import { Utils } from
|
|
4
|
-
import { useTheme } from
|
|
5
|
-
import React from
|
|
6
|
-
import { MUGlobal } from
|
|
1
|
+
import { css } from "@emotion/css";
|
|
2
|
+
import { ScrollerList } from "@etsoo/react";
|
|
3
|
+
import { Utils } from "@etsoo/shared";
|
|
4
|
+
import { useTheme } from "@mui/material";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { MUGlobal } from "./MUGlobal";
|
|
7
7
|
// Scroll bar size
|
|
8
8
|
const scrollbarSize = 16;
|
|
9
9
|
// Selected class name
|
|
10
|
-
const selectedClassName =
|
|
10
|
+
const selectedClassName = "ScrollerListEx-Selected";
|
|
11
11
|
const createGridStyle = (alternatingColors, selectedColor) => {
|
|
12
12
|
return css({
|
|
13
|
-
|
|
13
|
+
"& .ScrollerListEx-Selected": {
|
|
14
14
|
backgroundColor: selectedColor
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
"& .ScrollerListEx-Row0:not(.ScrollerListEx-Selected)": {
|
|
17
17
|
backgroundColor: alternatingColors[0]
|
|
18
18
|
},
|
|
19
|
-
|
|
19
|
+
"& .ScrollerListEx-Row1:not(.ScrollerListEx-Selected)": {
|
|
20
20
|
backgroundColor: alternatingColors[1]
|
|
21
21
|
},
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
"@media (min-width: 800px)": {
|
|
23
|
+
"::-webkit-scrollbar": {
|
|
24
24
|
width: scrollbarSize,
|
|
25
25
|
height: scrollbarSize,
|
|
26
|
-
backgroundColor:
|
|
26
|
+
backgroundColor: "#f6f6f6"
|
|
27
27
|
},
|
|
28
|
-
|
|
29
|
-
backgroundColor:
|
|
30
|
-
borderRadius:
|
|
28
|
+
"::-webkit-scrollbar-thumb": {
|
|
29
|
+
backgroundColor: "rgba(0,0,0,0.4)",
|
|
30
|
+
borderRadius: "2px"
|
|
31
31
|
},
|
|
32
|
-
|
|
33
|
-
background:
|
|
32
|
+
"::-webkit-scrollbar-track-piece:start": {
|
|
33
|
+
background: "transparent"
|
|
34
34
|
},
|
|
35
|
-
|
|
36
|
-
background:
|
|
35
|
+
"::-webkit-scrollbar-track-piece:end": {
|
|
36
|
+
background: "transparent"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
});
|
|
@@ -92,27 +92,25 @@ export function ScrollerListEx(props) {
|
|
|
92
92
|
// Selected item ref
|
|
93
93
|
const selectedItem = React.useRef();
|
|
94
94
|
const onMouseDown = (div, data) => {
|
|
95
|
-
var _a;
|
|
96
95
|
// Destruct
|
|
97
|
-
const [selectedDiv, selectedData] =
|
|
96
|
+
const [selectedDiv, selectedData] = selectedItem.current ?? [];
|
|
98
97
|
if (selectedData != null && selectedData[idField] === data[idField])
|
|
99
98
|
return;
|
|
100
|
-
selectedDiv
|
|
99
|
+
selectedDiv?.classList.remove(selectedClassName);
|
|
101
100
|
div.classList.add(selectedClassName);
|
|
102
101
|
selectedItem.current = [div, data];
|
|
103
102
|
if (onSelectChange)
|
|
104
103
|
onSelectChange([data]);
|
|
105
104
|
};
|
|
106
105
|
const isSelected = (data) => {
|
|
107
|
-
|
|
108
|
-
const [_, selectedData] = (_a = selectedItem.current) !== null && _a !== void 0 ? _a : [];
|
|
106
|
+
const [_, selectedData] = selectedItem.current ?? [];
|
|
109
107
|
const selected = selectedData && data && selectedData[idField] === data[idField]
|
|
110
108
|
? true
|
|
111
109
|
: false;
|
|
112
110
|
return selected;
|
|
113
111
|
};
|
|
114
112
|
// Destruct
|
|
115
|
-
const { alternatingColors = [undefined, undefined], className, idField =
|
|
113
|
+
const { alternatingColors = [undefined, undefined], className, idField = "id", innerItemRenderer, itemSize, itemRenderer = (itemProps) => {
|
|
116
114
|
const [itemHeight, space, margins] = calculateItemSize(itemProps.index);
|
|
117
115
|
return defaultItemRenderer({
|
|
118
116
|
itemHeight,
|
|
@@ -125,20 +123,16 @@ export function ScrollerListEx(props) {
|
|
|
125
123
|
selected: isSelected(itemProps.data),
|
|
126
124
|
...itemProps
|
|
127
125
|
});
|
|
128
|
-
}, onClick, onDoubleClick, onSelectChange, selectedColor =
|
|
126
|
+
}, onClick, onDoubleClick, onSelectChange, selectedColor = "#edf4fb", ...rest } = props;
|
|
129
127
|
// Theme
|
|
130
128
|
const theme = useTheme();
|
|
131
129
|
// Cache calculation
|
|
132
130
|
const itemSizeResult = React.useMemo(() => {
|
|
133
|
-
if (typeof itemSize ===
|
|
131
|
+
if (typeof itemSize === "function")
|
|
134
132
|
return undefined;
|
|
135
133
|
const [size, spaces, isNarrow] = itemSize;
|
|
136
|
-
if (typeof spaces ===
|
|
137
|
-
return [
|
|
138
|
-
size,
|
|
139
|
-
spaces,
|
|
140
|
-
defaultMargin(MUGlobal.pagePaddings, undefined)
|
|
141
|
-
];
|
|
134
|
+
if (typeof spaces === "number")
|
|
135
|
+
return [size, spaces, defaultMargin(MUGlobal.pagePaddings, undefined)];
|
|
142
136
|
return [
|
|
143
137
|
size,
|
|
144
138
|
MUGlobal.getSpace(spaces, theme),
|
|
@@ -148,7 +142,7 @@ export function ScrollerListEx(props) {
|
|
|
148
142
|
// Calculate size
|
|
149
143
|
const calculateItemSize = (index) => {
|
|
150
144
|
// Callback function
|
|
151
|
-
if (typeof itemSize ===
|
|
145
|
+
if (typeof itemSize === "function") {
|
|
152
146
|
const result = itemSize(index);
|
|
153
147
|
if (result.length == 2)
|
|
154
148
|
return [...result, defaultMargin(MUGlobal.pagePaddings)];
|
|
@@ -163,5 +157,5 @@ export function ScrollerListEx(props) {
|
|
|
163
157
|
return size + space;
|
|
164
158
|
};
|
|
165
159
|
// Layout
|
|
166
|
-
return (React.createElement(ScrollerList, { className: Utils.mergeClasses(
|
|
160
|
+
return (React.createElement(ScrollerList, { className: Utils.mergeClasses("ScrollerListEx-Body", className, createGridStyle(alternatingColors, selectedColor)), idField: idField, itemRenderer: itemRenderer, itemSize: itemSizeLocal, ...rest }));
|
|
167
161
|
}
|
package/lib/SearchField.js
CHANGED
|
@@ -8,11 +8,10 @@ import { MUGlobal } from './MUGlobal';
|
|
|
8
8
|
* @returns Component
|
|
9
9
|
*/
|
|
10
10
|
export function SearchField(props) {
|
|
11
|
-
var _a;
|
|
12
11
|
// Destruct
|
|
13
12
|
const { changeDelay, InputLabelProps = {}, InputProps = {}, onChange, readOnly, size = MUGlobal.searchFieldSize, variant = MUGlobal.searchFieldVariant, ...rest } = props;
|
|
14
13
|
// Shrink
|
|
15
|
-
|
|
14
|
+
InputLabelProps.shrink ?? (InputLabelProps.shrink = MUGlobal.searchFieldShrink);
|
|
16
15
|
// Read only
|
|
17
16
|
if (readOnly != null)
|
|
18
17
|
InputProps.readOnly = readOnly;
|
|
@@ -27,12 +26,12 @@ export function SearchField(props) {
|
|
|
27
26
|
onChange(event);
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
30
|
-
delayed
|
|
29
|
+
delayed?.call(undefined, event);
|
|
31
30
|
};
|
|
32
31
|
React.useEffect(() => {
|
|
33
32
|
return () => {
|
|
34
33
|
isMounted.current = false;
|
|
35
|
-
delayed
|
|
34
|
+
delayed?.clear();
|
|
36
35
|
};
|
|
37
36
|
}, []);
|
|
38
37
|
// Layout
|
package/lib/SelectBool.js
CHANGED
|
@@ -8,11 +8,10 @@ import { SelectEx } from "./SelectEx";
|
|
|
8
8
|
* @returns Component
|
|
9
9
|
*/
|
|
10
10
|
export function SelectBool(props) {
|
|
11
|
-
var _a;
|
|
12
11
|
// Destruct
|
|
13
12
|
const { search = true, autoAddBlankItem = search, ...rest } = props;
|
|
14
13
|
// Options
|
|
15
|
-
const options =
|
|
14
|
+
const options = globalApp?.getBools() ?? [];
|
|
16
15
|
if (autoAddBlankItem)
|
|
17
16
|
Utils.addBlankItem(options);
|
|
18
17
|
// Layout
|
package/lib/SelectEx.js
CHANGED
|
@@ -45,8 +45,8 @@ export function SelectEx(props) {
|
|
|
45
45
|
setOptionsAdd(options);
|
|
46
46
|
}, [options, propertyWay]);
|
|
47
47
|
// Local value
|
|
48
|
-
const v = defaultValue
|
|
49
|
-
const valueSource = React.useMemo(() => (multiple ? (v ? (Array.isArray(v) ? v : [v]) : []) : v
|
|
48
|
+
const v = defaultValue ?? value;
|
|
49
|
+
const valueSource = React.useMemo(() => (multiple ? (v ? (Array.isArray(v) ? v : [v]) : []) : v ?? ""), [multiple, v]);
|
|
50
50
|
// Value state
|
|
51
51
|
const [valueState, setValueStateBase] = React.useState(valueSource);
|
|
52
52
|
const valueRef = React.useRef();
|
|
@@ -62,14 +62,13 @@ export function SelectEx(props) {
|
|
|
62
62
|
const labelId = `selectex-label-${name}`;
|
|
63
63
|
// Set item
|
|
64
64
|
const setItemValue = (id) => {
|
|
65
|
-
var _a;
|
|
66
65
|
if (id !== valueRef.current) {
|
|
67
66
|
// Difference
|
|
68
67
|
const diff = multiple
|
|
69
68
|
? ArrayUtils.differences(id, valueRef.current)
|
|
70
69
|
: id;
|
|
71
70
|
setValueState(id);
|
|
72
|
-
const input =
|
|
71
|
+
const input = divRef.current?.querySelector("input");
|
|
73
72
|
if (input) {
|
|
74
73
|
// Different value, trigger change event
|
|
75
74
|
ReactUtils.triggerChange(input, id, false);
|
|
@@ -111,18 +110,17 @@ export function SelectEx(props) {
|
|
|
111
110
|
}, [valueSource]);
|
|
112
111
|
// When layout ready
|
|
113
112
|
React.useEffect(() => {
|
|
114
|
-
|
|
115
|
-
const input = (_a = divRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("input");
|
|
113
|
+
const input = divRef.current?.querySelector("input");
|
|
116
114
|
const inputChange = (event) => {
|
|
117
115
|
// Reset case
|
|
118
116
|
if (event.cancelable)
|
|
119
117
|
setValueState(multiple ? [] : "");
|
|
120
118
|
};
|
|
121
|
-
input
|
|
119
|
+
input?.addEventListener("change", inputChange);
|
|
122
120
|
isMounted.current = true;
|
|
123
121
|
return () => {
|
|
124
122
|
isMounted.current = false;
|
|
125
|
-
input
|
|
123
|
+
input?.removeEventListener("change", inputChange);
|
|
126
124
|
};
|
|
127
125
|
}, [multiple]);
|
|
128
126
|
// Layout
|
|
@@ -38,10 +38,9 @@ export const ShowDataComparison = (data, modelTitle, getLabel, equalCheck = true
|
|
|
38
38
|
}
|
|
39
39
|
// Labels
|
|
40
40
|
const { dataComparison, field, newValue, oldValue } = app.getLabels("dataComparison", "field", "newValue", "oldValue");
|
|
41
|
-
modelTitle
|
|
42
|
-
getLabel
|
|
43
|
-
|
|
44
|
-
return (_a = app.get(Utils.formatInitial(key))) !== null && _a !== void 0 ? _a : key;
|
|
41
|
+
modelTitle ?? (modelTitle = dataComparison);
|
|
42
|
+
getLabel ?? (getLabel = (key) => {
|
|
43
|
+
return app.get(Utils.formatInitial(key)) ?? key;
|
|
45
44
|
});
|
|
46
45
|
const keys = new Set([
|
|
47
46
|
...Object.keys(data.oldData),
|
package/lib/Switch.js
CHANGED
|
@@ -8,11 +8,10 @@ import MuiSwitch from '@mui/material/Switch';
|
|
|
8
8
|
* @returns Component
|
|
9
9
|
*/
|
|
10
10
|
export function Switch(props) {
|
|
11
|
-
var _a;
|
|
12
11
|
// Destruct
|
|
13
12
|
const { checked, defaultChecked, defaultValue, onChange, readOnly, size, checkbox = false, value = 'true', ...rest } = props;
|
|
14
13
|
// Checked state
|
|
15
|
-
const [controlChecked, setControlChecked] = React.useState(
|
|
14
|
+
const [controlChecked, setControlChecked] = React.useState(checked ?? defaultChecked ?? defaultValue == value);
|
|
16
15
|
React.useEffect(() => {
|
|
17
16
|
if (checked)
|
|
18
17
|
setControlChecked(checked);
|
package/lib/SwitchAnt.js
CHANGED
|
@@ -8,13 +8,12 @@ import { globalApp } from "./app/ReactApp";
|
|
|
8
8
|
* @returns Component
|
|
9
9
|
*/
|
|
10
10
|
export function SwitchAnt(props) {
|
|
11
|
-
var _a, _b;
|
|
12
11
|
// Labels
|
|
13
|
-
const { yes = "Yes", no = "No" } =
|
|
12
|
+
const { yes = "Yes", no = "No" } = globalApp?.getLabels("yes", "no") ?? {};
|
|
14
13
|
// Destruct
|
|
15
14
|
const { activeColor, checked, defaultChecked, defaultValue, endLabel = yes, startLabel = no, onChange, value = "true", ...rest } = props;
|
|
16
15
|
// Checked state
|
|
17
|
-
const [controlChecked, setControlChecked] = React.useState(
|
|
16
|
+
const [controlChecked, setControlChecked] = React.useState(checked ?? defaultChecked ?? defaultValue == value);
|
|
18
17
|
// Ref
|
|
19
18
|
const ref = React.useRef(null);
|
|
20
19
|
React.useEffect(() => {
|
|
@@ -29,17 +28,17 @@ export function SwitchAnt(props) {
|
|
|
29
28
|
};
|
|
30
29
|
// Layout
|
|
31
30
|
return (React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
|
|
32
|
-
React.createElement(Typography, { onClick: () =>
|
|
31
|
+
React.createElement(Typography, { onClick: () => controlChecked && ref.current?.click(), sx: {
|
|
33
32
|
cursor: "pointer",
|
|
34
33
|
color: controlChecked
|
|
35
34
|
? undefined
|
|
36
|
-
: (theme) => activeColor
|
|
35
|
+
: (theme) => activeColor ?? theme.palette.warning.main
|
|
37
36
|
} }, startLabel),
|
|
38
37
|
React.createElement(Switch, { checked: controlChecked, inputRef: ref, value: value, onChange: onChangeLocal, ...rest }),
|
|
39
|
-
React.createElement(Typography, { onClick: () =>
|
|
38
|
+
React.createElement(Typography, { onClick: () => !controlChecked && ref.current?.click(), sx: {
|
|
40
39
|
cursor: "pointer",
|
|
41
40
|
color: controlChecked
|
|
42
|
-
? (theme) => activeColor
|
|
41
|
+
? (theme) => activeColor ?? theme.palette.warning.main
|
|
43
42
|
: undefined
|
|
44
43
|
} }, endLabel)));
|
|
45
44
|
}
|
package/lib/TableEx.js
CHANGED
|
@@ -13,7 +13,6 @@ export const TableExMinWidth = 180;
|
|
|
13
13
|
* @returns Component
|
|
14
14
|
*/
|
|
15
15
|
export function TableEx(props) {
|
|
16
|
-
var _a;
|
|
17
16
|
// Theme
|
|
18
17
|
const theme = useTheme();
|
|
19
18
|
// Destruct
|
|
@@ -48,7 +47,7 @@ export function TableEx(props) {
|
|
|
48
47
|
isNextPageLoading: false,
|
|
49
48
|
orderBy: defaultOrderBy,
|
|
50
49
|
orderByAsc: defaultOrderBy
|
|
51
|
-
?
|
|
50
|
+
? columns.find((column) => column.field === defaultOrderBy)?.sortAsc
|
|
52
51
|
: undefined,
|
|
53
52
|
batchSize: rowsPerPageLocal,
|
|
54
53
|
selectedItems: [],
|
|
@@ -193,7 +192,7 @@ export function TableEx(props) {
|
|
|
193
192
|
// Total rows
|
|
194
193
|
const totalRows = hasNextPage
|
|
195
194
|
? -1
|
|
196
|
-
: currentPage * batchSize + (lastLoadedItems
|
|
195
|
+
: currentPage * batchSize + (lastLoadedItems ?? 0);
|
|
197
196
|
// Auto load data when current page is 0
|
|
198
197
|
if (currentPage === 0 && stateAutoLoad && lastLoadedItems == null)
|
|
199
198
|
loadDataLocal();
|
|
@@ -219,7 +218,7 @@ export function TableEx(props) {
|
|
|
219
218
|
// Destruct
|
|
220
219
|
const { align, field, header, minWidth, sortable, sortAsc = true, type, width } = column;
|
|
221
220
|
// Header text
|
|
222
|
-
const headerText = header
|
|
221
|
+
const headerText = header ?? field;
|
|
223
222
|
// Sortable
|
|
224
223
|
let sortLabel;
|
|
225
224
|
if (sortable && field != null) {
|
|
@@ -233,7 +232,7 @@ export function TableEx(props) {
|
|
|
233
232
|
else {
|
|
234
233
|
sortLabel = headerText;
|
|
235
234
|
}
|
|
236
|
-
return (React.createElement(TableCell, { align: GridAlignGet(align, type), key: field
|
|
235
|
+
return (React.createElement(TableCell, { align: GridAlignGet(align, type), key: field ?? index.toString(), width: width, sx: {
|
|
237
236
|
minWidth: minWidth == null
|
|
238
237
|
? width == null
|
|
239
238
|
? TableExMinWidth
|
|
@@ -249,11 +248,10 @@ export function TableEx(props) {
|
|
|
249
248
|
backgroundColor: alternatingColors[1]
|
|
250
249
|
}
|
|
251
250
|
} }, [...Array(batchSize)].map((_item, rowIndex) => {
|
|
252
|
-
var _a;
|
|
253
251
|
// Row
|
|
254
252
|
const row = rowIndex < rows.length ? rows[rowIndex] : undefined;
|
|
255
253
|
// Row id field value
|
|
256
|
-
const rowId =
|
|
254
|
+
const rowId = DataTypes.getValue(row, idField) ?? rowIndex;
|
|
257
255
|
// Selected or not
|
|
258
256
|
const isItemSelected = selectable
|
|
259
257
|
? selectedItems.some((item) => item[idField] === rowId)
|
package/lib/TagList.js
CHANGED
|
@@ -5,9 +5,8 @@ import React from "react";
|
|
|
5
5
|
import { InputField } from "./InputField";
|
|
6
6
|
import { globalApp } from "./app/ReactApp";
|
|
7
7
|
export function TagList(props) {
|
|
8
|
-
var _a;
|
|
9
8
|
// Labels
|
|
10
|
-
const { noOptions, loading: loadingLabel, more = "More", open: openDefault } =
|
|
9
|
+
const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
|
|
11
10
|
const moreLabel = more + "...";
|
|
12
11
|
// Destruct
|
|
13
12
|
const { renderOption = (props, option, { selected }) => (React.createElement("li", { ...props },
|
|
@@ -17,11 +16,10 @@ export function TagList(props) {
|
|
|
17
16
|
const [options, setOptions] = React.useState([]);
|
|
18
17
|
const [loading, setLoading] = React.useState(false);
|
|
19
18
|
const currentValue = React.useRef([]);
|
|
20
|
-
currentValue.current = value
|
|
19
|
+
currentValue.current = value ?? [];
|
|
21
20
|
const loadDataLocal = async (keyword) => {
|
|
22
|
-
var _a;
|
|
23
21
|
setLoading(true);
|
|
24
|
-
const result = (
|
|
22
|
+
const result = (await loadData(keyword, maxItems)) ?? [];
|
|
25
23
|
const len = result.length;
|
|
26
24
|
currentValue.current.forEach((item) => {
|
|
27
25
|
if (!result.includes(item))
|
package/lib/TagListPro.js
CHANGED
|
@@ -6,9 +6,8 @@ import { InputField } from "./InputField";
|
|
|
6
6
|
import { globalApp } from "./app/ReactApp";
|
|
7
7
|
import { DataTypes } from "@etsoo/shared";
|
|
8
8
|
export function TagListPro(props) {
|
|
9
|
-
var _a;
|
|
10
9
|
// Labels
|
|
11
|
-
const { noOptions, loading: loadingLabel, more = "More", open: openDefault } =
|
|
10
|
+
const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
|
|
12
11
|
const moreLabel = more + "...";
|
|
13
12
|
const getLabel = (item) => DataTypes.getListItemLabel(item);
|
|
14
13
|
// Destruct
|
|
@@ -20,11 +19,10 @@ export function TagListPro(props) {
|
|
|
20
19
|
const [options, setOptions] = React.useState([]);
|
|
21
20
|
const [loading, setLoading] = React.useState(false);
|
|
22
21
|
const currentValue = React.useRef([]);
|
|
23
|
-
currentValue.current = value
|
|
22
|
+
currentValue.current = value ?? [];
|
|
24
23
|
const loadDataLocal = async (keyword) => {
|
|
25
|
-
var _a;
|
|
26
24
|
setLoading(true);
|
|
27
|
-
const result = (
|
|
25
|
+
const result = (await loadData(keyword, maxItems)) ?? [];
|
|
28
26
|
const len = result.length;
|
|
29
27
|
currentValue.current.forEach((item) => {
|
|
30
28
|
if (!result.some((r) => r.id === item.id))
|
package/lib/TextFieldEx.js
CHANGED
|
@@ -121,12 +121,12 @@ export const TextFieldEx = React.forwardRef((props, ref) => {
|
|
|
121
121
|
onChange(event);
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
|
-
delayed
|
|
124
|
+
delayed?.call(undefined, event);
|
|
125
125
|
};
|
|
126
126
|
React.useEffect(() => {
|
|
127
127
|
return () => {
|
|
128
128
|
isMounted.current = false;
|
|
129
|
-
delayed
|
|
129
|
+
delayed?.clear();
|
|
130
130
|
};
|
|
131
131
|
}, []);
|
|
132
132
|
// Textfield
|
package/lib/Tiplist.js
CHANGED
|
@@ -11,9 +11,8 @@ import { InputField } from "./InputField";
|
|
|
11
11
|
* @returns Component
|
|
12
12
|
*/
|
|
13
13
|
export function Tiplist(props) {
|
|
14
|
-
var _a;
|
|
15
14
|
// Labels
|
|
16
|
-
const { noOptions, loading, more, open: openDefault } =
|
|
15
|
+
const { noOptions, loading, more, open: openDefault } = globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
|
|
17
16
|
// Destruct
|
|
18
17
|
const { search = false, idField = "id", idValue, inputAutoComplete = "off", inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputReset, inputVariant, label, loadData, defaultValue, value, maxItems = 16, width = search ? 160 : undefined, name, readOnly, onChange, onValueChange, openOnFocus = true, noOptionsText = noOptions, loadingText = loading, openText = openDefault, getOptionLabel, getOptionDisabled, sx = {}, ...rest } = props;
|
|
19
18
|
if (width && sx)
|
|
@@ -21,9 +20,9 @@ export function Tiplist(props) {
|
|
|
21
20
|
// Value input ref
|
|
22
21
|
const inputRef = React.createRef();
|
|
23
22
|
// Local value
|
|
24
|
-
let localValue = value
|
|
23
|
+
let localValue = value ?? defaultValue;
|
|
25
24
|
// One time calculation for input's default value (uncontrolled)
|
|
26
|
-
const localIdValue = idValue
|
|
25
|
+
const localIdValue = idValue ?? DataTypes.getValue(localValue, idField);
|
|
27
26
|
// Changable states
|
|
28
27
|
const [states, stateUpdate] = React.useReducer((currentState, newState) => {
|
|
29
28
|
return { ...currentState, ...newState };
|
|
@@ -112,13 +111,12 @@ export function Tiplist(props) {
|
|
|
112
111
|
};
|
|
113
112
|
const delayed = useDelayedExecutor(loadDataDirect, 480);
|
|
114
113
|
const setInputValue = (value) => {
|
|
115
|
-
var _a;
|
|
116
114
|
stateUpdate({ value });
|
|
117
115
|
// Input value
|
|
118
116
|
const input = inputRef.current;
|
|
119
117
|
if (input) {
|
|
120
118
|
// Update value
|
|
121
|
-
const newValue =
|
|
119
|
+
const newValue = DataTypes.getStringValue(value, idField) ?? "";
|
|
122
120
|
if (newValue !== input.value) {
|
|
123
121
|
// Different value, trigger change event
|
|
124
122
|
ReactUtils.triggerChange(input, newValue, false);
|
|
@@ -166,7 +164,7 @@ export function Tiplist(props) {
|
|
|
166
164
|
}, []);
|
|
167
165
|
// Layout
|
|
168
166
|
return (React.createElement("div", null,
|
|
169
|
-
React.createElement("input", { ref: inputRef, "data-reset": inputReset
|
|
167
|
+
React.createElement("input", { ref: inputRef, "data-reset": inputReset ?? true, type: "text", style: { display: "none" }, name: name, value: `${inputValue ?? (state.current.idSet ? "" : localIdValue ?? "")}`, readOnly: true, onChange: inputOnChange }),
|
|
170
168
|
React.createElement(Autocomplete, { filterOptions: (options, _state) => options, value: states.value, options: states.options, onChange: (event, value, reason, details) => {
|
|
171
169
|
// Set value
|
|
172
170
|
setInputValue(value);
|
|
@@ -200,7 +198,7 @@ export function Tiplist(props) {
|
|
|
200
198
|
if (typeof item !== "object")
|
|
201
199
|
return `${item}`;
|
|
202
200
|
if (item[idField] === "n/a")
|
|
203
|
-
return (more
|
|
201
|
+
return (more ?? "More") + "...";
|
|
204
202
|
return getOptionLabel
|
|
205
203
|
? getOptionLabel(item)
|
|
206
204
|
: DataTypes.getObjectItemLabel(item);
|
package/lib/TiplistPro.js
CHANGED
|
@@ -10,9 +10,8 @@ import { globalApp } from "./app/ReactApp";
|
|
|
10
10
|
* @returns Component
|
|
11
11
|
*/
|
|
12
12
|
export function TiplistPro(props) {
|
|
13
|
-
var _a;
|
|
14
13
|
// Labels
|
|
15
|
-
const { noOptions, loading, more, open: openDefault } =
|
|
14
|
+
const { noOptions, loading, more, open: openDefault } = globalApp?.getLabels("noOptions", "loading", "more", "open") ?? {};
|
|
16
15
|
// Destruct
|
|
17
16
|
const { label, loadData, defaultValue, value, idValue, maxItems = 16, width, name, inputOnChange, inputProps, inputReset, sx, openOnFocus = true, noOptionsText = noOptions, loadingText = loading, openText = openDefault, getOptionDisabled, getOptionLabel, onChange, onValueChange, ...rest } = props;
|
|
18
17
|
if (width && sx)
|
|
@@ -20,11 +19,12 @@ export function TiplistPro(props) {
|
|
|
20
19
|
// Value input ref
|
|
21
20
|
const inputRef = React.createRef();
|
|
22
21
|
// Local value
|
|
23
|
-
let localValue = value
|
|
22
|
+
let localValue = value ?? defaultValue;
|
|
24
23
|
// One time calculation for input's default value (uncontrolled)
|
|
25
|
-
const localIdValue = idValue
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const localIdValue = idValue ??
|
|
25
|
+
(localValue != null && typeof localValue === "object"
|
|
26
|
+
? localValue.id
|
|
27
|
+
: null);
|
|
28
28
|
// Changable states
|
|
29
29
|
const [states, stateUpdate] = React.useReducer((currentState, newState) => {
|
|
30
30
|
return { ...currentState, ...newState };
|
|
@@ -100,13 +100,12 @@ export function TiplistPro(props) {
|
|
|
100
100
|
};
|
|
101
101
|
const delayed = useDelayedExecutor(loadDataDirect, 480);
|
|
102
102
|
const setInputValue = (value) => {
|
|
103
|
-
var _a;
|
|
104
103
|
stateUpdate({ value });
|
|
105
104
|
// Input value
|
|
106
105
|
const input = inputRef.current;
|
|
107
106
|
if (input) {
|
|
108
107
|
// Update value
|
|
109
|
-
const newValue =
|
|
108
|
+
const newValue = value?.id.toString() ?? "";
|
|
110
109
|
if (newValue !== input.value) {
|
|
111
110
|
// Different value, trigger change event
|
|
112
111
|
ReactUtils.triggerChange(input, newValue, false);
|
|
@@ -151,7 +150,7 @@ export function TiplistPro(props) {
|
|
|
151
150
|
}, []);
|
|
152
151
|
// Layout
|
|
153
152
|
return (React.createElement("div", null,
|
|
154
|
-
React.createElement("input", { ref: inputRef, "data-reset": inputReset
|
|
153
|
+
React.createElement("input", { ref: inputRef, "data-reset": inputReset ?? true, type: "text", style: { display: "none" }, name: name, value: inputValue ?? (state.current.idSet ? "" : localIdValue ?? ""), readOnly: true, onChange: inputOnChange }),
|
|
155
154
|
React.createElement(Autocomplete, { filterOptions: (options, _state) => options, value: states.value, options: states.options, freeSolo: true, clearOnBlur: false, onChange: (event, value, reason, details) => {
|
|
156
155
|
if (typeof value === "object") {
|
|
157
156
|
// Set value
|
|
@@ -194,7 +193,7 @@ export function TiplistPro(props) {
|
|
|
194
193
|
if (typeof item === "string")
|
|
195
194
|
return item;
|
|
196
195
|
if (item["id"] === -1)
|
|
197
|
-
return (more
|
|
196
|
+
return (more ?? "More") + "...";
|
|
198
197
|
if (getOptionLabel == null)
|
|
199
198
|
return DataTypes.getListItemLabel(item);
|
|
200
199
|
return getOptionLabel(item);
|