@lowentry/mui 1.2.9 → 1.2.11
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/DatePicker/index.js +157 -1
- package/DatePicker/index.js.map +1 -1
- package/Dialog/index.js +27 -1
- package/Dialog/index.js.map +1 -1
- package/InitiallyInvisible/index.js +39 -1
- package/InitiallyInvisible/index.js.map +1 -1
- package/LeMuiUtils-c46ed1cc.js +33 -1
- package/LeMuiUtils-c46ed1cc.js.map +1 -1
- package/LoadingSpinner/index.js +8 -1
- package/LoadingSpinner/index.js.map +1 -1
- package/LoadingSpinner-49031768.js +65 -1
- package/LoadingSpinner-49031768.js.map +1 -1
- package/LoadingSpinnerWidget/index.js +8 -1
- package/LoadingSpinnerWidget/index.js.map +1 -1
- package/MenuButton/index.js +61 -1
- package/MenuButton/index.js.map +1 -1
- package/MuiRoot/index.js +28 -1
- package/MuiRoot/index.js.map +1 -1
- package/NumericTextField/index.js +107 -1
- package/NumericTextField/index.js.map +1 -1
- package/RemovableNumericTextField/index.js +47 -1
- package/RemovableNumericTextField/index.js.map +1 -1
- package/RemovableTextField/index.js +53 -1
- package/RemovableTextField/index.js.map +1 -1
- package/Submittable/index.js +32 -1
- package/Submittable/index.js.map +1 -1
- package/TextField/index.js +32 -1
- package/TextField/index.js.map +1 -1
- package/index.js +26 -1
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/NumericTextField.jsx +64 -66
- package/src/components/RemovableNumericTextField.jsx +1 -1
- package/style-inject.es-1f59c1d0.js +28 -1
- package/style-inject.es-1f59c1d0.js.map +1 -1
|
@@ -1,101 +1,99 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {LeRed} from '@lowentry/react-redux';
|
|
3
|
-
import {
|
|
3
|
+
import {FLOAT_LAX, INT_LAX_ANY, STRING} from '@lowentry/utils';
|
|
4
4
|
import {LeMuiUtils} from '../LeMuiUtils.js';
|
|
5
5
|
import TextField from './TextField.jsx';
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const getProcessedValue = (value, decimals, allowZero, allowNegative) =>
|
|
9
9
|
{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
allowZero = true;
|
|
13
|
-
}
|
|
14
|
-
if(typeof allowNegative === 'undefined')
|
|
15
|
-
{
|
|
16
|
-
allowNegative = true;
|
|
17
|
-
}
|
|
18
|
-
decimals = INT_LAX_ANY(decimals, 2);
|
|
10
|
+
let text = LeMuiUtils.purgePrependedHiddenChar(STRING(value));
|
|
11
|
+
let val = 0;
|
|
19
12
|
|
|
13
|
+
const negative = text.includes('-');
|
|
20
14
|
|
|
21
|
-
|
|
15
|
+
text = text.replace(',', '.').replace(/[^0-9.]/g, '');
|
|
16
|
+
if(text !== '')
|
|
22
17
|
{
|
|
23
|
-
let
|
|
24
|
-
|
|
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('.'))
|
|
25
27
|
{
|
|
26
|
-
text =
|
|
28
|
+
text = stringVal.split('.')[0] + '.';
|
|
29
|
+
}
|
|
30
|
+
else
|
|
31
|
+
{
|
|
32
|
+
text = stringVal.substring(0, stringVal.length - Math.max(0, decimals - text.split('.')[1].length));
|
|
27
33
|
}
|
|
28
34
|
|
|
29
|
-
text = text.toFixed(decimals); // rounds it
|
|
30
|
-
text = LeUtils.trimEnd(LeUtils.trimEnd(text, '0'), '.');
|
|
31
35
|
if(!allowZero && (text === '0'))
|
|
32
36
|
{
|
|
33
37
|
text = '';
|
|
34
38
|
}
|
|
35
|
-
|
|
36
|
-
|
|
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]);
|
|
37
74
|
|
|
38
75
|
|
|
39
76
|
const [visualValue, setVisualValue] = LeRed.useState(getVisualValue(value));
|
|
40
77
|
|
|
41
78
|
LeRed.useEffect(() =>
|
|
42
79
|
{
|
|
43
|
-
|
|
44
|
-
|
|
80
|
+
const newVisualValue = getVisualValue(value);
|
|
81
|
+
if(FLOAT_LAX(visualValue) !== FLOAT_LAX(newVisualValue))
|
|
82
|
+
{
|
|
83
|
+
setVisualValue(newVisualValue);
|
|
84
|
+
}
|
|
85
|
+
}, [value, getVisualValue]);
|
|
45
86
|
|
|
46
87
|
|
|
47
88
|
const onChanged = LeRed.useCallback((event) =>
|
|
48
89
|
{
|
|
49
90
|
const originalTargetValue = event.target.value;
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
let text = targetValue;
|
|
53
|
-
let val = 0;
|
|
91
|
+
const {text, val} = getProcessedValue(originalTargetValue, decimals, allowZero, allowNegative);
|
|
54
92
|
|
|
55
|
-
|
|
56
|
-
const minus = text.includes('-');
|
|
57
|
-
text = text.replace(',', '.').replace(/[^0-9.]/g, '');
|
|
58
|
-
if(text !== '')
|
|
59
|
-
{
|
|
60
|
-
val = Math.abs(FLOAT_LAX(text));
|
|
61
|
-
if(allowNegative && minus)
|
|
62
|
-
{
|
|
63
|
-
val = -val;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let stringVal = val.toFixed(decimals + 1); // prevents rounding (by adding an extra digit and then cutting it off)
|
|
67
|
-
stringVal = stringVal.substring(0, stringVal.length - 1);
|
|
68
|
-
|
|
69
|
-
if(!text.includes('.') || (decimals <= 0))
|
|
70
|
-
{
|
|
71
|
-
text = stringVal.split('.')[0];
|
|
72
|
-
}
|
|
73
|
-
else if(text.endsWith('.'))
|
|
74
|
-
{
|
|
75
|
-
text = stringVal.split('.')[0] + '.';
|
|
76
|
-
}
|
|
77
|
-
else
|
|
78
|
-
{
|
|
79
|
-
text = stringVal.substring(0, stringVal.length - Math.max(0, decimals - text.split('.')[1].length));
|
|
80
|
-
}
|
|
81
|
-
setVisualValue(text);
|
|
82
|
-
}
|
|
83
|
-
}// visual <<
|
|
93
|
+
setVisualValue(text);
|
|
84
94
|
|
|
85
95
|
if(onChange)
|
|
86
96
|
{
|
|
87
|
-
if(val !== 0)
|
|
88
|
-
{
|
|
89
|
-
if(decimals > 0)
|
|
90
|
-
{
|
|
91
|
-
val = Math.round(val * Math.pow(10, decimals)) / Math.pow(10, decimals);
|
|
92
|
-
}
|
|
93
|
-
else
|
|
94
|
-
{
|
|
95
|
-
val = Math.round(val);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
97
|
const newEvent = {
|
|
100
98
|
...event,
|
|
101
99
|
target:{
|
|
@@ -35,7 +35,7 @@ const RemovableNumericTextField = LeRed.memo(({onRemove, onChange, onSelect, cla
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
return (<>
|
|
38
|
-
<NumericTextField className={'lowentry-mui--removable-textfield lowentry-mui--removable-numeric-textfield ' + (className ?? '')} onRenderValue={LeMuiUtils.prependHiddenChar} onChange={onChanged} onSelect={onSelected}>{children}</NumericTextField>
|
|
38
|
+
<NumericTextField className={'lowentry-mui--removable-textfield lowentry-mui--removable-numeric-textfield ' + (className ?? '')} onRenderValue={LeMuiUtils.prependHiddenChar} onChange={onChanged} onSelect={onSelected} {...props}>{children}</NumericTextField>
|
|
39
39
|
</>);
|
|
40
40
|
});
|
|
41
41
|
export default RemovableNumericTextField;
|
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
function
|
|
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 };
|
|
2
29
|
//# sourceMappingURL=style-inject.es-1f59c1d0.js.map
|
|
@@ -1 +1 @@
|
|
|
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":[
|
|
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;;;;"}
|