@tanstack/react-table 8.0.0-alpha.1 → 8.0.0-alpha.11

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.
Files changed (96) hide show
  1. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -78
  2. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  3. package/build/cjs/index.js +67 -12
  4. package/build/cjs/index.js.map +1 -1
  5. package/build/esm/index.js +30 -3346
  6. package/build/esm/index.js.map +1 -1
  7. package/build/stats-html.html +1 -1
  8. package/build/stats-react.json +28 -632
  9. package/build/types/index.d.ts +3 -7
  10. package/build/umd/index.development.js +37 -3348
  11. package/build/umd/index.development.js.map +1 -1
  12. package/build/umd/index.production.js +1 -1
  13. package/build/umd/index.production.js.map +1 -1
  14. package/package.json +4 -1
  15. package/src/index.tsx +56 -7
  16. package/build/cjs/aggregationTypes.js +0 -130
  17. package/build/cjs/aggregationTypes.js.map +0 -1
  18. package/build/cjs/core.js +0 -493
  19. package/build/cjs/core.js.map +0 -1
  20. package/build/cjs/createTable.js +0 -103
  21. package/build/cjs/createTable.js.map +0 -1
  22. package/build/cjs/features/Expanding.js +0 -234
  23. package/build/cjs/features/Expanding.js.map +0 -1
  24. package/build/cjs/features/Filters.js +0 -396
  25. package/build/cjs/features/Filters.js.map +0 -1
  26. package/build/cjs/features/Grouping.js +0 -228
  27. package/build/cjs/features/Grouping.js.map +0 -1
  28. package/build/cjs/features/Headers.js +0 -483
  29. package/build/cjs/features/Headers.js.map +0 -1
  30. package/build/cjs/features/Ordering.js +0 -83
  31. package/build/cjs/features/Ordering.js.map +0 -1
  32. package/build/cjs/features/Pinning.js +0 -163
  33. package/build/cjs/features/Pinning.js.map +0 -1
  34. package/build/cjs/features/Sorting.js +0 -269
  35. package/build/cjs/features/Sorting.js.map +0 -1
  36. package/build/cjs/features/Visibility.js +0 -160
  37. package/build/cjs/features/Visibility.js.map +0 -1
  38. package/build/cjs/filterTypes.js +0 -172
  39. package/build/cjs/filterTypes.js.map +0 -1
  40. package/build/cjs/sortTypes.js +0 -121
  41. package/build/cjs/sortTypes.js.map +0 -1
  42. package/build/cjs/utils/columnFilterRowsFn.js +0 -130
  43. package/build/cjs/utils/columnFilterRowsFn.js.map +0 -1
  44. package/build/cjs/utils/expandRowsFn.js +0 -38
  45. package/build/cjs/utils/expandRowsFn.js.map +0 -1
  46. package/build/cjs/utils/globalFilterRowsFn.js +0 -100
  47. package/build/cjs/utils/globalFilterRowsFn.js.map +0 -1
  48. package/build/cjs/utils/groupRowsFn.js +0 -154
  49. package/build/cjs/utils/groupRowsFn.js.map +0 -1
  50. package/build/cjs/utils/sortRowsFn.js +0 -93
  51. package/build/cjs/utils/sortRowsFn.js.map +0 -1
  52. package/build/cjs/utils.js +0 -143
  53. package/build/cjs/utils.js.map +0 -1
  54. package/build/types/aggregationTypes.d.ts +0 -22
  55. package/build/types/core.d.ts +0 -122
  56. package/build/types/createTable.d.ts +0 -35
  57. package/build/types/features/Expanding.d.ts +0 -52
  58. package/build/types/features/Filters.d.ts +0 -93
  59. package/build/types/features/Grouping.d.ts +0 -82
  60. package/build/types/features/Headers.d.ts +0 -41
  61. package/build/types/features/Ordering.d.ts +0 -19
  62. package/build/types/features/Pinning.d.ts +0 -39
  63. package/build/types/features/Sorting.d.ts +0 -75
  64. package/build/types/features/Visibility.d.ts +0 -47
  65. package/build/types/filterTypes.d.ts +0 -50
  66. package/build/types/sortTypes.d.ts +0 -17
  67. package/build/types/types.d.ts +0 -122
  68. package/build/types/utils/columnFilterRowsFn.d.ts +0 -2
  69. package/build/types/utils/expandRowsFn.d.ts +0 -2
  70. package/build/types/utils/globalFilterRowsFn.d.ts +0 -2
  71. package/build/types/utils/groupRowsFn.d.ts +0 -2
  72. package/build/types/utils/sortRowsFn.d.ts +0 -2
  73. package/build/types/utils.d.ts +0 -24
  74. package/src/aggregationTypes.ts +0 -115
  75. package/src/core.tsx +0 -1194
  76. package/src/createTable.tsx +0 -181
  77. package/src/features/Expanding.ts +0 -388
  78. package/src/features/Filters.ts +0 -707
  79. package/src/features/Grouping.ts +0 -451
  80. package/src/features/Headers.ts +0 -907
  81. package/src/features/Ordering.ts +0 -134
  82. package/src/features/Pinning.ts +0 -213
  83. package/src/features/Sorting.ts +0 -487
  84. package/src/features/Visibility.ts +0 -281
  85. package/src/features/withColumnResizing.oldts +0 -281
  86. package/src/features/withPagination.oldts +0 -208
  87. package/src/features/withRowSelection.oldts +0 -467
  88. package/src/filterTypes.ts +0 -251
  89. package/src/sortTypes.ts +0 -159
  90. package/src/types.ts +0 -285
  91. package/src/utils/columnFilterRowsFn.ts +0 -162
  92. package/src/utils/expandRowsFn.ts +0 -53
  93. package/src/utils/globalFilterRowsFn.ts +0 -129
  94. package/src/utils/groupRowsFn.ts +0 -196
  95. package/src/utils/sortRowsFn.ts +0 -115
  96. package/src/utils.tsx +0 -243
