@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.
@@ -14,21 +14,50 @@ Object.defineProperty(exports, '__esModule', { value: true });
14
14
 
15
15
  var index = require('../../table-core/build/esm/index.js');
16
16
  var placeholder = require('./placeholder.svelte.js');
17
+ var internal = require('svelte/internal');
17
18
  var store = require('svelte/store');
18
19
  var renderComponent = require('./render-component.js');
19
20
 
20
- function render(Comp, props) {
21
- if (!Comp) return null;
21
+ function isSvelteServerComponent(component) {
22
+ return typeof component === 'object' && typeof component.$$render === 'function' && typeof component.render === 'function';
23
+ }
24
+
25
+ function isSvelteClientComponent(component) {
26
+ return component.prototype instanceof internal.SvelteComponent;
27
+ }
22
28
 
23
- if (Comp instanceof Function) {
24
- let res = Comp(props);
25
- return res;
29
+ function isSvelteComponent(component) {
30
+ if (typeof document === 'undefined') {
31
+ return isSvelteServerComponent(component);
26
32
  } else {
27
- return renderComponent.renderComponent(placeholder["default"], {
28
- content: Comp
29
- });
30
- } // return Comp
33
+ return isSvelteClientComponent(component);
34
+ }
35
+ }
36
+
37
+ function wrapInPlaceholder(content) {
38
+ return renderComponent.renderComponent(placeholder["default"], {
39
+ content
40
+ });
41
+ }
42
+
43
+ function render(component, props) {
44
+ if (!component) return null;
45
+
46
+ if (isSvelteComponent(component)) {
47
+ return renderComponent.renderComponent(component, props);
48
+ }
49
+
50
+ if (typeof component === 'function') {
51
+ const result = component(props);
52
+
53
+ if (isSvelteComponent(result)) {
54
+ return result;
55
+ }
56
+
57
+ return wrapInPlaceholder(result);
58
+ }
31
59
 
60
+ return wrapInPlaceholder(component);
32
61
  }
33
62
  const createTable = index.createTableFactory({
34
63
  render
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/index.ts"],"sourcesContent":["import {\n createTableFactory,\n createTableInstance as coreCreateTableInstance,\n PartialKeys,\n Table,\n TableGenerics,\n TableOptions,\n} from '@tanstack/table-core'\nimport Placeholder from './placeholder.svelte'\nimport { readable, writable, derived, Readable, get } from 'svelte/store'\nimport { renderComponent } from './render-component'\n\nexport { renderComponent } from './render-component'\n\nexport * from '@tanstack/table-core'\n\nexport function render(Comp: any, props: any) {\n if (!Comp) return null\n\n if (Comp instanceof Function) {\n let res = Comp(props)\n return res\n } else {\n return renderComponent(Placeholder, { content: Comp })\n }\n\n // return Comp\n}\n\nexport const createTable = createTableFactory({ render })\n\ntype ReadableOrVal<T> = T | Readable<T>\n\nexport function createTableInstance<TGenerics extends TableGenerics>(\n table: Table<TGenerics>,\n options: ReadableOrVal<\n PartialKeys<\n Omit<TableOptions<TGenerics>, 'render'>,\n 'state' | 'onStateChange'\n >\n >\n) {\n let optionsStore: Readable<\n PartialKeys<\n Omit<TableOptions<TGenerics>, 'render'>,\n 'state' | 'onStateChange'\n >\n >\n\n if ('subscribe' in options) {\n optionsStore = options\n } else {\n optionsStore = readable(options)\n }\n\n let resolvedOptions: TableOptions<TGenerics> = {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n ...get(optionsStore),\n }\n\n let instance = coreCreateTableInstance(resolvedOptions)\n\n let stateStore = writable(/** @type {number} */ instance.initialState)\n // combine stores\n let stateOptionsStore = derived([stateStore, optionsStore], s => s)\n const instanceReadable = readable(instance, function start(set) {\n const unsubscribe = stateOptionsStore.subscribe(([state, options]) => {\n instance.setOptions(prev => {\n return {\n ...prev,\n ...options,\n state: { ...state, ...options.state },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n if (updater instanceof Function) {\n stateStore.update(updater)\n } else {\n stateStore.set(updater)\n }\n\n resolvedOptions.onStateChange?.(updater)\n },\n }\n })\n\n // it didn't seem to rerender without setting the instance\n set(instance)\n })\n\n return function stop() {\n unsubscribe()\n }\n })\n\n return instanceReadable\n}\n"],"names":["render","Comp","props","Function","res","renderComponent","Placeholder","content","createTable","createTableFactory","createTableInstance","table","options","optionsStore","readable","resolvedOptions","state","onStateChange","get","instance","coreCreateTableInstance","stateStore","writable","initialState","stateOptionsStore","derived","s","instanceReadable","start","set","unsubscribe","subscribe","setOptions","prev","updater","update","stop"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBO,SAASA,MAAT,CAAgBC,IAAhB,EAA2BC,KAA3B,EAAuC;AAC5C,EAAA,IAAI,CAACD,IAAL,EAAW,OAAO,IAAP,CAAA;;AAEX,EAAIA,IAAAA,IAAI,YAAYE,QAApB,EAA8B;AAC5B,IAAA,IAAIC,GAAG,GAAGH,IAAI,CAACC,KAAD,CAAd,CAAA;AACA,IAAA,OAAOE,GAAP,CAAA;AACD,GAHD,MAGO;AACL,IAAOC,OAAAA,+BAAe,CAACC,sBAAD,EAAc;AAAEC,MAAAA,OAAO,EAAEN,IAAAA;AAAX,KAAd,CAAtB,CAAA;AACD,GAR2C;;AAW7C,CAAA;AAEYO,MAAAA,WAAW,GAAGC,wBAAkB,CAAC;AAAET,EAAAA,MAAAA;AAAF,CAAD,EAAtC;AAIA,SAASU,mBAAT,CACLC,KADK,EAELC,OAFK,EAQL;AACA,EAAA,IAAIC,YAAJ,CAAA;;AAOA,EAAI,IAAA,WAAA,IAAeD,OAAnB,EAA4B;AAC1BC,IAAAA,YAAY,GAAGD,OAAf,CAAA;AACD,GAFD,MAEO;AACLC,IAAAA,YAAY,GAAGC,cAAQ,CAACF,OAAD,CAAvB,CAAA;AACD,GAAA;;AAED,EAAA,IAAIG,eAAwC,GAAG,EAC7C,GAAGJ,KAAK,CAACC,OADoC;AAE7CI,IAAAA,KAAK,EAAE,EAFsC;AAElC;AACXC,IAAAA,aAAa,EAAE,MAAM,EAHwB;AAGpB;AACzBjB,IAAAA,MAJ6C;AAK7C,IAAGkB,GAAAA,SAAG,CAACL,YAAD,CAAA;AALuC,GAA/C,CAAA;AAQA,EAAA,IAAIM,QAAQ,GAAGC,yBAAuB,CAACL,eAAD,CAAtC,CAAA;AAEA,EAAIM,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,KAFD,CAAA;AAGD,GA5BgC,CAAjC,CAAA;AA8BA,EAAA,OAAOH,gBAAP,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/index.ts"],"sourcesContent":["import {\n createTableFactory,\n createTableInstance as coreCreateTableInstance,\n PartialKeys,\n Table,\n TableGenerics,\n TableOptions,\n} from '@tanstack/table-core'\nimport Placeholder from './placeholder.svelte'\nimport { SvelteComponent } from 'svelte/internal'\nimport { readable, writable, derived, Readable, get } from 'svelte/store'\nimport { renderComponent } from './render-component'\n\nexport { renderComponent } from './render-component'\n\nexport * from '@tanstack/table-core'\n\nfunction isSvelteServerComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$render === 'function' &&\n typeof component.render === 'function'\n )\n}\n\nfunction isSvelteClientComponent(component: any) {\n return component.prototype instanceof SvelteComponent\n}\n\nfunction isSvelteComponent(component: any) {\n if (typeof document === 'undefined') {\n return isSvelteServerComponent(component)\n } else {\n return isSvelteClientComponent(component)\n }\n}\n\nfunction wrapInPlaceholder(content: any) {\n return renderComponent(Placeholder, { content })\n}\n\nexport function render(component: any, props: any) {\n if (!component) return null\n\n if (isSvelteComponent(component)) {\n return renderComponent(component, props)\n }\n\n if (typeof component === 'function') {\n const result = component(props)\n\n if (isSvelteComponent(result)) {\n return result\n }\n\n return wrapInPlaceholder(result)\n }\n\n return wrapInPlaceholder(component)\n}\n\nexport const createTable = createTableFactory({ render })\n\ntype ReadableOrVal<T> = T | Readable<T>\n\nexport function createTableInstance<TGenerics extends TableGenerics>(\n table: Table<TGenerics>,\n options: ReadableOrVal<\n PartialKeys<\n Omit<TableOptions<TGenerics>, 'render'>,\n 'state' | 'onStateChange'\n >\n >\n) {\n let optionsStore: Readable<\n PartialKeys<\n Omit<TableOptions<TGenerics>, 'render'>,\n 'state' | 'onStateChange'\n >\n >\n\n if ('subscribe' in options) {\n optionsStore = options\n } else {\n optionsStore = readable(options)\n }\n\n let resolvedOptions: TableOptions<TGenerics> = {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n ...get(optionsStore),\n }\n\n let instance = coreCreateTableInstance(resolvedOptions)\n\n let stateStore = writable(/** @type {number} */ instance.initialState)\n // combine stores\n let stateOptionsStore = derived([stateStore, optionsStore], s => s)\n const instanceReadable = readable(instance, function start(set) {\n const unsubscribe = stateOptionsStore.subscribe(([state, options]) => {\n instance.setOptions(prev => {\n return {\n ...prev,\n ...options,\n state: { ...state, ...options.state },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n if (updater instanceof Function) {\n stateStore.update(updater)\n } else {\n stateStore.set(updater)\n }\n\n resolvedOptions.onStateChange?.(updater)\n },\n }\n })\n\n // it didn't seem to rerender without setting the instance\n set(instance)\n })\n\n return function stop() {\n unsubscribe()\n }\n })\n\n return instanceReadable\n}\n"],"names":["isSvelteServerComponent","component","$$render","render","isSvelteClientComponent","prototype","SvelteComponent","isSvelteComponent","document","wrapInPlaceholder","content","renderComponent","Placeholder","props","result","createTable","createTableFactory","createTableInstance","table","options","optionsStore","readable","resolvedOptions","state","onStateChange","get","instance","coreCreateTableInstance","stateStore","writable","initialState","stateOptionsStore","derived","s","instanceReadable","start","set","unsubscribe","subscribe","setOptions","prev","updater","Function","update","stop"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiBA,SAASA,uBAAT,CAAiCC,SAAjC,EAAiD;AAC/C,EAAA,OACE,OAAOA,SAAP,KAAqB,QAArB,IACA,OAAOA,SAAS,CAACC,QAAjB,KAA8B,UAD9B,IAEA,OAAOD,SAAS,CAACE,MAAjB,KAA4B,UAH9B,CAAA;AAKD,CAAA;;AAED,SAASC,uBAAT,CAAiCH,SAAjC,EAAiD;AAC/C,EAAA,OAAOA,SAAS,CAACI,SAAV,YAA+BC,wBAAtC,CAAA;AACD,CAAA;;AAED,SAASC,iBAAT,CAA2BN,SAA3B,EAA2C;AACzC,EA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CAAeK,OAAf,CAAA,CAAA;AACD,aAAA;;AAEDnB,YAAAA,eAAe,CAACE,aAAhB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAF,eAAe,CAACE,aAAhB,CAAgCiB,OAAhC,CAAA,CAAA;AACD,WAAA;AAdI,SAAP,CAAA;AAgBD,OAjBD,EADoE;;AAqBpEL,MAAAA,GAAG,CAACV,QAAD,CAAH,CAAA;AACD,KAtBmB,CAApB,CAAA;AAwBA,IAAO,OAAA,SAASkB,IAAT,GAAgB;AACrBP,MAAAA,WAAW,EAAA,CAAA;AACZ,KAFD,CAAA;AAGD,GA5BgC,CAAjC,CAAA;AA8BA,EAAA,OAAOH,gBAAP,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -2715,8 +2715,10 @@ const Headers = {
2715
2715
  }
2716
2716
  }),
2717
2717
  getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2718
- leafColumns = leafColumns.filter(column => left == null ? void 0 : left.includes(column.id));
2719
- return buildHeaderGroups(allColumns, leafColumns, instance, 'left');
2718
+ var _left$map$filter;
2719
+
2720
+ const orderedLeafColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2721
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2720
2722
  }, {
2721
2723
  key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
2722
2724
  debug: () => {
@@ -2726,8 +2728,10 @@ const Headers = {
2726
2728
  }
2727
2729
  }),
