@bpmn-io/properties-panel 3.29.0 → 3.29.1
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 +108 -76
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +108 -76
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -408,7 +408,7 @@ function useDebounce(callback, debounceFn) {
|
|
|
408
408
|
// make sure previous call is not stalled
|
|
409
409
|
useEffect(() => {
|
|
410
410
|
return () => {
|
|
411
|
-
debouncedCallback.
|
|
411
|
+
debouncedCallback.cancel?.();
|
|
412
412
|
};
|
|
413
413
|
}, [debouncedCallback]);
|
|
414
414
|
return debouncedCallback;
|
|
@@ -2143,50 +2143,6 @@ function prefixId$6(id) {
|
|
|
2143
2143
|
return `bio-properties-panel-${id}`;
|
|
2144
2144
|
}
|
|
2145
2145
|
|
|
2146
|
-
function TextInput({
|
|
2147
|
-
debounce,
|
|
2148
|
-
element,
|
|
2149
|
-
id,
|
|
2150
|
-
getValue,
|
|
2151
|
-
onBlur,
|
|
2152
|
-
setValue,
|
|
2153
|
-
validate,
|
|
2154
|
-
Component,
|
|
2155
|
-
...props
|
|
2156
|
-
}) {
|
|
2157
|
-
const modelValue = getValue(element);
|
|
2158
|
-
const setModelValue = useCallback((newValue, error) => {
|
|
2159
|
-
if (isFunction(validate)) {
|
|
2160
|
-
error = validate(newValue) || null;
|
|
2161
|
-
}
|
|
2162
|
-
setValue(newValue, error);
|
|
2163
|
-
}, [setValue, validate]);
|
|
2164
|
-
const debouncedSetValue = useDebounce(setModelValue, debounce);
|
|
2165
|
-
const handleInput = useCallback(newValue => {
|
|
2166
|
-
if (newValue !== modelValue) {
|
|
2167
|
-
debouncedSetValue(newValue);
|
|
2168
|
-
}
|
|
2169
|
-
}, [modelValue, debouncedSetValue]);
|
|
2170
|
-
const handleBlur = useCallback(value => {
|
|
2171
|
-
const newValue = value.trim?.() || value;
|
|
2172
|
-
if (newValue !== modelValue) {
|
|
2173
|
-
setModelValue(newValue);
|
|
2174
|
-
}
|
|
2175
|
-
if (isFunction(onBlur)) {
|
|
2176
|
-
onBlur(newValue);
|
|
2177
|
-
}
|
|
2178
|
-
}, [modelValue, setModelValue]);
|
|
2179
|
-
return jsx(Component, {
|
|
2180
|
-
...props,
|
|
2181
|
-
debounce: debounce,
|
|
2182
|
-
element: element,
|
|
2183
|
-
id: id,
|
|
2184
|
-
onInput: handleInput,
|
|
2185
|
-
onBlur: handleBlur,
|
|
2186
|
-
value: modelValue
|
|
2187
|
-
});
|
|
2188
|
-
}
|
|
2189
|
-
|
|
2190
2146
|
const noop$2 = () => {};
|
|
2191
2147
|
|
|
2192
2148
|
/**
|
|
@@ -2215,6 +2171,7 @@ const noop$2 = () => {};
|
|
|
2215
2171
|
*/
|
|
2216
2172
|
function FeelTextfield(props) {
|
|
2217
2173
|
const {
|
|
2174
|
+
debounce,
|
|
2218
2175
|
id,
|
|
2219
2176
|
element,
|
|
2220
2177
|
label,
|
|
@@ -2249,11 +2206,16 @@ function FeelTextfield(props) {
|
|
|
2249
2206
|
const position = hasFocus ? document.activeElement.selectionStart : Infinity;
|
|
2250
2207
|
_setFocus(position + offset);
|
|
2251
2208
|
};
|
|
2209
|
+
|
|
2210
|
+
/**
|
|
2211
|
+
* @type { import('min-dash').DebouncedFunction }
|
|
2212
|
+
*/
|
|
2213
|
+
const handleInputCallback = useDebounce(onInput, debounce);
|
|
2252
2214
|
const handleInput = newValue => {
|
|
2253
2215
|
// we don't commit empty FEEL expressions,
|
|
2254
2216
|
// but instead serialize them as <undefined>
|
|
2255
2217
|
const newModelValue = newValue === '' || newValue === '=' ? undefined : newValue;
|
|
2256
|
-
|
|
2218
|
+
handleInputCallback(newModelValue);
|
|
2257
2219
|
};
|
|
2258
2220
|
const handleFeelToggle = useStaticCallback(() => {
|
|
2259
2221
|
if (feel === 'required') {
|
|
@@ -2281,8 +2243,14 @@ function FeelTextfield(props) {
|
|
|
2281
2243
|
setFocus(-1);
|
|
2282
2244
|
}
|
|
2283
2245
|
};
|
|
2284
|
-
const handleOnBlur =
|
|
2285
|
-
|
|
2246
|
+
const handleOnBlur = e => {
|
|
2247
|
+
const trimmedValue = e.target.value.trim();
|
|
2248
|
+
|
|
2249
|
+
// trim and commit on blur
|
|
2250
|
+
onInput(trimmedValue);
|
|
2251
|
+
if (onBlur) {
|
|
2252
|
+
onBlur(e);
|
|
2253
|
+
}
|
|
2286
2254
|
};
|
|
2287
2255
|
const handleLint = useStaticCallback((lint = []) => {
|
|
2288
2256
|
const syntaxError = lint.some(report => report.type === 'Syntax Error');
|
|
@@ -2679,28 +2647,46 @@ function FeelEntry(props) {
|
|
|
2679
2647
|
placeholder,
|
|
2680
2648
|
tooltip
|
|
2681
2649
|
} = props;
|
|
2650
|
+
const [validationError, setValidationError] = useState(null);
|
|
2682
2651
|
const [localError, setLocalError] = useState(null);
|
|
2683
|
-
|
|
2684
|
-
|
|
2652
|
+
let value = getValue(element);
|
|
2653
|
+
useEffect(() => {
|
|
2654
|
+
if (isFunction(validate)) {
|
|
2655
|
+
const newValidationError = validate(value) || null;
|
|
2656
|
+
setValidationError(newValidationError);
|
|
2657
|
+
}
|
|
2658
|
+
}, [value, validate]);
|
|
2659
|
+
const onInput = useStaticCallback(newValue => {
|
|
2660
|
+
const value = getValue(element);
|
|
2661
|
+
let newValidationError = null;
|
|
2662
|
+
if (isFunction(validate)) {
|
|
2663
|
+
newValidationError = validate(newValue) || null;
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
// don't create multiple commandStack entries for the same value
|
|
2667
|
+
if (newValue !== value) {
|
|
2668
|
+
setValue(newValue, newValidationError);
|
|
2669
|
+
}
|
|
2670
|
+
setValidationError(newValidationError);
|
|
2671
|
+
});
|
|
2672
|
+
const onError = useCallback(err => {
|
|
2673
|
+
setLocalError(err);
|
|
2674
|
+
}, []);
|
|
2685
2675
|
const temporaryError = useError(id);
|
|
2686
2676
|
const error = temporaryError || localError || validationError;
|
|
2687
2677
|
return jsxs("div", {
|
|
2688
2678
|
class: classnames(props.class, 'bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
2689
2679
|
"data-entry-id": id,
|
|
2690
|
-
children: [createElement$1(
|
|
2680
|
+
children: [createElement$1(FeelTextfield, {
|
|
2691
2681
|
...props,
|
|
2692
|
-
Component: FeelTextfield,
|
|
2693
|
-
element: element,
|
|
2694
|
-
getValue: getValue,
|
|
2695
2682
|
debounce: debounce,
|
|
2696
|
-
setValue: setValue,
|
|
2697
|
-
validate: validate,
|
|
2698
2683
|
disabled: disabled,
|
|
2699
2684
|
feel: feel,
|
|
2700
2685
|
id: id,
|
|
2701
2686
|
key: element,
|
|
2702
2687
|
label: label,
|
|
2703
|
-
|
|
2688
|
+
onInput: onInput,
|
|
2689
|
+
onError: onError,
|
|
2704
2690
|
onFocus: onFocus,
|
|
2705
2691
|
onBlur: onBlur,
|
|
2706
2692
|
placeholder: placeholder,
|
|
@@ -3448,8 +3434,14 @@ function TextArea(props) {
|
|
|
3448
3434
|
setLocalValue(e.target.value);
|
|
3449
3435
|
handleInput(e.target.value);
|
|
3450
3436
|
};
|
|
3451
|
-
const handleOnBlur =
|
|
3452
|
-
|
|
3437
|
+
const handleOnBlur = e => {
|
|
3438
|
+
const trimmedValue = e.target.value.trim();
|
|
3439
|
+
|
|
3440
|
+
// trim and commit on blur
|
|
3441
|
+
onInput(trimmedValue);
|
|
3442
|
+
if (onBlur) {
|
|
3443
|
+
onBlur(e);
|
|
3444
|
+
}
|
|
3453
3445
|
};
|
|
3454
3446
|
useLayoutEffect(() => {
|
|
3455
3447
|
autoResize && resizeToContents(ref.current);
|
|
@@ -3527,21 +3519,35 @@ function TextAreaEntry(props) {
|
|
|
3527
3519
|
autoResize,
|
|
3528
3520
|
tooltip
|
|
3529
3521
|
} = props;
|
|
3530
|
-
const value = getValue(element);
|
|
3531
3522
|
const globalError = useError(id);
|
|
3532
|
-
const localError =
|
|
3523
|
+
const [localError, setLocalError] = useState(null);
|
|
3524
|
+
let value = getValue(element);
|
|
3525
|
+
useEffect(() => {
|
|
3526
|
+
if (isFunction(validate)) {
|
|
3527
|
+
const newValidationError = validate(value) || null;
|
|
3528
|
+
setLocalError(newValidationError);
|
|
3529
|
+
}
|
|
3530
|
+
}, [value, validate]);
|
|
3531
|
+
const onInput = useStaticCallback(newValue => {
|
|
3532
|
+
const value = getValue(element);
|
|
3533
|
+
let newValidationError = null;
|
|
3534
|
+
if (isFunction(validate)) {
|
|
3535
|
+
newValidationError = validate(newValue) || null;
|
|
3536
|
+
}
|
|
3537
|
+
if (newValue !== value) {
|
|
3538
|
+
setValue(newValue, newValidationError);
|
|
3539
|
+
}
|
|
3540
|
+
setLocalError(newValidationError);
|
|
3541
|
+
});
|
|
3533
3542
|
const error = globalError || localError;
|
|
3534
3543
|
return jsxs("div", {
|
|
3535
3544
|
class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
3536
3545
|
"data-entry-id": id,
|
|
3537
|
-
children: [jsx(
|
|
3538
|
-
Component: TextArea,
|
|
3539
|
-
getValue: getValue,
|
|
3540
|
-
setValue: setValue,
|
|
3541
|
-
validate: validate,
|
|
3546
|
+
children: [jsx(TextArea, {
|
|
3542
3547
|
id: id,
|
|
3543
3548
|
label: label,
|
|
3544
3549
|
value: value,
|
|
3550
|
+
onInput: onInput,
|
|
3545
3551
|
onFocus: onFocus,
|
|
3546
3552
|
onBlur: onBlur,
|
|
3547
3553
|
rows: rows,
|
|
@@ -3574,6 +3580,7 @@ function prefixId$2(id) {
|
|
|
3574
3580
|
|
|
3575
3581
|
function Textfield(props) {
|
|
3576
3582
|
const {
|
|
3583
|
+
debounce,
|
|
3577
3584
|
disabled = false,
|
|
3578
3585
|
id,
|
|
3579
3586
|
label,
|
|
@@ -3586,12 +3593,23 @@ function Textfield(props) {
|
|
|
3586
3593
|
} = props;
|
|
3587
3594
|
const [localValue, setLocalValue] = useState(value || '');
|
|
3588
3595
|
const ref = useShowEntryEvent(id);
|
|
3589
|
-
|
|
3590
|
-
|
|
3596
|
+
|
|
3597
|
+
/**
|
|
3598
|
+
* @type { import('min-dash').DebouncedFunction }
|
|
3599
|
+
*/
|
|
3600
|
+
const handleInputCallback = useDebounce(onInput, debounce);
|
|
3601
|
+
const handleOnBlur = e => {
|
|
3602
|
+
const trimmedValue = e.target.value.trim();
|
|
3603
|
+
|
|
3604
|
+
// trim and commit on blur
|
|
3605
|
+
onInput(trimmedValue);
|
|
3606
|
+
if (onBlur) {
|
|
3607
|
+
onBlur(e);
|
|
3608
|
+
}
|
|
3591
3609
|
};
|
|
3592
3610
|
const handleInput = newValue => {
|
|
3593
3611
|
const newModelValue = newValue === '' ? undefined : newValue;
|
|
3594
|
-
|
|
3612
|
+
handleInputCallback(newModelValue);
|
|
3595
3613
|
};
|
|
3596
3614
|
const handleLocalInput = e => {
|
|
3597
3615
|
if (e.target.value === localValue) {
|
|
@@ -3666,25 +3684,39 @@ function TextfieldEntry(props) {
|
|
|
3666
3684
|
placeholder,
|
|
3667
3685
|
tooltip
|
|
3668
3686
|
} = props;
|
|
3669
|
-
const value = getValue(element);
|
|
3670
3687
|
const globalError = useError(id);
|
|
3671
|
-
const localError =
|
|
3688
|
+
const [localError, setLocalError] = useState(null);
|
|
3689
|
+
let value = getValue(element);
|
|
3690
|
+
useEffect(() => {
|
|
3691
|
+
if (isFunction(validate)) {
|
|
3692
|
+
const newValidationError = validate(value) || null;
|
|
3693
|
+
setLocalError(newValidationError);
|
|
3694
|
+
}
|
|
3695
|
+
}, [value, validate]);
|
|
3696
|
+
const onInput = useStaticCallback(newValue => {
|
|
3697
|
+
const value = getValue(element);
|
|
3698
|
+
let newValidationError = null;
|
|
3699
|
+
if (isFunction(validate)) {
|
|
3700
|
+
newValidationError = validate(newValue) || null;
|
|
3701
|
+
}
|
|
3702
|
+
if (newValue !== value) {
|
|
3703
|
+
setValue(newValue, newValidationError);
|
|
3704
|
+
}
|
|
3705
|
+
setLocalError(newValidationError);
|
|
3706
|
+
});
|
|
3672
3707
|
const error = globalError || localError;
|
|
3673
3708
|
return jsxs("div", {
|
|
3674
3709
|
class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
3675
3710
|
"data-entry-id": id,
|
|
3676
|
-
children: [jsx(
|
|
3677
|
-
Component: Textfield,
|
|
3711
|
+
children: [jsx(Textfield, {
|
|
3678
3712
|
debounce: debounce,
|
|
3679
3713
|
disabled: disabled,
|
|
3680
|
-
getValue: getValue,
|
|
3681
3714
|
id: id,
|
|
3682
3715
|
label: label,
|
|
3716
|
+
onInput: onInput,
|
|
3683
3717
|
onFocus: onFocus,
|
|
3684
3718
|
onBlur: onBlur,
|
|
3685
3719
|
placeholder: placeholder,
|
|
3686
|
-
setValue: setValue,
|
|
3687
|
-
validate: validate,
|
|
3688
3720
|
value: value,
|
|
3689
3721
|
tooltip: tooltip,
|
|
3690
3722
|
element: element
|