warqadui 0.0.39 → 0.0.42

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.js CHANGED
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- A4DataView: () => A4DataView,
34
33
  Badge: () => Badge,
35
34
  Branding: () => Branding,
36
35
  Button: () => Button,
@@ -3248,7 +3247,7 @@ var TableCell = import_react16.default.memo(
3248
3247
  );
3249
3248
  },
3250
3249
  (prev, next) => {
3251
- return prev.cell.getValue() === next.cell.getValue() && prev.cell.row.getIsExpanded() === next.cell.row.getIsExpanded() && prev.cell.row.getIsSelected() === next.cell.row.getIsSelected() && prev.rowPadding === next.rowPadding && prev.verticalLines === next.verticalLines;
3250
+ return prev.cell.getValue() === next.cell.getValue() && prev.cell.row.original === next.cell.row.original && prev.cell.row.getIsExpanded() === next.cell.row.getIsExpanded() && prev.cell.row.getIsSelected() === next.cell.row.getIsSelected() && prev.rowPadding === next.rowPadding && prev.verticalLines === next.verticalLines;
3252
3251
  }
3253
3252
  );
3254
3253
  var TableRow = import_react16.default.memo(
@@ -3335,7 +3334,9 @@ function PostTable({
3335
3334
  }
3336
3335
  return initialState;
3337
3336
  });
3338
- const [data, setData] = (0, import_react16.useState)(controlledData || []);
3337
+ const [internalData, setInternalData] = (0, import_react16.useState)(controlledData || []);
3338
+ const isControlled = controlledData !== void 0;
3339
+ const data = isControlled ? controlledData : internalData;
3339
3340
  const entryRowRef = (0, import_react16.useRef)(null);
