@jobber/components 6.103.4-uncontroll-d4ef425.5 → 6.103.4-uncontroll-951d07b.6

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.
@@ -258,6 +258,9 @@ function useAutocomplete(props) {
258
258
  if (prevValueRef.current !== value) {
259
259
  prevValueRef.current = value;
260
260
  const currentValue = value;
261
+ // Mark this as a programmatic change, not user input
262
+ // This prevents onChange from being called when we sync from prop changes
263
+ lastInputWasUser.current = false;
261
264
  setInternalInputValue(currentValue ? getOptionLabel(currentValue) : "");
262
265
  }
263
266
  }, [value, inputValueProp, multiple, getOptionLabel]);
@@ -413,8 +416,11 @@ function useAutocomplete(props) {
413
416
  // In multiple mode, clearing the input should NOT clear the selection
414
417
  if (multiple)
415
418
  return;
416
- // For single-select, treat clearing input as clearing the selection
417
- if (hasSelection) {
419
+ // Only clear the selection if the user actually cleared the input
420
+ // (not from internal state sync when parent changes the value prop)
421
+ // This prevents calling onChange when we're syncing state from a controlled value prop,
422
+ // but still allows onChange to fire when the user deletes the input text
423
+ if (lastInputWasUser.current && hasSelection) {
418
424
  onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
419
425
  }
420
426
  }, [inputValue, multiple, hasSelection, setActiveIndex, onChange, open]);
@@ -256,6 +256,9 @@ function useAutocomplete(props) {
256
256
  if (prevValueRef.current !== value) {
257
257
  prevValueRef.current = value;
258
258
  const currentValue = value;
259
+ // Mark this as a programmatic change, not user input
260
+ // This prevents onChange from being called when we sync from prop changes
261
+ lastInputWasUser.current = false;
259
262
  setInternalInputValue(currentValue ? getOptionLabel(currentValue) : "");
260
263
  }
261
264
  }, [value, inputValueProp, multiple, getOptionLabel]);
@@ -411,8 +414,11 @@ function useAutocomplete(props) {
411
414
  // In multiple mode, clearing the input should NOT clear the selection
412
415
  if (multiple)
413
416
  return;
414
- // For single-select, treat clearing input as clearing the selection
415
- if (hasSelection) {
417
+ // Only clear the selection if the user actually cleared the input
418
+ // (not from internal state sync when parent changes the value prop)
419
+ // This prevents calling onChange when we're syncing state from a controlled value prop,
420
+ // but still allows onChange to fire when the user deletes the input text
421
+ if (lastInputWasUser.current && hasSelection) {
416
422
  onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
417
423
  }
418
424
  }, [inputValue, multiple, hasSelection, setActiveIndex, onChange, open]);
@@ -36,3 +36,20 @@ export declare function FreeFormWrapper({ initialValue, initialInputValue, onCha
36
36
  readonly inputEqualsOption?: (input: string, option: OptionLike) => boolean;
37
37
  readonly debounce?: number;
38
38
  }): React.JSX.Element;
39
+ export declare function UncontrolledWrapper<T extends OptionLike>({ defaultValue, menu, placeholder, }: {
40
+ readonly defaultValue?: T;
41
+ readonly menu: MenuItem<T>[];
42
+ readonly placeholder?: string;
43
+ }): React.JSX.Element;
44
+ export declare function SemiControlledWrapper<T extends OptionLike>({ initialValue, onChange, menu, placeholder, }: {
45
+ readonly initialValue?: T;
46
+ readonly onChange?: (v: T | undefined) => void;
47
+ readonly menu: MenuItem<T>[];
48
+ readonly placeholder?: string;
49
+ }): React.JSX.Element;
50
+ export declare function ControlledValueWrapper<T extends OptionLike>({ value, onChange, menu, placeholder, }: {
51
+ readonly value: T | undefined;
52
+ readonly onChange: (v: T | undefined) => void;
53
+ readonly menu: MenuItem<T>[];
54
+ readonly placeholder?: string;
55
+ }): React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.103.4-uncontroll-d4ef425.5+d4ef4259d",
3
+ "version": "6.103.4-uncontroll-951d07b.6+951d07b93",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -538,5 +538,5 @@
538
538
  "> 1%",
539
539
  "IE 10"
540
540
  ],
541
- "gitHead": "d4ef4259debb09593eabc29a42b18faa208329b8"
541
+ "gitHead": "951d07b936bd3e0cc6dc48c9a4cb98f2a93a838e"
542
542
  }