@bpmn-io/properties-panel 3.41.2 → 3.42.0
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 +49 -33
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +49 -33
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1047,9 +1047,12 @@ const DEFAULT_TOOLTIP = {};
|
|
|
1047
1047
|
* A basic properties panel component. Describes *how* content will be rendered, accepts
|
|
1048
1048
|
* data from implementor to describe *what* will be rendered.
|
|
1049
1049
|
*
|
|
1050
|
+
* If `headerProvider` is omitted (or `null`), the built-in `<Header>` is not rendered;
|
|
1051
|
+
* consumers can render `<Header>` standalone elsewhere using the same provider shape.
|
|
1052
|
+
*
|
|
1050
1053
|
* @param {Object} props
|
|
1051
1054
|
* @param {Object|Array} props.element
|
|
1052
|
-
* @param {import('./components/Header').HeaderProvider} props.headerProvider
|
|
1055
|
+
* @param {import('./components/Header').HeaderProvider} [props.headerProvider]
|
|
1053
1056
|
* @param {PlaceholderProvider} [props.placeholderProvider]
|
|
1054
1057
|
* @param {Array<GroupDefinition|ListGroupDefinition>} props.groups
|
|
1055
1058
|
* @param {Object} [props.layoutConfig]
|
|
@@ -1178,10 +1181,10 @@ function PropertiesPanel(props) {
|
|
|
1178
1181
|
value: eventContext,
|
|
1179
1182
|
children: jsxs("div", {
|
|
1180
1183
|
class: "bio-properties-panel",
|
|
1181
|
-
children: [jsx(Header, {
|
|
1184
|
+
children: [headerProvider ? jsx(Header, {
|
|
1182
1185
|
element: element,
|
|
1183
1186
|
headerProvider: headerProvider
|
|
1184
|
-
}), jsx("div", {
|
|
1187
|
+
}) : null, jsx("div", {
|
|
1185
1188
|
class: "bio-properties-panel-scroll-container",
|
|
1186
1189
|
children: groups.map(group => {
|
|
1187
1190
|
const {
|
|
@@ -1943,6 +1946,7 @@ function JsonEditor(props) {
|
|
|
1943
1946
|
* @param {boolean} [props.disabled]
|
|
1944
1947
|
* @param {string} [props.placeholder]
|
|
1945
1948
|
* @param {string} [props.tooltip]
|
|
1949
|
+
* @param {Function} [props.validate]
|
|
1946
1950
|
*/
|
|
1947
1951
|
function JsonEditorEntry(props) {
|
|
1948
1952
|
const {
|
|
@@ -1955,25 +1959,30 @@ function JsonEditorEntry(props) {
|
|
|
1955
1959
|
setValue,
|
|
1956
1960
|
disabled,
|
|
1957
1961
|
placeholder,
|
|
1958
|
-
tooltip
|
|
1962
|
+
tooltip,
|
|
1963
|
+
validate
|
|
1959
1964
|
} = props;
|
|
1960
1965
|
const globalError = useError(id);
|
|
1961
1966
|
let value = getValue(element);
|
|
1967
|
+
const [localError, setLocalError] = useState(() => computeError(validate, value));
|
|
1962
1968
|
const [editorValue, setEditorValue] = useState(value);
|
|
1963
1969
|
useEffect(() => {
|
|
1964
1970
|
if (value === editorValue) {
|
|
1965
1971
|
return;
|
|
1966
1972
|
}
|
|
1967
1973
|
setEditorValue(value);
|
|
1968
|
-
|
|
1974
|
+
setLocalError(computeError(validate, value));
|
|
1975
|
+
}, [value, validate]);
|
|
1969
1976
|
const onInput = useStaticCallback(newValue => {
|
|
1970
1977
|
setEditorValue(newValue);
|
|
1971
1978
|
const currentValue = getValue(element);
|
|
1972
1979
|
if (newValue !== currentValue) {
|
|
1973
|
-
|
|
1980
|
+
const newValidationError = computeError(validate, newValue);
|
|
1981
|
+
setValue(newValue, newValidationError);
|
|
1982
|
+
setLocalError(newValidationError);
|
|
1974
1983
|
}
|
|
1975
1984
|
});
|
|
1976
|
-
const error = globalError ||
|
|
1985
|
+
const error = globalError || localError;
|
|
1977
1986
|
return jsxs("div", {
|
|
1978
1987
|
class: classnames('bio-properties-panel-entry', error && 'has-error'),
|
|
1979
1988
|
"data-entry-id": id,
|
|
@@ -2007,6 +2016,9 @@ function isEdited$8(node) {
|
|
|
2007
2016
|
|
|
2008
2017
|
// helpers /////////////////
|
|
2009
2018
|
|
|
2019
|
+
function computeError(validate, value) {
|
|
2020
|
+
return (isFunction(validate) ? validate(value) : null) || validateJson(value);
|
|
2021
|
+
}
|
|
2010
2022
|
function validateJson(value) {
|
|
2011
2023
|
if (!value || !value.trim()) return null;
|
|
2012
2024
|
try {
|
|
@@ -2583,12 +2595,14 @@ function NumberFieldEntry(props) {
|
|
|
2583
2595
|
}
|
|
2584
2596
|
}, [value, validate]);
|
|
2585
2597
|
const onInput = newValue => {
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2598
|
+
if (newValue !== value) {
|
|
2599
|
+
let newValidationError = null;
|
|
2600
|
+
if (isFunction(validate)) {
|
|
2601
|
+
newValidationError = validate(newValue) || null;
|
|
2602
|
+
}
|
|
2603
|
+
setValue(newValue, newValidationError);
|
|
2604
|
+
setLocalError(newValidationError);
|
|
2589
2605
|
}
|
|
2590
|
-
setValue(newValue, newValidationError);
|
|
2591
|
-
setLocalError(newValidationError);
|
|
2592
2606
|
};
|
|
2593
2607
|
const error = globalError || localError;
|
|
2594
2608
|
return jsxs("div", {
|
|
@@ -3183,16 +3197,16 @@ function FeelEntry(props) {
|
|
|
3183
3197
|
}, [value, validate]);
|
|
3184
3198
|
const onInput = useStaticCallback(newValue => {
|
|
3185
3199
|
const value = getValue(element);
|
|
3186
|
-
let newValidationError = null;
|
|
3187
|
-
if (isFunction(validate)) {
|
|
3188
|
-
newValidationError = validate(newValue) || null;
|
|
3189
|
-
}
|
|
3190
3200
|
|
|
3191
|
-
// don't create multiple commandStack entries for the same value
|
|
3201
|
+
// don't create multiple commandStack entries and do validation for the same value
|
|
3192
3202
|
if (newValue !== value) {
|
|
3203
|
+
let newValidationError = null;
|
|
3204
|
+
if (isFunction(validate)) {
|
|
3205
|
+
newValidationError = validate(newValue) || null;
|
|
3206
|
+
}
|
|
3193
3207
|
setValue(newValue, newValidationError);
|
|
3208
|
+
setValidationError(newValidationError);
|
|
3194
3209
|
}
|
|
3195
|
-
setValidationError(newValidationError);
|
|
3196
3210
|
});
|
|
3197
3211
|
const onError = useCallback(err => {
|
|
3198
3212
|
setLocalError(err);
|
|
@@ -3915,12 +3929,14 @@ function SelectEntry(props) {
|
|
|
3915
3929
|
}
|
|
3916
3930
|
}, [value, validate]);
|
|
3917
3931
|
const onChange = newValue => {
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3932
|
+
if (newValue !== value) {
|
|
3933
|
+
let newValidationError = null;
|
|
3934
|
+
if (isFunction(validate)) {
|
|
3935
|
+
newValidationError = validate(newValue) || null;
|
|
3936
|
+
}
|
|
3937
|
+
setValue(newValue, newValidationError);
|
|
3938
|
+
setLocalError(newValidationError);
|
|
3921
3939
|
}
|
|
3922
|
-
setValue(newValue, newValidationError);
|
|
3923
|
-
setLocalError(newValidationError);
|
|
3924
3940
|
};
|
|
3925
3941
|
const error = globalError || localError;
|
|
3926
3942
|
return jsxs("div", {
|
|
@@ -4195,14 +4211,14 @@ function TextAreaEntry(props) {
|
|
|
4195
4211
|
}, [value, validate]);
|
|
4196
4212
|
const onInput = useStaticCallback(newValue => {
|
|
4197
4213
|
const value = getValue(element);
|
|
4198
|
-
let newValidationError = null;
|
|
4199
|
-
if (isFunction(validate)) {
|
|
4200
|
-
newValidationError = validate(newValue) || null;
|
|
4201
|
-
}
|
|
4202
4214
|
if (newValue !== value) {
|
|
4215
|
+
let newValidationError = null;
|
|
4216
|
+
if (isFunction(validate)) {
|
|
4217
|
+
newValidationError = validate(newValue) || null;
|
|
4218
|
+
}
|
|
4203
4219
|
setValue(newValue, newValidationError);
|
|
4220
|
+
setLocalError(newValidationError);
|
|
4204
4221
|
}
|
|
4205
|
-
setLocalError(newValidationError);
|
|
4206
4222
|
});
|
|
4207
4223
|
const error = globalError || localError;
|
|
4208
4224
|
return jsxs("div", {
|
|
@@ -4394,14 +4410,14 @@ function TextfieldEntry(props) {
|
|
|
4394
4410
|
}, [value, validate]);
|
|
4395
4411
|
const onInput = useStaticCallback(newValue => {
|
|
4396
4412
|
const value = getValue(element);
|
|
4397
|
-
let newValidationError = null;
|
|
4398
|
-
if (isFunction(validate)) {
|
|
4399
|
-
newValidationError = validate(newValue) || null;
|
|
4400
|
-
}
|
|
4401
4413
|
if (newValue !== value) {
|
|
4414
|
+
let newValidationError = null;
|
|
4415
|
+
if (isFunction(validate)) {
|
|
4416
|
+
newValidationError = validate(newValue) || null;
|
|
4417
|
+
}
|
|
4402
4418
|
setValue(newValue, newValidationError);
|
|
4419
|
+
setLocalError(newValidationError);
|
|
4403
4420
|
}
|
|
4404
|
-
setLocalError(newValidationError);
|
|
4405
4421
|
});
|
|
4406
4422
|
const error = globalError || localError;
|
|
4407
4423
|
return jsxs("div", {
|