warqadui 0.0.25 → 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,8 +2479,12 @@ var SearchApiInput = (0, import_react13.forwardRef)(
2479
2479
  setActiveIndex,
2480
2480
  options,
2481
2481
  handleSelect,
2482
+ clearSelection,
2482
2483
  inputRef,
2483
- fieldInternalProps
2484
+ fieldInternalProps,
2485
+ form,
2486
+ name,
2487
+ obj
2484
2488
  } = useSearchApiContext();
2485
2489
  const setInternalInputRef = (element) => {
2486
2490
  inputRef.current = element;
@@ -2541,11 +2545,22 @@ var SearchApiInput = (0, import_react13.forwardRef)(
2541
2545
  setIsOpen(true);
2542
2546
  } else {
2543
2547
  setIsOpen(false);
2548
+ if (selectedValue) {
2549
+ clearSelection(e);
2550
+ }
2551
+ }
2552
+ if (form) {
2553
+ if (name) form.clearErrors(name);
2554
+ if (obj) form.clearErrors(obj);
2544
2555
  }
2545
2556
  },
2546
2557
  onFocus: () => {
2547
2558
  setIsFocused(true);
2548
- 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) {
2549
2564
  setIsOpen(true);
2550
2565
  }
2551
2566
  },
@@ -3555,6 +3570,15 @@ function PostTable({
3555
3570
  handleSaveField();
3556
3571
  }
3557
3572
  },
3573
+ onInput: () => {
3574
+ if (fieldErrors[accessor]) {
3575
+ setFieldErrors((prev) => {
3576
+ const next = { ...prev };
3577
+ delete next[accessor];
3578
+ return next;
3579
+ });
3580
+ }
3581
+ },
3558
3582
  children: [
3559
3583
  fieldRenderer ? fieldRenderer({
3560
3584
  value,
@@ -3573,7 +3597,7 @@ function PostTable({
3573
3597
  placeholder: `${typeof column.columnDef.header === "string" ? column.columnDef.header : column.id}`
3574
3598
  }
3575
3599
  ),
3576
- typeof error === "string" && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "absolute left-1/2 -translate-x-1/2 bottom-[100%] mb-2 z-[9999] pointer-events-none opacity-0 group-hover:opacity-100 focus-within:opacity-100 group-focus-within:opacity-100 transition-opacity whitespace-nowrap bg-red-500 text-white text-xs px-2.5 py-1.5 rounded shadow-lg before:content-[''] before:absolute before:top-full before:left-1/2 before:-translate-x-1/2 before:border-4 before:border-transparent before:border-t-red-500", children: error })
3600
+ typeof error === "string" && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-9999 pointer-events-none opacity-0 group-hover:opacity-100 focus-within:opacity-100 group-focus-within:opacity-100 transition-opacity whitespace-nowrap bg-red-500 text-white text-xs px-2.5 py-1.5 rounded shadow-lg before:content-[''] before:absolute before:top-full before:left-1/2 before:-translate-x-1/2 before:border-4 before:border-transparent before:border-t-red-500", children: error })
3577
3601
  ]
3578
3602
  }
3579
3603
  )
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,8 +2420,12 @@ var SearchApiInput = forwardRef5(
2420
2420
  setActiveIndex,
2421
2421
  options,
2422
2422
  handleSelect,
2423
+ clearSelection,
2423
2424
  inputRef,
2424
- fieldInternalProps
2425
+ fieldInternalProps,
2426
+ form,
2427
+ name,
2428
+ obj
2425
2429
  } = useSearchApiContext();
2426
2430
  const setInternalInputRef = (element) => {
2427
2431
  inputRef.current = element;
@@ -2482,11 +2486,22 @@ var SearchApiInput = forwardRef5(
2482
2486
  setIsOpen(true);
2483
2487
  } else {
2484
2488
  setIsOpen(false);
2489
+ if (selectedValue) {
2490
+ clearSelection(e);
2491
+ }
2492
+ }
2493
+ if (form) {
2494
+ if (name) form.clearErrors(name);
2495
+ if (obj) form.clearErrors(obj);
2485
2496
  }
2486
2497
  },
