@tanstack/vue-table 8.0.0-beta.3 → 8.0.0-beta.4
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/build/cjs/table-core/build/esm/index.js +47 -13
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/cjs/vue-table/src/index.js +1 -0
- package/build/cjs/vue-table/src/index.js.map +1 -1
- package/build/esm/index.js +48 -13
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +26 -26
- package/build/umd/index.development.js +48 -13
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/index.ts"],"sourcesContent":["import {\n TableGenerics,\n TableOptions,\n PartialKeys,\n Table,\n createTableInstance,\n createTableFactory,\n TableOptionsResolved,\n} from '@tanstack/table-core'\nimport { h, watchEffect, ref, VNode } from 'vue'\nimport { mergeProxy } from './merge-proxy'\n\nexport * from '@tanstack/table-core'\n\nfunction render<TProps extends {}>(\n Comp: any,\n props: TProps\n): VNode | string | number | boolean | null {\n if (!Comp) return null\n\n if (typeof Comp === 'function') {\n return h(Comp, props)\n }\n\n return Comp\n}\n\nexport const createTable = createTableFactory({ render })\n\nexport function useTableInstance<TGenerics extends TableGenerics>(\n table: Table<TGenerics>,\n options: TableOptions<TGenerics>\n) {\n const resolvedOptions: TableOptionsResolved<TGenerics> = mergeProxy(\n {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n mergeOptions(\n defaultOptions: TableOptions<TGenerics>,\n options: TableOptions<TGenerics>\n ) {\n return mergeProxy(defaultOptions, options)\n },\n },\n options\n )\n\n const instance = createTableInstance<TGenerics>(resolvedOptions)\n // can't use `reactive` because update needs to be immutable\n const state = ref(instance.initialState)\n\n watchEffect(() => {\n instance.setOptions(prev => {\n const stateProxy = new Proxy({} as typeof state.value, {\n get: (_, prop) => state.value[prop as keyof typeof state.value],\n })\n\n return mergeProxy(prev, options, {\n // merge the initialState and `options.state`\n // create a new proxy on each `setOptions` call\n // and get the value from state on each property access\n state: mergeProxy(stateProxy, options.state ?? {}),\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: (updater: any) => {\n if (updater instanceof Function) {\n state.value = updater(state.value)\n } else {\n state.value = updater\n }\n\n options.onStateChange?.(updater)\n },\n })\n })\n })\n\n // onBeforeUpdate(() => {\n // instance.willUpdate()\n // })\n\n return instance\n}\n"],"names":["render","Comp","props","h","createTable","createTableFactory","useTableInstance","table","options","resolvedOptions","mergeProxy","state","onStateChange","mergeOptions","defaultOptions","instance","createTableInstance","ref","initialState","watchEffect","setOptions","prev","stateProxy","Proxy","get","_","prop","value","updater","Function"],"mappings":";;;;;;;;;;;;;;;;;;AAcA,SAASA,MAAT,CACEC,IADF,EAEEC,KAFF,EAG4C;AAC1C,EAAA,IAAI,CAACD,IAAL,EAAW,OAAO,IAAP,CAAA;;AAEX,EAAA,IAAI,OAAOA,IAAP,KAAgB,UAApB,EAAgC;AAC9B,IAAA,OAAOE,KAAC,CAACF,IAAD,EAAOC,KAAP,CAAR,CAAA;AACD,GAAA;;AAED,EAAA,OAAOD,IAAP,CAAA;AACD,CAAA;;AAEYG,MAAAA,WAAW,GAAGC,wBAAkB,CAAC;AAAEL,EAAAA,MAAAA;AAAF,CAAD,EAAtC;AAEA,SAASM,gBAAT,CACLC,KADK,EAELC,OAFK,EAGL;AACA,EAAMC,MAAAA,eAAgD,GAAGC,qBAAU,CACjE,EACE,GAAGH,KAAK,CAACC,OADX;AAEEG,IAAAA,KAAK,EAAE,EAFT;AAEa;AACXC,IAAAA,aAAa,EAAE,MAAM,EAHvB;AAG2B;AACzBZ,IAAAA,MAJF
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/index.ts"],"sourcesContent":["import {\n TableGenerics,\n TableOptions,\n PartialKeys,\n Table,\n createTableInstance,\n createTableFactory,\n TableOptionsResolved,\n} from '@tanstack/table-core'\nimport { h, watchEffect, ref, VNode } from 'vue'\nimport { mergeProxy } from './merge-proxy'\n\nexport * from '@tanstack/table-core'\n\nfunction render<TProps extends {}>(\n Comp: any,\n props: TProps\n): VNode | string | number | boolean | null {\n if (!Comp) return null\n\n if (typeof Comp === 'function') {\n return h(Comp, props)\n }\n\n return Comp\n}\n\nexport const createTable = createTableFactory({ render })\n\nexport function useTableInstance<TGenerics extends TableGenerics>(\n table: Table<TGenerics>,\n options: TableOptions<TGenerics>\n) {\n const resolvedOptions: TableOptionsResolved<TGenerics> = mergeProxy(\n {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n renderFallbackValue: null,\n mergeOptions(\n defaultOptions: TableOptions<TGenerics>,\n options: TableOptions<TGenerics>\n ) {\n return mergeProxy(defaultOptions, options)\n },\n },\n options\n )\n\n const instance = createTableInstance<TGenerics>(resolvedOptions)\n // can't use `reactive` because update needs to be immutable\n const state = ref(instance.initialState)\n\n watchEffect(() => {\n instance.setOptions(prev => {\n const stateProxy = new Proxy({} as typeof state.value, {\n get: (_, prop) => state.value[prop as keyof typeof state.value],\n })\n\n return mergeProxy(prev, options, {\n // merge the initialState and `options.state`\n // create a new proxy on each `setOptions` call\n // and get the value from state on each property access\n state: mergeProxy(stateProxy, options.state ?? {}),\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: (updater: any) => {\n if (updater instanceof Function) {\n state.value = updater(state.value)\n } else {\n state.value = updater\n }\n\n options.onStateChange?.(updater)\n },\n })\n })\n })\n\n // onBeforeUpdate(() => {\n // instance.willUpdate()\n // })\n\n return instance\n}\n"],"names":["render","Comp","props","h","createTable","createTableFactory","useTableInstance","table","options","resolvedOptions","mergeProxy","state","onStateChange","renderFallbackValue","mergeOptions","defaultOptions","instance","createTableInstance","ref","initialState","watchEffect","setOptions","prev","stateProx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AAJ,KAAahB,KAAK,CAACiB,KAAN,CAAYD,IAAZ,CAAA;AADmC,OAApC,CAAnB,CAAA;AAIA,MAAA,OAAOjB,qBAAU,CAACY,IAAD,EAAOd,OAAP,EAAgB;AAC/B;AACA;AACA;AACAG,QAAAA,KAAK,EAAED,qBAAU,CAACa,UAAD,EAAaf,CAAAA,cAAAA,GAAAA,OAAO,CAACG,KAArB,KAA8B,IAAA,GAAA,cAAA,GAAA,EAA9B,CAJc;AAK/B;AACA;AACAC,QAAAA,aAAa,EAAGiB,OAAD,IAAkB;AAC/B,UAAIA,IAAAA,OAAO,YAAYC,QAAvB,EAAiC;AAC/BnB,YAAAA,KAAK,CAACiB,KAAN,GAAcC,OAAO,CAAClB,KAAK,CAACiB,KAAP,CAArB,CAAA;AACD,WAFD,MAEO;AACLjB,YAAAA,KAAK,CAACiB,KAAN,GAAcC,OAAd,CAAA;AACD,WAAA;;AAEDrB,UAAAA,OAAO,CAACI,aAAR,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAJ,OAAO,CAACI,aAAR,CAAwBiB,OAAxB,CAAA,CAAA;AACD,SAAA;AAf8B,OAAhB,CAAjB,CAAA;AAiBD,KAtBD,CAAA,CAAA;AAuBD,GAxBU,CAAX,CAtBA;AAiDA;AACA;;AAEA,EAAA,OAAOb,QAAP,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/esm/index.js
CHANGED
|
@@ -1533,6 +1533,12 @@ const Grouping = {
|
|
|
1533
1533
|
};
|
|
1534
1534
|
},
|
|
1535
1535
|
createCell: (cell, column, row, instance) => {
|
|
1536
|
+
const getRenderValue = () => {
|
|
1537
|
+
var _cell$getValue;
|
|
1538
|
+
|
|
1539
|
+
return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : instance.options.renderFallbackValue;
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1536
1542
|
return {
|
|
1537
1543
|
getIsGrouped: () => column.getIsGrouped() && column.id === row.groupingColumnId,
|
|
1538
1544
|
getIsPlaceholder: () => !cell.getIsGrouped() && column.getIsGrouped(),
|
|
@@ -1542,15 +1548,19 @@ const Grouping = {
|
|
|
1542
1548
|
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
|
|
1543
1549
|
},
|
|
1544
1550
|
renderAggregatedCell: () => {
|
|
1545
|
-
|
|
1551
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1552
|
+
if (!column.columnDef.aggregatedCell) {
|
|
1553
|
+
console.warn('A columnDef.aggregatedCell template is recommended for displaying aggregated values.');
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1546
1556
|
|
|
1547
|
-
const template =
|
|
1557
|
+
const template = column.columnDef.aggregatedCell || column.columnDef.cell;
|
|
1548
1558
|
return template ? instance._render(template, {
|
|
1549
1559
|
instance,
|
|
1550
1560
|
column,
|
|
1551
1561
|
row,
|
|
1552
1562
|
cell,
|
|
1553
|
-
getValue:
|
|
1563
|
+
getValue: getRenderValue
|
|
1554
1564
|
}) : null;
|
|
1555
1565
|
}
|
|
1556
1566
|
};
|
|
@@ -2533,8 +2543,10 @@ const Sorting = {
|
|
|
2533
2543
|
// })
|
|
2534
2544
|
// return
|
|
2535
2545
|
// }
|
|
2546
|
+
// this needs to be outside of instance.setSorting to be in sync with rerender
|
|
2547
|
+
const nextSortingOrder = column.getNextSortingOrder();
|
|
2536
2548
|
instance.setSorting(old => {
|
|
2537
|
-
var
|
|
2549
|
+
var _instance$options$ena, _instance$options$ena2;
|
|
2538
2550
|
|
|
2539
2551
|
// Find any existing sorting for this column
|
|
2540
2552
|
const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
@@ -2559,30 +2571,29 @@ const Sorting = {
|
|
|
2559
2571
|
} else {
|
|
2560
2572
|
sortAction = 'replace';
|
|
2561
2573
|
}
|
|
2562
|
-
}
|
|
2574
|
+
} // Handle toggle states that will remove the sorting
|
|
2563
2575
|
|
|
2564
|
-
const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
|
|
2565
2576
|
|
|
2566
2577
|
if (sortAction === 'toggle' && ( // Must be toggling
|
|
2567
2578
|
(_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
|
|
2568
2579
|
!hasDescDefined && ( // Must not be setting desc
|
|
2569
|
-
multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) &&
|
|
2570
|
-
|
|
2571
|
-
|
|
2580
|
+
multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && // If multi, don't allow if enableMultiRemove
|
|
2581
|
+
!nextSortingOrder // Finally, detect if it should indeed be removed
|
|
2582
|
+
) {
|
|
2572
2583
|
sortAction = 'remove';
|
|
2573
2584
|
}
|
|
2574
2585
|
|
|
2575
2586
|
if (sortAction === 'replace') {
|
|
2576
2587
|
newSorting = [{
|
|
2577
2588
|
id: column.id,
|
|
2578
|
-
desc: hasDescDefined ? desc :
|
|
2589
|
+
desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
|
|
2579
2590
|
}];
|
|
2580
2591
|
} else if (sortAction === 'add' && old != null && old.length) {
|
|
2581
2592
|
var _instance$options$max;
|
|
2582
2593
|
|
|
2583
2594
|
newSorting = [...old, {
|
|
2584
2595
|
id: column.id,
|
|
2585
|
-
desc: hasDescDefined ? desc :
|
|
2596
|
+
desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
|
|
2586
2597
|
}]; // Take latest n columns
|
|
2587
2598
|
|
|
2588
2599
|
newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
|
|
@@ -2591,7 +2602,7 @@ const Sorting = {
|
|
|
2591
2602
|
newSorting = old.map(d => {
|
|
2592
2603
|
if (d.id === column.id) {
|
|
2593
2604
|
return { ...d,
|
|
2594
|
-
desc: hasDescDefined ? desc :
|
|
2605
|
+
desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
|
|
2595
2606
|
};
|
|
2596
2607
|
}
|
|
2597
2608
|
|
|
@@ -2604,6 +2615,23 @@ const Sorting = {
|
|
|
2604
2615
|
return newSorting;
|
|
2605
2616
|
});
|
|
2606
2617
|
},
|
|
2618
|
+
getNextSortingOrder: () => {
|
|
2619
|
+
var _ref2, _column$columnDef$sor;
|
|
2620
|
+
|
|
2621
|
+
const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc';
|
|
2622
|
+
const firstSortDirection = sortDescFirst ? 'desc' : 'asc';
|
|
2623
|
+
const isSorted = column.getIsSorted();
|
|
2624
|
+
|
|
2625
|
+
if (!isSorted) {
|
|
2626
|
+
return firstSortDirection;
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2629
|
+
if (isSorted === firstSortDirection) {
|
|
2630
|
+
return isSorted === 'desc' ? 'asc' : 'desc';
|
|
2631
|
+
} else {
|
|
2632
|
+
return false;
|
|
2633
|
+
}
|
|
2634
|
+
},
|
|
2607
2635
|
getCanSort: () => {
|
|
2608
2636
|
var _column$columnDef$ena, _instance$options$ena3;
|
|
2609
2637
|
|
|
@@ -3053,6 +3081,12 @@ function createTable$1(_, __, options) {
|
|
|
3053
3081
|
}
|
|
3054
3082
|
|
|
3055
3083
|
function createCell(instance, row, column, columnId) {
|
|
3084
|
+
const getRenderValue = () => {
|
|
3085
|
+
var _cell$getValue;
|
|
3086
|
+
|
|
3087
|
+
return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : instance.options.renderFallbackValue;
|
|
3088
|
+
};
|
|
3089
|
+
|
|
3056
3090
|
const cell = {
|
|
3057
3091
|
id: row.id + "_" + column.id,
|
|
3058
3092
|
row,
|
|
@@ -3064,7 +3098,7 @@ function createCell(instance, row, column, columnId) {
|
|
|
3064
3098
|
column,
|
|
3065
3099
|
row,
|
|
3066
3100
|
cell: cell,
|
|
3067
|
-
getValue:
|
|
3101
|
+
getValue: getRenderValue
|
|
3068
3102
|
}) : null;
|
|
3069
3103
|
}
|
|
3070
3104
|
};
|
|
@@ -3912,6 +3946,7 @@ function useTableInstance(table, options) {
|
|
|
3912
3946
|
onStateChange: () => {},
|
|
3913
3947
|
// noop
|
|
3914
3948
|
render,
|
|
3949
|
+
renderFallbackValue: null,
|
|
3915
3950
|
|
|
3916
3951
|
mergeOptions(defaultOptions, options) {
|
|
3917
3952
|
return mergeProxy(defaultOptions, options);
|