2728
2730
  getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2729
- leafColumns = leafColumns.filter(column => right == null ? void 0 : right.includes(column.id));
2730
- return buildHeaderGroups(allColumns, leafColumns, instance, 'right');
2731
+ var _right$map$filter;
2732
+
2733
+ const orderedLeafColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2734
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2731
2735
  }, {
2732
2736
  key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
2733
2737
  debug: () => {
@@ -3038,7 +3042,6 @@ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
3038
3042
  // data: Batch[]
3039
3043
  // facets: Batch[]
3040
3044
  // }
3041
- // export type TaskPriority = keyof CoreBatches
3042
3045
  function createTableInstance(options) {
3043
3046
  var _options$initialState;
3044
3047
 
@@ -3077,64 +3080,7 @@ function createTableInstance(options) {
3077
3080
  });
3078
3081
 
3079
3082
  const queued = [];
3080
- let queuedTimeout = false; // let workScheduled = false
3081
- // let working = false
3082
- // let latestCallback: ReturnType<typeof requestIdleCallback>
3083
- // let batchUid = 0
3084
- // const onProgress = () => {}
3085
- // const getBatch = () => {
3086
- // instance.batches.data = instance.batches.data.filter(d => d.tasks.length)
3087
- // instance.batches.facets = instance.batches.facets.filter(
3088
- // d => d.tasks.length
3089
- // )
3090
- // return (
3091
- // instance.batches.data.find(d => d.tasks.length) ??
3092
- // instance.batches.facets.find(d => d.tasks.length)
3093
- // )
3094
- // }
3095
- // const startWorkLoop = () => {
3096
- // working = true
3097
- // const workLoop = (deadline: IdleDeadline) => {
3098
- // const batch = getBatch()
3099
- // if (!batch) {
3100
- // working = false
3101
- // return
3102
- // }
3103
- // // Prioritize tasks
3104
- // while (deadline.timeRemaining() > 0 && batch.tasks.length) {
3105
- // batch.tasks.shift()!()
3106
- // }
3107
- // onProgress()
3108
- // if (working) {
3109
- // latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
3110
- // }
3111
- // }
3112
- // latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
3113
- // }
3114
- // const startWork = () => {
3115
- // if (getBatch() && !working) {
3116
- // if (
3117
- // (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
3118
- // instance.options.debugTable
3119
- // ) {
3120
- // console.info('Starting work...')
3121
- // }
3122
- // startWorkLoop()
3123
- // }
3124
- // }
3125
- // const stopWork = () => {
3126
- // if (working) {
3127
- // if (
3128
- // (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
3129
- // instance.options.debugTable
3130
- // ) {
3131
- // console.info('Stopping work...')
3132
- // }
3133
- // working = false
3134
- // cancelIdleCallback(latestCallback)
3135
- // }
3136
- // }
3137
-
3083
+ let queuedTimeout = false;
3138
3084
  const midInstance = { ...instance,
3139
3085
  // init: () => {
3140
3086
  // startWork()
@@ -3167,39 +3113,6 @@ function createTableInstance(options) {
3167
3113
  }));
3168
3114
  }
