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

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 +96 -12
  4. package/build/cjs/index.js.map +1 -1
  5. package/build/esm/index.js +40 -3330
  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 +13 -7
  10. package/build/umd/index.development.js +50 -3332
  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 +105 -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,103 @@
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
+ var render = function render(Comp, props) {
40
+ return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__namespace.createElement(Comp, props) : Comp;
41
+ };
42
+
43
+ function isReactComponent(component) {
44
+ return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
45
+ }
46
+
47
+ function isClassComponent(component) {
48
+ return typeof component === 'function' && function () {
49
+ var proto = Object.getPrototypeOf(component);
50
+ return proto.prototype && proto.prototype.isReactComponent;
51
+ }();
52
+ }
53
+
54
+ function isExoticComponent(component) {
55
+ return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
56
+ }
57
+
58
+ var _init = tableCore.init({
59
+ render: render
60
+ }),
61
+ createTable = _init.createTable,
62
+ createTableFactory = _init.createTableFactory;
63
+ function useTable(table, options) {
64
+ var _table$__options;
65
+
66
+ // Compose in the generic options to the user options
67
+ var resolvedOptions = _rollupPluginBabelHelpers["extends"]({}, (_table$__options = table.__options) != null ? _table$__options : {}, {
68
+ state: {},
69
+ // Dummy state
70
+ onStateChange: function onStateChange() {},
71
+ // noop
72
+ render: render
73
+ }, options); // Create a new table instance and store it in state
74
+
75
+
76
+ var _React$useState = React__namespace.useState(function () {
77
+ return tableCore.createTableInstance(resolvedOptions);
78
+ }),
79
+ instance = _React$useState[0]; // By default, manage table state here using the instance's initial state
80
+
81
+
82
+ var _React$useState2 = React__namespace.useState(function () {
83
+ return instance.initialState;
84
+ }),
85
+ state = _React$useState2[0],
86
+ setState = _React$useState2[1]; // Compose the default state above with any user state. This will allow the user
87
+ // to only control a subset of the state if desired.
88
+
89
+
90
+ instance.setOptions(function (prev) {
91
+ return _rollupPluginBabelHelpers["extends"]({}, prev, options, {
92
+ state: _rollupPluginBabelHelpers["extends"]({}, state, options.state),
93
+ // Similarly, we'll maintain both our internal state and any user-provided
94
+ // state.
95
+ onStateChange: function onStateChange(updater) {
96
+ setState(updater);
97
+ options.onStateChange == null ? void 0 : options.onStateChange(updater);
98
+ }
99
+ });
100
+ });
101
+ return instance;
102
+ }
103
+
104
+ exports.createTable = createTable;
105
+ exports.createTableFactory = createTableFactory;
106
+ exports.render = render;
107
+ exports.useTable = useTable;
108
+ Object.keys(tableCore).forEach(function (k) {
109
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
110
+ enumerable: true,
111
+ get: function () { return tableCore[k]; }
112
+ });
113
+ });
30
114
  //# 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 Table,\n init,\n AnyGenerics,\n} from '@tanstack/table-core'\n\nexport type Renderable<TProps> =\n | React.ReactNode\n | React.FunctionComponent<TProps>\n | React.Component<TProps>\n\nexport const render = <TProps extends {}>(\n Comp: Renderable<TProps>,\n props: TProps\n): React.ReactNode =>\n !Comp ? null : isReactComponent(Comp) ? <Comp {...props} /> : Comp\n\nexport type Render = typeof render\n\nfunction isReactComponent(component: unknown): component is React.FC {\n return (\n isClassComponent(component) ||\n typeof component === 'function' ||\n isExoticComponent(component)\n )\n}\n\nfunction isClassComponent(component: any) {\n return (\n typeof component === 'function' &&\n (() => {\n const proto = Object.getPrototypeOf(component)\n return proto.prototype && proto.prototype.isReactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description)\n )\n}\n\nconst { createTable, createTableFactory } = init({ render })\n\nexport { createTable, createTableFactory }\n\nexport function useTable<TGenerics extends AnyGenerics>(\n table: Table<TGenerics>,\n options: PartialKeys<\n Omit<\n Options<TGenerics>,\n keyof CreateTableFactoryOptions<any, any, any, any>\n >,\n 'state' | 'onStateChange'\n >\n): TableInstance<TGenerics> {\n // Compose in the generic options to the user options\n const resolvedOptions: Options<TGenerics> = {\n ...(table.__options ?? {}),\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\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":["render","Comp","props","isReactComponent","React","component","isClassComponent","isExoticComponent","proto","Object","getPrototypeOf","prototype","$$typeof","includes","description","init","createTable","createTableFactory","useTable","table","options","resolvedOptions","__options","state","onStateChange","useState","createTableInstance","instance","initialState","setState","setOptions","prev","updater"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqBaA,MAAM,GAAG,SAATA,MAAS,CACpBC,IADoB,EAEpBC,KAFoB;AAAA,SAIpB,CAACD,IAAD,GAAQ,IAAR,GAAeE,gBAAgB,CAACF,IAAD,CAAhB,gBAAyBG,+BAAC,IAAD,EAAUF,KAAV,CAAzB,GAA+CD,IAJ1C;AAAA;;AAQtB,SAASE,gBAAT,CAA0BE,SAA1B,EAAqE;AACnE,SACEC,gBAAgB,CAACD,SAAD,CAAhB,IACA,OAAOA,SAAP,KAAqB,UADrB,IAEAE,iBAAiB,CAACF,SAAD,CAHnB;AAKD;;AAED,SAASC,gBAAT,CAA0BD,SAA1B,EAA0C;AACxC,SACE,OAAOA,SAAP,KAAqB,UAArB,IACC,YAAM;AACL,QAAMG,KAAK,GAAGC,MAAM,CAACC,cAAP,CAAsBL,SAAtB,CAAd;AACA,WAAOG,KAAK,CAACG,SAAN,IAAmBH,KAAK,CAACG,SAAN,CAAgBR,gBAA1C;AACD,GA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