@etsoo/materialui 1.0.1
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/.eslintignore +3 -0
- package/.eslintrc.json +38 -0
- package/.gitattributes +2 -0
- package/.github/workflows/main.yml +48 -0
- package/.prettierignore +5 -0
- package/.prettierrc +6 -0
- package/LICENSE +21 -0
- package/README.md +16 -0
- package/__tests__/ComboBox.tsx +30 -0
- package/__tests__/MUGlobalTests.tsx +58 -0
- package/__tests__/NotifierMUTests.tsx +217 -0
- package/__tests__/SelectEx.tsx +26 -0
- package/__tests__/tsconfig.json +19 -0
- package/babel.config.json +11 -0
- package/lib/AuditDisplay.d.ts +33 -0
- package/lib/AuditDisplay.js +52 -0
- package/lib/AutocompleteExtendedProps.d.ts +64 -0
- package/lib/AutocompleteExtendedProps.js +1 -0
- package/lib/BackButton.d.ts +13 -0
- package/lib/BackButton.js +33 -0
- package/lib/BridgeCloseButton.d.ts +23 -0
- package/lib/BridgeCloseButton.js +32 -0
- package/lib/ButtonLink.d.ts +17 -0
- package/lib/ButtonLink.js +19 -0
- package/lib/ComboBox.d.ts +38 -0
- package/lib/ComboBox.js +108 -0
- package/lib/CountdownButton.d.ts +23 -0
- package/lib/CountdownButton.js +81 -0
- package/lib/CustomFabProps.d.ts +27 -0
- package/lib/CustomFabProps.js +1 -0
- package/lib/DataGridEx.d.ts +94 -0
- package/lib/DataGridEx.js +329 -0
- package/lib/DataGridRenderers.d.ts +22 -0
- package/lib/DataGridRenderers.js +99 -0
- package/lib/DialogButton.d.ts +54 -0
- package/lib/DialogButton.js +45 -0
- package/lib/DnDList.d.ts +87 -0
- package/lib/DnDList.js +153 -0
- package/lib/DraggablePaperComponent.d.ts +8 -0
- package/lib/DraggablePaperComponent.js +12 -0
- package/lib/EmailInput.d.ts +11 -0
- package/lib/EmailInput.js +15 -0
- package/lib/FabBox.d.ts +21 -0
- package/lib/FabBox.js +31 -0
- package/lib/FlexBox.d.ts +14 -0
- package/lib/FlexBox.js +18 -0
- package/lib/GridDataFormat.d.ts +10 -0
- package/lib/GridDataFormat.js +43 -0
- package/lib/IconButtonLink.d.ts +17 -0
- package/lib/IconButtonLink.js +16 -0
- package/lib/InputField.d.ts +21 -0
- package/lib/InputField.js +39 -0
- package/lib/ItemList.d.ts +56 -0
- package/lib/ItemList.js +69 -0
- package/lib/ListItemRightIcon.d.ts +4 -0
- package/lib/ListItemRightIcon.js +8 -0
- package/lib/ListMoreDisplay.d.ts +35 -0
- package/lib/ListMoreDisplay.js +99 -0
- package/lib/LoadingButton.d.ts +16 -0
- package/lib/LoadingButton.js +41 -0
- package/lib/MUGlobal.d.ts +102 -0
- package/lib/MUGlobal.js +184 -0
- package/lib/MaskInput.d.ts +34 -0
- package/lib/MaskInput.js +43 -0
- package/lib/MobileListItemRenderer.d.ts +17 -0
- package/lib/MobileListItemRenderer.js +35 -0
- package/lib/MoreFab.d.ts +45 -0
- package/lib/MoreFab.js +95 -0
- package/lib/NotifierMU.d.ts +47 -0
- package/lib/NotifierMU.js +387 -0
- package/lib/NotifierPromptProps.d.ts +22 -0
- package/lib/NotifierPromptProps.js +1 -0
- package/lib/OptionGroup.d.ts +58 -0
- package/lib/OptionGroup.js +81 -0
- package/lib/PList.d.ts +15 -0
- package/lib/PList.js +12 -0
- package/lib/ProgressCount.d.ts +44 -0
- package/lib/ProgressCount.js +79 -0
- package/lib/PullToRefreshUI.d.ts +9 -0
- package/lib/PullToRefreshUI.js +18 -0
- package/lib/RLink.d.ts +14 -0
- package/lib/RLink.js +37 -0
- package/lib/ResponsibleContainer.d.ts +87 -0
- package/lib/ResponsibleContainer.js +156 -0
- package/lib/ScrollTopFab.d.ts +7 -0
- package/lib/ScrollTopFab.js +25 -0
- package/lib/ScrollerListEx.d.ts +81 -0
- package/lib/ScrollerListEx.js +167 -0
- package/lib/SearchBar.d.ts +29 -0
- package/lib/SearchBar.js +260 -0
- package/lib/SearchField.d.ts +21 -0
- package/lib/SearchField.js +39 -0
- package/lib/SearchOptionGroup.d.ts +9 -0
- package/lib/SearchOptionGroup.js +14 -0
- package/lib/SelectBool.d.ts +13 -0
- package/lib/SelectBool.js +22 -0
- package/lib/SelectEx.d.ts +50 -0
- package/lib/SelectEx.js +156 -0
- package/lib/ShowDataComparison.d.ts +20 -0
- package/lib/ShowDataComparison.js +58 -0
- package/lib/Switch.d.ts +29 -0
- package/lib/Switch.js +34 -0
- package/lib/SwitchAnt.d.ts +25 -0
- package/lib/SwitchAnt.js +40 -0
- package/lib/TabBox.d.ts +54 -0
- package/lib/TabBox.js +31 -0
- package/lib/TableEx.d.ts +65 -0
- package/lib/TableEx.js +270 -0
- package/lib/TextFieldEx.d.ts +101 -0
- package/lib/TextFieldEx.js +126 -0
- package/lib/Tiplist.d.ts +18 -0
- package/lib/Tiplist.js +157 -0
- package/lib/TooltipClick.d.ts +15 -0
- package/lib/TooltipClick.js +40 -0
- package/lib/UserAvatar.d.ts +24 -0
- package/lib/UserAvatar.js +25 -0
- package/lib/UserAvatarEditor.d.ts +53 -0
- package/lib/UserAvatarEditor.js +129 -0
- package/lib/app/CommonApp.d.ts +38 -0
- package/lib/app/CommonApp.js +149 -0
- package/lib/app/IServiceAppSettings.d.ts +11 -0
- package/lib/app/IServiceAppSettings.js +1 -0
- package/lib/app/IServicePage.d.ts +6 -0
- package/lib/app/IServicePage.js +1 -0
- package/lib/app/IServiceUser.d.ts +14 -0
- package/lib/app/IServiceUser.js +1 -0
- package/lib/app/ISmartERPUser.d.ts +14 -0
- package/lib/app/ISmartERPUser.js +1 -0
- package/lib/app/Labels.d.ts +65 -0
- package/lib/app/Labels.js +62 -0
- package/lib/app/ReactApp.d.ts +195 -0
- package/lib/app/ReactApp.js +296 -0
- package/lib/app/ServiceApp.d.ts +78 -0
- package/lib/app/ServiceApp.js +244 -0
- package/lib/index.d.ts +74 -0
- package/lib/index.js +74 -0
- package/lib/pages/CommonPage.d.ts +11 -0
- package/lib/pages/CommonPage.js +60 -0
- package/lib/pages/CommonPageProps.d.ts +59 -0
- package/lib/pages/CommonPageProps.js +1 -0
- package/lib/pages/DataGridPage.d.ts +9 -0
- package/lib/pages/DataGridPage.js +79 -0
- package/lib/pages/DataGridPageProps.d.ts +17 -0
- package/lib/pages/DataGridPageProps.js +1 -0
- package/lib/pages/EditPage.d.ts +33 -0
- package/lib/pages/EditPage.js +29 -0
- package/lib/pages/FixedListPage.d.ts +15 -0
- package/lib/pages/FixedListPage.js +70 -0
- package/lib/pages/ListPage.d.ts +9 -0
- package/lib/pages/ListPage.js +50 -0
- package/lib/pages/ListPageProps.d.ts +7 -0
- package/lib/pages/ListPageProps.js +1 -0
- package/lib/pages/ResponsivePage.d.ts +9 -0
- package/lib/pages/ResponsivePage.js +45 -0
- package/lib/pages/ResponsivePageProps.d.ts +39 -0
- package/lib/pages/ResponsivePageProps.js +1 -0
- package/lib/pages/SearchPageProps.d.ts +30 -0
- package/lib/pages/SearchPageProps.js +1 -0
- package/lib/pages/TablePage.d.ts +9 -0
- package/lib/pages/TablePage.js +69 -0
- package/lib/pages/TablePageProps.d.ts +7 -0
- package/lib/pages/TablePageProps.js +1 -0
- package/lib/pages/ViewPage.d.ts +66 -0
- package/lib/pages/ViewPage.js +105 -0
- package/lib/texts/DateText.d.ts +34 -0
- package/lib/texts/DateText.js +25 -0
- package/lib/texts/MoneyText.d.ts +21 -0
- package/lib/texts/MoneyText.js +14 -0
- package/lib/texts/NumberText.d.ts +25 -0
- package/lib/texts/NumberText.js +14 -0
- package/package.json +97 -0
- package/src/AuditDisplay.tsx +114 -0
- package/src/AutocompleteExtendedProps.ts +83 -0
- package/src/BackButton.tsx +55 -0
- package/src/BridgeCloseButton.tsx +69 -0
- package/src/ButtonLink.tsx +32 -0
- package/src/ComboBox.tsx +251 -0
- package/src/CountdownButton.tsx +119 -0
- package/src/CustomFabProps.ts +32 -0
- package/src/DataGridEx.tsx +713 -0
- package/src/DataGridRenderers.tsx +140 -0
- package/src/DialogButton.tsx +163 -0
- package/src/DnDList.tsx +344 -0
- package/src/DraggablePaperComponent.tsx +19 -0
- package/src/EmailInput.tsx +24 -0
- package/src/FabBox.tsx +51 -0
- package/src/FlexBox.tsx +20 -0
- package/src/GridDataFormat.tsx +77 -0
- package/src/IconButtonLink.tsx +29 -0
- package/src/InputField.tsx +82 -0
- package/src/ItemList.tsx +204 -0
- package/src/ListItemRightIcon.tsx +9 -0
- package/src/ListMoreDisplay.tsx +205 -0
- package/src/LoadingButton.tsx +75 -0
- package/src/MUGlobal.ts +220 -0
- package/src/MaskInput.tsx +107 -0
- package/src/MobileListItemRenderer.tsx +79 -0
- package/src/MoreFab.tsx +211 -0
- package/src/NotifierMU.tsx +654 -0
- package/src/NotifierPromptProps.ts +24 -0
- package/src/OptionGroup.tsx +223 -0
- package/src/PList.tsx +27 -0
- package/src/ProgressCount.tsx +166 -0
- package/src/PullToRefreshUI.tsx +21 -0
- package/src/RLink.tsx +64 -0
- package/src/ResponsibleContainer.tsx +394 -0
- package/src/ScrollTopFab.tsx +34 -0
- package/src/ScrollerListEx.tsx +387 -0
- package/src/SearchBar.tsx +396 -0
- package/src/SearchField.tsx +82 -0
- package/src/SearchOptionGroup.tsx +31 -0
- package/src/SelectBool.tsx +33 -0
- package/src/SelectEx.tsx +290 -0
- package/src/ShowDataComparison.tsx +106 -0
- package/src/Switch.tsx +94 -0
- package/src/SwitchAnt.tsx +95 -0
- package/src/TabBox.tsx +118 -0
- package/src/TableEx.tsx +558 -0
- package/src/TextFieldEx.tsx +249 -0
- package/src/Tiplist.tsx +303 -0
- package/src/TooltipClick.tsx +84 -0
- package/src/UserAvatar.tsx +64 -0
- package/src/UserAvatarEditor.tsx +287 -0
- package/src/app/CommonApp.ts +223 -0
- package/src/app/IServiceAppSettings.ts +13 -0
- package/src/app/IServicePage.ts +6 -0
- package/src/app/IServiceUser.ts +17 -0
- package/src/app/ISmartERPUser.ts +16 -0
- package/src/app/Labels.ts +77 -0
- package/src/app/ReactApp.ts +504 -0
- package/src/app/ServiceApp.ts +352 -0
- package/src/index.ts +77 -0
- package/src/pages/CommonPage.tsx +128 -0
- package/src/pages/CommonPageProps.ts +70 -0
- package/src/pages/DataGridPage.tsx +140 -0
- package/src/pages/DataGridPageProps.ts +24 -0
- package/src/pages/EditPage.tsx +114 -0
- package/src/pages/FixedListPage.tsx +141 -0
- package/src/pages/ListPage.tsx +90 -0
- package/src/pages/ListPageProps.ts +12 -0
- package/src/pages/ResponsivePage.tsx +68 -0
- package/src/pages/ResponsivePageProps.ts +57 -0
- package/src/pages/SearchPageProps.ts +39 -0
- package/src/pages/TablePage.tsx +126 -0
- package/src/pages/TablePageProps.ts +12 -0
- package/src/pages/ViewPage.tsx +282 -0
- package/src/texts/DateText.tsx +74 -0
- package/src/texts/MoneyText.tsx +49 -0
- package/src/texts/NumberText.tsx +40 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IconButton, useTheme } from '@mui/material';
|
|
2
|
+
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { useNavigate } from 'react-router-dom';
|
|
5
|
+
/**
|
|
6
|
+
* BackButton
|
|
7
|
+
* @param props Props
|
|
8
|
+
* @returns Component
|
|
9
|
+
*/
|
|
10
|
+
export function BackButton(props) {
|
|
11
|
+
// Destruct
|
|
12
|
+
const { color = 'primary', size = 'small', onClick, ...rest } = props;
|
|
13
|
+
// Theme
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
// Navigate
|
|
16
|
+
const navigate = useNavigate();
|
|
17
|
+
// Color
|
|
18
|
+
const pColor = color != 'inherit' && color != 'default' && color in theme.palette
|
|
19
|
+
? theme.palette[color]
|
|
20
|
+
: theme.palette.primary;
|
|
21
|
+
// Click handler
|
|
22
|
+
const onClickLocal = async (event) => {
|
|
23
|
+
if (onClick)
|
|
24
|
+
onClick(event);
|
|
25
|
+
// Navigate
|
|
26
|
+
navigate(-1);
|
|
27
|
+
};
|
|
28
|
+
return (React.createElement(IconButton, { "aria-label": "Back", color: color, size: size, onClick: onClickLocal, sx: {
|
|
29
|
+
backgroundColor: pColor.contrastText,
|
|
30
|
+
border: `1px solid ${pColor.light}`
|
|
31
|
+
}, ...rest },
|
|
32
|
+
React.createElement(ArrowBackIcon, null)));
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IBridgeHost } from '@etsoo/appscript';
|
|
3
|
+
import { BoxProps, IconButtonProps } from '@mui/material';
|
|
4
|
+
/**
|
|
5
|
+
* Bridge close button props
|
|
6
|
+
*/
|
|
7
|
+
export interface BridgeCloseButtonProps extends IconButtonProps {
|
|
8
|
+
/**
|
|
9
|
+
* Box props
|
|
10
|
+
*/
|
|
11
|
+
boxProps?: BoxProps;
|
|
12
|
+
/**
|
|
13
|
+
* Validate the host
|
|
14
|
+
* @param host Host
|
|
15
|
+
*/
|
|
16
|
+
validate?(host: IBridgeHost): boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Bridge close button
|
|
20
|
+
* @param props Props
|
|
21
|
+
* @returns Component
|
|
22
|
+
*/
|
|
23
|
+
export declare function BridgeCloseButton(props: BridgeCloseButtonProps): JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BridgeUtils } from '@etsoo/appscript';
|
|
2
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
3
|
+
import { Box, IconButton } from '@mui/material';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { globalApp } from './app/ReactApp';
|
|
6
|
+
/**
|
|
7
|
+
* Bridge close button
|
|
8
|
+
* @param props Props
|
|
9
|
+
* @returns Component
|
|
10
|
+
*/
|
|
11
|
+
export function BridgeCloseButton(props) {
|
|
12
|
+
// Destruct
|
|
13
|
+
const { boxProps, onClick, title = typeof globalApp === 'undefined'
|
|
14
|
+
? 'Close'
|
|
15
|
+
: globalApp.get('close'), validate, ...rest } = props;
|
|
16
|
+
// Host
|
|
17
|
+
const host = BridgeUtils.host;
|
|
18
|
+
if (host == null ||
|
|
19
|
+
!host.closable() ||
|
|
20
|
+
(validate && validate(host) === false)) {
|
|
21
|
+
return React.createElement(React.Fragment, null);
|
|
22
|
+
}
|
|
23
|
+
// Click handler
|
|
24
|
+
const onClickLocal = (event) => {
|
|
25
|
+
if (onClick)
|
|
26
|
+
onClick(event);
|
|
27
|
+
host.exit();
|
|
28
|
+
};
|
|
29
|
+
return (React.createElement(Box, { ...boxProps },
|
|
30
|
+
React.createElement(IconButton, { "aria-label": "close", onClick: onClickLocal, title: title, ...rest },
|
|
31
|
+
React.createElement(CloseIcon, null))));
|
|
32
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ButtonProps } from '@mui/material';
|
|
3
|
+
/**
|
|
4
|
+
* ButtonLink props
|
|
5
|
+
*/
|
|
6
|
+
export declare type ButtonLinkProps = Omit<ButtonProps, 'href' | 'onClick'> & {
|
|
7
|
+
/**
|
|
8
|
+
* To href
|
|
9
|
+
*/
|
|
10
|
+
href: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* ButtonLink
|
|
14
|
+
* @param props Props
|
|
15
|
+
* @returns Component
|
|
16
|
+
*/
|
|
17
|
+
export declare function ButtonLink(props: ButtonLinkProps): JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Button } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useNavigate } from 'react-router-dom';
|
|
4
|
+
/**
|
|
5
|
+
* ButtonLink
|
|
6
|
+
* @param props Props
|
|
7
|
+
* @returns Component
|
|
8
|
+
*/
|
|
9
|
+
export function ButtonLink(props) {
|
|
10
|
+
// Destruct
|
|
11
|
+
const { href, ...rest } = props;
|
|
12
|
+
// Navigate
|
|
13
|
+
const navigate = useNavigate();
|
|
14
|
+
const onClick = href.includes('://')
|
|
15
|
+
? () => window.open(href, '_blank')
|
|
16
|
+
: () => navigate(href);
|
|
17
|
+
// Layout
|
|
18
|
+
return React.createElement(Button, { ...rest, onClick: onClick });
|
|
19
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DataTypes, IdDefaultType, LabelDefaultType, ListType } from '@etsoo/shared';
|
|
3
|
+
import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
|
|
4
|
+
/**
|
|
5
|
+
* ComboBox props
|
|
6
|
+
*/
|
|
7
|
+
export declare type ComboBoxProps<T extends object, D extends DataTypes.Keys<T>, L extends DataTypes.Keys<T, string>> = AutocompleteExtendedProps<T, D> & {
|
|
8
|
+
/**
|
|
9
|
+
* Auto add blank item
|
|
10
|
+
*/
|
|
11
|
+
autoAddBlankItem?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Data readonly
|
|
14
|
+
*/
|
|
15
|
+
dataReadonly?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Label field
|
|
18
|
+
*/
|
|
19
|
+
labelField?: L;
|
|
20
|
+
/**
|
|
21
|
+
* Load data callback
|
|
22
|
+
*/
|
|
23
|
+
loadData?: () => PromiseLike<T[] | null | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* On load data handler
|
|
26
|
+
*/
|
|
27
|
+
onLoadData?: (options: T[]) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Array of options.
|
|
30
|
+
*/
|
|
31
|
+
options?: ReadonlyArray<T>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* ComboBox
|
|
35
|
+
* @param props Props
|
|
36
|
+
* @returns Component
|
|
37
|
+
*/
|
|
38
|
+
export declare function ComboBox<T extends object = ListType, D extends DataTypes.Keys<T> = IdDefaultType<T>, L extends DataTypes.Keys<T, string> = LabelDefaultType<T>>(props: ComboBoxProps<T, D, L>): JSX.Element;
|
package/lib/ComboBox.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Keyboard } from '@etsoo/shared';
|
|
2
|
+
import { Autocomplete } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Utils as SharedUtils } from '@etsoo/shared';
|
|
5
|
+
import { InputField } from './InputField';
|
|
6
|
+
import { SearchField } from './SearchField';
|
|
7
|
+
import { ReactUtils } from '@etsoo/react';
|
|
8
|
+
/**
|
|
9
|
+
* ComboBox
|
|
10
|
+
* @param props Props
|
|
11
|
+
* @returns Component
|
|
12
|
+
*/
|
|
13
|
+
export function ComboBox(props) {
|
|
14
|
+
// Destruct
|
|
15
|
+
const { search = false, autoAddBlankItem = search, idField = 'id', idValue, inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, defaultValue, label, labelField = 'label', loadData, onLoadData, name, inputAutoComplete = 'off', options, dataReadonly = true, readOnly, onChange, openOnFocus = true, value, getOptionLabel = (option) => `${option[labelField]}`, sx = { minWidth: '150px' }, ...rest } = props;
|
|
16
|
+
// Value input ref
|
|
17
|
+
const inputRef = React.createRef();
|
|
18
|
+
// Options state
|
|
19
|
+
const [localOptions, setOptions] = React.useState(options !== null && options !== void 0 ? options : []);
|
|
20
|
+
const isMounted = React.useRef(true);
|
|
21
|
+
// When options change
|
|
22
|
+
// [options] will cause infinite loop
|
|
23
|
+
const propertyWay = loadData == null;
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
if (propertyWay && options != null)
|
|
26
|
+
setOptions(options);
|
|
27
|
+
}, [JSON.stringify(options), propertyWay]);
|
|
28
|
+
// Local default value
|
|
29
|
+
let localValue = idValue != null
|
|
30
|
+
? localOptions.find((o) => o[idField] === idValue)
|
|
31
|
+
: defaultValue !== null && defaultValue !== void 0 ? defaultValue : value;
|
|
32
|
+
if (localValue === undefined)
|
|
33
|
+
localValue = null;
|
|
34
|
+
// State
|
|
35
|
+
// null for controlled
|
|
36
|
+
const [stateValue, setStateValue] = React.useState(null);
|
|
37
|
+
// Current id value
|
|
38
|
+
// One time calculation for input's default value (uncontrolled)
|
|
39
|
+
const localIdValue = stateValue && stateValue[idField];
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
if (localValue != null)
|
|
42
|
+
setStateValue(localValue);
|
|
43
|
+
}, [localValue]);
|
|
44
|
+
// Add readOnly
|
|
45
|
+
const addReadOnly = (params) => {
|
|
46
|
+
if (readOnly != null) {
|
|
47
|
+
Object.assign(params, { readOnly });
|
|
48
|
+
if (readOnly) {
|
|
49
|
+
Object.assign(params.inputProps, { 'data-reset': true });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (dataReadonly) {
|
|
53
|
+
params.inputProps.onKeyDown = (event) => {
|
|
54
|
+
if (Keyboard.isTypingContent(event.key)) {
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// https://stackoverflow.com/questions/15738259/disabling-chrome-autofill
|
|
60
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html
|
|
61
|
+
Object.assign(params.inputProps, { autoComplete: inputAutoComplete });
|
|
62
|
+
return params;
|
|
63
|
+
};
|
|
64
|
+
const setInputValue = (value) => {
|
|
65
|
+
// Set state
|
|
66
|
+
setStateValue(value);
|
|
67
|
+
// Input value
|
|
68
|
+
const input = inputRef.current;
|
|
69
|
+
if (input) {
|
|
70
|
+
// Update value
|
|
71
|
+
const newValue = value != null ? `${value[idField]}` : '';
|
|
72
|
+
if (newValue !== input.value) {
|
|
73
|
+
// Different value, trigger change event
|
|
74
|
+
ReactUtils.triggerChange(input, newValue, false);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
// When value change
|
|
79
|
+
React.useEffect(() => {
|
|
80
|
+
if (loadData) {
|
|
81
|
+
loadData().then((result) => {
|
|
82
|
+
if (result == null || !isMounted.current)
|
|
83
|
+
return;
|
|
84
|
+
if (onLoadData)
|
|
85
|
+
onLoadData(result);
|
|
86
|
+
if (autoAddBlankItem) {
|
|
87
|
+
SharedUtils.addBlankItem(result, idField, labelField);
|
|
88
|
+
}
|
|
89
|
+
setOptions(result);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}, [localValue]);
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
return () => {
|
|
95
|
+
isMounted.current = false;
|
|
96
|
+
};
|
|
97
|
+
}, []);
|
|
98
|
+
// Layout
|
|
99
|
+
return (React.createElement("div", null,
|
|
100
|
+
React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: `${localIdValue !== null && localIdValue !== void 0 ? localIdValue : ''}`, readOnly: true, onChange: inputOnChange }),
|
|
101
|
+
React.createElement(Autocomplete, { value: stateValue, getOptionLabel: getOptionLabel, isOptionEqualToValue: (option, value) => option[idField] === value[idField], onChange: (event, value, reason, details) => {
|
|
102
|
+
// Set value
|
|
103
|
+
setInputValue(value);
|
|
104
|
+
// Custom
|
|
105
|
+
if (onChange != null)
|
|
106
|
+
onChange(event, value, reason, details);
|
|
107
|
+
}, openOnFocus: openOnFocus, sx: sx, renderInput: (params) => search ? (React.createElement(SearchField, { ...addReadOnly(params), label: label, name: name + 'Input', margin: inputMargin, variant: inputVariant, required: inputRequired, error: inputError, helperText: inputHelperText })) : (React.createElement(InputField, { ...addReadOnly(params), label: label, name: name + 'Input', margin: inputMargin, variant: inputVariant, required: inputRequired, error: inputError, helperText: inputHelperText })), options: localOptions, ...rest })));
|
|
108
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ButtonProps } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Countdown button action
|
|
5
|
+
*/
|
|
6
|
+
export interface CountdownButtonAction {
|
|
7
|
+
(): Promise<number>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Countdown button props
|
|
11
|
+
*/
|
|
12
|
+
export declare type CountdownButtonProps = Omit<ButtonProps, 'endIcon' | 'disabled'> & {
|
|
13
|
+
/**
|
|
14
|
+
* Action, required
|
|
15
|
+
*/
|
|
16
|
+
onAction: CountdownButtonAction;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Countdown button
|
|
20
|
+
* @param props Props
|
|
21
|
+
* @returns Button
|
|
22
|
+
*/
|
|
23
|
+
export declare const CountdownButton: React.ForwardRefExoticComponent<Pick<CountdownButtonProps, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "form" | "slot" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "type" | "size" | "name" | "href" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "value" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "fullWidth" | "startIcon" | "onAction"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Button, CircularProgress } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Countdown button
|
|
5
|
+
* @param props Props
|
|
6
|
+
* @returns Button
|
|
7
|
+
*/
|
|
8
|
+
export const CountdownButton = React.forwardRef((props, ref) => {
|
|
9
|
+
// Destructure
|
|
10
|
+
const { onAction, onClick, ...rest } = props;
|
|
11
|
+
// State
|
|
12
|
+
// 0 - normal
|
|
13
|
+
// 1 - loading
|
|
14
|
+
// 2 - countdown
|
|
15
|
+
const [state, updateState] = React.useState(0);
|
|
16
|
+
// Ignore seconds
|
|
17
|
+
const seconds = 2;
|
|
18
|
+
// Countdown length
|
|
19
|
+
const [shared] = React.useState({ maxLength: 0 });
|
|
20
|
+
const isMounted = React.useRef(true);
|
|
21
|
+
// endIcon
|
|
22
|
+
let endIcon;
|
|
23
|
+
if (state === 0) {
|
|
24
|
+
endIcon = undefined;
|
|
25
|
+
}
|
|
26
|
+
else if (state === 1) {
|
|
27
|
+
endIcon = React.createElement(CircularProgress, { size: 12 });
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const countdown = (state - seconds)
|
|
31
|
+
.toString()
|
|
32
|
+
.padStart(shared.maxLength, '0');
|
|
33
|
+
endIcon = React.createElement("span", { style: { fontSize: 'smaller' } }, countdown);
|
|
34
|
+
}
|
|
35
|
+
// Disabled?
|
|
36
|
+
const disabled = state > 0;
|
|
37
|
+
// Action
|
|
38
|
+
const doAction = (result) => {
|
|
39
|
+
// Seconds to wait, 120
|
|
40
|
+
if (result > seconds) {
|
|
41
|
+
// Here 122
|
|
42
|
+
result += seconds;
|
|
43
|
+
updateState(result);
|
|
44
|
+
// Update max length
|
|
45
|
+
shared.maxLength = result.toString().length;
|
|
46
|
+
const seed = setInterval(() => {
|
|
47
|
+
// Mounted?
|
|
48
|
+
if (!isMounted.current)
|
|
49
|
+
return;
|
|
50
|
+
// Last 1 second and then complete
|
|
51
|
+
if (result > seconds + 1) {
|
|
52
|
+
result--;
|
|
53
|
+
updateState(result);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
clearInterval(seed);
|
|
57
|
+
updateState(0);
|
|
58
|
+
}
|
|
59
|
+
}, 1000);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
updateState(0);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
// Local click
|
|
66
|
+
const localClick = (event) => {
|
|
67
|
+
// Show loading
|
|
68
|
+
updateState(1);
|
|
69
|
+
// Callback
|
|
70
|
+
if (onClick != null)
|
|
71
|
+
onClick(event);
|
|
72
|
+
// Return any countdown
|
|
73
|
+
onAction().then(doAction);
|
|
74
|
+
};
|
|
75
|
+
React.useEffect(() => {
|
|
76
|
+
return () => {
|
|
77
|
+
isMounted.current = false;
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
80
|
+
return (React.createElement(Button, { disabled: disabled, endIcon: endIcon, onClick: localClick, ref: ref, ...rest }));
|
|
81
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FabPropsColorOverrides, PropTypes } from '@mui/material';
|
|
2
|
+
import { OverridableStringUnion } from '@mui/types';
|
|
3
|
+
/**
|
|
4
|
+
* Custom fab size
|
|
5
|
+
*/
|
|
6
|
+
export declare type CustomFabSize = 'small' | 'medium' | 'large';
|
|
7
|
+
/**
|
|
8
|
+
* Custom fab props
|
|
9
|
+
*/
|
|
10
|
+
export interface CustomFabProps {
|
|
11
|
+
/**
|
|
12
|
+
* Color
|
|
13
|
+
*/
|
|
14
|
+
color?: OverridableStringUnion<PropTypes.Color, FabPropsColorOverrides>;
|
|
15
|
+
/**
|
|
16
|
+
* Fab size
|
|
17
|
+
*/
|
|
18
|
+
size?: CustomFabSize;
|
|
19
|
+
/**
|
|
20
|
+
* Scroll target
|
|
21
|
+
*/
|
|
22
|
+
target?: any;
|
|
23
|
+
/**
|
|
24
|
+
* Fab title
|
|
25
|
+
*/
|
|
26
|
+
title?: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { GridColumn, GridLoaderStates, ScrollerGridProps } from '@etsoo/react';
|
|
2
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { MouseEventWithDataHandler } from './MUGlobal';
|
|
5
|
+
/**
|
|
6
|
+
* Footer item renderer props
|
|
7
|
+
*/
|
|
8
|
+
export declare type DataGridExFooterItemRendererProps<T extends object> = {
|
|
9
|
+
column: GridColumn<T>;
|
|
10
|
+
index: number;
|
|
11
|
+
states: GridLoaderStates<T>;
|
|
12
|
+
cellProps: any;
|
|
13
|
+
checkable: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Extended DataGrid with VariableSizeGrid props
|
|
17
|
+
*/
|
|
18
|
+
export declare type DataGridExProps<T extends object, D extends DataTypes.Keys<T>> = Omit<ScrollerGridProps<T, D>, 'itemRenderer' | 'columnCount' | 'columnWidth' | 'width'> & {
|
|
19
|
+
/**
|
|
20
|
+
* Alternating colors for odd/even rows
|
|
21
|
+
*/
|
|
22
|
+
alternatingColors?: [string?, string?];
|
|
23
|
+
/**
|
|
24
|
+
* Checkable to choose multiple items
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
checkable?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Rows count to have the bottom border
|
|
30
|
+
*/
|
|
31
|
+
borderRowsCount?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Bottom height
|
|
34
|
+
*/
|
|
35
|
+
bottomHeight?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Columns
|
|
38
|
+
*/
|
|
39
|
+
columns: GridColumn<T>[];
|
|
40
|
+
/**
|
|
41
|
+
* Footer item renderer
|
|
42
|
+
*/
|
|
43
|
+
footerItemRenderer?: (rows: T[], props: DataGridExFooterItemRendererProps<T>) => React.ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Header height
|
|
46
|
+
* @default 56
|
|
47
|
+
*/
|
|
48
|
+
headerHeight?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Hide the footer
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
hideFooter?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Hover color
|
|
56
|
+
*/
|
|
57
|
+
hoverColor?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Double click handler
|
|
60
|
+
*/
|
|
61
|
+
onDoubleClick?: MouseEventWithDataHandler<T>;
|
|
62
|
+
/**
|
|
63
|
+
* Click handler
|
|
64
|
+
*/
|
|
65
|
+
onClick?: MouseEventWithDataHandler<T>;
|
|
66
|
+
/**
|
|
67
|
+
* Selectable to support hover over and out effect and row clickable
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
70
|
+
selectable?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Selected color
|
|
73
|
+
*/
|
|
74
|
+
selectedColor?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Width
|
|
77
|
+
*/
|
|
78
|
+
width?: number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Extended datagrid columns calculation
|
|
82
|
+
* @param columns
|
|
83
|
+
* @returns Total width and unset items
|
|
84
|
+
*/
|
|
85
|
+
export declare function DataGridExCalColumns<T>(columns: GridColumn<T>[]): {
|
|
86
|
+
total: number;
|
|
87
|
+
unset: number;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Extended DataGrid with VariableSizeGrid
|
|
91
|
+
* @param props Props
|
|
92
|
+
* @returns Component
|
|
93
|
+
*/
|
|
94
|
+
export declare function DataGridEx<T extends object, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: DataGridExProps<T, D>): JSX.Element;
|