3169
3115
  },
3170
- // batches: {
3171
- // data: [],
3172
- // facets: [],
3173
- // },
3174
- // createBatch: priority => {
3175
- // const batchId = batchUid++
3176
- // let canceled: boolean
3177
- // const batch: Batch = {
3178
- // id: batchId,
3179
- // priority,
3180
- // tasks: [],
3181
- // schedule: cb => {
3182
- // if (canceled) return
3183
- // batch.tasks.push(cb)
3184
- // if (!working && !workScheduled) {
3185
- // workScheduled = true
3186
- // instance.queue(() => {
3187
- // workScheduled = false
3188
- // instance.setState(old => ({ ...old }))
3189
- // })
3190
- // }
3191
- // },
3192
- // cancel: () => {
3193
- // canceled = true
3194
- // batch.tasks = []
3195
- // instance.batches[priority] = instance.batches[priority].filter(
3196
- // b => b.id !== batchId
3197
- // )
3198
- // },
3199
- // }
3200
- // instance.batches[priority].push(batch)
3201
- // return batch
3202
- // },
3203
3116
  reset: () => {
3204
3117
  instance.setState(instance.initialState);
3205
3118
  },
@@ -3310,69 +3223,55 @@ function createTable(_, __, options) {
3310
3223
 
3311
3224
  function getCoreRowModel() {
3312
3225
  return instance => memo(() => [instance.options.data], data => {
3313
- // Access the row model using initial columns
3314
- const rows = [];
3315
- const flatRows = [];
3316
- const rowsById = {};
3317
- const leafColumns = instance.getAllLeafColumns();
3226
+ const rowModel = {
3227
+ rows: [],
3228
+ flatRows: [],
3229
+ rowsById: {}
3230
+ };
3231
+ let rows;
3232
+ let row;
3233
+ let originalRow;
3318
3234
 
3319
- const accessRow = function (originalRow, rowIndex, depth, parentRows, parent) {
3235
+ const accessRows = function (originalRows, depth, parent) {
3320
3236
  if (depth === void 0) {
3321
3237
  depth = 0;
3322
3238
  }
3323
3239
 
3324
- const id = instance.getRowId(originalRow, rowIndex, parent);
3325
-
3326
- if (!id) {
3327
- if (process.env.NODE_ENV !== 'production') {
3328
- throw new Error("getRowId expected an ID, but got " + id);
3329
- }
3330
- }
3331
-
3332
- const values = {};
3333
-
3334
- for (let i = 0; i < leafColumns.length; i++) {
3335
- const column = leafColumns[i];
3336
-
3337
- if (column && column.accessorFn) {
3338
- values[column.id] = column.accessorFn(originalRow, rowIndex);
3339
- }
3340
- } // Make the row
3240
+ rows = [];
3341
3241
 
3242
+ for (let i = 0; i < originalRows.length; i++) {
3243
+ originalRow = originalRows[i]; // This could be an expensive check at scale, so we should move it somewhere else, but where?
3244
+ // if (!id) {
3245
+ // if (process.env.NODE_ENV !== 'production') {
3246
+ // throw new Error(`getRowId expected an ID, but got ${id}`)
3247
+ // }
3248
+ // }
3249
+ // Make the row
3342
3250
 
3343
- const row = instance.createRow(id, originalRow, rowIndex, depth); // Push instance row into the parentRows array
3251
+ row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3344
3252
 
3345
- parentRows.push(row); // Keep track of every row in a flat array
3253
+ rowModel.flatRows.push(row); // Also keep track of every row by its ID
3346
3254
 
3347
- flatRows.push(row); // Also keep track of every row by its ID
3255
+ rowModel.rowsById[row.id] = row; // Push instance row into parent
3348
3256
 
3349
- rowsById[id] = row; // Get the original subrows
3257
+ rows.push(row); // Get the original subrows
3350
3258
 
3351
- if (instance.options.getSubRows) {
3352
- const originalSubRows = instance.options.getSubRows(originalRow, rowIndex); // Then recursively access them
3259
+ if (instance.options.getSubRows) {
3260
+ var _row$originalSubRows;
3353
3261
 
3354
- if (originalSubRows != null && originalSubRows.length) {
3355
- row.originalSubRows = originalSubRows;
3356
- const subRows = [];
3262
+ row.originalSubRows = instance.options.getSubRows(originalRow, i); // Then recursively access them
3357
3263
 
3358
- for (let i = 0; i < row.originalSubRows.length; i++) {
3359
- accessRow(row.originalSubRows[i], i, depth + 1, subRows, row);
3264
+ if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
3265
+ row.subRows = accessRows(row.originalSubRows, depth + 1, row);
3360
3266
  }
3361
-
3362
- row.subRows = subRows;
3363
3267
  }
3364
3268
  }
3365
- };
3366
-
3367
- for (let i = 0; i < data.length; i++) {
3368
- accessRow(data[i], i, 0, rows);
3369
- }
3370
3269
 
3371
- return {
3372
- rows,
3373
- flatRows,
3374
- rowsById
3270
+ return rows;
3375
3271
  };
3272
+
3273
+ rowModel.rows = accessRows(data);
3274
+ return rowModel;
3376
3275
  }, {
3377
3276
  key: process.env.NODE_ENV === 'development' && 'getRowModel',
3378
3277
  debug: () => {