@@ -30,83 +30,5 @@ function _extends() {
30
30
  return _extends.apply(this, arguments);
31
31
  }
32
32
 
33
- function _objectWithoutPropertiesLoose(source, excluded) {
34
- if (source == null) return {};
35
- var target = {};
36
- var sourceKeys = Object.keys(source);
37
- var key, i;
38
-
39
- for (i = 0; i < sourceKeys.length; i++) {
40
- key = sourceKeys[i];
41
- if (excluded.indexOf(key) >= 0) continue;
42
- target[key] = source[key];
43
- }
44
-
45
- return target;
46
- }
47
-
48
- function _unsupportedIterableToArray(o, minLen) {
49
- if (!o) return;
50
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
51
- var n = Object.prototype.toString.call(o).slice(8, -1);
52
- if (n === "Object" && o.constructor) n = o.constructor.name;
53
- if (n === "Map" || n === "Set") return Array.from(o);
54
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
55
- }
56
-
57
- function _arrayLikeToArray(arr, len) {
58
- if (len == null || len > arr.length) len = arr.length;
59
-
60
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
61
-
62
- return arr2;
63
- }
64
-
65
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
66
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
67
- if (it) return (it = it.call(o)).next.bind(it);
68
-
69
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
70
- if (it) o = it;
71
- var i = 0;
72
- return function () {
73
- if (i >= o.length) return {
74
- done: true
75
- };
76
- return {
77
- done: false,
78
- value: o[i++]
79
- };
80
- };
81
- }
82
-
83
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
84
- }
85
-
86
- function _toPrimitive(input, hint) {
87
- if (typeof input !== "object" || input === null) return input;
88
- var prim = input[Symbol.toPrimitive];
89
-
90
- if (prim !== undefined) {
91
- var res = prim.call(input, hint || "default");
92
- if (typeof res !== "object") return res;
93
- throw new TypeError("@@toPrimitive must return a primitive value.");
94
- }
95
-
96
- return (hint === "string" ? String : Number)(input);
97
- }
98
-
99
- function _toPropertyKey(arg) {
100
- var key = _toPrimitive(arg, "string");
101
-
102
- return typeof key === "symbol" ? key : String(key);
103
- }
104
-
105
- exports.arrayLikeToArray = _arrayLikeToArray;
106
- exports.createForOfIteratorHelperLoose = _createForOfIteratorHelperLoose;
107
33
  exports["extends"] = _extends;