3340
3341
  const focusAndScrollEntryRow = () => {
3341
3342
  setTimeout(() => {
@@ -3356,11 +3357,6 @@ function PostTable({
3356
3357
  (0, import_react16.useEffect)(() => {
3357
3358
  focusAndScrollEntryRow();
3358
3359
  }, []);
3359
- (0, import_react16.useEffect)(() => {
3360
- if (controlledData) {
3361
- setData(controlledData);
3362
- }
3363
- }, [controlledData]);
3364
3360
  const [entryData, setEntryData] = (0, import_react16.useState)({});
3365
3361
  const [editingIndex, setEditingIndex] = (0, import_react16.useState)(null);
3366
3362
  const [isSavingAsync, setIsSavingAsync] = (0, import_react16.useState)(false);
@@ -3392,23 +3388,21 @@ function PostTable({
3392
3388
  };
3393
3389
  });
3394
3390
  const handleSaveField = (0, import_react16.useCallback)(async () => {
3395
- const {
3396
- data: data2,
3397
- entryData: entryData2,
3398
- editingIndex: editingIndex2,
3399
- isSavingAsync: isSavingAsync2,
3400
- submitLoading: submitLoading2,
3401
- onChange: onChange2
3402
- } = latestStateRef.current;
3391
+ const { data: data2, entryData: entryData2, editingIndex: editingIndex2, onChange: onChange2 } = latestStateRef.current;
3403
3392
  if (Object.keys(entryData2).length === 0) return;
3404
- let newData = [...data2];
3405
- if (editingIndex2 !== null) {
3406
- newData[editingIndex2] = {
3407
- ...newData[editingIndex2],
3408
- ...entryData2
3393
+ const actionType = editingIndex2 !== null ? "edit" : "add";
3394
+ const entryToSave = { ...entryData2 };
3395
+ const updated = [...data2];
3396
+ let entryToPass;
3397
+ if (actionType === "edit" && editingIndex2 !== null) {
3398
+ updated[editingIndex2] = {
3399
+ ...updated[editingIndex2],
3400
+ ...entryToSave
3409
3401
  };
3402
+ entryToPass = updated[editingIndex2];
3410
3403
  } else {
3411
- newData = [...newData, entryData2];
3404
+ updated.push(entryToSave);
3405
+ entryToPass = updated[updated.length - 1];
3412
3406
  }
3413
3407
  if (onChange2) {
3414
3408
  setIsSavingAsync(true);
@@ -3434,12 +3428,11 @@ function PostTable({
3434
3428
  }));
3435
3429
  }
3436
3430
  };
3437
- const type = editingIndex2 !== null ? "edit" : "add";
3438
3431
  const result = await onChange2({
3439
- entryData: entryData2,
3432
+ entryData: entryToPass,
3440
3433
  actions,
3441
- actionType: type,
3442
- fullData: newData
3434
+ actionType,
3435
+ fullData: updated
3443
3436
  });
3444
3437
  if (result === false) {
3445
3438
  setIsSavingAsync(false);
@@ -3450,14 +3443,14 @@ function PostTable({
3450
3443
  return;
3451
3444
  }
3452
3445
  }
3453
- setData(newData);
3446
+ setInternalData(updated);
3454
3447
  setEntryData({});
3455
3448
  setFieldErrors({});
3456
3449
  setIsSavingAsync(false);
3457
3450
  if (editingIndex2 !== null) {
3458
3451
  setEditingIndex(null);
3459
3452
  } else {
3460
- focusAndScrollEntryRow();
3453
+ setTimeout(() => focusAndScrollEntryRow(), 0);
3461
3454
  }
3462
3455
  }, []);
3463
3456
  const handleCancelEdit = (0, import_react16.useCallback)(() => {
@@ -3470,43 +3463,56 @@ function PostTable({
3470
3463
  const handleEdit = (0, import_react16.useCallback)((index2, rowOriginal) => {
3471
3464
  const { onEdit: onEdit2 } = latestStateRef.current;
3472
3465
  setEditingIndex(index2);
3473
- setEntryData(rowOriginal);
3466
+ setEntryData({ ...rowOriginal });
3474
3467
  if (onEdit2) onEdit2(rowOriginal);
3475
3468
  }, []);
3476
3469
  const handleDelete = (0, import_react16.useCallback)(
3477
- (index2) => {
3470
+ async (index2) => {
3478
3471
  const { data: data2, editingIndex: editingIndex2, onChange: onChange2, onDelete: onDelete2 } = latestStateRef.current;
3479
3472
  const rowToDelete = data2[index2];
3480
- const newData = data2.filter((_, i) => i !== index2);
3481
- setData(newData);
3482
- if (onDelete2) onDelete2(rowToDelete);
3483
- const actions = {
3484
- focus: (columnId) => {
3485
- if (entryRowRef.current) {
3486
- const td = entryRowRef.current.querySelector(
3487
- `td[data-column-id="${columnId}"]`
3488
- );
3489
- if (td) {
3490
- const input = td.querySelector(
3491
- `input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex='0'], [id*='${columnId}']`
3492
- );
3493
- if (input) input.focus();
3473
+ const updated = data2.filter((_, i) => i !== index2);
3474
+ if (onChange2) {
3475
+ setIsSavingAsync(true);
3476
+ try {
3477
+ const actions = {
3478
+ focus: (columnId) => {
3479
+ if (entryRowRef.current) {
3480
+ const td = entryRowRef.current.querySelector(
3481
+ `td[data-column-id="${columnId}"]`
3482
+ );
3483
+ if (td) {
3484
+ const input = td.querySelector(
3485
+ `input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex='0'], [id*='${columnId}']`
3486
+ );
3487
+ if (input) input.focus();
3488
+ }
3489
+ }
3490
+ },
3491
+ setError: (columnId, error) => {
3492
+ setFieldErrors((prev) => ({
3493
+ ...prev,
3494
+ [columnId]: error
3495
+ }));
3494
3496
  }
3497
+ };
3498
+ const result = await onChange2({
3499
+ entryData: rowToDelete,
3500
+ actions,
3501
+ actionType: "delete",
3502
+ fullData: updated
3503
+ });
3504
+ if (result === false) {
3505
+ setIsSavingAsync(false);
3506
+ return;
3495
3507
  }
3496
- },
3497
- setError: (columnId, error) => {
3498
- setFieldErrors((prev) => ({
3499
- ...prev,
3500
- [columnId]: error
3501
- }));
3508
+ } catch (error) {
3509
+ setIsSavingAsync(false);
3510
+ return;
3502
3511
  }
3503
- };
3504
- onChange2?.({
3505
- entryData: data2[index2],
3506
- actions,
3507
- actionType: "delete",
3508
- fullData: newData
3509
- });
3512
+ }
3513
+ setInternalData(updated);
3514
+ if (onDelete2) onDelete2(rowToDelete);
3515
+ setIsSavingAsync(false);
3510
3516
  if (editingIndex2 === index2) {
3511
3517
  handleCancelEdit();
3512
3518
  } else if (editingIndex2 !== null && editingIndex2 > index2) {
@@ -3900,7 +3906,8 @@ function SimpleTable({
3900
3906
  isLoading = false,
3901
3907
  title,
3902
3908
  enableSearch = false,
3903
- emptyState
3909
+ emptyState,
3910
+ skeletonCount = 5
3904
3911
  }) {
3905
3912
  const columns = (0, import_react17.useMemo)(() => {
3906
3913
  const cols = userColumns.filter((col) => !col.hide).map((col) => ({
@@ -3916,9 +3923,9 @@ function SimpleTable({
3916
3923
  cols.unshift({
3917
3924
  header: "#",
3918
3925
  id: "index",
3919
- width: 45,
3920
- className: "whitespace-nowrap pr-2",
3921
- cell: (info) => info.row.index + 1 + startIndex
3926
+ width: 75,
3927
+ className: "whitespace-nowrap px-2 text-center",
3928
+ cell: (info) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "tabular-nums", children: info.row.index + 1 + startIndex })
3922
3929
  });
3923
3930
  }
3924
3931
  return cols;
@@ -3964,7 +3971,7 @@ function SimpleTable({
3964
3971
  },
3965
3972
  headerGroup.id
3966
3973
  )) }),
3967
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("tbody", { className: "text-black dark:text-white font-semibold font-sans tabular-nums", children: isLoading ? Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3974
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("tbody", { className: "text-black dark:text-white font-semibold font-sans tabular-nums", children: isLoading && data.length === 0 ? Array.from({ length: skeletonCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3968
3975
  "tr",
3969
3976
  {
3970
3977
  className: `border-b ${verticalLines ? "border-black dark:border-white" : "border-gray-100 dark:border-zinc-800/60 last:border-0"}`,
@@ -3972,13 +3979,18 @@ function SimpleTable({
3972
3979
  "td",
3973
3980
  {
3974
3981
  className: `text-sm ${rowPadding} align-top ${verticalLines ? "border-x border-black dark:border-white" : ""}`,
3975
- children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "h-4 bg-gray-200 dark:bg-zinc-800 rounded-sm animate-pulse w-full" })
3982
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3983
+ "div",
3984
+ {
3985
+ className: `h-4 bg-gray-200 dark:bg-zinc-800/50 rounded-sm animate-pulse ${colIdx % 2 === 0 ? "w-3/4" : "w-1/2"} ${colIdx === 0 ? "w-4" : ""}`
3986
+ }
3987
+ )
3976
3988
  },
3977
3989
  `skeleton-col-${colIdx}`
3978
3990
  ))
3979
3991
  },
3980
3992
  `skeleton-row-${i}`
3981
- )) : data.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3993
+ )) : data.length === 0 && !isLoading ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3982
3994
  "td",
3983
3995
  {
3984
3996
  colSpan: columns.length,
@@ -4091,17 +4103,22 @@ var useA4StatementView = ({
4091
4103
  url,
4092
4104
  v = 1,
4093
4105
  delay,
4094
- params
4106
+ params,
4107
+ startPage = 1
4095
4108
  } = {}) => {
4096
4109
  const { data: apiData, isLoading, get, error: apiError } = useApis_default();
4097
4110
  const contentRef = (0, import_react19.useRef)(null);
4098
4111
  const reactToPrintFn = (0, import_react_to_print.useReactToPrint)({
4099
4112
  contentRef
4100
4113
  });
4101
- (0, import_react19.useEffect)(() => {
4114
+ const getData = async () => {
4102
4115
  if (url) {
4103
- get({ url, v, params, delay });
4116
+ console.log("url", delay);
4117
+ await get({ url, v, params, delay });
4104
4118
  }
4119
+ };
4120
+ (0, import_react19.useEffect)(() => {
4121
+ getData();
4105
4122
  }, [url, v, JSON.stringify(params), delay]);
4106
4123
  const A4DataViewComponent = ({
4107
4124
  columns = [
@@ -4125,13 +4142,18 @@ var useA4StatementView = ({
4125
4142
  rowPadding = "p-3",
4126
4143
  verticalLines = true,
4127
4144
  headers,
4128
- tableTitle = "Recent Transactions"
4145
+ tableTitle = "Recent Transactions",
4146
+ startPage: componentStartPage = startPage,
4147
+ isLoading: externalLoading
4129
4148
  }) => {
4130
4149
  const { store } = useWarqadConfig();
4150
+ const isActuallyLoading = externalLoading ?? isLoading;
4131
4151
  const measureContainerRef = (0, import_react19.useRef)(null);
4132
4152
  const [pages, setPages] = (0, import_react19.useState)([]);
4133
4153
  const [isMeasuring, setIsMeasuring] = (0, import_react19.useState)(true);
4134
4154
  const [globalFilter, setGlobalFilter] = (0, import_react19.useState)("");
4155
+ const [currentPageIndex, setCurrentPageIndex] = (0, import_react19.useState)(0);
4156
+ const [pageSearch, setPageSearch] = (0, import_react19.useState)("");
4135
4157
  const displayColumnsForSearch = columns.filter((col) => !col.hide);
4136
4158
  const filteredDisplayData = data.filter((row) => {
4137
4159
  if (!globalFilter) return true;
@@ -4180,11 +4202,15 @@ var useA4StatementView = ({
4180
4202
  if (filteredDisplayData && filteredDisplayData.length > 0) {
4181
4203
  setIsMeasuring(true);
4182
4204
  setPages((prev) => prev.length === 0 ? [[]] : prev);
4205
+ if (componentStartPage !== -1) {
4206
+ setCurrentPageIndex(Math.max(0, componentStartPage - 1));
4207
+ }
4183
4208
  } else {
4184
4209
  setIsMeasuring(false);
4185
4210
  setPages(
4186
4211
  (prev) => prev.length === 1 && prev[0].length === 0 ? prev : [[]]
4187
4212
  );
4213
+ setCurrentPageIndex(0);
4188
4214
  }
4189
4215
  }, [depsString]);
4190
4216
  (0, import_react19.useEffect)(() => {
@@ -4206,7 +4232,6 @@ var useA4StatementView = ({
4206
4232
  const thHeight = getH(tableHeaderEl);
4207
4233
  const tfHeight = getH(tableFooterEl);
4208
4234
  const finalTotalHeight = getH(finalTotalEl);
4209
- const MAX_CONTENT_HEIGHT = 950;
4210
4235
  let currentChunks = [];
4211
4236
  let currentChunk = [];
4212
4237
  let currentHeight = headerHeight + infoGridHeight + tableTitleHeight + thHeight + tfHeight;
@@ -4214,7 +4239,8 @@ var useA4StatementView = ({
4214
4239
  const rowHeight = getH(row);
4215
4240
  const isLastRow = i === rowEls.length - 1;
4216
4241
  const requiredHeight = isLastRow ? rowHeight + finalTotalHeight : rowHeight;
4217
- if (currentHeight + requiredHeight > MAX_CONTENT_HEIGHT) {
4242
+ const currentPageLimit = currentChunks.length === 0 ? 920 : 980;
4243
+ if (currentHeight + requiredHeight > currentPageLimit) {
4218
4244
  if (currentChunk.length > 0) {
4219
4245
  currentChunks.push([...currentChunk]);
4220
4246
  currentChunk = [];
@@ -4230,7 +4256,15 @@ var useA4StatementView = ({
4230
4256
  const validPages = currentChunks.filter(
4231
4257
  (chunk) => chunk && chunk.length > 0
4232
4258
  );
4233
- setPages(validPages.length > 0 ? validPages : [[]]);
4259
+ const finalPages = validPages.length > 0 ? validPages : [[]];
4260
+ setPages(finalPages);
4261
+ if (componentStartPage === -1) {
4262
+ setCurrentPageIndex(finalPages.length - 1);
4263
+ } else if (componentStartPage > 1) {
4264
+ setCurrentPageIndex(
4265
+ Math.min(componentStartPage - 1, finalPages.length - 1)
4266
+ );
4267
+ }
4234
4268
  setIsMeasuring(false);
4235
4269
  }, 150);
4236
4270
  return () => clearTimeout(timer);
@@ -4256,15 +4290,22 @@ var useA4StatementView = ({
4256
4290
  ]
4257
4291
  }
4258
4292
  );
4259
- const DisplayInfoGridEl = Array.isArray(info) && info.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { id: "a4-info-grid", className: "px-8", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(InfoGrid, { className: "mb-4", items: info, isLoading }) }) : null;
4260
- const emptyState = !isLoading && (error || !data || data.length === 0) ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "flex flex-col relative w-full items-center justify-center py-12 min-h-[300px]", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col items-center justify-center p-8 bg-gray-50/50 dark:bg-zinc-900/30 rounded-2xl border border-dashed border-gray-300 dark:border-zinc-700 w-full max-w-lg text-center shadow-sm", children: [
4261
- error ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "w-14 h-14 bg-red-100 dark:bg-red-500/10 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react12.AlertCircle, { className: "w-7 h-7 text-red-600 dark:text-red-500" }) }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "w-14 h-14 bg-gray-200 dark:bg-zinc-800 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react12.FileX, { className: "w-7 h-7 text-gray-500 dark:text-gray-400" }) }),
4262
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("h3", { className: "text-lg font-bold text-gray-900 dark:text-white mb-2", children: error ? "Failed to Load Statement" : "No Records Found" }),
4263
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-sm text-gray-500 dark:text-gray-400 max-w-xs mb-6 leading-relaxed", children: error ? typeof error === "string" ? error : "An unexpected error occurred while fetching the statement data." : "There are no transactions or records available in this requested statement." }),
4264
- url && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
4293
+ const DisplayInfoGridEl = Array.isArray(info) && info.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { id: "a4-info-grid", className: "px-8", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4294
+ InfoGrid,
4295
+ {
4296
+ className: "mb-4",
4297
+ items: info,
4298
+ isLoading: isActuallyLoading
4299
+ }
4300
+ ) }) : null;
4301
+ const statusOverlay = isActuallyLoading || error || !data || data.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "flex flex-col relative w-full items-center justify-center py-12 min-h-[400px]", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col items-center justify-center p-8 bg-gray-50/50 dark:bg-zinc-900/30 rounded-2xl border border-dashed border-gray-300 dark:border-zinc-700 w-full max-w-lg text-center shadow-sm", children: [
4302
+ isActuallyLoading ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ClassicSpin, {}) }) : error ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "w-14 h-14 bg-red-100 dark:bg-red-500/10 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react12.AlertCircle, { className: "w-7 h-7 text-red-600 dark:text-red-500" }) }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "w-14 h-14 bg-gray-200 dark:bg-zinc-800 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react12.FileX, { className: "w-7 h-7 text-gray-500 dark:text-gray-400" }) }),
4303
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("h3", { className: "text-lg font-bold text-gray-900 dark:text-white mb-2", children: isActuallyLoading ? "Loading data..." : error ? "Failed to Load Statement" : "No Records Found" }),
4304
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-sm text-gray-500 dark:text-gray-400 max-w-xs mb-6 leading-relaxed", children: isActuallyLoading ? "Please wait while we prepare your statement." : error ? typeof error === "string" ? error : "An unexpected error occurred while fetching the statement data." : "There are no transactions or records available in this requested statement." }),
4305
+ url && !isActuallyLoading && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
4265
4306
  "button",
4266
4307
  {
4267
- onClick: () => get({ url, v, params, delay }),
4308
+ onClick: () => getData(),
4268
4309
  className: "flex items-center gap-2 px-5 py-2 bg-black dark:bg-white text-white dark:text-black font-semibold rounded-lg shadow-md hover:bg-gray-800 dark:hover:bg-gray-100 transition-all active:scale-95 text-sm",
4269
4310
  children: [
4270
4311
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react12.RefreshCw, { size: 14 }),
@@ -4272,7 +4313,7 @@ var useA4StatementView = ({
4272
4313
  ]
4273
4314
  }
4274
4315
  )
4275
- ] }) }) : void 0;
4316
+ ] }) }) : null;
4276
4317
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col relative w-full items-center", children: [
4277
4318
  isMeasuring && filteredDisplayData.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "absolute top-0 opacity-0 pointer-events-none -left-full", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4278
4319
  "div",
@@ -4308,82 +4349,157 @@ var useA4StatementView = ({
4308
4349
  }
4309
4350
  ) }),
4310
4351
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "py-2 px-0 md:px-4 w-full", ref: contentRef, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "flex flex-col gap-8 print:block print:gap-0 w-full items-center", children: pages.map((pageData, pageIndex) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4311
- PageA4,
4352
+ "div",
4312
4353
  {
4313
- className: "w-full",
4314
- pageNumber: pageIndex + 1,
4315
- totalPages: pages.length,
4316
- isLastPage: pageIndex === pages.length - 1,
4317
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col h-full grow w-full", children: [
4318
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("header", { className: "flex justify-between gap-2 items-center px-8 pt-4 print:hidden", children: [
4319
- headers,
4320
- printable && pageIndex === 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "flex items-center justify-end ", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-2", children: [
4321
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
4322
- "button",
4323
- {
4324
- onClick: () => url && get({ url, v, params, delay }),
4325
- disabled: isLoading,
4326
- className: "flex items-center gap-2 px-3 py-1.5 text-gray-600 dark:text-gray-300 hover:text-black dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-all disabled:opacity-50",
4327
- children: [
4354
+ className: pageIndex === currentPageIndex ? "w-full" : "hidden print:block w-full",
4355
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4356
+ PageA4,
4357
+ {
4358
+ className: "w-full",
4359
+ pageNumber: pageIndex + 1,
4360
+ totalPages: pages.length,
4361
+ isLastPage: pageIndex === pages.length - 1,
4362
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col h-full grow w-full", children: [
4363
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("header", { className: "flex justify-between gap-2 items-center px-8 pt-4 print:hidden", children: [
4364
+ headers,
4365
+ printable && pageIndex === currentPageIndex && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "flex items-center justify-end ", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-2", children: [
4366
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
4367
+ "button",
4368
+ {
4369
+ onClick: async () => await getData(),
4370
+ disabled: isLoading,
4371
+ className: "flex items-center gap-2 px-3 py-1.5 text-gray-600 dark:text-gray-300 hover:text-black dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-all disabled:opacity-50",
4372
+ children: [
4373
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4374
+ import_lucide_react12.RefreshCw,
4375
+ {
4376
+ size: 16,
4377
+ className: isLoading ? "animate-spin" : ""
4378
+ }
4379
+ ),
4380
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-xs font-semibold", children: "Reload" })
4381
+ ]
4382
+ }
4383
+ ),
4384
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
4385
+ "button",
4386
+ {
4387
+ onClick: () => reactToPrintFn(),
4388
+ className: "flex items-center gap-2 px-4 py-1.5 bg-black dark:bg-zinc-800 text-white rounded-md text-xs font-bold shadow-sm hover:bg-zinc-800 dark:hover:bg-zinc-700 transition-all active:scale-95",
4389
+ children: [
4390
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react12.Printer, { size: 16 }),
4391
+ "Print"
4392
+ ]
4393
+ }
4394
+ ),
4395
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-1.5 ml-2 pl-2 border-l border-gray-200 dark:border-zinc-700", children: [
4328
4396
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4329
- import_lucide_react12.RefreshCw,
4397
+ "button",
4330
4398
  {
4331
- size: 16,
4332
- className: isLoading ? "animate-spin" : ""
4399
+ onClick: (e) => {
4400
+ e.stopPropagation();
4401
+ setCurrentPageIndex(
4402
+ (p) => Math.max(0, p - 1)
4403
+ );
4404
+ },
4405
+ disabled: currentPageIndex === 0,
4406
+ className: "p-1 rounded hover:bg-gray-100 dark:hover:bg-zinc-800 disabled:opacity-30 transition-colors text-gray-600 dark:text-gray-400",
4407
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react12.ChevronLeft, { size: 18 })
4333
4408
  }
4334
4409
  ),
4335
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-xs font-semibold", children: "Reload" })
4336
- ]
4337
- }
4338
- ),
4339
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
4340
- "button",
4341
- {
4342
- onClick: () => reactToPrintFn(),
4343
- className: "flex items-center gap-2 px-4 py-1.5 bg-black dark:bg-zinc-800 text-white rounded-md text-xs font-bold shadow-sm hover:bg-zinc-800 dark:hover:bg-zinc-700 transition-all active:scale-95",
4344
- children: [
4345
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react12.Printer, { size: 16 }),
4346
- "Print"
4347
- ]
4348
- }
4349
- )
4350
- ] }) })
4351
- ] }),
4352
- pageIndex === 0 && HeaderEl,
4353
- pageIndex === 0 && DisplayInfoGridEl,
4354
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "grow w-full px-8 pb-8", children: [
4355
- pageIndex === 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mb-4 border-b border-gray-200 dark:border-zinc-800 print:border-gray-200 pb-2 flex items-center gap-2 justify-between px-2 mt-2 print:hidden", children: [
4356
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("h3", { className: "text-sm font-bold text-gray-800 dark:text-gray-100 print:text-gray-800 uppercase tracking-wide shrink-0", children: tableTitle }),
4357
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4358
- "input",
4359
- {
4360
- type: "text",
4361
- value: globalFilter,
4362
- onChange: (e) => setGlobalFilter(e.target.value),
4363
- placeholder: "Search...",
4364
- className: "block w-full max-w-xs px-3 py-2 border border-gray-300 rounded-md text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 dark:bg-zinc-900 dark:border-zinc-700 dark:text-white"
4365
- }
4366
- )
4367
- ] }),
4368
- pageIndex === 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "hidden print:flex mb-4 border-b border-gray-200 print:border-gray-200 pb-2 items-center gap-2 justify-between px-2 mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("h3", { className: "text-sm font-bold text-gray-800 print:text-gray-800 uppercase tracking-wide shrink-0", children: tableTitle }) }),
4369
- pageIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "h-5 print:h-0" }),
4370
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4371
- SimpleTable,
4372
- {
4373
- columns,
4374
- data: pageData,
4375
- className: "bg-transparent!",
4376
- rowPadding,
4377
- index,
4378
- startIndex: pages.slice(0, pageIndex).reduce((acc, curr) => acc + curr.length, 0),
4379
- verticalLines,
4380
- emptyState,
4381
- isLoading: isLoading || isMeasuring && pages.length === 1 && pages[0].length === 0
4382
- }
4383
- ),
4384
- pageIndex === pages.length - 1 && !isLoading && DisplayFinalTotalEl
4385
- ] })
4386
- ] })
4410
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-1 text-[11px] font-bold tabular-nums", children: [
4411
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
4412
+ Select,
4413
+ {
4414
+ value: currentPageIndex + 1,
4415
+ onChange: (val) => {
4416
+ const num = Number(val);
4417
+ if (!isNaN(num)) {
4418
+ setCurrentPageIndex(num - 1);
4419
+ }
4420
+ },
4421
+ variant: "ghost",
4422
+ containerClassName: "inline-block",
4423
+ children: [
4424
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SelectTrigger, { className: "h-7 px-2 min-w-[40px] border border-gray-200 dark:border-zinc-700 rounded flex items-center justify-center bg-white dark:bg-zinc-900 hover:bg-gray-100 dark:hover:bg-zinc-800 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-gray-900 dark:text-white", children: currentPageIndex + 1 }) }),
4425
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(SelectContent, { className: "min-w-[100px] max-h-64 overflow-y-auto p-0", children: [
4426
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "p-2 border-b border-gray-100 dark:border-zinc-800 sticky top-0 bg-white dark:bg-zinc-950 z-10", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4427
+ "input",
4428
+ {
4429
+ type: "text",
4430
+ placeholder: "Page...",
4431
+ className: "w-full px-2 py-1 text-[11px] border rounded bg-gray-50 dark:bg-zinc-900 border-gray-200 dark:border-zinc-800 outline-none focus:ring-1 focus:ring-blue-500 text-gray-900 dark:text-white",
4432
+ value: pageSearch,
4433
+ onChange: (e) => setPageSearch(e.target.value),
4434
+ onKeyDown: (e) => e.stopPropagation(),
4435
+ autoFocus: true
4436
+ }
4437
+ ) }),
4438
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "p-1", children: pages.map((_, i) => i + 1).filter(
4439
+ (p) => String(p).includes(pageSearch)
4440
+ ).map((p) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SelectItem, { value: p, children: p }, p)) })
4441
+ ] })
4442
+ ]
4443
+ }
4444
+ ),
4445
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-gray-400 mx-0.5", children: "/" }),
4446
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-gray-600 dark:text-gray-400", children: pages.length })
4447
+ ] }),
4448
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4449
+ "button",
4450
+ {
4451
+ onClick: (e) => {
4452
+ e.stopPropagation();
4453
+ setCurrentPageIndex(
4454
+ (p) => Math.min(pages.length - 1, p + 1)
4455
+ );
4456
+ },
4457
+ disabled: currentPageIndex === pages.length - 1,
4458
+ className: "p-1 rounded hover:bg-gray-100 dark:hover:bg-zinc-800 disabled:opacity-30 transition-colors text-gray-600 dark:text-gray-400",
4459
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react12.ChevronRight, { size: 18 })
4460
+ }
4461
+ )
4462
+ ] })
4463
+ ] }) })
4464
+ ] }),
4465
+ pageIndex === 0 && HeaderEl,
4466
+ pageIndex === 0 && DisplayInfoGridEl,
4467
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "grow w-full px-8 pb-8", children: [
4468
+ pageIndex === 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mb-4 border-b border-gray-200 dark:border-zinc-700 print:border-gray-200 pb-2 flex items-center gap-2 justify-between px-2 mt-2 print:hidden", children: [
4469
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("h3", { className: "text-sm font-bold text-gray-800 dark:text-gray-100 print:text-gray-800 uppercase tracking-wide shrink-0", children: tableTitle }),
4470
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4471
+ "input",
4472
+ {
4473
+ type: "text",
4474
+ value: globalFilter,
4475
+ onChange: (e) => setGlobalFilter(e.target.value),
4476
+ placeholder: "Search...",
4477
+ className: "block w-full max-w-xs px-3 py-2 border border-gray-300 rounded-md text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 dark:bg-zinc-900 dark:border-zinc-700 dark:text-white"
4478
+ }
4479
+ )
4480
+ ] }),
4481
+ pageIndex === 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "hidden print:flex mb-4 border-b border-gray-200 print:border-gray-200 pb-2 items-center gap-2 justify-between px-2 mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("h3", { className: "text-sm font-bold text-gray-800 print:text-gray-800 uppercase tracking-wide shrink-0", children: tableTitle }) }),
4482
+ pageIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "h-7 print:h-0" }),
4483
+ statusOverlay ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "px-8 pb-8", children: statusOverlay }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4484
+ SimpleTable,
4485
+ {
4486
+ columns,
4487
+ data: pageData,
4488
+ className: "bg-transparent!",
4489
+ rowPadding,
4490
+ index,
4491
+ startIndex: pages.slice(0, pageIndex).reduce((acc, curr) => acc + curr.length, 0),
4492
+ verticalLines,
4493
+ emptyState: null,
4494
+ isLoading: isActuallyLoading || isMeasuring && pages.length === 1 && pages[0].length === 0
4495
+ }
4496
+ ),
4497
+ pageIndex === pages.length - 1 && !isActuallyLoading && !statusOverlay && DisplayFinalTotalEl
4498
+ ] })
4499
+ ] })
4500
+ },
4501
+ pageIndex
4502
+ )
4387
4503
  },
