@bpmn-io/form-js-viewer 1.6.2 → 1.6.3
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.cjs +42 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +42 -51
- package/dist/index.es.js.map +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -3058,40 +3058,6 @@ Image.config = {
|
|
|
3058
3058
|
})
|
|
3059
3059
|
};
|
|
3060
3060
|
|
|
3061
|
-
function useFlushDebounce(func, additionalDeps = []) {
|
|
3062
|
-
const timeoutRef = useRef(null);
|
|
3063
|
-
const lastArgsRef = useRef(null);
|
|
3064
|
-
const config = useService('config', false);
|
|
3065
|
-
const debounce = config && config.debounce;
|
|
3066
|
-
const shouldDebounce = debounce !== false && debounce !== 0;
|
|
3067
|
-
const delay = typeof debounce === 'number' ? debounce : 300;
|
|
3068
|
-
const debounceFunc = useCallback((...args) => {
|
|
3069
|
-
if (!shouldDebounce) {
|
|
3070
|
-
func(...args);
|
|
3071
|
-
return;
|
|
3072
|
-
}
|
|
3073
|
-
lastArgsRef.current = args;
|
|
3074
|
-
if (timeoutRef.current) {
|
|
3075
|
-
clearTimeout(timeoutRef.current);
|
|
3076
|
-
}
|
|
3077
|
-
timeoutRef.current = setTimeout(() => {
|
|
3078
|
-
func(...lastArgsRef.current);
|
|
3079
|
-
lastArgsRef.current = null;
|
|
3080
|
-
}, delay);
|
|
3081
|
-
}, [func, delay, shouldDebounce, ...additionalDeps]);
|
|
3082
|
-
const flushFunc = useCallback(() => {
|
|
3083
|
-
if (timeoutRef.current) {
|
|
3084
|
-
clearTimeout(timeoutRef.current);
|
|
3085
|
-
if (lastArgsRef.current !== null) {
|
|
3086
|
-
func(...lastArgsRef.current);
|
|
3087
|
-
lastArgsRef.current = null;
|
|
3088
|
-
}
|
|
3089
|
-
timeoutRef.current = null;
|
|
3090
|
-
}
|
|
3091
|
-
}, [func, ...additionalDeps]);
|
|
3092
|
-
return [debounceFunc, flushFunc];
|
|
3093
|
-
}
|
|
3094
|
-
|
|
3095
3061
|
function TemplatedInputAdorner(props) {
|
|
3096
3062
|
const {
|
|
3097
3063
|
pre,
|
|
@@ -3182,7 +3148,8 @@ function Numberfield(props) {
|
|
|
3182
3148
|
onFocus,
|
|
3183
3149
|
field,
|
|
3184
3150
|
value,
|
|
3185
|
-
readonly
|
|
3151
|
+
readonly,
|
|
3152
|
+
onChange
|
|
3186
3153
|
} = props;
|
|
3187
3154
|
const {
|
|
3188
3155
|
description,
|
|
@@ -3202,16 +3169,6 @@ function Numberfield(props) {
|
|
|
3202
3169
|
} = validate;
|
|
3203
3170
|
const inputRef = useRef();
|
|
3204
3171
|
const [stringValueCache, setStringValueCache] = useState('');
|
|
3205
|
-
const [onChangeDebounced, flushOnChange] = useFlushDebounce(params => {
|
|
3206
|
-
props.onChange(params);
|
|
3207
|
-
}, [props.onChange]);
|
|
3208
|
-
const onInputBlur = () => {
|
|
3209
|
-
flushOnChange && flushOnChange();
|
|
3210
|
-
onBlur && onBlur();
|
|
3211
|
-
};
|
|
3212
|
-
const onInputFocus = () => {
|
|
3213
|
-
onFocus && onFocus();
|
|
3214
|
-
};
|
|
3215
3172
|
|
|
3216
3173
|
// checks whether the value currently in the form data is practically different from the one in the input field cache
|
|
3217
3174
|
// this allows us to guarantee the field always displays valid form data, but without auto-simplifying values like 1.000 to 1
|
|
@@ -3235,7 +3192,7 @@ function Numberfield(props) {
|
|
|
3235
3192
|
const setValue = useCallback(stringValue => {
|
|
3236
3193
|
if (isNullEquivalentValue(stringValue)) {
|
|
3237
3194
|
setStringValueCache('');
|
|
3238
|
-
|
|
3195
|
+
onChange({
|
|
3239
3196
|
field,
|
|
3240
3197
|
value: null
|
|
3241
3198
|
});
|
|
@@ -3250,18 +3207,18 @@ function Numberfield(props) {
|
|
|
3250
3207
|
}
|
|
3251
3208
|
if (isNaN(Number(stringValue))) {
|
|
3252
3209
|
setStringValueCache('NaN');
|
|
3253
|
-
|
|
3210
|
+
onChange({
|
|
3254
3211
|
field,
|
|
3255
3212
|
value: 'NaN'
|
|
3256
3213
|
});
|
|
3257
3214
|
return;
|
|
3258
3215
|
}
|
|
3259
3216
|
setStringValueCache(stringValue);
|
|
3260
|
-
|
|
3217
|
+
onChange({
|
|
3261
3218
|
field,
|
|
3262
3219
|
value: serializeToString ? stringValue : Number(stringValue)
|
|
3263
3220
|
});
|
|
3264
|
-
}, [field,
|
|
3221
|
+
}, [field, onChange, serializeToString]);
|
|
3265
3222
|
const increment = () => {
|
|
3266
3223
|
if (readonly) {
|
|
3267
3224
|
return;
|
|
@@ -3345,8 +3302,8 @@ function Numberfield(props) {
|
|
|
3345
3302
|
id: domId,
|
|
3346
3303
|
onKeyDown: onKeyDown,
|
|
3347
3304
|
onKeyPress: onKeyPress,
|
|
3348
|
-
onBlur:
|
|
3349
|
-
onFocus:
|
|
3305
|
+
onBlur: onBlur,
|
|
3306
|
+
onFocus: onFocus
|
|
3350
3307
|
|
|
3351
3308
|
// @ts-ignore
|
|
3352
3309
|
,
|
|
@@ -4356,6 +4313,40 @@ function DisabledLink({
|
|
|
4356
4313
|
});
|
|
4357
4314
|
}
|
|
4358
4315
|
|
|
4316
|
+
function useFlushDebounce(func, additionalDeps = []) {
|
|
4317
|
+
const timeoutRef = useRef(null);
|
|
4318
|
+
const lastArgsRef = useRef(null);
|
|
4319
|
+
const config = useService('config', false);
|
|
4320
|
+
const debounce = config && config.debounce;
|
|
4321
|
+
const shouldDebounce = debounce !== false && debounce !== 0;
|
|
4322
|
+
const delay = typeof debounce === 'number' ? debounce : 300;
|
|
4323
|
+
const debounceFunc = useCallback((...args) => {
|
|
4324
|
+
if (!shouldDebounce) {
|
|
4325
|
+
func(...args);
|
|
4326
|
+
return;
|
|
4327
|
+
}
|
|
4328
|
+
lastArgsRef.current = args;
|
|
4329
|
+
if (timeoutRef.current) {
|
|
4330
|
+
clearTimeout(timeoutRef.current);
|
|
4331
|
+
}
|
|
4332
|
+
timeoutRef.current = setTimeout(() => {
|
|
4333
|
+
func(...lastArgsRef.current);
|
|
4334
|
+
lastArgsRef.current = null;
|
|
4335
|
+
}, delay);
|
|
4336
|
+
}, [func, delay, shouldDebounce, ...additionalDeps]);
|
|
4337
|
+
const flushFunc = useCallback(() => {
|
|
4338
|
+
if (timeoutRef.current) {
|
|
4339
|
+
clearTimeout(timeoutRef.current);
|
|
4340
|
+
if (lastArgsRef.current !== null) {
|
|
4341
|
+
func(...lastArgsRef.current);
|
|
4342
|
+
lastArgsRef.current = null;
|
|
4343
|
+
}
|
|
4344
|
+
timeoutRef.current = null;
|
|
4345
|
+
}
|
|
4346
|
+
}, [func, ...additionalDeps]);
|
|
4347
|
+
return [debounceFunc, flushFunc];
|
|
4348
|
+
}
|
|
4349
|
+
|
|
4359
4350
|
const type$2 = 'textfield';
|
|
4360
4351
|
function Textfield(props) {
|
|
4361
4352
|
const {
|