@bpmn-io/properties-panel 3.28.1 → 3.28.2

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { useContext, useState, useRef, useEffect, useMemo, useCallback, useLayoutEffect } from '../preact/hooks';
1
+ import { useContext, useState, useRef, useCallback, useEffect, useMemo, useLayoutEffect } from '../preact/hooks';
2
2
  import { isFunction, isArray, get, assign, set, isString, isNumber, debounce } from 'min-dash';
3
3
  import { createPortal, forwardRef } from '../preact/compat';
4
4
  import { jsx, jsxs, Fragment } from '../preact/jsx-runtime';
@@ -402,6 +402,18 @@ function useDescriptionContext(id, element) {
402
402
  return getDescriptionForId(id, element);
403
403
  }
404
404
 
405
+ function useDebounce(callback, debounceFn) {
406
+ const debouncedCallback = useCallback(debounceFn(callback), [callback, debounceFn]);
407
+
408
+ // make sure previous call is not stalled
409
+ useEffect(() => {
410
+ return () => {
411
+ debouncedCallback.flush?.();
412
+ };
413
+ }, [debouncedCallback]);
414
+ return debouncedCallback;
415
+ }
416
+
405
417
  function useError(id) {
406
418
  const {
407
419
  errors
@@ -2198,11 +2210,7 @@ function FeelTextfield(props) {
2198
2210
  /**
2199
2211
  * @type { import('min-dash').DebouncedFunction }
2200
2212
  */
2201
- const handleInputCallback = useMemo(() => {
2202
- return debounce(newValue => {
2203
- onInput(newValue);
2204
- });
2205
- }, [onInput, debounce]);
2213
+ const handleInputCallback = useDebounce(onInput, debounce);
2206
2214
  const handleInput = newValue => {
2207
2215
  // we don't commit empty FEEL expressions,
2208
2216
  // but instead serialize them as <undefined>
@@ -2236,14 +2244,10 @@ function FeelTextfield(props) {
2236
2244
  }
2237
2245
  };
2238
2246
  const handleOnBlur = e => {
2239
- const value = e.target.value;
2247
+ const trimmedValue = e.target.value.trim();
2240
2248
 
2241
- // we trim the value, if it is needed
2242
- // and update input accordingly
2243
- if (value.trim() !== value) {
2244
- setLocalValue(value.trim());
2245
- handleInput(value.trim());
2246
- }
2249
+ // trim and commit on blur
2250
+ onInput(trimmedValue);
2247
2251
  if (onBlur) {
2248
2252
  onBlur(e);
2249
2253
  }
@@ -3411,11 +3415,7 @@ function TextArea(props) {
3411
3415
  /**
3412
3416
  * @type { import('min-dash').DebouncedFunction }
3413
3417
  */
3414
- const handleInputCallback = useMemo(() => {
3415
- return debounce(newValue => {
3416
- onInput(newValue);
3417
- });
3418
- }, [onInput, debounce]);
3418
+ const handleInputCallback = useDebounce(onInput, debounce);
3419
3419
  const handleInput = newValue => {
3420
3420
  const newModelValue = newValue === '' ? undefined : newValue;
3421
3421
  handleInputCallback(newModelValue);
@@ -3429,11 +3429,10 @@ function TextArea(props) {
3429
3429
  handleInput(e.target.value);
3430
3430
  };
3431
3431
  const handleOnBlur = e => {
3432
- const value = e.target.value;
3433
- if (value.trim() !== value) {
3434
- setLocalValue(value.trim());
3435
- handleInput(value.trim());
3436
- }
3432
+ const trimmedValue = e.target.value.trim();
3433
+
3434
+ // trim and commit on blur
3435
+ onInput(trimmedValue);
3437
3436
  if (onBlur) {
3438
3437
  onBlur(e);
3439
3438
  }
@@ -3592,17 +3591,12 @@ function Textfield(props) {
3592
3591
  /**
3593
3592
  * @type { import('min-dash').DebouncedFunction }
3594
3593
  */
3595
- const handleInputCallback = useMemo(() => {
3596
- return debounce(newValue => {
3597
- onInput(newValue);
3598
- });
3599
- }, [onInput, debounce]);
3594
+ const handleInputCallback = useDebounce(onInput, debounce);
3600
3595
  const handleOnBlur = e => {
3601
- const value = e.target.value;
3602
- if (value.trim() !== value) {
3603
- setLocalValue(value.trim());
3604
- handleInput(value.trim());
3605
- }
3596
+ const trimmedValue = e.target.value.trim();
3597
+
3598
+ // trim and commit on blur
3599
+ onInput(trimmedValue);
3606
3600
  if (onBlur) {
3607
3601
  onBlur(e);
3608
3602
  }
@@ -4378,5 +4372,5 @@ var index = {
4378
4372
  feelPopupRenderer: ['type', FeelPopupRenderer]
4379
4373
  };
4380
4374
 
4381
- export { ArrowIcon, CheckboxEntry, CloseIcon, CollapsibleEntry, CreateIcon, index$1 as DebounceInputModule, DeleteIcon, DescriptionContext, Description as DescriptionEntry, DragIcon, DropdownButton, ErrorsContext, EventContext, ExternalLinkIcon, FeelCheckboxEntry, FeelEntry, FeelIcon$1 as FeelIcon, FeelNumberEntry, index as FeelPopupModule, FeelTemplatingEntry, FeelTextAreaEntry, FeelToggleSwitchEntry, Group, Header, HeaderButton, LaunchIcon, LayoutContext, List as ListEntry, ListGroup, ListItem, NumberFieldEntry, OpenPopupIcon, Placeholder, PropertiesPanel, LayoutContext as PropertiesPanelContext, SelectEntry, Simple as SimpleEntry, TemplatingEntry, TextAreaEntry, TextfieldEntry as TextFieldEntry, ToggleSwitchEntry, TooltipContext, TooltipWrapper as TooltipEntry, isEdited$8 as isCheckboxEntryEdited, isEdited$5 as isFeelEntryEdited, isEdited$6 as isNumberFieldEntryEdited, isEdited$3 as isSelectEntryEdited, isEdited$2 as isSimpleEntryEdited, isEdited$4 as isTemplatingEntryEdited, isEdited$1 as isTextAreaEntryEdited, isEdited as isTextFieldEntryEdited, isEdited$7 as isToggleSwitchEntryEdited, useDescriptionContext, useElementVisible, useError, useErrors, useEvent, useKeyFactory, useLayoutState, usePrevious, useShowEntryEvent, useStaticCallback, useStickyIntersectionObserver, useTooltipContext };
4375
+ export { ArrowIcon, CheckboxEntry, CloseIcon, CollapsibleEntry, CreateIcon, index$1 as DebounceInputModule, DeleteIcon, DescriptionContext, Description as DescriptionEntry, DragIcon, DropdownButton, ErrorsContext, EventContext, ExternalLinkIcon, FeelCheckboxEntry, FeelEntry, FeelIcon$1 as FeelIcon, FeelNumberEntry, index as FeelPopupModule, FeelTemplatingEntry, FeelTextAreaEntry, FeelToggleSwitchEntry, Group, Header, HeaderButton, LaunchIcon, LayoutContext, List as ListEntry, ListGroup, ListItem, NumberFieldEntry, OpenPopupIcon, Placeholder, PropertiesPanel, LayoutContext as PropertiesPanelContext, SelectEntry, Simple as SimpleEntry, TemplatingEntry, TextAreaEntry, TextfieldEntry as TextFieldEntry, ToggleSwitchEntry, TooltipContext, TooltipWrapper as TooltipEntry, isEdited$8 as isCheckboxEntryEdited, isEdited$5 as isFeelEntryEdited, isEdited$6 as isNumberFieldEntryEdited, isEdited$3 as isSelectEntryEdited, isEdited$2 as isSimpleEntryEdited, isEdited$4 as isTemplatingEntryEdited, isEdited$1 as isTextAreaEntryEdited, isEdited as isTextFieldEntryEdited, isEdited$7 as isToggleSwitchEntryEdited, useDebounce, useDescriptionContext, useElementVisible, useError, useErrors, useEvent, useKeyFactory, useLayoutState, usePrevious, useShowEntryEvent, useStaticCallback, useStickyIntersectionObserver, useTooltipContext };
4382
4376
  //# sourceMappingURL=index.esm.js.map