@juv/codego-react-ui 3.0.7 → 3.0.8

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.cjs CHANGED
@@ -4858,7 +4858,19 @@ function useServerDataGrid({ url, params }) {
4858
4858
  import_axios.default.get(url, { params: { ...params, page: currentPage } }).then(({ data: res }) => {
4859
4859
  if (cancelled) return;
4860
4860
  setData(res.data);
4861
- setPagination(res.pagination);
4861
+ const rawTotal = res.total;
4862
+ const rawPerPage = res.per_page;
4863
+ const lastPage = Math.ceil(rawTotal / rawPerPage);
4864
+ const pg = res.pagination ?? {
4865
+ first_page_url: res.first_page_url ?? `${url}?page=1`,
4866
+ last_page_url: res.last_page_url ?? `${url}?page=${lastPage}`,
4867
+ next_page_url: res.next_page_url !== void 0 ? res.next_page_url : currentPage < lastPage ? `${url}?page=${currentPage + 1}` : null,
4868
+ prev_page_url: res.prev_page_url !== void 0 ? res.prev_page_url : currentPage > 1 ? `${url}?page=${currentPage - 1}` : null,
4869
+ per_page: rawPerPage,
4870
+ total: rawTotal,
4871
+ links: res.links ?? []
4872
+ };
4873
+ setPagination(pg);
4862
4874
  if (res.data.length > 0) {
4863
4875
  setColumns(
4864
4876
  Object.keys(res.data[0]).map((key) => ({
@@ -9491,7 +9503,19 @@ function useServerTable({ url, params }) {
9491
9503
  }).then(({ data: res }) => {
9492
9504
  if (cancelled) return;
9493
9505
  setData(res.data);
9494
- setPagination(res.pagination);
9506
+ const rawTotal = res.total;
9507
+ const rawPerPage = res.per_page;
9508
+ const lastPage = Math.ceil(rawTotal / rawPerPage);
9509
+ const pg = res.pagination ?? {
9510
+ first_page_url: res.first_page_url ?? `${url}?page=1`,
9511
+ last_page_url: res.last_page_url ?? `${url}?page=${lastPage}`,
9512
+ next_page_url: res.next_page_url !== void 0 ? res.next_page_url : currentPage < lastPage ? `${url}?page=${currentPage + 1}` : null,
9513
+ prev_page_url: res.prev_page_url !== void 0 ? res.prev_page_url : currentPage > 1 ? `${url}?page=${currentPage - 1}` : null,
9514
+ per_page: rawPerPage,
9515
+ total: rawTotal,
9516
+ links: res.links ?? []
9517
+ };
9518
+ setPagination(pg);
9495
9519
  if (res.data.length > 0) {
9496
9520
  setColumns(
9497
9521
  Object.keys(res.data[0]).map((key) => ({
package/dist/index.d.cts CHANGED
@@ -350,10 +350,10 @@ interface ServerPagination {
350
350
  total: number;
351
351
  links: ServerPaginationLink[];
352
352
  }
353
- interface ServerTableResponse<T> {
353
+ interface ServerTableResponse<T> extends ServerPagination {
354
354
  current_page: number;
355
355
  data: T[];
356
- pagination: ServerPagination;
356
+ pagination?: ServerPagination;
357
357
  }
358
358
  interface UseServerTableOptions {
359
359
  /** Base URL — page param appended automatically: `url?page=N` */
package/dist/index.d.ts CHANGED
@@ -350,10 +350,10 @@ interface ServerPagination {
350
350
  total: number;
351
351
  links: ServerPaginationLink[];
352
352
  }
353
- interface ServerTableResponse<T> {
353
+ interface ServerTableResponse<T> extends ServerPagination {
354
354
  current_page: number;
355
355
  data: T[];
356
- pagination: ServerPagination;
356
+ pagination?: ServerPagination;
357
357
  }
358
358
  interface UseServerTableOptions {
359
359
  /** Base URL — page param appended automatically: `url?page=N` */
@@ -61433,7 +61433,19 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
61433
61433
  axios_default.get(url2, { params: { ...params, page: currentPage } }).then(({ data: res }) => {
61434
61434
  if (cancelled) return;
61435
61435
  setData(res.data);
61436
- setPagination(res.pagination);
61436
+ const rawTotal = res.total;
61437
+ const rawPerPage = res.per_page;
61438
+ const lastPage = Math.ceil(rawTotal / rawPerPage);
61439
+ const pg = res.pagination ?? {
61440
+ first_page_url: res.first_page_url ?? `${url2}?page=1`,
61441
+ last_page_url: res.last_page_url ?? `${url2}?page=${lastPage}`,
61442
+ next_page_url: res.next_page_url !== void 0 ? res.next_page_url : currentPage < lastPage ? `${url2}?page=${currentPage + 1}` : null,
61443
+ prev_page_url: res.prev_page_url !== void 0 ? res.prev_page_url : currentPage > 1 ? `${url2}?page=${currentPage - 1}` : null,
61444
+ per_page: rawPerPage,
61445
+ total: rawTotal,
61446
+ links: res.links ?? []
61447
+ };
61448
+ setPagination(pg);
61437
61449
  if (res.data.length > 0) {
61438
61450
  setColumns(
61439
61451
  Object.keys(res.data[0]).map((key) => ({
@@ -66477,7 +66489,19 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
66477
66489
  }).then(({ data: res }) => {
66478
66490
  if (cancelled) return;
66479
66491
  setData(res.data);
66480
- setPagination(res.pagination);
66492
+ const rawTotal = res.total;
66493
+ const rawPerPage = res.per_page;
66494
+ const lastPage = Math.ceil(rawTotal / rawPerPage);
66495
+ const pg = res.pagination ?? {
66496
+ first_page_url: res.first_page_url ?? `${url2}?page=1`,
66497
+ last_page_url: res.last_page_url ?? `${url2}?page=${lastPage}`,
66498
+ next_page_url: res.next_page_url !== void 0 ? res.next_page_url : currentPage < lastPage ? `${url2}?page=${currentPage + 1}` : null,
66499
+ prev_page_url: res.prev_page_url !== void 0 ? res.prev_page_url : currentPage > 1 ? `${url2}?page=${currentPage - 1}` : null,
66500
+ per_page: rawPerPage,
66501
+ total: rawTotal,
66502
+ links: res.links ?? []
66503
+ };
66504
+ setPagination(pg);
66481
66505
  if (res.data.length > 0) {
66482
66506
  setColumns(
66483
66507
  Object.keys(res.data[0]).map((key) => ({
package/dist/index.js CHANGED
@@ -4744,7 +4744,19 @@ function useServerDataGrid({ url, params }) {
4744
4744
  axios.get(url, { params: { ...params, page: currentPage } }).then(({ data: res }) => {
4745
4745
  if (cancelled) return;
4746
4746
  setData(res.data);
4747
- setPagination(res.pagination);
4747
+ const rawTotal = res.total;
4748
+ const rawPerPage = res.per_page;
4749
+ const lastPage = Math.ceil(rawTotal / rawPerPage);
4750
+ const pg = res.pagination ?? {
4751
+ first_page_url: res.first_page_url ?? `${url}?page=1`,
4752
+ last_page_url: res.last_page_url ?? `${url}?page=${lastPage}`,
4753
+ next_page_url: res.next_page_url !== void 0 ? res.next_page_url : currentPage < lastPage ? `${url}?page=${currentPage + 1}` : null,
4754
+ prev_page_url: res.prev_page_url !== void 0 ? res.prev_page_url : currentPage > 1 ? `${url}?page=${currentPage - 1}` : null,
4755
+ per_page: rawPerPage,
4756
+ total: rawTotal,
4757
+ links: res.links ?? []
4758
+ };
4759
+ setPagination(pg);
4748
4760
  if (res.data.length > 0) {
4749
4761
  setColumns(
4750
4762
  Object.keys(res.data[0]).map((key) => ({
@@ -9377,7 +9389,19 @@ function useServerTable({ url, params }) {
9377
9389
  }).then(({ data: res }) => {
9378
9390
  if (cancelled) return;
9379
9391
  setData(res.data);
9380
- setPagination(res.pagination);
9392
+ const rawTotal = res.total;
9393
+ const rawPerPage = res.per_page;
9394
+ const lastPage = Math.ceil(rawTotal / rawPerPage);
9395
+ const pg = res.pagination ?? {
9396
+ first_page_url: res.first_page_url ?? `${url}?page=1`,
9397
+ last_page_url: res.last_page_url ?? `${url}?page=${lastPage}`,
9398
+ next_page_url: res.next_page_url !== void 0 ? res.next_page_url : currentPage < lastPage ? `${url}?page=${currentPage + 1}` : null,
9399
+ prev_page_url: res.prev_page_url !== void 0 ? res.prev_page_url : currentPage > 1 ? `${url}?page=${currentPage - 1}` : null,
9400
+ per_page: rawPerPage,
9401
+ total: rawTotal,
9402
+ links: res.links ?? []
9403
+ };
9404
+ setPagination(pg);
9381
9405
  if (res.data.length > 0) {
9382
9406
  setColumns(
9383
9407
  Object.keys(res.data[0]).map((key) => ({
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "registry": "https://registry.npmjs.org/",
5
5
  "access": "public"
6
6
  },
7
- "version": "3.0.7",
7
+ "version": "3.0.8",
8
8
  "description": "Reusable React UI components",
9
9
  "license": "MIT",
10
10
  "main": "dist/index.js",