2487
2498
  onFocus: () => {
2488
2499
  setIsFocused(true);
2489
- 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) {
2490
2505
  setIsOpen(true);
2491
2506
  }
2492
2507
  },
@@ -3513,6 +3528,15 @@ function PostTable({
3513
3528
  handleSaveField();
3514
3529
  }
3515
3530
  },
3531
+ onInput: () => {
3532
+ if (fieldErrors[accessor]) {
3533
+ setFieldErrors((prev) => {
3534
+ const next = { ...prev };
3535
+ delete next[accessor];
3536
+ return next;
3537
+ });
3538
+ }
3539
+ },
3516
3540
  children: [
3517
3541
  fieldRenderer ? fieldRenderer({
3518
3542
  value,
@@ -3531,7 +3555,7 @@ function PostTable({
3531
3555
  placeholder: `${typeof column.columnDef.header === "string" ? column.columnDef.header : column.id}`
3532
3556
  }
3533
3557
  ),
3534
- typeof error === "string" && /* @__PURE__ */ jsx24("div", { className: "absolute left-1/2 -translate-x-1/2 bottom-[100%] mb-2 z-[9999] pointer-events-none opacity-0 group-hover:opacity-100 focus-within:opacity-100 group-focus-within:opacity-100 transition-opacity whitespace-nowrap bg-red-500 text-white text-xs px-2.5 py-1.5 rounded shadow-lg before:content-[''] before:absolute before:top-full before:left-1/2 before:-translate-x-1/2 before:border-4 before:border-transparent before:border-t-red-500", children: error })
3558
+ typeof error === "string" && /* @__PURE__ */ jsx24("div", { className: "absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-9999 pointer-events-none opacity-0 group-hover:opacity-100 focus-within:opacity-100 group-focus-within:opacity-100 transition-opacity whitespace-nowrap bg-red-500 text-white text-xs px-2.5 py-1.5 rounded shadow-lg before:content-[''] before:absolute before:top-full before:left-1/2 before:-translate-x-1/2 before:border-4 before:border-transparent before:border-t-red-500", children: error })
3535
3559
  ]
3536
3560
  }
3537
3561
  )
package/dist/styles.js CHANGED
@@ -472,7 +472,7 @@ select:-webkit-autofill:focus {
472
472
  .bottom-2 {
473
473
  bottom: 0.5rem;
474
474
  }
475
- .bottom-\\[100\\%\\] {
475
+ .bottom-full {
476
476
  bottom: 100%;
477
477
  }
478
478
  .left-0 {
@@ -511,9 +511,6 @@ select:-webkit-autofill:focus {
511
511
  .z-50 {
512
512
  z-index: 50;
513
513
  }
514
- .z-\\[9999\\] {
515
- z-index: 9999;
516
- }
517
514
  .mx-2 {
518
515
  margin-left: 0.5rem;
519
516
  margin-right: 0.5rem;
package/dist/styles.mjs CHANGED
@@ -470,7 +470,7 @@ select:-webkit-autofill:focus {
470
470
  .bottom-2 {
471
471
  bottom: 0.5rem;
472
472
  }
473
- .bottom-\\[100\\%\\] {
473
+ .bottom-full {
474
474
  bottom: 100%;
475
475
  }
476
476
  .left-0 {
@@ -509,9 +509,6 @@ select:-webkit-autofill:focus {
509
509
  .z-50 {
510
510
  z-index: 50;
511
511
  }
512
- .z-\\[9999\\] {
513
- z-index: 9999;
514
- }
515
512
  .mx-2 {
516
513
  margin-left: 0.5rem;
517
514
  margin-right: 0.5rem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warqadui",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",