@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.esm.js
CHANGED
|
@@ -2458,6 +2458,7 @@ function Select(props) {
|
|
|
2458
2458
|
* @param {Function} props.onBlur
|
|
2459
2459
|
* @param {Function} props.getOptions
|
|
2460
2460
|
* @param {boolean} [props.disabled]
|
|
2461
|
+
* @param {Function} [props.validate]
|
|
2461
2462
|
*/
|
|
2462
2463
|
function SelectEntry(props) {
|
|
2463
2464
|
const {
|
|
@@ -2470,11 +2471,37 @@ function SelectEntry(props) {
|
|
|
2470
2471
|
getOptions,
|
|
2471
2472
|
disabled,
|
|
2472
2473
|
onFocus,
|
|
2473
|
-
onBlur
|
|
2474
|
+
onBlur,
|
|
2475
|
+
validate
|
|
2474
2476
|
} = props;
|
|
2475
|
-
const value = getValue(element);
|
|
2476
2477
|
const options = getOptions(element);
|
|
2477
|
-
const
|
|
2478
|
+
const [cachedInvalidValue, setCachedInvalidValue] = useState(null);
|
|
2479
|
+
const globalError = useError(id);
|
|
2480
|
+
const [localError, setLocalError] = useState(null);
|
|
2481
|
+
let value = getValue(element);
|
|
2482
|
+
const previousValue = usePrevious(value);
|
|
2483
|
+
useEffect(() => {
|
|
2484
|
+
if (isFunction(validate)) {
|
|
2485
|
+
const newValidationError = validate(value) || null;
|
|
2486
|
+
setLocalError(newValidationError);
|
|
2487
|
+
}
|
|
2488
|
+
}, [value]);
|
|
2489
|
+
const onChange = newValue => {
|
|
2490
|
+
let newValidationError = null;
|
|
2491
|
+
if (isFunction(validate)) {
|
|
2492
|
+
newValidationError = validate(newValue) || null;
|
|
2493
|
+
}
|
|
2494
|
+
if (newValidationError) {
|
|
2495
|
+
setCachedInvalidValue(newValue);
|
|
2496
|
+
} else {
|
|
2497
|
+
setValue(newValue);
|
|
2498
|
+
}
|
|
2499
|
+
setLocalError(newValidationError);
|
|
2500
|
+
};
|
|
2501
|
+
if (previousValue === value && localError) {
|
|
2502
|
+
value = cachedInvalidValue;
|
|
2503
|
+
}
|
|
2504
|
+
const error = globalError || localError;
|
|
2478
2505
|
return jsxs("div", {
|
|
2479
2506
|
class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
2480
2507
|
"data-entry-id": id,
|
|
@@ -2482,7 +2509,7 @@ function SelectEntry(props) {
|
|
|
2482
2509
|
id: id,
|
|
2483
2510
|
label: label,
|
|
2484
2511
|
value: value,
|
|
2485
|
-
onChange:
|
|
2512
|
+
onChange: onChange,
|
|
2486
2513
|
onFocus: onFocus,
|
|
2487
2514
|
onBlur: onBlur,
|
|
2488
2515
|
options: options,
|