@bpmn-io/properties-panel 3.27.6 → 3.27.8
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 +109 -77
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +109 -77
- 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;
|
|
@@ -1951,50 +1951,6 @@ function prefixId$6(id) {
|
|
|
1951
1951
|
return `bio-properties-panel-${id}`;
|
|
1952
1952
|
}
|
|
1953
1953
|
|
|
1954
|
-
function TextInput({
|
|
1955
|
-
debounce,
|
|
1956
|
-
element,
|
|
1957
|
-
id,
|
|
1958
|
-
getValue,
|
|
1959
|
-
onBlur,
|
|
1960
|
-
setValue,
|
|
1961
|
-
validate,
|
|
1962
|
-
Component,
|
|
1963
|
-
...props
|
|
1964
|
-
}) {
|
|
1965
|
-
const modelValue = getValue(element);
|
|
1966
|
-
const setModelValue = useCallback((newValue, error) => {
|
|
1967
|
-
if (isFunction(validate)) {
|
|
1968
|
-
error = validate(newValue) || null;
|
|
1969
|
-
}
|
|
1970
|
-
setValue(newValue, error);
|
|
1971
|
-
}, [setValue, validate]);
|
|
1972
|
-
const debouncedSetValue = useDebounce(setModelValue, debounce);
|
|
1973
|
-
const handleInput = useCallback(newValue => {
|
|
1974
|
-
if (newValue !== modelValue) {
|
|
1975
|
-
debouncedSetValue(newValue);
|
|
1976
|
-
}
|
|
1977
|
-
}, [modelValue, debouncedSetValue]);
|
|
1978
|
-
const handleBlur = useCallback(value => {
|
|
1979
|
-
const newValue = value.trim?.() || value;
|
|
1980
|
-
if (newValue !== modelValue) {
|
|
1981
|
-
setModelValue(newValue);
|
|
1982
|
-
}
|
|
1983
|
-
if (isFunction(onBlur)) {
|
|
1984
|
-
onBlur(newValue);
|
|
1985
|
-
}
|
|
1986
|
-
}, [modelValue, setModelValue]);
|
|
1987
|
-
return jsx(Component, {
|
|
1988
|
-
...props,
|
|
1989
|
-
debounce: debounce,
|
|
1990
|
-
element: element,
|
|
1991
|
-
id: id,
|
|
1992
|
-
onInput: handleInput,
|
|
1993
|
-
onBlur: handleBlur,
|
|
1994
|
-
value: modelValue
|
|
1995
|
-
});
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
1954
|
const noop$2 = () => {};
|
|
1999
1955
|
|
|
2000
1956
|
/**
|
|
@@ -2024,6 +1980,7 @@ const noop$2 = () => {};
|
|
|
2024
1980
|
|
|
2025
1981
|
function FeelTextfieldComponent(props) {
|
|
2026
1982
|
const {
|
|
1983
|
+
debounce,
|
|
2027
1984
|
id,
|
|
2028
1985
|
element,
|
|
2029
1986
|
label,
|
|
@@ -2059,11 +2016,16 @@ function FeelTextfieldComponent(props) {
|
|
|
2059
2016
|
const position = hasFocus ? document.activeElement.selectionStart : Infinity;
|
|
2060
2017
|
_setFocus(position + offset);
|
|
2061
2018
|
};
|
|
2019
|
+
|
|
2020
|
+
/**
|
|
2021
|
+
* @type { import('min-dash').DebouncedFunction }
|
|
2022
|
+
*/
|
|
2023
|
+
const handleInputCallback = useDebounce(onInput, debounce);
|
|
2062
2024
|
const handleInput = newValue => {
|
|
2063
2025
|
// we don't commit empty FEEL expressions,
|
|
2064
2026
|
// but instead serialize them as <undefined>
|
|
2065
2027
|
const newModelValue = newValue === '' || newValue === '=' ? undefined : newValue;
|
|
2066
|
-
|
|
2028
|
+
handleInputCallback(newModelValue);
|
|
2067
2029
|
};
|
|
2068
2030
|
const handleFeelToggle = useStaticCallback(() => {
|
|
2069
2031
|
if (feel === 'required') {
|
|
@@ -2091,8 +2053,14 @@ function FeelTextfieldComponent(props) {
|
|
|
2091
2053
|
setFocus(-1);
|
|
2092
2054
|
}
|
|
2093
2055
|
};
|
|
2094
|
-
const handleOnBlur =
|
|
2095
|
-
|
|
2056
|
+
const handleOnBlur = e => {
|
|
2057
|
+
const trimmedValue = e.target.value.trim();
|
|
2058
|
+
|
|
2059
|
+
// trim and commit on blur
|
|
2060
|
+
onInput(trimmedValue);
|
|
2061
|
+
if (onBlur) {
|
|
2062
|
+
onBlur(e);
|
|
2063
|
+
}
|
|
2096
2064
|
};
|
|
2097
2065
|
const handleLint = useStaticCallback((lint = []) => {
|
|
2098
2066
|
const syntaxError = lint.some(report => report.type === 'Syntax Error');
|
|
@@ -2479,28 +2447,46 @@ function FeelEntry(props) {
|
|
|
2479
2447
|
placeholder,
|
|
2480
2448
|
tooltip
|
|
2481
2449
|
} = props;
|
|
2450
|
+
const [validationError, setValidationError] = useState(null);
|
|
2482
2451
|
const [localError, setLocalError] = useState(null);
|
|
2483
|
-
|
|
2484
|
-
|
|
2452
|
+
let value = getValue(element);
|
|
2453
|
+
useEffect(() => {
|
|
2454
|
+
if (isFunction(validate)) {
|
|
2455
|
+
const newValidationError = validate(value) || null;
|
|
2456
|
+
setValidationError(newValidationError);
|
|
2457
|
+
}
|
|
2458
|
+
}, [value, validate]);
|
|
2459
|
+
const onInput = useStaticCallback(newValue => {
|
|
2460
|
+
const value = getValue(element);
|
|
2461
|
+
let newValidationError = null;
|
|
2462
|
+
if (isFunction(validate)) {
|
|
2463
|
+
newValidationError = validate(newValue) || null;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
// don't create multiple commandStack entries for the same value
|
|
2467
|
+
if (newValue !== value) {
|
|
2468
|
+
setValue(newValue, newValidationError);
|
|
2469
|
+
}
|
|
2470
|
+
setValidationError(newValidationError);
|
|
2471
|
+
});
|
|
2472
|
+
const onError = useCallback(err => {
|
|
2473
|
+
setLocalError(err);
|
|
2474
|
+
}, []);
|
|
2485
2475
|
const temporaryError = useError(id);
|
|
2486
2476
|
const error = temporaryError || localError || validationError;
|
|
2487
2477
|
return jsxs("div", {
|
|
2488
2478
|
class: classnames(props.class, 'bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
2489
2479
|
"data-entry-id": id,
|
|
2490
|
-
children: [createElement(
|
|
2480
|
+
children: [createElement(FeelTextfield, {
|
|
2491
2481
|
...props,
|
|
2492
|
-
Component: FeelTextfield,
|
|
2493
|
-
element: element,
|
|
2494
|
-
getValue: getValue,
|
|
2495
2482
|
debounce: debounce,
|
|
2496
|
-
setValue: setValue,
|
|
2497
|
-
validate: validate,
|
|
2498
2483
|
disabled: disabled,
|
|
2499
2484
|
feel: feel,
|
|
2500
2485
|
id: id,
|
|
2501
2486
|
key: element,
|
|
2502
2487
|
label: label,
|
|
2503
|
-
|
|
2488
|
+
onInput: onInput,
|
|
2489
|
+
onError: onError,
|
|
2504
2490
|
onFocus: onFocus,
|
|
2505
2491
|
onBlur: onBlur,
|
|
2506
2492
|
placeholder: placeholder,
|
|
@@ -4036,8 +4022,14 @@ function TextArea(props) {
|
|
|
4036
4022
|
setLocalValue(e.target.value);
|
|
4037
4023
|
handleInput(e.target.value);
|
|
4038
4024
|
};
|
|
4039
|
-
const handleOnBlur =
|
|
4040
|
-
|
|
4025
|
+
const handleOnBlur = e => {
|
|
4026
|
+
const trimmedValue = e.target.value.trim();
|
|
4027
|
+
|
|
4028
|
+
// trim and commit on blur
|
|
4029
|
+
onInput(trimmedValue);
|
|
4030
|
+
if (onBlur) {
|
|
4031
|
+
onBlur(e);
|
|
4032
|
+
}
|
|
4041
4033
|
};
|
|
4042
4034
|
useLayoutEffect(() => {
|
|
4043
4035
|
autoResize && resizeToContents(ref.current);
|
|
@@ -4115,21 +4107,35 @@ function TextAreaEntry(props) {
|
|
|
4115
4107
|
autoResize,
|
|
4116
4108
|
tooltip
|
|
4117
4109
|
} = props;
|
|
4118
|
-
const value = getValue(element);
|
|
4119
4110
|
const globalError = useError(id);
|
|
4120
|
-
const localError =
|
|
4111
|
+
const [localError, setLocalError] = useState(null);
|
|
4112
|
+
let value = getValue(element);
|
|
4113
|
+
useEffect(() => {
|
|
4114
|
+
if (isFunction(validate)) {
|
|
4115
|
+
const newValidationError = validate(value) || null;
|
|
4116
|
+
setLocalError(newValidationError);
|
|
4117
|
+
}
|
|
4118
|
+
}, [value, validate]);
|
|
4119
|
+
const onInput = useStaticCallback(newValue => {
|
|
4120
|
+
const value = getValue(element);
|
|
4121
|
+
let newValidationError = null;
|
|
4122
|
+
if (isFunction(validate)) {
|
|
4123
|
+
newValidationError = validate(newValue) || null;
|
|
4124
|
+
}
|
|
4125
|
+
if (newValue !== value) {
|
|
4126
|
+
setValue(newValue, newValidationError);
|
|
4127
|
+
}
|
|
4128
|
+
setLocalError(newValidationError);
|
|
4129
|
+
});
|
|
4121
4130
|
const error = globalError || localError;
|
|
4122
4131
|
return jsxs("div", {
|
|
4123
4132
|
class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
4124
4133
|
"data-entry-id": id,
|
|
4125
|
-
children: [jsx(
|
|
4126
|
-
Component: TextArea,
|
|
4127
|
-
getValue: getValue,
|
|
4128
|
-
setValue: setValue,
|
|
4129
|
-
validate: validate,
|
|
4134
|
+
children: [jsx(TextArea, {
|
|
4130
4135
|
id: id,
|
|
4131
4136
|
label: label,
|
|
4132
4137
|
value: value,
|
|
4138
|
+
onInput: onInput,
|
|
4133
4139
|
onFocus: onFocus,
|
|
4134
4140
|
onBlur: onBlur,
|
|
4135
4141
|
rows: rows,
|
|
@@ -4162,6 +4168,7 @@ function prefixId$1(id) {
|
|
|
4162
4168
|
|
|
4163
4169
|
function Textfield(props) {
|
|
4164
4170
|
const {
|
|
4171
|
+
debounce,
|
|
4165
4172
|
disabled = false,
|
|
4166
4173
|
id,
|
|
4167
4174
|
label,
|
|
@@ -4174,12 +4181,23 @@ function Textfield(props) {
|
|
|
4174
4181
|
} = props;
|
|
4175
4182
|
const [localValue, setLocalValue] = useState(value || '');
|
|
4176
4183
|
const ref = useShowEntryEvent(id);
|
|
4177
|
-
|
|
4178
|
-
|
|
4184
|
+
|
|
4185
|
+
/**
|
|
4186
|
+
* @type { import('min-dash').DebouncedFunction }
|
|
4187
|
+
*/
|
|
4188
|
+
const handleInputCallback = useDebounce(onInput, debounce);
|
|
4189
|
+
const handleOnBlur = e => {
|
|
4190
|
+
const trimmedValue = e.target.value.trim();
|
|
4191
|
+
|
|
4192
|
+
// trim and commit on blur
|
|
4193
|
+
onInput(trimmedValue);
|
|
4194
|
+
if (onBlur) {
|
|
4195
|
+
onBlur(e);
|
|
4196
|
+
}
|
|
4179
4197
|
};
|
|
4180
4198
|
const handleInput = newValue => {
|
|
4181
4199
|
const newModelValue = newValue === '' ? undefined : newValue;
|
|
4182
|
-
|
|
4200
|
+
handleInputCallback(newModelValue);
|
|
4183
4201
|
};
|
|
4184
4202
|
const handleLocalInput = e => {
|
|
4185
4203
|
if (e.target.value === localValue) {
|
|
@@ -4254,25 +4272,39 @@ function TextfieldEntry(props) {
|
|
|
4254
4272
|
placeholder,
|
|
4255
4273
|
tooltip
|
|
4256
4274
|
} = props;
|
|
4257
|
-
const value = getValue(element);
|
|
4258
4275
|
const globalError = useError(id);
|
|
4259
|
-
const localError =
|
|
4276
|
+
const [localError, setLocalError] = useState(null);
|
|
4277
|
+
let value = getValue(element);
|
|
4278
|
+
useEffect(() => {
|
|
4279
|
+
if (isFunction(validate)) {
|
|
4280
|
+
const newValidationError = validate(value) || null;
|
|
4281
|
+
setLocalError(newValidationError);
|
|
4282
|
+
}
|
|
4283
|
+
}, [value, validate]);
|
|
4284
|
+
const onInput = useStaticCallback(newValue => {
|
|
4285
|
+
const value = getValue(element);
|
|
4286
|
+
let newValidationError = null;
|
|
4287
|
+
if (isFunction(validate)) {
|
|
4288
|
+
newValidationError = validate(newValue) || null;
|
|
4289
|
+
}
|
|
4290
|
+
if (newValue !== value) {
|
|
4291
|
+
setValue(newValue, newValidationError);
|
|
4292
|
+
}
|
|
4293
|
+
setLocalError(newValidationError);
|
|
4294
|
+
});
|
|
4260
4295
|
const error = globalError || localError;
|
|
4261
4296
|
return jsxs("div", {
|
|
4262
4297
|
class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
4263
4298
|
"data-entry-id": id,
|
|
4264
|
-
children: [jsx(
|
|
4265
|
-
Component: Textfield,
|
|
4299
|
+
children: [jsx(Textfield, {
|
|
4266
4300
|
debounce: debounce,
|
|
4267
4301
|
disabled: disabled,
|
|
4268
|
-
getValue: getValue,
|
|
4269
4302
|
id: id,
|
|
4270
4303
|
label: label,
|
|
4304
|
+
onInput: onInput,
|
|
4271
4305
|
onFocus: onFocus,
|
|
4272
4306
|
onBlur: onBlur,
|
|
4273
4307
|
placeholder: placeholder,
|
|
4274
|
-
setValue: setValue,
|
|
4275
|
-
validate: validate,
|
|
4276
4308
|
value: value,
|
|
4277
4309
|
tooltip: tooltip,
|
|
4278
4310
|
element: element
|
|
@@ -4296,7 +4328,7 @@ function prefixId(id) {
|
|
|
4296
4328
|
return `bio-properties-panel-${id}`;
|
|
4297
4329
|
}
|
|
4298
4330
|
|
|
4299
|
-
const DEFAULT_DEBOUNCE_TIME =
|
|
4331
|
+
const DEFAULT_DEBOUNCE_TIME = 600;
|
|
4300
4332
|
|
|
4301
4333
|
/**
|
|
4302
4334
|
* Creates a debounced version of a function, delaying its execution based on `debounceDelay`.
|