@tanstack/svelte-table 8.0.0-alpha.73 → 8.0.0-alpha.77
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/svelte-table/src/index.js +38 -9
- package/build/cjs/svelte-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +40 -141
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +77 -150
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +48 -42
- package/build/types/index.d.ts +1 -1
- package/build/umd/index.development.js +77 -150
- 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 +4 -4
- package/src/index.ts +39 -7
package/build/esm/index.js
CHANGED
|
@@ -2714,8 +2714,10 @@ const Headers = {
|
|
|
2714
2714
|
}
|
|
2715
2715
|
}),
|
|
2716
2716
|
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
2717
|
-
|
|
2718
|
-
|
|
2717
|
+
var _left$map$filter;
|
|
2718
|
+
|
|
2719
|
+
const orderedLeafColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
2720
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
2719
2721
|
}, {
|
|
2720
2722
|
key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
|
|
2721
2723
|
debug: () => {
|
|
@@ -2725,8 +2727,10 @@ const Headers = {
|
|
|
2725
2727
|
}
|
|
2726
2728
|
}),
|
|
2727
2729
|
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
+
var _right$map$filter;
|
|
2731
|
+
|
|
2732
|
+
const orderedLeafColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
2733
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
2730
2734
|
}, {
|
|
2731
2735
|
key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
|
|
2732
2736
|
debug: () => {
|
|
@@ -3037,7 +3041,6 @@ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
|
3037
3041
|
// data: Batch[]
|
|
3038
3042
|
// facets: Batch[]
|
|
3039
3043
|
// }
|
|
3040
|
-
// export type TaskPriority = keyof CoreBatches
|
|
3041
3044
|
function createTableInstance$1(options) {
|
|
3042
3045
|
var _options$initialState;
|
|
3043
3046
|
|
|
@@ -3076,64 +3079,7 @@ function createTableInstance$1(options) {
|
|
|
3076
3079
|
});
|
|
3077
3080
|
|
|
3078
3081
|
const queued = [];
|
|
3079
|
-
let queuedTimeout = false;
|
|
3080
|
-
// let working = false
|
|
3081
|
-
// let latestCallback: ReturnType<typeof requestIdleCallback>
|
|
3082
|
-
// let batchUid = 0
|
|
3083
|
-
// const onProgress = () => {}
|
|
3084
|
-
// const getBatch = () => {
|
|
3085
|
-
// instance.batches.data = instance.batches.data.filter(d => d.tasks.length)
|
|
3086
|
-
// instance.batches.facets = instance.batches.facets.filter(
|
|
3087
|
-
// d => d.tasks.length
|
|
3088
|
-
// )
|
|
3089
|
-
// return (
|
|
3090
|
-
// instance.batches.data.find(d => d.tasks.length) ??
|
|
3091
|
-
// instance.batches.facets.find(d => d.tasks.length)
|
|
3092
|
-
// )
|
|
3093
|
-
// }
|
|
3094
|
-
// const startWorkLoop = () => {
|
|
3095
|
-
// working = true
|
|
3096
|
-
// const workLoop = (deadline: IdleDeadline) => {
|
|
3097
|
-
// const batch = getBatch()
|
|
3098
|
-
// if (!batch) {
|
|
3099
|
-
// working = false
|
|
3100
|
-
// return
|
|
3101
|
-
// }
|
|
3102
|
-
// // Prioritize tasks
|
|
3103
|
-
// while (deadline.timeRemaining() > 0 && batch.tasks.length) {
|
|
3104
|
-
// batch.tasks.shift()!()
|
|
3105
|
-
// }
|
|
3106
|
-
// onProgress()
|
|
3107
|
-
// if (working) {
|
|
3108
|
-
// latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
|
|
3109
|
-
// }
|
|
3110
|
-
// }
|
|
3111
|
-
// latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
|
|
3112
|
-
// }
|
|
3113
|
-
// const startWork = () => {
|
|
3114
|
-
// if (getBatch() && !working) {
|
|
3115
|
-
// if (
|
|
3116
|
-
// (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
|
|
3117
|
-
// instance.options.debugTable
|
|
3118
|
-
// ) {
|
|
3119
|
-
// console.info('Starting work...')
|
|
3120
|
-
// }
|
|
3121
|
-
// startWorkLoop()
|
|
3122
|
-
// }
|
|
3123
|
-
// }
|
|
3124
|
-
// const stopWork = () => {
|
|
3125
|
-
// if (working) {
|
|
3126
|
-
// if (
|
|
3127
|
-
// (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
|
|
3128
|
-
// instance.options.debugTable
|
|
3129
|
-
// ) {
|
|
3130
|
-
// console.info('Stopping work...')
|
|
3131
|
-
// }
|
|
3132
|
-
// working = false
|
|
3133
|
-
// cancelIdleCallback(latestCallback)
|
|
3134
|
-
// }
|
|
3135
|
-
// }
|
|
3136
|
-
|
|
3082
|
+
let queuedTimeout = false;
|
|
3137
3083
|
const midInstance = { ...instance,
|
|
3138
3084
|
// init: () => {
|
|
3139
3085
|
// startWork()
|
|
@@ -3166,39 +3112,6 @@ function createTableInstance$1(options) {
|
|
|
3166
3112
|
}));
|
|
3167
3113
|
}
|
|
3168
3114
|
},
|
|
3169
|
-
// batches: {
|
|
3170
|
-
// data: [],
|
|
3171
|
-
// facets: [],
|
|
3172
|
-
// },
|
|
3173
|
-
// createBatch: priority => {
|
|
3174
|
-
// const batchId = batchUid++
|
|
3175
|
-
// let canceled: boolean
|
|
3176
|
-
// const batch: Batch = {
|
|
3177
|
-
// id: batchId,
|
|
3178
|
-
// priority,
|
|
3179
|
-
// tasks: [],
|
|
3180
|
-
// schedule: cb => {
|
|
3181
|
-
// if (canceled) return
|
|
3182
|
-
// batch.tasks.push(cb)
|
|
3183
|
-
// if (!working && !workScheduled) {
|
|
3184
|
-
// workScheduled = true
|
|
3185
|
-
// instance.queue(() => {
|
|
3186
|
-
// workScheduled = false
|
|
3187
|
-
// instance.setState(old => ({ ...old }))
|
|
3188
|
-
// })
|
|
3189
|
-
// }
|
|
3190
|
-
// },
|
|
3191
|
-
// cancel: () => {
|
|
3192
|
-
// canceled = true
|
|
3193
|
-
// batch.tasks = []
|
|
3194
|
-
// instance.batches[priority] = instance.batches[priority].filter(
|
|
3195
|
-
// b => b.id !== batchId
|
|
3196
|
-
// )
|
|
3197
|
-
// },
|
|
3198
|
-
// }
|
|
3199
|
-
// instance.batches[priority].push(batch)
|
|
3200
|
-
// return batch
|
|
3201
|
-
// },
|
|
3202
3115
|
reset: () => {
|
|
3203
3116
|
instance.setState(instance.initialState);
|
|
3204
3117
|
},
|
|
@@ -3309,69 +3222,55 @@ function createTable$1(_, __, options) {
|
|
|
3309
3222
|
|
|
3310
3223
|
function getCoreRowModel() {
|
|
3311
3224
|
return instance => memo(() => [instance.options.data], data => {
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3225
|
+
const rowModel = {
|
|
3226
|
+
rows: [],
|
|
3227
|
+
flatRows: [],
|
|
3228
|
+
rowsById: {}
|
|
3229
|
+
};
|
|
3230
|
+
let rows;
|
|
3231
|
+
let row;
|
|
3232
|
+
let originalRow;
|
|
3317
3233
|
|
|
3318
|
-
const
|
|
3234
|
+
const accessRows = function (originalRows, depth, parent) {
|
|
3319
3235
|
if (depth === void 0) {
|
|
3320
3236
|
depth = 0;
|
|
3321
3237
|
}
|
|
3322
3238
|
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
if (!id) {
|
|
3326
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3327
|
-
throw new Error("getRowId expected an ID, but got " + id);
|
|
3328
|
-
}
|
|
3329
|
-
}
|
|
3330
|
-
|
|
3331
|
-
const values = {};
|
|
3332
|
-
|
|
3333
|
-
for (let i = 0; i < leafColumns.length; i++) {
|
|
3334
|
-
const column = leafColumns[i];
|
|
3335
|
-
|
|
3336
|
-
if (column && column.accessorFn) {
|
|
3337
|
-
values[column.id] = column.accessorFn(originalRow, rowIndex);
|
|
3338
|
-
}
|
|
3339
|
-
} // Make the row
|
|
3239
|
+
rows = [];
|
|
3340
3240
|
|
|
3241
|
+
for (let i = 0; i < originalRows.length; i++) {
|
|
3242
|
+
originalRow = originalRows[i]; // This could be an expensive check at scale, so we should move it somewhere else, but where?
|
|
3243
|
+
// if (!id) {
|
|
3244
|
+
// if (process.env.NODE_ENV !== 'production') {
|
|
3245
|
+
// throw new Error(`getRowId expected an ID, but got ${id}`)
|
|
3246
|
+
// }
|
|
3247
|
+
// }
|
|
3248
|
+
// Make the row
|
|
3341
3249
|
|
|
3342
|
-
|
|
3250
|
+
row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3343
3251
|
|
|
3344
|
-
|
|
3252
|
+
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3345
3253
|
|
|
3346
|
-
|
|
3254
|
+
rowModel.rowsById[row.id] = row; // Push instance row into parent
|
|
3347
3255
|
|
|
3348
|
-
|
|
3256
|
+
rows.push(row); // Get the original subrows
|
|
3349
3257
|
|
|
3350
|
-
|
|
3351
|
-
|
|
3258
|
+
if (instance.options.getSubRows) {
|
|
3259
|
+
var _row$originalSubRows;
|
|
3352
3260
|
|
|
3353
|
-
|
|
3354
|
-
row.originalSubRows = originalSubRows;
|
|
3355
|
-
const subRows = [];
|
|
3261
|
+
row.originalSubRows = instance.options.getSubRows(originalRow, i); // Then recursively access them
|
|
3356
3262
|
|
|
3357
|
-
|
|
3358
|
-
|
|
3263
|
+
if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
|
|
3264
|
+
row.subRows = accessRows(row.originalSubRows, depth + 1, row);
|
|
3359
3265
|
}
|
|
3360
|
-
|
|
3361
|
-
row.subRows = subRows;
|
|
3362
3266
|
}
|
|
3363
3267
|
}
|
|
3364
|
-
};
|
|
3365
|
-
|
|
3366
|
-
for (let i = 0; i < data.length; i++) {
|
|
3367
|
-
accessRow(data[i], i, 0, rows);
|
|
3368
|
-
}
|
|
3369
3268
|
|
|
3370
|
-
|
|
3371
|
-
rows,
|
|
3372
|
-
flatRows,
|
|
3373
|
-
rowsById
|
|
3269
|
+
return rows;
|
|
3374
3270
|
};
|
|
3271
|
+
|
|
3272
|
+
rowModel.rows = accessRows(data);
|
|
3273
|
+
return rowModel;
|
|
3375
3274
|
}, {
|
|
3376
3275
|
key: process.env.NODE_ENV === 'development' && 'getRowModel',
|
|
3377
3276
|
debug: () => {
|
|
@@ -4107,18 +4006,46 @@ function renderServer(Comp, props) {
|
|
|
4107
4006
|
|
|
4108
4007
|
const renderComponent = typeof window === 'undefined' ? renderServer : renderClient;
|
|
4109
4008
|
|
|
4110
|
-
function
|
|
4111
|
-
|
|
4009
|
+
function isSvelteServerComponent(component) {
|
|
4010
|
+
return typeof component === 'object' && typeof component.$$render === 'function' && typeof component.render === 'function';
|
|
4011
|
+
}
|
|
4012
|
+
|
|
4013
|
+
function isSvelteClientComponent(component) {
|
|
4014
|
+
return component.prototype instanceof SvelteComponent;
|
|
4015
|
+
}
|
|
4112
4016
|
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
return
|
|
4017
|
+
function isSvelteComponent(component) {
|
|
4018
|
+
if (typeof document === 'undefined') {
|
|
4019
|
+
return isSvelteServerComponent(component);
|
|
4116
4020
|
} else {
|
|
4117
|
-
return
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4021
|
+
return isSvelteClientComponent(component);
|
|
4022
|
+
}
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
function wrapInPlaceholder(content) {
|
|
4026
|
+
return renderComponent(Placeholder, {
|
|
4027
|
+
content
|
|
4028
|
+
});
|
|
4029
|
+
}
|
|
4030
|
+
|
|
4031
|
+
function render(component, props) {
|
|
4032
|
+
if (!component) return null;
|
|
4033
|
+
|
|
4034
|
+
if (isSvelteComponent(component)) {
|
|
4035
|
+
return renderComponent(component, props);
|
|
4036
|
+
}
|
|
4037
|
+
|
|
4038
|
+
if (typeof component === 'function') {
|
|
4039
|
+
const result = component(props);
|
|
4040
|
+
|
|
4041
|
+
if (isSvelteComponent(result)) {
|
|
4042
|
+
return result;
|
|
4043
|
+
}
|
|
4044
|
+
|
|
4045
|
+
return wrapInPlaceholder(result);
|
|
4046
|
+
}
|
|
4121
4047
|
|
|
4048
|
+
return wrapInPlaceholder(component);
|
|
4122
4049
|
}
|
|
4123
4050
|
const createTable = createTableFactory({
|
|
4124
4051
|
render
|