awing-library 2.1.2-dev.543 → 2.1.2-dev.545
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/dist/AWING/DataInput/components/NumberInput.d.ts.map +1 -1
- package/dist/AWING/DataInput/components/NumberInput.js +15 -5
- package/dist/AWING/DataInput/components/TextInput.d.ts.map +1 -1
- package/dist/AWING/DataInput/components/TextInput.js +31 -3
- package/dist/AWING/MonacoEditor/container.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../../src/AWING/DataInput/components/NumberInput.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB,CAAC,MAAM,CAAC;IACtE,IAAI,EAAE,UAAU,CAAC,MAAM,GAAG,QAAQ,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,UAOpE;AAED,eAAO,MAAM,WAAW,oBAAqB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../../src/AWING/DataInput/components/NumberInput.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB,CAAC,MAAM,CAAC;IACtE,IAAI,EAAE,UAAU,CAAC,MAAM,GAAG,QAAQ,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,UAOpE;AAED,eAAO,MAAM,WAAW,oBAAqB,qBAAqB,4CAmFjE,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next";
|
|
|
3
3
|
import i18n from "../../../translate/i18n.js";
|
|
4
4
|
import NumberFormat from "../../NumberFormat/index.js";
|
|
5
5
|
import { numberNotNullValid } from "../../ultis/index.js";
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
6
|
+
import { useEffect, useRef, useState } from "react";
|
|
7
7
|
function clampNumber(value, min, max) {
|
|
8
8
|
let result = value;
|
|
9
9
|
if (void 0 !== min) result = Math.max(result, min);
|
|
@@ -16,8 +16,9 @@ const NumberInput = (fieldDefinition)=>{
|
|
|
16
16
|
});
|
|
17
17
|
const { name, defaultValue, value, onChange, error, disableHelperText, helperText, min, max, onValidateCustom, ...other } = fieldDefinition;
|
|
18
18
|
const [valueInput, setValueInput] = useState(defaultValue || value || '');
|
|
19
|
+
const isComposing = useRef(false);
|
|
19
20
|
useEffect(()=>{
|
|
20
|
-
if (valueInput !== value) setValueInput(value ?? '');
|
|
21
|
+
if (!isComposing.current && valueInput !== value) setValueInput(value ?? '');
|
|
21
22
|
}, [
|
|
22
23
|
value
|
|
23
24
|
]);
|
|
@@ -25,16 +26,18 @@ const NumberInput = (fieldDefinition)=>{
|
|
|
25
26
|
if (onValidateCustom) return onValidateCustom(Number(val));
|
|
26
27
|
return (void 0 === min || Number(val) >= min) && (void 0 === max || Number(val) <= max) && numberNotNullValid(Number(val));
|
|
27
28
|
};
|
|
28
|
-
const
|
|
29
|
-
const newValue = event.target.value;
|
|
29
|
+
const processChange = (newValue)=>{
|
|
30
30
|
if ('-' === newValue || '' === newValue) return void ('-' === newValue && void 0 !== min && min >= 0 ? setValueInput(0) : setValueInput(newValue));
|
|
31
31
|
const numberValue = Number(newValue);
|
|
32
32
|
if (!isNaN(numberValue)) {
|
|
33
33
|
const currentValue = clampNumber(numberValue, min, max);
|
|
34
34
|
setValueInput(currentValue);
|
|
35
|
-
onChange && onChange(currentValue, onValidate(currentValue), numberValue);
|
|
35
|
+
if (!isComposing.current) onChange && onChange(currentValue, onValidate(currentValue), numberValue);
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
const handleChange = (event)=>{
|
|
39
|
+
processChange(event.target.value);
|
|
40
|
+
};
|
|
38
41
|
return /*#__PURE__*/ jsx(NumberFormat, {
|
|
39
42
|
id: name?.toString(),
|
|
40
43
|
name: name?.toString(),
|
|
@@ -42,6 +45,13 @@ const NumberInput = (fieldDefinition)=>{
|
|
|
42
45
|
variant: "standard",
|
|
43
46
|
value: valueInput,
|
|
44
47
|
onChange: handleChange,
|
|
48
|
+
onCompositionStart: ()=>{
|
|
49
|
+
isComposing.current = true;
|
|
50
|
+
},
|
|
51
|
+
onCompositionEnd: (event)=>{
|
|
52
|
+
isComposing.current = false;
|
|
53
|
+
processChange(event.target.value);
|
|
54
|
+
},
|
|
45
55
|
error: error,
|
|
46
56
|
helperText: !disableHelperText && error ? helperText ?? t('Common.InvalidData') : '',
|
|
47
57
|
...other
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../../src/AWING/DataInput/components/TextInput.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB,CAAC,MAAM,CAAC;IAEpE,IAAI,EACE,UAAU,CAAC,IAAI,GACf,UAAU,CAAC,KAAK,GAChB,UAAU,CAAC,GAAG,GACd,UAAU,CAAC,SAAS,GACpB,UAAU,CAAC,GAAG,GACd,UAAU,CAAC,QAAQ,GACnB,MAAM,GACN,OAAO,GACP,KAAK,GACL,WAAW,GACX,KAAK,GACL,UAAU,CAAC;IACjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACzB;;;;;OAKG;IACH,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,SAAS,oBAAqB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../../src/AWING/DataInput/components/TextInput.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB,CAAC,MAAM,CAAC;IAEpE,IAAI,EACE,UAAU,CAAC,IAAI,GACf,UAAU,CAAC,KAAK,GAChB,UAAU,CAAC,GAAG,GACd,UAAU,CAAC,SAAS,GACpB,UAAU,CAAC,GAAG,GACd,UAAU,CAAC,QAAQ,GACnB,MAAM,GACN,OAAO,GACP,KAAK,GACL,WAAW,GACX,KAAK,GACL,UAAU,CAAC;IACjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACzB;;;;;OAKG;IACH,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,SAAS,oBAAqB,mBAAmB,4CA6F7D,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
4
|
import { TextField } from "@mui/material";
|
|
5
5
|
import i18n from "../../../translate/i18n.js";
|
|
@@ -11,6 +11,14 @@ const TextInput_TextInput = (fieldDefinition)=>{
|
|
|
11
11
|
});
|
|
12
12
|
const { name, value, onChange, error, disableHelperText, helperText, type, length, pattern, onValidateCustom, fieldName, ...other } = fieldDefinition;
|
|
13
13
|
const [errorText, setErrorText] = useState(t('Common.InvalidData'));
|
|
14
|
+
const [localValue, setLocalValue] = useState(value ?? '');
|
|
15
|
+
const isComposing = useRef(false);
|
|
16
|
+
const isFocused = useRef(false);
|
|
17
|
+
useEffect(()=>{
|
|
18
|
+
if (!isComposing.current && !isFocused.current && value !== localValue) setLocalValue(value ?? '');
|
|
19
|
+
}, [
|
|
20
|
+
value
|
|
21
|
+
]);
|
|
14
22
|
const onValidate = (val)=>{
|
|
15
23
|
if (onValidateCustom) return onValidateCustom(val ?? '');
|
|
16
24
|
if (type === FIELD_TYPE.EMAIL) return emailValid(val ?? '');
|
|
@@ -24,6 +32,10 @@ const TextInput_TextInput = (fieldDefinition)=>{
|
|
|
24
32
|
return valid;
|
|
25
33
|
}
|
|
26
34
|
};
|
|
35
|
+
const handleTextChange = (newValue)=>{
|
|
36
|
+
setLocalValue(newValue);
|
|
37
|
+
if (!isComposing.current) onChange && onChange(newValue, onValidate(newValue));
|
|
38
|
+
};
|
|
27
39
|
return /*#__PURE__*/ jsx(TextField, {
|
|
28
40
|
id: name?.toString(),
|
|
29
41
|
name: name?.toString(),
|
|
@@ -33,8 +45,24 @@ const TextInput_TextInput = (fieldDefinition)=>{
|
|
|
33
45
|
multiline: type === FIELD_TYPE.TEXT_AREA,
|
|
34
46
|
error: error,
|
|
35
47
|
helperText: !disableHelperText && (error ? helperText ?? errorText : helperText),
|
|
36
|
-
value:
|
|
37
|
-
onChange: (event)=>
|
|
48
|
+
value: localValue,
|
|
49
|
+
onChange: (event)=>handleTextChange(event.target.value),
|
|
50
|
+
onFocus: ()=>{
|
|
51
|
+
isFocused.current = true;
|
|
52
|
+
},
|
|
53
|
+
onBlur: (event)=>{
|
|
54
|
+
isFocused.current = false;
|
|
55
|
+
const finalValue = event.target.value;
|
|
56
|
+
onChange && onChange(finalValue, onValidate(finalValue));
|
|
57
|
+
},
|
|
58
|
+
onCompositionStart: ()=>{
|
|
59
|
+
isComposing.current = true;
|
|
60
|
+
},
|
|
61
|
+
onCompositionEnd: (event)=>{
|
|
62
|
+
isComposing.current = false;
|
|
63
|
+
const finalValue = event.target.value;
|
|
64
|
+
handleTextChange(finalValue);
|
|
65
|
+
},
|
|
38
66
|
disabled: fieldDefinition.readOnly,
|
|
39
67
|
...other
|
|
40
68
|
});
|
|
@@ -3,7 +3,7 @@ import react from "@monaco-editor/react";
|
|
|
3
3
|
import { formatJSON } from "../../Helpers/index.js";
|
|
4
4
|
import { useEffect, useState } from "react";
|
|
5
5
|
const MonacoEditorContainer = (props)=>{
|
|
6
|
-
const { value, height, language, onChange, isShowMinimap, disableFormatJSON = false,
|
|
6
|
+
const { value, height, language, onChange, isShowMinimap, disableFormatJSON = false, options } = props;
|
|
7
7
|
const [valueGetter, setValueGetter] = useState(void 0);
|
|
8
8
|
useEffect(()=>{
|
|
9
9
|
disableFormatJSON ? setValueGetter(value) : setValueGetter(formatJSON(value ?? ''));
|