@bpmn-io/properties-panel 1.5.1 → 1.6.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 +31 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +31 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2467,6 +2467,7 @@ function Select(props) {
|
|
|
2467
2467
|
* @param {Function} props.onBlur
|
|
2468
2468
|
* @param {Function} props.getOptions
|
|
2469
2469
|
* @param {boolean} [props.disabled]
|
|
2470
|
+
* @param {Function} [props.validate]
|
|
2470
2471
|
*/
|
|
2471
2472
|
function SelectEntry(props) {
|
|
2472
2473
|
const {
|
|
@@ -2479,11 +2480,37 @@ function SelectEntry(props) {
|
|
|
2479
2480
|
getOptions,
|
|
2480
2481
|
disabled,
|
|
2481
2482
|
onFocus,
|
|
2482
|
-
onBlur
|
|
2483
|
+
onBlur,
|
|
2484
|
+
validate
|
|
2483
2485
|
} = props;
|
|
2484
|
-
const value = getValue(element);
|
|
2485
2486
|
const options = getOptions(element);
|
|
2486
|
-
const
|
|
2487
|
+
const [cachedInvalidValue, setCachedInvalidValue] = hooks.useState(null);
|
|
2488
|
+
const globalError = useError(id);
|
|
2489
|
+
const [localError, setLocalError] = hooks.useState(null);
|
|
2490
|
+
let value = getValue(element);
|
|
2491
|
+
const previousValue = usePrevious(value);
|
|
2492
|
+
hooks.useEffect(() => {
|
|
2493
|
+
if (minDash.isFunction(validate)) {
|
|
2494
|
+
const newValidationError = validate(value) || null;
|
|
2495
|
+
setLocalError(newValidationError);
|
|
2496
|
+
}
|
|
2497
|
+
}, [value]);
|
|
2498
|
+
const onChange = newValue => {
|
|
2499
|
+
let newValidationError = null;
|
|
2500
|
+
if (minDash.isFunction(validate)) {
|
|
2501
|
+
newValidationError = validate(newValue) || null;
|
|
2502
|
+
}
|
|
2503
|
+
if (newValidationError) {
|
|
2504
|
+
setCachedInvalidValue(newValue);
|
|
2505
|
+
} else {
|
|
2506
|
+
setValue(newValue);
|
|
2507
|
+
}
|
|
2508
|
+
setLocalError(newValidationError);
|
|
2509
|
+
};
|
|
2510
|
+
if (previousValue === value && localError) {
|
|
2511
|
+
value = cachedInvalidValue;
|
|
2512
|
+
}
|
|
2513
|
+
const error = globalError || localError;
|
|
2487
2514
|
return jsxRuntime.jsxs("div", {
|
|
2488
2515
|
class: classnames__default["default"]('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
2489
2516
|
"data-entry-id": id,
|
|
@@ -2491,7 +2518,7 @@ function SelectEntry(props) {
|
|
|
2491
2518
|
id: id,
|
|
2492
2519
|
label: label,
|
|
2493
2520
|
value: value,
|
|
2494
|
-
onChange:
|
|
2521
|
+
onChange: onChange,
|
|
2495
2522
|
onFocus: onFocus,
|
|
2496
2523
|
onBlur: onBlur,
|
|
2497
2524
|
options: options,
|