@etsoo/react 1.2.2 → 1.2.6
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/lib/components/GridColumn.js +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/mu/AutocompleteExtendedProps.d.ts +1 -1
- package/lib/mu/ComboBox.js +2 -2
- package/lib/mu/CountdownButton.d.ts +1 -1
- package/lib/mu/DataGridRenderers.js +5 -7
- package/lib/mu/SelectEx.js +1 -1
- package/lib/mu/TextFieldEx.d.ts +3 -3
- package/lib/mu/texts/DateText.d.ts +30 -0
- package/lib/mu/texts/DateText.js +18 -0
- package/lib/mu/texts/MoneyText.d.ts +21 -0
- package/lib/mu/texts/MoneyText.js +14 -0
- package/lib/mu/texts/NumberText.d.ts +25 -0
- package/lib/mu/texts/NumberText.js +14 -0
- package/package.json +6 -6
- package/src/components/GridColumn.ts +1 -0
- package/src/index.ts +5 -0
- package/src/mu/AutocompleteExtendedProps.ts +1 -4
- package/src/mu/ComboBox.tsx +2 -4
- package/src/mu/DataGridRenderers.tsx +10 -7
- package/src/mu/SelectEx.tsx +1 -1
- package/src/mu/Tiplist.tsx +1 -1
- package/src/mu/texts/DateText.tsx +51 -0
- package/src/mu/texts/MoneyText.tsx +49 -0
- package/src/mu/texts/NumberText.tsx +40 -0
|
@@ -12,6 +12,7 @@ export { GridDataType };
|
|
|
12
12
|
export const GridAlignGet = (align, type) => {
|
|
13
13
|
if (align == null && type != null) {
|
|
14
14
|
if (type === GridDataType.Money ||
|
|
15
|
+
type === GridDataType.IntMoney ||
|
|
15
16
|
type === GridDataType.Int ||
|
|
16
17
|
type === GridDataType.Number)
|
|
17
18
|
return 'right';
|
package/lib/index.d.ts
CHANGED
|
@@ -19,6 +19,9 @@ export * from './mu/pages/ResponsivePageProps';
|
|
|
19
19
|
export * from './mu/pages/SearchPageProps';
|
|
20
20
|
export * from './mu/pages/TablePage';
|
|
21
21
|
export * from './mu/pages/ViewPage';
|
|
22
|
+
export * from './mu/texts/DateText';
|
|
23
|
+
export * from './mu/texts/MoneyText';
|
|
24
|
+
export * from './mu/texts/NumberText';
|
|
22
25
|
export * from './mu/ButtonLink';
|
|
23
26
|
export * from './mu/ComboBox';
|
|
24
27
|
export * from './mu/CountdownButton';
|
package/lib/index.js
CHANGED
|
@@ -22,6 +22,9 @@ export * from './mu/pages/ResponsivePageProps';
|
|
|
22
22
|
export * from './mu/pages/SearchPageProps';
|
|
23
23
|
export * from './mu/pages/TablePage';
|
|
24
24
|
export * from './mu/pages/ViewPage';
|
|
25
|
+
export * from './mu/texts/DateText';
|
|
26
|
+
export * from './mu/texts/MoneyText';
|
|
27
|
+
export * from './mu/texts/NumberText';
|
|
25
28
|
export * from './mu/ButtonLink';
|
|
26
29
|
export * from './mu/ComboBox';
|
|
27
30
|
export * from './mu/CountdownButton';
|
|
@@ -3,7 +3,7 @@ import { AutocompleteProps } from '@mui/material';
|
|
|
3
3
|
/**
|
|
4
4
|
* Autocomplete extended props
|
|
5
5
|
*/
|
|
6
|
-
export interface AutocompleteExtendedProps<T extends Record<string, any>> extends Omit<AutocompleteProps<T, undefined,
|
|
6
|
+
export interface AutocompleteExtendedProps<T extends Record<string, any>> extends Omit<AutocompleteProps<T, undefined, false, false>, 'renderInput'> {
|
|
7
7
|
/**
|
|
8
8
|
* Id field, default is id
|
|
9
9
|
*/
|
package/lib/mu/ComboBox.js
CHANGED
|
@@ -10,7 +10,7 @@ import { SearchField } from './SearchField';
|
|
|
10
10
|
*/
|
|
11
11
|
export function ComboBox(props) {
|
|
12
12
|
// Destruct
|
|
13
|
-
const { search = false, idField = 'id', idValue, inputMargin, inputRequired, inputVariant, defaultValue, label, name, options,
|
|
13
|
+
const { search = false, idField = 'id', idValue, inputMargin, inputRequired, inputVariant, defaultValue, label, name, options, readOnly = true, onChange, value, sx = { minWidth: '150px' }, ...rest } = props;
|
|
14
14
|
// Value input ref
|
|
15
15
|
const inputRef = React.createRef();
|
|
16
16
|
// Local default value
|
|
@@ -34,7 +34,7 @@ export function ComboBox(props) {
|
|
|
34
34
|
// Layout
|
|
35
35
|
return (React.createElement("div", null,
|
|
36
36
|
React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, defaultValue: localIdValue }),
|
|
37
|
-
React.createElement(Autocomplete, { defaultValue: localValue,
|
|
37
|
+
React.createElement(Autocomplete, { defaultValue: localValue, isOptionEqualToValue: (option, value) => option[idField] === value[idField], onChange: (event, value, reason, details) => {
|
|
38
38
|
// Input value
|
|
39
39
|
const input = inputRef.current;
|
|
40
40
|
if (input) {
|
|
@@ -20,4 +20,4 @@ export declare type CountdownButtonProps = Omit<ButtonProps, 'endIcon' | 'disabl
|
|
|
20
20
|
* @param props Props
|
|
21
21
|
* @returns Button
|
|
22
22
|
*/
|
|
23
|
-
export declare const CountdownButton: React.ForwardRefExoticComponent<Pick<CountdownButtonProps, "children" | "form" | "slot" | "title" | "value" | "name" | "type" | "
|
|
23
|
+
export declare const CountdownButton: React.ForwardRefExoticComponent<Pick<CountdownButtonProps, "children" | "form" | "slot" | "title" | "value" | "name" | "type" | "onScroll" | "id" | "hidden" | "color" | "size" | keyof import("@mui/material/OverridableComponent").CommonProps | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "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" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "key" | "href" | "disableFocusRipple" | "variant" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "disableElevation" | "fullWidth" | "startIcon" | "onAction"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CircularProgress } from '@mui/material';
|
|
3
3
|
import { GridDataType } from '../components/GridColumn';
|
|
4
|
-
import { DateUtils } from '@etsoo/shared';
|
|
4
|
+
import { DateUtils, NumberUtils } from '@etsoo/shared';
|
|
5
5
|
import CheckIcon from '@mui/icons-material/Check';
|
|
6
6
|
import ClearIcon from '@mui/icons-material/Clear';
|
|
7
7
|
/**
|
|
@@ -32,16 +32,14 @@ export var DataGridRenderers;
|
|
|
32
32
|
return undefined;
|
|
33
33
|
// For date time
|
|
34
34
|
if (value instanceof Date) {
|
|
35
|
-
return DateUtils.format(navigator.language,
|
|
35
|
+
return DateUtils.format(value, navigator.language, type === GridDataType.DateTime ? 'ds' : 'd');
|
|
36
36
|
}
|
|
37
37
|
// For numbers
|
|
38
38
|
if (typeof value === 'number') {
|
|
39
|
-
if (type === GridDataType.Money)
|
|
40
|
-
return
|
|
41
|
-
minimumFractionDigits: 2
|
|
42
|
-
}).format(value);
|
|
39
|
+
if (type === GridDataType.Money || type === GridDataType.IntMoney)
|
|
40
|
+
return NumberUtils.formatMoney(value, undefined, undefined, type === GridDataType.IntMoney);
|
|
43
41
|
else
|
|
44
|
-
return
|
|
42
|
+
return NumberUtils.format(value);
|
|
45
43
|
}
|
|
46
44
|
// For boolean
|
|
47
45
|
if (typeof value === 'boolean') {
|
package/lib/mu/SelectEx.js
CHANGED
|
@@ -79,7 +79,7 @@ export function SelectEx(props) {
|
|
|
79
79
|
: selected === option.id)
|
|
80
80
|
.map((option) => option.label)
|
|
81
81
|
.join(', ');
|
|
82
|
-
}, sx: { minWidth: '
|
|
82
|
+
}, sx: { minWidth: '150px' }, ...rest }, options.map((option) => {
|
|
83
83
|
// Option id
|
|
84
84
|
const id = option[idField];
|
|
85
85
|
// Option label
|
package/lib/mu/TextFieldEx.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Pick<import("
|
|
|
48
48
|
* Show password button
|
|
49
49
|
*/
|
|
50
50
|
showPassword?: boolean | undefined;
|
|
51
|
-
}, "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "name" | "type" | "
|
|
51
|
+
}, "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "name" | "type" | "onScroll" | "className" | "id" | "rows" | "hidden" | "color" | "size" | "disabled" | "error" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "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" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "margin" | "variant" | "autoFocus" | "autoComplete" | "readOnly" | "required" | "onEnter" | "inputProps" | "inputRef" | "fullWidth" | "SelectProps" | "InputLabelProps" | "focused" | "hiddenLabel" | "InputProps" | "FormHelperTextProps" | "helperText" | "multiline" | "maxRows" | "minRows" | "showClear" | "showPassword"> | Pick<import("@mui/material").FilledTextFieldProps & {
|
|
52
52
|
/**
|
|
53
53
|
* On enter click
|
|
54
54
|
*/
|
|
@@ -65,7 +65,7 @@ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Pick<import("
|
|
|
65
65
|
* Show password button
|
|
66
66
|
*/
|
|
67
67
|
showPassword?: boolean | undefined;
|
|
68
|
-
}, "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "name" | "type" | "
|
|
68
|
+
}, "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "name" | "type" | "onScroll" | "className" | "id" | "rows" | "hidden" | "color" | "size" | "disabled" | "error" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "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" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "margin" | "variant" | "autoFocus" | "autoComplete" | "readOnly" | "required" | "onEnter" | "inputProps" | "inputRef" | "fullWidth" | "SelectProps" | "InputLabelProps" | "focused" | "hiddenLabel" | "InputProps" | "FormHelperTextProps" | "helperText" | "multiline" | "maxRows" | "minRows" | "showClear" | "showPassword"> | Pick<import("@mui/material").OutlinedTextFieldProps & {
|
|
69
69
|
/**
|
|
70
70
|
* On enter click
|
|
71
71
|
*/
|
|
@@ -82,4 +82,4 @@ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Pick<import("
|
|
|
82
82
|
* Show password button
|
|
83
83
|
*/
|
|
84
84
|
showPassword?: boolean | undefined;
|
|
85
|
-
}, "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "name" | "type" | "
|
|
85
|
+
}, "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "name" | "type" | "onScroll" | "className" | "id" | "rows" | "hidden" | "color" | "size" | "disabled" | "error" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "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" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "margin" | "variant" | "autoFocus" | "autoComplete" | "readOnly" | "required" | "onEnter" | "inputProps" | "inputRef" | "fullWidth" | "SelectProps" | "InputLabelProps" | "focused" | "hiddenLabel" | "InputProps" | "FormHelperTextProps" | "helperText" | "multiline" | "maxRows" | "minRows" | "showClear" | "showPassword">) & React.RefAttributes<TextFieldExMethods>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DateUtils } from '@etsoo/shared';
|
|
3
|
+
import { TypographyProps } from '@mui/material';
|
|
4
|
+
/**
|
|
5
|
+
* Date text props
|
|
6
|
+
*/
|
|
7
|
+
export interface DateTextProps extends TypographyProps {
|
|
8
|
+
/**
|
|
9
|
+
* Locale
|
|
10
|
+
*/
|
|
11
|
+
locale?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Options
|
|
14
|
+
*/
|
|
15
|
+
options?: DateUtils.FormatOptions;
|
|
16
|
+
/**
|
|
17
|
+
* Time zone
|
|
18
|
+
*/
|
|
19
|
+
timeZone?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Value to display
|
|
22
|
+
*/
|
|
23
|
+
value?: Date | string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Date text
|
|
27
|
+
* @param props Props
|
|
28
|
+
* @returns Component
|
|
29
|
+
*/
|
|
30
|
+
export declare function DateText(props: DateTextProps): JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DateUtils } from '@etsoo/shared';
|
|
2
|
+
import { Typography } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* Date text
|
|
6
|
+
* @param props Props
|
|
7
|
+
* @returns Component
|
|
8
|
+
*/
|
|
9
|
+
export function DateText(props) {
|
|
10
|
+
// Destruct
|
|
11
|
+
const { locale = 'lookup', options, timeZone, value, ...rest } = props;
|
|
12
|
+
// Formatted value
|
|
13
|
+
const localValue = value == null
|
|
14
|
+
? undefined
|
|
15
|
+
: DateUtils.format(value, locale, options, timeZone);
|
|
16
|
+
// Layout
|
|
17
|
+
return (React.createElement(Typography, { noWrap: true, ...rest }, localValue));
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { NumberTextProps } from './NumberText';
|
|
3
|
+
/**
|
|
4
|
+
* Money text props
|
|
5
|
+
*/
|
|
6
|
+
export interface MoneyTextProps extends NumberTextProps {
|
|
7
|
+
/**
|
|
8
|
+
* Currency, USD for US dollar
|
|
9
|
+
*/
|
|
10
|
+
currency?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Is integer number
|
|
13
|
+
*/
|
|
14
|
+
isInteger?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Money text
|
|
18
|
+
* @param props Props
|
|
19
|
+
* @returns Component
|
|
20
|
+
*/
|
|
21
|
+
export declare function MoneyText(props: MoneyTextProps): JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NumberUtils } from '@etsoo/shared';
|
|
2
|
+
import { Typography } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* Money text
|
|
6
|
+
* @param props Props
|
|
7
|
+
* @returns Component
|
|
8
|
+
*/
|
|
9
|
+
export function MoneyText(props) {
|
|
10
|
+
// Destruct
|
|
11
|
+
const { currency, isInteger = false, locale, options = {}, value, ...rest } = props;
|
|
12
|
+
// Layout
|
|
13
|
+
return (React.createElement(Typography, { noWrap: true, ...rest }, NumberUtils.formatMoney(value, currency, locale, isInteger, options)));
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TypographyProps } from '@mui/material';
|
|
3
|
+
/**
|
|
4
|
+
* Number text props
|
|
5
|
+
*/
|
|
6
|
+
export interface NumberTextProps extends TypographyProps {
|
|
7
|
+
/**
|
|
8
|
+
* Locale
|
|
9
|
+
*/
|
|
10
|
+
locale?: string | string[];
|
|
11
|
+
/**
|
|
12
|
+
* Options
|
|
13
|
+
*/
|
|
14
|
+
options?: Intl.NumberFormatOptions;
|
|
15
|
+
/**
|
|
16
|
+
* Value
|
|
17
|
+
*/
|
|
18
|
+
value?: number | bigint;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Number text
|
|
22
|
+
* @param props Props
|
|
23
|
+
* @returns Component
|
|
24
|
+
*/
|
|
25
|
+
export declare function NumberText(props: NumberTextProps): JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NumberUtils } from '@etsoo/shared';
|
|
2
|
+
import { Typography } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* Number text
|
|
6
|
+
* @param props Props
|
|
7
|
+
* @returns Component
|
|
8
|
+
*/
|
|
9
|
+
export function NumberText(props) {
|
|
10
|
+
// Destruct
|
|
11
|
+
const { locale, options = {}, value, ...rest } = props;
|
|
12
|
+
// Layout
|
|
13
|
+
return (React.createElement(Typography, { noWrap: true, ...rest }, NumberUtils.format(value, locale, options)));
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"@emotion/react": "^11.4.1",
|
|
45
45
|
"@emotion/style": "^0.8.0",
|
|
46
46
|
"@emotion/styled": "^11.3.0",
|
|
47
|
-
"@etsoo/appscript": "^1.0.
|
|
47
|
+
"@etsoo/appscript": "^1.0.96",
|
|
48
48
|
"@etsoo/notificationbase": "^1.0.78",
|
|
49
|
-
"@etsoo/shared": "^1.0.
|
|
49
|
+
"@etsoo/shared": "^1.0.44",
|
|
50
50
|
"@mui/icons-material": "^5.0.1",
|
|
51
51
|
"@mui/material": "^5.0.2",
|
|
52
52
|
"@reach/router": "^1.3.4",
|
|
53
53
|
"@types/pica": "^5.1.3",
|
|
54
54
|
"@types/pulltorefreshjs": "^0.1.5",
|
|
55
55
|
"@types/reach__router": "^1.3.9",
|
|
56
|
-
"@types/react": "^17.0.
|
|
56
|
+
"@types/react": "^17.0.27",
|
|
57
57
|
"@types/react-avatar-editor": "^10.3.6",
|
|
58
58
|
"@types/react-dom": "^17.0.9",
|
|
59
59
|
"@types/react-window": "^1.8.5",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
74
74
|
"@types/jest": "^27.0.2",
|
|
75
75
|
"@types/react-test-renderer": "^17.0.1",
|
|
76
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
77
|
-
"@typescript-eslint/parser": "^4.
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
77
|
+
"@typescript-eslint/parser": "^4.33.0",
|
|
78
78
|
"eslint": "^7.32.0",
|
|
79
79
|
"eslint-config-airbnb-base": "^14.2.1",
|
|
80
80
|
"eslint-plugin-import": "^2.24.2",
|
package/src/index.ts
CHANGED
|
@@ -24,6 +24,11 @@ export * from './mu/pages/ResponsivePageProps';
|
|
|
24
24
|
export * from './mu/pages/SearchPageProps';
|
|
25
25
|
export * from './mu/pages/TablePage';
|
|
26
26
|
export * from './mu/pages/ViewPage';
|
|
27
|
+
|
|
28
|
+
export * from './mu/texts/DateText';
|
|
29
|
+
export * from './mu/texts/MoneyText';
|
|
30
|
+
export * from './mu/texts/NumberText';
|
|
31
|
+
|
|
27
32
|
export * from './mu/ButtonLink';
|
|
28
33
|
export * from './mu/ComboBox';
|
|
29
34
|
export * from './mu/CountdownButton';
|
|
@@ -5,10 +5,7 @@ import { AutocompleteProps } from '@mui/material';
|
|
|
5
5
|
* Autocomplete extended props
|
|
6
6
|
*/
|
|
7
7
|
export interface AutocompleteExtendedProps<T extends Record<string, any>>
|
|
8
|
-
extends Omit<
|
|
9
|
-
AutocompleteProps<T, undefined, boolean, false>,
|
|
10
|
-
'renderInput'
|
|
11
|
-
> {
|
|
8
|
+
extends Omit<AutocompleteProps<T, undefined, false, false>, 'renderInput'> {
|
|
12
9
|
/**
|
|
13
10
|
* Id field, default is id
|
|
14
11
|
*/
|
package/src/mu/ComboBox.tsx
CHANGED
|
@@ -31,11 +31,10 @@ export function ComboBox<T extends Record<string, any>>(
|
|
|
31
31
|
label,
|
|
32
32
|
name,
|
|
33
33
|
options,
|
|
34
|
-
disableClearable = true,
|
|
35
34
|
readOnly = true,
|
|
36
35
|
onChange,
|
|
37
36
|
value,
|
|
38
|
-
sx = { minWidth: '
|
|
37
|
+
sx = { minWidth: '150px' },
|
|
39
38
|
...rest
|
|
40
39
|
} = props;
|
|
41
40
|
|
|
@@ -76,10 +75,9 @@ export function ComboBox<T extends Record<string, any>>(
|
|
|
76
75
|
name={name}
|
|
77
76
|
defaultValue={localIdValue}
|
|
78
77
|
/>
|
|
79
|
-
{/* Previous input will reset first, next input trigger change works */}
|
|
78
|
+
{/* Previous input will reset first with "disableClearable = false", next input trigger change works */}
|
|
80
79
|
<Autocomplete
|
|
81
80
|
defaultValue={localValue}
|
|
82
|
-
disableClearable={disableClearable}
|
|
83
81
|
isOptionEqualToValue={(option: T, value: T) =>
|
|
84
82
|
option[idField] === value[idField]
|
|
85
83
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CircularProgress } from '@mui/material';
|
|
3
3
|
import { GridCellRendererProps, GridDataType } from '../components/GridColumn';
|
|
4
|
-
import { DateUtils } from '@etsoo/shared';
|
|
4
|
+
import { DateUtils, NumberUtils } from '@etsoo/shared';
|
|
5
5
|
import CheckIcon from '@mui/icons-material/Check';
|
|
6
6
|
import ClearIcon from '@mui/icons-material/Clear';
|
|
7
7
|
import { DataGridExFooterItemRendererProps } from './DataGridEx';
|
|
@@ -42,19 +42,22 @@ export namespace DataGridRenderers {
|
|
|
42
42
|
// For date time
|
|
43
43
|
if (value instanceof Date) {
|
|
44
44
|
return DateUtils.format(
|
|
45
|
-
navigator.language,
|
|
46
45
|
value,
|
|
46
|
+
navigator.language,
|
|
47
47
|
type === GridDataType.DateTime ? 'ds' : 'd'
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// For numbers
|
|
52
52
|
if (typeof value === 'number') {
|
|
53
|
-
if (type === GridDataType.Money)
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
if (type === GridDataType.Money || type === GridDataType.IntMoney)
|
|
54
|
+
return NumberUtils.formatMoney(
|
|
55
|
+
value,
|
|
56
|
+
undefined,
|
|
57
|
+
undefined,
|
|
58
|
+
type === GridDataType.IntMoney
|
|
59
|
+
);
|
|
60
|
+
else return NumberUtils.format(value);
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
// For boolean
|
package/src/mu/SelectEx.tsx
CHANGED
package/src/mu/Tiplist.tsx
CHANGED
|
@@ -205,7 +205,7 @@ export function Tiplist<T extends Record<string, any>>(props: TiplistProps<T>) {
|
|
|
205
205
|
name={name}
|
|
206
206
|
defaultValue={localIdValue}
|
|
207
207
|
/>
|
|
208
|
-
{/* Previous input will reset first, next input trigger change works */}
|
|
208
|
+
{/* Previous input will reset first with "disableClearable = false", next input trigger change works */}
|
|
209
209
|
<Autocomplete
|
|
210
210
|
filterOptions={(options, _state) => options}
|
|
211
211
|
value={states.value}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DateUtils } from '@etsoo/shared';
|
|
2
|
+
import { Typography, TypographyProps } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Date text props
|
|
7
|
+
*/
|
|
8
|
+
export interface DateTextProps extends TypographyProps {
|
|
9
|
+
/**
|
|
10
|
+
* Locale
|
|
11
|
+
*/
|
|
12
|
+
locale?: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Options
|
|
16
|
+
*/
|
|
17
|
+
options?: DateUtils.FormatOptions;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Time zone
|
|
21
|
+
*/
|
|
22
|
+
timeZone?: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Value to display
|
|
26
|
+
*/
|
|
27
|
+
value?: Date | string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Date text
|
|
32
|
+
* @param props Props
|
|
33
|
+
* @returns Component
|
|
34
|
+
*/
|
|
35
|
+
export function DateText(props: DateTextProps) {
|
|
36
|
+
// Destruct
|
|
37
|
+
const { locale = 'lookup', options, timeZone, value, ...rest } = props;
|
|
38
|
+
|
|
39
|
+
// Formatted value
|
|
40
|
+
const localValue =
|
|
41
|
+
value == null
|
|
42
|
+
? undefined
|
|
43
|
+
: DateUtils.format(value, locale, options, timeZone);
|
|
44
|
+
|
|
45
|
+
// Layout
|
|
46
|
+
return (
|
|
47
|
+
<Typography noWrap {...rest}>
|
|
48
|
+
{localValue}
|
|
49
|
+
</Typography>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NumberUtils } from '@etsoo/shared';
|
|
2
|
+
import { Typography } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { NumberTextProps } from './NumberText';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Money text props
|
|
8
|
+
*/
|
|
9
|
+
export interface MoneyTextProps extends NumberTextProps {
|
|
10
|
+
/**
|
|
11
|
+
* Currency, USD for US dollar
|
|
12
|
+
*/
|
|
13
|
+
currency?: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Is integer number
|
|
17
|
+
*/
|
|
18
|
+
isInteger?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Money text
|
|
23
|
+
* @param props Props
|
|
24
|
+
* @returns Component
|
|
25
|
+
*/
|
|
26
|
+
export function MoneyText(props: MoneyTextProps) {
|
|
27
|
+
// Destruct
|
|
28
|
+
const {
|
|
29
|
+
currency,
|
|
30
|
+
isInteger = false,
|
|
31
|
+
locale,
|
|
32
|
+
options = {},
|
|
33
|
+
value,
|
|
34
|
+
...rest
|
|
35
|
+
} = props;
|
|
36
|
+
|
|
37
|
+
// Layout
|
|
38
|
+
return (
|
|
39
|
+
<Typography noWrap {...rest}>
|
|
40
|
+
{NumberUtils.formatMoney(
|
|
41
|
+
value,
|
|
42
|
+
currency,
|
|
43
|
+
locale,
|
|
44
|
+
isInteger,
|
|
45
|
+
options
|
|
46
|
+
)}
|
|
47
|
+
</Typography>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NumberUtils } from '@etsoo/shared';
|
|
2
|
+
import { Typography, TypographyProps } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Number text props
|
|
7
|
+
*/
|
|
8
|
+
export interface NumberTextProps extends TypographyProps {
|
|
9
|
+
/**
|
|
10
|
+
* Locale
|
|
11
|
+
*/
|
|
12
|
+
locale?: string | string[];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Options
|
|
16
|
+
*/
|
|
17
|
+
options?: Intl.NumberFormatOptions;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Value
|
|
21
|
+
*/
|
|
22
|
+
value?: number | bigint;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Number text
|
|
27
|
+
* @param props Props
|
|
28
|
+
* @returns Component
|
|
29
|
+
*/
|
|
30
|
+
export function NumberText(props: NumberTextProps) {
|
|
31
|
+
// Destruct
|
|
32
|
+
const { locale, options = {}, value, ...rest } = props;
|
|
33
|
+
|
|
34
|
+
// Layout
|
|
35
|
+
return (
|
|
36
|
+
<Typography noWrap {...rest}>
|
|
37
|
+
{NumberUtils.format(value, locale, options)}
|
|
38
|
+
</Typography>
|
|
39
|
+
);
|
|
40
|
+
}
|