warqadui 0.0.22 → 0.0.24
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 +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +69 -37
- package/dist/index.mjs +69 -37
- package/dist/styles.js +2346 -1
- package/dist/styles.mjs +2346 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -424,14 +424,19 @@ declare module "@tanstack/react-table" {
|
|
|
424
424
|
}
|
|
425
425
|
interface PostTableActions {
|
|
426
426
|
focus: (columnId: string) => void;
|
|
427
|
-
setError: (columnId: string,
|
|
427
|
+
setError: (columnId: string, error: boolean | string) => void;
|
|
428
428
|
}
|
|
429
429
|
interface PostTableProps<TData> {
|
|
430
430
|
columns: (ColumnDef<TData, any> & {
|
|
431
431
|
key?: string;
|
|
432
432
|
})[];
|
|
433
433
|
data?: TData[];
|
|
434
|
-
onChange?: (
|
|
434
|
+
onChange?: (params: {
|
|
435
|
+
entryData: Partial<TData>;
|
|
436
|
+
actions: PostTableActions;
|
|
437
|
+
actionType: "add" | "edit" | "delete";
|
|
438
|
+
fullData: TData[];
|
|
439
|
+
}) => void | Promise<void | boolean>;
|
|
435
440
|
isLoading?: boolean;
|
|
436
441
|
className?: string;
|
|
437
442
|
verticalLines?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -424,14 +424,19 @@ declare module "@tanstack/react-table" {
|
|
|
424
424
|
}
|
|
425
425
|
interface PostTableActions {
|
|
426
426
|
focus: (columnId: string) => void;
|
|
427
|
-
setError: (columnId: string,
|
|
427
|
+
setError: (columnId: string, error: boolean | string) => void;
|
|
428
428
|
}
|
|
429
429
|
interface PostTableProps<TData> {
|
|
430
430
|
columns: (ColumnDef<TData, any> & {
|
|
431
431
|
key?: string;
|
|
432
432
|
})[];
|
|
433
433
|
data?: TData[];
|
|
434
|
-
onChange?: (
|
|
434
|
+
onChange?: (params: {
|
|
435
|
+
entryData: Partial<TData>;
|
|
436
|
+
actions: PostTableActions;
|
|
437
|
+
actionType: "add" | "edit" | "delete";
|
|
438
|
+
fullData: TData[];
|
|
439
|
+
}) => void | Promise<void | boolean>;
|
|
435
440
|
isLoading?: boolean;
|
|
436
441
|
className?: string;
|
|
437
442
|
verticalLines?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1877,7 +1877,7 @@ var Textarea = (0, import_react11.forwardRef)(
|
|
|
1877
1877
|
);
|
|
1878
1878
|
|
|
1879
1879
|
// src/components/Fields/searchApi.tsx
|
|
1880
|
-
var import_react13 =
|
|
1880
|
+
var import_react13 = require("react");
|
|
1881
1881
|
var import_react_dom2 = require("react-dom");
|
|
1882
1882
|
var import_lucide_react8 = require("lucide-react");
|
|
1883
1883
|
|
|
@@ -2063,7 +2063,7 @@ var useSearchApiContext = () => {
|
|
|
2063
2063
|
};
|
|
2064
2064
|
var SearchApi = (0, import_react13.forwardRef)(
|
|
2065
2065
|
(props, _) => {
|
|
2066
|
-
const { form, name, onChange, value, children } = props;
|
|
2066
|
+
const { form, name, onChange, value, children, ...restProps } = props;
|
|
2067
2067
|
if (form && name) {
|
|
2068
2068
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2069
2069
|
import_react_hook_form5.Controller,
|
|
@@ -2073,7 +2073,9 @@ var SearchApi = (0, import_react13.forwardRef)(
|
|
|
2073
2073
|
render: ({ field }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2074
2074
|
SearchApiRoot,
|
|
2075
2075
|
{
|
|
2076
|
-
...
|
|
2076
|
+
...restProps,
|
|
2077
|
+
form,
|
|
2078
|
+
name,
|
|
2077
2079
|
currentValue: field.value !== void 0 && field.value !== "" ? field.value : value,
|
|
2078
2080
|
onChangeHandler: (val) => {
|
|
2079
2081
|
field.onChange(val);
|
|
@@ -2089,7 +2091,9 @@ var SearchApi = (0, import_react13.forwardRef)(
|
|
|
2089
2091
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2090
2092
|
SearchApiRoot,
|
|
2091
2093
|
{
|
|
2092
|
-
...
|
|
2094
|
+
...restProps,
|
|
2095
|
+
form,
|
|
2096
|
+
name,
|
|
2093
2097
|
currentValue: value,
|
|
2094
2098
|
onChangeHandler: onChange || (() => {
|
|
2095
2099
|
}),
|
|
@@ -2343,7 +2347,7 @@ var SearchApiRoot = ({
|
|
|
2343
2347
|
obj,
|
|
2344
2348
|
error: message
|
|
2345
2349
|
};
|
|
2346
|
-
const hasChildren =
|
|
2350
|
+
const hasChildren = !!children;
|
|
2347
2351
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SearchApiContext.Provider, { value: valueCtx, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2348
2352
|
"div",
|
|
2349
2353
|
{
|
|
@@ -2390,7 +2394,8 @@ var SearchApiTrigger = (0, import_react13.forwardRef)(
|
|
|
2390
2394
|
clearSelection,
|
|
2391
2395
|
selectedValue,
|
|
2392
2396
|
variant,
|
|
2393
|
-
inputRef
|
|
2397
|
+
inputRef,
|
|
2398
|
+
searchTerm
|
|
2394
2399
|
} = useSearchApiContext();
|
|
2395
2400
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "relative", ref: dropdownAnchorRef, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2396
2401
|
"div",
|
|
@@ -2403,7 +2408,9 @@ var SearchApiTrigger = (0, import_react13.forwardRef)(
|
|
|
2403
2408
|
onClick: () => {
|
|
2404
2409
|
if (disabled) return;
|
|
2405
2410
|
inputRef.current?.focus();
|
|
2406
|
-
|
|
2411
|
+
if (searchTerm.trim()) {
|
|
2412
|
+
setIsOpen(true);
|
|
2413
|
+
}
|
|
2407
2414
|
},
|
|
2408
2415
|
...props,
|
|
2409
2416
|
children: [
|
|
@@ -2471,7 +2478,8 @@ var SearchApiInput = (0, import_react13.forwardRef)(
|
|
|
2471
2478
|
};
|
|
2472
2479
|
const handleKeyDown = (e) => {
|
|
2473
2480
|
if (!isOpen) {
|
|
2474
|
-
if (e.key === "ArrowDown" || e.key === "Enter")
|
|
2481
|
+
if ((e.key === "ArrowDown" || e.key === "Enter") && searchTerm.trim())
|
|
2482
|
+
setIsOpen(true);
|
|
2475
2483
|
return;
|
|
2476
2484
|
}
|
|
2477
2485
|
switch (e.key) {
|
|
@@ -2510,10 +2518,20 @@ var SearchApiInput = (0, import_react13.forwardRef)(
|
|
|
2510
2518
|
className: `block w-full bg-transparent border-none focus:ring-0 py-1 focus:outline-none text-sm placeholder-gray-400 dark:placeholder-zinc-500 ${!isOpen && selectedValue ? "opacity-0" : "opacity-100"} ${variant === "ghost" ? "h-full" : "h-9"} ${className}`,
|
|
2511
2519
|
placeholder: !selectedValue ? placeholder : "",
|
|
2512
2520
|
value: searchTerm,
|
|
2513
|
-
onChange: (e) =>
|
|
2521
|
+
onChange: (e) => {
|
|
2522
|
+
const val = e.target.value;
|
|
2523
|
+
setSearchTerm(val);
|
|
2524
|
+
if (val.trim()) {
|
|
2525
|
+
setIsOpen(true);
|
|
2526
|
+
} else {
|
|
2527
|
+
setIsOpen(false);
|
|
2528
|
+
}
|
|
2529
|
+
},
|
|
2514
2530
|
onFocus: () => {
|
|
2515
2531
|
setIsFocused(true);
|
|
2516
|
-
|
|
2532
|
+
if (searchTerm.trim()) {
|
|
2533
|
+
setIsOpen(true);
|
|
2534
|
+
}
|
|
2517
2535
|
},
|
|
2518
2536
|
onKeyDown: handleKeyDown,
|
|
2519
2537
|
disabled,
|
|
@@ -2580,7 +2598,7 @@ var SearchApiContent = (0, import_react13.forwardRef)(
|
|
|
2580
2598
|
isLoading && options.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "p-4 text-center text-sm text-gray-500", children: [
|
|
2581
2599
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react8.Loader2, { className: "h-5 w-5 animate-spin mx-auto mb-2" }),
|
|
2582
2600
|
"Loading options..."
|
|
2583
|
-
] }) :
|
|
2601
|
+
] }) : children ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "py-1", children }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "p-4 text-center text-sm text-gray-500", children: searchTerm ? `No results for "${searchTerm}"` : "No options available" })
|
|
2584
2602
|
]
|
|
2585
2603
|
}
|
|
2586
2604
|
),
|
|
@@ -3175,15 +3193,20 @@ function PostTable({
|
|
|
3175
3193
|
}
|
|
3176
3194
|
}
|
|
3177
3195
|
},
|
|
3178
|
-
setError: (columnId,
|
|
3196
|
+
setError: (columnId, error) => {
|
|
3179
3197
|
setFieldErrors((prev) => ({
|
|
3180
3198
|
...prev,
|
|
3181
|
-
[columnId]:
|
|
3199
|
+
[columnId]: error
|
|
3182
3200
|
}));
|
|
3183
3201
|
}
|
|
3184
3202
|
};
|
|
3185
3203
|
const type = editingIndex !== null ? "edit" : "add";
|
|
3186
|
-
const result = await onChange(
|
|
3204
|
+
const result = await onChange({
|
|
3205
|
+
entryData,
|
|
3206
|
+
actions,
|
|
3207
|
+
actionType: type,
|
|
3208
|
+
fullData: newData
|
|
3209
|
+
});
|
|
3187
3210
|
if (result === false) {
|
|
3188
3211
|
setIsSavingAsync(false);
|
|
3189
3212
|
return;
|
|
@@ -3229,14 +3252,19 @@ function PostTable({
|
|
|
3229
3252
|
}
|
|
3230
3253
|
}
|
|
3231
3254
|
},
|
|
3232
|
-
setError: (columnId,
|
|
3255
|
+
setError: (columnId, error) => {
|
|
3233
3256
|
setFieldErrors((prev) => ({
|
|
3234
3257
|
...prev,
|
|
3235
|
-
[columnId]:
|
|
3258
|
+
[columnId]: error
|
|
3236
3259
|
}));
|
|
3237
3260
|
}
|
|
3238
3261
|
};
|
|
3239
|
-
onChange?.(
|
|
3262
|
+
onChange?.({
|
|
3263
|
+
entryData: data[index2],
|
|
3264
|
+
actions,
|
|
3265
|
+
actionType: "delete",
|
|
3266
|
+
fullData: newData
|
|
3267
|
+
});
|
|
3240
3268
|
if (editingIndex === index2) {
|
|
3241
3269
|
handleCancelEdit();
|
|
3242
3270
|
} else if (editingIndex !== null && editingIndex > index2) {
|
|
@@ -3463,7 +3491,8 @@ function PostTable({
|
|
|
3463
3491
|
const fieldRenderer = column.columnDef.meta?.field;
|
|
3464
3492
|
const accessor = column.columnDef.accessorKey || column.id;
|
|
3465
3493
|
const value = entryData[accessor] || "";
|
|
3466
|
-
const
|
|
3494
|
+
const error = fieldErrors[accessor];
|
|
3495
|
+
const hasError = !!error;
|
|
3467
3496
|
const onChangeValue = (val) => {
|
|
3468
3497
|
setEntryData((prev) => ({
|
|
3469
3498
|
...prev,
|
|
@@ -3497,12 +3526,12 @@ function PostTable({
|
|
|
3497
3526
|
column.id === "_index" ? "w-px whitespace-nowrap" : "",
|
|
3498
3527
|
hasError && "ring-1 ring-inset ring-red-500"
|
|
3499
3528
|
),
|
|
3500
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime23.
|
|
3529
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
3501
3530
|
"div",
|
|
3502
3531
|
{
|
|
3503
3532
|
className: cn(
|
|
3504
|
-
"flex items-center",
|
|
3505
|
-
column.id === "_index" ? "" : "
|
|
3533
|
+
"flex items-center relative group w-full",
|
|
3534
|
+
column.id === "_index" ? "" : "min-w-32 h-9"
|
|
3506
3535
|
),
|
|
3507
3536
|
onKeyDown: (e) => {
|
|
3508
3537
|
if (e.key === "Enter") {
|
|
@@ -3510,23 +3539,26 @@ function PostTable({
|
|
|
3510
3539
|
handleSaveField();
|
|
3511
3540
|
}
|
|
3512
3541
|
},
|
|
3513
|
-
children:
|
|
3514
|
-
|
|
3515
|
-
onChange: onChangeValue,
|
|
3516
|
-
rowData: entryData,
|
|
3517
|
-
setRowData: setEntryData
|
|
3518
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3519
|
-
Fields_default.Input,
|
|
3520
|
-
{
|
|
3521
|
-
id: `pti-${accessor}`,
|
|
3522
|
-
label: "",
|
|
3523
|
-
variant: "ghost",
|
|
3542
|
+
children: [
|
|
3543
|
+
fieldRenderer ? fieldRenderer({
|
|
3524
3544
|
value,
|
|
3525
|
-
onChange:
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
}
|
|
3529
|
-
|
|
3545
|
+
onChange: onChangeValue,
|
|
3546
|
+
rowData: entryData,
|
|
3547
|
+
setRowData: setEntryData
|
|
3548
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3549
|
+
Fields_default.Input,
|
|
3550
|
+
{
|
|
3551
|
+
id: `pti-${accessor}`,
|
|
3552
|
+
label: "",
|
|
3553
|
+
variant: "ghost",
|
|
3554
|
+
value,
|
|
3555
|
+
onChange: (e) => onChangeValue(e.target.value),
|
|
3556
|
+
className: "px-0! bg-transparent!",
|
|
3557
|
+
placeholder: `${typeof column.columnDef.header === "string" ? column.columnDef.header : column.id}`
|
|
3558
|
+
}
|
|
3559
|
+
),
|
|
3560
|
+
typeof error === "string" && /* @__PURE__ */ (0, import_jsx_runtime23.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 })
|
|
3561
|
+
]
|
|
3530
3562
|
}
|
|
3531
3563
|
)
|
|
3532
3564
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -1811,7 +1811,7 @@ var Textarea = forwardRef4(
|
|
|
1811
1811
|
);
|
|
1812
1812
|
|
|
1813
1813
|
// src/components/Fields/searchApi.tsx
|
|
1814
|
-
import
|
|
1814
|
+
import {
|
|
1815
1815
|
createContext as createContext4,
|
|
1816
1816
|
useContext as useContext4,
|
|
1817
1817
|
useState as useState12,
|
|
@@ -2004,7 +2004,7 @@ var useSearchApiContext = () => {
|
|
|
2004
2004
|
};
|
|
2005
2005
|
var SearchApi = forwardRef5(
|
|
2006
2006
|
(props, _) => {
|
|
2007
|
-
const { form, name, onChange, value, children } = props;
|
|
2007
|
+
const { form, name, onChange, value, children, ...restProps } = props;
|
|
2008
2008
|
if (form && name) {
|
|
2009
2009
|
return /* @__PURE__ */ jsx20(
|
|
2010
2010
|
Controller5,
|
|
@@ -2014,7 +2014,9 @@ var SearchApi = forwardRef5(
|
|
|
2014
2014
|
render: ({ field }) => /* @__PURE__ */ jsx20(
|
|
2015
2015
|
SearchApiRoot,
|
|
2016
2016
|
{
|
|
2017
|
-
...
|
|
2017
|
+
...restProps,
|
|
2018
|
+
form,
|
|
2019
|
+
name,
|
|
2018
2020
|
currentValue: field.value !== void 0 && field.value !== "" ? field.value : value,
|
|
2019
2021
|
onChangeHandler: (val) => {
|
|
2020
2022
|
field.onChange(val);
|
|
@@ -2030,7 +2032,9 @@ var SearchApi = forwardRef5(
|
|
|
2030
2032
|
return /* @__PURE__ */ jsx20(
|
|
2031
2033
|
SearchApiRoot,
|
|
2032
2034
|
{
|
|
2033
|
-
...
|
|
2035
|
+
...restProps,
|
|
2036
|
+
form,
|
|
2037
|
+
name,
|
|
2034
2038
|
currentValue: value,
|
|
2035
2039
|
onChangeHandler: onChange || (() => {
|
|
2036
2040
|
}),
|
|
@@ -2284,7 +2288,7 @@ var SearchApiRoot = ({
|
|
|
2284
2288
|
obj,
|
|
2285
2289
|
error: message
|
|
2286
2290
|
};
|
|
2287
|
-
const hasChildren =
|
|
2291
|
+
const hasChildren = !!children;
|
|
2288
2292
|
return /* @__PURE__ */ jsx20(SearchApiContext.Provider, { value: valueCtx, children: /* @__PURE__ */ jsxs15(
|
|
2289
2293
|
"div",
|
|
2290
2294
|
{
|
|
@@ -2331,7 +2335,8 @@ var SearchApiTrigger = forwardRef5(
|
|
|
2331
2335
|
clearSelection,
|
|
2332
2336
|
selectedValue,
|
|
2333
2337
|
variant,
|
|
2334
|
-
inputRef
|
|
2338
|
+
inputRef,
|
|
2339
|
+
searchTerm
|
|
2335
2340
|
} = useSearchApiContext();
|
|
2336
2341
|
return /* @__PURE__ */ jsx20("div", { className: "relative", ref: dropdownAnchorRef, children: /* @__PURE__ */ jsxs15(
|
|
2337
2342
|
"div",
|
|
@@ -2344,7 +2349,9 @@ var SearchApiTrigger = forwardRef5(
|
|
|
2344
2349
|
onClick: () => {
|
|
2345
2350
|
if (disabled) return;
|
|
2346
2351
|
inputRef.current?.focus();
|
|
2347
|
-
|
|
2352
|
+
if (searchTerm.trim()) {
|
|
2353
|
+
setIsOpen(true);
|
|
2354
|
+
}
|
|
2348
2355
|
},
|
|
2349
2356
|
...props,
|
|
2350
2357
|
children: [
|
|
@@ -2412,7 +2419,8 @@ var SearchApiInput = forwardRef5(
|
|
|
2412
2419
|
};
|
|
2413
2420
|
const handleKeyDown = (e) => {
|
|
2414
2421
|
if (!isOpen) {
|
|
2415
|
-
if (e.key === "ArrowDown" || e.key === "Enter")
|
|
2422
|
+
if ((e.key === "ArrowDown" || e.key === "Enter") && searchTerm.trim())
|
|
2423
|
+
setIsOpen(true);
|
|
2416
2424
|
return;
|
|
2417
2425
|
}
|
|
2418
2426
|
switch (e.key) {
|
|
@@ -2451,10 +2459,20 @@ var SearchApiInput = forwardRef5(
|
|
|
2451
2459
|
className: `block w-full bg-transparent border-none focus:ring-0 py-1 focus:outline-none text-sm placeholder-gray-400 dark:placeholder-zinc-500 ${!isOpen && selectedValue ? "opacity-0" : "opacity-100"} ${variant === "ghost" ? "h-full" : "h-9"} ${className}`,
|
|
2452
2460
|
placeholder: !selectedValue ? placeholder : "",
|
|
2453
2461
|
value: searchTerm,
|
|
2454
|
-
onChange: (e) =>
|
|
2462
|
+
onChange: (e) => {
|
|
2463
|
+
const val = e.target.value;
|
|
2464
|
+
setSearchTerm(val);
|
|
2465
|
+
if (val.trim()) {
|
|
2466
|
+
setIsOpen(true);
|
|
2467
|
+
} else {
|
|
2468
|
+
setIsOpen(false);
|
|
2469
|
+
}
|
|
2470
|
+
},
|
|
2455
2471
|
onFocus: () => {
|
|
2456
2472
|
setIsFocused(true);
|
|
2457
|
-
|
|
2473
|
+
if (searchTerm.trim()) {
|
|
2474
|
+
setIsOpen(true);
|
|
2475
|
+
}
|
|
2458
2476
|
},
|
|
2459
2477
|
onKeyDown: handleKeyDown,
|
|
2460
2478
|
disabled,
|
|
@@ -2521,7 +2539,7 @@ var SearchApiContent = forwardRef5(
|
|
|
2521
2539
|
isLoading && options.length === 0 ? /* @__PURE__ */ jsxs15("div", { className: "p-4 text-center text-sm text-gray-500", children: [
|
|
2522
2540
|
/* @__PURE__ */ jsx20(Loader22, { className: "h-5 w-5 animate-spin mx-auto mb-2" }),
|
|
2523
2541
|
"Loading options..."
|
|
2524
|
-
] }) :
|
|
2542
|
+
] }) : children ? /* @__PURE__ */ jsx20("div", { className: "py-1", children }) : /* @__PURE__ */ jsx20("div", { className: "p-4 text-center text-sm text-gray-500", children: searchTerm ? `No results for "${searchTerm}"` : "No options available" })
|
|
2525
2543
|
]
|
|
2526
2544
|
}
|
|
2527
2545
|
),
|
|
@@ -3133,15 +3151,20 @@ function PostTable({
|
|
|
3133
3151
|
}
|
|
3134
3152
|
}
|
|
3135
3153
|
},
|
|
3136
|
-
setError: (columnId,
|
|
3154
|
+
setError: (columnId, error) => {
|
|
3137
3155
|
setFieldErrors((prev) => ({
|
|
3138
3156
|
...prev,
|
|
3139
|
-
[columnId]:
|
|
3157
|
+
[columnId]: error
|
|
3140
3158
|
}));
|
|
3141
3159
|
}
|
|
3142
3160
|
};
|
|
3143
3161
|
const type = editingIndex !== null ? "edit" : "add";
|
|
3144
|
-
const result = await onChange(
|
|
3162
|
+
const result = await onChange({
|
|
3163
|
+
entryData,
|
|
3164
|
+
actions,
|
|
3165
|
+
actionType: type,
|
|
3166
|
+
fullData: newData
|
|
3167
|
+
});
|
|
3145
3168
|
if (result === false) {
|
|
3146
3169
|
setIsSavingAsync(false);
|
|
3147
3170
|
return;
|
|
@@ -3187,14 +3210,19 @@ function PostTable({
|
|
|
3187
3210
|
}
|
|
3188
3211
|
}
|
|
3189
3212
|
},
|
|
3190
|
-
setError: (columnId,
|
|
3213
|
+
setError: (columnId, error) => {
|
|
3191
3214
|
setFieldErrors((prev) => ({
|
|
3192
3215
|
...prev,
|
|
3193
|
-
[columnId]:
|
|
3216
|
+
[columnId]: error
|
|
3194
3217
|
}));
|
|
3195
3218
|
}
|
|
3196
3219
|
};
|
|
3197
|
-
onChange?.(
|
|
3220
|
+
onChange?.({
|
|
3221
|
+
entryData: data[index2],
|
|
3222
|
+
actions,
|
|
3223
|
+
actionType: "delete",
|
|
3224
|
+
fullData: newData
|
|
3225
|
+
});
|
|
3198
3226
|
if (editingIndex === index2) {
|
|
3199
3227
|
handleCancelEdit();
|
|
3200
3228
|
} else if (editingIndex !== null && editingIndex > index2) {
|
|
@@ -3421,7 +3449,8 @@ function PostTable({
|
|
|
3421
3449
|
const fieldRenderer = column.columnDef.meta?.field;
|
|
3422
3450
|
const accessor = column.columnDef.accessorKey || column.id;
|
|
3423
3451
|
const value = entryData[accessor] || "";
|
|
3424
|
-
const
|
|
3452
|
+
const error = fieldErrors[accessor];
|
|
3453
|
+
const hasError = !!error;
|
|
3425
3454
|
const onChangeValue = (val) => {
|
|
3426
3455
|
setEntryData((prev) => ({
|
|
3427
3456
|
...prev,
|
|
@@ -3455,12 +3484,12 @@ function PostTable({
|
|
|
3455
3484
|
column.id === "_index" ? "w-px whitespace-nowrap" : "",
|
|
3456
3485
|
hasError && "ring-1 ring-inset ring-red-500"
|
|
3457
3486
|
),
|
|
3458
|
-
children: /* @__PURE__ */
|
|
3487
|
+
children: /* @__PURE__ */ jsxs18(
|
|
3459
3488
|
"div",
|
|
3460
3489
|
{
|
|
3461
3490
|
className: cn(
|
|
3462
|
-
"flex items-center",
|
|
3463
|
-
column.id === "_index" ? "" : "
|
|
3491
|
+
"flex items-center relative group w-full",
|
|
3492
|
+
column.id === "_index" ? "" : "min-w-32 h-9"
|
|
3464
3493
|
),
|
|
3465
3494
|
onKeyDown: (e) => {
|
|
3466
3495
|
if (e.key === "Enter") {
|
|
@@ -3468,23 +3497,26 @@ function PostTable({
|
|
|
3468
3497
|
handleSaveField();
|
|
3469
3498
|
}
|
|
3470
3499
|
},
|
|
3471
|
-
children:
|
|
3472
|
-
|
|
3473
|
-
onChange: onChangeValue,
|
|
3474
|
-
rowData: entryData,
|
|
3475
|
-
setRowData: setEntryData
|
|
3476
|
-
}) : /* @__PURE__ */ jsx23(
|
|
3477
|
-
Fields_default.Input,
|
|
3478
|
-
{
|
|
3479
|
-
id: `pti-${accessor}`,
|
|
3480
|
-
label: "",
|
|
3481
|
-
variant: "ghost",
|
|
3500
|
+
children: [
|
|
3501
|
+
fieldRenderer ? fieldRenderer({
|
|
3482
3502
|
value,
|
|
3483
|
-
onChange:
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
}
|
|
3487
|
-
|
|
3503
|
+
onChange: onChangeValue,
|
|
3504
|
+
rowData: entryData,
|
|
3505
|
+
setRowData: setEntryData
|
|
3506
|
+
}) : /* @__PURE__ */ jsx23(
|
|
3507
|
+
Fields_default.Input,
|
|
3508
|
+
{
|
|
3509
|
+
id: `pti-${accessor}`,
|
|
3510
|
+
label: "",
|
|
3511
|
+
variant: "ghost",
|
|
3512
|
+
value,
|
|
3513
|
+
onChange: (e) => onChangeValue(e.target.value),
|
|
3514
|
+
className: "px-0! bg-transparent!",
|
|
3515
|
+
placeholder: `${typeof column.columnDef.header === "string" ? column.columnDef.header : column.id}`
|
|
3516
|
+
}
|
|
3517
|
+
),
|
|
3518
|
+
typeof error === "string" && /* @__PURE__ */ jsx23("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 })
|
|
3519
|
+
]
|
|
3488
3520
|
}
|
|
3489
3521
|
)
|
|
3490
3522
|
},
|