@dartech/arsenal-ui 1.4.20 → 1.4.21
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/index.js +18 -5
- package/package.json +1 -1
- package/src/lib/Forms/ControlAceEditor.d.ts +1 -0
package/index.js
CHANGED
@@ -1066,9 +1066,10 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1066
1066
|
fontSize = 16,
|
1067
1067
|
validate = true,
|
1068
1068
|
parseValue,
|
1069
|
-
requiredErrorText = ''
|
1069
|
+
requiredErrorText = '',
|
1070
|
+
useCleanValue
|
1070
1071
|
} = _a,
|
1071
|
-
otherProps = __rest(_a, ["control", "name", "mode", "label", "width", "height", "readOnly", "required", "validateJson", "hideErrorMessage", "fontSize", "validate", "parseValue", "requiredErrorText"]);
|
1072
|
+
otherProps = __rest(_a, ["control", "name", "mode", "label", "width", "height", "readOnly", "required", "validateJson", "hideErrorMessage", "fontSize", "validate", "parseValue", "requiredErrorText", "useCleanValue"]);
|
1072
1073
|
const _b = useController({
|
1073
1074
|
control,
|
1074
1075
|
name,
|
@@ -1106,6 +1107,16 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1106
1107
|
javascript: [langs.javascript()],
|
1107
1108
|
python: [langs.python()]
|
1108
1109
|
}), []);
|
1110
|
+
const safeValue = useMemo(() => {
|
1111
|
+
if (mode === 'json' && typeof value !== 'string') {
|
1112
|
+
if (value === null) return '';
|
1113
|
+
return useCleanValue ? JSON.stringify(value, null, 2).replace(/\\"/g, '') : JSON.stringify(value, null, 2);
|
1114
|
+
}
|
1115
|
+
if (typeof value === 'string') {
|
1116
|
+
return useCleanValue ? value.replace(/\\"/g, '') : value;
|
1117
|
+
}
|
1118
|
+
return value;
|
1119
|
+
}, [value, useCleanValue, mode]);
|
1109
1120
|
const handleChange = useCallback(value => {
|
1110
1121
|
if (parseValue) {
|
1111
1122
|
try {
|
@@ -1157,7 +1168,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1157
1168
|
isolation: 'isolate'
|
1158
1169
|
},
|
1159
1170
|
readOnly: readOnly,
|
1160
|
-
value:
|
1171
|
+
value: safeValue,
|
1161
1172
|
onChange: handleChange,
|
1162
1173
|
extensions: extensions[mode]
|
1163
1174
|
}, otherProps)), error && !hideErrorMessage && jsx(FormHelperText, Object.assign({
|
@@ -6035,7 +6046,8 @@ const PropertyFiller = ({
|
|
6035
6046
|
control: control,
|
6036
6047
|
label: valueLabel,
|
6037
6048
|
parseValue: true,
|
6038
|
-
hideErrorMessage: true
|
6049
|
+
hideErrorMessage: true,
|
6050
|
+
useCleanValue: true
|
6039
6051
|
}) : jsx(ControlInput, {
|
6040
6052
|
control: control,
|
6041
6053
|
name: name,
|
@@ -6294,7 +6306,8 @@ const MultiplePropertyFiller = ({
|
|
6294
6306
|
control: control,
|
6295
6307
|
label: valueLabel,
|
6296
6308
|
parseValue: true,
|
6297
|
-
hideErrorMessage: true
|
6309
|
+
hideErrorMessage: true,
|
6310
|
+
useCleanValue: true
|
6298
6311
|
}) : jsx(ControlInput, {
|
6299
6312
|
required: true,
|
6300
6313
|
hideErrorMessage: true,
|
package/package.json
CHANGED
@@ -17,6 +17,7 @@ export interface ControlAceEditorProps {
|
|
17
17
|
parseValue?: boolean;
|
18
18
|
requiredErrorText?: string;
|
19
19
|
[key: string]: unknown;
|
20
|
+
useCleanValue?: boolean;
|
20
21
|
}
|
21
22
|
export declare const ControlAceEditor: import("react").ForwardRefExoticComponent<Omit<ControlAceEditorProps, "ref"> & import("react").RefAttributes<ReactCodeMirrorRef>>;
|
22
23
|
export default ControlAceEditor;
|