@etsoo/react 1.5.78 → 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 +6 -6
- package/lib/components/ScrollerList.d.ts +3 -3
- package/lib/index.d.ts +2 -74
- package/lib/index.js +2 -75
- package/lib/notifier/Notifier.d.ts +2 -3
- package/lib/uses/useWindowScroll.d.ts +10 -0
- package/lib/uses/useWindowScroll.js +46 -0
- package/lib/uses/useWindowSize.js +11 -5
- package/package.json +9 -21
- package/src/{mu → components}/DnDList.tsx +11 -34
- package/src/components/GridMethodRef.ts +12 -0
- package/src/components/ScrollerGrid.tsx +6 -6
- package/src/components/ScrollerList.tsx +5 -3
- package/src/index.ts +2 -78
- package/src/notifier/Notifier.ts +2 -3
- package/src/uses/useWindowScroll.ts +60 -0
- package/src/uses/useWindowSize.ts +14 -5
- package/__tests__/mu/MUGlobalTests.tsx +0 -58
- package/__tests__/mu/NotifierMUTests.tsx +0 -213
- package/lib/app/CommonApp.d.ts +0 -39
- package/lib/app/CommonApp.js +0 -149
- package/lib/app/IServiceAppSettings.d.ts +0 -11
- package/lib/app/IServiceAppSettings.js +0 -1
- package/lib/app/IServicePage.d.ts +0 -6
- package/lib/app/IServicePage.js +0 -1
- package/lib/app/IServiceUser.d.ts +0 -14
- package/lib/app/IServiceUser.js +0 -1
- package/lib/app/ISmartERPUser.d.ts +0 -14
- package/lib/app/ISmartERPUser.js +0 -1
- package/lib/app/Labels.d.ts +0 -65
- package/lib/app/Labels.js +0 -62
- package/lib/app/ReactApp.d.ts +0 -194
- package/lib/app/ReactApp.js +0 -298
- package/lib/app/ServiceApp.d.ts +0 -78
- package/lib/app/ServiceApp.js +0 -244
- package/lib/components/ShowDataComparison.d.ts +0 -20
- package/lib/components/ShowDataComparison.js +0 -60
- package/lib/mu/AuditDisplay.d.ts +0 -33
- package/lib/mu/AuditDisplay.js +0 -52
- package/lib/mu/AutocompleteExtendedProps.d.ts +0 -66
- 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 -40
- 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 -55
- package/lib/mu/ItemList.js +0 -77
- 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 -62
- 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 -14
- package/lib/mu/SelectBool.js +0 -22
- package/lib/mu/SelectEx.d.ts +0 -54
- 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 -68
- 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 -84
- 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 -244
- 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 -201
- 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 -218
- 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 -25
- package/src/mu/SelectBool.tsx +0 -40
- package/src/mu/SelectEx.tsx +0 -285
- 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 -561
- 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 -134
- package/src/mu/pages/ListPage.tsx +0 -86
- package/src/mu/pages/ListPageProps.ts +0 -11
- 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 -119
- package/src/mu/pages/TablePageProps.ts +0 -11
- 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/SelectEx.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { Checkbox, FormControl, InputLabel, ListItemText, MenuItem, OutlinedInput, Select } from '@mui/material';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { MUGlobal } from './MUGlobal';
|
|
4
|
-
import { ListItemRightIcon } from './ListItemRightIcon';
|
|
5
|
-
import { Utils } from '@etsoo/shared';
|
|
6
|
-
import { ReactUtils } from '../app/ReactUtils';
|
|
7
|
-
/**
|
|
8
|
-
* Extended select component
|
|
9
|
-
* @param props Props
|
|
10
|
-
* @returns Component
|
|
11
|
-
*/
|
|
12
|
-
export function SelectEx(props) {
|
|
13
|
-
var _a;
|
|
14
|
-
// Destruct
|
|
15
|
-
const { defaultValue, idField = 'id', itemIconRenderer, label, labelField = 'label', loadData, onItemClick, onLoadData, multiple = false, name, options = [], search = false, autoAddBlankItem = search, value, onChange, fullWidth, ...rest } = props;
|
|
16
|
-
// Options state
|
|
17
|
-
const [localOptions, setOptions] = React.useState(options);
|
|
18
|
-
const isMounted = React.useRef(true);
|
|
19
|
-
// When options change
|
|
20
|
-
// [options] will cause infinite loop
|
|
21
|
-
const propertyWay = loadData == null;
|
|
22
|
-
React.useEffect(() => {
|
|
23
|
-
if (propertyWay && options != null)
|
|
24
|
-
setOptions(options);
|
|
25
|
-
}, [JSON.stringify(options), propertyWay]);
|
|
26
|
-
// Local value
|
|
27
|
-
const valueSource = (_a = defaultValue !== null && defaultValue !== void 0 ? defaultValue : value) !== null && _a !== void 0 ? _a : '';
|
|
28
|
-
let localValue;
|
|
29
|
-
if (multiple) {
|
|
30
|
-
if (Array.isArray(valueSource))
|
|
31
|
-
localValue = valueSource;
|
|
32
|
-
else
|
|
33
|
-
localValue = [valueSource];
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
localValue = valueSource;
|
|
37
|
-
}
|
|
38
|
-
// Value state
|
|
39
|
-
const [valueState, setValueState] = React.useState();
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
if (localValue != null)
|
|
42
|
-
setValueState(localValue);
|
|
43
|
-
}, [localValue]);
|
|
44
|
-
// Label id
|
|
45
|
-
const labelId = `selectex-label-${name}`;
|
|
46
|
-
// Item checked or not
|
|
47
|
-
const itemChecked = (id) => {
|
|
48
|
-
if (Array.isArray(valueState))
|
|
49
|
-
return valueState.indexOf(id) !== -1;
|
|
50
|
-
return valueState === id;
|
|
51
|
-
};
|
|
52
|
-
// Change handler
|
|
53
|
-
const handleChange = (event) => {
|
|
54
|
-
const value = event.target.value;
|
|
55
|
-
if (multiple && !Array.isArray(value))
|
|
56
|
-
setItemValue([value]);
|
|
57
|
-
else
|
|
58
|
-
setItemValue(value);
|
|
59
|
-
};
|
|
60
|
-
// Set item
|
|
61
|
-
const setItemValue = (id) => {
|
|
62
|
-
var _a;
|
|
63
|
-
if (id != valueState) {
|
|
64
|
-
setValueState(id);
|
|
65
|
-
const input = (_a = divRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('input');
|
|
66
|
-
if (input) {
|
|
67
|
-
// Different value, trigger change event
|
|
68
|
-
ReactUtils.triggerChange(input, id, false);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
// Get option id
|
|
73
|
-
const getId = (option) => {
|
|
74
|
-
return option[idField];
|
|
75
|
-
};
|
|
76
|
-
// Get option label
|
|
77
|
-
const getLabel = (option) => {
|
|
78
|
-
return typeof labelField === 'function'
|
|
79
|
-
? labelField(option)
|
|
80
|
-
: new String(option[labelField]);
|
|
81
|
-
};
|
|
82
|
-
// Refs
|
|
83
|
-
const divRef = React.useRef();
|
|
84
|
-
// When value change
|
|
85
|
-
React.useEffect(() => {
|
|
86
|
-
if (loadData) {
|
|
87
|
-
loadData().then((result) => {
|
|
88
|
-
if (result == null || !isMounted.current)
|
|
89
|
-
return;
|
|
90
|
-
if (onLoadData)
|
|
91
|
-
onLoadData(result);
|
|
92
|
-
if (autoAddBlankItem) {
|
|
93
|
-
Utils.addBlankItem(result, idField, labelField);
|
|
94
|
-
}
|
|
95
|
-
setOptions(result);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}, [localValue]);
|
|
99
|
-
// When layout ready
|
|
100
|
-
React.useEffect(() => {
|
|
101
|
-
var _a;
|
|
102
|
-
const input = (_a = divRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('input');
|
|
103
|
-
const inputChange = (event) => {
|
|
104
|
-
// Reset case
|
|
105
|
-
if (event.cancelable)
|
|
106
|
-
setValueState(multiple ? [] : '');
|
|
107
|
-
};
|
|
108
|
-
input === null || input === void 0 ? void 0 : input.addEventListener('change', inputChange);
|
|
109
|
-
return () => {
|
|
110
|
-
isMounted.current = false;
|
|
111
|
-
input === null || input === void 0 ? void 0 : input.removeEventListener('change', inputChange);
|
|
112
|
-
};
|
|
113
|
-
}, []);
|
|
114
|
-
// Layout
|
|
115
|
-
return (React.createElement(FormControl, { size: search ? MUGlobal.searchFieldSize : MUGlobal.inputFieldSize, fullWidth: fullWidth },
|
|
116
|
-
React.createElement(InputLabel, { id: labelId, shrink: search
|
|
117
|
-
? MUGlobal.searchFieldShrink
|
|
118
|
-
: MUGlobal.inputFieldShrink }, label),
|
|
119
|
-
React.createElement(Select, { ref: divRef, value: localOptions.some((option) => itemChecked(getId(option)))
|
|
120
|
-
? valueState !== null && valueState !== void 0 ? valueState : ''
|
|
121
|
-
: '', input: React.createElement(OutlinedInput, { notched: true, label: label }), labelId: labelId, name: name, multiple: multiple, onChange: (event, child) => {
|
|
122
|
-
if (onChange)
|
|
123
|
-
onChange(event, child);
|
|
124
|
-
if (multiple)
|
|
125
|
-
handleChange(event);
|
|
126
|
-
}, renderValue: (selected) => {
|
|
127
|
-
// The text shows up
|
|
128
|
-
return localOptions
|
|
129
|
-
.filter((option) => {
|
|
130
|
-
const id = getId(option);
|
|
131
|
-
return Array.isArray(selected)
|
|
132
|
-
? selected.indexOf(id) !== -1
|
|
133
|
-
: selected === id;
|
|
134
|
-
})
|
|
135
|
-
.map((option) => getLabel(option))
|
|
136
|
-
.join(', ');
|
|
137
|
-
}, sx: { minWidth: '150px' }, fullWidth: fullWidth, ...rest }, localOptions.map((option) => {
|
|
138
|
-
// Option id
|
|
139
|
-
const id = getId(option);
|
|
140
|
-
// Option label
|
|
141
|
-
const label = getLabel(option);
|
|
142
|
-
// Option
|
|
143
|
-
return (React.createElement(MenuItem, { key: id, value: id, onClick: (event) => {
|
|
144
|
-
if (onItemClick) {
|
|
145
|
-
onItemClick(event, id);
|
|
146
|
-
if (event.defaultPrevented)
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
if (!multiple)
|
|
150
|
-
setItemValue(id);
|
|
151
|
-
} },
|
|
152
|
-
multiple && React.createElement(Checkbox, { checked: itemChecked(id) }),
|
|
153
|
-
React.createElement(ListItemText, { primary: label }),
|
|
154
|
-
itemIconRenderer && (React.createElement(ListItemRightIcon, null, itemIconRenderer(id)))));
|
|
155
|
-
}))));
|
|
156
|
-
}
|
package/lib/mu/Switch.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { FormControlLabelProps } from '@mui/material';
|
|
3
|
-
/**
|
|
4
|
-
* Switch props
|
|
5
|
-
*/
|
|
6
|
-
export interface SwitchProps extends Omit<FormControlLabelProps, 'control'> {
|
|
7
|
-
/**
|
|
8
|
-
* Value, default 'on'
|
|
9
|
-
*/
|
|
10
|
-
value?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Is the field read only?
|
|
13
|
-
*/
|
|
14
|
-
readOnly?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Size
|
|
17
|
-
*/
|
|
18
|
-
size?: 'small' | 'medium';
|
|
19
|
-
/**
|
|
20
|
-
* Display as Checkbox
|
|
21
|
-
*/
|
|
22
|
-
checkbox?: boolean;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Switch
|
|
26
|
-
* @param props Props
|
|
27
|
-
* @returns Component
|
|
28
|
-
*/
|
|
29
|
-
export declare function Switch(props: SwitchProps): JSX.Element;
|
package/lib/mu/Switch.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FormControlLabel } from '@mui/material';
|
|
3
|
-
import MuiCheckbox from '@mui/material/Checkbox';
|
|
4
|
-
import MuiSwitch from '@mui/material/Switch';
|
|
5
|
-
/**
|
|
6
|
-
* Switch
|
|
7
|
-
* @param props Props
|
|
8
|
-
* @returns Component
|
|
9
|
-
*/
|
|
10
|
-
export function Switch(props) {
|
|
11
|
-
var _a;
|
|
12
|
-
// Destruct
|
|
13
|
-
const { checked, defaultChecked, defaultValue, onChange, readOnly, size, checkbox = false, value = 'true', ...rest } = props;
|
|
14
|
-
// Checked state
|
|
15
|
-
const [controlChecked, setControlChecked] = React.useState((_a = checked !== null && checked !== void 0 ? checked : defaultChecked) !== null && _a !== void 0 ? _a : defaultValue == value);
|
|
16
|
-
React.useEffect(() => {
|
|
17
|
-
if (checked)
|
|
18
|
-
setControlChecked(checked);
|
|
19
|
-
}, [checked]);
|
|
20
|
-
// Handle change
|
|
21
|
-
const handleChange = (event, checked) => {
|
|
22
|
-
if (onChange)
|
|
23
|
-
onChange(event, checked);
|
|
24
|
-
setControlChecked(checked);
|
|
25
|
-
};
|
|
26
|
-
// Control
|
|
27
|
-
const control = checkbox ? (React.createElement(MuiCheckbox, { readOnly: readOnly, checked: controlChecked, onChange: handleChange, size: size, value: value })) : (React.createElement(MuiSwitch, { readOnly: readOnly, checked: controlChecked, onChange: handleChange, size: size, value: value }));
|
|
28
|
-
// Default state
|
|
29
|
-
React.useEffect(() => {
|
|
30
|
-
setControlChecked(controlChecked);
|
|
31
|
-
}, [controlChecked]);
|
|
32
|
-
// Layout
|
|
33
|
-
return React.createElement(FormControlLabel, { control: control, ...rest });
|
|
34
|
-
}
|
package/lib/mu/SwitchAnt.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { SwitchProps } from '@mui/material/Switch';
|
|
3
|
-
/**
|
|
4
|
-
* Ant style switch props
|
|
5
|
-
*/
|
|
6
|
-
export interface SwitchAntProps extends SwitchProps {
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
activeColor?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Start label
|
|
13
|
-
*/
|
|
14
|
-
startLabel: string;
|
|
15
|
-
/**
|
|
16
|
-
* End label
|
|
17
|
-
*/
|
|
18
|
-
endLabel: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Ant style switch
|
|
22
|
-
* @param props Props
|
|
23
|
-
* @returns Component
|
|
24
|
-
*/
|
|
25
|
-
export declare function SwitchAnt(props: SwitchAntProps): JSX.Element;
|
package/lib/mu/SwitchAnt.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Stack, Typography } from '@mui/material';
|
|
2
|
-
import Switch from '@mui/material/Switch';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
/**
|
|
5
|
-
* Ant style switch
|
|
6
|
-
* @param props Props
|
|
7
|
-
* @returns Component
|
|
8
|
-
*/
|
|
9
|
-
export function SwitchAnt(props) {
|
|
10
|
-
var _a;
|
|
11
|
-
// Destruct
|
|
12
|
-
const { activeColor, checked, defaultChecked, defaultValue, endLabel, startLabel, onChange, value = 'true', ...rest } = props;
|
|
13
|
-
// Checked state
|
|
14
|
-
const [controlChecked, setControlChecked] = React.useState((_a = checked !== null && checked !== void 0 ? checked : defaultChecked) !== null && _a !== void 0 ? _a : defaultValue == value);
|
|
15
|
-
React.useEffect(() => {
|
|
16
|
-
if (checked)
|
|
17
|
-
setControlChecked(checked);
|
|
18
|
-
}, [checked]);
|
|
19
|
-
// On change
|
|
20
|
-
const onChangeLocal = (event, checked) => {
|
|
21
|
-
if (onChange)
|
|
22
|
-
onChange(event, checked);
|
|
23
|
-
setControlChecked(checked);
|
|
24
|
-
};
|
|
25
|
-
// Layout
|
|
26
|
-
return (React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
|
|
27
|
-
React.createElement(Typography, { onClick: () => setControlChecked(false), sx: {
|
|
28
|
-
cursor: 'pointer',
|
|
29
|
-
color: controlChecked
|
|
30
|
-
? undefined
|
|
31
|
-
: (theme) => activeColor !== null && activeColor !== void 0 ? activeColor : theme.palette.warning.main
|
|
32
|
-
} }, startLabel),
|
|
33
|
-
React.createElement(Switch, { checked: controlChecked, value: value, onChange: onChangeLocal, ...rest }),
|
|
34
|
-
React.createElement(Typography, { onClick: () => setControlChecked(true), sx: {
|
|
35
|
-
cursor: 'pointer',
|
|
36
|
-
color: controlChecked
|
|
37
|
-
? (theme) => activeColor !== null && activeColor !== void 0 ? activeColor : theme.palette.warning.main
|
|
38
|
-
: undefined
|
|
39
|
-
} }, endLabel)));
|
|
40
|
-
}
|
package/lib/mu/TabBox.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { BoxProps, TabProps, TabsProps } from '@mui/material';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* Tab with box panel props
|
|
5
|
-
*/
|
|
6
|
-
export interface TabBoxPanel extends Omit<TabProps, 'value' | 'children'> {
|
|
7
|
-
/**
|
|
8
|
-
* Children
|
|
9
|
-
*/
|
|
10
|
-
children?: ((visible: boolean) => React.ReactNode) | React.ReactNode;
|
|
11
|
-
/**
|
|
12
|
-
* Panel box props
|
|
13
|
-
*/
|
|
14
|
-
panel?: Omit<BoxProps, 'hidden'>;
|
|
15
|
-
/**
|
|
16
|
-
* To URL
|
|
17
|
-
*/
|
|
18
|
-
to?: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Tabs with box props
|
|
22
|
-
*/
|
|
23
|
-
export interface TabBoxPros extends BoxProps {
|
|
24
|
-
/**
|
|
25
|
-
* Container props
|
|
26
|
-
*/
|
|
27
|
-
container?: Omit<TabsProps, 'value'>;
|
|
28
|
-
/**
|
|
29
|
-
* Default selected index
|
|
30
|
-
*/
|
|
31
|
-
defaultIndex?: number;
|
|
32
|
-
/**
|
|
33
|
-
* Current index
|
|
34
|
-
*/
|
|
35
|
-
index?: number;
|
|
36
|
-
/**
|
|
37
|
-
* Add a hidden input and its name
|
|
38
|
-
*/
|
|
39
|
-
inputName?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Root props
|
|
42
|
-
*/
|
|
43
|
-
root?: BoxProps;
|
|
44
|
-
/**
|
|
45
|
-
* Tabs
|
|
46
|
-
*/
|
|
47
|
-
tabs: TabBoxPanel[];
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Tabs with box
|
|
51
|
-
* @param props Props
|
|
52
|
-
* @returns Component
|
|
53
|
-
*/
|
|
54
|
-
export declare function TabBox(props: TabBoxPros): JSX.Element;
|
package/lib/mu/TabBox.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Utils } from '@etsoo/shared';
|
|
2
|
-
import { Box, Tab, Tabs } from '@mui/material';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { Link } from 'react-router-dom';
|
|
5
|
-
/**
|
|
6
|
-
* Tabs with box
|
|
7
|
-
* @param props Props
|
|
8
|
-
* @returns Component
|
|
9
|
-
*/
|
|
10
|
-
export function TabBox(props) {
|
|
11
|
-
// Destruct
|
|
12
|
-
const { index, inputName, root, container = {}, defaultIndex = 0, tabs } = props;
|
|
13
|
-
const { onChange, ...rest } = container;
|
|
14
|
-
// State
|
|
15
|
-
const [value, setValue] = React.useState(defaultIndex);
|
|
16
|
-
React.useEffect(() => {
|
|
17
|
-
if (index == null)
|
|
18
|
-
return;
|
|
19
|
-
setValue(index);
|
|
20
|
-
}, [index]);
|
|
21
|
-
// Layout
|
|
22
|
-
return (React.createElement(React.Fragment, null,
|
|
23
|
-
inputName && (React.createElement("input", { type: "hidden", name: inputName, value: value })),
|
|
24
|
-
React.createElement(Box, { ...root },
|
|
25
|
-
React.createElement(Tabs, { value: value, onChange: (event, newValue) => {
|
|
26
|
-
setValue(newValue);
|
|
27
|
-
if (onChange)
|
|
28
|
-
onChange(event, newValue);
|
|
29
|
-
}, ...rest }, tabs.map(({ children, panel, ...tabRest }, index) => (React.createElement(Tab, { key: index, value: index, LinkComponent: tabRest.to ? Link : undefined, ...tabRest }))))),
|
|
30
|
-
tabs.map(({ children, panel }, index) => (React.createElement(Box, { key: index, hidden: value !== index, ...panel }, Utils.getResult(children, value === index))))));
|
|
31
|
-
}
|
package/lib/mu/TableEx.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
|
-
import { TableProps } from '@mui/material';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { GridColumn } from '../components/GridColumn';
|
|
5
|
-
import { GridLoader } from '../components/GridLoader';
|
|
6
|
-
import { GridMethodRef } from './GridMethodRef';
|
|
7
|
-
/**
|
|
8
|
-
* Extended table min width for width-unset column
|
|
9
|
-
*/
|
|
10
|
-
export declare const TableExMinWidth: number;
|
|
11
|
-
/**
|
|
12
|
-
* Extended table methods ref
|
|
13
|
-
*/
|
|
14
|
-
export interface TableExMethodRef extends GridMethodRef {
|
|
15
|
-
/**
|
|
16
|
-
* Refresh data
|
|
17
|
-
*/
|
|
18
|
-
refresh(): void;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Extended table props
|
|
22
|
-
*/
|
|
23
|
-
export declare type TableExProps<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> = TableProps & GridLoader<T> & {
|
|
24
|
-
/**
|
|
25
|
-
* Alternating colors for odd/even rows
|
|
26
|
-
*/
|
|
27
|
-
alternatingColors?: [string?, string?];
|
|
28
|
-
/**
|
|
29
|
-
* Columns
|
|
30
|
-
*/
|
|
31
|
-
columns: GridColumn<T>[];
|
|
32
|
-
/**
|
|
33
|
-
* Header cells background color and font color
|
|
34
|
-
*/
|
|
35
|
-
headerColors?: [string?, string?];
|
|
36
|
-
/**
|
|
37
|
-
* Max height
|
|
38
|
-
*/
|
|
39
|
-
maxHeight?: number;
|
|
40
|
-
/**
|
|
41
|
-
* Methods
|
|
42
|
-
*/
|
|
43
|
-
mRef?: React.Ref<TableExMethodRef>;
|
|
44
|
-
/**
|
|
45
|
-
* On items select change
|
|
46
|
-
*/
|
|
47
|
-
onSelectChange?: (selectedItems: T[]) => void;
|
|
48
|
-
/**
|
|
49
|
-
* Row height
|
|
50
|
-
*/
|
|
51
|
-
rowHeight?: number;
|
|
52
|
-
/**
|
|
53
|
-
* Header and bottom height
|
|
54
|
-
*/
|
|
55
|
-
otherHeight?: number;
|
|
56
|
-
} & (T extends {
|
|
57
|
-
id: DataTypes.IdType;
|
|
58
|
-
} ? {
|
|
59
|
-
idField?: D;
|
|
60
|
-
} : {
|
|
61
|
-
idField: D;
|
|
62
|
-
});
|
|
63
|
-
/**
|
|
64
|
-
* Extended Table
|
|
65
|
-
* @param props Props
|
|
66
|
-
* @returns Component
|
|
67
|
-
*/
|
|
68
|
-
export declare function TableEx<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: TableExProps<T, D>): JSX.Element;
|