warqadui 0.0.22 → 0.0.23
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 +40 -26
- package/dist/index.mjs +40 -26
- 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
|
@@ -3175,15 +3175,20 @@ function PostTable({
|
|
|
3175
3175
|
}
|
|
3176
3176
|
}
|
|
3177
3177
|
},
|
|
3178
|
-
setError: (columnId,
|
|
3178
|
+
setError: (columnId, error) => {
|
|
3179
3179
|
setFieldErrors((prev) => ({
|
|
3180
3180
|
...prev,
|
|
3181
|
-
[columnId]:
|
|
3181
|
+
[columnId]: error
|
|
3182
3182
|
}));
|
|
3183
3183
|
}
|
|
3184
3184
|
};
|
|
3185
3185
|
const type = editingIndex !== null ? "edit" : "add";
|
|
3186
|
-
const result = await onChange(
|
|
3186
|
+
const result = await onChange({
|
|
3187
|
+
entryData,
|
|
3188
|
+
actions,
|
|
3189
|
+
actionType: type,
|
|
3190
|
+
fullData: newData
|
|
3191
|
+
});
|
|
3187
3192
|
if (result === false) {
|
|
3188
3193
|
setIsSavingAsync(false);
|
|
3189
3194
|
return;
|
|
@@ -3229,14 +3234,19 @@ function PostTable({
|
|
|
3229
3234
|
}
|
|
3230
3235
|
}
|
|
3231
3236
|
},
|
|
3232
|
-
setError: (columnId,
|
|
3237
|
+
setError: (columnId, error) => {
|
|
3233
3238
|
setFieldErrors((prev) => ({
|
|
3234
3239
|
...prev,
|
|
3235
|
-
[columnId]:
|
|
3240
|
+
[columnId]: error
|
|
3236
3241
|
}));
|
|
3237
3242
|
}
|
|
3238
3243
|
};
|
|
3239
|
-
onChange?.(
|
|
3244
|
+
onChange?.({
|
|
3245
|
+
entryData: data[index2],
|
|
3246
|
+
actions,
|
|
3247
|
+
actionType: "delete",
|
|
3248
|
+
fullData: newData
|
|
3249
|
+
});
|
|
3240
3250
|
if (editingIndex === index2) {
|
|
3241
3251
|
handleCancelEdit();
|
|
3242
3252
|
} else if (editingIndex !== null && editingIndex > index2) {
|
|
@@ -3463,7 +3473,8 @@ function PostTable({
|
|
|
3463
3473
|
const fieldRenderer = column.columnDef.meta?.field;
|
|
3464
3474
|
const accessor = column.columnDef.accessorKey || column.id;
|
|
3465
3475
|
const value = entryData[accessor] || "";
|
|
3466
|
-
const
|
|
3476
|
+
const error = fieldErrors[accessor];
|
|
3477
|
+
const hasError = !!error;
|
|
3467
3478
|
const onChangeValue = (val) => {
|
|
3468
3479
|
setEntryData((prev) => ({
|
|
3469
3480
|
...prev,
|
|
@@ -3497,12 +3508,12 @@ function PostTable({
|
|
|
3497
3508
|
column.id === "_index" ? "w-px whitespace-nowrap" : "",
|
|
3498
3509
|
hasError && "ring-1 ring-inset ring-red-500"
|
|
3499
3510
|
),
|
|
3500
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime23.
|
|
3511
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
3501
3512
|
"div",
|
|
3502
3513
|
{
|
|
3503
3514
|
className: cn(
|
|
3504
|
-
"flex items-center",
|
|
3505
|
-
column.id === "_index" ? "" : "
|
|
3515
|
+
"flex items-center relative group w-full",
|
|
3516
|
+
column.id === "_index" ? "" : "min-w-32 h-9"
|
|
3506
3517
|
),
|
|
3507
3518
|
onKeyDown: (e) => {
|
|
3508
3519
|
if (e.key === "Enter") {
|
|
@@ -3510,23 +3521,26 @@ function PostTable({
|
|
|
3510
3521
|
handleSaveField();
|
|
3511
3522
|
}
|
|
3512
3523
|
},
|
|
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",
|
|
3524
|
+
children: [
|
|
3525
|
+
fieldRenderer ? fieldRenderer({
|
|
3524
3526
|
value,
|
|
3525
|
-
onChange:
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
}
|
|
3529
|
-
|
|
3527
|
+
onChange: onChangeValue,
|
|
3528
|
+
rowData: entryData,
|
|
3529
|
+
setRowData: setEntryData
|
|
3530
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3531
|
+
Fields_default.Input,
|
|
3532
|
+
{
|
|
3533
|
+
id: `pti-${accessor}`,
|
|
3534
|
+
label: "",
|
|
3535
|
+
variant: "ghost",
|
|
3536
|
+
value,
|
|
3537
|
+
onChange: (e) => onChangeValue(e.target.value),
|
|
3538
|
+
className: "px-0! bg-transparent!",
|
|
3539
|
+
placeholder: `${typeof column.columnDef.header === "string" ? column.columnDef.header : column.id}`
|
|
3540
|
+
}
|
|
3541
|
+
),
|
|
3542
|
+
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 })
|
|
3543
|
+
]
|
|
3530
3544
|
}
|
|
3531
3545
|
)
|
|
3532
3546
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -3133,15 +3133,20 @@ function PostTable({
|
|
|
3133
3133
|
}
|
|
3134
3134
|
}
|
|
3135
3135
|
},
|
|
3136
|
-
setError: (columnId,
|
|
3136
|
+
setError: (columnId, error) => {
|
|
3137
3137
|
setFieldErrors((prev) => ({
|
|
3138
3138
|
...prev,
|
|
3139
|
-
[columnId]:
|
|
3139
|
+
[columnId]: error
|
|
3140
3140
|
}));
|
|
3141
3141
|
}
|
|
3142
3142
|
};
|
|
3143
3143
|
const type = editingIndex !== null ? "edit" : "add";
|
|
3144
|
-
const result = await onChange(
|
|
3144
|
+
const result = await onChange({
|
|
3145
|
+
entryData,
|
|
3146
|
+
actions,
|
|
3147
|
+
actionType: type,
|
|
3148
|
+
fullData: newData
|
|
3149
|
+
});
|
|
3145
3150
|
if (result === false) {
|
|
3146
3151
|
setIsSavingAsync(false);
|
|
3147
3152
|
return;
|
|
@@ -3187,14 +3192,19 @@ function PostTable({
|
|
|
3187
3192
|
}
|
|
3188
3193
|
}
|
|
3189
3194
|
},
|
|
3190
|
-
setError: (columnId,
|
|
3195
|
+
setError: (columnId, error) => {
|
|
3191
3196
|
setFieldErrors((prev) => ({
|
|
3192
3197
|
...prev,
|
|
3193
|
-
[columnId]:
|
|
3198
|
+
[columnId]: error
|
|
3194
3199
|
}));
|
|
3195
3200
|
}
|
|
3196
3201
|
};
|
|
3197
|
-
onChange?.(
|
|
3202
|
+
onChange?.({
|
|
3203
|
+
entryData: data[index2],
|
|
3204
|
+
actions,
|
|
3205
|
+
actionType: "delete",
|
|
3206
|
+
fullData: newData
|
|
3207
|
+
});
|
|
3198
3208
|
if (editingIndex === index2) {
|
|
3199
3209
|
handleCancelEdit();
|
|
3200
3210
|
} else if (editingIndex !== null && editingIndex > index2) {
|
|
@@ -3421,7 +3431,8 @@ function PostTable({
|
|
|
3421
3431
|
const fieldRenderer = column.columnDef.meta?.field;
|
|
3422
3432
|
const accessor = column.columnDef.accessorKey || column.id;
|
|
3423
3433
|
const value = entryData[accessor] || "";
|
|
3424
|
-
const
|
|
3434
|
+
const error = fieldErrors[accessor];
|
|
3435
|
+
const hasError = !!error;
|
|
3425
3436
|
const onChangeValue = (val) => {
|
|
3426
3437
|
setEntryData((prev) => ({
|
|
3427
3438
|
...prev,
|
|
@@ -3455,12 +3466,12 @@ function PostTable({
|
|
|
3455
3466
|
column.id === "_index" ? "w-px whitespace-nowrap" : "",
|
|
3456
3467
|
hasError && "ring-1 ring-inset ring-red-500"
|
|
3457
3468
|
),
|
|
3458
|
-
children: /* @__PURE__ */
|
|
3469
|
+
children: /* @__PURE__ */ jsxs18(
|
|
3459
3470
|
"div",
|
|
3460
3471
|
{
|
|
3461
3472
|
className: cn(
|
|
3462
|
-
"flex items-center",
|
|
3463
|
-
column.id === "_index" ? "" : "
|
|
3473
|
+
"flex items-center relative group w-full",
|
|
3474
|
+
column.id === "_index" ? "" : "min-w-32 h-9"
|
|
3464
3475
|
),
|
|
3465
3476
|
onKeyDown: (e) => {
|
|
3466
3477
|
if (e.key === "Enter") {
|
|
@@ -3468,23 +3479,26 @@ function PostTable({
|
|
|
3468
3479
|
handleSaveField();
|
|
3469
3480
|
}
|
|
3470
3481
|
},
|
|
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",
|
|
3482
|
+
children: [
|
|
3483
|
+
fieldRenderer ? fieldRenderer({
|
|
3482
3484
|
value,
|
|
3483
|
-
onChange:
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
}
|
|
3487
|
-
|
|
3485
|
+
onChange: onChangeValue,
|
|
3486
|
+
rowData: entryData,
|
|
3487
|
+
setRowData: setEntryData
|
|
3488
|
+
}) : /* @__PURE__ */ jsx23(
|
|
3489
|
+
Fields_default.Input,
|
|
3490
|
+
{
|
|
3491
|
+
id: `pti-${accessor}`,
|
|
3492
|
+
label: "",
|
|
3493
|
+
variant: "ghost",
|
|
3494
|
+
value,
|
|
3495
|
+
onChange: (e) => onChangeValue(e.target.value),
|
|
3496
|
+
className: "px-0! bg-transparent!",
|
|
3497
|
+
placeholder: `${typeof column.columnDef.header === "string" ? column.columnDef.header : column.id}`
|
|
3498
|
+
}
|
|
3499
|
+
),
|
|
3500
|
+
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 })
|
|
3501
|
+
]
|
|
3488
3502
|
}
|
|
3489
3503
|
)
|
|
3490
3504
|
},
|