@bpmn-io/properties-panel 1.7.0 → 1.8.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.js CHANGED
@@ -2750,6 +2750,7 @@ function TextArea(props) {
2750
2750
  * @param {Function} props.onBlur
2751
2751
  * @param {number} props.rows
2752
2752
  * @param {boolean} props.monospace
2753
+ * @param {Function} [props.validate]
2753
2754
  * @param {boolean} [props.disabled]
2754
2755
  */
2755
2756
  function TextAreaEntry(props) {
@@ -2764,12 +2765,38 @@ function TextAreaEntry(props) {
2764
2765
  rows,
2765
2766
  monospace,
2766
2767
  disabled,
2768
+ validate,
2767
2769
  onFocus,
2768
2770
  onBlur,
2769
2771
  autoResize
2770
2772
  } = props;
2771
- const value = getValue(element);
2772
- const error = useError(id);
2773
+ const [cachedInvalidValue, setCachedInvalidValue] = hooks.useState(null);
2774
+ const globalError = useError(id);
2775
+ const [localError, setLocalError] = hooks.useState(null);
2776
+ let value = getValue(element);
2777
+ const previousValue = usePrevious(value);
2778
+ hooks.useEffect(() => {
2779
+ if (minDash.isFunction(validate)) {
2780
+ const newValidationError = validate(value) || null;
2781
+ setLocalError(newValidationError);
2782
+ }
2783
+ }, [value]);
2784
+ const onInput = newValue => {
2785
+ let newValidationError = null;
2786
+ if (minDash.isFunction(validate)) {
2787
+ newValidationError = validate(newValue) || null;
2788
+ }
2789
+ if (newValidationError) {
2790
+ setCachedInvalidValue(newValue);
2791
+ } else {
2792
+ setValue(newValue);
2793
+ }
2794
+ setLocalError(newValidationError);
2795
+ };
2796
+ if (previousValue === value && localError) {
2797
+ value = cachedInvalidValue;
2798
+ }
2799
+ const error = globalError || localError;
2773
2800
  return jsxRuntime.jsxs("div", {
2774
2801
  class: classnames__default["default"]('bio-properties-panel-entry', error ? 'has-error' : ''),
2775
2802
  "data-entry-id": id,
@@ -2777,7 +2804,7 @@ function TextAreaEntry(props) {
2777
2804
  id: id,
2778
2805
  label: label,
2779
2806
  value: value,
2780
- onInput: setValue,
2807
+ onInput: onInput,
2781
2808
  onFocus: onFocus,
2782
2809
  onBlur: onBlur,
2783
2810
  rows: rows,