warqadui 0.0.31 → 0.0.32
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +202 -120
- package/dist/index.mjs +239 -143
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -351,7 +351,7 @@ interface PhoneInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElemen
|
|
|
351
351
|
}
|
|
352
352
|
declare const PhoneInput: React$1.ForwardRefExoticComponent<PhoneInputProps & React$1.RefAttributes<any>>;
|
|
353
353
|
|
|
354
|
-
interface InputProps<T extends FieldValues> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "name" | "form"> {
|
|
354
|
+
interface InputProps<T extends FieldValues> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "name" | "form" | "onChange"> {
|
|
355
355
|
label?: string;
|
|
356
356
|
icon?: React.ReactNode;
|
|
357
357
|
error?: string;
|
|
@@ -360,6 +360,7 @@ interface InputProps<T extends FieldValues> extends Omit<React.InputHTMLAttribut
|
|
|
360
360
|
form?: UseFormReturn<T>;
|
|
361
361
|
type?: "text" | "number" | "email" | "password";
|
|
362
362
|
variant?: "ghost" | "default";
|
|
363
|
+
onChange?: (value: any) => void;
|
|
363
364
|
}
|
|
364
365
|
declare const Input: <T extends FieldValues>(props: InputProps<T> & {
|
|
365
366
|
ref?: React.ForwardedRef<HTMLInputElement>;
|
package/dist/index.d.ts
CHANGED
|
@@ -351,7 +351,7 @@ interface PhoneInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElemen
|
|
|
351
351
|
}
|
|
352
352
|
declare const PhoneInput: React$1.ForwardRefExoticComponent<PhoneInputProps & React$1.RefAttributes<any>>;
|
|
353
353
|
|
|
354
|
-
interface InputProps<T extends FieldValues> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "name" | "form"> {
|
|
354
|
+
interface InputProps<T extends FieldValues> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "name" | "form" | "onChange"> {
|
|
355
355
|
label?: string;
|
|
356
356
|
icon?: React.ReactNode;
|
|
357
357
|
error?: string;
|
|
@@ -360,6 +360,7 @@ interface InputProps<T extends FieldValues> extends Omit<React.InputHTMLAttribut
|
|
|
360
360
|
form?: UseFormReturn<T>;
|
|
361
361
|
type?: "text" | "number" | "email" | "password";
|
|
362
362
|
variant?: "ghost" | "default";
|
|
363
|
+
onChange?: (value: any) => void;
|
|
363
364
|
}
|
|
364
365
|
declare const Input: <T extends FieldValues>(props: InputProps<T> & {
|
|
365
366
|
ref?: React.ForwardedRef<HTMLInputElement>;
|
package/dist/index.js
CHANGED
|
@@ -1157,6 +1157,14 @@ var Input = (0, import_react8.forwardRef)(
|
|
|
1157
1157
|
const [showPassword, setShowPassword] = (0, import_react8.useState)(false);
|
|
1158
1158
|
const { theme } = useWarqadConfig();
|
|
1159
1159
|
const primaryColor = theme?.primaryColor;
|
|
1160
|
+
(0, import_react8.useEffect)(() => {
|
|
1161
|
+
if (form && name && props.value !== void 0 && props.value !== null && props.value !== "") {
|
|
1162
|
+
const currentFormValue = form.getValues(name);
|
|
1163
|
+
if (currentFormValue === void 0 || currentFormValue === "" || currentFormValue === 0) {
|
|
1164
|
+
form.setValue(name, props.value);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
}, [props.value, name, form]);
|
|
1160
1168
|
let message = error;
|
|
1161
1169
|
if (form && name) {
|
|
1162
1170
|
const {
|
|
@@ -1239,39 +1247,62 @@ var Input = (0, import_react8.forwardRef)(
|
|
|
1239
1247
|
{
|
|
1240
1248
|
control: form.control,
|
|
1241
1249
|
name,
|
|
1242
|
-
render: ({ field: { onChange, value, ref: fieldRef, onBlur: onBlur2 } }) =>
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
(
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
if (
|
|
1259
|
-
onChange(
|
|
1250
|
+
render: ({ field: { onChange, value, ref: fieldRef, onBlur: onBlur2 } }) => {
|
|
1251
|
+
const hasValue = value !== void 0 && value !== null && value !== "";
|
|
1252
|
+
const hasPropsValue = props.value !== void 0 && props.value !== null && props.value !== "";
|
|
1253
|
+
const displayValue = hasValue ? value : hasPropsValue ? props.value : "";
|
|
1254
|
+
return renderInput(
|
|
1255
|
+
{
|
|
1256
|
+
ref: fieldRef,
|
|
1257
|
+
onBlur: () => {
|
|
1258
|
+
onBlur2();
|
|
1259
|
+
},
|
|
1260
|
+
value: displayValue !== "" ? String(displayValue).split(".").map(
|
|
1261
|
+
(part, index) => index === 0 ? part.replace(/\B(?=(\d{3})+(?!\d))/g, ",") : part
|
|
1262
|
+
).join(".") : "",
|
|
1263
|
+
onChange: (e) => {
|
|
1264
|
+
const rawValue = e.target.value.replace(/,/g, "");
|
|
1265
|
+
if (!/^\d*\.?\d*$/.test(rawValue)) return;
|
|
1266
|
+
if (rawValue === "") {
|
|
1267
|
+
onChange("");
|
|
1268
|
+
props.onChange?.("");
|
|
1260
1269
|
} else {
|
|
1261
|
-
|
|
1270
|
+
const numValue = Number(rawValue);
|
|
1271
|
+
if (!isNaN(numValue) && String(numValue) === rawValue) {
|
|
1272
|
+
onChange(numValue);
|
|
1273
|
+
props.onChange?.(numValue);
|
|
1274
|
+
} else {
|
|
1275
|
+
onChange(rawValue);
|
|
1276
|
+
props.onChange?.(rawValue);
|
|
1277
|
+
}
|
|
1262
1278
|
}
|
|
1263
1279
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
)
|
|
1280
|
+
},
|
|
1281
|
+
"text"
|
|
1282
|
+
);
|
|
1283
|
+
}
|
|
1269
1284
|
}
|
|
1270
1285
|
);
|
|
1271
1286
|
}
|
|
1272
|
-
let inputPropsObj =
|
|
1287
|
+
let inputPropsObj = {};
|
|
1288
|
+
const originalOnChange = props.onChange;
|
|
1289
|
+
if (form && name) {
|
|
1290
|
+
const registeredProps = form.register(
|
|
1291
|
+
name,
|
|
1292
|
+
type === "number" ? { valueAsNumber: true } : {}
|
|
1293
|
+
);
|
|
1294
|
+
inputPropsObj = {
|
|
1295
|
+
...registeredProps,
|
|
1296
|
+
onChange: (e) => {
|
|
1297
|
+
registeredProps.onChange(e);
|
|
1298
|
+
const rawValue = e.target.value.replace(/,/g, "");
|
|
1299
|
+
originalOnChange?.(
|
|
1300
|
+
type === "number" ? rawValue === "" ? "" : Number(rawValue) : e.target.value
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1273
1305
|
if (type === "number" && (!form || !name)) {
|
|
1274
|
-
const originalOnChange = props.onChange;
|
|
1275
1306
|
inputPropsObj = {
|
|
1276
1307
|
...inputPropsObj,
|
|
1277
1308
|
value: props.value !== void 0 && props.value !== null ? String(props.value).split(".").map(
|
|
@@ -1281,20 +1312,20 @@ var Input = (0, import_react8.forwardRef)(
|
|
|
1281
1312
|
const rawValue = e.target.value.replace(/,/g, "");
|
|
1282
1313
|
if (!/^\d*\.?\d*$/.test(rawValue)) return;
|
|
1283
1314
|
if (originalOnChange) {
|
|
1284
|
-
|
|
1285
|
-
...e,
|
|
1286
|
-
target: {
|
|
1287
|
-
...e.target,
|
|
1288
|
-
value: rawValue,
|
|
1289
|
-
valueAsNumber: rawValue === "" ? NaN : Number(rawValue)
|
|
1290
|
-
}
|
|
1291
|
-
};
|
|
1292
|
-
originalOnChange(fakeEvent);
|
|
1315
|
+
originalOnChange(rawValue === "" ? "" : Number(rawValue));
|
|
1293
1316
|
}
|
|
1294
1317
|
}
|
|
1295
1318
|
};
|
|
1296
1319
|
return renderInput(inputPropsObj, "text");
|
|
1297
1320
|
}
|
|
1321
|
+
if (!form || !name) {
|
|
1322
|
+
inputPropsObj = {
|
|
1323
|
+
...inputPropsObj,
|
|
1324
|
+
onChange: (e) => {
|
|
1325
|
+
originalOnChange?.(e.target.value);
|
|
1326
|
+
}
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1298
1329
|
return renderInput(inputPropsObj, type === "number" ? "text" : type);
|
|
1299
1330
|
}
|
|
1300
1331
|
);
|
|
@@ -1412,6 +1443,14 @@ var useSelectContext = () => {
|
|
|
1412
1443
|
};
|
|
1413
1444
|
var Select = (0, import_react10.forwardRef)((props, ref) => {
|
|
1414
1445
|
const { form, name, onChange, value, children, options = [] } = props;
|
|
1446
|
+
(0, import_react10.useEffect)(() => {
|
|
1447
|
+
if (form && name && value !== void 0 && value !== null && value !== "") {
|
|
1448
|
+
const currentFormValue = form.getValues(name);
|
|
1449
|
+
if (currentFormValue === void 0 || currentFormValue === "" || currentFormValue === 0) {
|
|
1450
|
+
form.setValue(name, value);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}, [value, name, form]);
|
|
1415
1454
|
if (form && name) {
|
|
1416
1455
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1417
1456
|
import_react_hook_form3.Controller,
|
|
@@ -1866,30 +1905,47 @@ var Textarea = (0, import_react11.forwardRef)(
|
|
|
1866
1905
|
) }),
|
|
1867
1906
|
message && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message })
|
|
1868
1907
|
] });
|
|
1908
|
+
(0, import_react11.useEffect)(() => {
|
|
1909
|
+
if (form && name && props.value !== void 0 && props.value !== null && props.value !== "") {
|
|
1910
|
+
const currentFormValue = form.getValues(name);
|
|
1911
|
+
if (currentFormValue === void 0 || currentFormValue === "" || currentFormValue === 0) {
|
|
1912
|
+
form.setValue(name, props.value);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
}, [props.value, name, form]);
|
|
1869
1916
|
if (form && name) {
|
|
1870
1917
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1871
1918
|
import_react_hook_form4.Controller,
|
|
1872
1919
|
{
|
|
1873
1920
|
control: form.control,
|
|
1874
1921
|
name,
|
|
1875
|
-
render: ({ field: { onChange, value, ref: fieldRef, onBlur: onBlur2 } }) =>
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
onChange(e)
|
|
1881
|
-
|
|
1922
|
+
render: ({ field: { onChange, value, ref: fieldRef, onBlur: onBlur2 } }) => {
|
|
1923
|
+
const displayValue = value !== void 0 && value !== null && value !== "" ? value : props.value;
|
|
1924
|
+
return renderInput(
|
|
1925
|
+
{
|
|
1926
|
+
value: displayValue || "",
|
|
1927
|
+
onChange: (e) => {
|
|
1928
|
+
onChange(e);
|
|
1929
|
+
props.onChange?.(e);
|
|
1930
|
+
},
|
|
1931
|
+
onBlur: () => {
|
|
1932
|
+
onBlur2();
|
|
1933
|
+
}
|
|
1882
1934
|
},
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
},
|
|
1887
|
-
fieldRef
|
|
1888
|
-
)
|
|
1935
|
+
fieldRef
|
|
1936
|
+
);
|
|
1937
|
+
}
|
|
1889
1938
|
}
|
|
1890
1939
|
);
|
|
1891
1940
|
}
|
|
1892
|
-
return renderInput(
|
|
1941
|
+
return renderInput(
|
|
1942
|
+
{
|
|
1943
|
+
onChange: (e) => {
|
|
1944
|
+
props.onChange?.(e);
|
|
1945
|
+
}
|
|
1946
|
+
},
|
|
1947
|
+
ref
|
|
1948
|
+
);
|
|
1893
1949
|
}
|
|
1894
1950
|
);
|
|
1895
1951
|
|
|
@@ -2081,6 +2137,14 @@ var useSearchApiContext = () => {
|
|
|
2081
2137
|
var SearchApi = (0, import_react13.forwardRef)(
|
|
2082
2138
|
(props, _) => {
|
|
2083
2139
|
const { form, name, onChange, onSelect, onClear, value, children, ...restProps } = props;
|
|
2140
|
+
(0, import_react13.useEffect)(() => {
|
|
2141
|
+
if (form && name && value !== void 0 && value !== null && value !== "") {
|
|
2142
|
+
const currentFormValue = form.getValues(name);
|
|
2143
|
+
if (currentFormValue === void 0 || currentFormValue === "" || currentFormValue === 0) {
|
|
2144
|
+
form.setValue(name, value);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
}, [value, name, form]);
|
|
2084
2148
|
if (form && name) {
|
|
2085
2149
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2086
2150
|
import_react_hook_form5.Controller,
|
|
@@ -2209,12 +2273,12 @@ var SearchApiRoot = ({
|
|
|
2209
2273
|
}
|
|
2210
2274
|
}, [isOpen]);
|
|
2211
2275
|
(0, import_react13.useEffect)(() => {
|
|
2212
|
-
if (currentValue && !selectedObject) {
|
|
2276
|
+
if (currentValue !== void 0 && currentValue !== null && currentValue !== "" && !selectedObject) {
|
|
2213
2277
|
setHasAttemptedHydration(false);
|
|
2214
2278
|
fetchOptions(currentValue).finally(() => {
|
|
2215
2279
|
setHasAttemptedHydration(true);
|
|
2216
2280
|
});
|
|
2217
|
-
} else if (
|
|
2281
|
+
} else if (currentValue === void 0 || currentValue === null || currentValue === "") {
|
|
2218
2282
|
setHasAttemptedHydration(true);
|
|
2219
2283
|
if (selectedObject) setSelectedObject(void 0);
|
|
2220
2284
|
}
|
|
@@ -2226,7 +2290,7 @@ var SearchApiRoot = ({
|
|
|
2226
2290
|
return option[valueKey];
|
|
2227
2291
|
};
|
|
2228
2292
|
(0, import_react13.useEffect)(() => {
|
|
2229
|
-
if (currentValue && !selectedObject && options.length > 0) {
|
|
2293
|
+
if (currentValue !== void 0 && currentValue !== null && currentValue !== "" && !selectedObject && options.length > 0) {
|
|
2230
2294
|
const found = options.find((o) => getOptionValue(o) === currentValue);
|
|
2231
2295
|
if (found) {
|
|
2232
2296
|
setSelectedObject(found);
|
|
@@ -2279,13 +2343,13 @@ var SearchApiRoot = ({
|
|
|
2279
2343
|
}, [fieldInternalProps]);
|
|
2280
2344
|
const getDisplayValue = () => {
|
|
2281
2345
|
if (selectedObject) return selectedObject[labelKey];
|
|
2282
|
-
if (options.length > 0 && currentValue) {
|
|
2346
|
+
if (options.length > 0 && (currentValue !== void 0 && currentValue !== null && currentValue !== "")) {
|
|
2283
2347
|
const found = options.find((o) => getOptionValue(o) === currentValue);
|
|
2284
2348
|
if (found) return found[labelKey];
|
|
2285
2349
|
}
|
|
2286
|
-
if (isLoading || currentValue && !hasAttemptedHydration)
|
|
2350
|
+
if (isLoading || currentValue !== void 0 && currentValue !== null && currentValue !== "" && !hasAttemptedHydration)
|
|
2287
2351
|
return "Loading...";
|
|
2288
|
-
return currentValue
|
|
2352
|
+
return currentValue !== void 0 && currentValue !== null && currentValue !== "" ? currentValue : "";
|
|
2289
2353
|
};
|
|
2290
2354
|
const handleSelect = (option) => {
|
|
2291
2355
|
const val = getOptionValue(option);
|
|
@@ -2540,7 +2604,7 @@ var SearchApiInput = (0, import_react13.forwardRef)(
|
|
|
2540
2604
|
}
|
|
2541
2605
|
};
|
|
2542
2606
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2543
|
-
!isOpen && selectedValue && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "absolute inset-0 flex items-center ms-1 truncate select-none", children: getDisplayValue() }),
|
|
2607
|
+
!isOpen && (selectedValue !== void 0 && selectedValue !== null && selectedValue !== "") && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "absolute inset-0 flex items-center ms-1 truncate select-none", children: getDisplayValue() }),
|
|
2544
2608
|
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2545
2609
|
"input",
|
|
2546
2610
|
{
|
|
@@ -3386,72 +3450,78 @@ function PostTable({
|
|
|
3386
3450
|
setEditingIndex(index2);
|
|
3387
3451
|
setEntryData(rowOriginal);
|
|
3388
3452
|
}, []);
|
|
3389
|
-
const handleDelete = (0, import_react16.useCallback)(
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
if (td) {
|
|
3400
|
-
const input = td.querySelector(
|
|
3401
|
-
`input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex='0'], [id*='${columnId}']`
|
|
3453
|
+
const handleDelete = (0, import_react16.useCallback)(
|
|
3454
|
+
(index2) => {
|
|
3455
|
+
const { data: data2, editingIndex: editingIndex2, onChange: onChange2 } = latestStateRef.current;
|
|
3456
|
+
const newData = data2.filter((_, i) => i !== index2);
|
|
3457
|
+
setData(newData);
|
|
3458
|
+
const actions = {
|
|
3459
|
+
focus: (columnId) => {
|
|
3460
|
+
if (entryRowRef.current) {
|
|
3461
|
+
const td = entryRowRef.current.querySelector(
|
|
3462
|
+
`td[data-column-id="${columnId}"]`
|
|
3402
3463
|
);
|
|
3403
|
-
if (
|
|
3464
|
+
if (td) {
|
|
3465
|
+
const input = td.querySelector(
|
|
3466
|
+
`input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex='0'], [id*='${columnId}']`
|
|
3467
|
+
);
|
|
3468
|
+
if (input) input.focus();
|
|
3469
|
+
}
|
|
3404
3470
|
}
|
|
3471
|
+
},
|
|
3472
|
+
setError: (columnId, error) => {
|
|
3473
|
+
setFieldErrors((prev) => ({
|
|
3474
|
+
...prev,
|
|
3475
|
+
[columnId]: error
|
|
3476
|
+
}));
|
|
3405
3477
|
}
|
|
3406
|
-
}
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3478
|
+
};
|
|
3479
|
+
onChange2?.({
|
|
3480
|
+
entryData: data2[index2],
|
|
3481
|
+
actions,
|
|
3482
|
+
actionType: "delete",
|
|
3483
|
+
fullData: newData
|
|
3484
|
+
});
|
|
3485
|
+
if (editingIndex2 === index2) {
|
|
3486
|
+
handleCancelEdit();
|
|
3487
|
+
} else if (editingIndex2 !== null && editingIndex2 > index2) {
|
|
3488
|
+
setEditingIndex(editingIndex2 - 1);
|
|
3412
3489
|
}
|
|
3413
|
-
}
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
title: "Delete",
|
|
3449
|
-
children: submitLoading2 || isSavingAsync2 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.Loader2, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.Trash2, { size: 16 })
|
|
3450
|
-
}
|
|
3451
|
-
)
|
|
3452
|
-
] });
|
|
3453
|
-
}
|
|
3454
|
-
}), []);
|
|
3490
|
+
},
|
|
3491
|
+
[handleCancelEdit]
|
|
3492
|
+
);
|
|
3493
|
+
const actionColumn = (0, import_react16.useMemo)(
|
|
3494
|
+
() => ({
|
|
3495
|
+
id: "actions",
|
|
3496
|
+
header: "Actions",
|
|
3497
|
+
cell: ({ row, table: table2 }) => {
|
|
3498
|
+
const { handleEdit: handleEdit2, handleDelete: handleDelete2, submitLoading: submitLoading2, isSavingAsync: isSavingAsync2 } = table2.options.meta;
|
|
3499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3500
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3501
|
+
"button",
|
|
3502
|
+
{
|
|
3503
|
+
onClick: () => handleEdit2(row.index, row.original),
|
|
3504
|
+
disabled: submitLoading2 || isSavingAsync2,
|
|
3505
|
+
className: "p-1 px-2 rounded-md hover:bg-gray-100 dark:hover:bg-zinc-800 text-gray-500 hover:text-(--theme-primary) dark:hover:text-(--theme-primary) transition-colors disabled:opacity-50",
|
|
3506
|
+
title: "Edit",
|
|
3507
|
+
children: submitLoading2 || isSavingAsync2 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.Loader2, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.Edit2, { size: 16 })
|
|
3508
|
+
}
|
|
3509
|
+
),
|
|
3510
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3511
|
+
"button",
|
|
3512
|
+
{
|
|
3513
|
+
onClick: () => handleDelete2(row.index),
|
|
3514
|
+
disabled: submitLoading2 || isSavingAsync2,
|
|
3515
|
+
className: "p-1 px-2 rounded-md hover:bg-gray-100 dark:hover:bg-zinc-800 text-gray-500 hover:text-red-600 dark:hover:text-red-400 transition-colors disabled:opacity-50",
|
|
3516
|
+
title: "Delete",
|
|
3517
|
+
children: submitLoading2 || isSavingAsync2 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.Loader2, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.Trash2, { size: 16 })
|
|
3518
|
+
}
|
|
3519
|
+
)
|
|
3520
|
+
] });
|
|
3521
|
+
}
|
|
3522
|
+
}),
|
|
3523
|
+
[]
|
|
3524
|
+
);
|
|
3455
3525
|
const columns = (0, import_react16.useMemo)(() => {
|
|
3456
3526
|
const mappedUserColumns = userColumns.map((col) => ({
|
|
3457
3527
|
...col,
|
|
@@ -3610,7 +3680,13 @@ function PostTable({
|
|
|
3610
3680
|
disabled: isSavingAsync || submitLoading,
|
|
3611
3681
|
className: "flex-1 h-8 flex items-center justify-center rounded-lg bg-green-500/10 text-green-600 dark:bg-emerald-500/20 dark:text-emerald-400 hover:bg-green-500 hover:text-white dark:hover:bg-emerald-500 transition-colors shadow-sm active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
3612
3682
|
title: "Update",
|
|
3613
|
-
children: isSavingAsync || submitLoading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3683
|
+
children: isSavingAsync || submitLoading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3684
|
+
import_lucide_react11.Loader2,
|
|
3685
|
+
{
|
|
3686
|
+
size: 16,
|
|
3687
|
+
className: "animate-spin"
|
|
3688
|
+
}
|
|
3689
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.Check, { size: 16, strokeWidth: 2.5 })
|
|
3614
3690
|
}
|
|
3615
3691
|
),
|
|
3616
3692
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
@@ -3638,7 +3714,13 @@ function PostTable({
|
|
|
3638
3714
|
},
|
|
3639
3715
|
title: "Add Row",
|
|
3640
3716
|
children: [
|
|
3641
|
-
isSavingAsync || submitLoading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3717
|
+
isSavingAsync || submitLoading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3718
|
+
import_lucide_react11.Loader2,
|
|
3719
|
+
{
|
|
3720
|
+
size: 14,
|
|
3721
|
+
className: "animate-spin"
|
|
3722
|
+
}
|
|
3723
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.Plus, { size: 14, strokeWidth: 2.5 }),
|
|
3642
3724
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: isSavingAsync || submitLoading ? "Adding..." : "Add" })
|
|
3643
3725
|
]
|
|
3644
3726
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1079,6 +1079,14 @@ var Input = forwardRef(
|
|
|
1079
1079
|
const [showPassword, setShowPassword] = useState7(false);
|
|
1080
1080
|
const { theme } = useWarqadConfig();
|
|
1081
1081
|
const primaryColor = theme?.primaryColor;
|
|
1082
|
+
useEffect5(() => {
|
|
1083
|
+
if (form && name && props.value !== void 0 && props.value !== null && props.value !== "") {
|
|
1084
|
+
const currentFormValue = form.getValues(name);
|
|
1085
|
+
if (currentFormValue === void 0 || currentFormValue === "" || currentFormValue === 0) {
|
|
1086
|
+
form.setValue(name, props.value);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
}, [props.value, name, form]);
|
|
1082
1090
|
let message = error;
|
|
1083
1091
|
if (form && name) {
|
|
1084
1092
|
const {
|
|
@@ -1161,39 +1169,62 @@ var Input = forwardRef(
|
|
|
1161
1169
|
{
|
|
1162
1170
|
control: form.control,
|
|
1163
1171
|
name,
|
|
1164
|
-
render: ({ field: { onChange, value, ref: fieldRef, onBlur: onBlur2 } }) =>
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
(
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
if (
|
|
1181
|
-
onChange(
|
|
1172
|
+
render: ({ field: { onChange, value, ref: fieldRef, onBlur: onBlur2 } }) => {
|
|
1173
|
+
const hasValue = value !== void 0 && value !== null && value !== "";
|
|
1174
|
+
const hasPropsValue = props.value !== void 0 && props.value !== null && props.value !== "";
|
|
1175
|
+
const displayValue = hasValue ? value : hasPropsValue ? props.value : "";
|
|
1176
|
+
return renderInput(
|
|
1177
|
+
{
|
|
1178
|
+
ref: fieldRef,
|
|
1179
|
+
onBlur: () => {
|
|
1180
|
+
onBlur2();
|
|
1181
|
+
},
|
|
1182
|
+
value: displayValue !== "" ? String(displayValue).split(".").map(
|
|
1183
|
+
(part, index) => index === 0 ? part.replace(/\B(?=(\d{3})+(?!\d))/g, ",") : part
|
|
1184
|
+
).join(".") : "",
|
|
1185
|
+
onChange: (e) => {
|
|
1186
|
+
const rawValue = e.target.value.replace(/,/g, "");
|
|
1187
|
+
if (!/^\d*\.?\d*$/.test(rawValue)) return;
|
|
1188
|
+
if (rawValue === "") {
|
|
1189
|
+
onChange("");
|
|
1190
|
+
props.onChange?.("");
|
|
1182
1191
|
} else {
|
|
1183
|
-
|
|
1192
|
+
const numValue = Number(rawValue);
|
|
1193
|
+
if (!isNaN(numValue) && String(numValue) === rawValue) {
|
|
1194
|
+
onChange(numValue);
|
|
1195
|
+
props.onChange?.(numValue);
|
|
1196
|
+
} else {
|
|
1197
|
+
onChange(rawValue);
|
|
1198
|
+
props.onChange?.(rawValue);
|
|
1199
|
+
}
|
|
1184
1200
|
}
|
|
1185
1201
|
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
)
|
|
1202
|
+
},
|
|
1203
|
+
"text"
|
|
1204
|
+
);
|
|
1205
|
+
}
|
|
1191
1206
|
}
|
|
1192
1207
|
);
|
|
1193
1208
|
}
|
|
1194
|
-
let inputPropsObj =
|
|
1209
|
+
let inputPropsObj = {};
|
|
1210
|
+
const originalOnChange = props.onChange;
|
|
1211
|
+
if (form && name) {
|
|
1212
|
+
const registeredProps = form.register(
|
|
1213
|
+
name,
|
|
1214
|
+
type === "number" ? { valueAsNumber: true } : {}
|
|
1215
|
+
);
|
|
1216
|
+
inputPropsObj = {
|
|
1217
|
+
...registeredProps,
|
|
1218
|
+
onChange: (e) => {
|
|
1219
|
+
registeredProps.onChange(e);
|
|
1220
|
+
const rawValue = e.target.value.replace(/,/g, "");
|
|
1221
|
+
originalOnChange?.(
|
|
1222
|
+
type === "number" ? rawValue === "" ? "" : Number(rawValue) : e.target.value
|
|
1223
|
+
);
|
|
1224
|
+
}
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1195
1227
|
if (type === "number" && (!form || !name)) {
|
|
1196
|
-
const originalOnChange = props.onChange;
|
|
1197
1228
|
inputPropsObj = {
|
|
1198
1229
|
...inputPropsObj,
|
|
1199
1230
|
value: props.value !== void 0 && props.value !== null ? String(props.value).split(".").map(
|
|
@@ -1203,20 +1234,20 @@ var Input = forwardRef(
|
|
|
1203
1234
|
const rawValue = e.target.value.replace(/,/g, "");
|
|
1204
1235
|
if (!/^\d*\.?\d*$/.test(rawValue)) return;
|
|
1205
1236
|
if (originalOnChange) {
|
|
1206
|
-
|
|
1207
|
-
...e,
|
|
1208
|
-
target: {
|
|
1209
|
-
...e.target,
|
|
1210
|
-
value: rawValue,
|
|
1211
|
-
valueAsNumber: rawValue === "" ? NaN : Number(rawValue)
|
|
1212
|
-
}
|
|
1213
|
-
};
|
|
1214
|
-
originalOnChange(fakeEvent);
|
|
1237
|
+
originalOnChange(rawValue === "" ? "" : Number(rawValue));
|
|
1215
1238
|
}
|
|
1216
1239
|
}
|
|
1217
1240
|
};
|
|
1218
1241
|
return renderInput(inputPropsObj, "text");
|
|
1219
1242
|
}
|
|
1243
|
+
if (!form || !name) {
|
|
1244
|
+
inputPropsObj = {
|
|
1245
|
+
...inputPropsObj,
|
|
1246
|
+
onChange: (e) => {
|
|
1247
|
+
originalOnChange?.(e.target.value);
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1220
1251
|
return renderInput(inputPropsObj, type === "number" ? "text" : type);
|
|
1221
1252
|
}
|
|
1222
1253
|
);
|
|
@@ -1343,6 +1374,14 @@ var useSelectContext = () => {
|
|
|
1343
1374
|
};
|
|
1344
1375
|
var Select = forwardRef3((props, ref) => {
|
|
1345
1376
|
const { form, name, onChange, value, children, options = [] } = props;
|
|
1377
|
+
useEffect6(() => {
|
|
1378
|
+
if (form && name && value !== void 0 && value !== null && value !== "") {
|
|
1379
|
+
const currentFormValue = form.getValues(name);
|
|
1380
|
+
if (currentFormValue === void 0 || currentFormValue === "" || currentFormValue === 0) {
|
|
1381
|
+
form.setValue(name, value);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
}, [value, name, form]);
|
|
1346
1385
|
if (form && name) {
|
|
1347
1386
|
return /* @__PURE__ */ jsx19(
|
|
1348
1387
|
Controller3,
|
|
@@ -1735,7 +1774,7 @@ var SelectItem = forwardRef3(
|
|
|
1735
1774
|
SelectItem.displayName = "SelectItem";
|
|
1736
1775
|
|
|
1737
1776
|
// src/components/Fields/textArea.tsx
|
|
1738
|
-
import { forwardRef as forwardRef4, useState as useState10 } from "react";
|
|
1777
|
+
import { forwardRef as forwardRef4, useEffect as useEffect7, useState as useState10 } from "react";
|
|
1739
1778
|
import {
|
|
1740
1779
|
Controller as Controller4
|
|
1741
1780
|
} from "react-hook-form";
|
|
@@ -1799,30 +1838,47 @@ var Textarea = forwardRef4(
|
|
|
1799
1838
|
) }),
|
|
1800
1839
|
message && /* @__PURE__ */ jsx20("p", { className: "text-sm text-red-600 dark:text-red-400", children: message })
|
|
1801
1840
|
] });
|
|
1841
|
+
useEffect7(() => {
|
|
1842
|
+
if (form && name && props.value !== void 0 && props.value !== null && props.value !== "") {
|
|
1843
|
+
const currentFormValue = form.getValues(name);
|
|
1844
|
+
if (currentFormValue === void 0 || currentFormValue === "" || currentFormValue === 0) {
|
|
1845
|
+
form.setValue(name, props.value);
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
}, [props.value, name, form]);
|
|
1802
1849
|
if (form && name) {
|
|
1803
1850
|
return /* @__PURE__ */ jsx20(
|
|
1804
1851
|
Controller4,
|
|
1805
1852
|
{
|
|
1806
1853
|
control: form.control,
|
|
1807
1854
|
name,
|
|
1808
|
-
render: ({ field: { onChange, value, ref: fieldRef, onBlur: onBlur2 } }) =>
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
onChange(e)
|
|
1814
|
-
|
|
1855
|
+
render: ({ field: { onChange, value, ref: fieldRef, onBlur: onBlur2 } }) => {
|
|
1856
|
+
const displayValue = value !== void 0 && value !== null && value !== "" ? value : props.value;
|
|
1857
|
+
return renderInput(
|
|
1858
|
+
{
|
|
1859
|
+
value: displayValue || "",
|
|
1860
|
+
onChange: (e) => {
|
|
1861
|
+
onChange(e);
|
|
1862
|
+
props.onChange?.(e);
|
|
1863
|
+
},
|
|
1864
|
+
onBlur: () => {
|
|
1865
|
+
onBlur2();
|
|
1866
|
+
}
|
|
1815
1867
|
},
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
},
|
|
1820
|
-
fieldRef
|
|
1821
|
-
)
|
|
1868
|
+
fieldRef
|
|
1869
|
+
);
|
|
1870
|
+
}
|
|
1822
1871
|
}
|
|
1823
1872
|
);
|
|
1824
1873
|
}
|
|
1825
|
-
return renderInput(
|
|
1874
|
+
return renderInput(
|
|
1875
|
+
{
|
|
1876
|
+
onChange: (e) => {
|
|
1877
|
+
props.onChange?.(e);
|
|
1878
|
+
}
|
|
1879
|
+
},
|
|
1880
|
+
ref
|
|
1881
|
+
);
|
|
1826
1882
|
}
|
|
1827
1883
|
);
|
|
1828
1884
|
|
|
@@ -1832,7 +1888,7 @@ import {
|
|
|
1832
1888
|
useContext as useContext4,
|
|
1833
1889
|
useState as useState12,
|
|
1834
1890
|
useRef as useRef4,
|
|
1835
|
-
useEffect as
|
|
1891
|
+
useEffect as useEffect8,
|
|
1836
1892
|
forwardRef as forwardRef5
|
|
1837
1893
|
} from "react";
|
|
1838
1894
|
import { createPortal as createPortal2 } from "react-dom";
|
|
@@ -2021,6 +2077,14 @@ var useSearchApiContext = () => {
|
|
|
2021
2077
|
var SearchApi = forwardRef5(
|
|
2022
2078
|
(props, _) => {
|
|
2023
2079
|
const { form, name, onChange, onSelect, onClear, value, children, ...restProps } = props;
|
|
2080
|
+
useEffect8(() => {
|
|
2081
|
+
if (form && name && value !== void 0 && value !== null && value !== "") {
|
|
2082
|
+
const currentFormValue = form.getValues(name);
|
|
2083
|
+
if (currentFormValue === void 0 || currentFormValue === "" || currentFormValue === 0) {
|
|
2084
|
+
form.setValue(name, value);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}, [value, name, form]);
|
|
2024
2088
|
if (form && name) {
|
|
2025
2089
|
return /* @__PURE__ */ jsx21(
|
|
2026
2090
|
Controller5,
|
|
@@ -2135,7 +2199,7 @@ var SearchApiRoot = ({
|
|
|
2135
2199
|
setOptions([]);
|
|
2136
2200
|
}
|
|
2137
2201
|
};
|
|
2138
|
-
|
|
2202
|
+
useEffect8(() => {
|
|
2139
2203
|
const timer = setTimeout(() => {
|
|
2140
2204
|
if (isOpen) {
|
|
2141
2205
|
fetchOptions(searchTerm);
|
|
@@ -2143,18 +2207,18 @@ var SearchApiRoot = ({
|
|
|
2143
2207
|
}, 300);
|
|
2144
2208
|
return () => clearTimeout(timer);
|
|
2145
2209
|
}, [searchTerm, api, isOpen]);
|
|
2146
|
-
|
|
2210
|
+
useEffect8(() => {
|
|
2147
2211
|
if (isOpen && options.length === 0) {
|
|
2148
2212
|
fetchOptions("");
|
|
2149
2213
|
}
|
|
2150
2214
|
}, [isOpen]);
|
|
2151
|
-
|
|
2152
|
-
if (currentValue && !selectedObject) {
|
|
2215
|
+
useEffect8(() => {
|
|
2216
|
+
if (currentValue !== void 0 && currentValue !== null && currentValue !== "" && !selectedObject) {
|
|
2153
2217
|
setHasAttemptedHydration(false);
|
|
2154
2218
|
fetchOptions(currentValue).finally(() => {
|
|
2155
2219
|
setHasAttemptedHydration(true);
|
|
2156
2220
|
});
|
|
2157
|
-
} else if (
|
|
2221
|
+
} else if (currentValue === void 0 || currentValue === null || currentValue === "") {
|
|
2158
2222
|
setHasAttemptedHydration(true);
|
|
2159
2223
|
if (selectedObject) setSelectedObject(void 0);
|
|
2160
2224
|
}
|
|
@@ -2165,8 +2229,8 @@ var SearchApiRoot = ({
|
|
|
2165
2229
|
}
|
|
2166
2230
|
return option[valueKey];
|
|
2167
2231
|
};
|
|
2168
|
-
|
|
2169
|
-
if (currentValue && !selectedObject && options.length > 0) {
|
|
2232
|
+
useEffect8(() => {
|
|
2233
|
+
if (currentValue !== void 0 && currentValue !== null && currentValue !== "" && !selectedObject && options.length > 0) {
|
|
2170
2234
|
const found = options.find((o) => getOptionValue(o) === currentValue);
|
|
2171
2235
|
if (found) {
|
|
2172
2236
|
setSelectedObject(found);
|
|
@@ -2179,7 +2243,7 @@ var SearchApiRoot = ({
|
|
|
2179
2243
|
}
|
|
2180
2244
|
}
|
|
2181
2245
|
}, [currentValue, options, obj]);
|
|
2182
|
-
|
|
2246
|
+
useEffect8(() => {
|
|
2183
2247
|
if (prevApiRef.current !== api) {
|
|
2184
2248
|
prevApiRef.current = api;
|
|
2185
2249
|
setSearchTerm("");
|
|
@@ -2204,7 +2268,7 @@ var SearchApiRoot = ({
|
|
|
2204
2268
|
fetchOptions("");
|
|
2205
2269
|
}
|
|
2206
2270
|
}, [api, name, obj]);
|
|
2207
|
-
|
|
2271
|
+
useEffect8(() => {
|
|
2208
2272
|
const handleClickOutside = (event) => {
|
|
2209
2273
|
const target = event.target;
|
|
2210
2274
|
if (containerRef.current && !containerRef.current.contains(target) && !(dropdownContentRef.current && dropdownContentRef.current.contains(target))) {
|
|
@@ -2219,13 +2283,13 @@ var SearchApiRoot = ({
|
|
|
2219
2283
|
}, [fieldInternalProps]);
|
|
2220
2284
|
const getDisplayValue = () => {
|
|
2221
2285
|
if (selectedObject) return selectedObject[labelKey];
|
|
2222
|
-
if (options.length > 0 && currentValue) {
|
|
2286
|
+
if (options.length > 0 && (currentValue !== void 0 && currentValue !== null && currentValue !== "")) {
|
|
2223
2287
|
const found = options.find((o) => getOptionValue(o) === currentValue);
|
|
2224
2288
|
if (found) return found[labelKey];
|
|
2225
2289
|
}
|
|
2226
|
-
if (isLoading || currentValue && !hasAttemptedHydration)
|
|
2290
|
+
if (isLoading || currentValue !== void 0 && currentValue !== null && currentValue !== "" && !hasAttemptedHydration)
|
|
2227
2291
|
return "Loading...";
|
|
2228
|
-
return currentValue
|
|
2292
|
+
return currentValue !== void 0 && currentValue !== null && currentValue !== "" ? currentValue : "";
|
|
2229
2293
|
};
|
|
2230
2294
|
const handleSelect = (option) => {
|
|
2231
2295
|
const val = getOptionValue(option);
|
|
@@ -2480,7 +2544,7 @@ var SearchApiInput = forwardRef5(
|
|
|
2480
2544
|
}
|
|
2481
2545
|
};
|
|
2482
2546
|
return /* @__PURE__ */ jsxs15(Fragment4, { children: [
|
|
2483
|
-
!isOpen && selectedValue && /* @__PURE__ */ jsx21("div", { className: "absolute inset-0 flex items-center ms-1 truncate select-none", children: getDisplayValue() }),
|
|
2547
|
+
!isOpen && (selectedValue !== void 0 && selectedValue !== null && selectedValue !== "") && /* @__PURE__ */ jsx21("div", { className: "absolute inset-0 flex items-center ms-1 truncate select-none", children: getDisplayValue() }),
|
|
2484
2548
|
/* @__PURE__ */ jsx21(
|
|
2485
2549
|
"input",
|
|
2486
2550
|
{
|
|
@@ -2554,7 +2618,7 @@ var SearchApiContent = forwardRef5(
|
|
|
2554
2618
|
setDropdownStyle(newStyle);
|
|
2555
2619
|
}
|
|
2556
2620
|
};
|
|
2557
|
-
|
|
2621
|
+
useEffect8(() => {
|
|
2558
2622
|
if (isOpen) {
|
|
2559
2623
|
updateDropdownPosition();
|
|
2560
2624
|
window.addEventListener("scroll", updateDropdownPosition, true);
|
|
@@ -2774,7 +2838,7 @@ var Fields = {
|
|
|
2774
2838
|
var Fields_default = Fields;
|
|
2775
2839
|
|
|
2776
2840
|
// src/components/tables/DataTable.tsx
|
|
2777
|
-
import React8, { useState as useState14, useMemo as useMemo3, useEffect as
|
|
2841
|
+
import React8, { useState as useState14, useMemo as useMemo3, useEffect as useEffect9 } from "react";
|
|
2778
2842
|
import {
|
|
2779
2843
|
useReactTable,
|
|
2780
2844
|
getCoreRowModel,
|
|
@@ -2829,7 +2893,7 @@ function DataTable({
|
|
|
2829
2893
|
pageIndex: 0,
|
|
2830
2894
|
pageSize: pageRows || 10
|
|
2831
2895
|
});
|
|
2832
|
-
|
|
2896
|
+
useEffect9(() => {
|
|
2833
2897
|
if (pageRows) {
|
|
2834
2898
|
setPagination((prev) => ({ ...prev, pageSize: pageRows }));
|
|
2835
2899
|
}
|
|
@@ -2895,7 +2959,7 @@ function DataTable({
|
|
|
2895
2959
|
},
|
|
2896
2960
|
manualPagination: false
|
|
2897
2961
|
});
|
|
2898
|
-
|
|
2962
|
+
useEffect9(() => {
|
|
2899
2963
|
if (onChange) {
|
|
2900
2964
|
onChange({
|
|
2901
2965
|
pagination: {
|
|
@@ -3093,7 +3157,13 @@ function DataTable({
|
|
|
3093
3157
|
}
|
|
3094
3158
|
|
|
3095
3159
|
// src/components/tables/PostTable.tsx
|
|
3096
|
-
import React9, {
|
|
3160
|
+
import React9, {
|
|
3161
|
+
useState as useState15,
|
|
3162
|
+
useMemo as useMemo4,
|
|
3163
|
+
useEffect as useEffect10,
|
|
3164
|
+
useRef as useRef5,
|
|
3165
|
+
useCallback as useCallback2
|
|
3166
|
+
} from "react";
|
|
3097
3167
|
import {
|
|
3098
3168
|
useReactTable as useReactTable2,
|
|
3099
3169
|
getCoreRowModel as getCoreRowModel2,
|
|
@@ -3102,7 +3172,15 @@ import {
|
|
|
3102
3172
|
getExpandedRowModel as getExpandedRowModel2,
|
|
3103
3173
|
flexRender as flexRender2
|
|
3104
3174
|
} from "@tanstack/react-table";
|
|
3105
|
-
import {
|
|
3175
|
+
import {
|
|
3176
|
+
Plus,
|
|
3177
|
+
Edit2,
|
|
3178
|
+
Trash2,
|
|
3179
|
+
Check as Check4,
|
|
3180
|
+
X as X3,
|
|
3181
|
+
ChevronDown as ChevronDown5,
|
|
3182
|
+
Loader2 as Loader23
|
|
3183
|
+
} from "lucide-react";
|
|
3106
3184
|
import { Fragment as Fragment6, jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3107
3185
|
var TableCell = React9.memo(
|
|
3108
3186
|
({
|
|
@@ -3233,10 +3311,10 @@ function PostTable({
|
|
|
3233
3311
|
}
|
|
3234
3312
|
}, 50);
|
|
3235
3313
|
};
|
|
3236
|
-
|
|
3314
|
+
useEffect10(() => {
|
|
3237
3315
|
focusAndScrollEntryRow();
|
|
3238
3316
|
}, []);
|
|
3239
|
-
|
|
3317
|
+
useEffect10(() => {
|
|
3240
3318
|
if (controlledData) {
|
|
3241
3319
|
setData(controlledData);
|
|
3242
3320
|
}
|
|
@@ -3254,7 +3332,7 @@ function PostTable({
|
|
|
3254
3332
|
fieldErrors,
|
|
3255
3333
|
onChange
|
|
3256
3334
|
});
|
|
3257
|
-
|
|
3335
|
+
useEffect10(() => {
|
|
3258
3336
|
latestStateRef.current = {
|
|
3259
3337
|
data,
|
|
3260
3338
|
entryData,
|
|
@@ -3343,72 +3421,78 @@ function PostTable({
|
|
|
3343
3421
|
setEditingIndex(index2);
|
|
3344
3422
|
setEntryData(rowOriginal);
|
|
3345
3423
|
}, []);
|
|
3346
|
-
const handleDelete = useCallback2(
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
if (td) {
|
|
3357
|
-
const input = td.querySelector(
|
|
3358
|
-
`input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex='0'], [id*='${columnId}']`
|
|
3424
|
+
const handleDelete = useCallback2(
|
|
3425
|
+
(index2) => {
|
|
3426
|
+
const { data: data2, editingIndex: editingIndex2, onChange: onChange2 } = latestStateRef.current;
|
|
3427
|
+
const newData = data2.filter((_, i) => i !== index2);
|
|
3428
|
+
setData(newData);
|
|
3429
|
+
const actions = {
|
|
3430
|
+
focus: (columnId) => {
|
|
3431
|
+
if (entryRowRef.current) {
|
|
3432
|
+
const td = entryRowRef.current.querySelector(
|
|
3433
|
+
`td[data-column-id="${columnId}"]`
|
|
3359
3434
|
);
|
|
3360
|
-
if (
|
|
3435
|
+
if (td) {
|
|
3436
|
+
const input = td.querySelector(
|
|
3437
|
+
`input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex='0'], [id*='${columnId}']`
|
|
3438
|
+
);
|
|
3439
|
+
if (input) input.focus();
|
|
3440
|
+
}
|
|
3361
3441
|
}
|
|
3442
|
+
},
|
|
3443
|
+
setError: (columnId, error) => {
|
|
3444
|
+
setFieldErrors((prev) => ({
|
|
3445
|
+
...prev,
|
|
3446
|
+
[columnId]: error
|
|
3447
|
+
}));
|
|
3362
3448
|
}
|
|
3363
|
-
}
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3449
|
+
};
|
|
3450
|
+
onChange2?.({
|
|
3451
|
+
entryData: data2[index2],
|
|
3452
|
+
actions,
|
|
3453
|
+
actionType: "delete",
|
|
3454
|
+
fullData: newData
|
|
3455
|
+
});
|
|
3456
|
+
if (editingIndex2 === index2) {
|
|
3457
|
+
handleCancelEdit();
|
|
3458
|
+
} else if (editingIndex2 !== null && editingIndex2 > index2) {
|
|
3459
|
+
setEditingIndex(editingIndex2 - 1);
|
|
3369
3460
|
}
|
|
3370
|
-
}
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
title: "Delete",
|
|
3406
|
-
children: submitLoading2 || isSavingAsync2 ? /* @__PURE__ */ jsx24(Loader23, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ jsx24(Trash2, { size: 16 })
|
|
3407
|
-
}
|
|
3408
|
-
)
|
|
3409
|
-
] });
|
|
3410
|
-
}
|
|
3411
|
-
}), []);
|
|
3461
|
+
},
|
|
3462
|
+
[handleCancelEdit]
|
|
3463
|
+
);
|
|
3464
|
+
const actionColumn = useMemo4(
|
|
3465
|
+
() => ({
|
|
3466
|
+
id: "actions",
|
|
3467
|
+
header: "Actions",
|
|
3468
|
+
cell: ({ row, table: table2 }) => {
|
|
3469
|
+
const { handleEdit: handleEdit2, handleDelete: handleDelete2, submitLoading: submitLoading2, isSavingAsync: isSavingAsync2 } = table2.options.meta;
|
|
3470
|
+
return /* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
|
|
3471
|
+
/* @__PURE__ */ jsx24(
|
|
3472
|
+
"button",
|
|
3473
|
+
{
|
|
3474
|
+
onClick: () => handleEdit2(row.index, row.original),
|
|
3475
|
+
disabled: submitLoading2 || isSavingAsync2,
|
|
3476
|
+
className: "p-1 px-2 rounded-md hover:bg-gray-100 dark:hover:bg-zinc-800 text-gray-500 hover:text-(--theme-primary) dark:hover:text-(--theme-primary) transition-colors disabled:opacity-50",
|
|
3477
|
+
title: "Edit",
|
|
3478
|
+
children: submitLoading2 || isSavingAsync2 ? /* @__PURE__ */ jsx24(Loader23, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ jsx24(Edit2, { size: 16 })
|
|
3479
|
+
}
|
|
3480
|
+
),
|
|
3481
|
+
/* @__PURE__ */ jsx24(
|
|
3482
|
+
"button",
|
|
3483
|
+
{
|
|
3484
|
+
onClick: () => handleDelete2(row.index),
|
|
3485
|
+
disabled: submitLoading2 || isSavingAsync2,
|
|
3486
|
+
className: "p-1 px-2 rounded-md hover:bg-gray-100 dark:hover:bg-zinc-800 text-gray-500 hover:text-red-600 dark:hover:text-red-400 transition-colors disabled:opacity-50",
|
|
3487
|
+
title: "Delete",
|
|
3488
|
+
children: submitLoading2 || isSavingAsync2 ? /* @__PURE__ */ jsx24(Loader23, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ jsx24(Trash2, { size: 16 })
|
|
3489
|
+
}
|
|
3490
|
+
)
|
|
3491
|
+
] });
|
|
3492
|
+
}
|
|
3493
|
+
}),
|
|
3494
|
+
[]
|
|
3495
|
+
);
|
|
3412
3496
|
const columns = useMemo4(() => {
|
|
3413
3497
|
const mappedUserColumns = userColumns.map((col) => ({
|
|
3414
3498
|
...col,
|
|
@@ -3567,7 +3651,13 @@ function PostTable({
|
|
|
3567
3651
|
disabled: isSavingAsync || submitLoading,
|
|
3568
3652
|
className: "flex-1 h-8 flex items-center justify-center rounded-lg bg-green-500/10 text-green-600 dark:bg-emerald-500/20 dark:text-emerald-400 hover:bg-green-500 hover:text-white dark:hover:bg-emerald-500 transition-colors shadow-sm active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
3569
3653
|
title: "Update",
|
|
3570
|
-
children: isSavingAsync || submitLoading ? /* @__PURE__ */ jsx24(
|
|
3654
|
+
children: isSavingAsync || submitLoading ? /* @__PURE__ */ jsx24(
|
|
3655
|
+
Loader23,
|
|
3656
|
+
{
|
|
3657
|
+
size: 16,
|
|
3658
|
+
className: "animate-spin"
|
|
3659
|
+
}
|
|
3660
|
+
) : /* @__PURE__ */ jsx24(Check4, { size: 16, strokeWidth: 2.5 })
|
|
3571
3661
|
}
|
|
3572
3662
|
),
|
|
3573
3663
|
/* @__PURE__ */ jsx24(
|
|
@@ -3595,7 +3685,13 @@ function PostTable({
|
|
|
3595
3685
|
},
|
|
3596
3686
|
title: "Add Row",
|
|
3597
3687
|
children: [
|
|
3598
|
-
isSavingAsync || submitLoading ? /* @__PURE__ */ jsx24(
|
|
3688
|
+
isSavingAsync || submitLoading ? /* @__PURE__ */ jsx24(
|
|
3689
|
+
Loader23,
|
|
3690
|
+
{
|
|
3691
|
+
size: 14,
|
|
3692
|
+
className: "animate-spin"
|
|
3693
|
+
}
|
|
3694
|
+
) : /* @__PURE__ */ jsx24(Plus, { size: 14, strokeWidth: 2.5 }),
|
|
3599
3695
|
/* @__PURE__ */ jsx24("span", { children: isSavingAsync || submitLoading ? "Adding..." : "Add" })
|
|
3600
3696
|
]
|
|
3601
3697
|
}
|
|
@@ -3937,7 +4033,7 @@ var Branding = ({
|
|
|
3937
4033
|
};
|
|
3938
4034
|
|
|
3939
4035
|
// src/hooks/Fetches/useA4DataView.tsx
|
|
3940
|
-
import { useEffect as
|
|
4036
|
+
import { useEffect as useEffect11, useRef as useRef6, useState as useState16 } from "react";
|
|
3941
4037
|
import { useReactToPrint } from "react-to-print";
|
|
3942
4038
|
import { RefreshCw, Printer, AlertCircle, FileX } from "lucide-react";
|
|
3943
4039
|
import { jsx as jsx28, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
@@ -3952,7 +4048,7 @@ var useA4StatementView = ({
|
|
|
3952
4048
|
const reactToPrintFn = useReactToPrint({
|
|
3953
4049
|
contentRef
|
|
3954
4050
|
});
|
|
3955
|
-
|
|
4051
|
+
useEffect11(() => {
|
|
3956
4052
|
if (url) {
|
|
3957
4053
|
get({ url, v, params, delay });
|
|
3958
4054
|
}
|
|
@@ -4029,7 +4125,7 @@ var useA4StatementView = ({
|
|
|
4029
4125
|
renderFooter: c.renderFooter ? c.renderFooter.toString() : ""
|
|
4030
4126
|
}))
|
|
4031
4127
|
});
|
|
4032
|
-
|
|
4128
|
+
useEffect11(() => {
|
|
4033
4129
|
if (filteredDisplayData && filteredDisplayData.length > 0) {
|
|
4034
4130
|
setIsMeasuring(true);
|
|
4035
4131
|
setPages((prev) => prev.length === 0 ? [[]] : prev);
|
|
@@ -4040,7 +4136,7 @@ var useA4StatementView = ({
|
|
|
4040
4136
|
);
|
|
4041
4137
|
}
|
|
4042
4138
|
}, [depsString]);
|
|
4043
|
-
|
|
4139
|
+
useEffect11(() => {
|
|
4044
4140
|
if (!isMeasuring || filteredDisplayData.length === 0) return;
|
|
4045
4141
|
const timer = setTimeout(() => {
|
|
4046
4142
|
if (!measureContainerRef.current) return;
|
|
@@ -4258,7 +4354,7 @@ var A4DataView = (props) => {
|
|
|
4258
4354
|
var useA4DataView_default = useA4StatementView;
|
|
4259
4355
|
|
|
4260
4356
|
// src/hooks/Fetches/useTransaction.tsx
|
|
4261
|
-
import { useEffect as
|
|
4357
|
+
import { useEffect as useEffect12, useState as useState17 } from "react";
|
|
4262
4358
|
import { AlertCircle as AlertCircle2, FileX as FileX2, Plus as Plus2, RefreshCw as RefreshCw2 } from "lucide-react";
|
|
4263
4359
|
import moment from "moment";
|
|
4264
4360
|
import { jsx as jsx29, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
@@ -4285,7 +4381,7 @@ var useTransaction = ({
|
|
|
4285
4381
|
delay
|
|
4286
4382
|
});
|
|
4287
4383
|
};
|
|
4288
|
-
|
|
4384
|
+
useEffect12(() => {
|
|
4289
4385
|
getData();
|
|
4290
4386
|
}, [url, v, JSON.stringify(params), delay, date]);
|
|
4291
4387
|
const TransactionViewComponent = ({
|