@bpmn-io/properties-panel 3.41.2 → 3.41.3
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/index.esm.js +43 -30
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +43 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1943,6 +1943,7 @@ function JsonEditor(props) {
|
|
|
1943
1943
|
* @param {boolean} [props.disabled]
|
|
1944
1944
|
* @param {string} [props.placeholder]
|
|
1945
1945
|
* @param {string} [props.tooltip]
|
|
1946
|
+
* @param {Function} [props.validate]
|
|
1946
1947
|
*/
|
|
1947
1948
|
function JsonEditorEntry(props) {
|
|
1948
1949
|
const {
|
|
@@ -1955,25 +1956,30 @@ function JsonEditorEntry(props) {
|
|
|
1955
1956
|
setValue,
|
|
1956
1957
|
disabled,
|
|
1957
1958
|
placeholder,
|
|
1958
|
-
tooltip
|
|
1959
|
+
tooltip,
|
|
1960
|
+
validate
|
|
1959
1961
|
} = props;
|
|
1960
1962
|
const globalError = useError(id);
|
|
1961
1963
|
let value = getValue(element);
|
|
1964
|
+
const [localError, setLocalError] = useState(() => computeError(validate, value));
|
|
1962
1965
|
const [editorValue, setEditorValue] = useState(value);
|
|
1963
1966
|
useEffect(() => {
|
|
1964
1967
|
if (value === editorValue) {
|
|
1965
1968
|
return;
|
|
1966
1969
|
}
|
|
1967
1970
|
setEditorValue(value);
|
|
1968
|
-
|
|
1971
|
+
setLocalError(computeError(validate, value));
|
|
1972
|
+
}, [value, validate]);
|
|
1969
1973
|
const onInput = useStaticCallback(newValue => {
|
|
1970
1974
|
setEditorValue(newValue);
|
|
1971
1975
|
const currentValue = getValue(element);
|
|
1972
1976
|
if (newValue !== currentValue) {
|
|
1973
|
-
|
|
1977
|
+
const newValidationError = computeError(validate, newValue);
|
|
1978
|
+
setValue(newValue, newValidationError);
|
|
1979
|
+
setLocalError(newValidationError);
|
|
1974
1980
|
}
|
|
1975
1981
|
});
|
|
1976
|
-
const error = globalError ||
|
|
1982
|
+
const error = globalError || localError;
|
|
1977
1983
|
return jsxs("div", {
|
|
1978
1984
|
class: classnames('bio-properties-panel-entry', error && 'has-error'),
|
|
1979
1985
|
"data-entry-id": id,
|
|
@@ -2007,6 +2013,9 @@ function isEdited$8(node) {
|
|
|
2007
2013
|
|
|
2008
2014
|
// helpers /////////////////
|
|
2009
2015
|
|
|
2016
|
+
function computeError(validate, value) {
|
|
2017
|
+
return (isFunction(validate) ? validate(value) : null) || validateJson(value);
|
|
2018
|
+
}
|
|
2010
2019
|
function validateJson(value) {
|
|
2011
2020
|
if (!value || !value.trim()) return null;
|
|
2012
2021
|
try {
|
|
@@ -2583,12 +2592,14 @@ function NumberFieldEntry(props) {
|
|
|
2583
2592
|
}
|
|
2584
2593
|
}, [value, validate]);
|
|
2585
2594
|
const onInput = newValue => {
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2595
|
+
if (newValue !== value) {
|
|
2596
|
+
let newValidationError = null;
|
|
2597
|
+
if (isFunction(validate)) {
|
|
2598
|
+
newValidationError = validate(newValue) || null;
|
|
2599
|
+
}
|
|
2600
|
+
setValue(newValue, newValidationError);
|
|
2601
|
+
setLocalError(newValidationError);
|
|
2589
2602
|
}
|
|
2590
|
-
setValue(newValue, newValidationError);
|
|
2591
|
-
setLocalError(newValidationError);
|
|
2592
2603
|
};
|
|
2593
2604
|
const error = globalError || localError;
|
|
2594
2605
|
return jsxs("div", {
|
|
@@ -3183,16 +3194,16 @@ function FeelEntry(props) {
|
|
|
3183
3194
|
}, [value, validate]);
|
|
3184
3195
|
const onInput = useStaticCallback(newValue => {
|
|
3185
3196
|
const value = getValue(element);
|
|
3186
|
-
let newValidationError = null;
|
|
3187
|
-
if (isFunction(validate)) {
|
|
3188
|
-
newValidationError = validate(newValue) || null;
|
|
3189
|
-
}
|
|
3190
3197
|
|
|
3191
|
-
// don't create multiple commandStack entries for the same value
|
|
3198
|
+
// don't create multiple commandStack entries and do validation for the same value
|
|
3192
3199
|
if (newValue !== value) {
|
|
3200
|
+
let newValidationError = null;
|
|
3201
|
+
if (isFunction(validate)) {
|
|
3202
|
+
newValidationError = validate(newValue) || null;
|
|
3203
|
+
}
|
|
3193
3204
|
setValue(newValue, newValidationError);
|
|
3205
|
+
setValidationError(newValidationError);
|
|
3194
3206
|
}
|
|
3195
|
-
setValidationError(newValidationError);
|
|
3196
3207
|
});
|
|
3197
3208
|
const onError = useCallback(err => {
|
|
3198
3209
|
setLocalError(err);
|
|
@@ -3915,12 +3926,14 @@ function SelectEntry(props) {
|
|
|
3915
3926
|
}
|
|
3916
3927
|
}, [value, validate]);
|
|
3917
3928
|
const onChange = newValue => {
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3929
|
+
if (newValue !== value) {
|
|
3930
|
+
let newValidationError = null;
|
|
3931
|
+
if (isFunction(validate)) {
|
|
3932
|
+
newValidationError = validate(newValue) || null;
|
|
3933
|
+
}
|
|
3934
|
+
setValue(newValue, newValidationError);
|
|
3935
|
+
setLocalError(newValidationError);
|
|
3921
3936
|
}
|
|
3922
|
-
setValue(newValue, newValidationError);
|
|
3923
|
-
setLocalError(newValidationError);
|
|
3924
3937
|
};
|
|
3925
3938
|
const error = globalError || localError;
|
|
3926
3939
|
return jsxs("div", {
|
|
@@ -4195,14 +4208,14 @@ function TextAreaEntry(props) {
|
|
|
4195
4208
|
}, [value, validate]);
|
|
4196
4209
|
const onInput = useStaticCallback(newValue => {
|
|
4197
4210
|
const value = getValue(element);
|
|
4198
|
-
let newValidationError = null;
|
|
4199
|
-
if (isFunction(validate)) {
|
|
4200
|
-
newValidationError = validate(newValue) || null;
|
|
4201
|
-
}
|
|
4202
4211
|
if (newValue !== value) {
|
|
4212
|
+
let newValidationError = null;
|
|
4213
|
+
if (isFunction(validate)) {
|
|
4214
|
+
newValidationError = validate(newValue) || null;
|
|
4215
|
+
}
|
|
4203
4216
|
setValue(newValue, newValidationError);
|
|
4217
|
+
setLocalError(newValidationError);
|
|
4204
4218
|
}
|
|
4205
|
-
setLocalError(newValidationError);
|
|
4206
4219
|
});
|
|
4207
4220
|
const error = globalError || localError;
|
|
4208
4221
|
return jsxs("div", {
|
|
@@ -4394,14 +4407,14 @@ function TextfieldEntry(props) {
|
|
|
4394
4407
|
}, [value, validate]);
|
|
4395
4408
|
const onInput = useStaticCallback(newValue => {
|
|
4396
4409
|
const value = getValue(element);
|
|
4397
|
-
let newValidationError = null;
|
|
4398
|
-
if (isFunction(validate)) {
|
|
4399
|
-
newValidationError = validate(newValue) || null;
|
|
4400
|
-
}
|
|
4401
4410
|
if (newValue !== value) {
|
|
4411
|
+
let newValidationError = null;
|
|
4412
|
+
if (isFunction(validate)) {
|
|
4413
|
+
newValidationError = validate(newValue) || null;
|
|
4414
|
+
}
|
|
4402
4415
|
setValue(newValue, newValidationError);
|
|
4416
|
+
setLocalError(newValidationError);
|
|
4403
4417
|
}
|
|
4404
|
-
setLocalError(newValidationError);
|
|
4405
4418
|
});
|
|
4406
4419
|
const error = globalError || localError;
|
|
4407
4420
|
return jsxs("div", {
|