108
- exports.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose;
109
- exports.toPrimitive = _toPrimitive;
110
- exports.toPropertyKey = _toPropertyKey;
111
- exports.unsupportedIterableToArray = _unsupportedIterableToArray;
112
34
  //# sourceMappingURL=_rollupPluginBabelHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -12,19 +12,74 @@
12
12
 
13
13
  Object.defineProperty(exports, '__esModule', { value: true });
14
14
 
15
- var columnFilterRowsFn = require('./utils/columnFilterRowsFn.js');
16
- var globalFilterRowsFn = require('./utils/globalFilterRowsFn.js');
17
- var sortRowsFn = require('./utils/sortRowsFn.js');
18
- var groupRowsFn = require('./utils/groupRowsFn.js');
19
- var expandRowsFn = require('./utils/expandRowsFn.js');
20
- var createTable = require('./createTable.js');
15
+ var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
16
+ var React = require('react');
17
+ var tableCore = require('@tanstack/table-core');
21
18
 
19
+ function _interopNamespace(e) {
20
+ if (e && e.__esModule) return e;
21
+ var n = Object.create(null);
22
+ if (e) {
23
+ Object.keys(e).forEach(function (k) {
24
+ if (k !== 'default') {
25
+ var d = Object.getOwnPropertyDescriptor(e, k);
26
+ Object.defineProperty(n, k, d.get ? d : {
27
+ enumerable: true,
28
+ get: function () { return e[k]; }
29
+ });
30
+ }
31
+ });
32
+ }
33
+ n["default"] = e;
34
+ return Object.freeze(n);
35
+ }
22
36
 
37
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
23
38
 
