warqadui 0.0.26 → 0.0.27

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.d.mts CHANGED
@@ -264,7 +264,7 @@ interface SearchApiContextValue {
264
264
  options: any[];
265
265
  setOptions: (opts: any[]) => void;
266
266
  isLoading: boolean;
267
- clearSelection: (e: React__default.MouseEvent) => void;
267
+ clearSelection: (e: React__default.MouseEvent | any) => void;
268
268
  handleSelect: (opt: any) => void;
269
269
  getDisplayValue: () => string;
270
270
  placeholder?: string;
package/dist/index.d.ts CHANGED
@@ -264,7 +264,7 @@ interface SearchApiContextValue {
264
264
  options: any[];
265
265
  setOptions: (opts: any[]) => void;
266
266
  isLoading: boolean;
267
- clearSelection: (e: React__default.MouseEvent) => void;
267
+ clearSelection: (e: React__default.MouseEvent | any) => void;
268
268
  handleSelect: (opt: any) => void;
269
269
  getDisplayValue: () => string;
270
270
  placeholder?: string;
package/dist/index.js CHANGED
@@ -2297,7 +2297,7 @@ var SearchApiRoot = ({
2297
2297
  fieldInternalProps?.onBlur?.();
2298
2298
  };
2299
2299
  const clearSelection = (e) => {
2300
- e.stopPropagation();
2300
+ if (e?.stopPropagation) e.stopPropagation();
2301
2301
  if (form) {
2302
2302
  if (name)
2303
2303
  form.setValue(name, void 0, {
@@ -2479,6 +2479,7 @@ var SearchApiInput = (0, import_react13.forwardRef)(
2479
2479
  setActiveIndex,
2480
2480
  options,
2481
2481
  handleSelect,
2482
+ clearSelection,
2482
2483
  inputRef,
2483
2484
  fieldInternalProps,
2484
2485
  form,
@@ -2544,6 +2545,9 @@ var SearchApiInput = (0, import_react13.forwardRef)(
2544
2545
  setIsOpen(true);
2545
2546
  } else {
2546
2547
  setIsOpen(false);
2548
+ if (selectedValue) {
2549
+ clearSelection(e);
2550
+ }
2547
2551
  }
2548
2552
  if (form) {
2549
2553
  if (name) form.clearErrors(name);
@@ -2552,7 +2556,11 @@ var SearchApiInput = (0, import_react13.forwardRef)(
2552
2556
  },
2553
2557
  onFocus: () => {
2554
2558
  setIsFocused(true);
2555
- if (searchTerm.trim()) {
2559
+ const display = getDisplayValue();
2560
+ if (!searchTerm && selectedValue && display && display !== "Loading...") {
2561
+ setSearchTerm(display);
2562
+ setIsOpen(true);
2563
+ } else if (searchTerm.trim() || selectedValue) {
2556
2564
  setIsOpen(true);
2557
2565
  }
2558
2566
  },
package/dist/index.mjs CHANGED
@@ -2238,7 +2238,7 @@ var SearchApiRoot = ({
2238
2238
  fieldInternalProps?.onBlur?.();
2239
2239
  };
2240
2240
  const clearSelection = (e) => {
2241
- e.stopPropagation();
2241
+ if (e?.stopPropagation) e.stopPropagation();
2242
2242
  if (form) {
2243
2243
  if (name)
2244
2244
  form.setValue(name, void 0, {
@@ -2420,6 +2420,7 @@ var SearchApiInput = forwardRef5(
2420
2420
  setActiveIndex,
2421
2421
  options,
2422
2422
  handleSelect,
2423
+ clearSelection,
2423
2424
  inputRef,
2424
2425
  fieldInternalProps,
2425
2426
  form,
@@ -2485,6 +2486,9 @@ var SearchApiInput = forwardRef5(
2485
2486
  setIsOpen(true);
2486
2487
  } else {
2487
2488
  setIsOpen(false);
2489
+ if (selectedValue) {
2490
+ clearSelection(e);
2491
+ }
2488
2492
  }
2489
2493
  if (form) {
2490
2494
  if (name) form.clearErrors(name);
@@ -2493,7 +2497,11 @@ var SearchApiInput = forwardRef5(
2493
2497
  },
2494
2498
  onFocus: () => {
2495
2499
  setIsFocused(true);
2496
- if (searchTerm.trim()) {
2500
+ const display = getDisplayValue();
2501
+ if (!searchTerm && selectedValue && display && display !== "Loading...") {
2502
+ setSearchTerm(display);
2503
+ setIsOpen(true);
2504
+ } else if (searchTerm.trim() || selectedValue) {
2497
2505
  setIsOpen(true);
2498
2506
  }
2499
2507
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warqadui",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",