4388
4504
  pageIndex
4389
4505
  )) }) })
@@ -4397,11 +4513,6 @@ var useA4StatementView = ({
4397
4513
  reactToPrintFn
4398
4514
  };
4399
4515
  };
4400
- var A4DataView = (props) => {
4401
- const { url, v, delay, params, ...rest } = props;
4402
- const { A4DataView: View } = useA4StatementView({ url, v, delay, params });
4403
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(View, { ...rest });
4404
- };
4405
4516
  var useA4DataView_default = useA4StatementView;
4406
4517
 
4407
4518
  // src/hooks/Fetches/useTransaction.tsx
@@ -4422,12 +4533,13 @@ var useTransaction = ({
4422
4533
  if (date) dateObj.date = date;
4423
4534
  const { data: apiData, isLoading, get, error: apiError } = useApis_default();
4424
4535
  const getData = () => {
4536
+ console.log(dateObj);
4425
4537
  get({
4426
4538
  url,
4427
4539
  v,
4428
4540
  params: {
4429
- ...dateObj,
4430
- ...params
4541
+ ...params,
4542
+ ...dateObj
4431
4543
  },
4432
4544
  delay
4433
4545
  });
@@ -4470,7 +4582,7 @@ var useTransaction = ({
4470
4582
  url && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
4471
4583
  "button",
4472
4584
  {
4473
- onClick: () => get({ url, v, params, delay }),
4585
+ onClick: () => getData(),
4474
4586
  className: "flex items-center gap-2 px-5 py-2 bg-black dark:bg-white text-white dark:text-black font-semibold rounded-lg shadow-md hover:bg-gray-800 dark:hover:bg-gray-100 transition-all active:scale-95 text-sm",
4475
4587
  children: [
4476
4588
  /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react13.RefreshCw, { size: 14 }),
@@ -4728,7 +4840,6 @@ var storage = {
4728
4840
  };
4729
4841
  // Annotate the CommonJS export names for ESM import in node:
4730
4842
  0 && (module.exports = {
4731
- A4DataView,
4732
4843
  Badge,
4733
4844
  Branding,
4734
4845
  Button,