24
- exports.columnFilterRowsFn = columnFilterRowsFn.columnFilterRowsFn;
25
- exports.globalFilterRowsFn = globalFilterRowsFn.globalFilterRowsFn;
26
- exports.sortRowsFn = sortRowsFn.sortRowsFn;
27
- exports.groupRowsFn = groupRowsFn.groupRowsFn;
28
- exports.expandRowsFn = expandRowsFn.expandRowsFn;
29
- exports.createTable = createTable.createTable;
39
+ function useTable(table, options) {
40
+ var _table$__options;
41
+
42
+ // Compose in the generic options to the user options
43
+ var resolvedOptions = _rollupPluginBabelHelpers["extends"]({}, (_table$__options = table.__options) != null ? _table$__options : {}, {
44
+ state: {},
45
+ // Dummy state
46
+ onStateChange: function onStateChange() {}
47
+ }, options); // Create a new table instance and store it in state
48
+
49
+
50
+ var _React$useState = React__namespace.useState(function () {
51
+ return tableCore.createTableInstance(resolvedOptions);
52
+ }),
53
+ instance = _React$useState[0]; // By default, manage table state here using the instance's initial state
54
+
55
+
56
+ var _React$useState2 = React__namespace.useState(function () {
57
+ return instance.initialState;
58
+ }),
59
+ state = _React$useState2[0],
60
+ setState = _React$useState2[1]; // Compose the default state above with any user state. This will allow the user
61
+ // to only control a subset of the state if desired.
62
+
63
+
64
+ instance.setOptions(function (prev) {
65
+ return _rollupPluginBabelHelpers["extends"]({}, prev, options, {
66
+ state: _rollupPluginBabelHelpers["extends"]({}, state, options.state),
67
+ // Similarly, we'll maintain both our internal state and any user-provided
68
+ // state.
69
+ onStateChange: function onStateChange(updater) {
70
+ setState(updater);
71
+ options.onStateChange == null ? void 0 : options.onStateChange(updater);
72
+ }
73
+ });
74
+ });
75
+ return instance;
76
+ }
77
+
78
+ exports.useTable = useTable;
79
+ Object.keys(tableCore).forEach(function (k) {
80
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
81
+ enumerable: true,
82
+ get: function () { return tableCore[k]; }
83
+ });
84
+ });
30
85
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nexport * from '@tanstack/table-core'\n\nimport {\n createTableInstance,\n _NonGenerated,\n PartialKeys,\n Options,\n TableInstance,\n PartialGenerics,\n CreateTableFactoryOptions,\n TableFactory,\n} from '@tanstack/table-core'\n\nexport function useTable<TGenerics extends PartialGenerics>(\n table: TableFactory<TGenerics>,\n options: PartialKeys<\n Omit<Options<TGenerics>, keyof CreateTableFactoryOptions<any, any, any>>,\n 'state' | 'onStateChange'\n >\n): TableInstance<TGenerics> {\n // Compose in the generic options to the user options\n const resolvedOptions = {\n ...(table.__options ?? {}),\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n ...options,\n }\n\n // Create a new table instance and store it in state\n const [instance] = React.useState(() =>\n createTableInstance<TGenerics>(resolvedOptions)\n )\n\n // By default, manage table state here using the instance's initial state\n const [state, setState] = React.useState(() => instance.initialState)\n\n // Compose the default state above with any user state. This will allow the user\n // to only control a subset of the state if desired.\n instance.setOptions(prev => ({\n ...prev,\n ...options,\n state: {\n ...state,\n ...options.state,\n },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n setState(updater)\n options.onStateChange?.(updater)\n },\n }))\n\n return instance\n}\n"],"names":["useTable","table","options","resolvedOptions","__options","state","onStateChange","React","useState","createTableInstance","instance","initialState","setState","setOptions","prev","updater"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAASA,QAAT,CACLC,KADK,EAELC,OAFK,EAMqB;AAAA;;AAC1B;AACA,MAAMC,eAAe,gEACfF,KAAK,CAACG,SADS,+BACI,EADJ;AAEnBC,IAAAA,KAAK,EAAE,EAFY;AAER;AACXC,IAAAA,aAAa,EAAE,yBAAM;AAHF,KAIhBJ,OAJgB,CAArB,CAF0B;;;AAU1B,wBAAmBK,gBAAK,CAACC,QAAN,CAAe;AAAA,WAChCC,6BAAmB,CAAYN,eAAZ,CADa;AAAA,GAAf,CAAnB;AAAA,MAAOO,QAAP,sBAV0B;;;AAe1B,yBAA0BH,gBAAK,CAACC,QAAN,CAAe;AAAA,WAAME,QAAQ,CAACC,YAAf;AAAA,GAAf,CAA1B;AAAA,MAAON,KAAP;AAAA,MAAcO,QAAd,uBAf0B;AAkB1B;;;AACAF,EAAAA,QAAQ,CAACG,UAAT,CAAoB,UAAAC,IAAI;AAAA,oDACnBA,IADmB,EAEnBZ,OAFmB;AAGtBG,MAAAA,KAAK,2CACAA,KADA,EAEAH,OAAO,CAACG,KAFR,CAHiB;AAOtB;AACA;AACAC,MAAAA,aAAa,EAAE,uBAAAS,OAAO,EAAI;AACxBH,QAAAA,QAAQ,CAACG,OAAD,CAAR;AACAb,QAAAA,OAAO,CAACI,aAAR,oBAAAJ,OAAO,CAACI,aAAR,CAAwBS,OAAxB;AACD;AAZqB;AAAA,GAAxB;AAeA,SAAOL,QAAP;AACD;;;;;;;;;;"}