@lowentry/mui 1.4.4 → 2.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/LICENSE +23 -0
- package/dist/index.d.ts +129 -0
- package/dist/index.js +720 -0
- package/dist/index.js.map +1 -0
- package/package.json +82 -73
- package/Avatar/index.js +0 -44
- package/Avatar/index.js.map +0 -1
- package/DatePicker/index.js +0 -166
- package/DatePicker/index.js.map +0 -1
- package/Dialog/index.js +0 -45
- package/Dialog/index.js.map +0 -1
- package/InitiallyInvisible/index.js +0 -40
- package/InitiallyInvisible/index.js.map +0 -1
- package/LeMuiUtils-c46ed1cc.js +0 -34
- package/LeMuiUtils-c46ed1cc.js.map +0 -1
- package/LoadingSpinner/index.js +0 -10
- package/LoadingSpinner/index.js.map +0 -1
- package/LoadingSpinner-4ccdb773.js +0 -67
- package/LoadingSpinner-4ccdb773.js.map +0 -1
- package/LoadingSpinnerWidget/index.js +0 -10
- package/LoadingSpinnerWidget/index.js.map +0 -1
- package/MenuButton/index.js +0 -63
- package/MenuButton/index.js.map +0 -1
- package/MuiRoot/index.js +0 -30
- package/MuiRoot/index.js.map +0 -1
- package/NumericTextField/index.js +0 -108
- package/NumericTextField/index.js.map +0 -1
- package/RemovableNumericTextField/index.js +0 -48
- package/RemovableNumericTextField/index.js.map +0 -1
- package/RemovableTextField/index.js +0 -54
- package/RemovableTextField/index.js.map +0 -1
- package/Submittable/index.js +0 -33
- package/Submittable/index.js.map +0 -1
- package/TextField/index.js +0 -33
- package/TextField/index.js.map +0 -1
- package/api-extractor.json +0 -43
- package/index.js +0 -38
- package/index.js.map +0 -1
- package/src/LeMuiUtils.js +0 -52
- package/src/components/Avatar.jsx +0 -28
- package/src/components/DatePicker.jsx +0 -120
- package/src/components/DatePicker.less +0 -32
- package/src/components/Dialog.jsx +0 -35
- package/src/components/Dialog.less +0 -7
- package/src/components/InitiallyInvisible.jsx +0 -20
- package/src/components/LoadingSpinner/LoadingSpinner.jsx +0 -51
- package/src/components/LoadingSpinner/LoadingSpinner.less +0 -9
- package/src/components/LoadingSpinner.jsx +0 -1
- package/src/components/LoadingSpinnerWidget.jsx +0 -1
- package/src/components/MenuButton.jsx +0 -54
- package/src/components/MuiRoot.jsx +0 -23
- package/src/components/MuiRoot.less +0 -21
- package/src/components/NumericTextField.jsx +0 -115
- package/src/components/RemovableNumericTextField.jsx +0 -41
- package/src/components/RemovableTextField.jsx +0 -48
- package/src/components/Submittable.jsx +0 -41
- package/src/components/TextField.jsx +0 -30
- package/src/components/TextField.less +0 -4
- package/src/index.js +0 -13
- package/style-inject.es-1f59c1d0.js +0 -29
- package/style-inject.es-1f59c1d0.js.map +0 -1
- package/tsconfig.d.ts +0 -1
- package/tsconfig.json +0 -39
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {LeRed} from '@lowentry/react-redux';
|
|
3
|
-
import {FLOAT_LAX, INT_LAX_ANY, STRING} from '@lowentry/utils';
|
|
4
|
-
import {LeMuiUtils} from '../LeMuiUtils.js';
|
|
5
|
-
import TextField from './TextField.jsx';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const getProcessedValue = (value, decimals, allowZero, allowNegative) =>
|
|
9
|
-
{
|
|
10
|
-
let text = LeMuiUtils.purgePrependedHiddenChar(STRING(value));
|
|
11
|
-
let val = 0;
|
|
12
|
-
|
|
13
|
-
const negative = text.includes('-');
|
|
14
|
-
|
|
15
|
-
text = text.replace(',', '.').replace(/[^0-9.]/g, '');
|
|
16
|
-
if(text !== '')
|
|
17
|
-
{
|
|
18
|
-
let stringVal = Math.abs(FLOAT_LAX(text)).toFixed(decimals + 1); // prevents rounding (by adding an extra digit and then cutting it off)
|
|
19
|
-
stringVal = stringVal.substring(0, stringVal.length - 1);
|
|
20
|
-
|
|
21
|
-
const textDotCount = text.split('.').length - 1;
|
|
22
|
-
if((textDotCount <= 0) || (decimals <= 0))
|
|
23
|
-
{
|
|
24
|
-
text = stringVal.split('.')[0];
|
|
25
|
-
}
|
|
26
|
-
else if((textDotCount === 1) && text.endsWith('.'))
|
|
27
|
-
{
|
|
28
|
-
text = stringVal.split('.')[0] + '.';
|
|
29
|
-
}
|
|
30
|
-
else
|
|
31
|
-
{
|
|
32
|
-
text = stringVal.substring(0, stringVal.length - Math.max(0, decimals - text.split('.')[1].length));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if(!allowZero && (text === '0'))
|
|
36
|
-
{
|
|
37
|
-
text = '';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if(allowNegative && negative)
|
|
42
|
-
{
|
|
43
|
-
text = '-' + text;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
val = FLOAT_LAX(text);
|
|
47
|
-
if(val !== 0)
|
|
48
|
-
{
|
|
49
|
-
if(decimals > 0)
|
|
50
|
-
{
|
|
51
|
-
val = Math.round(val * Math.pow(10, decimals)) / Math.pow(10, decimals);
|
|
52
|
-
}
|
|
53
|
-
else
|
|
54
|
-
{
|
|
55
|
-
val = Math.round(val);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return {text, val};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const NumericTextField = LeRed.memo(({decimals, allowZero, allowNegative, value, onChange, onRenderValue, className, inputProps, children, ...props}) =>
|
|
64
|
-
{
|
|
65
|
-
allowZero = !!allowZero;
|
|
66
|
-
allowNegative = !!allowNegative;
|
|
67
|
-
decimals = INT_LAX_ANY(decimals, 0);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const getVisualValue = LeRed.useCallback((value) =>
|
|
71
|
-
{
|
|
72
|
-
return getProcessedValue(value, decimals, allowZero, allowNegative).text;
|
|
73
|
-
}, [decimals, allowZero, allowNegative]);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const [visualValue, setVisualValue] = LeRed.useState(getVisualValue(value));
|
|
77
|
-
|
|
78
|
-
LeRed.useEffect(() =>
|
|
79
|
-
{
|
|
80
|
-
const newVisualValue = getVisualValue(value);
|
|
81
|
-
if(FLOAT_LAX(visualValue) !== FLOAT_LAX(newVisualValue))
|
|
82
|
-
{
|
|
83
|
-
setVisualValue(newVisualValue);
|
|
84
|
-
}
|
|
85
|
-
}, [value, getVisualValue]);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const onChanged = LeRed.useCallback((event) =>
|
|
89
|
-
{
|
|
90
|
-
const originalTargetValue = event.target.value;
|
|
91
|
-
const {text, val} = getProcessedValue(originalTargetValue, decimals, allowZero, allowNegative);
|
|
92
|
-
|
|
93
|
-
setVisualValue(text);
|
|
94
|
-
|
|
95
|
-
if(onChange)
|
|
96
|
-
{
|
|
97
|
-
const newEvent = {
|
|
98
|
-
...event,
|
|
99
|
-
target:{
|
|
100
|
-
...event.target,
|
|
101
|
-
value: val,
|
|
102
|
-
valueText:text,
|
|
103
|
-
valueRaw: originalTargetValue,
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
onChange(newEvent);
|
|
107
|
-
}
|
|
108
|
-
}, [onChange]);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return (<>
|
|
112
|
-
<TextField className={'lowentry-mui--numeric-textfield ' + (className ?? '')} type="text" inputProps={{inputMode:'decimal', ...(inputProps ?? {})}} value={!!onRenderValue ? onRenderValue(visualValue) : visualValue} onChange={onChanged} {...props}>{children}</TextField>
|
|
113
|
-
</>);
|
|
114
|
-
});
|
|
115
|
-
export default NumericTextField;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {LeRed} from '@lowentry/react-redux';
|
|
3
|
-
import {LeMuiUtils} from '../LeMuiUtils';
|
|
4
|
-
import NumericTextField from './NumericTextField.jsx';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const RemovableNumericTextField = LeRed.memo(({onRemove, onChange, onSelect, className, children, ...props}) =>
|
|
8
|
-
{
|
|
9
|
-
const onChanged = LeRed.useCallback((event) =>
|
|
10
|
-
{
|
|
11
|
-
if(event.target.valueRaw === '')
|
|
12
|
-
{
|
|
13
|
-
if(onRemove)
|
|
14
|
-
{
|
|
15
|
-
onRemove(event);
|
|
16
|
-
}
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if(onChange)
|
|
21
|
-
{
|
|
22
|
-
onChange(event);
|
|
23
|
-
}
|
|
24
|
-
}, [onRemove, onChange]);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const onSelected = LeRed.useCallback((event) =>
|
|
28
|
-
{
|
|
29
|
-
LeMuiUtils.onSelectEnsureMinimumOffset(1)(event);
|
|
30
|
-
if(onSelect)
|
|
31
|
-
{
|
|
32
|
-
onSelect(event);
|
|
33
|
-
}
|
|
34
|
-
}, [onSelect]);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return (<>
|
|
38
|
-
<NumericTextField className={'lowentry-mui--removable-textfield lowentry-mui--removable-numeric-textfield ' + (className ?? '')} onRenderValue={LeMuiUtils.prependHiddenChar} onChange={onChanged} onSelect={onSelected} {...props}>{children}</NumericTextField>
|
|
39
|
-
</>);
|
|
40
|
-
});
|
|
41
|
-
export default RemovableNumericTextField;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {LeRed} from '@lowentry/react-redux';
|
|
3
|
-
import {LeMuiUtils} from '../LeMuiUtils';
|
|
4
|
-
import TextField from './TextField.jsx';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const RemovableTextField = LeRed.memo(({className, value, onRemove, onChange, onSelect, children, ...props}) =>
|
|
8
|
-
{
|
|
9
|
-
const onChanged = LeRed.useCallback((event) =>
|
|
10
|
-
{
|
|
11
|
-
if(event.target.value === '')
|
|
12
|
-
{
|
|
13
|
-
if(onRemove)
|
|
14
|
-
{
|
|
15
|
-
onRemove(event);
|
|
16
|
-
}
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if(onChange)
|
|
21
|
-
{
|
|
22
|
-
const newEvent = {
|
|
23
|
-
...event,
|
|
24
|
-
target:{
|
|
25
|
-
...event.target,
|
|
26
|
-
value:LeMuiUtils.purgePrependedHiddenChar(event.target.value),
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
onChange(newEvent);
|
|
30
|
-
}
|
|
31
|
-
}, [onRemove, onChange]);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const onSelected = LeRed.useCallback((event) =>
|
|
35
|
-
{
|
|
36
|
-
LeMuiUtils.onSelectEnsureMinimumOffset(1)(event);
|
|
37
|
-
if(onSelect)
|
|
38
|
-
{
|
|
39
|
-
onSelect(event);
|
|
40
|
-
}
|
|
41
|
-
}, [onSelect]);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return (<>
|
|
45
|
-
<TextField className={'lowentry-mui--removable-textfield ' + (className ?? '')} value={LeMuiUtils.prependHiddenChar(value)} onChange={onChanged} onSelect={onSelected} {...props}>{children}</TextField>
|
|
46
|
-
</>);
|
|
47
|
-
});
|
|
48
|
-
export default RemovableTextField;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {LeRed} from '@lowentry/react-redux';
|
|
3
|
-
import Stack from '@mui/material/Stack';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const Submittable = LeRed.memo(({onSubmit, disabled, sx, children, ...props}) =>
|
|
7
|
-
{
|
|
8
|
-
const handleSubmit = LeRed.useCallback((event) =>
|
|
9
|
-
{
|
|
10
|
-
try
|
|
11
|
-
{
|
|
12
|
-
event.preventDefault();
|
|
13
|
-
}
|
|
14
|
-
catch(e)
|
|
15
|
-
{
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if(disabled)
|
|
19
|
-
{
|
|
20
|
-
if(!(typeof disabled === 'function') || disabled())
|
|
21
|
-
{
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if(onSubmit)
|
|
27
|
-
{
|
|
28
|
-
onSubmit(event);
|
|
29
|
-
}
|
|
30
|
-
}, [onSubmit, disabled]);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return (<>
|
|
34
|
-
<form style={sx ?? {}} onSubmit={handleSubmit}>
|
|
35
|
-
<Stack {...props}>
|
|
36
|
-
{children}
|
|
37
|
-
</Stack>
|
|
38
|
-
</form>
|
|
39
|
-
</>);
|
|
40
|
-
});
|
|
41
|
-
export default Submittable;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {LeRed} from '@lowentry/react-redux';
|
|
3
|
-
import MuiTextField from '@mui/material/TextField';
|
|
4
|
-
import './TextField.less';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const TextField = LeRed.memo(({className, onClick, children, ...props}) =>
|
|
8
|
-
{
|
|
9
|
-
const onClicked = LeRed.useCallback((event) =>
|
|
10
|
-
{
|
|
11
|
-
try
|
|
12
|
-
{
|
|
13
|
-
event.stopPropagation();
|
|
14
|
-
}
|
|
15
|
-
catch(e)
|
|
16
|
-
{
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if(onClick)
|
|
20
|
-
{
|
|
21
|
-
onClick(event);
|
|
22
|
-
}
|
|
23
|
-
}, [onClick]);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return (<>
|
|
27
|
-
<MuiTextField className={'lowentry-mui--textfield ' + (className ?? '')} autoComplete="off" onClick={onClicked} {...props}>{children}</MuiTextField>
|
|
28
|
-
</>);
|
|
29
|
-
});
|
|
30
|
-
export default TextField;
|
package/src/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export {default as Avatar} from './components/Avatar.jsx';
|
|
2
|
-
export {default as DatePicker} from './components/DatePicker.jsx';
|
|
3
|
-
export {default as Dialog} from './components/Dialog.jsx';
|
|
4
|
-
export {default as InitiallyInvisible} from './components/InitiallyInvisible.jsx';
|
|
5
|
-
export {default as LoadingSpinner} from './components/LoadingSpinner.jsx';
|
|
6
|
-
export {default as LoadingSpinnerWidget} from './components/LoadingSpinnerWidget.jsx';
|
|
7
|
-
export {default as MenuButton} from './components/MenuButton.jsx';
|
|
8
|
-
export {default as MuiRoot} from './components/MuiRoot.jsx';
|
|
9
|
-
export {default as NumericTextField} from './components/NumericTextField.jsx';
|
|
10
|
-
export {default as RemovableNumericTextField} from './components/RemovableNumericTextField.jsx';
|
|
11
|
-
export {default as RemovableTextField} from './components/RemovableTextField.jsx';
|
|
12
|
-
export {default as Submittable} from './components/Submittable.jsx';
|
|
13
|
-
export {default as TextField} from './components/TextField.jsx';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
function styleInject(css, ref) {
|
|
2
|
-
if ( ref === void 0 ) ref = {};
|
|
3
|
-
var insertAt = ref.insertAt;
|
|
4
|
-
|
|
5
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
6
|
-
|
|
7
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
8
|
-
var style = document.createElement('style');
|
|
9
|
-
style.type = 'text/css';
|
|
10
|
-
|
|
11
|
-
if (insertAt === 'top') {
|
|
12
|
-
if (head.firstChild) {
|
|
13
|
-
head.insertBefore(style, head.firstChild);
|
|
14
|
-
} else {
|
|
15
|
-
head.appendChild(style);
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
18
|
-
head.appendChild(style);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (style.styleSheet) {
|
|
22
|
-
style.styleSheet.cssText = css;
|
|
23
|
-
} else {
|
|
24
|
-
style.appendChild(document.createTextNode(css));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { styleInject as s };
|
|
29
|
-
//# sourceMappingURL=style-inject.es-1f59c1d0.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style-inject.es-1f59c1d0.js","sources":["../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":[],"mappings":"AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,KAAK,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;AACjC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;AAC9B;AACA,EAAE,IAAI,CAAC,GAAG,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO,EAAE;AAC1D;AACA,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,EAAE,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAC9C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC;AAC1B;AACA,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AAChD,KAAK,MAAM;AACX,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC9B,KAAK;AACL,GAAG,MAAM;AACT,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,GAAG;AACH;AACA,EAAE,IAAI,KAAK,CAAC,UAAU,EAAE;AACxB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC;AACnC,GAAG,MAAM;AACT,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,GAAG;AACH;;;;"}
|
package/tsconfig.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference lib="esnext" />
|
package/tsconfig.json
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"allowJs": true,
|
|
4
|
-
"checkJs": true,
|
|
5
|
-
"strict": true,
|
|
6
|
-
"noImplicitAny": false,
|
|
7
|
-
"noImplicitThis": false,
|
|
8
|
-
"alwaysStrict": true,
|
|
9
|
-
"resolveJsonModule": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"allowSyntheticDefaultImports": true,
|
|
12
|
-
"jsx": "react-jsx",
|
|
13
|
-
"target": "esnext",
|
|
14
|
-
"module": "esnext",
|
|
15
|
-
"moduleResolution": "node",
|
|
16
|
-
"skipLibCheck": true,
|
|
17
|
-
"types": [],
|
|
18
|
-
"noEmit": false,
|
|
19
|
-
"declaration": true,
|
|
20
|
-
"declarationMap": false,
|
|
21
|
-
"outDir": "./build",
|
|
22
|
-
"removeComments": false,
|
|
23
|
-
"stripInternal": true,
|
|
24
|
-
"emitDeclarationOnly": true
|
|
25
|
-
},
|
|
26
|
-
"include": [
|
|
27
|
-
"tsconfig.d.ts",
|
|
28
|
-
"src"
|
|
29
|
-
],
|
|
30
|
-
"exclude": [
|
|
31
|
-
"node_modules"
|
|
32
|
-
],
|
|
33
|
-
"typeAcquisition": {
|
|
34
|
-
"include": [
|
|
35
|
-
"react",
|
|
36
|
-
"react-dom"
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
}
|