@tint-ui/data-table 0.3.6 → 0.3.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/cjs/data-table.js CHANGED
@@ -13,7 +13,7 @@ var _context = require("./context");
13
13
  var _dataTableToolbar = require("./data-table-toolbar");
14
14
  var _dataTableContent = require("./data-table-content");
15
15
  var _dataTablePagination = require("./data-table-pagination");
16
- const _excluded = ["themePropsType", "header", "table", "data", "navbar", "initialData", "limit", "offset", "lexicon", "total", "onRowClick", "filter", "filterText", "sortBy", "sortDir", "toolbar", "cacheable"];
16
+ const _excluded = ["themePropsType", "header", "table", "data", "navbar", "initialData", "limit", "offset", "lexicon", "total", "onRowClick", "filter", "filterText", "sortBy", "sortDir", "toolbar", "cacheable", "options"];
17
17
  const DataTable = exports.DataTable = /*#__PURE__*/React.forwardRef((_ref, ref) => {
18
18
  let {
19
19
  themePropsType = "data-table",
@@ -32,7 +32,8 @@ const DataTable = exports.DataTable = /*#__PURE__*/React.forwardRef((_ref, ref)
32
32
  sortBy,
33
33
  sortDir,
34
34
  toolbar,
35
- cacheable
35
+ cacheable,
36
+ options
36
37
  } = _ref,
37
38
  props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
38
39
  const context = (0, _useDataTable.useDataTable)({
@@ -51,7 +52,8 @@ const DataTable = exports.DataTable = /*#__PURE__*/React.forwardRef((_ref, ref)
51
52
  sortDir,
52
53
  header,
53
54
  onRowClick,
54
- cacheable
55
+ cacheable,
56
+ options
55
57
  });
56
58
  return /*#__PURE__*/React.createElement(_context.DataTableContext.Provider, {
57
59
  value: context
package/cjs/index.js CHANGED
@@ -91,6 +91,12 @@ Object.keys(_paginationSizeOptions).forEach(function (key) {
91
91
  if (key in exports && exports[key] === _paginationSizeOptions[key]) return;
92
92
  exports[key] = _paginationSizeOptions[key];
93
93
  });
94
+ var _useDataTable = require("./use-data-table");
95
+ Object.keys(_useDataTable).forEach(function (key) {
96
+ if (key === "default" || key === "__esModule") return;
97
+ if (key in exports && exports[key] === _useDataTable[key]) return;
98
+ exports[key] = _useDataTable[key];
99
+ });
94
100
  var _types = require("./types");
95
101
  Object.keys(_types).forEach(function (key) {
96
102
  if (key === "default" || key === "__esModule") return;
@@ -199,7 +199,8 @@ const useDataTable = function (props) {
199
199
  cacheable = true,
200
200
  onRowClick,
201
201
  toolbar: toolbarProp,
202
- navbar: navbarProp
202
+ navbar: navbarProp,
203
+ options
203
204
  } = props;
204
205
  const {
205
206
  name,
@@ -390,6 +391,10 @@ const useDataTable = function (props) {
390
391
  return prev;
391
392
  }
392
393
  const state = Object.assign({}, prev, {
394
+ pagination: {
395
+ pageSize: prev.pagination.pageSize,
396
+ pageIndex: 0
397
+ },
393
398
  columnFilters: [],
394
399
  globalFilter: ""
395
400
  });
@@ -431,6 +436,10 @@ const useDataTable = function (props) {
431
436
  value = value(globalFilter);
432
437
  }
433
438
  const state = Object.assign({}, rest, {
439
+ pagination: {
440
+ pageSize: prev.pagination.pageSize,
441
+ pageIndex: 0
442
+ },
434
443
  globalFilter: value == null ? "" : String(value)
435
444
  });
436
445
  if (force(state, true, "filter-text")) {
@@ -456,6 +465,10 @@ const useDataTable = function (props) {
456
465
  value
457
466
  }) => Array.isArray(value) ? value.length > 0 : value != null && value !== "");
458
467
  const state = Object.assign({}, rest, {
468
+ pagination: {
469
+ pageSize: prev.pagination.pageSize,
470
+ pageIndex: 0
471
+ },
459
472
  columnFilters: value
460
473
  });
461
474
  if (force(state)) {
@@ -475,6 +488,10 @@ const useDataTable = function (props) {
475
488
  } = prev,
476
489
  rest = (0, _objectWithoutPropertiesLoose2.default)(prev, _excluded3);
477
490
  const state = Object.assign({}, rest, {
491
+ pagination: {
492
+ pageSize: prev.pagination.pageSize,
493
+ pageIndex: 0
494
+ },
478
495
  error: null,
479
496
  sorting: typeof value === "function" ? value(sorting) : value,
480
497
  loading: false
@@ -689,7 +706,7 @@ const useDataTable = function (props) {
689
706
  const {
690
707
  pagination
691
708
  } = state;
692
- const tableCtx = (0, _reactTable.useReactTable)({
709
+ const tableCtx = (0, _reactTable.useReactTable)(Object.assign({
693
710
  data,
694
711
  columns,
695
712
  pageCount: manual ? state.pageCount : undefined,
@@ -713,7 +730,7 @@ const useDataTable = function (props) {
713
730
  manualFiltering: manual,
714
731
  manualSorting: manual,
715
732
  manualPagination: manual
716
- });
733
+ }, options));
717
734
 
718
735
  // lexicon page config
719
736
  const limit = pagination.pageSize;
@@ -736,7 +753,6 @@ const useDataTable = function (props) {
736
753
  size,
737
754
  selected: state.selected.length
738
755
  });
739
- console.log("state.loadingTarget", state.loadingTarget);
740
756
  return {
741
757
  hash,
742
758
  data,
package/data-table.js CHANGED
@@ -25,6 +25,7 @@ const DataTable = /*#__PURE__*/React.forwardRef(({
25
25
  sortDir,
26
26
  toolbar,
27
27
  cacheable,
28
+ options,
28
29
  ...props
29
30
  }, ref) => {
30
31
  const context = useDataTable({
@@ -43,7 +44,8 @@ const DataTable = /*#__PURE__*/React.forwardRef(({
43
44
  sortDir,
44
45
  header,
45
46
  onRowClick,
46
- cacheable
47
+ cacheable,
48
+ options
47
49
  });
48
50
  return /*#__PURE__*/React.createElement(DataTableContext.Provider, {
49
51
  value: context
package/index.d.ts CHANGED
@@ -13,4 +13,5 @@ export * from "./data-table";
13
13
  export * from "./pagination-arrow";
14
14
  export * from "./pagination-number";
15
15
  export * from "./pagination-size-options";
16
+ export * from "./use-data-table";
16
17
  export * from "./types";
package/index.js CHANGED
@@ -13,4 +13,5 @@ export * from "./data-table.js";
13
13
  export * from "./pagination-arrow.js";
14
14
  export * from "./pagination-number.js";
15
15
  export * from "./pagination-size-options.js";
16
+ export * from "./use-data-table.js";
16
17
  export * from "./types.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tint-ui/data-table",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "author": "phragon@websoftlab.com",
5
5
  "license": "MIT",
6
6
  "dependencies": {
package/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { Table } from "@tanstack/react-table";
2
+ import type { Table, TableOptions } from "@tanstack/react-table";
3
3
  import type { InputSelectOption } from "@tint-ui/tools";
4
4
  import type { TriggerProp } from "@tint-ui/trigger";
5
5
  interface FilterRangeType {
@@ -47,6 +47,7 @@ export interface DataTableCoreProps<TData> extends FilterType<TData> {
47
47
  navbar?: Partial<Omit<NavbarConfig, "onPageSizeChange">> | null;
48
48
  compact?: boolean;
49
49
  cacheable?: boolean;
50
+ options?: TableOptions<TData>;
50
51
  }
51
52
  export type StringOrFn = string | (() => string);
52
53
  export interface DataTableLexicon {
package/use-data-table.js CHANGED
@@ -189,7 +189,8 @@ const useDataTable = function (props) {
189
189
  cacheable = true,
190
190
  onRowClick,
191
191
  toolbar: toolbarProp,
192
- navbar: navbarProp
192
+ navbar: navbarProp,
193
+ options
193
194
  } = props;
194
195
  const {
195
196
  name,
@@ -383,6 +384,10 @@ const useDataTable = function (props) {
383
384
  }
384
385
  const state = {
385
386
  ...prev,
387
+ pagination: {
388
+ pageSize: prev.pagination.pageSize,
389
+ pageIndex: 0
390
+ },
386
391
  columnFilters: [],
387
392
  globalFilter: ""
388
393
  };
@@ -426,6 +431,10 @@ const useDataTable = function (props) {
426
431
  }
427
432
  const state = {
428
433
  ...rest,
434
+ pagination: {
435
+ pageSize: prev.pagination.pageSize,
436
+ pageIndex: 0
437
+ },
429
438
  globalFilter: value == null ? "" : String(value)
430
439
  };
431
440
  if (force(state, true, "filter-text")) {
@@ -452,6 +461,10 @@ const useDataTable = function (props) {
452
461
  }) => Array.isArray(value) ? value.length > 0 : value != null && value !== "");
453
462
  const state = {
454
463
  ...rest,
464
+ pagination: {
465
+ pageSize: prev.pagination.pageSize,
466
+ pageIndex: 0
467
+ },
455
468
  columnFilters: value
456
469
  };
457
470
  if (force(state)) {
@@ -472,6 +485,10 @@ const useDataTable = function (props) {
472
485
  } = prev;
473
486
  const state = {
474
487
  ...rest,
488
+ pagination: {
489
+ pageSize: prev.pagination.pageSize,
490
+ pageIndex: 0
491
+ },
475
492
  error: null,
476
493
  sorting: typeof value === "function" ? value(sorting) : value,
477
494
  loading: false
@@ -710,7 +727,8 @@ const useDataTable = function (props) {
710
727
  onPaginationChange,
711
728
  manualFiltering: manual,
712
729
  manualSorting: manual,
713
- manualPagination: manual
730
+ manualPagination: manual,
731
+ ...options
714
732
  });
715
733
 
716
734
  // lexicon page config
@@ -734,7 +752,6 @@ const useDataTable = function (props) {
734
752
  size,
735
753
  selected: state.selected.length
736
754
  });
737
- console.log("state.loadingTarget", state.loadingTarget);
738
755
  return {
739
756
  hash,
740
757
  data,